Skip to content

Commit

Permalink
Run builder even if cannot connect to remote relay (ethereum#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruteri authored and avalonche committed Mar 8, 2023
1 parent f405fac commit 3279d15
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
7 changes: 5 additions & 2 deletions builder/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions builder/relay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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)

Expand Down
5 changes: 1 addition & 4 deletions builder/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 3279d15

Please sign in to comment.