Skip to content

Commit

Permalink
eth/executionclient: fail if any client cannot be dialed on start
Browse files Browse the repository at this point in the history
  • Loading branch information
nkryuchkov committed Dec 27, 2024
1 parent c95b8ba commit 359a615
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions eth/executionclient/execution_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func New(ctx context.Context, nodeAddr string, contractAddr ethcommon.Address, o
mc, err := NewManagedClient(ctx, addr, client.logger, client.reconnectionInitialInterval, client.reconnectionMaxInterval)
if err != nil {
client.logger.Error("Failed to initialize ManagedClient", zap.String("address", addr), zap.Error(err))
// Continue initializing other clients
return nil, fmt.Errorf("create managed client: %w", err)
}

Check warning on line 90 in eth/executionclient/execution_client.go

View check run for this annotation

Codecov / codecov/patch

eth/executionclient/execution_client.go#L88-L90

Added lines #L88 - L90 were not covered by tests
client.clients = append(client.clients, mc)
}
Expand Down Expand Up @@ -118,20 +118,20 @@ func (ec *ExecutionClient) assertSameChainIDs(ctx context.Context) (bool, error)
for _, client := range ec.clients {
c := client.getClient()
if c == nil {
ec.logger.Warn("Skipping unhealthy client", zap.String("address", client.addr))
continue // Skip unhealthy clients
ec.logger.Warn("Client is not healthy", zap.String("address", client.addr))
return false, fmt.Errorf("client is not healthy")
}

Check warning on line 123 in eth/executionclient/execution_client.go

View check run for this annotation

Codecov / codecov/patch

eth/executionclient/execution_client.go#L121-L123

Added lines #L121 - L123 were not covered by tests
chainID, err := c.ChainID(ctx)
if err != nil {
ec.logger.Error("Failed to get chain ID", zap.String("address", client.addr), zap.Error(err))
return false, err
return false, fmt.Errorf("get chain ID: %w", err)
}

Check warning on line 128 in eth/executionclient/execution_client.go

View check run for this annotation

Codecov / codecov/patch

eth/executionclient/execution_client.go#L126-L128

Added lines #L126 - L128 were not covered by tests
if firstChainID == nil {
firstChainID = chainID
continue
}
if firstChainID.Cmp(chainID) != 0 {
ec.logger.Warn("Chain ID mismatch",
ec.logger.Error("Chain ID mismatch",
zap.String("first_chain_id", firstChainID.String()),
zap.String("current_chain_id", chainID.String()),
zap.String("address", client.addr))
Expand Down
3 changes: 2 additions & 1 deletion eth/executionclient/managed_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package executionclient

import (
"context"
"fmt"
"sync"
"time"

Expand Down Expand Up @@ -35,7 +36,7 @@ func NewManagedClient(ctx context.Context, addr string, logger *zap.Logger, init
err := mc.connect(ctx)
if err != nil {
mc.logger.Error("Initial connection failed", zap.String("address", addr), zap.Error(err))
// Continue without a connected client; health monitoring will attempt reconnection
return nil, fmt.Errorf("connect: %w", err)
}

Check warning on line 40 in eth/executionclient/managed_client.go

View check run for this annotation

Codecov / codecov/patch

eth/executionclient/managed_client.go#L38-L40

Added lines #L38 - L40 were not covered by tests

mc.wg.Add(1)
Expand Down

0 comments on commit 359a615

Please sign in to comment.