-
Notifications
You must be signed in to change notification settings - Fork 311
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
chore(contracts): Calculate public call stack item hash from Noir #1141
Conversation
@@ -246,15 +260,42 @@ struct PublicCircuitPublicInputs { | |||
new_commitments: [Field; MAX_NEW_COMMITMENTS_PER_CALL], | |||
new_nullifiers: [Field; crate::abi::MAX_NEW_NULLIFIERS_PER_CALL], | |||
new_l2_to_l1_msgs: [Field; crate::abi::MAX_NEW_L2_TO_L1_MSGS_PER_CALL], | |||
commitment_trees_roots: CommitmentTreesRoots, | |||
commitment_trees_roots: CommitmentTreesRoots, // TODO: This is not present in cpp or ts, do we need to include it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Maddiaa0 I noted this field was added in Noir but has no counterpart in cpp. Should we add it there as well, so the two structs don't diverge?
1dded6d
to
70be9bd
Compare
✅ Deploy Preview for preeminent-bienenstitch-606ad0 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
/** | ||
* Alias for toBuffer32. | ||
* @returns A 32-byte Buffer containing the padded Ethereum address. | ||
*/ | ||
public toBuffer() { | ||
return this.toBuffer32(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Serializing EthAddress to 20 bytes by default was causing issues with serialization to/from cpp (yay). Msgpack autobindings were calling toBuffer on this field for serializing, which returned 20 bytes, but cpp was expecting 32. This resulted in the eth address being left or right aligned in cpp depending on how it got there. This was not uncovered before because eth address deserialization handled both cases, but when we started hashing this field in cpp, the difference started to show.
Please add 4hs to the counter of "time lost due to serialization issues"!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💀💀💀
c7955b3
to
cad0757
Compare
cad0757
to
1fd762f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a minor comment. Great job!
constexpr size_t PUBLIC_CIRCUIT_PUBLIC_INPUTS_HASH_INPUT_LENGTH = | ||
2 + RETURN_VALUES_LENGTH + // + 1 for args_hash + 1 call_context.hash | ||
MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL + MAX_PUBLIC_DATA_READS_PER_CALL + MAX_PUBLIC_CALL_STACK_LENGTH_PER_CALL + | ||
MAX_NEW_COMMITMENTS_PER_CALL + MAX_NEW_NULLIFIERS_PER_CALL + MAX_NEW_L2_TO_L1_MSGS_PER_CALL + 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would help readability if you describe why is there the +5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. I will add it on a subsequent PR, for now I want to merge this one before I keep getting conflicts!
Removes a longstanding TODO to calculate the call stack item hash (for enqueued public calls) correctly in Noir, instead of overwriting it in
private_execution
. This required changing severalhash
methods in cpp fromNCT::compress
toNCT::hash
, so they match the Pedersen flavor used in Noir (cc @suyash67).