Skip to content

Commit

Permalink
Merge pull request #2012 from OffchainLabs/nethermind-execution-reverted
Browse files Browse the repository at this point in the history
Add support for nethermind's version of "execution reverted"
  • Loading branch information
joshuacolvin0 authored Dec 11, 2023
2 parents 1de9e02 + 8e8788e commit a0e6317
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 1 addition & 3 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"os/signal"
"path/filepath"
"reflect"
"regexp"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -546,7 +545,6 @@ func mainImpl() int {
// Validate sequencer's MaxTxDataSize and batchPoster's MaxSize params.
// SequencerInbox's maxDataSize is defaulted to 117964 which is 90% of Geth's 128KB tx size limit, leaving ~13KB for proving.
seqInboxMaxDataSize := 117964
executionRevertedRegexp := regexp.MustCompile("(?i)execution reverted")
if nodeConfig.Node.ParentChainReader.Enable {
seqInbox, err := bridgegen.NewSequencerInbox(rollupAddrs.SequencerInbox, l1Client)
if err != nil {
Expand All @@ -556,7 +554,7 @@ func mainImpl() int {
res, err := seqInbox.MaxDataSize(&bind.CallOpts{Context: ctx})
if err == nil {
seqInboxMaxDataSize = int(res.Int64())
} else if !executionRevertedRegexp.MatchString(err.Error()) {
} else if !headerreader.ExecutionRevertedRegexp.MatchString(err.Error()) {
log.Error("error fetching MaxDataSize from sequencer inbox", "err", err)
return 1
}
Expand Down
7 changes: 2 additions & 5 deletions staker/rollup_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"errors"
"fmt"
"math/big"
"regexp"
"sync/atomic"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/solgen/go/rollupgen"
"github.com/offchainlabs/nitro/util/headerreader"

"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -72,9 +72,6 @@ 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 @@ -83,7 +80,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 executionRevertedRegexp.MatchString(err.Error()) {
if headerreader.ExecutionRevertedRegexp.MatchString(err.Error()) {
r.unSupportedL3Method.Store(true)
} else {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package staker
// Copyright 2021-2023, Offchain Labs, Inc.
// For license information, see https://github.com/nitro/blob/master/LICENSE

package headerreader

import (
"io"
Expand All @@ -13,14 +16,16 @@ func TestExecutionRevertedRegexp(t *testing.T) {
"execution reverted: FOO",
// besu returns "Execution reverted"
"Execution reverted",
// nethermind returns "VM execution error."
"VM execution error.",
}
for _, errString := range executionRevertedErrors {
if !executionRevertedRegexp.MatchString(errString) {
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()) {
if ExecutionRevertedRegexp.MatchString(io.ErrUnexpectedEOF.Error()) {
t.Fatal("execution reverted regexp matched unexpected EOF")
}
}
4 changes: 4 additions & 0 deletions util/headerreader/header_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"errors"
"fmt"
"math/big"
"regexp"
"sync"
"time"

Expand All @@ -22,6 +23,9 @@ import (
flag "github.com/spf13/pflag"
)

// A regexp matching "execution reverted" errors returned from the parent chain RPC.
var ExecutionRevertedRegexp = regexp.MustCompile(`(?i)execution reverted|VM execution error\.?`)

type ArbSysInterface interface {
ArbBlockNumber(*bind.CallOpts) (*big.Int, error)
}
Expand Down

0 comments on commit a0e6317

Please sign in to comment.