From 1bbe2e2ae6351e42435bea0a45607504ba99446b Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Tue, 2 Dec 2025 12:00:15 -0500 Subject: [PATCH 1/2] Enable changing l1 recipe default block time This PR introducts a `--block-time=1s` on `builder-playground cook l1` so it's possible to product blocks faster on the launched node. I took the libery to rename the op block time flag to be unexported and to have the `InSeconds` suffix. I also used `time.Duration` flag type for the `--block-time` implementation on L1 recipe, let me know if you would like this to be applied to op block-time too, or if in the opposite, would you prefer keeping the old way for both flag. --- README.md | 1 + playground/artifacts.go | 34 ++++++++++++++++++++++------------ playground/config.yaml.tmpl | 2 +- playground/recipe_l1.go | 7 +++++++ 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 5331b30..e35b476 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ $ builder-playground cook l1 [flags] Flags: - `--latest-fork`: Enable the latest fork at startup +- `--block-time`: Change the default block time (`12s`), to be provided in duration format (e.g. `--block-time=1s`) - `--use-reth-for-validation`: Use Reth EL for block validation in mev-boost. - `--secondary-el`: Port to use for a secondary el (enables the internal cl-proxy proxy) - `--use-native-reth`: Run the Reth EL binary on the host instead of docker (recommended to bind to the Reth DB) diff --git a/playground/artifacts.go b/playground/artifacts.go index 3e74540..499dff0 100644 --- a/playground/artifacts.go +++ b/playground/artifacts.go @@ -15,6 +15,7 @@ import ( "os" "path/filepath" "reflect" + "strconv" "strings" "sync" "text/template" @@ -36,6 +37,7 @@ import ( ) var ( + defaultL1BlockTimeSeconds = uint64(12) defaultOpBlockTimeSeconds = uint64(2) ) @@ -60,19 +62,21 @@ var clConfigContent []byte var queryReadyCheck []byte type ArtifactsBuilder struct { - outputDir string - applyLatestL1Fork bool - genesisDelay uint64 - applyLatestL2Fork *uint64 - OpblockTime uint64 + outputDir string + applyLatestL1Fork bool + genesisDelay uint64 + applyLatestL2Fork *uint64 + l1BlockTimeInSeconds uint64 + opBlockTimeInSeconds uint64 } func NewArtifactsBuilder() *ArtifactsBuilder { return &ArtifactsBuilder{ - outputDir: "", - applyLatestL1Fork: false, - genesisDelay: MinimumGenesisDelay, - OpblockTime: defaultOpBlockTimeSeconds, + outputDir: "", + applyLatestL1Fork: false, + genesisDelay: MinimumGenesisDelay, + l1BlockTimeInSeconds: defaultL1BlockTimeSeconds, + opBlockTimeInSeconds: defaultOpBlockTimeSeconds, } } @@ -96,8 +100,13 @@ func (b *ArtifactsBuilder) GenesisDelay(genesisDelaySeconds uint64) *ArtifactsBu return b } +func (b *ArtifactsBuilder) L1BlockTime(blockTimeSeconds uint64) *ArtifactsBuilder { + b.l1BlockTimeInSeconds = blockTimeSeconds + return b +} + func (b *ArtifactsBuilder) OpBlockTime(blockTimeSeconds uint64) *ArtifactsBuilder { - b.OpblockTime = blockTimeSeconds + b.opBlockTimeInSeconds = blockTimeSeconds return b } @@ -138,6 +147,7 @@ func (b *ArtifactsBuilder) Build() (*Artifacts, error) { latestForkEpoch = "18446744073709551615" } clConfigContentStr := strings.Replace(string(clConfigContent), "{{.LatestForkEpoch}}", latestForkEpoch, 1) + clConfigContentStr = strings.Replace(clConfigContentStr, "{{.SecondsPerSlot}}", strconv.FormatInt(int64(b.l1BlockTimeInSeconds), 10), 1) // load the config.yaml file clConfig, err := params.UnmarshalConfig([]byte(clConfigContentStr), nil) @@ -262,7 +272,7 @@ func (b *ArtifactsBuilder) Build() (*Artifacts, error) { forkTime = new(uint64) if *b.applyLatestL2Fork != 0 { - *forkTime = opTimestamp + b.OpblockTime*(*b.applyLatestL2Fork) + *forkTime = opTimestamp + b.opBlockTimeInSeconds*(*b.applyLatestL2Fork) } else { *forkTime = 0 } @@ -321,7 +331,7 @@ func (b *ArtifactsBuilder) Build() (*Artifacts, error) { "number": 0, }, }, - "block_time": b.OpblockTime, + "block_time": b.opBlockTimeInSeconds, "chain_op_config": map[string]interface{}{ // TODO: Read this from somewhere (genesis??) "eip1559Elasticity": 6, "eip1559Denominator": 50, diff --git a/playground/config.yaml.tmpl b/playground/config.yaml.tmpl index 12c68ee..271f540 100644 --- a/playground/config.yaml.tmpl +++ b/playground/config.yaml.tmpl @@ -31,7 +31,7 @@ FULU_FORK_EPOCH: 18446744073709551615 FULU_FORK_VERSION: 0x20000095 # Time parameters -SECONDS_PER_SLOT: 12 +SECONDS_PER_SLOT: {{.SecondsPerSlot}} # Deposit contract DEPOSIT_CONTRACT_ADDRESS: 0x4242424242424242424242424242424242424242 diff --git a/playground/recipe_l1.go b/playground/recipe_l1.go index b45c2b0..5444130 100644 --- a/playground/recipe_l1.go +++ b/playground/recipe_l1.go @@ -2,6 +2,7 @@ package playground import ( "fmt" + "time" flag "github.com/spf13/pflag" ) @@ -12,6 +13,10 @@ type L1Recipe struct { // latestFork enables the use of the latest fork at startup latestFork bool + // blockTime is the block time to use for the L1 nodes + // (default is 12 seconds) + blockTime time.Duration + // useRethForValidation signals mev-boost to use the Reth EL node for block validation useRethForValidation bool @@ -38,6 +43,7 @@ func (l *L1Recipe) Description() string { func (l *L1Recipe) Flags() *flag.FlagSet { flags := flag.NewFlagSet("l1", flag.ContinueOnError) flags.BoolVar(&l.latestFork, "latest-fork", false, "use the latest fork") + flags.DurationVar(&l.blockTime, "block-time", time.Duration(defaultL1BlockTimeSeconds)*time.Second, "Block time to use for the L1") flags.BoolVar(&l.useRethForValidation, "use-reth-for-validation", false, "use reth for validation") flags.Uint64Var(&l.secondaryELPort, "secondary-el", 0, "port to use for the secondary builder") flags.BoolVar(&l.useNativeReth, "use-native-reth", false, "use the native reth binary") @@ -48,6 +54,7 @@ func (l *L1Recipe) Flags() *flag.FlagSet { func (l *L1Recipe) Artifacts() *ArtifactsBuilder { builder := NewArtifactsBuilder() builder.ApplyLatestL1Fork(l.latestFork) + builder.L1BlockTime(min(1, uint64(l.blockTime.Seconds()))) return builder } From b0258ad746b27561e35e04339964a37ec22504d5 Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Fri, 5 Dec 2025 19:05:43 -0500 Subject: [PATCH 2/2] Fixed wrong logic to prevent duration lower than 1 second --- playground/recipe_l1.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/playground/recipe_l1.go b/playground/recipe_l1.go index 5444130..e53cff8 100644 --- a/playground/recipe_l1.go +++ b/playground/recipe_l1.go @@ -54,7 +54,7 @@ func (l *L1Recipe) Flags() *flag.FlagSet { func (l *L1Recipe) Artifacts() *ArtifactsBuilder { builder := NewArtifactsBuilder() builder.ApplyLatestL1Fork(l.latestFork) - builder.L1BlockTime(min(1, uint64(l.blockTime.Seconds()))) + builder.L1BlockTime(max(1, uint64(l.blockTime.Seconds()))) return builder }