Skip to content

Commit 5e392ba

Browse files
committed
fix catchup height check
1 parent 3fc79c3 commit 5e392ba

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

block/internal/syncing/syncer.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -786,33 +786,33 @@ func (s *Syncer) TrySyncNextBlock(ctx context.Context, event *common.DAHeightEve
786786
// instead of the next forced-inclusion epoch), causing valid catch-up blocks
787787
// to be incorrectly flagged as malicious.
788788
//
789-
// To handle this, when the gap exceeds one DA epoch, we advance DAHeight by
790-
// exactly one epoch per block. This lets the forced inclusion verifier check
791-
// the correct epoch for each catch-up block. Once the sequencer finishes
792-
// catching up and the gap closes, DAHeight converges to event.DaHeight.
789+
// To handle this, when the gap exceeds one DA epoch, we compute the epoch
790+
// start that contains event.DaHeight and set DAHeight to that epoch start.
791+
// This ensures all blocks from the same DA epoch verify against the same
792+
// epoch. Once the sequencer finishes catching up and the gap closes,
793+
// DAHeight converges to event.DaHeight.
793794
if event.DaHeight > newState.DAHeight {
794795
epochSize := s.genesis.DAEpochForcedInclusion
795796
gap := event.DaHeight - newState.DAHeight
796797

797798
if epochSize > 0 && gap > epochSize {
798799
// Large gap detected — likely catch-up blocks from a restarted sequencer.
799-
// Advance DAHeight by one epoch to keep forced inclusion verification
800-
// aligned with the epoch the sequencer is replaying.
801-
_, epochEnd, _ := types.CalculateEpochBoundaries(
802-
newState.DAHeight, s.genesis.DAStartHeight, epochSize,
800+
// Compute the epoch start that contains event.DaHeight so all blocks
801+
// from the same epoch verify against the same DA epoch.
802+
epochStart, _, _ := types.CalculateEpochBoundaries(
803+
event.DaHeight, s.genesis.DAStartHeight, epochSize,
803804
)
804-
nextEpochStart := epochEnd + 1
805-
if nextEpochStart > event.DaHeight {
805+
if epochStart > event.DaHeight {
806806
// Shouldn't happen, but clamp to event.DaHeight as a safety net.
807-
nextEpochStart = event.DaHeight
807+
epochStart = event.DaHeight
808808
}
809809
s.logger.Debug().
810810
Uint64("current_da_height", newState.DAHeight).
811811
Uint64("event_da_height", event.DaHeight).
812-
Uint64("advancing_to", nextEpochStart).
812+
Uint64("epoch_start", epochStart).
813813
Uint64("gap", gap).
814-
Msg("large DA height gap detected (sequencer catch-up), advancing DA height by one epoch")
815-
newState.DAHeight = nextEpochStart
814+
Msg("large DA height gap detected (sequencer catch-up), setting DA height to epoch start")
815+
newState.DAHeight = epochStart
816816
} else {
817817
newState.DAHeight = event.DaHeight
818818
}

0 commit comments

Comments
 (0)