diff --git a/README.md b/README.md index aa3ed97..75cefb9 100644 --- a/README.md +++ b/README.md @@ -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:` or a complete URL (e.g., `http://remote-host:8551`), use `http://host.docker.internal:` 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 diff --git a/playground/recipe_l1.go b/playground/recipe_l1.go index d619d12..a87f097 100644 --- a/playground/recipe_l1.go +++ b/playground/recipe_l1.go @@ -2,6 +2,7 @@ package playground import ( "fmt" + "regexp" flag "github.com/spf13/pflag" ) @@ -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: 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 @@ -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:` or a complete URL (e.g., `http://docker-container-name:8551`), use `http://host.docker.internal:` 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 @@ -52,6 +56,8 @@ func (l *L1Recipe) Artifacts() *ArtifactsBuilder { return builder } +var looksLikePortRegex = regexp.MustCompile(`^\d{2,5}$`) + func (l *L1Recipe) Apply(svcManager *Manifest) { svcManager.AddService(&RethEL{ UseRethForValidation: l.useRethForValidation, @@ -59,13 +65,18 @@ func (l *L1Recipe) Apply(svcManager *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(&ClProxy{ PrimaryBuilder: "el", - SecondaryBuilder: fmt.Sprintf("http://localhost:%d", l.secondaryELPort), + SecondaryBuilder: address, }) } else { elService = "el"