Documentation
¶
Overview ¶
Package executionclient implements functions for interacting with Ethereum execution clients.
Package executionclient is a generated GoMock package.
Index ¶
- Constants
- Variables
- type BlockLogs
- type ExecutionClient
- func (ec *ExecutionClient) Address() string
- func (ec *ExecutionClient) ChainID(ctx context.Context) (*big.Int, error)
- func (ec *ExecutionClient) Close() error
- func (ec *ExecutionClient) FetchHistoricalLogs(ctx context.Context, fromBlock uint64) (logsCh <-chan BlockLogs, errsCh <-chan error, err error)
- func (ec *ExecutionClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]ethtypes.Log, error)
- func (ec *ExecutionClient) Filterer() (*contract.ContractFilterer, error)
- func (ec *ExecutionClient) HeaderByNumber(ctx context.Context, blockNumber *big.Int) (*ethtypes.Header, error)
- func (ec *ExecutionClient) Healthy(ctx context.Context) error
- func (ec *ExecutionClient) StreamLogs(ctx context.Context, fromBlock uint64) (logsCh chan BlockLogs)
- func (ec *ExecutionClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- ethtypes.Log) (ethereum.Subscription, error)
- func (ec *ExecutionClient) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
- type MockProvider
- func (m *MockProvider) ChainID(ctx context.Context) (*big.Int, error)
- func (m *MockProvider) Close() error
- func (m *MockProvider) EXPECT() *MockProviderMockRecorder
- func (m *MockProvider) FetchHistoricalLogs(ctx context.Context, fromBlock uint64) (<-chan BlockLogs, <-chan error, error)
- func (m *MockProvider) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
- func (m *MockProvider) Filterer() (*contract.ContractFilterer, error)
- func (m *MockProvider) HeaderByNumber(ctx context.Context, blockNumber *big.Int) (*types.Header, error)
- func (m *MockProvider) Healthy(ctx context.Context) error
- func (m *MockProvider) StreamLogs(ctx context.Context, fromBlock uint64) chan BlockLogs
- func (m *MockProvider) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- type MockProviderMockRecorder
- func (mr *MockProviderMockRecorder) ChainID(ctx any) *gomock.Call
- func (mr *MockProviderMockRecorder) Close() *gomock.Call
- func (mr *MockProviderMockRecorder) FetchHistoricalLogs(ctx, fromBlock any) *gomock.Call
- func (mr *MockProviderMockRecorder) FilterLogs(ctx, q any) *gomock.Call
- func (mr *MockProviderMockRecorder) Filterer() *gomock.Call
- func (mr *MockProviderMockRecorder) HeaderByNumber(ctx, blockNumber any) *gomock.Call
- func (mr *MockProviderMockRecorder) Healthy(ctx any) *gomock.Call
- func (mr *MockProviderMockRecorder) StreamLogs(ctx, fromBlock any) *gomock.Call
- func (mr *MockProviderMockRecorder) SubscribeFilterLogs(ctx, q, ch any) *gomock.Call
- type MockSingleClientProvider
- func (m *MockSingleClientProvider) ChainID(ctx context.Context) (*big.Int, error)
- func (m *MockSingleClientProvider) Close() error
- func (m *MockSingleClientProvider) EXPECT() *MockSingleClientProviderMockRecorder
- func (m *MockSingleClientProvider) FetchHistoricalLogs(ctx context.Context, fromBlock uint64) (<-chan BlockLogs, <-chan error, error)
- func (m *MockSingleClientProvider) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
- func (m *MockSingleClientProvider) Filterer() (*contract.ContractFilterer, error)
- func (m *MockSingleClientProvider) HeaderByNumber(ctx context.Context, blockNumber *big.Int) (*types.Header, error)
- func (m *MockSingleClientProvider) Healthy(ctx context.Context) error
- func (m *MockSingleClientProvider) StreamLogs(ctx context.Context, fromBlock uint64) chan BlockLogs
- func (m *MockSingleClientProvider) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (m *MockSingleClientProvider) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
- type MockSingleClientProviderMockRecorder
- func (mr *MockSingleClientProviderMockRecorder) ChainID(ctx any) *gomock.Call
- func (mr *MockSingleClientProviderMockRecorder) Close() *gomock.Call
- func (mr *MockSingleClientProviderMockRecorder) FetchHistoricalLogs(ctx, fromBlock any) *gomock.Call
- func (mr *MockSingleClientProviderMockRecorder) FilterLogs(ctx, q any) *gomock.Call
- func (mr *MockSingleClientProviderMockRecorder) Filterer() *gomock.Call
- func (mr *MockSingleClientProviderMockRecorder) HeaderByNumber(ctx, blockNumber any) *gomock.Call
- func (mr *MockSingleClientProviderMockRecorder) Healthy(ctx any) *gomock.Call
- func (mr *MockSingleClientProviderMockRecorder) StreamLogs(ctx, fromBlock any) *gomock.Call
- func (mr *MockSingleClientProviderMockRecorder) SubscribeFilterLogs(ctx, q, ch any) *gomock.Call
- func (mr *MockSingleClientProviderMockRecorder) SyncProgress(ctx any) *gomock.Call
- type MultiClient
- func (mc *MultiClient) ChainID(_ context.Context) (*big.Int, error)
- func (mc *MultiClient) Close() error
- func (mc *MultiClient) FetchHistoricalLogs(ctx context.Context, fromBlock uint64) (<-chan BlockLogs, <-chan error, error)
- func (mc *MultiClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]ethtypes.Log, error)
- func (mc *MultiClient) Filterer() (*contract.ContractFilterer, error)
- func (mc *MultiClient) HeaderByNumber(ctx context.Context, blockNumber *big.Int) (*ethtypes.Header, error)
- func (mc *MultiClient) Healthy(ctx context.Context) error
- func (mc *MultiClient) StreamLogs(ctx context.Context, fromBlock uint64) (logsCh chan BlockLogs)
- func (mc *MultiClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- ethtypes.Log) (ethereum.Subscription, error)
- type Option
- type OptionMulti
- type Options
- type Provider
- type SingleClientProvider
Constants ¶
Variables ¶
Functions ¶
This section is empty.
Types ¶
type ExecutionClient ¶
type ExecutionClient struct {
// contains filtered or unexported fields
}
ExecutionClient represents a client for interacting with Ethereum execution client.
func New ¶
func New(ctx context.Context, nodeAddr string, contractAddr ethcommon.Address, opts ...Option) (*ExecutionClient, error)
New creates a new instance of ExecutionClient.
func (*ExecutionClient) Address ¶
func (ec *ExecutionClient) Address() string
func (*ExecutionClient) Close ¶
func (ec *ExecutionClient) Close() error
Close shuts down ExecutionClient.
func (*ExecutionClient) FetchHistoricalLogs ¶
func (ec *ExecutionClient) FetchHistoricalLogs(ctx context.Context, fromBlock uint64) ( logsCh <-chan BlockLogs, errsCh <-chan error, err error, )
FetchHistoricalLogs retrieves historical logs emitted by the contract starting from fromBlock.
func (*ExecutionClient) FilterLogs ¶
func (ec *ExecutionClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]ethtypes.Log, error)
func (*ExecutionClient) Filterer ¶
func (ec *ExecutionClient) Filterer() (*contract.ContractFilterer, error)
func (*ExecutionClient) HeaderByNumber ¶
func (*ExecutionClient) Healthy ¶
func (ec *ExecutionClient) Healthy(ctx context.Context) error
Healthy returns if execution client is currently healthy: responds to requests and not in the syncing state.
func (*ExecutionClient) StreamLogs ¶
func (ec *ExecutionClient) StreamLogs(ctx context.Context, fromBlock uint64) (logsCh chan BlockLogs)
StreamLogs subscribes to events emitted by the Ethereum SSV contract(s) starting at fromBlock. It spawns a go-routine that spins in a perpetual retry loop, terminating only on unrecoverable interruptions (such as context cancels, client closure, etc.) as defined by isSingleClientInterruptedError func. The logsCh is closed once the streaming go-routine terminates. Any errors encountered during streaming are logged.
func (*ExecutionClient) SubscribeFilterLogs ¶
func (ec *ExecutionClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- ethtypes.Log) (ethereum.Subscription, error)
func (*ExecutionClient) SyncProgress ¶
func (ec *ExecutionClient) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
type MockProvider ¶
type MockProvider struct {
// contains filtered or unexported fields
}
MockProvider is a mock of Provider interface.
func NewMockProvider ¶
func NewMockProvider(ctrl *gomock.Controller) *MockProvider
NewMockProvider creates a new mock instance.
func (*MockProvider) EXPECT ¶
func (m *MockProvider) EXPECT() *MockProviderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockProvider) FetchHistoricalLogs ¶
func (m *MockProvider) FetchHistoricalLogs(ctx context.Context, fromBlock uint64) (<-chan BlockLogs, <-chan error, error)
FetchHistoricalLogs mocks base method.
func (*MockProvider) FilterLogs ¶
func (m *MockProvider) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
FilterLogs mocks base method.
func (*MockProvider) Filterer ¶
func (m *MockProvider) Filterer() (*contract.ContractFilterer, error)
Filterer mocks base method.
func (*MockProvider) HeaderByNumber ¶
func (m *MockProvider) HeaderByNumber(ctx context.Context, blockNumber *big.Int) (*types.Header, error)
HeaderByNumber mocks base method.
func (*MockProvider) Healthy ¶
func (m *MockProvider) Healthy(ctx context.Context) error
Healthy mocks base method.
func (*MockProvider) StreamLogs ¶
func (m *MockProvider) StreamLogs(ctx context.Context, fromBlock uint64) chan BlockLogs
StreamLogs mocks base method.
func (*MockProvider) SubscribeFilterLogs ¶
func (m *MockProvider) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs mocks base method.
type MockProviderMockRecorder ¶
type MockProviderMockRecorder struct {
// contains filtered or unexported fields
}
MockProviderMockRecorder is the mock recorder for MockProvider.
func (*MockProviderMockRecorder) ChainID ¶
func (mr *MockProviderMockRecorder) ChainID(ctx any) *gomock.Call
ChainID indicates an expected call of ChainID.
func (*MockProviderMockRecorder) Close ¶
func (mr *MockProviderMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockProviderMockRecorder) FetchHistoricalLogs ¶
func (mr *MockProviderMockRecorder) FetchHistoricalLogs(ctx, fromBlock any) *gomock.Call
FetchHistoricalLogs indicates an expected call of FetchHistoricalLogs.
func (*MockProviderMockRecorder) FilterLogs ¶
func (mr *MockProviderMockRecorder) FilterLogs(ctx, q any) *gomock.Call
FilterLogs indicates an expected call of FilterLogs.
func (*MockProviderMockRecorder) Filterer ¶
func (mr *MockProviderMockRecorder) Filterer() *gomock.Call
Filterer indicates an expected call of Filterer.
func (*MockProviderMockRecorder) HeaderByNumber ¶
func (mr *MockProviderMockRecorder) HeaderByNumber(ctx, blockNumber any) *gomock.Call
HeaderByNumber indicates an expected call of HeaderByNumber.
func (*MockProviderMockRecorder) Healthy ¶
func (mr *MockProviderMockRecorder) Healthy(ctx any) *gomock.Call
Healthy indicates an expected call of Healthy.
func (*MockProviderMockRecorder) StreamLogs ¶
func (mr *MockProviderMockRecorder) StreamLogs(ctx, fromBlock any) *gomock.Call
StreamLogs indicates an expected call of StreamLogs.
func (*MockProviderMockRecorder) SubscribeFilterLogs ¶
func (mr *MockProviderMockRecorder) SubscribeFilterLogs(ctx, q, ch any) *gomock.Call
SubscribeFilterLogs indicates an expected call of SubscribeFilterLogs.
type MockSingleClientProvider ¶
type MockSingleClientProvider struct {
// contains filtered or unexported fields
}
MockSingleClientProvider is a mock of SingleClientProvider interface.
func NewMockSingleClientProvider ¶
func NewMockSingleClientProvider(ctrl *gomock.Controller) *MockSingleClientProvider
NewMockSingleClientProvider creates a new mock instance.
func (*MockSingleClientProvider) Close ¶
func (m *MockSingleClientProvider) Close() error
Close mocks base method.
func (*MockSingleClientProvider) EXPECT ¶
func (m *MockSingleClientProvider) EXPECT() *MockSingleClientProviderMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
func (*MockSingleClientProvider) FetchHistoricalLogs ¶
func (m *MockSingleClientProvider) FetchHistoricalLogs(ctx context.Context, fromBlock uint64) (<-chan BlockLogs, <-chan error, error)
FetchHistoricalLogs mocks base method.
func (*MockSingleClientProvider) FilterLogs ¶
func (m *MockSingleClientProvider) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
FilterLogs mocks base method.
func (*MockSingleClientProvider) Filterer ¶
func (m *MockSingleClientProvider) Filterer() (*contract.ContractFilterer, error)
Filterer mocks base method.
func (*MockSingleClientProvider) HeaderByNumber ¶
func (m *MockSingleClientProvider) HeaderByNumber(ctx context.Context, blockNumber *big.Int) (*types.Header, error)
HeaderByNumber mocks base method.
func (*MockSingleClientProvider) Healthy ¶
func (m *MockSingleClientProvider) Healthy(ctx context.Context) error
Healthy mocks base method.
func (*MockSingleClientProvider) StreamLogs ¶
func (m *MockSingleClientProvider) StreamLogs(ctx context.Context, fromBlock uint64) chan BlockLogs
StreamLogs mocks base method.
func (*MockSingleClientProvider) SubscribeFilterLogs ¶
func (m *MockSingleClientProvider) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs mocks base method.
func (*MockSingleClientProvider) SyncProgress ¶
func (m *MockSingleClientProvider) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
SyncProgress mocks base method.
type MockSingleClientProviderMockRecorder ¶
type MockSingleClientProviderMockRecorder struct {
// contains filtered or unexported fields
}
MockSingleClientProviderMockRecorder is the mock recorder for MockSingleClientProvider.
func (*MockSingleClientProviderMockRecorder) ChainID ¶
func (mr *MockSingleClientProviderMockRecorder) ChainID(ctx any) *gomock.Call
ChainID indicates an expected call of ChainID.
func (*MockSingleClientProviderMockRecorder) Close ¶
func (mr *MockSingleClientProviderMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close.
func (*MockSingleClientProviderMockRecorder) FetchHistoricalLogs ¶
func (mr *MockSingleClientProviderMockRecorder) FetchHistoricalLogs(ctx, fromBlock any) *gomock.Call
FetchHistoricalLogs indicates an expected call of FetchHistoricalLogs.
func (*MockSingleClientProviderMockRecorder) FilterLogs ¶
func (mr *MockSingleClientProviderMockRecorder) FilterLogs(ctx, q any) *gomock.Call
FilterLogs indicates an expected call of FilterLogs.
func (*MockSingleClientProviderMockRecorder) Filterer ¶
func (mr *MockSingleClientProviderMockRecorder) Filterer() *gomock.Call
Filterer indicates an expected call of Filterer.
func (*MockSingleClientProviderMockRecorder) HeaderByNumber ¶
func (mr *MockSingleClientProviderMockRecorder) HeaderByNumber(ctx, blockNumber any) *gomock.Call
HeaderByNumber indicates an expected call of HeaderByNumber.
func (*MockSingleClientProviderMockRecorder) Healthy ¶
func (mr *MockSingleClientProviderMockRecorder) Healthy(ctx any) *gomock.Call
Healthy indicates an expected call of Healthy.
func (*MockSingleClientProviderMockRecorder) StreamLogs ¶
func (mr *MockSingleClientProviderMockRecorder) StreamLogs(ctx, fromBlock any) *gomock.Call
StreamLogs indicates an expected call of StreamLogs.
func (*MockSingleClientProviderMockRecorder) SubscribeFilterLogs ¶
func (mr *MockSingleClientProviderMockRecorder) SubscribeFilterLogs(ctx, q, ch any) *gomock.Call
SubscribeFilterLogs indicates an expected call of SubscribeFilterLogs.
func (*MockSingleClientProviderMockRecorder) SyncProgress ¶
func (mr *MockSingleClientProviderMockRecorder) SyncProgress(ctx any) *gomock.Call
SyncProgress indicates an expected call of SyncProgress.
type MultiClient ¶
type MultiClient struct {
// contains filtered or unexported fields
}
MultiClient wraps several execution clients and uses the current available one.
There are several scenarios of node outage:
1) SSV node uses EL1, EL2, CL1, CL2; CL1 uses only EL1, CL2 uses only EL2. EL1 becomes unavailable.
The execution client MultiClient switches to EL2, consensus multi client (another package) remains on CL1. CL1 remains available and responds to requests but its syncing distance increases until EL1 is up. The consensus multi client cannot determine that it's unhealthy until the sync distance reaches SyncDistanceTolerance, but when it does, it switches to CL2 and then SSV node uses EL2 and CL2. This case usually causes duty misses approximately for duration of SyncDistanceTolerance.
2) SSV node uses EL1, EL2, CL1, CL2; CL1 uses EL1 and other available ELs, CL2 uses any available EL. EL1 becomes unavailable.
The execution MultiClient switches to EL2, the consensus multi client remains on CL1, which should switch its execution client from EL1 to an available one. Possible duty misses up to SyncDistanceTolerance duration
3) SSV node uses EL1, EL2, CL1, CL2; CL1 uses any available EL, CL2 uses any available EL. EL1 becomes unavailable.
The execution MultiClient switches to EL2, the consensus multi client remains on CL1, which should remain working. This shouldn't cause significant duty misses.
4) SSV node uses EL1, EL2, CL1, CL2; CL1 uses only EL1, CL2 uses only EL2. EL1 and CL1 become unavailable.
The execution MultiClient switches to EL2, the consensus multi client switches to CL2, This shouldn't cause significant duty misses.
func NewMulti ¶
func NewMulti(ctx context.Context, nodeAddrs []string, contractAddr ethcommon.Address, opts ...OptionMulti) (*MultiClient, error)
NewMulti creates a new instance of MultiClient.
func (*MultiClient) Close ¶
func (mc *MultiClient) Close() error
func (*MultiClient) FetchHistoricalLogs ¶
func (mc *MultiClient) FetchHistoricalLogs(ctx context.Context, fromBlock uint64) (<-chan BlockLogs, <-chan error, error)
FetchHistoricalLogs retrieves historical logs emitted by the Ethereum SSV contract(s) starting at fromBlock. It delegates the FetchHistoricalLogs call to clients MultiClient is configured with until one of them manages to serve it without an error.
func (*MultiClient) FilterLogs ¶
func (mc *MultiClient) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]ethtypes.Log, error)
func (*MultiClient) Filterer ¶
func (mc *MultiClient) Filterer() (*contract.ContractFilterer, error)
func (*MultiClient) HeaderByNumber ¶
func (mc *MultiClient) HeaderByNumber(ctx context.Context, blockNumber *big.Int) (*ethtypes.Header, error)
HeaderByNumber retrieves a block header by its number.
func (*MultiClient) Healthy ¶
func (mc *MultiClient) Healthy(ctx context.Context) error
Healthy returns whether MultiClient has at least 1 healthy EL client (a client that responds to requests and not is in the syncing state).
func (*MultiClient) StreamLogs ¶
func (mc *MultiClient) StreamLogs(ctx context.Context, fromBlock uint64) (logsCh chan BlockLogs)
StreamLogs subscribes to events emitted by the Ethereum SSV contract(s) starting at fromBlock. It spawns a go-routine that spins in a perpetual retry loop, terminating only on unrecoverable interruptions (such as context cancels, client closure, etc.) as defined by isMultiClientInterruptedError func. The logsCh is closed once the streaming go-routine terminates. Any errors encountered during streaming are logged.
func (*MultiClient) SubscribeFilterLogs ¶
func (mc *MultiClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- ethtypes.Log) (ethereum.Subscription, error)
type Option ¶
type Option func(*ExecutionClient)
Option defines an ExecutionClient configuration option.
func WithFollowDistance ¶
WithFollowDistance sets finalization offset (a block at this offset into the past from the head block will be considered as very likely finalized).
func WithHealthInvalidationInterval ¶
WithHealthInvalidationInterval sets health invalidation interval. 0 disables caching.
func WithReqTimeout ¶
WithReqTimeout sets timeout for RPC requests to eth1 node. The timeout must be positive, otherwise the default value will be used.
func WithSyncDistanceTolerance ¶
WithSyncDistanceTolerance sets the number of blocks that is acceptable to lag behind.
type OptionMulti ¶
type OptionMulti func(client *MultiClient)
OptionMulti defines a MultiClient configuration option.
func WithLoggerMulti ¶
func WithLoggerMulti(logger *zap.Logger) OptionMulti
WithLoggerMulti enables logging.
func WithReqTimeoutMulti ¶
func WithReqTimeoutMulti(timeout time.Duration) OptionMulti
WithReqTimeoutMulti sets timeout for RPC requests to eth1 node. The timeout must be positive, otherwise the default value will be used.
func WithSyncDistanceToleranceMulti ¶
func WithSyncDistanceToleranceMulti(count uint64) OptionMulti
WithSyncDistanceToleranceMulti sets the number of blocks that is acceptable to lag behind.
type Options ¶
type Options struct {
Addr string `` /* 214-byte string literal not displayed */
ConnectionTimeout time.Duration `` /* 133-byte string literal not displayed */
SyncDistanceTolerance uint64 `` /* 158-byte string literal not displayed */
}
Options contains config configurations related to Ethereum execution client.
type Provider ¶
type Provider interface {
FetchHistoricalLogs(ctx context.Context, fromBlock uint64) (logsCh <-chan BlockLogs, errsCh <-chan error, err error)
StreamLogs(ctx context.Context, fromBlock uint64) (logsCh chan BlockLogs)
Filterer() (*contract.ContractFilterer, error)
HeaderByNumber(ctx context.Context, blockNumber *big.Int) (*ethtypes.Header, error)
ChainID(ctx context.Context) (*big.Int, error)
Healthy(ctx context.Context) error
SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- ethtypes.Log) (ethereum.Subscription, error)
FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]ethtypes.Log, error)
Close() error
}