-
Notifications
You must be signed in to change notification settings - Fork 109
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
hotfix(el/cl): allow multi clients to start if at least one node is up #2000
Changes from 31 commits
4a7ed06
1784907
6139748
54f982f
7a4248d
1025641
af5c455
3b9efcf
c6592ad
b21c110
902c99a
13edb6a
e1cc2e3
2bdc1ac
8db421f
0dd1027
8452bf4
d5fed41
75e2753
999608b
66d5051
61874f7
70594e8
3cc71cd
7dd5aa0
ab91668
99405c9
768665d
6af3463
e9f5c7b
f093561
7b3a1f5
16dc397
95af801
411f482
cbd61f5
f8188c6
5b72d6a
77ca3cf
0406ad3
23d393d
85779ec
c890973
4751783
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 |
---|---|---|
|
@@ -6,7 +6,6 @@ import ( | |
"errors" | ||
"fmt" | ||
"math/big" | ||
"sync" | ||
"sync/atomic" | ||
"time" | ||
|
||
|
@@ -49,7 +48,6 @@ var _ Provider = &ExecutionClient{} | |
|
||
var ( | ||
ErrClosed = fmt.Errorf("closed") | ||
ErrUnhealthy = fmt.Errorf("unhealthy") | ||
ErrNotConnected = fmt.Errorf("not connected") | ||
ErrBadInput = fmt.Errorf("bad input") | ||
ErrNothingToSync = errors.New("nothing to sync") | ||
|
@@ -81,8 +79,6 @@ type ExecutionClient struct { | |
client *ethclient.Client | ||
closed chan struct{} | ||
lastSyncedTime atomic.Int64 | ||
healthyChMu sync.Mutex | ||
healthyCh chan struct{} | ||
} | ||
|
||
// New creates a new instance of ExecutionClient. | ||
|
@@ -98,7 +94,6 @@ func New(ctx context.Context, nodeAddr string, contractAddr ethcommon.Address, o | |
healthInvalidationInterval: DefaultHealthInvalidationInterval, | ||
logBatchSize: DefaultHistoricalLogsBatchSize, // TODO Make batch of logs adaptive depending on "websocket: read limit" | ||
closed: make(chan struct{}), | ||
healthyCh: make(chan struct{}), | ||
} | ||
for _, opt := range opts { | ||
opt(client) | ||
|
@@ -246,8 +241,6 @@ func (ec *ExecutionClient) StreamLogs(ctx context.Context, fromBlock uint64) <-c | |
return | ||
case <-ec.closed: | ||
return | ||
case <-ec.healthyCh: | ||
return | ||
default: | ||
lastBlock, err := ec.streamLogsToChan(ctx, logs, fromBlock) | ||
if errors.Is(err, ErrClosed) || errors.Is(err, context.Canceled) { | ||
|
@@ -294,22 +287,7 @@ func (ec *ExecutionClient) Healthy(ctx context.Context) error { | |
return nil | ||
} | ||
|
||
ec.healthyChMu.Lock() | ||
defer ec.healthyChMu.Unlock() | ||
|
||
if err := ec.healthy(ctx); err != nil { | ||
close(ec.healthyCh) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This triggers closing of closed channel which panics, I'm removing it as it's dangerous to use |
||
return fmt.Errorf("unhealthy: %w", err) | ||
} | ||
|
||
// Reset the healthyCh channel if it was closed. | ||
select { | ||
case <-ec.healthyCh: | ||
default: | ||
ec.healthyCh = make(chan struct{}) | ||
} | ||
|
||
return nil | ||
return ec.healthy(ctx) | ||
} | ||
|
||
func (ec *ExecutionClient) healthy(ctx context.Context) error { | ||
|
@@ -426,9 +404,6 @@ func (ec *ExecutionClient) streamLogsToChan(ctx context.Context, logs chan<- Blo | |
case <-ec.closed: | ||
return fromBlock, ErrClosed | ||
|
||
case <-ec.healthyCh: | ||
return fromBlock, ErrUnhealthy | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not working as expected, I saw it returning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 Just briefly looking at this channel (and corresponding mutex) - it's not entirely clear how it is supposed to be used (what it's for, etc.) so if we aren't gonna remove it entirely we need to at least re-think it's purpose/usage |
||
|
||
case err := <-sub.Err(): | ||
if err == nil { | ||
return fromBlock, ErrClosed | ||
|
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.
Not really specific to this PR but we often (and here as well) do 2 "duplicate" things
maybe would be simpler to just return
error
(with formatted withfmt.Errorf
to provide the necessary context) in places like this, bringing it up so we can get on the same page (whether we want to keep an eye on things like this or not)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 main difference and issue is that when logging with zap and adding fields its easy to search them by the label value. we'll need to squeeze everything to the
fmt.Errorf
, it'll still be searchable, but not by label.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.
I agree that we could think more about our logging approach, but I think this package currently uses logging in a way similar to other packages. If we decide to improve logging (e.g. use custom error types with fields), we need to do it project-wide