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

Implement advice inputs extender #993

Merged
merged 7 commits into from
Dec 1, 2024
Merged

Conversation

Fumuran
Copy link
Contributor

@Fumuran Fumuran commented Nov 28, 2024

This PR implements a new function in TransactionKernel which extends the advice inputs with the provided account data and Merkle proofs.

Closes: #961

@Fumuran Fumuran added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Nov 28, 2024
@Fumuran Fumuran force-pushed the andrew-fpi-setup-improvements branch from b9d1dd8 to 00d6d63 Compare November 28, 2024 15:24
Comment on lines +200 to +196
advice_inputs.extend_merkle_store(
merkle_path.inner_nodes(account_id.into(), account_header.hash())?,
);
Copy link
Contributor Author

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 the miden-crypto to be imported.
  • obtaining the inner nodes requires the returning value to be a Result<> with the MerkleError as an error type, which then should be somehow converted to the ClientError (maybe it is not a problem, I'm not sure)

Copy link
Collaborator

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.

@Fumuran Fumuran marked this pull request as ready for review November 28, 2024 15:34
@Fumuran Fumuran requested review from bobbinth and igamigo November 28, 2024 15:34
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.

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(
Copy link
Collaborator

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

Copy link
Contributor Author

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.

Comment on lines 163 to 171
/// Extends the advice inputs with account data and Merkle proofs.
pub fn extend_advice_inputs_for_account(
Copy link
Collaborator

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.

Comment on lines +200 to +196
advice_inputs.extend_merkle_store(
merkle_path.inner_nodes(account_id.into(), account_header.hash())?,
);
Copy link
Collaborator

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.

Comment on lines 184 to 191
foreign_id_root,
[
&foreign_id_and_nonce,
vault_root.as_elements(),
storage_root.as_elements(),
code_root.as_elements(),
]
.concat(),
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree!

Copy link
Contributor

@bobbinth bobbinth left a 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.

Comment on lines 169 to 171
/// - 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(
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

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!

@Fumuran Fumuran force-pushed the andrew-fpi-setup-improvements branch from 333c39b to 20186fd Compare November 30, 2024 00:54
@Fumuran Fumuran requested a review from bobbinth November 30, 2024 00:55
@Fumuran Fumuran force-pushed the andrew-fpi-setup-improvements branch from 20186fd to 115648b Compare November 30, 2024 00:59
Copy link
Contributor

@bobbinth bobbinth left a 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.

objects/src/accounts/storage/header.rs Outdated Show resolved Hide resolved
miden-lib/src/transaction/mod.rs Outdated Show resolved Hide resolved
@Fumuran Fumuran force-pushed the andrew-fpi-setup-improvements branch from 9f797b5 to baf1c10 Compare November 30, 2024 11:09
@Fumuran Fumuran force-pushed the andrew-fpi-setup-improvements branch from baf1c10 to d3a2db7 Compare November 30, 2024 11:14
@Fumuran Fumuran requested a review from bobbinth November 30, 2024 22:59
Copy link
Contributor

@bobbinth bobbinth left a 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.

objects/src/accounts/storage/header.rs Outdated Show resolved Hide resolved
objects/src/accounts/storage/header.rs Outdated Show resolved Hide resolved
objects/src/accounts/storage/mod.rs Outdated Show resolved Hide resolved
@Fumuran Fumuran force-pushed the andrew-fpi-setup-improvements branch from 5091ba2 to 68322b3 Compare December 1, 2024 22:24
Copy link
Contributor

@bobbinth bobbinth left a 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!

@Fumuran Fumuran merged commit d3ddfad into next Dec 1, 2024
9 checks passed
@Fumuran Fumuran deleted the andrew-fpi-setup-improvements branch December 1, 2024 22:45
@Fumuran Fumuran mentioned this pull request Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog This PR does not require an entry in the `CHANGELOG.md` file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants