From 7ab9fb60c2812222c8595fa2e120b4339f688a80 Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Wed, 6 Sep 2023 13:40:06 +1000 Subject: [PATCH] feat(beacon): Pass through headers to beacon package (#183) * fix(cannon): Check sync status before deriving events * feat(beacon): Pass through headers to beacon package * feat(beacon): Pass through headers to beacon package --- pkg/cannon/ethereum/beacon.go | 5 +++-- pkg/cannon/ethereum/config.go | 2 ++ pkg/sentry/ethereum/beacon.go | 5 +++-- pkg/sentry/ethereum/config.go | 2 ++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/cannon/ethereum/beacon.go b/pkg/cannon/ethereum/beacon.go index 29d8c588..c8b6b215 100644 --- a/pkg/cannon/ethereum/beacon.go +++ b/pkg/cannon/ethereum/beacon.go @@ -42,8 +42,9 @@ func NewBeaconNode(ctx context.Context, name string, config *Config, log logrus. opts.BeaconSubscription.Enabled = false node := beacon.NewNode(log, &beacon.Config{ - Name: name, - Addr: config.BeaconNodeAddress, + Name: name, + Addr: config.BeaconNodeAddress, + Headers: config.BeaconNodeHeaders, }, "xatu_cannon", opts) metadata := services.NewMetadataService(log, node) diff --git a/pkg/cannon/ethereum/config.go b/pkg/cannon/ethereum/config.go index c16f15b2..d583387e 100644 --- a/pkg/cannon/ethereum/config.go +++ b/pkg/cannon/ethereum/config.go @@ -16,6 +16,8 @@ type Config struct { BlockCacheSize uint64 `yaml:"blockCacheSize" default:"1000"` // BlockCacheTTL is the time to live for blocks in the cache. BlockCacheTTL human.Duration `yaml:"blockCacheTtl" default:"1h"` + // BeaconNodeHeaders is a map of headers to send to the beacon node. + BeaconNodeHeaders map[string]string `yaml:"beaconNodeHeaders"` } func (c *Config) Validate() error { diff --git a/pkg/sentry/ethereum/beacon.go b/pkg/sentry/ethereum/beacon.go index a2593321..345e9734 100644 --- a/pkg/sentry/ethereum/beacon.go +++ b/pkg/sentry/ethereum/beacon.go @@ -33,8 +33,9 @@ func NewBeaconNode(ctx context.Context, name string, config *Config, log logrus. opts.HealthCheck.SuccessfulResponses = 1 node := beacon.NewNode(log, &beacon.Config{ - Name: name, - Addr: config.BeaconNodeAddress, + Name: name, + Addr: config.BeaconNodeAddress, + Headers: config.BeaconNodeHeaders, }, "xatu_sentry", opts) metadata := services.NewMetadataService(log, node) diff --git a/pkg/sentry/ethereum/config.go b/pkg/sentry/ethereum/config.go index ee6f3297..2a6b4134 100644 --- a/pkg/sentry/ethereum/config.go +++ b/pkg/sentry/ethereum/config.go @@ -8,6 +8,8 @@ type Config struct { // OverrideNetworkName is the name of the network to use for the sentry. // If not set, the network name will be retrieved from the beacon node. OverrideNetworkName string `yaml:"overrideNetworkName" default:""` + // BeaconNodeHeaders is a map of headers to send to the beacon node. + BeaconNodeHeaders map[string]string `yaml:"beaconNodeHeaders"` } func (c *Config) Validate() error {