-
Notifications
You must be signed in to change notification settings - Fork 22
fix: Reset streamer in case of L1 reorg causing batch tx not to go through #1045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: integration-v3.9.8
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,6 +44,8 @@ type EspressoStreamerInterface interface { | |
| Advance() | ||
| // Reset sets the current message position and the next hotshot block number. | ||
| Reset(currentMessagePos uint64, currentHostshotBlock uint64) | ||
| // GetCurrentMessagePos returns the current message position of the streamer. | ||
| GetCurrentMessagePos() uint64 | ||
| // RecordTimeDurationBetweenHotshotAndCurrentBlock records the time duration between | ||
| // the next hotshot block and the current block. | ||
| RecordTimeDurationBetweenHotshotAndCurrentBlock(nextHotshotBlock uint64, blockProductionTime time.Time) | ||
|
|
@@ -225,6 +227,12 @@ func (s *EspressoStreamer) Advance() { | |
| s.currentMessagePos += 1 | ||
| } | ||
|
|
||
| func (s *EspressoStreamer) GetCurrentMessagePos() uint64 { | ||
| s.messageLock.RLock() | ||
| defer s.messageLock.RUnlock() | ||
| return s.currentMessagePos | ||
| } | ||
|
|
||
| func (s *EspressoStreamer) AdvanceTo(toPos uint64) { | ||
| s.messageLock.Lock() | ||
| defer s.messageLock.Unlock() | ||
|
|
@@ -383,6 +391,11 @@ func (s *EspressoStreamer) parseEspressoTransaction(tx espressoTypes.Bytes, l1He | |
| continue | ||
| } | ||
|
|
||
| if _, exists := s.messageWithMetadataAndPos[indices[i]]; exists { | ||
| log.Warn("duplicate message position, discarding", "pos", indices[i]) | ||
| continue | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This check for duplicate message positions is a good addition for robustness. However, it would be more efficient to perform this check before the RLP decoding of the message (around line 382), as |
||
|
|
||
| msg := &MessageWithMetadataAndPos{ | ||
| MessageWithMeta: messageWithMetadata, | ||
| Pos: indices[i], | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current logic performs a reorg check and potential reset on every iteration where a new batch is being built. On startup (
b.espressoRestarting == true), this leads to redundant operations: 1.b.espressoStreamer.GetCurrentMessagePos()is initialized to 1, so ifbatchPosition.MessageCountis 0, it triggers a warning and a reset at line 1861. 2. Then, line 1869 calls the exact same reset function again. 3. IfbatchPosition.MessageCount > 0, it callsAdvanceToand then immediatelyResetat line 1869, making theAdvanceTocall redundant. Wrapping the reorg check inif !b.espressoRestartingavoids these redundant calls and prevents a false-positive reorg warning on startup.