Skip to content

feat(node): integrate epoch reward processing#2874

Open
wolf31o2 wants to merge 2 commits into
mainfrom
codex/issue-1959-reward-integration
Open

feat(node): integrate epoch reward processing#2874
wolf31o2 wants to merge 2 commits into
mainfrom
codex/issue-1959-reward-integration

Conversation

@wolf31o2

@wolf31o2 wolf31o2 commented Jul 18, 2026

Copy link
Copy Markdown
Member

Summary by cubic

Integrates epoch reward processing by capturing genesis and epoch-boundary snapshots during dingo load, surfacing any capture failures, and rebuilding live stake with progress so the first reward round runs on time. Addresses #1959 by seeding the epoch-0 mark snapshot during dingo load to prevent skipped rewards on devnets.

  • New Features

    • Capture genesis snapshot during dingo load after ls.Start; fatal for block producers, warn for relays via snapshot.HandleGenesisSnapshotError.
    • Install epoch-boundary snapshot hook in load mode using snapshot.Manager; record failures and fail load after replay to avoid missing mark/reward snapshots.
    • Rebuild reward live stake at the end of ledgerstate.ImportLedgerState with progress reporting and a cancellation pre-check.
  • Bug Fixes

    • Create epoch-0 mark RewardSnapshot when replaying Shelley-genesis staking so epoch-3 rewards are applied.

Written for commit 51bf721. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Added automatic snapshot capture during ledger loading, including the initial genesis snapshot and epoch-boundary snapshots.
    • Added progress reporting for rebuilding reward live stake during reconciled ledger imports.
  • Bug Fixes

    • Improved genesis snapshot error handling: block-producing nodes now fail clearly, while relay nodes continue with a warning.
    • Ensured loaded networks with Shelley genesis staking include the expected initial reward snapshot.

Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
@wolf31o2
wolf31o2 requested a review from a team as a code owner July 18, 2026 20:01
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Load-mode startup now creates a snapshot manager, installs epoch-boundary snapshot capture, and captures the epoch-0 genesis snapshot before replay. Genesis snapshot errors use shared block-producer and relay handling. Tests cover hook wiring, error behavior, and the "mark" snapshot. Reconciled ledger-state imports now rebuild reward live stake and report progress.

Possibly related PRs

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and matches the main theme of adding epoch reward and snapshot processing in node load/import paths.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue-1959-reward-integration

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/node/load_test.go (1)

507-524: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the relay warning, not only the nil error.

This test passes if snapshot failures are silently swallowed. Capture the logger output and assert the warning message.

Proposed test improvement
 func TestCaptureLoadGenesisSnapshot_RelayWarnsAndContinues(t *testing.T) {
 	db := newTestDB(t)
-	logger := slog.New(slog.NewTextHandler(io.Discard, nil))
+	var logs bytes.Buffer
+	logger := slog.New(slog.NewTextHandler(&logs, nil))
 	mgr := snapshot.NewManager(db, nil, logger)
 
 	require.NoError(t, db.Close())
 
 	err := captureLoadGenesisSnapshot(
 		context.Background(),
 		mgr,
 		&config.Config{BlockProducer: false},
 		logger,
 	)
 	require.NoError(t, err)
+	require.Contains(t, logs.String(), "failed to capture genesis snapshot")
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/node/load_test.go` around lines 507 - 524, Update
TestCaptureLoadGenesisSnapshot_RelayWarnsAndContinues to capture logger output
instead of discarding it, then assert that the relay failure path emits the
expected warning message while retaining the existing require.NoError assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/node/load_test.go`:
- Around line 507-524: Update
TestCaptureLoadGenesisSnapshot_RelayWarnsAndContinues to capture logger output
instead of discarding it, then assert that the relay failure path emits the
expected warning message while retaining the existing require.NoError assertion.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 694b0bd3-73dc-44fb-9753-071aecc23881

📥 Commits

Reviewing files that changed from the base of the PR and between 9afdd66 and e07ac9e.

📒 Files selected for processing (4)
  • internal/node/load.go
  • internal/node/load_test.go
  • ledgerstate/import.go
  • node_forging.go

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread internal/node/load.go
Comment thread ledgerstate/import.go
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
@wolf31o2
wolf31o2 requested review from a team as code owners July 18, 2026 20:48

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread ledgerstate/import.go
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