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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Flags:

- `--latest-fork`: Enable the latest fork at startup
- `--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)
- `--secondary-el`: Host or port to use for a secondary el (enables the internal cl-proxy proxy). Can be a port number (e.g., '8551') in which case the full URL is derived as `http://localhost:<port>` or a complete URL (e.g., `http://remote-host:8551`), use `http://host.docker.internal:<port>` to reach a secondary execution client that runs on your host and not within Docker.
- `--use-native-reth`: Run the Reth EL binary on the host instead of docker (recommended to bind to the Reth DB)
- `--use-separate-mev-boost`: Spins a seperate service for mev-boost in addition with mev-boost-relay

Expand Down
23 changes: 17 additions & 6 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"
"regexp"

flag "github.com/spf13/pflag"
)
Expand All @@ -15,9 +16,12 @@ type L1Recipe struct {
// useRethForValidation signals mev-boost to use the Reth EL node for block validation
useRethForValidation bool

// secondaryELPort enables the use of a secondary EL connected to the validator beacon node
// It is enabled through the use of the cl-proxy service
secondaryELPort uint64
// secondaryEL enables the use of a secondary EL connected to the validator beacon node
// It is enabled through the use of the cl-proxy service. If the input is a plain number, it is assumed
// to be a port number and the secondary EL is assumed to be running on localhost at that port.
// Otherwise, it is assumed to be a full address (e.g http://some-el:8551) where to reach the secondary EL,
// use http://host.docker.internal:<port> to reach the host machine from within docker.
secondaryEL string

// if useNativeReth is set to true, the Reth EL execution client for the validator beacon node
// will run on the host machine. This is useful if you want to bind to the Reth database and you
Expand All @@ -39,7 +43,7 @@ func (l *L1Recipe) Flags() *flag.FlagSet {
flags := flag.NewFlagSet("l1", flag.ContinueOnError)
flags.BoolVar(&l.latestFork, "latest-fork", false, "use the latest fork")
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.StringVar(&l.secondaryEL, "secondary-el", "", "Address or port to use for the secondary EL (execution layer); Can be a port number (e.g., '8551') in which case the full URL is derived as `http://localhost:<port>` or a complete URL (e.g., `http://docker-container-name:8551`), use `http://host.docker.internal:<port>` to reach a secondary execution client that runs on your host and not within Docker.")
flags.BoolVar(&l.useNativeReth, "use-native-reth", false, "use the native reth binary")
flags.BoolVar(&l.useSeparateMevBoost, "use-separate-mev-boost", false, "use separate mev-boost and mev-boost-relay services")
return flags
Expand All @@ -52,6 +56,8 @@ func (l *L1Recipe) Artifacts() *ArtifactsBuilder {
return builder
}

var looksLikePortRegex = regexp.MustCompile(`^\d{2,5}$`)

func (l *L1Recipe) Apply(ctx *ExContext, artifacts *Artifacts) *Manifest {
svcManager := NewManifest(ctx, artifacts.Out)

Expand All @@ -61,13 +67,18 @@ func (l *L1Recipe) Apply(ctx *ExContext, artifacts *Artifacts) *Manifest {
})

var elService string
if l.secondaryELPort != 0 {
if l.secondaryEL != "" {
address := l.secondaryEL
if looksLikePortRegex.MatchString(l.secondaryEL) {
address = fmt.Sprintf("http://localhost:%s", l.secondaryEL)
}

// we are going to use the cl-proxy service to connect the beacon node to two builders
// one the 'el' builder and another one the remote one
elService = "cl-proxy"
svcManager.AddService("cl-proxy", &ClProxy{
PrimaryBuilder: "el",
SecondaryBuilder: fmt.Sprintf("http://localhost:%d", l.secondaryELPort),
SecondaryBuilder: address,
})
} else {
elService = "el"
Expand Down