Skip to content

fix(node): share the current accumulator, not the first one dumped - #163

Merged
jvsena42 merged 1 commit into
mainfrom
fix/share-validation-stale-accumulator
Sep 20, 2026
Merged

jvsena42 merged 1 commit into
mainfrom
fix/share-validation-stale-accumulator

Conversation

@jvsena42

Copy link
Copy Markdown
Owner

Found while checking the "Share validation" card on the emulator; independent of the FiltersMan work (#162).

The bug

  • withExportPayload kept the first Utreexo dump in exportPayload and returned it for the rest of the session. Show QR, Copy and Share all handed out the accumulator from whenever one of them was first tapped. On a mainnet node that had been running since the morning, the node was at height 967,875 (3,201,422,762 leaves, 19 roots) while the copied payload decoded to height 967,818 (3,201,204,366 leaves, 16 roots): valid, right network, 57 blocks stale. A device importing it starts that far behind.
  • Copy wrote uiState.exportPayload to the clipboard synchronously, before the asynchronous dump finished. The first tap showed "Copied to clipboard" and copied nothing; later taps copied the previous payload.

The node itself is fine: over RPC the accumulator moves with every validated block (leaf count and all roots change).

The fix

  • Dump on every use. dumpUtreexoState only reads the chain state, so there is nothing worth caching; exportPayload still holds the latest dump for the QR sheet.
  • The payload reaches the clipboard through a new NodeEvents.OnCopyAccumulator event, the same way Share already works.

Tests

NodeViewModelExportTest: two consecutive copies deliver two different dumps, the first copy already carries a payload, and reopening the QR sheet shows a fresh dump. Two of the three fail against the old caching code.

./gradlew testDebugUnitTest detekt pass. Not re-checked on the emulator: the build installed there carries the unmerged node bindings on a throwaway branch.

🤖 Generated with Claude Code

The "Share validation" card kept the first Utreexo dump in
`exportPayload` and handed it out for the rest of the session: Show QR,
Copy and Share all returned the accumulator from whenever one of them
was first tapped. On a node that had been running for a day the copied
payload was 57 blocks behind, so the device importing it started that
far back. Dump on every use instead; it only reads the chain state.

Copy also wrote `uiState.exportPayload` to the clipboard synchronously,
before the asynchronous dump had finished. The first tap showed "Copied
to clipboard" without copying anything, and later taps copied the
previous payload. The payload now reaches the clipboard through a
`NodeEvents.OnCopyAccumulator` event, like Share already does.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jvsena42
jvsena42 enabled auto-merge (rebase) September 20, 2026 18:57
@jvsena42
jvsena42 merged commit 1d34fe7 into main Sep 20, 2026
2 checks passed
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.

1 participant