diff --git a/.changeset/gentle-brooms-lick.md b/.changeset/gentle-brooms-lick.md new file mode 100644 index 0000000000000..919cbd1856057 --- /dev/null +++ b/.changeset/gentle-brooms-lick.md @@ -0,0 +1,5 @@ +--- +'@eth-optimism/batch-submitter-service': patch +--- + +Adds MIN_L1_TX_SIZE configuration diff --git a/go/batch-submitter/batch_submitter.go b/go/batch-submitter/batch_submitter.go index 00c61f322ae57..fc8b24e458d16 100644 --- a/go/batch-submitter/batch_submitter.go +++ b/go/batch-submitter/batch_submitter.go @@ -27,6 +27,10 @@ func Main(gitVersion string) func(ctx *cli.Context) error { return err } + log.Info("Config parsed", + "min_tx_size", cfg.MinL1TxSize, + "max_tx_size", cfg.MaxL1TxSize) + // The call to defer is done here so that any errors logged from // this point on are posted to Sentry before exiting. if cfg.SentryEnable { @@ -121,6 +125,7 @@ func Main(gitVersion string) func(ctx *cli.Context) error { L1Client: l1Client, L2Client: l2Client, BlockOffset: cfg.BlockOffset, + MinTxSize: cfg.MinL1TxSize, MaxTxSize: cfg.MaxL1TxSize, CTCAddr: ctcAddress, ChainID: chainID, diff --git a/go/batch-submitter/config.go b/go/batch-submitter/config.go index 3186e7bc898a0..7231f3dcf5416 100644 --- a/go/batch-submitter/config.go +++ b/go/batch-submitter/config.go @@ -197,6 +197,7 @@ func NewConfig(ctx *cli.Context) (Config, error) { L2EthRpc: ctx.GlobalString(flags.L2EthRpcFlag.Name), CTCAddress: ctx.GlobalString(flags.CTCAddressFlag.Name), SCCAddress: ctx.GlobalString(flags.SCCAddressFlag.Name), + MinL1TxSize: ctx.GlobalUint64(flags.MinL1TxSizeFlag.Name), MaxL1TxSize: ctx.GlobalUint64(flags.MaxL1TxSizeFlag.Name), MaxBatchSubmissionTime: ctx.GlobalDuration(flags.MaxBatchSubmissionTimeFlag.Name), PollInterval: ctx.GlobalDuration(flags.PollIntervalFlag.Name), diff --git a/go/batch-submitter/drivers/sequencer/driver.go b/go/batch-submitter/drivers/sequencer/driver.go index 0c5e7a8b74402..bc317f79e5801 100644 --- a/go/batch-submitter/drivers/sequencer/driver.go +++ b/go/batch-submitter/drivers/sequencer/driver.go @@ -32,6 +32,7 @@ type Config struct { L1Client *ethclient.Client L2Client *l2ethclient.Client BlockOffset uint64 + MinTxSize uint64 MaxTxSize uint64 CTCAddr common.Address ChainID *big.Int @@ -150,7 +151,8 @@ func (d *Driver) GetBatchBlockRange( // CraftBatchTx transforms the L2 blocks between start and end into a batch // transaction using the given nonce. A dummy gas price is used in the resulting -// transaction to use for size estimation. +// transaction to use for size estimation. A nil transaction is returned if the +// transaction does not meet the minimum size requirements. // // NOTE: This method SHOULD NOT publish the resulting transaction. func (d *Driver) CraftBatchTx( @@ -211,13 +213,18 @@ func (d *Driver) CraftBatchTx( batchCallData := append(appendSequencerBatchID, batchArguments...) // Continue pruning until calldata size is less than configured max. - if uint64(len(batchCallData)) > d.cfg.MaxTxSize { + calldataSize := uint64(len(batchCallData)) + if calldataSize > d.cfg.MaxTxSize { oldLen := len(batchElements) newBatchElementsLen := (oldLen * 9) / 10 batchElements = batchElements[:newBatchElementsLen] log.Info(name+" pruned batch", "old_num_txs", oldLen, "new_num_txs", newBatchElementsLen) pruneCount++ continue + } else if calldataSize < d.cfg.MinTxSize { + log.Info(name+" batch tx size below minimum", + "size", calldataSize, "min_tx_size", d.cfg.MinTxSize) + return nil, nil } d.metrics.NumElementsPerBatch().Observe(float64(len(batchElements))) diff --git a/go/batch-submitter/flags/flags.go b/go/batch-submitter/flags/flags.go index d8b0b3a2a9d60..5d4b7835facc4 100644 --- a/go/batch-submitter/flags/flags.go +++ b/go/batch-submitter/flags/flags.go @@ -52,6 +52,13 @@ var ( Required: true, EnvVar: "SCC_ADDRESS", } + MinL1TxSizeFlag = cli.Uint64Flag{ + Name: "min-l1-tx-size", + Usage: "Minimum size in bytes of any L1 transaction that gets " + + "generated by the batch submitter", + Required: true, + EnvVar: prefixEnvVar("MIN_L1_TX_SIZE"), + } MaxL1TxSizeFlag = cli.Uint64Flag{ Name: "max-l1-tx-size", Usage: "Maximum size in bytes of any L1 transaction that gets " + @@ -231,6 +238,7 @@ var requiredFlags = []cli.Flag{ L2EthRpcFlag, CTCAddressFlag, SCCAddressFlag, + MinL1TxSizeFlag, MaxL1TxSizeFlag, MaxBatchSubmissionTimeFlag, PollIntervalFlag, diff --git a/go/bss-core/service.go b/go/bss-core/service.go index 4a4ebbc7f4405..2a4de9e8d0a49 100644 --- a/go/bss-core/service.go +++ b/go/bss-core/service.go @@ -46,7 +46,9 @@ type Driver interface { // CraftBatchTx transforms the L2 blocks between start and end into a batch // transaction using the given nonce. A dummy gas price is used in the - // resulting transaction to use for size estimation. + // resulting transaction to use for size estimation. The driver may return a + // nil value for transaction if there is no action that needs to be + // performed. // // NOTE: This method SHOULD NOT publish the resulting transaction. CraftBatchTx( @@ -184,6 +186,8 @@ func (s *Service) eventLoop() { log.Error(name+" unable to craft batch tx", "err", err) continue + } else if tx == nil { + continue } batchTxBuildTime := time.Since(batchTxBuildStart) / time.Millisecond s.metrics.BatchTxBuildTimeMs().Set(float64(batchTxBuildTime)) diff --git a/ops/envs/batch-submitter.env b/ops/envs/batch-submitter.env index 86bd8924473ac..143ca67b4b220 100644 --- a/ops/envs/batch-submitter.env +++ b/ops/envs/batch-submitter.env @@ -4,6 +4,7 @@ ETH_NETWORK_NAME=clique LOG_LEVEL=debug BATCH_SUBMITTER_LOG_LEVEL=debug BATCH_SUBMITTER_LOG_TERMINAL=true +BATCH_SUBMITTER_MIN_L1_TX_SIZE=32 BATCH_SUBMITTER_MAX_L1_TX_SIZE=90000 BATCH_SUBMITTER_MAX_BATCH_SUBMISSION_TIME=0 BATCH_SUBMITTER_POLL_INTERVAL=500ms