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

Refactored NoteOrigin and NoteInclusionProof structs #810

Merged
merged 9 commits into from
Aug 2, 2024

Conversation

polydez
Copy link
Contributor

@polydez polydez commented Jul 31, 2024

Resolves: #781

Here I renamed NoteOrigin to NoteLocation, simplified node index field to u32 (haven't succeed with note trees depth reduction, will try these reductions next). Removed block's sub-hash and note root from NoteInclusionProof.

@polydez polydez requested a review from bobbinth July 31, 2024 18:26
@bobbinth bobbinth requested a review from igamigo August 1, 2024 08:58
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 comments inline and also tagged @igamigo for review as I think this is a breaking change for the client.

Lastly, could you check if this is a breaking change for the node as well?

CHANGELOG.md Outdated Show resolved Hide resolved
objects/src/notes/location.rs Outdated Show resolved Hide resolved
objects/src/notes/location.rs Outdated Show resolved Hide resolved
miden-lib/src/transaction/inputs.rs Outdated Show resolved Hide resolved
@polydez
Copy link
Contributor Author

polydez commented Aug 1, 2024

Lastly, could you check if this is a breaking change for the node as well?

This is only breaking for 0xPolygonMiden/miden-node#421

@polydez polydez requested a review from bobbinth August 1, 2024 13: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.

LGTM! I agree with these changes. I'd also favor removing NoteLocation altogether, but don't mind either way.


impl NoteInclusionProof {
/// Returns a new [NoteInclusionProof].
pub fn new(block_num: u32, index: u64, note_path: MerklePath) -> Result<Self, NoteError> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should index be u32 instead of u64? I see that BlockNoteIndex::to_absolute_index() returns u64 as well but u32 should be enough there as well I think.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now maximum note index can be 2^12 * 2^8 - 1 = 2^20 - 1 so it fits to u32. Actually we're trying to reduce this index even to u16 by reducing tree depth. Anyway, this is good catch, I will try to make to_absolute_index return u32 as well.

@polydez polydez force-pushed the polydez-incl-proofs-simplyfication branch from a912557 to 47007c7 Compare August 1, 2024 14:57
objects/src/constants.rs Outdated Show resolved Hide resolved
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 just a couple of small comments inline.

Also, before merging this PR - let's make sure we have a corresponding PR that undoes the breaking changes ready on the node.

Comment on lines 23 to 26
/// Returns the index of the note in the note Merkle tree of the block the note was created in.
pub fn node_index(&self) -> u64 {
self.node_index_in_block as u64
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add to the doc comment a bit more info about the returned value. Specifically, we should say what the height of the tree is and what the maximum value is.

Once we reduce the height of the tree to 16, this will be less ambiguous as we can simply return u16 or LeafIndex<16> (this will be even cleaner, I think).

Comment on lines 4 to 5
/// The depth of the Merkle tree used to commit to notes produced in a block.
pub const NOTE_TREE_DEPTH: u8 = 20;
pub const OUTPUT_NOTE_TREE_DEPTH: u8 = 20;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure we need to do this (and other related) renaming. The note tree in a block contains just notes - these are output notes at some point and input notes at another point. Also, there isn't really a concept of an "input note tree" - so, just "note tree" is unambiguous, I think.

@polydez polydez merged commit 5d61865 into next Aug 2, 2024
13 checks passed
@polydez polydez deleted the polydez-incl-proofs-simplyfication branch August 2, 2024 04:07
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