Skip to content

fix: batch seven review follow-ups (#1342, #1343, #1344, #1345, #1347, #1350, #1355) - #1358

Merged
thiras merged 8 commits into
mainfrom
fix/1342-1355-review-followups-batch
Jul 21, 2026
Merged

thiras merged 8 commits into
mainfrom
fix/1342-1355-review-followups-batch

Conversation

@thiras

@thiras thiras commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Batches the review follow-ups filed off #1340, #1341 and #1353. Two multi-agent review passes ran against this branch; roughly half the diff is the response to what they found, so the history is worth reading commit-by-commit rather than as a squash.

Issues closed

Issue Change
#1342 ReportGate folded into ReputationWiring as a sum type
#1343 reputation_publish_trigger doc no longer enumerates causes (it named 2 of 5)
#1344 Enforce-without-sink is now unrepresentable rather than tested
#1345 report_gate rename, NodeStakedNodeSet narrowed, fail-OPEN doc corrected
#1347 Stale "this alloy build ships no Asserter" comments corrected
#1350 Discovery module doc named a caller that doesn't exist
#1355 decdn node bond / setup drop partial outcomes on failure

#1356 is a duplicate of #1347 and can be closed with it.

⚠️ Correction to commit edb3e80's message

That commit's body claims the real callers are fetch::discover_provider and bundle_pull::discover_candidates. The second symbol does not exist — I copied it from #1350's text without verifying, inside a commit whose subject is about fixing inaccurate comments. The code is fixed (the real sites are fetch::discover_provider and the discovery branch of bundle_pull::bundle_pull); the commit message could not be amended (rebase -i unavailable in that environment), so it is corrected here where reviewers will see it.

Breaking change

c1fbd8d removes the ReportGate export and ReputationWiring's struct literal. Callers: the runtime and four test sites, all updated. GossipRuntimeConfig::subscribe_reputation is also gone — the operator-facing [gossip] subscribe_reputation TOML key is unchanged; decdn-node now resolves it into the wiring variant at the single site that builds it, so there is one authority instead of two.

The two defects worth reviewing closely

bond's resume guidance could double the bond. chain_ctx::send captured the tx hash before awaiting the receipt but returned it only inside the error string, so outcome.bond stayed None on a receipt-fetch timeout — meaning the "do NOT re-run" arm fired only when the bond had confirmed (where re-running is safe), while the arm that fired in the dangerous case said "no bond transaction followed" and pointed at the already-settled approve hash. alloy's nonce filler resolves against the pending block, so following that advice submits a second bond. send now takes a landed: &mut Option<B256> slot with an explicit contract: Some means may have taken effect (including the unreadable-receipt case), cleared on a confirmed revert.

AnnounceGate::Disabled is now #[cfg(test)]. It fails OPEN on ADR 001 rule 2 and was guarded only by a doc comment plus a test on announce_staked_gate — which would stay green if a future edit passed Disabled to spawn, reopening the hole #1170 closed. It no longer exists in production builds.

Tests

  • Two resume_hint tests assert the property (every arm naming a hash must hedge and warn), not a denylist of previous phrasing — the first version denylisted four literals and missed an arm phrasing the same falsehood differently.
  • New e2e journey cli_setup_partial drives the production binary against anvil and asserts setup --json still prints its summary when a live phase fails. Needed a lever that breaks a write while every read succeeds (starving the operator of TOKEN trips the pre-flight), so ChainFixture gains pause_capacity_bond.
  • The gossip integration test's drain now varies its payload per round: plumtree dedups byte-identical messages for 90s and the publisher stamps whole seconds, so a constant payload silently collapsed a 50-round budget to ~6.
  • Every new test was mutation-verified. Note cargo nextest -p decdn-e2e does not rebuild target/debug/decdn, so a CLI mutation check silently tests a stale binary; CI is unaffected (ci.yml builds both binaries first).

Verification

cargo fmt --check, cargo clippy --workspace --all-targets -- -D warnings, RUSTDOCFLAGS=-D warnings cargo doc --document-private-items, 2573/2573 unit tests, and all 19 anvil-e2e journeys pass. No Solidity behaviour changed (one binding added), so .gas-snapshot is unaffected.

Pre-existing on main and untouched here: markdownlint/whitespace failures in .github/workflows/issue-triage.*, and two clippy similar_names/cognitive_complexity errors in crates/e2e/tests/ that only surface under --features anvil-e2e (not linted by CI's clippy job).

Deliberately not done

  • #1346, #1348, #1349 — blocked on feat(client-pull): retry + peer-cache fallback for registry bootstrap #1341, and two need a design decision.
  • #1347 part 2 (writing the deferred swap-revert tests) — only the false premise is removed here.
  • cli::commands::channel is not migrated to the shared submitter: it classifies a revert as an expected Ok(TxOutcome::Reverted), since a channel someone else already closed is a normal race.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Setup now reports partial progress and retains transaction details when a live operation fails.
    • Bonding commands provide clearer guidance for safely resuming after interrupted transactions.
    • Transaction errors now include more actionable failure context across node, appeal, publishing, and swap commands.
  • Bug Fixes

    • Improved handling of failed, pending, or unreadable transaction confirmations.
    • Gossip reputation features now fail closed when required configuration is incomplete.
  • Documentation

    • Clarified command output semantics and client-side node discovery behavior.

thiras and others added 7 commits July 21, 2026 18:16
…er both gate branches (#1342, #1343, #1344, #1345)

Follow-ups from the review of #1340, grouped because they all touch the
staked-membership gate seam.

#1342 — `ReportGate<S>` took `AnnounceGate<S>`'s generic shape without its
justification. `Copy` could never apply (the only instantiation is
`Arc<dyn StakedNodeSet>`, which is not `Copy`), `Clone` had no call sites, and
there is no borrowed form: `validate_reputation_envelope` takes a bare
`&dyn StakedNodeSet` and the gate is resolved once at spawn. Made it a concrete
enum and deleted the `OwnedReportGate` alias. The doc now states why the shape
differs from its sibling, so the difference reads as a signal that the two are
not interchangeable rather than as drift.

#1345 — `ReputationWiring.staked` held a gate, not a set, and kept the name
from when it was an `Option<Arc<dyn StakedNodeSet>>`; renamed to `report_gate`,
which lets the field doc drop the opener that existed only to undo the name.
`NodeStakedNodeSet` narrowed to `pub(crate)`: both gate constructors are
described as the unit-tested guarantee that the runtime never fails open, and
that claim only holds while wrapping the set in a gate is the only way to reach
it. Reconciled `AnnounceGate::Disabled`'s "accept any signature-valid announce"
with what it does — it skips the staked-membership check alone; version byte,
trailing bytes, payload variant, region allowlist and clock skew still reject.

#1343 — the `reputation_publish_trigger` "iff" list named two causes; there are
five (the issue itself missed the failed-subscribe branch). Replaced with a
pointer to the function that owns them, since an exhaustive list sited away
from the branch is what went stale in the first place.

#1344 — two coverage gaps. The `sink: None` + `Enforce` row was untested even
though the comment justifying the single combined check cites exactly that case,
so a future split of the check would leave every test green. And nothing drove a
report through the spawned subscriber; the new three-node integration test
proves both polarities — B admits A's signed report, C rejects it with
`NotStakedReporter` — where B admitting establishes the broadcast happened, so
C's counter is attributable to the gate and not to a mesh that never formed.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
, #1347)

#1350 — `client-pull`'s discovery module doc claimed it exists so `decdn
fetch`/`probe` can pick a node. `probe` has no `discovery::` reference and still
requires an explicit target; the real callers are `fetch::discover_provider` and
`bundle_pull::discover_candidates`. Named them, and made `probe`'s exclusion
explicit so the next reader does not re-derive it.

#1347 — both swap venues defer their revert-path coverage citing "this alloy
build ships no `Asserter`/`MockProvider`". That is false: `Asserter` +
`connect_mocked_client` ships in the pinned alloy and is already used in
`blacklist_watcher`, `chain_events`, and `cli::unbond`. This is a comment that
*caused* a coverage gap rather than describing one — the stated reason for
skipping the test does not hold — so it is corrected and pointed at the working
idiom. Writing the deferred tests stays open as follow-up; only the false
premise is removed here.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`decdn node bond` submits up to three transactions — approve, bond, declareMbps
— recording each hash into an `Outcome` owned inside `execute`. Any failure
dropped the whole thing: an operator whose `bond` mined and whose `declareMbps`
reverted saw empty stdout and no record that their TOKEN had moved into
`CapacityBond`. Same defect #1353 fixed for `unbond`, left alone there to keep
that PR scoped.

`execute` now takes `&mut Outcome` and returns `Result<()>`; `run` owns the
value, always writes the plan before propagating, and attaches context naming
what landed and that a re-run converges (bond tops up only the shortfall, so it
cannot over-bond).

`setup` had the same bug one level up and is the worse case: under `--json` the
only bond output is the aggregated summary at the end, so a mid-sequence failure
printed nothing at all. It now owns the outcome and emits it on the error path.

While here, the three hand-rolled send/receipt/`ensure!(status)` triples in
`bond` and the one in `register` now route through `unbond`'s `send` helper,
promoted to `chain_ctx`. Its doc already described itself as that triple factored
out of `bond::execute`. This also fixes a latent defect in both: `send` captures
the tx hash *before* awaiting the receipt, so a receipt-fetch timeout still names
the in-flight transaction, which the bespoke code lost entirely. `register`'s
send-failure string also advised "check RPC, gas"; dropped deliberately, since
the wrapped transport error already says which and the bond/curve half of that
advice only ever applied to the revert — which is now carried as the hint.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
#1342, #1344)

Review follow-up. #1342 removed `ReportGate`'s vestigial generic; the type
review that followed argued the type should not survive standalone at all, and
it is right.

`ReputationWiring` carried `sink`, `report_gate` and `report_drain` as three
independent fields whose validity was interdependent: 8 representable
combinations for what is really "off", "subscribe-only" and "subscribe+publish".
The admission set and the sink it feeds are ONE decision — a set with nowhere to
put what it admits is meaningless, and a sink with no set would consume unvetted
reports — so they are now one variant:

    enum ReputationWiring { Disabled, Enabled { sink, staked, publish } }

What this buys beyond tidiness:

- The combination #1344 asked for a test of — an enforcing gate with no sink —
  is now UNREPRESENTABLE. That test is deleted rather than kept, because the
  type change subsumes it. Its own doc had conceded the weakness: line coverage
  was already satisfied by the `Disabled` sibling, so a future split of the
  combined check would have left every test green.
- The `sink_wired`/`gate_enforcing` shadow copies and the "not fully wired"
  runtime `warn!` are gone with it. `Disabled` is now a stated intent, not a
  wiring accident to diagnose after startup.
- `is_enforcing` had exactly one caller — that warn — and is deleted.
- #1338's hazard is resolved at the root: there is no longer a second gate of
  the same shape with inverted fail polarity to confuse `AnnounceGate` with.
  `AnnounceGate`'s "do not confuse with" caveat is rewritten to say so.

`report_staked_gate` becomes `report_staked_set` (returning the membership set;
the on/off decision is the variant now). Its test keeps pinning the thing that
matters — that the set tracks the live registry rather than being permissive.

Also from the review, in the same files:

- `AnnounceGate::Disabled`'s rule list omitted signature verification and read
  as exhaustive, so it could be taken to mean signatures are skipped. They are
  not — `verify_signature` runs before the gate is consulted.
- The `reputation_publish_trigger` doc still enumerated causes right after
  saying an enumeration is what went stale. It now only points at the function.
- `NodeStakedNodeSet`'s `pub(crate)` rationale was false: exporting it would
  create no un-gated path, since the only thing an external caller could build
  with it is what `announce_staked_gate` already returns. The real un-gated seam
  is `AnnounceGate::Disabled`, which this does not touch. Narrowing is kept on
  its own merit (minimal surface) with the true reason stated.
- The integration test's drain now varies its payload per round. plumtree dedups
  by blake3(content) for 90s and the publisher stamps whole seconds, so constant
  reports were byte-identical within a second — collapsing the advertised 50-round
  retry budget to ~6. It also now asserts metric fidelity end to end.

BREAKING: `ReputationWiring`'s struct literal and the `ReportGate` export are
gone. Callers: the runtime and four test sites, all updated.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…report holes (#1355, #1350)

Review follow-up to the #1355 fix, which reported a partial `bond` sequence but
got the guidance attached to it wrong in a way that could cost an operator money.

**The resume advice could double the bond.** `chain_ctx::send` returns `Err`
when a receipt cannot be FETCHED — its own doc says "the transaction is in
flight either way" — so an absent hash means "not confirmed", never "did not
happen". The messages asserted the strong negatives anyway ("no TOKEN was
transferred", "on-chain state is unchanged") and told the operator to re-run
immediately. Since alloy's nonce filler resolves against the *pending* block, a
re-run while a `bond` tx is still in the mempool takes the next nonce, re-reads
a stale `activeBond`, and submits a SECOND top-up. The message claimed the
opposite as a guarantee: "it tops up only the remaining shortfall, so it will
not over-bond" — true only after settlement.

Extracted as `resume_hint` and unit-tested, which the previous version was not:
the arms are one edit from telling someone whose TOKEN has moved that only an
allowance was granted, and the old `write_plan`-only test could not fail for
that (it exercised a formatter this change never touched).

**The `hint` was attached to the arm that never fires.** `build_provider` uses
`ProviderBuilder::new()`, which installs the recommended fillers, so `send()`
runs `eth_estimateGas` — a call that would revert fails there, before broadcast,
and never reaches the receipt check. `register`'s bond/curve/signature guidance
was therefore unreachable in practice, and its send-failure text had been
dropped on the reasoning that the revert arm covered it. It does not. `send` now
carries the hint on both arms, which also restores `bond`'s capacity-band hint.

**A failed stdout write masked the chain error.** `write_plan(...)?` ran before
the propagation, so `decdn node bond --json | head` (EPIPE; Rust ignores
SIGPIPE) lost the "bond ALREADY LANDED" message entirely — the exact outcome
#1355 exists to prevent, reintroduced via the reporting call. The chain error
now always wins; the write error goes to stderr.

**`setup`'s hole was only half closed.** The previous fix guarded the bond phase
only, so under `--json` a *register* failure still printed nothing, and a landed
swap's tx hash — irreversibly spent USDC — had no machine-readable carrier at
all (`hline` is a no-op under `--json`; only `build_summary` emits it). The live
phases are now one fallible section with a single reporting site, so a failure at
any phase emits the aggregated summary with whatever landed. `build_summary`
takes `Option<&Readiness>` and flags `partial`, so both paths emit the SAME
shape and a consumer branches on the flag rather than recognising a second
object shape.

Also: `write_tx_line`'s doc promised `skipped` lets an operator distinguish a
no-op from a failure. Since #1355 prints the outcome on the error path too, it
does not; the doc now says the exit status is the discriminator.

And #1350: the discovery module doc named `bundle_pull::discover_candidates`,
which does not exist — I copied the symbol from the issue text without checking
it, in the same batch whose subject was fixing inaccurate comments. The real
sites are `fetch::discover_provider` and the discovery branch of
`bundle_pull::bundle_pull`, with the ranking half also used by
`fetch::probe_and_rank`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…t two safety-inverting docs

Second review pass. The previous commit's headline fix was decorative and one
new doc actively blessed the hazard it described.

**The WAIT-before-re-running guidance was unreachable.** `chain_ctx::send`
captured the tx hash before awaiting the receipt — but then returned it only
inside the error *string*, so `outcome.bond = Some(send(...).await?)` left
`outcome.bond` as `None` on a receipt-fetch timeout. The arm warning "do not
re-run, a second bond doubles it" therefore fired only when the bond had
*confirmed*, where re-running is safe; the arm that actually fired said "no bond
transaction followed" and told the operator to wait on the already-settled
approve hash. Following it literally double-bonds — the exact harm the rewrite
existed to prevent.

`send` now takes a `landed: &mut Option<B256>` slot with a documented contract:
untouched if nothing was broadcast, `Some` if the tx may have taken effect
(including the unreadable-receipt case), cleared on a confirmed revert. So
`Some` means "may have taken effect", never merely "was broadcast", and
`resume_hint` selects the right arm. It is also matched over all three steps
rather than two — ignoring `declare` was correct only by a control-flow fact the
function cannot see.

The forbidden-phrase test was the reason this slipped through: it denylisted four
literal strings from the previous wording, and the offending arm phrased the same
falsehood differently. It now asserts the property — every arm naming a hash must
hedge and must warn against re-running.

**`setup` re-created the `?`-masking bug its sibling had just fixed**, in the same
commit: the partial-report write discarded the chain error, and the `--json` arm
used `println!`, which panics on EPIPE. Both fixed; the bond re-run guidance is
now attached there too, gated on the bond phase being the one that failed.

**Two docs were wrong in the safety-inverting direction:**

- `AnnounceGate`'s rewritten caveat claimed "nothing of this shape is fail-closed
  any more — read `Disabled` as permissive without checking which gate you are
  looking at". `ReputationWiring::Disabled` is fail-CLOSED, one file away, as its
  own doc says. What #1342 removed is the shape collision, not the inverted pole.
- `validate_envelope` said signature verification "runs first"; it runs last of
  the pre-gate rules, contradicting an in-body comment 40 lines down.

Also from the review: the #864 warning was over-broad (it fired for every
`Enabled` wiring, so every deliberate opt-out, including `publish: None` where
nothing accumulates); the fully-disabled-but-subscribed case lost its only
diagnostic and gets an `info!` back; the partial `--json` summary conflated "not
due" with "registration failed", now split by a `due` field; a dangling
"#1345's follow-up" reference and a stale `report_staked_gate` name were removed;
and the plumtree payload-variation fix is now pinned by an assertion on C's
reject counter (which the gate ordering leaves un-rate-limited), verified to fail
with `got 0` when the drain reverts to a constant.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…unify tx submission, single off-switch, e2e the partial report

Everything the second review pass left open.

**`AnnounceGate::Disabled` is now `#[cfg(test)]`.** It fails OPEN on ADR 001
rule 2, and its only guard was a doc comment plus a unit test asserting that
`announce_staked_gate` returns `Enforce` — which would stay green if a future
edit passed `Disabled` straight to `spawn`, reopening the hole #1170 closed. The
variant no longer exists in a production build, so that is now a compile error
rather than a convention. Cheaper than expected: `decdn-gossip` has no `tests/`
dir and no feature table, so plain `#[cfg(test)]` covers its own tests, and the
single external user (`self_hosted_discovery`) was passing it at a call site its
own comment describes as irrelevant — swapped for `Enforce(AllStaked)`.

The knock-on is the point: `announce_staked_gate_enforces_never_fails_open`'s
`let ... else { panic!() }` is now irrefutable, so the half of that test which
guarded the variant is deleted. The invariant moved from the test to the
compiler. The membership half — that the set is the *live* registry, not a
permissive stub — is what the test still pins.

**One authority for "is reputation gossip on".** `subscribe_reputation` is gone
from `GossipRuntimeConfig`; `decdn-node` resolves the operator knob into the
`ReputationWiring` variant at the single site that builds it. Previously there
were two ways to say "off", checked at two points in `spawn_reputation_tasks`,
while the runtime pinned the wiring to `Enabled` permanently — so the type's
fail-closed pole was decorative and a bool did the real work. The operator-facing
`[gossip] subscribe_reputation` key is untouched (no schema change). The #864
warning moves to the runtime, which is the only scope holding both
`subscribe_reputation` and `node_to_node_pull_through_enabled`; from inside the
gossip crate it could only guess which the operator meant to change. Its
gossip-side test is deleted as a duplicate of the `Disabled` one.

**Transaction submission is shared, including the swap venues.** `send` moved to
`decdn_incentive::tx` so the venues can use it — they spend USDC, the least
recoverable write the workspace makes, and both hand-rolled the send/receipt pair
with the hash read *after* `get_receipt()`, so a receipt timeout produced an
error naming no transaction at all. `appeal` and `publish` migrate too (the
latter via `send_for_receipt`, which returns the receipt for callers that decode
event logs). `channel` is deliberately NOT migrated and the module doc says why:
it classifies a revert as an expected outcome rather than an error, and routing
it through here would turn a normal race into a hard failure. The previous
"who still hand-rolls this" list was already stale — the same failure mode #1343
removed from `GossipHandles` — so it now states the exception and its reason
rather than enumerating callers.

**The `setup` partial report has a real test.** The unit test only covered
`build_summary`'s shape; deleting the entire emission left it green. The new
journey drives the production binary against anvil and asserts stdout is not
empty on a mid-sequence failure. Inducing that failure needed a lever that breaks
a *write* while every *read* still succeeds — starving the operator of TOKEN
trips the pre-flight and never enters the live phase — so `ChainFixture` gains
`pause_capacity_bond`: `bond()` is `whenNotPaused`, the balance/allowance/curve
views are not. Verified by mutation: replacing the emission's guard with `false`
fails the test.

One trap found while verifying that: `cargo nextest -p decdn-e2e` does not
rebuild `target/debug/decdn`, so a mutation check on CLI behaviour silently tests
a stale binary. CI is unaffected — `ci.yml` builds `decdn-node` + `decdn-cli`
before the journeys.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 21, 2026 17:53
@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@thiras, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 08d5082f-e624-4601-b1b1-4b1a2caff2b7

📥 Commits

Reviewing files that changed from the base of the PR and between 43a2694 and c831a60.

📒 Files selected for processing (3)
  • crates/cli/src/commands/register.rs
  • crates/cli/src/commands/setup.rs
  • crates/e2e/tests/cli_setup_partial.rs

Walkthrough

The changes centralize on-chain transaction submission, preserve partial CLI outcomes, add partial setup JSON reporting, and replace reputation report-gate wiring with fail-closed staked-node-set configuration and integration coverage.

Changes

Transaction flow and CLI reporting

Layer / File(s) Summary
Shared transaction submission helper
crates/incentive/src/{lib.rs,tx.rs}
Adds shared helpers for receipt handling, revert reporting, and landed transaction hashes.
Swap transaction adoption
crates/incentive/src/swap_*.rs
Routes swap submissions and allowance resets through the shared helper while preserving best-effort cleanup.
CLI transaction command migration
crates/cli/src/commands/{appeal,chain_ctx,publish,register,unbond}.rs, crates/client-pull/src/discovery.rs
Updates command transaction paths to use centralized submission and outcome recording.
Bond partial-outcome reporting
crates/cli/src/commands/bond.rs
Reports accumulated outcomes on errors and adds resume guidance based on recorded hashes.
Setup partial JSON flow
crates/cli/src/commands/setup.rs, crates/e2e/src/*, crates/e2e/tests/cli_setup_partial.rs
Represents incomplete setup with partial, nullable readiness, registration due state, and a paused-contract regression test.

Reputation gossip wiring

Layer / File(s) Summary
Reputation admission API
crates/gossip/src/{lib.rs,reputation.rs,validation.rs}, crates/node/src/reputation_wiring.rs
Removes report-gate types, exposes staked-node-set admission, and limits announce-gate disabling to tests.
Fail-closed service wiring
crates/gossip/src/service.rs
Replaces optional reputation wiring with Disabled and Enabled enum variants and updates task spawning.
Node reputation runtime integration
crates/node/src/runtime/mod.rs, crates/node/tests/anvil_bringup_shutdown_e2e.rs
Builds reputation wiring from node configuration and removes the obsolete runtime field.
Subscriber gating integration test
crates/node/tests/self_hosted_discovery.rs
Adds multi-node coverage for accepting reports from staked reporters and rejecting reports from non-staked reporters.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant TransactionHelper
  participant Chain
  participant SetupSummary

  CLI->>TransactionHelper: submit transaction
  TransactionHelper->>Chain: send call and await receipt
  Chain-->>TransactionHelper: hash and receipt status
  TransactionHelper-->>CLI: outcome hash or error
  CLI->>SetupSummary: emit success or partial JSON summary
Loading
sequenceDiagram
  participant NodeRuntime
  participant GossipService
  participant ReputationSubscriber
  participant StakedNodeSet
  participant ReputationSink

  NodeRuntime->>GossipService: construct Enabled or Disabled wiring
  GossipService->>ReputationSubscriber: spawn reputation task when enabled
  ReputationSubscriber->>StakedNodeSet: check reporter membership
  StakedNodeSet-->>ReputationSubscriber: accept or reject
  ReputationSubscriber->>ReputationSink: deliver accepted report
Loading

Note

🎁 Summarized by CodeRabbit Free

Your 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 @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors transaction submission to ensure that partial outcomes and transaction hashes are preserved and reported during failures across commands like bond, setup, and register. It also simplifies the gossip reputation wiring into a sum type to prevent configuration errors. The review feedback identifies a critical bug where the registration transaction hash is still lost on failure because the transaction slot is not passed as a mutable reference from the caller, and suggests a minor readability improvement for a test timeout duration.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/cli/src/commands/register.rs Outdated
// The hint below reaches both the send and revert arms, which matters here:
// `registerNode`'s failure modes are pre-flight gas-estimate reverts, so it
// is the SEND arm that fires in practice.
let mut landed = None;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

Currently, submit_registration defines landed as a local variable and returns Result<RegisterOutcome>. If chain_ctx::send fails (e.g., due to a receipt fetch timeout), the error is propagated with ? and the local landed variable is dropped. As a result, the caller (setup.rs) receives an Err and register_outcome remains None, meaning the transaction hash is completely lost and cannot be reported in the partial JSON summary.

To fix this and ensure the partial outcome is preserved on failure (matching the behavior of bond::execute), we should pass a mutable reference to the outcome or the transaction slot. For example, we can update submit_registration's signature to take tx_slot: &mut Option<B256>:

pub(crate) async fn submit_registration<P: Provider + Clone>(
    // ... other args ...
    dry_run: bool,
    tx_slot: &mut Option<B256>,
) -> anyhow::Result<RegisterOutcome> {

And then pass tx_slot directly to chain_ctx::send:

    let tx = chain_ctx::send(
        bond.registerNode(...),
        "registerNode",
        Some(...),
        tx_slot,
    )
    .await?;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed and fixed in c831a60 — this is the same defect #1355 fixed for bond, in the one command this branch left alone (I'd flagged it as an unaddressed follow-up rather than fixing it).

Took the signature you suggested, tx_slot: &mut Option<B256>, because caller-ownership is the part that actually makes it survive. Threading it is only half the fix, though: build_summary's register object had no tx field on the register_outcome: None arm, so the hash would have been carried and then dropped at the point of rendering. That arm now emits tx alongside skipped/due, with a unit test pinning that an unresolved registration is named and stays distinguishable from a not-due one.

Comment on lines +526 to +537
let outcome = register::submit_registration(
&provider,
&signer,
&resolved.data_dir,
cb_addr,
resolved.chain_id,
&args.region,
&args.multiaddrs,
terms_hash,
false,
)
.await?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

If register::submit_registration fails (e.g., due to a receipt fetch timeout), the error is propagated immediately via ? at line 537. Because of this, register_outcome (initialized to None at line 491) is never populated with the partial outcome, and the transaction hash is lost from the final JSON summary printed on failure.

To preserve the transaction hash on failure, we should initialize register_outcome before the call and pass a mutable reference to its tx slot to submit_registration (updating its signature accordingly), so that any broadcast transaction is recorded even if the receipt fetch fails.

Comment thread crates/e2e/tests/cli_setup_partial.rs Outdated
use tokio::process::Command;

/// Matches the other CLI journeys (anvil launch + forge deploy dominate).
const OVERALL_TIMEOUT: Duration = Duration::from_secs(780);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The duration of 780 seconds is exactly 13 minutes. For better readability, we should define this duration in minutes using Duration::from_mins instead of Duration::from_secs.

Suggested change
const OVERALL_TIMEOUT: Duration = Duration::from_secs(780);
const OVERALL_TIMEOUT: Duration = Duration::from_mins(13);
References
  1. Prefer using Duration::from_mins instead of Duration::from_secs when defining durations in minutes for better readability, provided the pinned Rust toolchain supports it (Rust 1.80.0+).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Adopted in c831a60. Verified Duration::from_mins is const-stable on the pinned toolchain (1.95) and already used at crates/gossip/src/service.rs:560 and crates/client-pull/src/buyer_channel.rs:71, so this is consistent with the codebase rather than new surface.

Better than my original in a way worth noting: I had added #![allow(clippy::duration_suboptimal_units)] to match the sibling e2e journeys, which suppressed the lint instead of fixing it. The allow is now gone, since the timeout is the only Duration in the file. anvil_bringup_shutdown_e2e.rs:52 documents why second-scale timeouts stay from_secs; 780s is exactly 13 minutes, so it isn't one of those.

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.

Pull request overview

This PR batches follow-ups across gossip reputation wiring, CLI onboarding resilience, and transaction submission ergonomics. It primarily hardens safety-critical “on/off” states into unrepresentable types, ensures transaction hashes are retained through receipt-fetch failures, and adds integration/e2e coverage for previously untested paths.

Changes:

  • Refactors reputation gossip wiring into a sum type (ReputationWiring::{Disabled, Enabled{…}}) and removes the redundant subscribe_reputation gating from GossipRuntimeConfig.
  • Introduces a shared tx submitter (decdn_incentive::tx) and migrates multiple call sites to capture tx hashes before awaiting receipts.
  • Reworks CLI bond / setup to report partially-landed outcomes on failure, and adds new integration/e2e tests for reputation gating and partial setup reporting.

Reviewed changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/node/tests/self_hosted_discovery.rs Adds an end-to-end integration test that drives reputation reports through the spawned subscriber path and asserts staked-reporter gating.
crates/node/tests/anvil_bringup_shutdown_e2e.rs Updates test config construction to match the removal of subscribe_reputation from GossipRuntimeConfig.
crates/node/src/runtime/mod.rs Resolves gossip.subscribe_reputation into the ReputationWiring variant at the runtime’s single wiring site and emits a targeted warning for inert knob combinations.
crates/node/src/reputation_wiring.rs Narrows NodeStakedNodeSet visibility and splits “reputation on/off” from “membership source” by returning a staked set for ReputationWiring::Enabled.
crates/incentive/src/tx.rs Adds a shared transaction submission helper that records tx hashes before receipt waits and defines the landed contract.
crates/incentive/src/swap_uniswap.rs Migrates Uniswap venue send/receipt logic to the shared tx helper and corrects stale testing rationale comments.
crates/incentive/src/swap_balancer.rs Migrates Balancer venue send/receipt logic to the shared tx helper and corrects stale testing rationale comments.
crates/incentive/src/lib.rs Exports the new tx module.
crates/gossip/src/validation.rs Makes AnnounceGate::Disabled test-only (#[cfg(test)]) and updates docs/Debug/as_gate accordingly.
crates/gossip/src/service.rs Refactors reputation wiring into ReputationWiring enum, removes subscribe_reputation from runtime config, and updates spawn logic/tests.
crates/gossip/src/reputation.rs Removes the now-obsolete ReportGate type and related exports.
crates/gossip/src/lib.rs Updates public re-exports to reflect the removal of ReportGate/OwnedReportGate.
crates/e2e/tests/cli_setup_partial.rs Adds an anvil-e2e journey asserting decdn setup --json still prints a partial summary when a live phase fails.
crates/e2e/src/chain.rs Adds pause_capacity_bond to deterministically force mid-sequence write reverts while keeping reads live.
crates/e2e/src/bindings.rs Extends CapacityBond bindings with pause/unpause for e2e control.
crates/client-pull/src/discovery.rs Corrects module docs to name real callers and explicitly state decdn probe still requires an explicit target.
crates/cli/src/commands/unbond.rs Switches call sites to chain_ctx::send(.., &mut landed) and updates docs to reference the shared submitter.
crates/cli/src/commands/setup.rs Restructures live phases so bond/register outcomes are owned outside fallible sections and emits a partial summary on failure.
crates/cli/src/commands/register.rs Migrates registerNode submission to the shared tx helper.
crates/cli/src/commands/publish.rs Migrates several publish-path transactions to the shared tx helper, including receipt-returning cases.
crates/cli/src/commands/chain_ctx.rs Re-exports decdn_incentive::tx::send as chain_ctx::send to preserve call-site shape.
crates/cli/src/commands/bond.rs Restructures bonding to preserve/print partial outcomes on failure and adds operator-facing resume guidance.
crates/cli/src/commands/appeal.rs Migrates appeal transactions to the shared tx helper to preserve hashes across receipt failures.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/cli/src/commands/register.rs Outdated
Comment on lines +191 to +193
let mut landed = None;
let tx = chain_ctx::send(
bond.registerNode(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in c831a60, though not quite as suggested — &mut outcome.tx alone would not work here.

outcome is a local returned by value, so the ? on the send propagates and drops it before the caller sees anything; writing the hash into outcome.tx would still lose it. The slot has to be caller-owned to survive the Err, so submit_registration now takes tx_slot: &mut Option<B256> and setup keeps it beside register_outcome, rendering it as register.tx in the partial summary.

Same conclusion as the gemini thread above, which spotted the caller-ownership requirement.

@github-actions

github-actions Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 81.52% (was 81.33%, ▲ +0.19%) — 52812/64785 lines

File Coverage Lines Δ
crates/cli/src/commands/appeal.rs 50.53% 96/190 ▲ +1.80%
crates/cli/src/commands/bond.rs 66.02% 239/362 ▲ +34.42%
crates/cli/src/commands/chain_ctx.rs 91.50% 560/612 ● 0.00%
crates/cli/src/commands/publish.rs 54.87% 259/472 ▲ +1.03%
crates/cli/src/commands/register.rs 27.66% 52/188 ▼ 0.15%
crates/cli/src/commands/setup.rs 48.20% 537/1114 ▲ +4.29%
crates/cli/src/commands/unbond.rs 71.45% 483/676 ▲ +1.65%
crates/client-pull/src/discovery.rs 84.74% 161/190 ● 0.00%
crates/e2e/src/chain.rs 1.19% 11/926 ▼ 0.02%
crates/gossip/src/reputation.rs 100.00% 335/335 ● 0.00%
crates/gossip/src/service.rs 86.32% 732/848 ▲ +4.08%
crates/gossip/src/validation.rs 100.00% 367/367 ● 0.00%
crates/incentive/src/swap_balancer.rs 66.98% 142/212 ▲ +7.48%
crates/incentive/src/swap_uniswap.rs 64.06% 139/217 ▲ +5.13%
crates/incentive/src/tx.rs 72.34% 34/47 new
crates/node/src/reputation_wiring.rs 95.57% 367/384 ▲ +0.50%
crates/node/src/runtime/mod.rs 45.29% 1111/2453 ▼ 0.07%
History
Commit Total Δ vs base
43a2694 81.51% ▲ +0.18%
c831a60 (HEAD) 81.52% ▲ +0.19%

…summary

Review feedback on #1358. `submit_registration` passed `chain_ctx::send` a
local `landed` slot, so a `registerNode` that was broadcast but whose receipt
could not be read lost its hash: the slot died with the function, and `setup`'s
partial `--json` summary reported the registration as merely `skipped`.

That is the same defect #1355 fixed for `bond`, in the one command this branch
left alone — I had flagged it as an unaddressed follow-up rather than fixing it.

The slot is now caller-owned (`tx_slot: &mut Option<B256>`), which is what makes
it survive: writing into the local `RegisterOutcome` instead would not, because
that is returned by value and the `Err` takes it. `setup` keeps the slot beside
`register_outcome` and renders it as `register.tx`, so the partial summary names
the in-flight transaction — the case where an operator most needs it, since
re-running while it is pending is what duplicates a registration.

Also from the review: `Duration::from_mins(13)` in the new e2e journey, which
drops the `duration_suboptimal_units` allow rather than suppressing it. Verified
const-stable on the pinned toolchain and already used in `gossip` and
`client-pull`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[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.

2 participants