Skip to content

Commit

Permalink
optimize(batcher): limit the max load blocks one time
Browse files Browse the repository at this point in the history
  • Loading branch information
bnoieh committed Jun 13, 2024
1 parent ebbbfcb commit 04befd7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion op-batcher/batcher/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/ethereum/go-ethereum/params"
)

const LimitLoadBlocksOneTime uint64 = 300

// Auto DA params
const DATypeSwitchThrehold int = 5
const CallDataMaxTxSize uint64 = 120000
Expand Down Expand Up @@ -170,10 +172,15 @@ func (l *BatchSubmitter) loadBlocksIntoState(ctx context.Context) error {
} else if start.Number >= end.Number {
return errors.New("start number is >= end number")
}
// Limit the max loaded blocks one time
endNumber := end.Number
if endNumber-start.Number > LimitLoadBlocksOneTime {
endNumber = start.Number + LimitLoadBlocksOneTime
}

var latestBlock *types.Block
// Add all blocks to "state"
for i := start.Number + 1; i < end.Number+1; i++ {
for i := start.Number + 1; i < endNumber+1; i++ {
block, err := l.loadBlockIntoState(ctx, i)
if errors.Is(err, ErrReorg) {
l.Log.Warn("Found L2 reorg", "block_number", i)
Expand Down

0 comments on commit 04befd7

Please sign in to comment.