-
Notifications
You must be signed in to change notification settings - Fork 42
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
Note objects and structure refactoring #350
Comments
I'm still not 100% familiar with how exactly all of these are used, when and why, so my input is limited. A few things:
pub struct Note {
script: NoteScript,
inputs: NoteInputs,
vault: NoteVault,
serial_num: Word,
} Methods who also need the metadata can receive it in another argument. What I like about this is that Applying the same logic, you wouldn't need
Finally, I would try to use newtypes for hashes instead of |
Nice issue, and cool that we are constantly maintaining.
Isn't hash(note_hash, metadata) the same as
That makes a lot of sense to me.
Makes sense to me as well. Renaming this will make it easier to understand.
That makes sense. However, maybe it is even clearer when we say
This will make it clearer! |
Agreed - I've already started doing it here and here.
It is not a perfect name, but I couldn't come up with a better one. The way it is computed is defined here. The basic rational is that a combination of
This is also not a perfect name, and similarly, I wasn't able to come up with a better name yet. The idea here is that this is the minimal amount of data which is known publicly about a note (more concretely, this is what is stored in the leaves of note trees). It is a direct replacement for
I'm not sure we can do it this way. In many cases metadata goes together with the note, and we'll just end up passing tuples of One thing I was thinking about which could make definition of things like
What do you think about this approach?
This combines two things: (1) the block in which the note was recorded in (i.e., its place in Chain MMR), and (2) which index in the block's note tree the note is at. i'm not sure
I was thinking of moving these into
We could, but then I'm not really sure we'd use
I think this should be OK as missing a letter would be caught by the compiler. |
Right, I understand better why
Few ideas that come to mind:
If we feel a bit silly:
Much much better! I think this removes all confusion.
I was thinking more along the lines of: if we have another object that fits the same structure of needing a block index &
👍 |
With the recent refactorings, a big part of what is described in this issue is already done. Specifically:
Out of things that remain from the original post we have:
However, one other thing came up in #380 (comment). Specifically, we may want to create a pub struct Note {
script: NoteScript,
inputs: NoteInputs,
assets: NoteAssets,
serial_num: Word,
} We can then update the pub struct InputNote {
note: Note,
metadata: NoteMetadata,
location: NoteLocation,
proof: MerklePath,
} We still probably want to have a struct which encapsulates the note together with its metadata (but without the location/proof) - though, I don't love the |
Let's break it down with the remaining tasks,m then ppl can pick it up Monday |
Here are some ideas Add explicit structure to hold hashed dataFor example, struct NoteNullifier {
serial_number: SerialNumber,
script: NoteScript,
inputs: NoteInputs,
assets: NoteAssets
} The wrapper type represents the blinded version, which is used often in the protocol, so we need a way to express it. The full version represents the values when they are being created, and sometimes consumed. We need all the data to compute the hash in the first place, so it also makes sense to have these structures. Another example here is the If we have this split, we can implement traits to compute the digest see. And the code follows more close the protocol. The crypto structures should have generic containersTypes like |
Wouldn't The situation with |
With the approach I proposed above, the struct: pub struct NoteDetails {
assets: NoteAssets,
recipient: NoteRecipient,
} Corresponds to: miden-base/objects/src/notes/note_id.rs Lines 15 to 17 in 1307080
So not quite the |
|
There are use cases where users don't know the serial number to construct a ProposalChange the This change would be obviously a breaking one since all This change would be obviously a breaking one since all note: discussion on discord here https://discord.com/channels/893151281848406016/1114419272165376030/1247871953767895120 |
I will look into this in more detail tomorrow, but I'm curious if the PartialNote is the more appropriate object to use here. |
Thank you! I didn't know about |
Yes, I think this should be possible. Let me think through what changes this would imply. Also, cc @igamigo as this will probably result in more changes in the client rather than in |
Looking into this more, I think we might already have everything that we need on the pub enum ExpectedNote {
Full(Note),
Partial(PartialNote),
} @igamigo - what do you think? |
Yeah, sounds right. I'll be implementing this soon. EDIT: Implemented some of this but found out that we are missing some mechanism to extend the transaction arguments accordingly. Additionally, we might want to add a |
Yeah - it seems like some changes in One way to do it is to define pub enum ExpectedNote {
Full(NoteDetails),
Partial(Digest, NoteAssets),
} But there could be other ways to do this as well. @daedlock - one question: this feature seems to be useful only for private notes. For public notes, the users would always be able to get full note details from the chain. Or are you thinking of using this with public notes as well somehow? |
I was planning to use this with public notes but it turns out it's not entirely needed as I ended up exposing the note serial through the backend (since I learned it's already public for public notes). However, we are also planning to have private limit orders in the near future where the |
Most of the refactorings described in this issue are now done. What remains is:
|
We have quite a few structs which describe different aspects of notes. Specifically:
Note
,NoteEnvelope
,NoteOrigin
,RecordedNote
,NoteInclusionProof
,NoteStub
,CreatedNotes
,ConsumedNotes
,ConsumedNoteInfo
, and maybe others. I think naming and relations between these structs have becomes somewhat unintuitive and also we have some obsolete concepts which we need to remove and some changes we'd like to make. So, in this issue I'll try to describe which changes I think we could make to the overall note structure. Any feedback is welcome.Note
structCurrently this struct looks like so:
I think the structure is fine, but what bothers me a little is how we treat the metadata field. Specifically, here
metadata
is considered to be a part of the note, but when we insert notes into the note tree, metadata goes into a different leaf. I think we should come up with a name for entity defined byhash(note_hash, metadata)
and then this entity should be inserted into a single leaf in the notes tree.Open question: how should we name this entity?
NoteStub
structThe
Note
struct described above contains all information about a note. However, sometimes we may have minimal info about a note. I would call a struct which contains such info aNoteStub
. This struct could look like so:NoteLocation
structI would rename the current
NoteOrigin
struct intoNoteLocation
struct as I think it better describes the data contained in this struct (i.e., the location of the note in the chain). The struct would look like this:InputNote
structI would replace
RecordedNote
andNoteInclusionProof
structs with a singleInputNote
struct which would look like so:The purpose of this struct would be to provide note info for notes consumed in a transaction.
This is slightly different from the combination of the two mentioned structs in that it doesn't include
sub_hash
andnote_root
fields, but I think these should not be a part of the note info anyway.OutputNote
structThis struct would replace the current
NoteStub
struct, and it would look as follows:InputNotes
andOutputNotes
structsThese structs could replace
ConsumedNotes
andCreatedNotes
structs. They could look like so:Nullifier
structLastly, I would replace
ConsumedNoteInfo
withNullifier
struct which would look simply like:Since we've migrated to dynamic note script invocation, I don't believe
ConsumedNoteInfo
is needed, and we actually should update the transaction kernel to work with justNullifiers
for consumed notes.The text was updated successfully, but these errors were encountered: