-
Notifications
You must be signed in to change notification settings - Fork 47
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
Implement advice inputs extender #993
Conversation
b9d1dd8
to
00d6d63
Compare
advice_inputs.extend_merkle_store( | ||
merkle_path.inner_nodes(account_id.into(), account_header.hash())?, | ||
); |
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.
The main question which I have is should we move this extension of the inputs with Merkle path out of this function. The reasons are:
merkle_path
requires themiden-crypto
to be imported.- obtaining the inner nodes requires the returning value to be a
Result<>
with theMerkleError
as an error type, which then should be somehow converted to theClientError
(maybe it is not a problem, I'm not sure)
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.
For the error, that would not be a problem. I think it should be fine to keep the merkle path inside the function. But more generally I wonder if those types should be re-exported from miden-objects
instead.
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.
Looks good to me, left some mostly minor comments with some suggestions and questions. Also, should this be added to the changelog? Even though it's a simple change it is user-facing
@@ -161,6 +160,50 @@ impl TransactionKernel { | |||
.expect("Invalid stack input") | |||
} | |||
|
|||
/// Extends the advice inputs with account data and Merkle proofs. | |||
pub fn extend_advice_inputs_for_account( |
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.
The FPI tests could use this function for extending the advice inputs now, right? And so then it would be tested as well
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 we can use it for FPI tests, but in that case merkle_path
should become an Option
. If it is not a problem, I can adjust this function to work with FPI.
miden-lib/src/transaction/mod.rs
Outdated
/// Extends the advice inputs with account data and Merkle proofs. | ||
pub fn extend_advice_inputs_for_account( |
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.
nit: It would b e nice to explain that merkle_path
should be a path that corresponds to the note root for the account tree of the transaction block header, since it has a generic name for a parameter.
advice_inputs.extend_merkle_store( | ||
merkle_path.inner_nodes(account_id.into(), account_header.hash())?, | ||
); |
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.
For the error, that would not be a problem. I think it should be fine to keep the merkle path inside the function. But more generally I wonder if those types should be re-exported from miden-objects
instead.
miden-lib/src/transaction/mod.rs
Outdated
foreign_id_root, | ||
[ | ||
&foreign_id_and_nonce, | ||
vault_root.as_elements(), | ||
storage_root.as_elements(), | ||
code_root.as_elements(), | ||
] | ||
.concat(), |
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.
Should this be AccountHeader::as_elements()
as well? Not sure if that makes sense but it does seem more in line with the others since it does encode all the header information as well
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 agree!
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.
Looks good! Thank you! I left one comment re clarifying one of the comments.
miden-lib/src/transaction/mod.rs
Outdated
/// - merkle_path is the path which corresponds to the note root for the account tree of the | ||
/// transaction block header. | ||
pub fn extend_advice_inputs_for_account( |
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 didn't fully understand what merkle_path
is supposed to represent. How is it related to note_root
? As far as I remember, account tree contains just accounts and does not have note roots in it.
Also, would be good to explain why it can be optional.
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.
Probably the definition from the miden-client
should explain this variable better: Authentication path from the account_root of the block header to the account.
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.
Ah I see my comment in this PR said "note root". I meant to write "account root", sorry.
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.
LGTM!
333c39b
to
20186fd
Compare
… merkle path of foreign account
20186fd
to
115648b
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.
Looks good! Thank you! I left a couple more small comments inline. After these are addressed, we can merge.
9f797b5
to
baf1c10
Compare
baf1c10
to
d3a2db7
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.
Looks good! Thank you! I left a few more small comments inline. Once these are addressed, we can merge.
5091ba2
to
68322b3
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.
Looks good! Thank you!
This PR implements a new function in
TransactionKernel
which extends the advice inputs with the provided account data and Merkle proofs.Closes: #961