Skip to content

repro: transparent discovery persists addresses and loses scan targets when a later scope fails - #2729

Draft
dorianvp wants to merge 1 commit into
devfrom
repro/transparent-discovery-partial-persist-on-error
Draft

repro: transparent discovery persists addresses and loses scan targets when a later scope fails#2729
dorianvp wants to merge 1 commit into
devfrom
repro/transparent-discovery-partial-persist-on-error

Conversation

@dorianvp

Copy link
Copy Markdown
Member

Claim

pepper-sync/src/sync/transparent.rs, update_addresses_and_scan_targets (lines 26-185). Per scope, new addresses are derived and queried one gRPC call at a time (lines 125-159). The addresses discovered for a scope are written into the wallet inside the per-scope loop (lines 163-169), while the collected scan_targets are appended to the wallet only once after all scopes complete (lines 174-179). If a server error propagates from a ? in a later scope (lines 67, 132, 141), the function returns Err with the earlier scope's addresses persisted and every collected scan target discarded. On the next sync those persisted addresses are only queried over the recent window (block_range at lines 49-57), so transactions found in the aborted pass below that window are never scanned.

What the test does

pepper-sync/src/sync/transparent.rs, tests::error_in_later_scope_does_not_persist_addresses_without_their_scan_targets.

The test builds a UFVK with a transparent key from a fixed seed, an in-memory SyncWallet with no known addresses, and a responder task standing in for client::fetch::fetch. With gap_limit: 2 and the external and internal scopes enabled, the responder answers the first external address with a stream containing one transaction, the next two with empty streams, and the first internal address with tonic::Status::internal, which the client does not retry. The test asserts the call returns Err and then asserts the invariant that either no addresses were persisted or the scan targets found for the persisted addresses were also persisted.

Observed failing output

thread 'sync::transparent::tests::error_in_later_scope_does_not_persist_addresses_without_their_scan_targets' panicked at pepper-sync/src/sync/transparent.rs:437:9:
addresses were persisted without their scan targets after an error: persisted addresses = {TransparentAddressId { account_id: AccountId(0), scope: External, address_index: NonHardenedChildIndex(0) }: "tmCUAhdeyFwVxETt3xTZrrQ3Z87e1Grakc1"}, persisted scan targets = {}
test result: FAILED. 0 passed; 1 failed

This PR is a reproduction only and does not include a fix. The sync-bench A/B rule was not run because the commit adds a test only.

🤖 Generated with Claude Code

… drops targets on error

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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