-
Notifications
You must be signed in to change notification settings - Fork 32
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 NoteFile
importing/exporting
#371
Comments
I would probably rename First, we now have an option to import a note in 3 different states: note ID, note details, and full note with inclusion path. Here is how I think these cases can be handled (some of these things are already done):
As a result of the above, the
So, at the end of the state sync request (once we synced to the chain tip) we would need to deal with some of these notes separately (i.e., handle the "leftover notes" as introduced in #361). The cases we care about are as follows:
Two important things to note here:
Overall, the pub async fn import_note(
&mut self,
note: NoteFile,
) -> Result<InputNoteRecord, ClientError> Separately, I would consider renaming |
What's an example of the second case? Is it a note which we don't know its tag? Or a note tag that we want to ignore?
In terms of Right now we always try to get the inclusion path of an imported note (with a combination of calls to |
I already started working on this ( #375 ). Right now I just added the basics so that the client works with the new faucet. I can add more functionality to it once we decided how to treat each case (especially the |
It can actually be both (i.e., we either don't know the tag, or we know the tag but don't want to add it to the list of tags which are tracked regularly). I don't have a great example for this, but I can imagine someone sending me a
Yes - but it also depends on how much data we already have in the client for a given note.
Yes, except for the NoteFile::NoteId` case, we don't make requests to the node on import and try to "hydrate" the note on sync. If the note is a "tracked" note, this could happen naturally during the sync process. But there can also be cases when the user may need to do it manually (i.e., the imported tracked note is "in the past" with respect to the current sync height).
I think right now there is a |
You are right, there is a |
I'll start working on adding this changes to #375. I also created a PR in miden-base to add the tag to I have a question about the tag in |
I think the user could eventually verify the validity by retrieving the real metadata from the node. However, this might defeat the purpose of sending the tag anyway (hiding the interest on a specific I'm not totally convinced adding the |
If we don't add the About this last case (untracked notes) should the |
That's how I was thinking about it: we wouldn't add the tag to the list of tags but would rather use it to figure out if a given note is tracked. We could still store the imported tag with the note and the overwrite it (together with the rest of metadata) once the actual note gets retrieved.
I was thinking we'd do it on every sync for now. In the future, we could have a more sophisticated strategy where we implement some kind of backoff strategy. Another option is to leave management of the leftover notes to the user (i.e., CLI in our case). For example, the client could have a method for trying to retrieve leftover notes, but this method would be invoked by CLI rather than by the client automatically. |
I think I may have gotten a little bit lost with this one:
I think I'm confusing the tag that comes with the We store the file tags separate from the persistent list of tags (the ones that are stored+tracked in the client). When doing a sync we add all the file tags to the note_tags sent to the node. When the metadata for imported+tracked notes we discard the file tag in favor of the metadata tag. |
Sorry, I should have described it more clearly. Here is how I'm thinking about it: When we import When doing the sync, we don't do anything extra with the file tags - but we do make a separate call to get notes by ID for the untracked notes. Any note which we get data for from the node, we update in the So, basically, there is not separate place in which we'd store file tags - they are stored together with the imported notes. |
Some questions/comments @bobbinth:
|
We need the file tag to determine if we already track the note or not. Or said another way, without the file tag, we wouldn't be able to tell if the note is already covered by existing flags.
We could do this, but it adds complexity. For example, if the user adds a "permanent" tag which would be the same as "ephemeral" tag, we need to make sure to keep it after the note with the "ephemeral" tag is retrieved. In general, I'm trying to keep things relatively simple in the client to make it less "opinionated" (and move some of the "orchestration" logic into the CLI). But maybe the complexity here is not as big as I'm imagining.
Let's say the client is tracking tags
I think we should always overwrite note metadata with the data we get from the node. That is, until we get the note from the node, we can't be sure if the metadata we got from
Regarding
There are two ways of adding tags to this list:
In vast majority of the cases, the user would get notes matching these tags. Most of the discussion above is about handling edge cases when the file tag does not match any of the tracked tags (and this should be a very rare exception). |
Ah, OK, I understand better now. Thanks for explaining!
Is this true?
I agree with making it less opinionated and having the CLI represent only one perspective of how to handle things. To clarify though, I think this could be solved in a simpler way: On sync requests, we can just group all For reference, this is how account tags are currently handled - they are not included in the user's list of tags, we force-add them to the sync's list of tags on each request, regardless of the user's settings. |
I tried to summerize all of the changes, tell me if I missunderstood something:
Also, just to be clear, ephemeral tags are tags that are not in the tag table and are not inferred from the tracked accounts but are still added separately to the status request to the node. Currently these would be the tags of uncommitted notes I'll edit this message with the corrections as they come so we have a clear and centralized list. |
Ah yes - that's correct.
One correction here: we would always insert it as a
This is a good point. We may end up with some
I'm thinking maybe we should move the "automation" part here to the CLI - i.e., the client would not try to retrieve the data for untracked notes as a part of it its sync request, but maybe the CLI would instruct the client (potentially via a separate method) to retrieve the untracked notes.
I think the issue with
Assuming we don't have |
Another question, what would be the benefits of not requesting the block header in the import for notes that we know are commited ( |
For notes that have inclusion proof, they could be either in a future block or a past block compared to the client (or I guess at the same block height, but this is not an interesting case as it's solved by default). In any case they would be marked as
we should be fine. Otherwise, for example, importing would possibly imply a sync (in the case of the note being in a future block) which is undesirable as Bobbin mentioned. |
Got it, we want to create a better separation between the import and sync. I was thinking about the implementation of the tracked/untracked note mark in the store. I find that name a little confusing as untracked notes are technically tracked by the client as they are in the database, maybe calling them acknowledged/ignored notes is better? The ignored notes are not updated in the
For this we could add a |
There's one thing I realized after working on the integration tests fixes for this new features. Most of the If this ends up being the case, most of the imported notes will be retrieved "manually" with |
That shouldn't be the case as most of the time the imported note's tags should match a tag derived from one of the tracked accounts. The flow that I think would be the most common:
Separately, reading through the discussion above, I'm still not super happy with where we are landing - it feels like there is too much complexity and different combinations of various states/conditions. This will get even more complex once we need to support 0xPolygonMiden/miden-base#353 on the client (i.e., we'll be able to create transactions consuming notes which have not been recorded on chain yet). I'll try to think through this more to see if there is a clean way to organize all of this. |
I think I found an edge case that can't be resolved from what I've gathered in the summary. In this part we specify what to do if the imported
The problem with this is that the |
I probably could have described it more clearly in #371 (comment), but there are actually two paths here for importing via
So, the edge case should be covered by the second path - unless I'm missing something. |
should we close this since #375 got merged? |
Closed as done by #375! |
What should be done?
Following 0xPolygonMiden/miden-base#721,
NoteFile
will be the type used for importing/exporting notes from applications like the faucet, so we need to implement importing and exporting features from the client.How should it be done?
Client::import_input_note()
to takeNoteFile
InputNoteRecord
(eventually we might be able to replace this struct with the new one)miden export
andmiden import
to work withNoteFile
binary filesWhen is this task done?
When importing and exporting to and from files happens with
NoteFile
instead ofInputNoteRecord
Additional context
No response
The text was updated successfully, but these errors were encountered: