From b77fa75610916a878bac33c8584208c7e0f6fe1b Mon Sep 17 00:00:00 2001 From: Mateusz Morusiewicz <11313015+Ruteri@users.noreply.github.com> Date: Mon, 25 Jul 2022 12:53:10 +0200 Subject: [PATCH] Run builder even if cannot connect to remote relay (#12) --- builder/relay.go | 7 +++++-- builder/relay_test.go | 5 ++--- builder/service.go | 5 +---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/builder/relay.go b/builder/relay.go index b476b68f6c48..432c03bfd024 100644 --- a/builder/relay.go +++ b/builder/relay.go @@ -44,7 +44,7 @@ type RemoteRelay struct { validatorSlotMap map[uint64]ValidatorData } -func NewRemoteRelay(endpoint string, localRelay *LocalRelay) (*RemoteRelay, error) { +func NewRemoteRelay(endpoint string, localRelay *LocalRelay) *RemoteRelay { r := &RemoteRelay{ endpoint: endpoint, client: http.Client{Timeout: time.Second}, @@ -55,7 +55,10 @@ func NewRemoteRelay(endpoint string, localRelay *LocalRelay) (*RemoteRelay, erro } err := r.updateValidatorsMap(0, 3) - return r, err + if err != nil { + log.Error("could not connect to remote relay, continuing anyway", "err", err) + } + return r } type GetValidatorRelayResponse []struct { diff --git a/builder/relay_test.go b/builder/relay_test.go index 93def4cd5148..adc0f9aabac8 100644 --- a/builder/relay_test.go +++ b/builder/relay_test.go @@ -45,8 +45,7 @@ func TestRemoteRelay(t *testing.T) { } srv := httptest.NewServer(r) - relay, err := NewRemoteRelay(srv.URL, nil) - require.NoError(t, err) + relay := NewRemoteRelay(srv.URL, nil) vd, found := relay.validatorSlotMap[123] require.True(t, found) expectedValidator_123 := ValidatorData{ @@ -57,7 +56,7 @@ func TestRemoteRelay(t *testing.T) { } require.Equal(t, expectedValidator_123, vd) - vd, err = relay.GetValidatorForSlot(123) + vd, err := relay.GetValidatorForSlot(123) require.NoError(t, err) require.Equal(t, expectedValidator_123, vd) diff --git a/builder/service.go b/builder/service.go index 340cb46c6aed..d7da282ad261 100644 --- a/builder/service.go +++ b/builder/service.go @@ -114,10 +114,7 @@ func Register(stack *node.Node, backend *eth.Ethereum, cfg *BuilderConfig) error var relay IRelay if cfg.RemoteRelayEndpoint != "" { - relay, err = NewRemoteRelay(cfg.RemoteRelayEndpoint, localRelay) - if err != nil { - return err - } + relay = NewRemoteRelay(cfg.RemoteRelayEndpoint, localRelay) } else { relay = localRelay }