feat(ledger): initialize genesis network state#2838
Conversation
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| if err != nil { | ||
| return fmt.Errorf("get existing network state: %w", err) | ||
| } | ||
| if state != nil { |
There was a problem hiding this comment.
It is returning silently when network_state already has rows. If a node ran epoch boundaries under the old bug (reserves defaulted to 0), its existing rows are wrong and the PR says it needs a resync — but nothing in the logs tells the operator that. Can't distinguish "already backfilled, fine" from "needs resync" just by watching logs.
Fix: Please add one log line for the early return
if state != nil {
ls.config.Logger.Debug(
"network state already present, skipping genesis baseline backfill",
"component", "ledger",
"slot", state.Slot,
"treasury", uint64(state.Treasury),
"reserves", uint64(state.Reserves),
)
return nil
}
There was a problem hiding this comment.
That's fine. Resync from scratch is common for our operators. We don't guarantee backfill or fixing data on upgrade.
54c3d04 to
c090c89
Compare
|
Merging without waiting. I pushed back to the approved exact ref. |
Summary
Part of #1959.
Validation
make golinesgolangci-lint run ./...make import-boundariesgo build ./cmd/dingogo build -tags extra_plugins ./cmd/dingogo test -race ./ledger ./ledgerstatego test -race ./internal/test/conformanceinternal/test/devnet/run-tests.shmodernize ./...andnilaway ./...were also run; both report existing findings outside this change.Documentation
DATABASE.mdARCHITECTURE.mdSummary by cubic
Initialize slot-0
network_state(treasury/reserves) from genesis and persist certified account state on Mithril import so epoch rewards, MIR, donations, and pot transitions start from the correct baseline. Contributes to #1959 by deriving reserves asmaxLovelaceSupplyminus combined Byron+Shelley genesis UTxOs and safely backfilling older databases.New Features
0, reserves =maxLovelaceSupply− sum(genesis UTxOs), with input validation.network_stateis empty; no rewrite when history exists.AccountStatetreasury/reserves at the imported tip (no genesis derivation).Migration
network_state: baseline is backfilled on startup.network_staterows, resync from genesis to reconstruct the correct history.Written for commit c090c89. Summary will update on new commits.