Skip to content

test(e2e): G-NODE-01 onboarding journey, bare to accepting delivery (#1030) - #1768

Merged
alpergundogdu merged 6 commits into
mainfrom
feat/1030-node-registry-serve-gate
Aug 20, 2026
Merged

alpergundogdu merged 6 commits into
mainfrom
feat/1030-node-registry-serve-gate

Conversation

@yigitdot

@yigitdot yigitdot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

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.rs 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 to a paid delivery that settles on-chain.

Nothing covered this. Every other journey begins already onboarded (NodeFixture::launch onboards before the daemon spawns), cli_setup_partial drives setup only into a revert, and smoke proves delivery from an already-bonded node. No test ran setup to 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 NodeRegistered event 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:

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

EjectedByBlacklist was missing from the registry route's topic0 OR-set. ejected is a conjunct of isActive, 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 only ZeroAmount, so an under-bond succeeds and the TOKEN really moves; the floor is enforced downstream at registerNode. 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_active on admin_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 of onboard_operator, which is now built on it) and fund_and_bond.

Verification

Suite Result
cargo nextest run --workspace 2763 passed
cargo nextest run -p decdn-e2e --features anvil-e2e 49 passed
decdn-node anvil settlement + bringup 5 passed
cargo clippy --workspace --all-targets --all-features -- -D warnings clean
cargo fmt --check, cargo doc, ADR book guards, markdownlint clean

crates/node/src/handlers/, crates/node/src/metrics.rs and crates/node/tests/ are byte-identical to main.

Contracts are untouched.

🤖 Generated with Claude Code

yigitdot and others added 5 commits August 20, 2026 17:57
#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]>
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]>
@yigitdot
yigitdot force-pushed the feat/1030-node-registry-serve-gate branch from 3f53e10 to 4669821 Compare August 20, 2026 15:06
@alpergundogdu

Copy link
Copy Markdown
Contributor

Let's not actually enforce this gate in the serve path — please pull the production staker_set.is_active(...) check out of serve_stream and keep this PR test-only.

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:

  • Drop the serve-path gate itself (the is_active check above the pay/send branch), plus the decdn_serve_stream_rejected_not_registered_total counter and the registry_active reject wiring that only exist to support it.
  • Drop the test that asserts enforcement — the "refuses at step 1, delivers at step 3, one process no restart" hinge in g_node_01_onboarding.rs (and the corresponding gate assertions in client_loopback.rs).
  • Keep everything else: the G-NODE-01 onboarding journey through the real decdn setup CLI to a paid delivery, and the two negatives that had zero coverage (BondBelowMinimum, NodeIdAlreadyBound).

The EjectedByBlacklist topic0 fix is a genuine bug in the registry route and should stay regardless — that one affects DHT admission, which is a real peer-side decision, not node self-policing.

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]>
@yigitdot yigitdot changed the title feat(node): enforce the ADR 019 registry serve gate + G-NODE-01 onboarding journey (#1030) test(e2e): G-NODE-01 onboarding journey, bare to accepting delivery (#1030) Aug 20, 2026
@yigitdot

Copy link
Copy Markdown
Contributor Author

Agreed, and done — the gate is out. 9c3e9f8b.

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 isActiveNode(nodeId) as an acceptance criterion and the daemon didn't implement it, and read that gap as a missing enforcement rather than as an acceptance criterion that was never a daemon obligation. That's the part worth fixing in the ADR, which I did.

Dropped: the is_active check in serve_stream, ServeRejectReason::NotRegistered and its wire mapping, decdn_serve_stream_rejected_not_registered_total, the ClientHandlerDeps staker-set wiring, the two client_loopback.rs tests, and the refusal step in the journey. crates/node/src/handlers/, metrics.rs and crates/node/tests/ are now byte-identical to main.

Kept: the journey through the real decdn setup to a paid delivery, both negatives, and the EjectedByBlacklist topic0 fix.

Three things worth flagging:

Your no-vote-weight claim is stronger than you stated, and I've cited it. PaymentPool runs no isActive gate at redeem, so I checked whether an unregistered node could redeem and accrue weight anyway. It can redeem — but DecdnGovernor._getVotes caps each epoch's credited bytes at declaredMbpsAtEpoch(account, e) × epochSeconds × BYTES_PER_MBIT_SECOND (contracts/src/DecdnGovernor.sol:265). An unregistered operator never called declareMbps, so the cap is 0 and every delivered byte credits zero weight. That's #1760, landed two days ago. The ADR cites it rather than asserting it, so the reasoning doesn't rot if that cap moves.

I kept registry_active on admin_v1_health, and I want to be explicit since it's the one place I read you loosely. You said to drop "the registry_active reject wiring that only exists to support it" — I took that as the reject wiring, not the health field. My reasoning: it's a read-only diagnostic that gates nothing, so it doesn't touch your principle, and without a gate it's more necessary, not less — nothing on the wire tells an operator why their healthy node earns nothing, because the traffic simply never arrives. It's also the observable that lets the journey assert the daemon saw its own registration without a restart. Say the word and I'll drop it; it's contained to four files.

On "drop the hinge": I removed the refusal assertion but kept the bare → setup → delivery arc on one process with the no-restart poll on registry_active. That half isn't an enforcement claim — it proves the registry projection is live rather than sampled at boot, which matters for DHT admission regardless. If you meant to drop that too, it's a small cut.

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 --all-features clean. The branch name still says serve-gate — happy to leave it since it squash-merges.

@github-actions

Copy link
Copy Markdown

Coverage report

Total: 81.28% (was 81.15%, ▲ +0.13%) — 60683/74658 lines

File Coverage Lines Δ
crates/cli/src/commands/node.rs 77.37% 1012/1308 ▲ +0.42%
crates/common/src/admin.rs 93.58% 102/109 ● 0.00%
crates/e2e/src/chain.rs 13.60% 229/1684 ▼ 0.36%
crates/e2e/src/node.rs 23.30% 120/515 ▼ 1.49%
crates/node/src/admin.rs 93.75% 975/1040 ▼ 0.89%
crates/node/src/dht/capacity_bond_registry.rs 79.07% 593/750 ▲ +0.78%
crates/node/src/runtime/mod.rs 47.88% 1094/2285 ▼ 0.35%
History
Commit Total Δ vs base
9c3e9f8 (HEAD) 81.28% ▲ +0.13%

@alpergundogdu
alpergundogdu merged commit 8425857 into main Aug 20, 2026
26 checks passed
@alpergundogdu
alpergundogdu deleted the feat/1030-node-registry-serve-gate branch August 20, 2026 16:36
alpergundogdu added a commit that referenced this pull request Aug 20, 2026
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]>
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.

e2e G-NODE-01: node onboarding full sequence (bare → accepting delivery)

2 participants