proxy wallet: sweep quotes across per-epoch currency units #31
Loading…
Reference in a new issue
No description provided.
Delete branch "agent/multi-unit-sweeper"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The proxy's quote sweeper now mints ecash in every per-epoch currency unit, not just the one its wallet was built with. Before this, the first epoch rotation silently cost every later epoch all of its mining rewards: the sweeper fetched the new unit's quotes, stored them, and never minted them. What proves it: on a live dev stack, mining filled the genesis epoch to a balance of 2752, two rotations then minted in the new units, and a backlog of 55 previously stuck rewards drained in a single pass. If this is wrong, revert the two commits — the wallet DB schema is untouched, so rollback is safe.
Replaces vnprc/hashpool#23, closed only so the history could be squashed; the forge refuses force-push on an open pull request branch. The tree is byte-identical to the state verified there.
Merge after vnprc/hashpool#21.
In plain English
Once the mint issues a separate kind of ecash per mining epoch, the wallet has to collect all of them, and it could only collect the first. This teaches it to collect every kind it sees, and to work through a backlog in bounded batches so one bad reward cannot block the rest.
Two bugs found by running the real stack are fixed here, because without them a new epoch cannot be collected at all. First, on first seeing a new kind of ecash the wallet never asked the mint for the matching key, so every attempt failed and rewards piled up uncollectable forever. Second, a failed attempt left the reward marked "in progress" with nothing to ever clear it, so it could never be retried.
Worth knowing: all 32 tests on the original branch passed while both bugs were live. They covered the planning logic, not the actual collection call.
Commits
f1f4e994re-pins cdk forWallet::cleanup_orphaned_quote_reservations, the narrow cleanup that never resumes a saga. Pin only, so it builds alone.4453ffffis the sweeper: per-unit wallet handles, unioned discovery, bounded per-pass work, the keyset refresh, and the reservation recovery.Risk
R2. Per-unit wallet handles share one sqlite localstore and one metadata cache; the wallet schema and NUT-13 keyset counters are unit- or keyset-scoped, and units are swept sequentially within a pass, so there is no cross-unit contention. Discovery no longer depends on the pubkey lookup alone: a lookup-endpoint failure leaves every DB-known unit sweepable and visible in the reconcile log. A unit whose keyset refresh fails is skipped for that pass and retried on the next, so a persistent mint outage defers that unit rather than leaking reservations behind a keyset it could not look up. The reconcile log format changed to a per-unit summary; anything scraping the old string needs updating.
Residual risk that review could not settle and running it did: the per-chunk network paths are exercised by the live witness, not by unit tests.
Validation
cargo check -p translator_sv2clean;cargo test -p translator_sv237 passed, 0 failed, re-run by the integrator. Each commit builds independently.time0.3.41,serde_with3.17.0,darling0.21.3,simple_asn10.6.3 against rustc 1.86.0.Not run: the end-to-end rotation witness against the reward trigger of vnprc/hashpool#18, which is unstarted.