-
Notifications
You must be signed in to change notification settings - Fork 145
Load specs from beacon node #771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||||||||||||||||||||||
| package cmd | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import ( | ||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||
| "net/url" | ||||||||||||||||||||||||||
| "os" | ||||||||||||||||||||||||||
| "os/signal" | ||||||||||||||||||||||||||
|
|
@@ -90,13 +91,6 @@ var apiCmd = &cobra.Command{ | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| log.Infof("boost-relay %s", Version) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| networkInfo, err := common.NewEthNetworkDetails(network) | ||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||
| log.WithError(err).Fatalf("error getting network details") | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| log.Infof("Using network: %s", networkInfo.Name) | ||||||||||||||||||||||||||
| log.Debug(networkInfo.String()) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Connect to beacon clients and ensure it's synced | ||||||||||||||||||||||||||
| if len(beaconNodeURIs) == 0 { | ||||||||||||||||||||||||||
| log.Fatalf("no beacon endpoints specified") | ||||||||||||||||||||||||||
|
|
@@ -117,6 +111,19 @@ var apiCmd = &cobra.Command{ | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| beaconClient := beaconclient.NewMultiBeaconClient(log, beaconInstances) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| if network == "" { | ||||||||||||||||||||||||||
| if err := loadSpecFromBeaconClient(beaconClient); err != nil { | ||||||||||||||||||||||||||
| log.WithError(err).Fatalf("error loading spec from beacon client") | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| networkInfo, err := common.NewEthNetworkDetails(network) | ||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||
| log.WithError(err).Fatalf("error getting network details") | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| log.Infof("Using network: %s", networkInfo.Name) | ||||||||||||||||||||||||||
| log.Debug(networkInfo.String()) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Connect to Redis | ||||||||||||||||||||||||||
| if redisReadonlyURI == "" { | ||||||||||||||||||||||||||
| log.Infof("Connecting to Redis at %s ...", redisURI) | ||||||||||||||||||||||||||
|
|
@@ -217,3 +224,34 @@ var apiCmd = &cobra.Command{ | |||||||||||||||||||||||||
| log.Info("bye") | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // loadSpecFromBeaconClient fetches the chain spec and genesis data from the beacon client | ||||||||||||||||||||||||||
| // and sets the corresponding environment variables for fork versions and genesis info. | ||||||||||||||||||||||||||
| // This allows the relay to automatically configure network parameters without manual specification. | ||||||||||||||||||||||||||
| func loadSpecFromBeaconClient(beaconClient *beaconclient.MultiBeaconClient) error { | ||||||||||||||||||||||||||
| spec, err := beaconClient.GetSpec() | ||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| genesis, err := beaconClient.GetGenesis() | ||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||
| return err | ||||||||||||||||||||||||||
|
Comment on lines
+234
to
+239
|
||||||||||||||||||||||||||
| return err | |
| } | |
| genesis, err := beaconClient.GetGenesis() | |
| if err != nil { | |
| return err | |
| return fmt.Errorf("get beacon spec: %w", err) | |
| } | |
| genesis, err := beaconClient.GetGenesis() | |
| if err != nil { | |
| return fmt.Errorf("get beacon genesis: %w", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still using env variables such that I do not have to modify NewEthNetworkDetails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be great to leave as comment
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unconditionally overwrites any user-provided env vars. If someone set fork versions explicitly (intentionally overriding the beacon), this will silently replace them. Consider only setting values when the env var is not already present (using os.LookupEnv), or clearly defining/implementing precedence (e.g., env overrides beacon, or vice versa) with logging.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,7 @@ var ( | |||||
| EthNetworkHoodi = "hoodi" | ||||||
| EthNetworkMainnet = "mainnet" | ||||||
| EthNetworkCustom = "custom" | ||||||
| EthNetworkBeacon = "" | ||||||
|
||||||
| EthNetworkBeacon = "" | |
| EthNetworkBeacon = "beacon" |
Copilot
AI
Feb 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using an empty string as a named network constant is ambiguous and makes it hard to distinguish between “unset flag” and an intentional mode. It also results in EthNetworkDetails.Name being empty for this path. Prefer a non-empty explicit value (e.g., \"beacon\"/\"auto\") or keep empty as invalid and handle the auto-load decision entirely in cmd/api.go (e.g., set network = common.EthNetworkCustom after loading env vars).
| case EthNetworkBeacon: | |
| fallthrough |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description says specs should be loaded when the network is not part of presets, but the current logic only loads from the beacon when
network == \"\". If a user sets--network custom, they still won’t get auto-loading. Consider triggeringloadSpecFromBeaconClientfornetwork == common.EthNetworkCustom(or introducing an explicit--network auto/beaconvalue) and then passing a non-empty value intoNewEthNetworkDetailsso logs/config reflect the mode.