Skip to content

fix(cli): label earnings periods by when coverage starts, not by the earliest settlement - #2679

Merged
thiras merged 1 commit into
mainfrom
fix/earnings-coverage-label-2624
Oct 28, 2026
Merged

thiras merged 1 commit into
mainfrom
fix/earnings-coverage-label-2624

Conversation

@thiras

@thiras thiras commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

What

decdn node earnings added "(ledger from )" to a period that started before the earliest settlement row. That is not when the data source started covering. Two cases from #2623's review:

  • Daemon: a ledger that ran 30 days before its first settlement labelled a complete last 7d as truncated.
  • Chain mode (--address): the real boundary, the first scanned block's time, never appeared in the response.

EarningsResponse.covered_from_unix: u64 replaces ledger_since_unix. Each producer reports what it knows:

  • Daemon: a one-row settlement_ledger_start_v1 stamp in settle.redb.
    • The open that finds no stamp writes it; a reopen only reads it.
    • It is dropped with the ledger, in the same transaction, on a PaymentPool repoint.
    • build_earnings_response uses the stamp, or this operator's earliest row when that row is earlier. A row can predate the stamp in three cases: a PoolRedeemed watcher backfill from its checkpoint, a ledger written before the stamp existed, or clock skew. The watcher scans every block from its resume point, so coverage from such a row is real.
  • --address: the first scanned block's timestamp. It is read before the scan, so an RPC that can't serve that header fails the command before thousands of eth_getLogs calls, not after. The code after the scan moves into response_from_rows so a mocked provider can test it.

period_label compares against covered_from_unix, and the label reads (covered from <date>). The header reads covered_from=<date>. The PERIOD column widens from 34 to 42 characters, which fits the longest label, since YYYY-MM-DD (covered from YYYY-MM-DD). The dashboard footnote now always shows the date.

Closes #2624

Breaking

Admin wire: EarningsResponse.ledger_since_unix: Option<u64> becomes covered_from_unix: u64, which is required. A decdn CLI at this release reads admin_v1_earnings only from a daemon at this release. The CHANGELOG entry is under Changed (BREAKING), and the existing #2598 entry is updated in place.

Storage: a new table in settle.redb. It needs no migration: a store without it takes a stamp at its next open.

Reviewer notes

Verification

  • Mutation checks:
    • Making bind_ledger_start skip its write fails bind_ledger_start_persists_the_first_stamp, and no other test.
    • The chain-mode tests pin covered_from_unix to the first block's time, not the first settlement's.
  • Live check: decdn node earnings --address 0x…01 --from-block <head-1000> --since 2026-01-01 against the Arbitrum Sepolia public RPC. Every row reads (covered from 2026-10-28), the first scanned block's date, and the columns line up.

