Skip to content

refactor(rewards): remove never-emitted ChainPeakUnavailable (dig_ecosystem#3448) - #636

Merged
MichaelTaylor3d merged 2 commits into
developfrom
loop/3448-remove-chain-peak-unavailable
Oct 5, 2026
Merged

MichaelTaylor3d merged 2 commits into
developfrom
loop/3448-remove-chain-peak-unavailable

Conversation

@MichaelTaylor3d

Copy link
Copy Markdown
Contributor

Refs DIG-Network/dig_ecosystem#3448

What

  • Removes ChainPortError::ChainPeakUnavailable and its RPC machine code REWARD_CHAIN_PEAK_UNAVAILABLE (match arm + const in seams/dig_rpc/dispatch.rs). Zero producers and zero consumers org-wide; dig-rpc-protocol SPEC 4.5 only requires "a JSON-RPC error", which Other/Unavailable already give.
  • Rewrites the chain_peak_height doc in rewards/port.rs to name the real refusal: dig_rewards_coin::read_distributor refuses to build a ChainObservation without a peak (Malformed -> ChainPortError::Other; a failed read -> ChainUnavailable -> ChainPortError::Unavailable).
  • Test: distributor_report_refuses_when_the_chain_has_no_peak over a real simulator launch with a peak-less MockChainSource (shared builder mock_chain_source_without_peak; mock_chain_source now calls it).

Wire answer for an absent peak

JSON-RPC code -32032, data.code CONTROL_ERROR, message "reward-distributor chain read failed: ... no peak height".

Test scope (honest)

Port-level: asserts Err(ChainPortError::Other(msg)) with msg containing "no peak height". A NotADistributor/Unavailable refusal would fail the message assertion, so the read provably reaches the peak step. The behaviour already existed, so this is a pin, not a red-first fix. The dispatch Other arm already maps it to the wire answer above; that mapping is not re-tested here.

Not touched: crates/dig-node-service/src/rewards/chain_port.rs (dig-node#630). No version bump.

🤖 Generated with Claude Code

MichaelTaylor3d and others added 2 commits October 5, 2026 12:55
Zero producers and zero consumers; the real adapter already refuses an absent peak via read_distributor (Other/Unavailable). Fix the chain_peak_height doc to name that refusal.

Refs DIG-Network/dig_ecosystem#3448

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@MichaelTaylor3d MichaelTaylor3d left a comment

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.

PASS at a9bf40f.

Checked: (1) mock_chain_source refactor is behaviour-identical (same coins/spends/lineage, timestamps 0..=height, same peak applied last); (2) new test reaches the peak step: state.rs read_distributor checks peak only after all coin/lineage checks, message "chain source exposes no peak height" contains the asserted substring, and any NotADistributor/Unavailable/other Other would fail it; it goes red if the adapter emitted a 0 peak (Ok) ; (3) git grep for ChainPeakUnavailable / REWARD_CHAIN_PEAK_UNAVAILABLE is empty at head; (4) rewritten doc matches chain_port.rs reader_error_to_port_error (Malformed -> Other, ChainUnavailable -> Unavailable); (5) readable, no duplication.
CI: Test + coverage and Lint commit messages green; Rustfmt/Clippy/Release-script/CodeQL were runner-starved (not a code signal) - confirm they go green before merge. No threads opened. Did not run cargo locally.

@MichaelTaylor3d

Copy link
Copy Markdown
Contributor Author

PASS — loop-security verdict, dig-node#636 head a9bf40fbcee07ae25b66745c4381eb1f91d8700e (base c3d6f96). Read-only audit from git objects, own worktree.

  1. Fail-closed: CLEAR. report_from_snapshot (chain_port.rs:193-194) takes the peak from snapshot.observed() (non-Option peak_height()); an absent peak never reaches it because dig-rewards-coin read_distributor refuses (Malformed -> ChainPortError::Other, chain_port.rs:316). Both reward read methods share reward_chain_port_error_response, so both refuse identically. The removed variant was never constructed, so no behavioural path is lost, and no 0 or second-read peak exists anywhere in the diff.
  2. Other arm: message path unchanged by this PR (dispatch.rs:103). The string is RewardsError/LaunchCommentError Display text, not raw peer bytes; the absent-peak case yields a static string with nothing attacker-relevant. NOTE (defence-in-depth, not gating, already tracked as #3456 shape): dispatch.rs interpolates msg without a local bound; SPEC §3.7 cl.4 bounding is not applied at this site. Pre-existing and out of this diff.
  3. Exhaustiveness: ChainPortError is not #[non_exhaustive], but grep over the whole tree finds no reference to the removed variant or machine code and the only exhaustive match is dispatch.rs (updated in the same diff). Variant was unconstructed in released v0.262.1, so no downstream match could be depending on it. Semver-breaking only in the pedantic sense for an internal crate.
  4. Tests: fixture split is behaviour-preserving (mock_chain_source = same coins/timestamps + with_peak(sim.height()), identical value as before). Existing A3 tests still use mock_chain_source with a peak; the new test asserts the refusal comes from the peak read (msg.contains("no peak height")), so it cannot pass vacuously on NotADistributor/Unavailable. No masking found.

Not covered: no cargo build/test run (CI Test + coverage PASS reported at this SHA); dig-rewards-coin internals taken from L1 measurement, not re-read.

@MichaelTaylor3d
MichaelTaylor3d marked this pull request as ready for review October 5, 2026 21:03
@MichaelTaylor3d
MichaelTaylor3d merged commit 57c505f into develop Oct 5, 2026
10 of 21 checks passed
@MichaelTaylor3d
MichaelTaylor3d deleted the loop/3448-remove-chain-peak-unavailable branch October 5, 2026 21:10
MichaelTaylor3d added a commit that referenced this pull request Oct 5, 2026
…#637)

* refactor(rewards): remove never-emitted ChainPeakUnavailable (dig_ecosystem#3448) (#636)

* refactor(rewards): remove never-emitted ChainPeakUnavailable

Zero producers and zero consumers; the real adapter already refuses an absent peak via read_distributor (Other/Unavailable). Fix the chain_peak_height doc to name that refusal.

Refs DIG-Network/dig_ecosystem#3448

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* test(rewards): pin absent-peak refusal at the chain port

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>

* chore(release): v0.262.2 -- remove never-emitted ChainPeakUnavailable

Refs DIG-Network/dig_ecosystem#3448

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

1 participant