Repository navigation
test(e2e): G-NODE-01 onboarding journey, bare to accepting delivery (#1030) - #1768
Conversation
#1030) Implementation plan for issue #1030. Two halves: enforce the ADR 019 Phase 4 acceptance criterion #1 on the cdn/client/v1 serve path (the daemon never implemented it, so an unregistered and therefore unslashable node earns today), then write the bare-to-serving e2e journey that uses that gate as its hinge. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…1030) ADR 019 Phase 4 lists `CapacityBond.isActiveNode(nodeId)` as acceptance criterion 1 for serving `cdn/client/v1`, but the daemon never enforced it. `serve_stream` read no registry state at all; the only registration awareness was `binding_check`, an advisory bring-up WARN. So a node that was never registered - or whose key was swapped out from under its binding - kept selling bytes while being unslashable, which is the one state the enforcement model cannot price. The predicate already existed. The DHT registry projection keeps a live `StakerSet` off `getRegisteredNodes` plus the CapacityBond membership events, so the gate is `staker_set.is_active(self_node_id)` against the same Arc DHT admission holds - no new poller route (a second CapacityBond route would collide on (address, topic0) and fail the daemon at boot), no new RPC, and no unconfirmed state to fail closed on. The gate sits below the two denylist checks so a takedown still answers `HashBlacklisted` rather than degrading to `NotFound`, and above everything that spends money or sends bytes. It signs `NotFound`, deliberately indistinguishable from a miss: a distinct code would be a cheap oracle for which operators cannot currently sell. The cause is operator-local, in `decdn_serve_stream_rejected_not_registered_total` and `registry_active` on `decdn node health`. Also closes a real gap in the registry route itself: `EjectedByBlacklist` was missing from its topic0 OR-set, so a blacklist ejection only landed at the 15-minute re-enumeration and every consumer of the staker set - DHT admission included - was wrong until then. Probes stay ungated (unpaid, and the canonical rate-discovery channel), as does the daemon's own buyer leg: the rule is may-not-sell, not may-not-participate. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…1030) Starts where an operator starts - a provisioned data dir, a running daemon, nothing on chain - and drives the production `decdn setup` CLI through approve/bond/declareMbps/registerNode until the same process is selling bytes. Every other journey begins already onboarded (`NodeFixture::launch` onboards before the daemon spawns), so nothing observed the bare state and no test drove a SUCCESSFUL setup end to end; `cli_setup_partial` covers only the failure path. The load-bearing assertion is the hinge, not the CLI: one process, no restart, refusing at step 1 and delivering at step 3. That is what proves the ADR 019 serve gate reads a live projection rather than a boot-time sample. The refusal is pinned by the `not_registered` counter, not by the error - every reject reason collapses to a wire `NotFound`, so asserting on the error alone would pass just as happily for a cache miss. New fixtures: `NodeFixture::launch_bare` (the only path to an un-onboarded daemon; funds gas but not TOKEN so setup's funding pre-flight has a real step to clear), `ChainFixture::register_node_raw` (the signing half of `onboard_operator`, which is now built on it, so the two cannot disagree), and `fund_and_bond`. Both negatives were previously untested anywhere in the repo. `register_below_min_bond_reverts` also corrects the issue's wording: `bond()` has no floor - it guards only `ZeroAmount` - so an under-bond succeeds and the TOKEN really moves; the floor is enforced at `registerNode`, which is why an operator can strand capital and still not be registered. The re-registration negative bonds its impostor to minBond FIRST and signs both proofs genuinely, because `_checkRegistrationPreconditions` runs before `_checkBindingOneToOne` - an unfunded impostor would revert on the bond floor and pass for the wrong reason. The admin_rpc drain stub needed `registry_active`: it hand-builds the health JSON precisely so DTO drift fails a test rather than silently deserializing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The plan was scaffolding for the change, not a design artifact the repo needs to carry: ADR 019 already owns the serve-gate decision, and the PR description carries the rationale. Leaving it in docs/ would have introduced a plans/ convention the repo does not otherwise have. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
3f53e10 to
4669821
Compare
|
Let's not actually enforce this gate in the serve path — please pull the production The reasoning: the gate is a node checking its own registration status and choosing to refuse. There's no code we can force a node to run, so a node that wants to sell while unregistered just deletes the check — we're only gating the honest ones against themselves, which buys us nothing. And we don't need to: an unregistered/slashed node accumulates no voting weight, and peers won't transact with a slashed node anyway (you shouldn't be pulling from one). That's the real enforcement, and it already exists off-chain and on-chain. Pretending the daemon self-enforces just adds a code path that the actual adversary ignores and the honest operator never trips. So concretely:
The Worth a note in ADR 019 that the § Phase 4 "gate" is realized by peer rejection + no vote weight rather than daemon self-enforcement, so the acceptance criterion doesn't keep re-summoning this. |
…ey (#1030) Review call on #1768: the gate was a node checking its OWN registration and choosing to refuse. There is no code we can force a node to run, so an operator who wants to sell unregistered deletes the check and rebuilds - it constrained only the honest, which is not enforcement. Reverts the serve path, the not_registered reject reason and counter, and the ClientHandlerDeps staker-set wiring; crates/node/src/handlers/, metrics.rs and tests/ are now byte-identical to main. The real constraints are external and already exist. An unregistered operator never called declareMbps, so DecdnGovernor._getVotes caps each epoch at declaredMbpsAtEpoch x epochSeconds x BYTES_PER_MBIT_SECOND = 0 and it accrues no vote weight (contracts/src/DecdnGovernor.sol:265, landed in #1760). And a client should not select an upstream it cannot slash. Neither can be removed by patching the daemon. ADR 019 Phase 4 now says this outright, including why a serve-side gate should not be re-added, so the acceptance criterion stops reading as a daemon obligation. Kept: registry_active on admin health, now documented as purely diagnostic. It is the answer to "my node is up and earning nothing" - more necessary without a gate, not less, since nothing on the wire says so and the traffic simply never arrives. It is also what lets the journey assert the daemon observed its own registration live. Kept: the EjectedByBlacklist topic0 fix, which is a genuine registry-route bug affecting DHT admission - a peer-side decision, not self-policing. The journey keeps its arc (bare -> real decdn setup -> paid delivery on one process, no restart) and both negatives. Only the refusal assertion is gone; the no-restart poll on registry_active stays, since it proves the registry projection is live rather than sampled at boot. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Agreed, and done — the gate is out. Your framing is the right one: a node checking its own registration constrains only operators who were never the threat. I'd built it because ADR 019 §Phase 4 lists Dropped: the Kept: the journey through the real Three things worth flagging: Your no-vote-weight claim is stronger than you stated, and I've cited it. I kept On "drop the hinge": I removed the refusal assertion but kept the bare → ADR 019 §Phase 4 now has a How criterion 1 is enforced section covering both external mechanisms and an explicit "do not add a serve-side registration gate" with the reasoning, so this doesn't get re-summoned. Full suite green after the revert: 2763 workspace tests, 49 anvil journeys, 5 settlement, clippy |
Coverage reportTotal: 81.28% (was 81.15%, ▲ +0.13%) — 60683/74658 lines
History
|
Resolves conflicts with the G-NODE-01 onboarding work (#1030/#1768) on AdminState and the admin-server builder chain: kept both the ADR 041 `warming` handle (for admin-evict forget) and the new `staker_set` handle. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Closes #1030.
Revised after review — this PR no longer adds a serve-path registration gate. See the discussion; rationale summarized below and written into ADR 019.
The journey
g_node_01_onboarding.rsstarts where an operator starts — a provisioned data dir, a running daemon, nothing on chain — and drives the productiondecdn setupCLI throughapprove→bond→declareMbps→registerNodeto a paid delivery that settles on-chain.Nothing covered this. Every other journey begins already onboarded (
NodeFixture::launchonboards before the daemon spawns),cli_setup_partialdrivessetuponly into a revert, andsmokeproves delivery from an already-bonded node. No test ransetupto a clean finish, and none started from nothing.The load-bearing property is that it happens on one process, no restart. That is what proves the daemon's registry projection is live — a
NodeRegisteredevent reaching a running node — rather than a value sampled at bring-up. That projection feeds DHT admission, so a stale one is a real defect.Why there is no serve-side gate
ADR 019 §Phase 4 lists
isActiveNode(nodeId)as an acceptance criterion, which reads like a daemon obligation. It is not one, and the ADR now says so.A node checking its own registration and refusing to sell constrains only operators who were never the threat — anyone who wants to sell unregistered deletes the check and rebuilds. The real constraints are external and already exist:
declareMbps, soDecdnGovernor._getVotescaps each epoch atdeclaredMbpsAtEpoch × epochSeconds × BYTES_PER_MBIT_SECOND= 0 (contracts/src/DecdnGovernor.sol:265, landed in feat(contracts): cap governance vote weight by declared capacity per epoch #1760).Neither is removable by patching the daemon. ADR 019 records this, including why a serve-side gate should not be re-added.
A real bug found along the way
EjectedByBlacklistwas missing from the registry route's topic0 OR-set.ejectedis a conjunct ofisActive, so a blacklist ejection only landed at the 15-minute re-enumeration — and every consumer of the staker set, DHT admission included, was wrong until then. That one is a peer-side decision, not self-policing, so it stays.A correction to the issue text
#1030 lists "under-bonded
bond()reverts". It does not.bond()guards onlyZeroAmount, so an under-bond succeeds and the TOKEN really moves; the floor is enforced downstream atregisterNode. That is a worse failure mode than the issue describes — an operator can strand capital in the contract and still not be registered — so the test pins the guard that exists.Both negatives (
BondBelowMinimum,NodeIdAlreadyBound) had zero coverage anywhere in the repo, Solidity or Rust.Also included
registry_activeonadmin_v1_health/decdn node health, documented as purely diagnostic. It answers "my node is up and earning nothing" — more necessary without a gate, not less, since nothing on the wire says so and the traffic simply never arrives.New e2e fixtures:
NodeFixture::launch_bare(the only path to an un-onboarded daemon),ChainFixture::register_node_raw(the signing half ofonboard_operator, which is now built on it) andfund_and_bond.Verification
cargo nextest run --workspacecargo nextest run -p decdn-e2e --features anvil-e2edecdn-nodeanvil settlement + bringupcargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --check,cargo doc, ADR book guards, markdownlintcrates/node/src/handlers/,crates/node/src/metrics.rsandcrates/node/tests/are byte-identical tomain.Contracts are untouched.
🤖 Generated with Claude Code