Skip to content

feat(note-transport): add nonce to FetchNotes cursor - #2640

Open
kkovaacs wants to merge 3 commits into
krisztian/note-transport-importfrom
krisztian/note-transport-add-cursor-nonce
Open

kkovaacs wants to merge 3 commits into
krisztian/note-transport-importfrom
krisztian/note-transport-add-cursor-nonce

Conversation

@kkovaacs

Copy link
Copy Markdown
Collaborator

Summary

Replace scalar cursors with a fixed64 nonce and sequence. Persist the nonce across restarts and return FAILED_PRECONDITION for cursors from a replaced database. Includes migration, regression tests, and updated documentation.

This is a solution to the issue where after a catastrophic event (eg. losing the note transport databse) clients get stuck receiving new notes because they're using invalid cursors. For a more detailed description please check 0xMiden/note-transport-service#97.

Changelog

[[entry]]
scope       = "note-transport"
impact      = "breaking"
description = "Changed FetchNotes cursor to a structured message containing a nonce."

@kkovaacs
kkovaacs force-pushed the krisztian/note-transport-add-cursor-nonce branch from 5efe58d to a9a30dd Compare September 17, 2026 12:04
@kkovaacs
kkovaacs marked this pull request as ready for review September 17, 2026 12:05

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: the doc comments are 1-line per sentence in parts here which is weird.

I think in general the docs here should be clearer e.g. avoid terms like generation and other implementation details.

We should communicate that a nonce identifies a stable sequence, and that a change in the server's nonce (e.g. if the database is reset) invalidates the current cursor, requiring a resync from scratch.

Perhaps we can also enforce the tag change == cursor invalidation, by hashing database nonce with the provided tags? That way changing tags also invalidates the cursor? If we believe this isn't expensive because we don't retain much data, then this could be a good way to enforce this API?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Nit: the doc comments are 1-line per sentence in parts here which is weird.

I've updated the docs, I hope it's a bit better now.

Perhaps we can also enforce the tag change == cursor invalidation, by hashing database nonce with the provided tags? That way changing tags also invalidates the cursor? If we believe this isn't expensive because we don't retain much data, then this could be a good way to enforce this API?

I think that would make it pretty much impossible to implement the logic the client is implementing now when a new account (-> new tag) is added. @igamigo might have more accurate information.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think that would make it pretty much impossible to implement the logic the client is implementing now when a new account (-> new tag) is added. @igamigo might have more accurate information.

My thinking was that we could make the cursor completely opaque if we do this, and also force correct API usage.

This assumes that resyncing is "cheap" for both client and server or that adding an account/tag is a fairly rare operation.

@kkovaacs
kkovaacs force-pushed the krisztian/note-transport-import branch from 618fe3b to a2ac09b Compare September 17, 2026 14:12
@kkovaacs
kkovaacs force-pushed the krisztian/note-transport-add-cursor-nonce branch 2 times, most recently from bd268b8 to bb3d853 Compare September 18, 2026 05:42
@kkovaacs
kkovaacs force-pushed the krisztian/note-transport-import branch from bb02984 to fc0cb8e Compare September 18, 2026 06:28
@kkovaacs
kkovaacs force-pushed the krisztian/note-transport-add-cursor-nonce branch from bb3d853 to 97a48aa Compare September 18, 2026 06:33
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.

2 participants