Skip to content

Commit 50b2f40

Browse files
committed
fix: flashblock and block time settings
1 parent 48f0e04 commit 50b2f40

14 files changed

Lines changed: 97 additions & 48 deletions

File tree

benchmark/flags/flags.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ var (
4444
}
4545

4646
RootDirFlag = &cli.StringFlag{
47-
Name: RootDirFlagName,
48-
Usage: "Root Directory",
49-
EnvVars: prefixEnvVars("ROOT_DIR"),
50-
Required: true,
47+
Name: RootDirFlagName,
48+
Usage: "Root Directory",
49+
EnvVars: prefixEnvVars("ROOT_DIR"),
50+
Value: "./data-dir",
5151
}
5252

5353
OutputDirFlag = &cli.StringFlag{
54-
Name: OutputDirFlagName,
55-
Usage: "Output Directory",
56-
EnvVars: prefixEnvVars("OUTPUT_DIR"),
57-
Required: true,
54+
Name: OutputDirFlagName,
55+
Usage: "Output Directory",
56+
Value: "./output",
57+
EnvVars: prefixEnvVars("OUTPUT_DIR"),
5858
}
5959

6060
TxFuzzBinFlag = &cli.StringFlag{

runner/benchmark/benchmark.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"os"
88
"strings"
99
"sync/atomic"
10-
"time"
1110

1211
"github.com/base/base-bench/runner/network/types"
1312
"github.com/ethereum/go-ethereum/core"
@@ -29,9 +28,8 @@ const (
2928
)
3029

3130
var DefaultParams = &types.RunParams{
32-
NodeType: "geth",
33-
GasLimit: 50e9,
34-
BlockTime: 1 * time.Second,
31+
NodeType: "geth",
32+
GasLimit: 50e9,
3533
}
3634

3735
// NewParamsFromValues constructs a new benchmark params given a config and a set of transaction payloads to run.

runner/benchmark/definition.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"path"
99
"path/filepath"
1010
"strings"
11+
"time"
1112

1213
"github.com/base/base-bench/runner/payload"
1314
)
@@ -87,13 +88,40 @@ func (s SnapshotDefinition) CreateSnapshot(nodeType string, outputDir string) er
8788
return cmd.Run()
8889
}
8990

91+
// FlashblocksConfig holds top-level flashblocks configuration.
92+
type FlashblocksConfig struct {
93+
BlockTime string `yaml:"block_time"`
94+
}
95+
96+
const DefaultFlashblocksBlockTime = "250ms"
97+
const DefaultBlockTime = "1s"
98+
9099
type BenchmarkConfig struct {
91100
Name string `yaml:"name"`
92101
Description *string `yaml:"description"`
102+
BlockTime *string `yaml:"block_time"`
103+
Flashblocks *FlashblocksConfig `yaml:"flashblocks"`
93104
Benchmarks []TestDefinition `yaml:"benchmarks"`
94105
TransactionPayloads []payload.Definition `yaml:"payloads"`
95106
}
96107

