Repository navigation
feat(cli): add decdn node rotate-key + G-NODE-07 journey (#1034) - #1614
Conversation
Wraps `adr/appendix-operator-key-rotation.md` as a command. `--key` picks the path, because the two are not comparable in cost or effect. `--key iroh` rebinds the wire node id through `CapacityBond.bindNodeId`: stage a fresh key, build the terms-free `BindNodeId` EIP-712 signature plus the new key's ed25519 ownership proof, submit, and install `node.secret` ONLY after the receipt carries a matching `NodeIdBound` log. That ordering is the point. Disk-first would leave a daemon serving under a key no binding names, and such a node is unslashable — `SlashJudge._checkRegistered` resolves the accused through `nodeIdOf` — so it keeps earning while its bond is unreachable. Chain-first risks only the inverse, a plain outage that `--bind-existing` repairs. `--key eth` moves the whole on-chain identity, since no rebinding API exists for the address. Phase comes from chain state the way `decdn node unbond` does — deregister, request, waiting, withdraw, reonboard, complete — so a run that lost its receipt converges instead of double-submitting. It reuses `bond::execute` and `register::submit_registration` rather than growing a second copy of that sequence. The daemon now flags the unslashable state it cannot otherwise surface: one `addressToNodeId` read at bring-up, a WARN naming the repair, and `binding`/`bound_node_id` on `admin_v1_health`. Advisory by construction — refusing to start on a transient RPC failure would brick the node during the window an operator needs it up to fix the binding. Also fixes two things found on the way: - The e2e chain fixture deployed a sentinel `currentTermsHash`, which made every CLI registration journey impossible: `terms::ensure_accepted` refuses to sign against terms the binary does not hash to. It now deploys the real `keccak256(TERMS.md)`. - The CI journey timeout inventory was already stale by one test, crediting `cli_fetch_topup` with four running tests when its fourth is `#[ignore]`d. Corrected to a verified 27 tests / 328m, and the bound raised 175m -> 200m to keep the compile headroom the previous bump targeted. Verified: fmt, `clippy --workspace --all-targets --all-features -D warnings`, `cargo doc` in CI form, 2801 unit tests, all 36 anvil-e2e tests, cargo-deny. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Free Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe PR adds ChangesNode key rotation and binding health
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Operator
participant RotateKeyCLI
participant CapacityBond
participant NodeDaemon
Operator->>RotateKeyCLI: Run rotate-key workflow
RotateKeyCLI->>CapacityBond: Read binding and migration state
RotateKeyCLI->>CapacityBond: Submit rotation transaction
CapacityBond-->>RotateKeyCLI: Return receipt and binding event
RotateKeyCLI->>NodeDaemon: Install key after confirmed iroh binding
NodeDaemon->>CapacityBond: Check binding during startup
NodeDaemon-->>Operator: Report binding status through health
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 |
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 90.07% (2629/2919 lines) |
Coverage reportTotal: 80.17% (was 80.82%, ▼ 0.65%) — 62068/77423 lines
History
|
Follow-up: the anvil-e2e timeout budgets I touched here are incoherent, not just largeThis PR raised Checking the actual numbers turned up something worse than over-provisioning. The two budgets contradict each other: the job bound is ~25× the observed run, while the per-test ceilings are smaller than the fixture retry ladders they are supposed to contain. Both follow from the same mistake — every figure in that comment is derived from other figures, and none is anchored to a measurement. Observed job duration
The sibling Observed test durationFull suite locally at
The rest are ≤ 16s. The 1200s tier runs ~110× faster than its ceiling. The contradictionUnder CI,
That is ~38m of setup inside a test whose largest ceiling is 20m. The ladders are partly unreachable today: a test that hits them trips its own Proposal
Caveats
|
Code reviewStrengths
Critical
Important
AssessmentReady to merge: No. The Ethereum retry path can directly create an active on-chain/local-key mismatch, while the Iroh path still violates its no-write and reorg-safety guarantees. These affect the core slashability invariant and should be fixed before merging. |
ReviewOverviewImplements the operator key-rotation runbook as Findings1. The module doc says: "Committing the fresh key up front … makes the phase resumable — a failed Mostly harmless (no registration landed, so any fresh key works), but there is a narrow race the resumability story is supposed to cover: Suggested fix (either is fine):
2. CI timeout inventory arithmetic is off by 3m — The corrected buckets are 13m×12 + 20m×4 + 10m×8 + 5m×3 = 156 + 80 + 80 + 15 = 331m, not the 328m the comment states (and the PR description repeats as "verified 27 tests / 328m"). Balanced 2-thread ceiling is therefore ~166m, not ~164m. Cross-check from the other direction agrees: the corrected pre-PR sum is 285m (298 − 13), and G-NODE-07 adds 46m → 331m. The 200m bound still leaves ~34m of compile headroom, so nothing functional changes — but this comment is precisely the one that "has gone stale three times now", and it's shipping stale a fourth time. Worth fixing the numbers before merge. 3. Security consideration: dry-run output contains a live, submittable binding signature for a discarded key —
4. Minor: post-migration re-run without
5. Minor: Sampled-once is well justified (readiness path), and the DTO doc says so — but after What looks particularly good
VerdictApprove-shaped with fixes requested on #1 (comment or behavior) and #2 (numbers) before merge; #3–#5 are take-or-leave polish. Generated by Claude Code |
Two reviewers converged on the same root cause, from different angles: reonboard's unconditional fresh-key-per-attempt breaks the resumability the module doc promises. A registerNode(K1) broadcast with an unread receipt, followed by a retry before K1 mines, would mint and install K2 and submit registerNode(K2); if K1 then lands first, K2's registration reverts while node.secret already holds it — the daemon ends up serving an unbound key, the exact mismatch this whole command exists to prevent, reachable through the retry path instead of the happy one. Fix: reuse the key already on disk when nothing on chain claims it (key_is_reusable), mint fresh only otherwise. The first-ever reonboard call still mints fresh, because deregisterNode never clears nodeIdToAddress, so the pre-migration key reads as "claimed" (by the old address) and falls through to the same mint path. Also fixes, in order of what each finding actually was: - A --dry-run preview of a fresh iroh key created data_dir as a side effect of stage_node_key's ensure_data_dir call, even though the temp file itself was removed on drop -- a real filesystem write from a command advertised to write nothing. Fixed by generating the preview key fully in memory (NewKey::Preview) rather than staging it, so a preview against a nonexistent data_dir now touches no path on disk. - --new-keystore could silently name the SAME address a --key eth migration is leaving, which would re-bond the old address rather than migrate anywhere. Refused as soon as the phase names a destination address. - The CI journey-timeout inventory comment carried a 331m sum that had been transcribed as 328m (13*12+20*4+10*8+5*3=331, not 328), so the derived ~164m balanced ceiling was also off. Corrected the arithmetic; timeout- minutes stays 200 since even the corrected ~166m ceiling leaves ~34m of compile headroom. Referenced #1620, which tracks replacing this whole sum-of-ceilings derivation with one anchored to observed job duration. - Documented two narrower findings rather than changing behavior for them: a dry-run's printed bindNodeId signatures stay submittable against the live nonces until the binding nonce advances (an off-chain griefing lever if the output leaks), and BindingStatus::Mismatch doesn't clear to Bound until the daemon restarts, so a mismatch seen right after --bind-existing is a stale sample, not a failed repair. Not fixed: the ask to require finalized/safe-block inclusion before committing node.secret on the iroh path. send_for_receipt waits for exactly one inclusion everywhere in this codebase (register, deregister, bond, unbond all use the same helper with no confirmation-depth parameter), and the runbook this PR added is explicit that one block confirmation is the intended semantics (adr/appendix-operator-key-rotation.md, step 5). Adding bespoke confirmation-depth logic to only this one command would be inconsistent with every other on-chain write in the CLI; a reorg-safety policy, if wanted, is a cross-cutting concern for all of them, not this PR. Verified: fmt, clippy --workspace --all-targets --all-features -D warnings, 2808 unit tests (7 new: key_is_reusable / ensure_distinct_operator / dry_run_acquire_creates_no_data_dir / preview_key_refuses_to_commit and their surrounding cases), all 3 G-NODE-07 anvil-e2e journeys. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Fixed The critical/#1 finding (both reviews)Confirmed: Dry-run FS mutationConfirmed —
|
Five analysis agents reviewed the PR; every claim below was verified against the contracts or the source before being accepted. CORRECTION TO MY OWN PRIOR ROUND. In 88a1b54 I added a warning to the ADR and to a code comment claiming a leaked --dry-run output lets a third party submit bindNodeId and strand the operator. That is false, and I introduced it by implementing a review suggestion without checking the contract: _verifyBindingSignature derives the digest from bindingNonce[msg.sender] and validates with isValidSignatureNow(msg.sender, ...), and the ed25519 proof puts msg.sender in its preimage. A third-party submitter IS msg.sender, so the operator's signatures cannot validate — the transaction reverts InvalidBindingSignature. There is no relayer path. Both copies of the claim are removed and replaced with what is actually true: a dry run discards the key whose id it prints, so that id must not be recorded as the node's next identity. Critical: - A lost receipt could destroy the new secret and reach the unslashable state. send_for_receipt sets InFlight(hash) BEFORE awaiting the receipt, so a receipt-fetch failure returns Err with the transaction already broadcast; the Err arm dropped NewKey, and StagedNodeKey::drop deletes the temp. If the transaction then mined, the chain was bound to a key whose secret existed nowhere while the daemon served an id bindNodeId had just unbound. Adds StagedNodeKey::keep(), which parks the secret at node.secret.pending.<node_id> — deliberately not node.secret, so no daemon loads it — whenever outcome.maybe_effected(). A definitively-rejected send still discards it rather than littering key material. Important: - Two paths past the send (failed confirm_bound, failed commit) returned before write_plan, so a --json consumer got empty stdout for exactly the states that most need a receipt — byte-identical to a config error that sent nothing. Both now report before propagating, and the transaction hash is read before the gate so every error can name it. - A broken stdout replaced the operation error: write_plan(...)? discarded it, so piping into head turned "may have been broadcast — re-sending is not idempotent" into "Broken pipe". The receipt now degrades to stderr on both paths and the real error survives. - preview_key was derived from dry_run, so a failed real run reported preview_key=false — asserting the printed new_node_id named a persisted key at exactly the moment it named one just discarded or parked. Now derived from whether the key was actually persisted. - eth submitted omitted approve and declare, both of which bond::execute can land independently, printing approve_tx=0x... next to submitted=false. bond::write_plan, the direct twin, ORs all three of its slots. - ensure_distinct_operator never fired on the phases that matter: select_phase returned deregister/request/waiting/withdraw before reading --new-keystore, so a same-address keystore was accepted silently and only refused after the 14-day window. Now validated on every invocation. The keystore is loaded once per invocation and reused rather than decrypted per branch — scrypt is deliberately expensive and this runs on every call across the migration (the G-NODE-07 eth journey went 78s -> 12s). - The address that transacts was not provably the one confirmed: select_phase loaded the keystore to derive and disclose an address, then reonboard loaded it AGAIN and transacted from that. reonboard now takes the planned address and refuses a mismatch. - confirm_bound also matches the emitting contract address, not just topic0 and the indexed fields. Documentation corrections: - Two comments described a nodeId -> address lookup the slashing path does not perform. _checkRegistered(challengedNode, nodeId) resolves the challenged ADDRESS through nodeIdOf, so a challenge citing a retired id against a still-bound operator reverts NodeIdMismatch; NodeNotRegistered fires only when the address has no binding at all. The PR's premise is unchanged — evidence against the served, unbound key still cannot be submitted. - The documented "carry the original node id across" procedure could not work: --key iroh frees the original on-chain but also archives it and installs the throwaway, so the eth path finds the throwaway on disk and mints a third key. The archive-restore step is now stated in the disclosure, the module doc, and the ADR. - --mbps help promised a default that cannot exist (deregisterNode clears the tier, so the fallback is unreachable and every real re-onboarding hits the required-flag error). Two other places in the PR said so correctly; the clap help, which operators actually read, was the odd one out. - --bind-existing help rendered literal ** markdown in the terminal. - Documented that both keystores unlock from one password source. Tests: confirm_bound had no coverage at any layer despite being the gate on the irreversible local write — six cases added (matching log, no log, wrong operator, wrong node id, foreign contract, match among other logs), built from real encode_log_data receipts. The foreign-contract case fails against the pre-hardening filter. Plus the failed-real-run preview_key regression. Verified: fmt, clippy --workspace --all-targets --all-features -D warnings, cargo doc in CI form, 2815 unit tests (7 new), all 3 G-NODE-07 anvil-e2e journeys. Reported but not actioned (type reshapes, select_phase pure seam, e2e assertion tightening, ASD-STE100 nits): see the PR comment. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review round 3 — five-agent pass, fixes in
|
Four agents reviewed round 3 — the commit that was itself a response to round 2. Every high-severity claim was verified against the source before being accepted; three agents converged independently on the first two. CRITICAL, and a hole in round 3's own fix. Round 3 added key-parking for the two post-send paths where the bind's fate is UNCERTAIN, and left the one path where it is PROVEN as the only one that still destroyed the key. Reaching `new_key.commit()` means `confirm_bound` already matched a NodeIdBound log for this exact operator and id, so the chain names this key — and `StagedNodeKey::commit(self)` dropped the stage on a failed install, letting Drop delete the temp. Worst corner: `install_staged`'s restore-also-failed branch leaves node.secret MISSING, and --bind-existing refuses when no key is on disk, so recovery needed a manual .bak restore plus a second bindNodeId and another binding nonce. Now `commit` takes &mut self, the caller retains the key, and both post-send failures park it — recovery is a mv. Same principle applied one level down: `keep()` used to destroy the temp when its own rename failed. It now sets committed first and leaves the material in place, naming the surviving path — it is only ever called when the key may already be bound, so an awkwardly-named file beats a lost identity. `commit` keeps the opposite policy on purpose (a failed install means never bound), and a test now pins that the two do not get 'unified'. Important: - MaybeBroadcast rendered as submitted=false / bind_tx=skipped on the exact path that parks a key, so a --json wrapper read 'nothing happened' and would re-run, double-submitting over the same binding nonce. submitted is now tri-state (true/unknown/false) with bind_tx=unknown and a maybe_broadcast field. This is the bug round 3 fixed on the eth side, left on the iroh side. - The parked key was stderr-only English. parked_key is now a field in both renderings, and the three different reasons for its absence are no longer conflated — describe_key_fate consults the key rather than the Option. - confirm_bound's error hard-coded 'has been preserved separately', which is false under --bind-existing (nothing to preserve) and when parking failed (stderr simultaneously said discarded). The claim moved to the caller. - The success path swallowed a failed stdout write and exited 0, losing bind_tx and archived_key. report()'s degradation is for paths that already carry an error; success now fails. Same for eth's Ok arm. - confirm_bound computed the ABI-drift-vs-absence distinction and discarded it, then told the operator the two were indistinguishable. They imply opposite recoveries (install the parked key vs delete it), so it now partitions and reports which, including the decode error. - The eth planned-operator guard's message shipped with collapsed indentation from a heredoc that ate its line continuations — which was itself evidence the branch had never been executed. Extracted as a pure ensure_planned_operator and tested, including a guard on the whitespace. Tests (the whole parking mechanism was unverified — zero callers outside production code): - StagedNodeKey::keep: parks and survives Drop, the bytes reload to the recorded public key, node.secret is untouched, and a failed rename leaves the temp with its path named. Plus the abandoned-stage and failed-commit policies, so the three outcomes stay distinct. - park-vs-discard across all six SendOutcome variants, and both non-staged NewKey arms. - submitted for each of the seven transaction slots, and the negative case that a minted node id alone is not a submission. - e2e: a same-address --new-keystore is refused on the FIRST invocation, with is_registered still true afterwards — pinning 'refused before deregisterNode', which nothing asserted. Docs: the .pending. artifact now has a rollback row in the runbook; the ADR's named revert is EOA-qualified (a permissive ERC-1271 submitter clears the binding check and reverts InvalidEd25519Signature instead); 'before deregister' dropped as over-constraining (bindNodeId has no active/bond precondition); the dry-run paragraph carves out --bind-existing; and key_persisted is renamed key_installed, since a parked key IS persisted and still is not the identity. Verified: fmt, clippy --workspace --all-targets --all-features -D warnings, 2825 unit tests (10 new), all 3 G-NODE-07 anvil-e2e journeys. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…merge
Main moved `TERMS.md` from the repo root into `crates/cli/` (the new
package-embeds check: an `include_str!` reaching the workspace root builds
in-tree and then fails for every `cargo install` user, because a published
`.crate` contains only its own package directory).
The merge was textually clean, so nothing flagged that this fixture's
`include_str!("../../../TERMS.md")` no longer resolved — it surfaced only on
the post-merge build. Repointed at `../../cli/TERMS.md`, which is legitimate
here solely because `decdn-e2e` is `publish = false` and the check exempts
unpublished crates; the doc now says so, since the old rationale ("repo-root
TERMS.md") no longer describes where the file lives.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review round 4 — four-agent pass on round 3, fixes in
|
One conflict, in adr/appendix-operator-key-rotation.md steps 7-10 of the EOA -> EOA migration. #1650 rewrote the payment model from pairwise channels to a shared pool and swept this file's vocabulary; this branch had rewritten step 8 in review round 4. Resolved per-line rather than per-hunk, since the two sides touched disjoint steps: - step 7 -> main (rewritten for pools; this branch never edited it) - step 8 -> ours (the 'from the old address' fix that dropped an over-constraining 'before deregister', plus the three-step archive-restore procedure — main left step 8 untouched) - steps 9, 10 -> main (channels -> pools) Deliberately NOT swept: the channel vocabulary in this branch's Rust doc comments. #1650 is ADR-only (no crates/, no contracts/) — PaymentChannel.sol still exists and PaymentPool.sol does not — so those comments describe what the code actually does today. Rewriting them to pool vocabulary would make them false, which is the failure mode the earlier review rounds were about. The metric names decdn_channels_open and decdn_channel_deposit_usdc are likewise unchanged, matching main's own choice to keep them. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Closes #1034.
What
decdn node rotate-key --key <iroh|eth>— the operator key-rotation runbook (adr/appendix-operator-key-rotation.md) as a command, plus the G-NODE-07 journey.--key iroh— rebind the wire node idStage a fresh key → build the terms-free
BindNodeIdEIP-712 signature and the new key's ed25519 ownership proof → submitbindNodeId→ installnode.secretonly after the receipt carries a matchingNodeIdBoundlog.The ordering is the design, not a detail. Disk-first would leave a daemon serving under a key no binding names, and that node is unslashable:
SlashJudge._checkRegistered(challengedNode, nodeId)resolves the challenged address throughnodeIdOfand requires the cited id to equal the bound one, so evidence gathered against the key the node is actually serving under reverts (NodeIdMismatch, orNodeNotRegisteredwhen nothing is bound). The node keeps serving and keeps getting paid while its bond is unreachable. Chain-first risks only the inverse — a plain outage, repaired by--bind-existing.--dry-runproduces real signatures over a real key and writes nothing at all — not evendata_dir, which staging would have created as a side effect. The preview key is generated in memory only.--bind-existingbinds whatever is already atnode.secret— the repair lever for a hand-swapped key, and the runbook's rollback path.NodeIdAlreadyBoundbefore spending gas.--key eth— migrate the Ethereum addressNo rebinding API exists for the address, so this moves the whole identity across the unbonding window. Phase is read from chain state the way
decdn node unbonddoes —deregister → request → waiting → withdraw → reonboard → complete— so a run that lost its receipt converges rather than double-submitting. Reusesbond::executeandregister::submit_registrationinstead of growing a second copy of that sequence. The maturing phase exits non-zero so a polling wrapper cannot read it as done.Daemon: flag the unslashable state
New
crates/node/src/binding_check.rs. OneaddressToNodeIdread at bring-up, a WARN naming the repair, andbinding/bound_node_idonadmin_v1_health(rendered bydecdn node health). Advisory by construction — a daemon that refused to start on a transient RPC failure would be unusable during exactly the window an operator needs it up to fix the binding.Tests
crates/e2e/tests/g_node_07_rotate_key.rs, three journeys:addressToNodeId/nodeIdToAddressmappings the slashing path reads, not on the liveness-awareisActiveNode); the retired id stops answering and the new one serves; bond, tier,firstBondedAt, and the open channel survive; a delivery paid for before the rotation still settles.bindNodeIdreportsbinding=mismatch, resolves to no operator on-chain, and is repaired by--bind-existing. A second--bind-existingis refused rather than silently consuming a nonce.advance_time, then asserts the two costs it cannot avoid: a fresh node id, and a resetfirstBondedAt.Two fixes found on the way
currentTermsHash, which made any CLI registration journey impossible —terms::ensure_acceptedrefuses to sign against terms the binary does not hash to. It now deploys the realkeccak256(TERMS.md). All 36 journeys still pass, so nothing depended on the sentinel.cli_fetch_topupwith four running tests when its fourth is#[ignore]d. Corrected to a verified 27 tests / 331m (see the review round below for a further arithmetic fix on top of this);timeout-minutesraised 175 → 200 to keep the ~25m of compile headroom the previous bump targeted.Review round 2
Two reviews converged on the same root cause from different angles:
reonboard(the--key ethre-onboarding phase) minted a fresh node key on every invocation, unconditionally — contradicting the module doc's own resumability claim. An unreadregisterNode(K1)receipt followed by a retry could mint and install K2 before K1 mines; if K1 then lands first, K2's registration reverts whilenode.secretalready holds it — the exact unslashable mismatch this whole command exists to prevent, reachable through the retry path instead of the happy one. Fixed by reusing the key already on disk when nothing on chain claims it (key_is_reusable, unit-tested); the very firstreonboardcall still mints fresh, sincederegisterNodenever clearsnodeIdToAddressand the pre-migration key reads as bound to the old address.Also fixed:
--dry-runpreview of a fresh iroh key createddata_diras a side effect ofstage_node_key'sensure_data_dir, even though the temp file itself was removed on drop — a real filesystem write from a command advertised to write nothing. Fixed with an in-memory-onlyNewKey::Previewvariant; added the nonexistent-data-dir test.--new-keystorecould silently name the SAME address a--key ethmigration is leaving. Refused as soon as the phase names a destination address (ensure_distinct_operator).timeout-minutesstays 200 since the corrected ~166m ceiling still leaves ~34m of headroom, and now links ci: right-size the anvil-e2e timeout budgets (200m bound vs ~6m runs; per-test ceilings smaller than their retry ladders) #1620 for the further work replacing the whole sum-of-ceilings derivation.Documented rather than changed:
BindingStatus::Mismatchdoesn't clear toBounduntil the daemon restarts, so a mismatch seen right after--bind-existingis a stale sample, not a failed repair. (This round also added a warning about dry-run signatures being submittable by a third party — that was wrong and is retracted in round 3 below.)Not changed: the ask for finalized/safe-block confirmation depth before committing
node.secreton the iroh path.send_for_receiptwaits for exactly one inclusion everywhere in this codebase (register,deregister,bond,unbondall share it, no confirmation-depth parameter), and the runbook this PR adds is explicit that one block confirmation is the intended semantics (step 5). Special-casing reorg safety for only this command would be inconsistent with every other on-chain write in the CLI — a cross-cutting concern for all of them, not a fix scoped to key rotation.Review round 3
A five-agent pass (code review, silent-failure, test coverage, comment accuracy, type design). Every claim was verified against the contracts or the source before being acted on; three agents independently converged on the
submittedbug and two on the staged-key hole.Retraction from round 2. Round 2 added a warning — to the ADR and a code comment — that a leaked
--dry-runoutput lets a third party submitbindNodeIdand strand the operator. That is false._verifyBindingSignaturederives the digest frombindingNonce[msg.sender]and validates withisValidSignatureNow(msg.sender, …), and the ed25519 proof putsmsg.senderin its preimage — a third-party submitter ismsg.sender, so the operator's signatures cannot validate and the transaction revertsInvalidBindingSignature. There is no relayer path. It was introduced by implementing a review suggestion without checking the contract. Both copies are removed and replaced with what is actually true: a dry run discards the key whose id it prints, so that id must not be recorded as the node's next identity.Critical — a lost receipt could destroy the new secret and reach the unslashable state.
send_for_receiptsetsInFlight(hash)before awaiting the receipt, so a receipt-fetch failure returnsErrwith the transaction already broadcast — and the error arm droppedNewKey, whoseDropdeletes the staged temp. If the transaction then mined, the chain was bound to a key whose secret existed nowhere, while the daemon served an idbindNodeIdhad just unbound. AddedStagedNodeKey::keep(), parking the secret atnode.secret.pending.<node_id>— deliberately notnode.secret, so no daemon loads it — wheneveroutcome.maybe_effected(). A definitively-rejected send still discards it rather than littering key material.Important:
confirm_boundand failedcommitreturned beforewrite_plan, so--jsongot empty stdout for exactly the states that most need a receipt — indistinguishable from a config error that sent nothing. Both now report first, and the tx hash is read before the gate so every error can name it.headturned "may have been broadcast; re-sending is not idempotent" into "Broken pipe". The receipt now degrades to stderr on both paths.preview_keywas derived fromdry_run, so a failed real run reportedpreview_key=false— claiming the printed id named a persisted key at the moment it named one just discarded or parked. Now derived from whether the key was actually persisted.submittedomittedapprove/declare, both of whichbond::executecan land independently — printingapprove_tx=0x…next tosubmitted=false.ensure_distinct_operatornever fired on the phases that matter:select_phasereturned deregister/request/waiting/withdraw before reading--new-keystore, so a same-address mistake surfaced only after the 14-day window. Now checked on every invocation, with the keystore loaded once per call rather than per branch (scrypt is deliberately expensive — the eth journey went 78s → 12s).reonboardre-loaded the keystore after the prompt and transacted from that. It now takes the planned address and refuses a mismatch.confirm_boundnow also matches the emitting contract address, not justtopic0and the indexed fields.Documentation corrections:
--key irohfrees the original on-chain but also archives it and installs the throwaway, so the eth path finds the throwaway on disk and mints a third key. The archive-restore step is now stated in the disclosure, the module doc, and the ADR.--mbpshelp promised a default that cannot exist (deregisterNodeclears the tier, so the fallback is unreachable);--bind-existingrendered literal**markdown in the terminal.Tests:
confirm_bound— the gate on the irreversible local write — had no coverage at any layer. Six cases added from realencode_log_datareceipts (matching log, no log, wrong operator, wrong node id, foreign contract, match among others); the foreign-contract case fails against the pre-hardening filter, so it is discriminating rather than decorative.Reported but not actioned, with rationale, in this comment: type reshapes,
select_phasepure-seam extraction, e2e assertion tightening, and style nits. One out-of-scope item is filed as #1623 rather than bundled.Verification
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
decdn node rotate-keyworkflows for Iroh key rebinding and Ethereum operator-key migration.--bind-existing.Documentation
Tests