Skip to content

Commit d3b4846

Browse files
authored
fix: always emit block-based epoch transitions (#1452)
Signed-off-by: Chris Gianelloni <wolf31o2@blinklabs.io>
1 parent 0bb69d4 commit d3b4846

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

ledger/state.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,22 +1728,16 @@ func (ls *LedgerState) ledgerProcessBlocks() {
17281728
if rolloverResult != nil && ls.config.EventBus != nil {
17291729
newEpochId := rolloverResult.NewCurrentEpoch.EpochId
17301730

1731-
// Use MarkEpochEmitted to coordinate with slot-based detection.
1732-
// If slot clock already emitted this epoch event (when synced),
1733-
// we skip emitting again to avoid duplicates.
1734-
shouldEmit := true
1731+
// Always emit block-based epoch transitions. Even if the
1732+
// slot clock already emitted an event for this epoch, the
1733+
// block-based event is needed because it fires AFTER the
1734+
// epoch nonce has been computed. Subscribers (leader
1735+
// election, snapshot manager) use drain logic to handle
1736+
// duplicates, keeping only the latest event.
17351737
if ls.slotClock != nil {
1736-
shouldEmit = ls.slotClock.MarkEpochEmitted(newEpochId)
1737-
if !shouldEmit {
1738-
ls.config.Logger.Debug(
1739-
"block-based epoch transition skipped (already emitted by slot clock)",
1740-
"epoch",
1741-
newEpochId,
1742-
)
1743-
}
1738+
ls.slotClock.MarkEpochEmitted(newEpochId)
17441739
}
1745-
1746-
if shouldEmit {
1740+
{
17471741
// Calculate snapshot slot (boundary - 1, or 0 if boundary is 0)
17481742
snapshotSlot := rolloverResult.NewCurrentEpoch.StartSlot
17491743
if snapshotSlot > 0 {

0 commit comments

Comments
 (0)