Skip to content

Commit

Permalink
use modular batcher e2esys config
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianst committed Nov 6, 2024
1 parent de41315 commit 2ac5316
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
3 changes: 2 additions & 1 deletion op-e2e/system/da/brotli_batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions op-e2e/system/da/da_throttling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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")
Expand Down
44 changes: 30 additions & 14 deletions op-e2e/system/e2esys/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 2ac5316

Please sign in to comment.