diff --git a/arbnode/dataposter/data_poster.go b/arbnode/dataposter/data_poster.go index 1a202171ec..b5be06af56 100644 --- a/arbnode/dataposter/data_poster.go +++ b/arbnode/dataposter/data_poster.go @@ -823,7 +823,7 @@ var DefaultDataPosterConfig = DataPosterConfig{ AllocateMempoolBalance: true, UseDBStorage: true, UseNoOpStorage: false, - LegacyStorageEncoding: true, + LegacyStorageEncoding: false, Dangerous: DangerousConfig{ClearDBStorage: false}, ExternalSigner: ExternalSignerCfg{Method: "eth_signTransaction"}, } @@ -847,6 +847,7 @@ var TestDataPosterConfig = DataPosterConfig{ AllocateMempoolBalance: true, UseDBStorage: false, UseNoOpStorage: false, + LegacyStorageEncoding: false, ExternalSigner: ExternalSignerCfg{Method: "eth_signTransaction"}, } diff --git a/arbnode/transaction_streamer.go b/arbnode/transaction_streamer.go index bcc389dc01..2ee1526ee9 100644 --- a/arbnode/transaction_streamer.go +++ b/arbnode/transaction_streamer.go @@ -696,6 +696,7 @@ func (s *TransactionStreamer) addMessagesAndEndBatchImpl(messageStartPos arbutil var oldMsg *arbostypes.MessageWithMetadata var lastDelayedRead uint64 var hasNewConfirmedMessages bool + var cacheClearLen int messagesAfterPos := messageStartPos + arbutil.MessageIndex(len(messages)) broadcastStartPos := arbutil.MessageIndex(atomic.LoadUint64(&s.broadcasterQueuedMessagesPos)) @@ -724,10 +725,13 @@ func (s *TransactionStreamer) addMessagesAndEndBatchImpl(messageStartPos arbutil // Or no active broadcast reorg and broadcast messages start before or immediately after last L1 message if messagesAfterPos >= broadcastStartPos { broadcastSliceIndex := int(messagesAfterPos - broadcastStartPos) + messagesOldLen := len(messages) if broadcastSliceIndex < len(s.broadcasterQueuedMessages) { // Some cached feed messages can be used messages = append(messages, s.broadcasterQueuedMessages[broadcastSliceIndex:]...) } + // This calculation gives the exact length of cache which was appended to messages + cacheClearLen = broadcastSliceIndex + len(messages) - messagesOldLen } // L1 used or replaced broadcast cache items @@ -800,8 +804,14 @@ func (s *TransactionStreamer) addMessagesAndEndBatchImpl(messageStartPos arbutil } if clearQueueOnSuccess { - s.broadcasterQueuedMessages = s.broadcasterQueuedMessages[:0] - atomic.StoreUint64(&s.broadcasterQueuedMessagesPos, 0) + // Check if new messages were added at the end of cache, if they were, then dont remove those particular messages + if len(s.broadcasterQueuedMessages) > cacheClearLen { + s.broadcasterQueuedMessages = s.broadcasterQueuedMessages[cacheClearLen:] + atomic.StoreUint64(&s.broadcasterQueuedMessagesPos, uint64(broadcastStartPos)+uint64(cacheClearLen)) + } else { + s.broadcasterQueuedMessages = s.broadcasterQueuedMessages[:0] + atomic.StoreUint64(&s.broadcasterQueuedMessagesPos, 0) + } s.broadcasterQueuedMessagesActiveReorg = false } diff --git a/staker/execution_reverted_test.go b/staker/execution_reverted_test.go new file mode 100644 index 0000000000..98a3bdfd61 --- /dev/null +++ b/staker/execution_reverted_test.go @@ -0,0 +1,26 @@ +package staker + +import ( + "io" + "testing" +) + +func TestExecutionRevertedRegexp(t *testing.T) { + executionRevertedErrors := []string{ + // go-ethereum and most other execution clients return "execution reverted" + "execution reverted", + // execution clients may decode the EVM revert data as a string and include it in the error + "execution reverted: FOO", + // besu returns "Execution reverted" + "Execution reverted", + } + for _, errString := range executionRevertedErrors { + if !executionRevertedRegexp.MatchString(errString) { + t.Fatalf("execution reverted regexp didn't match %q", errString) + } + } + // This regexp should not match random IO errors + if executionRevertedRegexp.MatchString(io.ErrUnexpectedEOF.Error()) { + t.Fatal("execution reverted regexp matched unexpected EOF") + } +} diff --git a/staker/rollup_watcher.go b/staker/rollup_watcher.go index 2fa3f888e8..59a23d891d 100644 --- a/staker/rollup_watcher.go +++ b/staker/rollup_watcher.go @@ -9,7 +9,7 @@ import ( "errors" "fmt" "math/big" - "strings" + "regexp" "sync/atomic" "github.com/ethereum/go-ethereum/common" @@ -72,6 +72,9 @@ func (r *RollupWatcher) getCallOpts(ctx context.Context) *bind.CallOpts { return &opts } +// A regexp matching "execution reverted" errors returned from the parent chain RPC. +var executionRevertedRegexp = regexp.MustCompile("(?i)execution reverted") + func (r *RollupWatcher) getNodeCreationBlock(ctx context.Context, nodeNum uint64) (*big.Int, error) { callOpts := r.getCallOpts(ctx) if !r.unSupportedL3Method.Load() { @@ -80,7 +83,7 @@ func (r *RollupWatcher) getNodeCreationBlock(ctx context.Context, nodeNum uint64 return createdAtBlock, nil } log.Trace("failed to call getNodeCreationBlockForLogLookup, falling back on node CreatedAtBlock field", "err", err) - if strings.Contains(err.Error(), "execution reverted") { + if executionRevertedRegexp.MatchString(err.Error()) { r.unSupportedL3Method.Store(true) } else { return nil, err