-
Notifications
You must be signed in to change notification settings - Fork 57
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
Conversation
# Conflicts: # CHANGELOG.md
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 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?
This is only breaking for 0xPolygonMiden/miden-node#421 |
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! I agree with these changes. I'd also favor removing NoteLocation
altogether, but don't mind either way.
objects/src/notes/location.rs
Outdated
|
||
impl NoteInclusionProof { | ||
/// Returns a new [NoteInclusionProof]. | ||
pub fn new(block_num: u32, index: u64, note_path: MerklePath) -> Result<Self, NoteError> { |
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 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.
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.
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.
…:leaf_index` return `u32`
a912557
to
47007c7
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 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.
objects/src/notes/location.rs
Outdated
/// 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 | ||
} |
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 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).
objects/src/constants.rs
Outdated
/// 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; |
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'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.
Resolves: #781
Here I renamed
NoteOrigin
toNoteLocation
, simplified node index field tou32
(haven't succeed with note trees depth reduction, will try these reductions next). Removed block's sub-hash and note root fromNoteInclusionProof
.