108+
// GetBlockTime returns the configured block time as a duration, or the default (1s).
109+
func (bc *BenchmarkConfig) GetBlockTime() (time.Duration, error) {
110+
raw := DefaultBlockTime
111+
if bc.BlockTime != nil && *bc.BlockTime != "" {
112+
raw = *bc.BlockTime
113+
}
114+
return time.ParseDuration(raw)
115+
}
116+
117+
// FlashblocksBlockTime returns the configured flashblocks block time, or the default.
118+
func (bc *BenchmarkConfig) FlashblocksBlockTime() string {
119+
if bc.Flashblocks != nil && bc.Flashblocks.BlockTime != "" {
120+
return bc.Flashblocks.BlockTime
121+
}
122+
return DefaultFlashblocksBlockTime
123+
}
124+
97125
type DatadirConfig struct {
98126
Sequencer *string `yaml:"sequencer"`
99127
Validator *string `yaml:"validator"`

runner/benchmark/matrix.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ func NewTestPlanFromConfig(c TestDefinition, testFileName string, config *Benchm
4747

4848
// ResolveTestRunsFromMatrix constructs a new ParamsMatrix from a config.
4949
func ResolveTestRunsFromMatrix(c TestDefinition, testFileName string, config *BenchmarkConfig) ([]TestRun, error) {
50+
blockTime, err := config.GetBlockTime()
51+
if err != nil {
52+
return nil, fmt.Errorf("invalid block_time: %w", err)
53+
}
54+
5055
seenParams := make(map[string]bool)
5156

5257
// Multiple payloads can run in a single benchmark.
@@ -107,6 +112,7 @@ func ResolveTestRunsFromMatrix(c TestDefinition, testFileName string, config *Be
107112
return nil, err
108113
}
109114

115+
params.BlockTime = blockTime
110116
params.Name = config.Name
111117
if config.Description != nil {
112118
params.Description = *config.Description

runner/benchmark/matrix_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package benchmark_test
22

33
import (
44
"testing"
5+
"time"
56

67
"github.com/base/base-bench/runner/benchmark"
78
"github.com/base/base-bench/runner/network/types"
@@ -31,7 +32,7 @@ func TestResolveTestRunsFromMatrix(t *testing.T) {
3132
NodeType: "geth",
3233
PayloadID: "simple",
3334
GasLimit: benchmark.DefaultParams.GasLimit,
34-
BlockTime: benchmark.DefaultParams.BlockTime,
35+
BlockTime: 1 * time.Second,
3536
},
3637
},
3738
},
@@ -57,31 +58,31 @@ func TestResolveTestRunsFromMatrix(t *testing.T) {
5758
NodeType: "geth",
5859
GasLimit: benchmark.DefaultParams.GasLimit,
5960
PayloadID: "simple",
60-
BlockTime: benchmark.DefaultParams.BlockTime,
61+
BlockTime: 1 * time.Second,
6162
},
6263
},
6364
{
6465
Params: types.RunParams{
6566
NodeType: "erigon",
6667
GasLimit: benchmark.DefaultParams.GasLimit,
6768
PayloadID: "simple",
68-
BlockTime: benchmark.DefaultParams.BlockTime,
69+
BlockTime: 1 * time.Second,
6970
},
7071
},
7172
{
7273
Params: types.RunParams{
7374
NodeType: "geth",
7475
GasLimit: benchmark.DefaultParams.GasLimit,
7576
PayloadID: "complex",
76-
BlockTime: benchmark.DefaultParams.BlockTime,
77+
BlockTime: 1 * time.Second,
7778
},
7879
},
7980
{
8081
Params: types.RunParams{
8182
NodeType: "erigon",
8283
GasLimit: benchmark.DefaultParams.GasLimit,
8384
PayloadID: "complex",
84-
BlockTime: benchmark.DefaultParams.BlockTime,
85+
BlockTime: 1 * time.Second,
8586
},
8687
},
8788
},

runner/clients/builder/client.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ func (r *BuilderClient) Run(ctx context.Context, cfg *types.RuntimeConfig) error
4949

5050
cfg2 := *cfg
5151
cfg2.Args = append(cfg2.Args, "--flashblocks.port", fmt.Sprintf("%d", r.websocketPort))
52+
cfg2.Args = append(cfg2.Args, "--flashblocks.fixed")
53+
if cfg.FlashblocksBlockTime != "" {
54+
cfg2.Args = append(cfg2.Args, "--flashblocks.block-time", cfg.FlashblocksBlockTime)
55+
}
56+
if cfg.BlockTimeMs > 0 {
57+
cfg2.Args = append(cfg2.Args, "--rollup.chain-block-time", fmt.Sprintf("%d", cfg.BlockTimeMs))
58+
}
5259
err := r.elClient.Run(ctx, &cfg2)
5360
if err != nil {
5461
return err

runner/clients/types/types.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ import (
1010
)
1111

1212
type RuntimeConfig struct {
13-
Stdout io.WriteCloser
14-
Stderr io.WriteCloser
15-
Args []string
16-
FlashblocksURL *string // Optional URL for flashblocks websocket server (only used by clients that support it)
13+
Stdout io.WriteCloser
14+
Stderr io.WriteCloser
15+
Args []string
16+
FlashblocksURL *string // Optional URL for flashblocks websocket server (only used by clients that support it)
17+
FlashblocksBlockTime string // Block time for flashblocks (e.g. "250ms")
18+
BlockTimeMs uint64 // L2 block time in milliseconds
1719
}
1820

1921
// ExecutionClient is an abstraction over the different clients that can be used to run the chain like

runner/network/configutil/rollup_config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"github.com/ethereum/go-ethereum/params"
1313
)
1414

15-
// GetRollupConfig creates a rollup configuration for the given genesis and chain
16-
func GetRollupConfig(genesis *core.Genesis, chain fakel1.L1Chain, batcherAddr common.Address) *rollup.Config {
15+
// GetRollupConfig creates a rollup configuration for the given genesis, chain, and block time (in seconds).
16+
func GetRollupConfig(genesis *core.Genesis, chain fakel1.L1Chain, batcherAddr common.Address, blockTimeSec uint64) *rollup.Config {
1717
var eipParams eth.Bytes8
1818
copy(eipParams[:], eip1559.EncodeHolocene1559Params(50, 1))
1919

@@ -50,7 +50,7 @@ func GetRollupConfig(genesis *core.Genesis, chain fakel1.L1Chain, batcherAddr co
5050
}),
5151
},
5252
},
53-
BlockTime: 1,
53+
BlockTime: blockTimeSec,
5454
MaxSequencerDrift: 20,
5555
SeqWindowSize: 24,
5656
L1ChainID: big.NewInt(1),

runner/network/consensus/sequencer_consensus.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ func (f *SequencerConsensusClient) Propose(ctx context.Context, blockMetrics *me
289289
blockMetrics.AddExecutionMetric(networktypes.UpdateForkChoiceLatencyMetric, duration)
290290

291291
f.currentPayloadID = payloadID
292+
f.log.Info("Waiting for block time", "block_time", f.options.BlockTime)
292293
// wait block time
293294
time.Sleep(f.options.BlockTime)
294295

runner/network/fault_proof_benchmark.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ type opProgramBenchmark struct {
4343
rollupCfg *rollup.Config
4444
}
4545

46-
func NewOPProgramBenchmark(genesis *core.Genesis, log log.Logger, opProgramBin string, l2RPCURL string, l1Chain fakel1.L1Chain, batcherKey *ecdsa.PrivateKey) ProofProgramBenchmark {
47-
rollupCfg := configutil.GetRollupConfig(genesis, l1Chain, crypto.PubkeyToAddress(batcherKey.PublicKey))
46+
func NewOPProgramBenchmark(genesis *core.Genesis, log log.Logger, opProgramBin string, l2RPCURL string, l1Chain fakel1.L1Chain, batcherKey *ecdsa.PrivateKey, blockTimeSec uint64) ProofProgramBenchmark {
47+
rollupCfg := configutil.GetRollupConfig(genesis, l1Chain, crypto.PubkeyToAddress(batcherKey.PublicKey), blockTimeSec)
4848
batcher := proofprogram.NewBatcher(rollupCfg, batcherKey, l1Chain)
4949

5050
return &opProgramBenchmark{

0 commit comments

Comments
 (0)