Skip to content

Commit

Permalink
clear cache in recordFailedTx
Browse files Browse the repository at this point in the history
  • Loading branch information
blockchaindevsh committed Sep 22, 2024
1 parent a4af765 commit 8613b74
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"math/big"
_ "net/http/pprof"
"sync"
"sync/atomic"
"time"

"github.com/ethereum-optimism/optimism/op-batcher/metrics"
Expand Down Expand Up @@ -73,7 +74,7 @@ type BatchSubmitter struct {
lastL1Tip eth.L1BlockRef

state *channelManager
inboxIsEOA *bool
inboxIsEOA atomic.Pointer[bool]
}

// NewBatchSubmitter initializes the BatchSubmitter driver from a preconfigured DriverSetup
Expand Down Expand Up @@ -516,18 +517,20 @@ func (l *BatchSubmitter) sendTransaction(ctx context.Context, txdata txData, que
if *candidate.To != l.RollupConfig.BatchInboxAddress {
return fmt.Errorf("candidate.To is not inbox")
}
if l.inboxIsEOA == nil {
isEOAPointer := l.inboxIsEOA.Load()
if isEOAPointer == nil {
var code []byte
code, err = l.L1Client.CodeAt(ctx, *candidate.To, nil)
if err != nil {
return fmt.Errorf("CodeAt failed:%w", err)
}
isEOA := len(code) == 0
l.inboxIsEOA = &isEOA
isEOAPointer = &isEOA
l.inboxIsEOA.Store(isEOAPointer)
}

// Don't set GasLimit when inbox is contract so that later on `EstimateGas` will be called
if !*l.inboxIsEOA {
if !*isEOAPointer {
intrinsicGas, err := core.IntrinsicGas(candidate.TxData, nil, false, true, true, false)
if err != nil {
// we log instead of return an error here because txmgr can do its own gas estimation
Expand Down Expand Up @@ -589,6 +592,7 @@ func (l *BatchSubmitter) recordL1Tip(l1tip eth.L1BlockRef) {
}

func (l *BatchSubmitter) recordFailedTx(id txID, err error) {
l.inboxIsEOA.Store(nil)
l.Log.Warn("Transaction failed to send", logFields(id, err)...)
l.state.TxFailed(id)
}
Expand Down

0 comments on commit 8613b74

Please sign in to comment.