Repository navigation
fix(cli): label earnings periods by when coverage starts, not by the earliest settlement - #2679
Merged
Merged
Conversation
…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]>
There was a problem hiding this comment.
🟢 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_unixwith requiredcovered_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
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 8 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
decdn node earningsadded "(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:last 7das truncated.--address): the real boundary, the first scanned block's time, never appeared in the response.EarningsResponse.covered_from_unix: u64replacesledger_since_unix. Each producer reports what it knows:settlement_ledger_start_v1stamp insettle.redb.PaymentPoolrepoint.build_earnings_responseuses the stamp, or this operator's earliest row when that row is earlier. A row can predate the stamp in three cases: aPoolRedeemedwatcher 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 ofeth_getLogscalls, not after. The code after the scan moves intoresponse_from_rowsso a mocked provider can test it.period_labelcompares againstcovered_from_unix, and the label reads(covered from <date>). The header readscovered_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>becomescovered_from_unix: u64, which is required. AdecdnCLI at this release readsadmin_v1_earningsonly 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
decdn node earningsprints settled and owed USDC per period #2598 ledger takes its stamp at the first boot of this build. Its existing rows predate the stamp, socovered_fromstays at its earliest row, which is the old value, until the next redeploy or repoint. It never overstates coverage. Per the pre-mainnet rule, there is no migration.lanes.redb) is unchanged. The stamp lives insettle.redb, and a reopen that finds it takes only a read transaction.settle.redbno-write on reopen and dropped it. redb trims its files on open:settle.redbwent from 1056768 to 61440 bytes without the stamp being rewritten. Size is not a write signal.Verification
bind_ledger_startskip its write failsbind_ledger_start_persists_the_first_stamp, and no other test.covered_from_unixto the first block's time, not the first settlement's.decdn node earnings --address 0x…01 --from-block <head-1000> --since 2026-01-01against 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 runon the changed files: every hook passes (thecargo denyadvisories are already inCargo.lockand don't block)cargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run -p decdn-node -p decdn-cli -p decdn-common -p decdn-incentive: 3858 passedCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-itemsOnly if touched:
CHANGELOG.mdentrypnpm test(65 passed),pnpm lint,pnpm build; status fixtures regenerated withUPDATE_STATUS_FIXTURES=1🤖 Generated with Claude Code