feat: reduce NoteType to a 1 bit encoding and add metadata version#2691
Merged
PhilippGackstatter merged 5 commits intonextfrom Mar 30, 2026
Merged
feat: reduce NoteType to a 1 bit encoding and add metadata version#2691PhilippGackstatter merged 5 commits intonextfrom
NoteType to a 1 bit encoding and add metadata version#2691PhilippGackstatter merged 5 commits intonextfrom
Conversation
bobbinth
approved these changes
Mar 30, 2026
Contributor
bobbinth
left a comment
There was a problem hiding this comment.
Looks good! Thank you! I left a couple of small questions/comments inline.
Comment on lines
+405
to
+406
| let sender_suffix = | ||
| Felt::try_from(raw & 0xffff_ffff_ffff_ff00).expect("felt should still be valid"); |
Contributor
There was a problem hiding this comment.
Any reason to switch away from using SENDER_SUFFIX_MASK constant here?
Contributor
Author
There was a problem hiding this comment.
Previously we had:
const NOTE_TYPE_MASK: u8 = 0b11;
const SENDER_SUFFIX_MASK: u64 = !(NOTE_TYPE_MASK as u64);If we update the note type mask it would still technically work, but would be semantically incorrect because we'd also be extracting the version from the metadata (which happens to be 0 for now). So it seems better to explicitly mask out the least significant byte.
I brought back the constant for explicitness:
const SENDER_SUFFIX_MASK: u64 = 0xffff_ffff_ffff_ff00;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reduces
NoteTypeencoding from 2 bits to 1 bit and adds a 4-bit version field to the note metadata header, as a prerequisite for #2555 (multiple attachments per note). This frees up bits in the metadata header for future attachment metadata.Breaking change: The note metadata encoding (both Rust serialization and MASM Word layout) has changed.
This PR also implements
Default for NoteTypeby makingNoteType::Privatethe default - and we could do the same forAccountStorageMode::Privatewhen we get rid of theNetworkvariant. This makes derivingbon::builderfor notes (see #2283) even easier since we don't have to make the decision on what the default note type is for every note.New metadata layout
NoteType::Privatechanged from2to0(new default)NoteType::Publicremains10for forward compatibility