Always:

  • pre-commit run on the changed files: every hook passes (the cargo deny advisories are already in Cargo.lock and don't block)
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo nextest run -p decdn-node -p decdn-cli -p decdn-common -p decdn-incentive: 3858 passed
  • CARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items
  • PR title uses an allowed type, lowercase subject

Only if touched:

  • User-visible change: CHANGELOG.md entry
  • Dashboard: pnpm test (65 passed), pnpm lint, pnpm build; status fixtures regenerated with UPDATE_STATUS_FIXTURES=1

🤖 Generated with Claude Code

…earliest settlement

`decdn node earnings` marked a period "(ledger from <date>)" when it began
before the earliest settlement row. A ledger that ran for weeks before its
first settlement therefore labelled a complete 7-day figure as truncated,
and chain mode never reported its real boundary, the first scanned block.

`EarningsResponse.covered_from_unix` replaces `ledger_since_unix`:
- daemon: a one-row `settlement_ledger_start_v1` stamp in `settle.redb`,
  written by the open that finds none and dropped with the ledger on a
  `PaymentPool` repoint; an earlier row (a watcher backfill, a pre-stamp
  ledger, clock skew) moves coverage back to it;
- `--address`: the first scanned block's timestamp, read before the scan.

The CLI labels a period that starts earlier "(covered from <date>)"; the
dashboard footnote always shows the date.

Closes #2624

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras thiras self-assigned this Oct 28, 2026
Copilot AI balanced review requested due to automatic review settings October 28, 2026 11:41

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.

🟢 Approval recommended

No active review issues remain for the earnings coverage-date changes.

No open issues 🎉

What changed in this PR

Fixes #2624 by making earnings labels reflect when data coverage starts rather than when the first settlement occurred, across daemon and chain-only modes.

Changes:

  • Persists a ledger-start timestamp and uses the first scanned block’s timestamp for chain-mode coverage.
  • Replaces ledger_since_unix with required covered_from_unix, updating CLI labels and the dashboard footnote.
  • Adds regression coverage and documents the breaking admin-wire change.
File Description
docs/​runbook.md Explains coverage dates after resets and repoints.
crates/​node/​src/​runtime/​mod.rs Passes the ledger-start timestamp to admin handlers.
crates/​node/​src/​pool_store/​tests.rs Tests stamp persistence, reopening, and repointing.
crates/​node/​src/​pool_store.rs Persists and resets the ledger-start stamp.
crates/​node/​src/​admin/​tests.rs Tests coverage boundaries and operator filtering.
crates/​node/​src/​admin.rs Derives coverage from the stamp or earlier operator rows.
crates/​common/​src/​admin.rs Defines and documents the required coverage field.
crates/​cli/​tests/​admin_rpc.rs Checks coverage through the admin RPC.
crates/​cli/​src/​commands/​setup/​tests.rs Updates setup JSON assertions.
crates/​cli/​src/​commands/​node/​tests.rs Tests coverage labels and empty-ledger rendering.
crates/​cli/​src/​commands/​node/​earnings_chain/​tests.rs Tests first-block coverage, including empty scans.
crates/​cli/​src/​commands/​node/​earnings_chain.rs Reads the coverage header before scanning and extracts response assembly.
crates/​cli/​src/​commands/​node.rs Updates earnings labels and widens the period column.
crates/​cli/​src/​commands/​dashboard/​status/​tests.rs Updates the dashboard status fixture source.
crates/​cli/​dashboard/​src/​view.test.ts Updates the earnings view test data.
crates/​cli/​dashboard/​src/​fixtures/​dashboard-full.json Updates the full dashboard fixture’s coverage field.
crates/​cli/​dashboard/​src/​fixtures/​dashboard-failing.json Updates the failing dashboard fixture’s coverage field.
crates/​cli/​dashboard/​src/​contract.test.ts Aligns response-key checks with the wire change.
crates/​cli/​dashboard/​src/​components/​NodeEarnings.tsx Always displays the coverage date.
crates/​cli/​dashboard/​src/​api.ts Updates the TypeScript earnings response type.
CHANGELOG.md Documents the wire break and revised coverage behavior.

Review effort: Balanced

@github-code-quality

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main ce241f3 fix/earnings-coverag... 3661a3b +/-
77% 77% 0%
View coverage of the 8 most impacted files.
File main ce241f3 fix/earnings-coverag... 3661a3b +/-
crates/node/src/dht/publish.rs 80% 78% -2%
crates/node/src/pool_store.rs 83% 82% -1%
crates/client/src/lib.rs 89% 89% 0%
crates/client/s...undle/engine.rs 65% 65% 0%
crates/node/src...gin/pull_leg.rs 84% 84% 0%
crates/node/src/runtime/mod.rs 26% 26% 0%
crates/node/src/admin.rs 77% 77% 0%
crates/cli/src/...rnings_chain.rs 72% 80% +8%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.

@thiras
thiras merged commit f2e3dd4 into main Oct 28, 2026
38 checks passed
@thiras
thiras deleted the fix/earnings-coverage-label-2624 branch October 28, 2026 11:53
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.

cli: node earnings labels a period from the earliest row, not from when the ledger started covering

2 participants