Skip to content

Commit 3d2f379

Browse files
authored
fix: remove wrong transition check in rollup-verifier (#1226)
* fix: remove wrong transition check in rollup-verifier * auto-reset sync height * comment
1 parent 1a2baf0 commit 3d2f379

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

params/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
const (
2525
VersionMajor = 5 // Major version component of the current release
2626
VersionMinor = 8 // Minor version component of the current release
27-
VersionPatch = 73 // Patch version component of the current release
27+
VersionPatch = 74 // Patch version component of the current release
2828
VersionMeta = "mainnet" // Version metadata to append to the version string
2929
)
3030

rollup/rollup_sync_service/rollup_sync_service.go

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,18 @@ const (
4848
)
4949

5050
var (
51-
finalizedBlockGauge = metrics.NewRegisteredGauge("chain/head/finalized", nil)
52-
ErrShouldResetSyncHeight = errors.New("ErrShouldResetSyncHeight")
53-
ErrMissingBatchEvent = errors.New("ErrMissingBatchEvent")
51+
finalizedBlockGauge = metrics.NewRegisteredGauge("chain/head/finalized", nil)
52+
ErrMissingBatchEvent = errors.New("ErrMissingBatchEvent")
5453
)
5554

55+
type errShouldResetSyncHeight struct {
56+
height uint64
57+
}
58+
59+
func (e errShouldResetSyncHeight) Error() string {
60+
return fmt.Sprintf("ErrShouldResetSyncHeight: height=%d", e.height)
61+
}
62+
5663
// RollupSyncService collects ScrollChain batch commit/revert/finalize events and stores metadata into db.
5764
type RollupSyncService struct {
5865
ctx context.Context
@@ -224,10 +231,10 @@ func (s *RollupSyncService) fetchRollupEvents() error {
224231
}
225232

226233
if err = s.updateRollupEvents(daEntries); err != nil {
227-
if errors.Is(err, ErrShouldResetSyncHeight) {
228-
log.Warn("Resetting sync height to L1 block 7892668 to fix L1 message queue hash calculation")
229-
s.callDataBlobSource.SetL1Height(7892668)
230-
234+
var resetSyncErr errShouldResetSyncHeight
235+
if errors.As(err, &resetSyncErr) {
236+
log.Warn("Resetting rollup sync height", "height", resetSyncErr.height)
237+
s.callDataBlobSource.SetL1Height(resetSyncErr.height)
231238
return nil
232239
}
233240
if errors.Is(err, ErrMissingBatchEvent) {
@@ -482,14 +489,8 @@ func (s *RollupSyncService) getCommittedBatchMeta(commitedBatch da.EntryWithBloc
482489
return nil, fmt.Errorf("parent committed batch meta = nil, batch index: %v, err: %w", commitedBatch.BatchIndex()-1, ErrMissingBatchEvent)
483490
}
484491

485-
// If parent batch has a lower version this means this is the first batch of CodecV7.
486-
// In this case we need to compute the prevL1MessageQueueHash from the empty hash.
487-
var prevL1MessageQueueHash common.Hash
488-
if encoding.CodecVersion(parentCommittedBatchMeta.Version) < commitedBatch.Version() {
489-
prevL1MessageQueueHash = common.Hash{}
490-
} else {
491-
prevL1MessageQueueHash = parentCommittedBatchMeta.PostL1MessageQueueHash
492-
}
492+
// For the first batch of CodecV7, this will be the empty hash.
493+
prevL1MessageQueueHash := parentCommittedBatchMeta.PostL1MessageQueueHash
493494

494495
chunks, err := s.getLocalChunksForBatch(chunkRanges)
495496
if err != nil {
@@ -598,7 +599,17 @@ func validateBatch(batchIndex uint64, event *l1.FinalizeBatchEvent, parentFinali
598599
// We need to reset the sync height to 1 block before the L1 block in which the last batch in CodecV6 was committed.
599600
// The node will overwrite the wrongly computed message queue hashes.
600601
if strings.Contains(err.Error(), "0xaa16faf2a1685fe1d7e0f2810b1a0e98c2841aef96596d10456a6d0f00000000") {
601-
return 0, nil, ErrShouldResetSyncHeight
602+
log.Warn("Resetting sync height to L1 block 7892668 to fix L1 message queue hash calculation issue after EuclidV2 on Scroll Sepolia")
603+
return 0, nil, errShouldResetSyncHeight{height: 7892668}
604+
}
605+
// This is hotfix for the L1 message hash mismatch issue which lead to wrong committedBatchMeta.PostL1MessageQueueHash hashes.
606+
// This happened after upgrading to Feyman where rollup-verifier erroneously reset the prevMessageQueueHash to the empty hash.
607+
// If the error message due to mismatching PostL1MessageQueueHash contains the same hash as the hardcoded one,
608+
// this means the node ran into this issue.
609+
// We need to reset the sync height to before committing the first Feynman batch.
610+
if strings.Contains(err.Error(), "expected 0x19c790f49efb448b523d94e5672d9ed108656886be12c038cf39062700000000, got 0x0000000000000000000000000000000000000000000000000000000000000000") {
611+
log.Warn("Resetting sync height to L1 block 8816625 to fix L1 message queue hash calculation issue after Feynman on Scroll Sepolia")
612+
return 0, nil, errShouldResetSyncHeight{height: 8816625}
602613
}
603614
return 0, nil, fmt.Errorf("failed to create DA batch, batch index: %v, codec version: %v, err: %w", batchIndex, codecVersion, err)
604615
}

0 commit comments

Comments
 (0)