Skip to content

Commit

Permalink
feat(lighthouse): Support lighthouse 5.3.0+ (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanschneider authored Oct 31, 2024
1 parent 55b0d8d commit 62ad77a
Showing 1 changed file with 39 additions and 2 deletions.
41 changes: 39 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,30 @@ func setupServices(svcManager *serviceManager, out *output) error {
WithPort("authrpc", 8551).
Run()

lightHouseVersion := func() string {
cmd := exec.Command(lighthouseBin, "--version")
out, err := cmd.Output()
if err != nil {
return "unknown"
}
// find the line of the form:
// Lighthouse v5.2.1-9e12c21
for _, line := range strings.Split(string(out), "\n") {
if strings.HasPrefix(line, "Lighthouse ") {
v := strings.TrimSpace(strings.TrimPrefix(line, "Lighthouse "))
if !strings.HasPrefix(v, "v") {
v = "v" + v
}
// Go semver considers - as a pre-release, so we need to remove it
v = strings.Split(v, "-")[0]
return semver.Canonical(v)
}
}
return "unknown"
}()

// start the beacon node
fmt.Println("Starting lighthouse version " + lightHouseVersion)
svcManager.
NewService("beacon_node").
WithArgs(
Expand All @@ -438,7 +461,6 @@ func setupServices(svcManager *serviceManager, out *output) error {
"--enable-private-discovery",
"--disable-peer-scoring",
"--staking",
"--http-allow-sync-stalled",
"--enr-address", "127.0.0.1",
"--enr-udp-port", "9000",
"--enr-tcp-port", "9000",
Expand All @@ -456,6 +478,21 @@ func setupServices(svcManager *serviceManager, out *output) error {
"--always-prepare-payload",
"--prepare-payload-lookahead", "8000",
).
If(
semver.Compare(lightHouseVersion, "v5.3") < 0,
func(s *service) *service {
// For versions <= v5.2.1, we want to run with --http-allow-sync-stalled
// However this flag is not available in newer versions
return s.WithArgs("--http-allow-sync-stalled")
},
).
If(
semver.Compare(lightHouseVersion, "v5.3") >= 0,
func(s *service) *service {
// For versions >= v5.3.0, ----suggested-fee-recipient is apparently now required for non-validator nodes as well
return s.WithArgs("--suggested-fee-recipient", "0x690B9A9E9aa1C9dB991C7721a92d351Db4FaC990")
},
).
WithPort("http", 3500).
Run()

Expand Down Expand Up @@ -688,7 +725,7 @@ func (s *serviceManager) Run(ss *service) {
}

// first thing to output is the command itself
fmt.Fprint(logOutput, strings.Join(ss.args, " "))
fmt.Fprint(logOutput, strings.Join(ss.args, " ")+"\n\n")

cmd.Stdout = logOutput
cmd.Stderr = logOutput
Expand Down

0 comments on commit 62ad77a

Please sign in to comment.