Skip to content

trigger recovery hardening - #7991

Open
AdoAdoAdo wants to merge 18 commits into
refactor-contended-headers-gatefrom
trigger-recovery-hardening
Open

trigger recovery hardening#7991
AdoAdoAdo wants to merge 18 commits into
refactor-contended-headers-gatefrom
trigger-recovery-hardening

Conversation

@AdoAdoAdo

Copy link
Copy Markdown
Contributor

Reasoning behind the pull request

Proposed changes

Testing procedure

Pre-requisites

Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:

  • was the PR targeted to the correct branch?
  • if this is a larger feature that probably needs more than one PR, is there a feat branch created?
  • if this is a feat branch merging, do all satellite projects have a proper tag inside go.mod?

Copilot AI 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.

Pull request overview

This PR hardens epoch-start trigger recovery by shifting shard-block epoch mismatch handling to the epoch start trigger, introducing Supernova-specific recovery tracking (candidates + generation), and extending request handling to support epoch-stamped meta-header requests.

Changes:

  • Delegate epoch mismatch remediation from shardProcessor.checkEpochCorrectness to EpochStartTrigger.RequestEpochStartIfNeeded.
  • Add Supernova epoch-start recovery state machine (candidates/pending data + generation gating + close/reset behavior) and broaden related test coverage.
  • Extend the epochStart RequestHandler API to support epoch-aware meta-header-by-hash/nonce requests and update callers/tests accordingly.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
process/mock/endOfEpochTriggerStub.go Extends the epoch start trigger stub to allow observing RequestEpochStartIfNeeded calls in tests.
process/block/shardblock.go Replaces local “evict + request” logic with trigger notification on epoch mismatch.
process/block/shardblock_test.go Updates tests to assert trigger notification instead of header eviction/request side effects.
epochStart/shardchain/triggerRegistry.go Resets pending recovery state after loading trigger state.
epochStart/shardchain/triggerRegistry_test.go Adjusts cloning/equality logic to account for new recovery fields/generation.
epochStart/shardchain/trigger.go Implements Supernova recovery tracking, generation-based stale-state protection, and epoch-stamped neighbor requests.
epochStart/shardchain/trigger_test.go Adds targeted tests for Supernova recovery flows and generation/close behavior.
epochStart/mock/validatorInfoSyncerStub.go Makes the syncer stub callbacks configurable for new recovery tests.
epochStart/interface.go Extends request handler interface with epoch-aware meta-header request methods.
Suppressed comments (2)

epochStart/shardchain/trigger_test.go:754

  • Using a fixed time.Sleep(50ms) to assert that no second sync happens can make the test nondeterministic (it may pass/fail depending on timing). It’s more robust to assert the invariants hold for a short bounded interval.
		tr.RequestEpochStartIfNeeded(header)
		time.Sleep(50 * time.Millisecond)
		require.Equal(t, int32(1), syncCalls.Load())
		require.Equal(t, 1, numRecoveryCandidates(tr))

epochStart/shardchain/trigger_test.go:799

  • Same flakiness concern here: a single time.Sleep(50ms) doesn’t reliably prove no second async call occurs. Consider checking the counters remain stable over a bounded interval instead.
		tr.RequestEpochStartIfNeeded(header)
		time.Sleep(50 * time.Millisecond)
		require.Equal(t, int32(1), syncCalls.Load())
		require.Equal(t, 1, numRecoveryCandidates(tr))

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread epochStart/shardchain/trigger.go Outdated
Comment thread epochStart/shardchain/trigger_test.go

Copilot AI 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.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Comment thread epochStart/shardchain/trigger.go Outdated
Comment on lines +1077 to +1099
@@ -713,13 +1096,24 @@ func (t *trigger) pendingEpochStartDataSnapshot() (map[string]pendingEpochStartP
pendingHeaders[epoch] = struct{}{}
}

return pending, pendingHeaders
return t.epoch, pending, pendingHeaders, t.recoveryGeneration
Base automatically changed from epoch-start-trigger-fix to refactor-contended-headers-gate August 27, 2026 09:11
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.

4 participants