Skip to content

test(e2e): cover the PaymentPool redeploy collision against two live deployments - #2182

Merged
thiras merged 2 commits into
mainfrom
claude/paymentpool-redeploy-e2e-66398c
Sep 27, 2026
Merged

thiras merged 2 commits into
mainfrom
claude/paymentpool-redeploy-e2e-66398c

Conversation

@yigitdot

@yigitdot yigitdot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Refs #2088. It stays open until #2181 lands: the seller-side lane store has the same redeploy collision, so this PR covers the buyer side only.

What

New anvil e2e crates/e2e/tests/node_pull_pool_redeploy.rs. It deploys a second PaymentPool beside the snapshot's and repoints a pull-through node at it. poolId = keccak256(owner, ownerPoolNonce), so the node's first pool on deployment 2 has the same id as its tracked pool on deployment 1.

  • Empty redeploy (issue steps 1–3).
    • Bootstrap logs the foreign-row drop, naming pool_id, foreign_payment_pool=#1 and configured_payment_pool=#2 on one line.
    • Once bootstrap is through, the store is empty, and ownerPoolNonce/getPools on deployment 2 are empty.
    • The first miss opens a fresh pool on deployment 2. It has the same id, and it is escrowed and tracked at the new working deposit rather than as the deployment 1 row.
    • Deployment 1's pool is untouched.
  • Reissued id (issue step 4, the one that would have caught production).
    • With the node stopped, the test opens a pool on deployment 2 under the node's own key at the tracked nonce.
    • The node adopts that pool with the deployment 2 deposit and no lanes, and opens nothing.
    • Keeping the deployment 1 row would show the deployment 1 deposit and the lane to SEEDER 1.
  • In both tests:
    • The deployment 2 pull then proves the repointed node buys and settles on deployment 2 at exactly the leg-2 wire price, in its own store and in the on-chain watermark.
    • The pull-path fallback ("ignoring a tracked buyer pool from another deployment") never fires, so bootstrap's drop is what does the work.

Fixture changes (crates/e2e)

  • ChainFixture::redeploy_payment_pool.
    • Deploys FeeRouter and PaymentPool from their forge artifacts. Their parameters are read at runtime from the snapshot pool (dispute window, delivery floor, min deposit) and the snapshot router (window, shares).
    • Grants ROUTER_CALLER_ROLE, then reads back the new pool's USDC, router and bond wiring.
    • A fresh router is needed: the deployer renounced DEFAULT_ADMIN_ROLE on the snapshot router, which pins ROUTER_CALLER_ROLE to the snapshot pool.
  • NodeFixture.
    • New: launch_with_blobs_on_payment_pool, repoint_payment_pool (rewrites the pool address and discovery peers, then restarts; the data dir stays), and stop.
    • A daemon log tee pipes stdout and stderr. Output is echoed to the test process's own streams, so nextest output is unchanged, and buffered ANSI-stripped for log_line / wait_for_log_line.
      • A cut-off line is terminated.
      • A capture failure leaves a marker line.
      • Timeouts report the log tail.
    • Unit tests cover the TOML rewrite, strip_ansi, needle matching and the tee.
  • ClientFixture::new_on_payment_pool: the client approves, opens and signs against a chosen deployment.

