Skip to content

fix(node)!: a per-chain redeem floor and a final-claim sweep - #3033

Open
alpergundogdu wants to merge 2 commits into
mainfrom
claude/2836-dynamic-redeem-floor-07b8c5
Open

alpergundogdu wants to merge 2 commits into
mainfrom
claude/2836-dynamic-redeem-floor-07b8c5

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Closes #2836

A pool owner could sign capabilities with a cap just under the fixed 0.05 USDC redeem threshold, take that much from each node, and let each capability expire: the node never redeemed the vouchers. This PR makes the floor a gas cost the node reads at redeem time, redeems final claims as soon as they pay their own gas, and caps what one pool can strand on a node.

What changes

1. Gas-priced floor per payment chain (crates/node/src/redeem_floor.rs)

  • Floor = redeemMany gas × live eth_gasPrice (+ Arbitrum L1 data fee from the ArbGasInfo precompile, 0 when the precompile has no code) × blockchain.payment_chains[].gas_token_price_micro_usdc.
  • Per-claim gas is the first-time-lane marginal from contracts/test/PaymentPool.t.sol (759,105 − 695,329 = 63,776), plus 544 calldata bytes priced at 16 gas/byte. Fixed tx gas is 78,569 (the N-voucher benchmark less ten claims, plus 21,000 intrinsic).
  • Chunk floor: 20× the gas of a redeemMany with that many claims (gas ≤ 5% of what it redeems). Final-claim floor: 3× one claim's gas (one claim plus a whole transaction's fixed gas cost less than three claims, so a lone final claim pays for its transaction).
  • A quote is reused for 60 s, so a burst of hints costs one read. A failed read falls back to the last quote; with no quote ever, nothing redeems and the sweep reports a chain fault.
  • blockchain.redeem_threshold_micro_usdc is removed. The price knob defaults to 5,000 USDC/ETH and rejects 0.

2. Final-claim sweep

  • A lane inside its capability-expiry margin is marked final_claim. At the existing cutoff wake it redeems once it clears the final-claim floor, batched with other claims or alone. A final claim below that floor is never submitted.

3. Per-pool stranded-value cap

  • Each sweep sums, per pool, the unredeemed value of this node's expired lanes that were below the final-claim floor (read from the lane store, so it survives restarts and clears when the pool is reclaimed). A pool with more than one floor stranded is published to the PoolProjection.
  • Admission refuses a new lane on such a pool with InsufficientDeposit (wire Unfunded, proven requester). Lanes the node already holds keep service. No on-chain mechanism.

Other surfaces

  • Admin admin_v1_lanes: drops settlement_eligible and redeem_threshold_micro_usdc (the floor is now dynamic and per chain). CLI decdn node lanes, the dashboard and fixtures follow.
  • ADR 003: new § Redemption floor; expiry-margin and sweep text updated to the new rule.
  • Runbook drain step uses gas_token_price_micro_usdc = 1 instead of the threshold.
  • e2e fixtures set the price to 1 µUSDC/ETH, so every floor rounds to 1 µUSDC on anvil.

Tests

  • a_sub_floor_lane_is_redeemed_at_its_serve_cutoff_when_its_final_claim_clears
  • an_expired_sub_floor_lane_strands_its_value_on_its_pool
  • a_pool_over_its_stranded_cap_refuses_a_new_signer
  • the_floor_follows_the_gas_price, plus L1-fee, rounding, quote-cache and fallback tests in redeem_floor/tests.rs
  • chunk-floor-per-lane and final-claim chunking tests

Ran: cargo nextest run -p decdn-node -p decdn-common -p decdn-cli (only node_origin_pull timing flakes, which pass on retry and don't touch the redeemer), cargo clippy --workspace --all-targets --all-features, cargo test --no-run -p decdn-e2e --features anvil-e2e, CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items, dashboard build/test/lint.

Review notes

  • The 20× chunk and 3× final multiples are this PR's choices; the issue fixed only "× a safety margin".
  • The L1 term prices each claim byte as a non-zero, uncompressed byte, which overstates Arbitrum's compressed L1 cost.
  • A pool that issues many short-lived, low-value capabilities (for example sponsord's per-client capabilities on small downloads) will hit the stranded cap after about two sub-floor expiries per node. That is the intended trade-off, but it does reach honest pools of that shape.

🤖 Generated with Claude Code

The redeemer's floor is the gas of a redeemMany, priced at the payment
chain's live gas price (plus the Arbitrum L1 data fee from ArbGasInfo) and
the per-chain `gas_token_price_micro_usdc`. `redeem_threshold_micro_usdc`
is removed. A chunk redeems at 20x its gas; a final claim (capability
inside the expiry margin) redeems at 3x one claim's gas, batched or alone.
A lane that expires below that floor adds to its pool's stranded value,
and a pool with more than one floor stranded admits no new signer.

The admin lanes API drops `settlement_eligible` and
`redeem_threshold_micro_usdc`.

Closes #2836

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-code-quality

github-code-quality Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main d769020 claude/2836-dynamic-... 82b3bd0 +/-
78% 78% 0%
View coverage of the 10 most impacted files.
File main d769020 claude/2836-dynamic-... 82b3bd0 +/-
crates/node/src...t_settlement.rs 83% 83% 0%
crates/node/src/runtime/mod.rs 28% 28% 0%
crates/client/src/lib.rs 89% 89% 0%
crates/node/src...gin/pull_leg.rs 84% 84% 0%
crates/cli/src/...ommands/node.rs 65% 65% 0%
crates/node/src...nt/admission.rs 98% 98% 0%
crates/protocol/src/framing.rs 92% 93% +1%
crates/node/src/admin.rs 75% 76% +1%
crates/node/src/pool_view.rs 84% 86% +2%
crates/node/src...redeem_floor.rs 0% 94% +94%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 27, 2026 14:30 UTC

The 1 µUSDC e2e floor lets each hint redeem, so the settlement ledger can
hold more than two rows. Assert chain order and that the first two rows
are the first two redeems.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant