Skip to content

Commit 9428632

Browse files
maouehCopilot
andauthored
Added possibility to have a secondary el on the host (#219)
This change, relatively simple and backward compatible, enables syncing an external execution client from the host itself instead of relying on running within Docker. We tested it and to succesfully sync with the inner el peer, one further change is needed which is to expose the P2P address to the public interface (instead of only within the host), PR incoming for this. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 7c4b1ae commit 9428632

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Flags:
4949
- `--latest-fork`: Enable the latest fork at startup
5050
- `--block-time`: Change the default block time (`12s`), to be provided in duration format (e.g. `--block-time=1s`)
5151
- `--use-reth-for-validation`: Use Reth EL for block validation in mev-boost.
52-
- `--secondary-el`: Port to use for a secondary el (enables the internal cl-proxy proxy)
52+
- `--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.
5353
- `--use-native-reth`: Run the Reth EL binary on the host instead of docker (recommended to bind to the Reth DB)
5454
- `--use-separate-mev-boost`: Spins a seperate service for mev-boost in addition with mev-boost-relay
5555

playground/recipe_l1.go

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

33
import (
44
"fmt"
5+
"regexp"
56
"time"
67

78
flag "github.com/spf13/pflag"
@@ -20,9 +21,12 @@ type L1Recipe struct {
2021
// useRethForValidation signals mev-boost to use the Reth EL node for block validation
2122
useRethForValidation bool
2223

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

2731
// if useNativeReth is set to true, the Reth EL execution client for the validator beacon node
2832
// will run on the host machine. This is useful if you want to bind to the Reth database and you
@@ -45,7 +49,7 @@ func (l *L1Recipe) Flags() *flag.FlagSet {
4549
flags.BoolVar(&l.latestFork, "latest-fork", false, "use the latest fork")
4650
flags.DurationVar(&l.blockTime, "block-time", time.Duration(defaultL1BlockTimeSeconds)*time.Second, "Block time to use for the L1")
4751
flags.BoolVar(&l.useRethForValidation, "use-reth-for-validation", false, "use reth for validation")
48-
flags.Uint64Var(&l.secondaryELPort, "secondary-el", 0, "port to use for the secondary builder")
52+
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.")
4953
flags.BoolVar(&l.useNativeReth, "use-native-reth", false, "use the native reth binary")
5054
flags.BoolVar(&l.useSeparateMevBoost, "use-separate-mev-boost", false, "use separate mev-boost and mev-boost-relay services")
5155
return flags
@@ -59,20 +63,27 @@ func (l *L1Recipe) Artifacts() *ArtifactsBuilder {
5963
return builder
6064
}
6165

66+
var looksLikePortRegex = regexp.MustCompile(`^\d{2,5}$`)
67+
6268
func (l *L1Recipe) Apply(svcManager *Manifest) {
6369
svcManager.AddService(&RethEL{
6470
UseRethForValidation: l.useRethForValidation,
6571
UseNativeReth: l.useNativeReth,
6672
})
6773

6874
var elService string
69-
if l.secondaryELPort != 0 {
75+
if l.secondaryEL != "" {
76+
address := l.secondaryEL
77+
if looksLikePortRegex.MatchString(l.secondaryEL) {
78+
address = fmt.Sprintf("http://localhost:%s", l.secondaryEL)
79+
}
80+
7081
// we are going to use the cl-proxy service to connect the beacon node to two builders
7182
// one the 'el' builder and another one the remote one
7283
elService = "cl-proxy"
7384
svcManager.AddService(&ClProxy{
7485
PrimaryBuilder: "el",
75-
SecondaryBuilder: fmt.Sprintf("http://localhost:%d", l.secondaryELPort),
86+
SecondaryBuilder: address,
7687
})
7788
} else {
7889
elService = "el"

0 commit comments

Comments
 (0)