Reviewer notes

  • Fresh seeder for the deployment 2 leg is deliberate.
    • The seller-side lane store (lane_state_v1, keyed pool_id‖signer‖provider) has the same collision. A repointed seeder rejects the buyer's first deployment 2 voucher against its deployment 1 frontier, and the pull dies as OurDeadLane.
    • That is filed as node: seller lane state collides across PaymentPool redeploys (lane_state_v1 keyed without the contract address) #2181. Its acceptance is a variant of this file that repoints the original seeder.
    • Because leg 2 pays a different provider, it cannot show a deployment 1 cumulative carried onto a deployment 2 lane. The store assertions pin the guard instead.
  • Bootstrap barrier. restart() returns on admin health, but the buyer bootstrap runs later on its own task. The test waits for decdn_buyer_wallet_usdc, which is published last and per process, before reading boot state. That keeps the negative checks from passing on a bootstrap that has not yet run.
  • Prices use wire bytes. Expected prices come from bao_encoded_size plus rate::min_payment (content plus proof, per ADR 038).
  • Sensitivity check (manual, not committed). With BuyerPoolState::is_on stubbed to always return true, both tests fail. With the log assertion also bypassed, both still fail on the store/adoption assertions.
  • Naming follow-up. The upstream node is called a "SEEDER" here, following the node_pull_pool_adopt.rs template. The contract, the admin API and every other journey call it a "provider". The rename across all three node-to-node pull journeys is tracked in test(e2e): rename "seeder" to "provider" in the node-to-node pull journeys #2184, so this PR does not touch the two older files.

Verification

  • cargo nextest run -p decdn-e2e --features anvil-e2e --test-threads 2: 76/76 pass, including the whole existing suite on the piped-stdio fixture.
  • cargo clippy --workspace --all-targets -- -D warnings, plus the feature-gated -p decdn-e2e --features anvil-e2e: clean.
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items: clean.
  • cargo fmt -- --check: clean.

🤖 Generated with Claude Code

…deployments (#2088)

Pool ids carry no contract address, so a node's first pool on a
redeployed PaymentPool has the same id as its first pool on the old
one. Pin the buyer-side guard against two real deployments: a node
repointed at an empty redeploy drops its stale row (logged naming the
old deployment as foreign_payment_pool), opens nothing at boot, and
opens fresh on its first miss; a node whose key already owns the
reissued id on the redeploy adopts it with the new deposit and no
lanes, and pays the redeploy only for the bytes it delivers.

Fixture support: ChainFixture::redeploy_payment_pool deploys a second
PaymentPool behind a fresh FeeRouter (the snapshot router's role table
is frozen); NodeFixture gains a PaymentPool override at launch,
repoint_payment_pool, stop, and a daemon log tee with log_line /
wait_for_log_line; ClientFixture can pay through a chosen PaymentPool.

The redeploy leg is served by a fresh seeder: the seller-side lane store
has the same collision, tracked in #2181.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 27, 2026 16:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 0f4b520 in the claude/paymentpool-r... branch remains at 86%, unchanged from commit e55b48d in the main branch.

Show a line coverage summary of the most impacted files.
File main e55b48d claude/paymentpool-r... 0f4b520 +/-
crates/e2e/src/chain.rs 14% 13% -1%
crates/node/src...gin/pull_leg.rs 89% 89% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/protocol/src/framing.rs 97% 97% 0%
crates/e2e/src/node.rs 32% 42% +10%

Updated September 27, 2026 18:15 UTC

…s, fixture hardening

- The leg-2 lane pays SEEDER #2, not SEEDER #1, so it cannot show a #1
  cumulative carried over; say what it proves (the repointed node buys and
  settles on #2 at the leg-2 price) and let the store assertions carry the
  guard.
- Wait for the buyer bootstrap (decdn_buyer_wallet_usdc) after every
  restart before reading boot state, so the negative checks cannot pass on
  a bootstrap that has not run.
- Propagate admin RPC and address-parse errors from polls; wait on metered
  bytes / watermark >= expected before asserting the exact figure; price
  with rate::min_payment.
- redeploy_payment_pool copies the snapshot pool's and router's parameters
  at runtime and reads the new pool's wiring back.
- NodeFixture: stop() propagates a failed kill; the log tee records a
  capture failure and ends a cut-off line; strip_ansi drops a lone ESC
  alone; wait_for_log_line timeouts carry the log tail.
- Doc fixes: timelock role, HEAVY tier list, client approval.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@yigitdot
yigitdot requested a review from thiras September 27, 2026 22:12
@thiras
thiras merged commit af5a682 into main Sep 27, 2026
30 checks passed
@thiras
thiras deleted the claude/paymentpool-redeploy-e2e-66398c branch September 27, 2026 22:27
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.

3 participants