Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add serialization for TransactionRequest #471

Merged
merged 9 commits into from
Aug 13, 2024

Conversation

tomyrd
Copy link
Collaborator

@tomyrd tomyrd commented Aug 7, 2024

closes #466

This PR implements serialization to and from bytes for TransactionRequest. Some tests are also added to verify a correct serialization.

When comparing if the deserialized TransactionRequest is the same, we are ommitting the ProgramAst code as we found that they were not the same. The difference was mentioned by a comment in miden-vm, which was later removed in v0.10. Once the client is updated to the new vm version we can add back the check to see if the problem persists.

@tomyrd tomyrd force-pushed the tomyrd-tx-request-serialization branch from 7a14d70 to c587460 Compare August 7, 2024 16:10
@tomyrd tomyrd marked this pull request as ready for review August 7, 2024 16:44
Copy link
Collaborator

@igamigo igamigo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Left a couple of non-blocking minor comments

let same_script_template = match &self.script_template {
Some(TransactionScriptTemplate::CustomScript(script)) => match &other.script_template {
Some(TransactionScriptTemplate::CustomScript(other_script)) => {
// TODO: We should also compare the source code. However, the ProgramAst
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should warn!("Checking equality for TransactionRequests does not involve comparing the source code") here so that it does not go unnoticed until the TODO is addressed.

@igamigo igamigo requested a review from bobbinth August 7, 2024 17:25
}
self.expected_output_notes.write_into(target);
self.expected_future_notes.write_into(target);
self.advice_map.clone().into_iter().collect::<Vec<_>>().write_into(target);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to avoid cloning the advice map here?

Copy link
Collaborator Author

@tomyrd tomyrd Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AdviceMap only implements IntoIter so we have to consume the map to iterate it. In this case the map is a reference which we can't consume. If we don't want to clone it the two alternatives that I can think of would be to:

  • Implement deserialization for AdviceMap so we can use write_into.
  • Implement .iter() to iterate over a reference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both of these would need to be done in miden-vm - right? If so, let's keep it like it is now, add a TODO here and create an issue for this in the miden-vm repo.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@igamigo igamigo merged commit 04f29a6 into next Aug 13, 2024
13 checks passed
@igamigo igamigo deleted the tomyrd-tx-request-serialization branch August 13, 2024 14:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants