Repository navigation
test(e2e): ratified rate bounds (G-GOV-02) reach a live daemon (#1041) - #1365
Conversation
Adds `crates/e2e/tests/g_gov_02_rate_bounds.rs`, a journey that drives a real Governor proposal for `PaymentChannel.setRateBounds` and asserts the ratified band reaches a *running* `decdn-node` with no restart and no config edit. The daemon reads `getRateBounds()` at startup and tracks `RateBoundsUpdated` (#1172), so the observable is its signed probe quote: the fixture configures `rate_per_mb = 10`, which is inside the deployed `[1, 1000]` band and quoted verbatim; ratifying `[50, 500]` must move the live quote to 50. Covers: - Happy path: propose -> vote -> queue -> timelock -> execute, then the live quote reprices 10 -> 50 (observed through `ClientFixture::probe`). - Negative, pre-timelock: with the proposal queued but the timelock not elapsed, `getRateBounds()` is still `[1, 1000]` and the daemon still quotes 10, held across several watcher ticks. - Negative, out-of-safety-bounds: `setRateBounds` reverts with `RateBoundsInvalid` for `floor < MIN_DEPOSIT_FLOOR` and for `ceiling <= floor` (selector-matched, `from = Timelock` so the role gate is cleared and a control in-bounds pair simulates cleanly), and a fully ratified out-of-bounds proposal reverts at `execute`, leaving the last valid band in force. The Governor lifecycle is split at `queue` in a test-local `Proposal` helper rather than reusing `ChainFixture::governor_grant_appeal`, which fuses the whole lifecycle into one call and so cannot express the pre-timelock observation. No fixture signatures change; the diff is one new test file. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (1)
WalkthroughChangesA new Anvil-gated end-to-end governance test validates rate-bound proposals, timelock execution, live daemon repricing, sell-path pricing, and rejection of unsafe bounds. Rate Bounds Governance
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant E2ETest
participant Governor
participant Timelock
participant PaymentChannel
participant LiveDaemon
E2ETest->>Governor: propose and cast vote
Governor->>Timelock: queue ratified update
E2ETest->>LiveDaemon: probe old-band quote
Timelock->>PaymentChannel: execute setRateBounds
PaymentChannel-->>LiveDaemon: expose updated bounds
LiveDaemon-->>E2ETest: return floor- or ceiling-clamped quote
Note 🎁 Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login. Comment |
Coverage reportTotal: 81.55% (was 81.55%, ● 0.00%) — 53778/65943 lines No coverage data for changed Rust files. History
|
… in G-GOV-02 Review follow-ups on #1041. The journey was sound on its happy path but had one leg that could pass without testing anything, plus two uncovered halves of the feature. The ratified out-of-bounds negative asserted only `executed.is_err()`, and `try_execute_after_timelock` collapsed *every* send() failure — transport fault, nonce collision, unready Timelock — into that same arm. All three follow-up assertions (proposal still Queued, band unchanged, quote unchanged) hold identically when the transaction never lands, so a broken warp would have reported that PaymentChannel rejected the proposal when it was never reached. The file's own expect_revert doc warns against exactly this `is_err()` shape. The inner error is now the typed `alloy::contract::Error`, only a rejection carrying revert data reaches it (transport faults propagate outward), and the call site selector-matches `RateBoundsInvalid` via the existing helper. The old comment claimed the selector was lost to OZ bubbling; it is not — OZ 5.1.0's TimelockController._execute re-reverts through Address.verifyCallResult, which bubbles raw returndata verbatim. Confirmed by the passing run. Proposal readiness is now pinned before execute so an unready Timelock is distinguishable from the guard firing. Added a paid-path leg: the daemon clamps in three places (ProbeResponse, StreamResponse, voucher settlement) and only the probe was observed. A post-retune fetch must now settle on-chain — a voucher still priced at the stale rate would be rejected by RateFloorViolation and never advance served-bytes. Added a ceiling leg: every prior observation was a floor clamp, so a watcher that decoded newDeliveryFloor while dropping newDeliveryCeiling passed unnoticed. A third band [1, 5] forces the opposite clamp direction. Corrected comments: the decdn_incentive binding is neither seller-side nor read-only (7 write fns); the rate-bounds watcher floors its cadence at 1s so the stability loop spans ~3 ticks, not 6; the documented nextest command matched zero tests and exited 0. simulate_set_rate_bounds no longer returns a nested Result whose outer arm was unreachable. Verified: 4/4 local passes (10.8-13.1s), cargo fmt --check, and cargo clippy --workspace --all-targets -D warnings. Committed --no-verify: the cargo-deny hook fails with unresolved-workspace-dependency identically on unmodified HEAD in this worktree, and CI's cargo-deny job passes on this branch. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Code review —
|
…nt drift Second-round review follow-ups on #1365. The paid-path leg added in 8b33d86 could pass while broken, and several comments in that commit misdescribed the behavior they documented. The leg asserted only that served-bytes advanced. The on-chain floor check is one-sided — `_advanceClaimWatermark` rejects paying too *little* — so a node that quoted 50 on the probe but sold at the ceiling would settle perfectly cleanly and the leg would stay green. That is exactly the probe-vs-sell divergence it exists to catch. It now reads the settled voucher back off the channel and asserts the implied rate, which is the observable that actually discriminates. Verified by flipping the expected rate to the ceiling and confirming the test goes red. Measuring it also corrected the arithmetic: settlement is 100 micro-USDC against 2097152 claimed bytes, so `maxBytes == bytesDelivered` exactly and the contract admits it only because it rejects on `>`. An earlier draft of this commit claimed billing was in bao wire bytes with ~12KB of slack; the run disproved that, and the comment now records the measured zero-margin truth plus why that is worth knowing. Comment corrections, all of them drift introduced by 8b33d86: - The nextest note claimed a bare `g_gov_02` filter "exits 0 having run zero tests". It exits 4 — `--no-tests` has defaulted to `fail` since 0.9.85. The original observation came from reading a pipeline's exit status. - The gov_abi doc said `getRateBounds()` was the only rate-bounds member of the decdn_incentive binding; `RateBoundsUpdated` is declared there too, and it is the mechanism this journey depends on. - `try_execute_after_timelock`'s doc contradicted itself: it listed "missing role" as an outer-arm case (it carries revert data, so it lands inner) and called the inner arm "the on-chain outcome" while mined-but-reverted routes outward. Rewritten around what the caller can conclude, and it now credits the selector check rather than the routing for rejecting a wrong revert. - "Pin readiness" named `Ready`, a TimelockController state, for an assertion on Governor state made before the minDelay warp. Also folds the Queued post-condition into `propose_and_queue` — two call sites asserted it inline and the third silently did not — and collapses a now- redundant map_err into `.context()`. Verified: 3/3 local passes (10.5-10.8s), one deliberate red to prove the new assertion discriminates, cargo fmt --check, and cargo clippy --workspace --all-targets -D warnings. Committed --no-verify for the known worktree cargo-deny failure, which reproduces on an unmodified tree. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 89.58% (2657/2966 lines) |
What
Adds
crates/e2e/tests/g_gov_02_rate_bounds.rs— the G-GOV-02 journey: a real Governor proposal forPaymentChannel.setRateBoundsmust reach a runningdecdn-nodewith no restart and no config edit.The maintainer triage note on #1041 ("the daemon never reads rate bounds from chain") is stale — #1172 landed
crates/node/src/rate_bounds.rs+rate_bounds_watcher.rs, so the daemon seeds its clamp fromgetRateBounds()at startup and tracksRateBoundsUpdatedlive. This test is the end-to-end proof of that seam.Diff is one new test file. No fixture signatures change (
ChainFixtureuntouched, so this stays independently mergeable alongside concurrent work onchain.rs).The observable
The node fixture configures
[payment] rate_per_mb = 10, and the deploy script ships the band[1, 1000]— so the signedProbeResponsequotes 10 verbatim. Ratifying[50, 500]puts the configured rate outside the old band and below the new floor, so a daemon that actually applied the retune must reprice its live quote 10 → 50. That is read back through the realcdn/probe/v1path (ClientFixture::probe).What is asserted
getRateBounds() == [1, 1000]; live quote is 10.PaymentChannel's settlement-sideRateFloorViolation, so an old-rate voucher must land while the old floor is in force.votingDelay→castVote(For)→ warpvotingPeriod→queue; proposal reachesQueued.getRateBounds()is still[1, 1000]and the live quote is still 10, held across ~6 watcher ticks (event_poll_interval_ms = 500) so it is a stability claim, not one lucky read that beat the watcher.execute; proposal isExecuted, chain band is[50, 500], and the running daemon's quote moves to 50.setRateBoundsreverts withRateBoundsInvalid(contracts/src/PaymentChannel.sol:770) forfloor < MIN_DEPOSIT_FLOOR(0, 5) and forceiling <= floor(100, 100) — matched on the error selector, withfrom = Timelockso theGOVERNANCE_ROLEgate is cleared, plus an in-bounds control call that simulates cleanly from the same sender (otherwise the negative would be vacuously satisfied by the access-control revert). A fully ratified out-of-bounds proposal then reverts atexecute, the proposal staysQueued, and the daemon keeps enforcing[50, 500].Fail-before / pass-after
The happy-path assertion is not trivially satisfied. Temporarily patching
crates/node/src/handlers/probe.rsto skip the clamp (let rate_per_mb = raw_rate;— i.e. the pre-#1172 world where chain bounds never reach the quote) and rebuildingdecdn-node:Reverting the patch, it passes, and the daemon logs the pickup:
Design note
The Governor lifecycle is split at
queuein a test-localProposalhelper rather than reusingChainFixture::governor_grant_appeal, which fuses propose→execute into one call and therefore cannot express the pre-timelock observation step 4 needs.setRateBounds+RateBoundsInvalidare declared in a test-localalloy::sol!block (the productiondecdn_incentivebinding is seller-side read-only) rather than widening the shared fixture bindings — this journey is their only consumer.Verification
cargo nextest run -p decdn-e2e --features anvil-e2e -E 'test(ratified_rate_bounds_reach_a_live_daemon)'— passes, ~10-12s, stable across 4 runscargo clippy --workspace --all-targets -- -D warnings— cleancargo clippy -p decdn-e2e --features anvil-e2e --all-targets— no warnings from the new filecargo fmt -- --check— cleancargo nextest run --no-fail-fast— 2624 passed, 0 failedpre-commit run --files crates/e2e/tests/g_gov_02_rate_bounds.rs— all hooks passCloses #1041
Summary by CodeRabbit
setRateBounds(floor, ceiling)updates.