Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into merge-v1.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-Wilson committed Nov 2, 2023
2 parents bac4190 + fdd098e commit 5cf0875
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 5 deletions.
3 changes: 2 additions & 1 deletion arbnode/dataposter/data_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
}
Expand All @@ -847,6 +847,7 @@ var TestDataPosterConfig = DataPosterConfig{
AllocateMempoolBalance: true,
UseDBStorage: false,
UseNoOpStorage: false,
LegacyStorageEncoding: false,
ExternalSigner: ExternalSignerCfg{Method: "eth_signTransaction"},
}

Expand Down
14 changes: 12 additions & 2 deletions arbnode/transaction_streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
26 changes: 26 additions & 0 deletions staker/execution_reverted_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
}
7 changes: 5 additions & 2 deletions staker/rollup_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"errors"
"fmt"
"math/big"
"strings"
"regexp"
"sync/atomic"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -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() {
Expand All @@ -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
Expand Down

0 comments on commit 5cf0875

Please sign in to comment.