Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,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)
Expand Down
38 changes: 25 additions & 13 deletions playground/artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"os"
"path/filepath"
"reflect"
"strconv"
"strings"
"sync"
"text/template"
Expand All @@ -35,7 +36,10 @@
"gopkg.in/yaml.v2"
)

var defaultOpBlockTimeSeconds = uint64(2)
var (
defaultL1BlockTimeSeconds = uint64(12)
defaultOpBlockTimeSeconds = uint64(2)
)

// minimumGenesisDelay is the minimum delay for the genesis time. This is required
// because lighthouse takes some time to start and we need to make sure it is ready
Expand All @@ -58,19 +62,21 @@
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,
}
}

Expand All @@ -94,8 +100,13 @@
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
}

Expand Down Expand Up @@ -136,6 +147,7 @@
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)
Expand Down Expand Up @@ -258,7 +270,7 @@
forkTime = new(uint64)

if *b.applyLatestL2Fork != 0 {
*forkTime = opTimestamp + b.OpblockTime*(*b.applyLatestL2Fork)
*forkTime = opTimestamp + b.opBlockTimeInSeconds*(*b.applyLatestL2Fork)
} else {
*forkTime = 0
}
Expand Down Expand Up @@ -317,7 +329,7 @@
"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,
Expand Down Expand Up @@ -687,7 +699,7 @@
"0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6",
}

func applyTemplate2(templateStr []byte, input interface{}) ([]byte, error) {

Check failure on line 702 in playground/artifacts.go

View workflow job for this annotation

GitHub Actions / Lint

func applyTemplate2 is unused (U1000)
tpl, err := template.New("").Parse(string(templateStr))
if err != nil {
return nil, fmt.Errorf("failed to parse template: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion playground/config.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions playground/recipe_l1.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package playground

import (
"fmt"
"time"

flag "github.com/spf13/pflag"
)
Expand All @@ -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

Expand All @@ -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")
Expand All @@ -48,6 +54,7 @@ func (l *L1Recipe) Flags() *flag.FlagSet {
func (l *L1Recipe) Artifacts() *ArtifactsBuilder {
builder := NewArtifactsBuilder()
builder.ApplyLatestL1Fork(l.latestFork)
builder.L1BlockTime(max(1, uint64(l.blockTime.Seconds())))

return builder
}
Expand Down
Loading