diff --git a/op-e2e/system/da/brotli_batcher_test.go b/op-e2e/system/da/brotli_batcher_test.go index a55e5bced8ad..fe9b4a9fab97 100644 --- a/op-e2e/system/da/brotli_batcher_test.go +++ b/op-e2e/system/da/brotli_batcher_test.go @@ -8,6 +8,7 @@ import ( "time" op_e2e "github.com/ethereum-optimism/optimism/op-e2e" + "github.com/ethereum-optimism/optimism/op-node/rollup/derive" "github.com/ethereum-optimism/optimism/op-e2e/system/e2esys" "github.com/ethereum-optimism/optimism/op-e2e/system/helpers" @@ -67,7 +68,7 @@ func TestBrotliBatcherFjord(t *testing.T) { cfg.DeployConfig.L2GenesisFjordTimeOffset = &genesisActivation // set up batcher to use brotli - sys, err := cfg.Start(t, e2esys.StartOption{Key: "compressionAlgo", Role: "brotli", Action: nil}) + sys, err := cfg.Start(t, e2esys.WithBatcherCompressionAlgo(derive.Brotli)) require.Nil(t, err, "Error starting up system") log := testlog.Logger(t, log.LevelInfo) diff --git a/op-e2e/system/da/da_throttling_test.go b/op-e2e/system/da/da_throttling_test.go index 1809a36fc15f..e98ad9d3338d 100644 --- a/op-e2e/system/da/da_throttling_test.go +++ b/op-e2e/system/da/da_throttling_test.go @@ -131,7 +131,6 @@ func TestDABlockThrottling(t *testing.T) { require.NotEqual(t, 0, r1.BlockNumber.Cmp(r3.BlockNumber)) require.NotEqual(t, 0, r2.BlockNumber.Cmp(r3.BlockNumber)) } - } func setupTest(t *testing.T, maxTxSize, maxBlockSize uint64) (e2esys.SystemConfig, *sources.RollupClient, *ethclient.Client, *ethclient.Client, *batcher.TestBatchSubmitter) { @@ -142,13 +141,11 @@ func setupTest(t *testing.T, maxTxSize, maxBlockSize uint64) (e2esys.SystemConfi return nil }, }...) - cfg.ThrottleThreshold = 1 // make sure throttling is always active - cfg.ThrottleTxSize = maxTxSize - cfg.ThrottleBlockSize = maxBlockSize // disable batcher because we start it manually later cfg.DisableBatcher = true - sys, err := cfg.Start(t) + sys, err := cfg.Start(t, + e2esys.WithBatcherThrottling(500*time.Millisecond, 1, maxTxSize, maxBlockSize)) require.NoError(t, err, "Error starting up system") rollupClient := sys.RollupClient("verifier") diff --git a/op-e2e/system/e2esys/setup.go b/op-e2e/system/e2esys/setup.go index 6d5449a92a22..9ab6d2de14f6 100644 --- a/op-e2e/system/e2esys/setup.go +++ b/op-e2e/system/e2esys/setup.go @@ -325,9 +325,6 @@ type SystemConfig struct { // SupportL1TimeTravel determines if the L1 node supports quickly skipping forward in time SupportL1TimeTravel bool - // Batcher throttling params - ThrottleThreshold, ThrottleTxSize, ThrottleBlockSize uint64 - AllocType config.AllocType } @@ -474,6 +471,9 @@ type StartOption struct { Key string Role string Action SystemConfigHook + + // Batcher CLIConfig modifications to apply before starting the batcher. + BatcherMod func(*bss.CLIConfig) } type startOptions struct { @@ -494,6 +494,25 @@ func parseStartOptions(_opts []StartOption) (startOptions, error) { }, nil } +func WithBatcherCompressionAlgo(ca derive.CompressionAlgo) StartOption { + return StartOption{ + BatcherMod: func(cfg *bss.CLIConfig) { + cfg.CompressionAlgo = ca + }, + } +} + +func WithBatcherThrottling(interval time.Duration, threshold, txSize, blockSize uint64) StartOption { + return StartOption{ + BatcherMod: func(cfg *bss.CLIConfig) { + cfg.ThrottleInterval = interval + cfg.ThrottleThreshold = threshold + cfg.ThrottleTxSize = txSize + cfg.ThrottleBlockSize = blockSize + }, + } +} + func (s *startOptions) Get(key, role string) (SystemConfigHook, bool) { v, ok := s.opts[key+":"+role] return v, ok @@ -862,12 +881,6 @@ func (cfg SystemConfig) Start(t *testing.T, startOpts ...StartOption) (*System, batcherTargetNumFrames = 1 } - var compressionAlgo derive.CompressionAlgo = derive.Zlib - // if opt has brotli key, set the compression algo as brotli - if _, ok := parsedStartOpts.Get("compressionAlgo", "brotli"); ok { - compressionAlgo = derive.Brotli10 - } - var batcherAltDACLIConfig altda.CLIConfig if cfg.DeployConfig.UseAltDA { fakeAltDAServer := altda.NewFakeDAServer("127.0.0.1", 0, sys.Cfg.Loggers["da-server"]) @@ -905,14 +918,17 @@ func (cfg SystemConfig) Start(t *testing.T, startOpts ...StartOption) (*System, BatchType: cfg.BatcherBatchType, MaxBlocksPerSpanBatch: cfg.BatcherMaxBlocksPerSpanBatch, DataAvailabilityType: sys.Cfg.DataAvailabilityType, - CompressionAlgo: compressionAlgo, + CompressionAlgo: derive.Zlib, AltDA: batcherAltDACLIConfig, + } - ThrottleThreshold: cfg.ThrottleThreshold, - ThrottleInterval: 500 * time.Millisecond, - ThrottleTxSize: cfg.ThrottleTxSize, - ThrottleBlockSize: cfg.ThrottleBlockSize, + // Apply batcher cli modifications + for _, opt := range startOpts { + if opt.BatcherMod != nil { + opt.BatcherMod(batcherCLIConfig) + } } + // Batch Submitter batcher, err := bss.BatcherServiceFromCLIConfig(context.Background(), "0.0.1", batcherCLIConfig, sys.Cfg.Loggers["batcher"]) if err != nil {