Repository navigation
fix(node): bind the seller store to its PaymentPool deployment - #2191
Conversation
Code Coverage OverviewLanguages: Rust Rust / code-coverage/cargo-llvm-covThe overall line coverage in commit b23147a in the Show a line coverage summary of the most impacted files.
Updated |
744ec42 to
13f4cf6
Compare
|
Ran a five-agent review pass (code, tests, comments, silent failures, type design) over the diff; no critical findings. 13f4cf6 applies the follow-ups:
All gates re-run green after the rebase onto |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
It changes irreversible seller payment-state deletion with cross-file crash-safety and on-chain redemption implications, so a human should confirm the forfeit semantics and boot-preflight before merge.
Review effort: Balanced
Findings: None
| 1. Let the node redeem its open lanes and finish any pending settles on the | ||
| old deployment (`decdn_unredeemed_usdc` reaches 0 / the redeemer logs go | ||
| quiet), then stop the node. |
There was a problem hiding this comment.
Step 1 can wait forever: a lane below the per-chunk redeem floor never settles while the node runs, so decdn_unredeemed_usdc may never reach 0. Only the graceful-shutdown sweep (PaymentSettlement::shutdown, floor == 0) redeems that dust.
Suggested wording:
| 1. Let the node redeem its open lanes and finish any pending settles on the | |
| old deployment (`decdn_unredeemed_usdc` reaches 0 / the redeemer logs go | |
| quiet), then stop the node. | |
| 1. Stop the node gracefully while it still points at the old deployment. | |
| Shutdown runs one final redeem sweep with no floor, so it settles every | |
| open lane, dust included. Confirm the log has no `shutdown redeem deadline | |
| elapsed` warning; if it does, start the node on the old config and stop it | |
| again. |
There was a problem hiding this comment.
Agreed that step 1 could hang. decdn_unredeemed_usdc counts every lane's owed − paid, and a chunk below the floor never redeems, so the gauge may never reach 0.
The suggested fix doesn't hold, though: graceful shutdown doesn't sweep with floor == 0. final_redeem_sweep passes self.redeem_threshold (payment_settlement.rs:445), and config requires redeem_threshold_micro_usdc > 0 (default 1 USDC). So a stop leaves sub-floor dust unredeemed, same as the self-tick. The floor == U256::ZERO forces every lane (the close/shutdown path) doc on redeem_planned_lanes (:1854) is stale. No caller passes zero.
Fixed in 2fa187c:
- On the old deployment, set
redeem_threshold_micro_usdc = 1and restart. The next self-tick then redeems every lane that owes anything. - Wait for
decdn_unredeemed_usdcto reach 0, then stop gracefully. Check for theshutdown redeem deadline elapsedwarning (your check, kept). - Repoint and restore the threshold.
I also dropped the "finish pending settles" wait. The pending-settle tables have no production reader or writer, so there is nothing to wait on.
There was a problem hiding this comment.
Re-checked against current main (after #2226) and the history. The graceful-shutdown sweep has always passed self.redeem_threshold: it does so now, in b57d55ef (chunking), and in b82100fc before chunking. The only zero-floor caller was the close-redeem path, and #1761 removed it. The floor == 0 … close/shutdown path doc outlived it. 562dcbc corrects that doc in redeem_planned_lanes, chunk_redemptions, flush_store_durable, final_redeem_sweep, the non-strict flush-failure log line and two test comments. They now say that every path, shutdown included, applies the configured floor.
poolId = keccak256(owner, ownerPoolNonce) names neither the chain nor the contract, so a pool id repeats across PaymentPool redeploys. The seller lane table, both pending-settle sets and the watcher checkpoint carried no deployment, so a seller repointed with its data dir intact kept the old deployment's frontier for a returning buyer's reissued pool: it rejected the buyer's first voucher as AmountRegression and redeemed the old signatures against the new contract. PersistentPoolStateStore::open now takes the configured Deployment (chain id + PaymentPool) and keeps a stamp in lanes.redb. A matching stamp is a read-only check; a missing stamp is claimed without dropping rows; a foreign stamp drops the lanes, pending settles and checkpoints (lanes in the same commit as the new stamp) and logs the drop at WARN. The redeploy e2e gains the acceptance journey: SEEDER #1 repointed at the redeploy with its data dir intact serves the reissued pool from zero. Closes #2181. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review follow-ups on the seller-store deployment binding (#2181): - Boot verifies the configured deployment against the live chain before the lane store opens: eth_chainId must match blockchain.chain_id and the PaymentPool address must have code. A config typo aborts bring-up instead of triggering the irreversible seller-state drop. - The voucher EIP-712 domain is derived from the same Deployment the store is stamped with (one parse in build_infra, threaded via Infra). - The rebind logs each dropped lane (pool id, signer, provider, unredeemed value) as the last record of its claim, plus a summed forfeited_micro_usdc on the summary WARN. - Deployment::from_bytes decodes without the panicking Address::from_slice. - New unit tests: a crashed drop is repeated by the next boot, a foreign stamp over an absent lane table drops cleanly, buyer.redb survives the seller-side drop, the stamp survives record/flush cycles, and the unstamped claim keeps every family. - Docs: the unstamped-store case is a pre-stamp store (not "new"), the config-revert crash hazard is documented, ADR 003 sentences are split to STE form, the e2e module doc names both watched logs and pins the blob-price ordering its mutation detection rests on, and the operator runbook gains a "Repointing at a redeployed PaymentPool" section. Co-Authored-By: Claude Fable 5 <[email protected]>
…ntPool Every redeem path, graceful shutdown included, submits a chunk only when its unredeemed total clears blockchain.redeem_threshold_micro_usdc (config enforces > 0), so sub-floor lanes never redeem and decdn_unredeemed_usdc may never reach 0. Drop the floor to 1 µUSDC on the old deployment first, drain, stop gracefully, then repoint. Also drop the pending-settle wait: those tables have no production writer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The redeem path docs still described a forced close/shutdown path passing floor == 0. The close-redeem path was the only zero-floor caller and is gone; every caller, including the graceful-shutdown sweep, passes blockchain.redeem_threshold_micro_usdc, which config keeps above zero, so sub-floor dust defers on every path. Correct the redeem_planned_lanes, chunk_redemptions, flush_store_durable and final_redeem_sweep docs, the non-strict flush-failure log line, and two test comments. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2fa187c to
562dcbc
Compare
…feited claim Second review pass on the deployment-binding follow-ups: - The deployment preflight now also calls PaymentPool.usdc(): a code- presence check alone passes a sibling contract pasted from the same deploy manifest — the likeliest wrong-address typo — and the rebind would still drop the lanes. A non-PaymentPool target surfaces as a permanent contract error and aborts at once. The preflight is generic over the provider and gains five mocked unit tests (match, chain-id mismatch, codeless address, non-PaymentPool target pinned as not-retried, transient fault retried). It runs on its own retry budget, and the misplaced doc block that had swallowed check_rpc_reachability's rustdoc is re-attached. - The forfeit audit reports the lane's full claim: forfeited_value is owed() — the signed cumulative plus the chain-verified frontier — minus the paid watermark, the figure the redeemer collects; last_amount alone understates a lane by up to one whole chain. The summary WARN gains undecodable_lanes so a partial sum announces itself, and a table or iterator error during the walk degrades to a WARN instead of aborting bring-up: the walk is observational, and the delete that follows arbitrates real corruption. New tests pin the value math, the corrupt-foreign-row tolerance, the crash-state setup deletes, and the absent-lane-table precondition; journey 3 asserts undecodable_lanes=0 and the per-lane last-record line. - Docs: the rpc_url parse error no longer echoes the URL (it can embed an API key); two remaining "forced close" passages in receipt_log and the watermark-reconcile comment now name the shutdown sweep; the redeem floor is described as per-chunk (dust rides alongside larger lanes); the runbook drain procedure waits out the gauge's initial zero, watches decdn_redemption_skipped_insolvent_total for held drained-pool lanes, and tallies from the final boot's summary line; the CHANGELOG tells operators to leave buyer.redb in place. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Second review pass (four agents over the follow-up commits
Gates: fmt, workspace clippy (all targets+features), 1481 node tests, doc gate, and the three redeploy e2e journeys all pass. |
…ace convention The preflight test helpers returned Result<Value, ()> so they could sit beside Err(()) fault entries, which needed three #[expect(clippy::unnecessary_wraps)]. Follow the Option convention the other mixed-response mock helpers use (incentive payment_pool.rs mocked, cli fetch.rs run): the helpers return a bare serde_json::Value, the call sites wrap in Some, and None faults the call. The list stays JSON rather than Bytes because eth_chainId answers with a quantity. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the Option encoding in the preflight test provider with a small
local enum, MockAnswer { Ok(serde_json::Value), TransientError }, so each
queued answer names what it is. The helpers keep returning a bare
serde_json::Value and call sites wrap them. buyer_channel.rs's MockCall is
not reused: it holds Bytes, and eth_chainId answers with a JSON quantity.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
What
poolId = keccak256(owner, ownerPoolNonce)names neither the chain nor the contract, and a redeploy restarts every owner's nonce. So a buyer's Nth pool on a newPaymentPoolhas the same id as its Nth pool on the old one. #2087 fixed the buyer side. On the seller side,lane_state_v1, both pending-settle sets andwatcher_checkpoint_v1carried no deployment. A seller repointed with its data dir intact kept the old lane for the reissued pool. It rejected the buyer's first voucher asAmountRegression, so the buyer suppressed the provider. It also redeemed the old deployment's signatures against the new contract, which reverted and took the rest of eachredeemManybatch with it.PersistentPoolStateStore::opennow takes the configuredDeployment(chain id +PaymentPooladdress).lanes.redbstores it in a one-rowdeployment_v1table. At boot:dropped_lanes,undecodable_lanesandforfeited_micro_usdc. It then dropspending_settle_v1+buyer_pending_settle_v1andwatcher_checkpoint_v1, and then the lane table in the samelanes.redbcommit that writes the new record. A crash midway leaves the old record, so the next boot repeats the drop.Boot preflight. Because the drop is irreversible, a config typo must never trigger it. Before the store opens, the node checks the configured deployment against the live chain:
eth_chainIdmust equalblockchain.chain_id, the address must have code, and that code must answerPaymentPool.usdc()— code presence alone would pass a sibling contract pasted from the same deploy manifest. Any mismatch aborts boot with the store untouched. The voucher EIP-712 domain is derived from the sameDeploymentvalue, so the store stamp and the signature domain cannot disagree.ADR 003 § Off-chain voucher state persistence describes the binding;
docs/runbook.mdgains Repointing at a redeployed PaymentPool (drain sub-floor lanes by loweringredeem_threshold_micro_usdc, what the gauge does and does not count, how to read the drop WARNs).Closes #2181
Reviewer notes
bind_deploymentandlog_forfeited_lanesincrates/node/src/channel_store.rs, thencheck_deployment_preflightincrates/node/src/runtime/mod.rs.StoredLaneState/LaneStatedo not change, and the u64-valued tables need no format change.PaymentPooladdress on two chains. (The buyer row's tag has no chain id — filed as buyer pool row's deployment tag carries no chain id #2198.)owed()(signed cumulative + chain-verified frontier) minus the paid watermark, the figure the redeemer collects. The forfeit walk is observational: a corrupt foreign row or an iterator error degrades to a WARN rather than blocking a rebind over data that is being deleted.buyer.redbis not touched: fix(incentive,node): scope buyer pool rows to their PaymentPool deployment #2087's per-rowis_onalready covers it.lanes.redb,settle.redbandcheckpoint.redbby hand (notbuyer.redb).payment_settlement.rsandreceipt_log.rs: they described a zero-floor close/shutdown path that refactor(node): drop PaymentPool close monitor; lean on the redeem sweep #1761 removed. Every redeem path, graceful shutdown included, applies the configured per-chunk floor.Verification
cargo fmt -- --checkcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-node: 1481 passed.-p decdn-cli --test pool_list: 14 passed.RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-itemscargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(node_pull_pool_redeploy)': 3 passed, including the acceptance journeya_seeder_repointed_at_a_redeploy_drops_its_stale_lane_and_serves_the_reissued_pool. It repoints SEEDER Add devcontainer for secure Claude Code sessions #1 with its data dir intact and checks that it drops its Add devcontainer for secure Claude Code sessions #1 lane (dropped_lanes=1,undecodable_lanes=0, the per-lane last-record line) and serves and redeems the reissued pool at exactly the leg-2 price. The full anvil suite (77) passed after the preflight landed.reason=AmountRegressionand the SERVER suppressing the provider).cargo nextest run -p decdn-node --features anvil-e2e -E 'binary(anvil_settlement_e2e)': 4 passed.channel_storecovers same deployment kept, other address and other chain dropped, no record claimed, no file growth on a matching reopen, malformed record isCorrupt, a crashed drop repeated by the next boot, a foreign record with no lane table, a corrupt foreign row,buyer.redbsurviving, and the forfeited-value math.runtimecovers the preflight: match, chain-id mismatch, codeless address, non-PaymentPoolcontract (not retried), transient fault retried.contracts/changed: n/aCHANGELOG.mdentry added under Fixed🤖 Generated with Claude Code