services

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2024 License: AGPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EthClientSyncTimeout    int64 = 8 // 8 seconds
	BeaconClientSyncTimeout int64 = 8 // 8 seconds

)

Variables

This section is empty.

Functions

func GetEthClientLatestBlockTimestamp

func GetEthClientLatestBlockTimestamp(ec eth.IExecutionClient) (uint64, error)

func IsSyncWithinThreshold

func IsSyncWithinThreshold(ec eth.IExecutionClient) (bool, time.Time, error)

Confirm the EC's latest block is within the threshold of the current system clock

Types

type BeaconClientManager

type BeaconClientManager struct {
	// contains filtered or unexported fields
}

This is a proxy for multiple Beacon clients, providing natural fallback support if one of them fails.

func NewBeaconClientManager

func NewBeaconClientManager(cfg *config.HyperdriveConfig) (*BeaconClientManager, error)

Creates a new BeaconClientManager instance based on the Hyperdrive config

func (*BeaconClientManager) ChangeWithdrawalCredentials

func (m *BeaconClientManager) ChangeWithdrawalCredentials(ctx context.Context, validatorIndex string, fromBlsPubkey beaconutils.ValidatorPubkey, toExecutionAddress common.Address, signature beaconutils.ValidatorSignature) error

Change the withdrawal credentials for a validator

func (*BeaconClientManager) CheckStatus

func (*BeaconClientManager) Close

func (m *BeaconClientManager) Close(ctx context.Context) error

Close the connection to the Beacon client

func (*BeaconClientManager) ExitValidator

func (m *BeaconClientManager) ExitValidator(ctx context.Context, validatorIndex string, epoch uint64, signature beaconutils.ValidatorSignature) error

Voluntarily exit a validator

func (*BeaconClientManager) GetAttestations

func (m *BeaconClientManager) GetAttestations(ctx context.Context, blockId string) ([]types.AttestationInfo, bool, error)

Get the attestations in a Beacon chain block

func (*BeaconClientManager) GetBeaconBlock

func (m *BeaconClientManager) GetBeaconBlock(ctx context.Context, blockId string) (types.BeaconBlock, bool, error)

Get a Beacon chain block

func (*BeaconClientManager) GetBeaconHead

func (m *BeaconClientManager) GetBeaconHead(ctx context.Context) (types.BeaconHead, error)

Get the Beacon chain's head information

func (*BeaconClientManager) GetDomainData

func (m *BeaconClientManager) GetDomainData(ctx context.Context, domainType []byte, epoch uint64, useGenesisFork bool) ([]byte, error)

Get the Beacon chain's domain data

func (*BeaconClientManager) GetEth1DataForEth2Block

func (m *BeaconClientManager) GetEth1DataForEth2Block(ctx context.Context, blockId string) (types.Eth1Data, bool, error)

Get the EL data for a CL block

func (*BeaconClientManager) GetEth2Config

func (m *BeaconClientManager) GetEth2Config(ctx context.Context) (types.Eth2Config, error)

Get the Beacon configuration

func (*BeaconClientManager) GetEth2DepositContract

func (m *BeaconClientManager) GetEth2DepositContract(ctx context.Context) (types.Eth2DepositContract, error)

Get the Beacon configuration

func (*BeaconClientManager) GetSyncStatus

func (m *BeaconClientManager) GetSyncStatus(ctx context.Context) (types.SyncStatus, error)

Get the client's sync status

func (*BeaconClientManager) GetValidatorIndex

func (m *BeaconClientManager) GetValidatorIndex(ctx context.Context, pubkey beaconutils.ValidatorPubkey) (string, error)

Get a validator's index

func (*BeaconClientManager) GetValidatorProposerDuties

func (m *BeaconClientManager) GetValidatorProposerDuties(ctx context.Context, indices []string, epoch uint64) (map[string]uint64, error)

Get a validator's proposer duties

func (*BeaconClientManager) GetValidatorStatus

Get a validator's status by its pubkey

func (*BeaconClientManager) GetValidatorStatusByIndex

func (m *BeaconClientManager) GetValidatorStatusByIndex(ctx context.Context, index string, opts *types.ValidatorStatusOptions) (types.ValidatorStatus, error)

Get a validator's status by its index

func (*BeaconClientManager) GetValidatorStatuses

Get the statuses of multiple validators by their pubkeys

func (*BeaconClientManager) GetValidatorSyncDuties

func (m *BeaconClientManager) GetValidatorSyncDuties(ctx context.Context, indices []string, epoch uint64) (map[string]bool, error)

Get a validator's sync duties

func (*BeaconClientManager) IsFallbackReady

func (m *BeaconClientManager) IsFallbackReady() bool

func (*BeaconClientManager) IsPrimaryReady

func (m *BeaconClientManager) IsPrimaryReady() bool

type ExecutionClientManager

type ExecutionClientManager struct {
	// contains filtered or unexported fields
}

This is a proxy for multiple ETH clients, providing natural fallback support if one of them fails.

func NewExecutionClientManager

func NewExecutionClientManager(cfg *config.HyperdriveConfig) (*ExecutionClientManager, error)

Creates a new ExecutionClientManager instance based on the Hyperdrive config

func (*ExecutionClientManager) BalanceAt

func (m *ExecutionClientManager) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)

BalanceAt returns the wei balance of the given account. The block number can be nil, in which case the balance is taken from the latest known block.

func (*ExecutionClientManager) BlockNumber

func (m *ExecutionClientManager) BlockNumber(ctx context.Context) (uint64, error)

BlockNumber returns the most recent block number

func (*ExecutionClientManager) CallContract

func (m *ExecutionClientManager) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)

CallContract executes an Ethereum contract call with the specified data as the input.

func (*ExecutionClientManager) CheckStatus

func (*ExecutionClientManager) CodeAt

func (m *ExecutionClientManager) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)

CodeAt returns the code of the given account. This is needed to differentiate between contract internal errors and the local chain being out of sync.

func (*ExecutionClientManager) EstimateGas

func (m *ExecutionClientManager) EstimateGas(ctx context.Context, call ethereum.CallMsg) (gas uint64, err error)

EstimateGas tries to estimate the gas needed to execute a specific transaction based on the current pending state of the backend blockchain. There is no guarantee that this is the true gas limit requirement as other transactions may be added or removed by miners, but it should provide a basis for setting a reasonable default.

func (*ExecutionClientManager) FilterLogs

func (m *ExecutionClientManager) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)

FilterLogs executes a log filter operation, blocking during execution and returning all the results in one batch.

TODO(karalabe): Deprecate when the subscription one can return past data too.

func (ExecutionClientManager) GetFallbackExecutionClient

func (m ExecutionClientManager) GetFallbackExecutionClient() eth.IExecutionClient

func (ExecutionClientManager) GetPrimaryExecutionClient

func (m ExecutionClientManager) GetPrimaryExecutionClient() eth.IExecutionClient

func (*ExecutionClientManager) HeaderByHash

func (m *ExecutionClientManager) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

HeaderByHash returns the block header with the given hash.

func (*ExecutionClientManager) HeaderByNumber

func (m *ExecutionClientManager) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)

HeaderByNumber returns a block header from the current canonical chain. If number is nil, the latest known header is returned.

func (*ExecutionClientManager) IsFallbackReady

func (m *ExecutionClientManager) IsFallbackReady() bool

func (*ExecutionClientManager) IsPrimaryReady

func (m *ExecutionClientManager) IsPrimaryReady() bool

func (*ExecutionClientManager) NonceAt

func (m *ExecutionClientManager) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)

NonceAt returns the account nonce of the given account. The block number can be nil, in which case the nonce is taken from the latest known block.

func (*ExecutionClientManager) PendingCodeAt

func (m *ExecutionClientManager) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

PendingCodeAt returns the code of the given account in the pending state.

func (*ExecutionClientManager) PendingNonceAt

func (m *ExecutionClientManager) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

PendingNonceAt retrieves the current pending nonce associated with an account.

func (*ExecutionClientManager) SendTransaction

func (m *ExecutionClientManager) SendTransaction(ctx context.Context, tx *types.Transaction) error

SendTransaction injects the transaction into the pending pool for execution.

func (*ExecutionClientManager) SubscribeFilterLogs

func (m *ExecutionClientManager) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)

SubscribeFilterLogs creates a background log filtering operation, returning a subscription immediately, which can be used to stream the found events.

func (*ExecutionClientManager) SuggestGasPrice

func (m *ExecutionClientManager) SuggestGasPrice(ctx context.Context) (*big.Int, error)

SuggestGasPrice retrieves the currently suggested gas price to allow a timely execution of a transaction.

func (*ExecutionClientManager) SuggestGasTipCap

func (m *ExecutionClientManager) SuggestGasTipCap(ctx context.Context) (*big.Int, error)

SuggestGasTipCap retrieves the currently suggested 1559 priority fee to allow a timely execution of a transaction.

func (*ExecutionClientManager) SyncProgress

func (m *ExecutionClientManager) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)

SyncProgress retrieves the current progress of the sync algorithm. If there's no sync currently running, it returns nil.

func (*ExecutionClientManager) TransactionByHash

func (m *ExecutionClientManager) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)

TransactionByHash returns the transaction with the given hash.

func (*ExecutionClientManager) TransactionReceipt

func (m *ExecutionClientManager) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

TransactionReceipt returns the receipt of a transaction by transaction hash. Note that the receipt is not available for pending transactions.

type ModuleSigner added in v0.2.3

type ModuleSigner struct {
	// contains filtered or unexported fields
}

Used to request TX signatures from the node wallet

func NewModuleSigner added in v0.2.3

func NewModuleSigner(hd *client.ApiClient) *ModuleSigner

Creates a new ModuleSigner

func (*ModuleSigner) GetTransactor added in v0.2.3

func (s *ModuleSigner) GetTransactor(walletAddress common.Address) *bind.TransactOpts

Gets a transactor for signing transactions

type ServiceProvider

type ServiceProvider[ConfigType config.IModuleConfig] struct {
	// contains filtered or unexported fields
}

A container for all of the various services used by Hyperdrive

func NewServiceProvider

func NewServiceProvider[ConfigType config.IModuleConfig](moduleDir string, factory func(*config.HyperdriveConfig) ConfigType) (*ServiceProvider[ConfigType], error)

Creates a new ServiceProvider instance

func (*ServiceProvider[_]) GetApiLogger

func (p *ServiceProvider[_]) GetApiLogger() *log.ColorLogger

func (*ServiceProvider[_]) GetBeaconClient

func (p *ServiceProvider[_]) GetBeaconClient() *BeaconClientManager

func (*ServiceProvider[_]) GetDocker

func (p *ServiceProvider[_]) GetDocker() *docker.Client

func (*ServiceProvider[_]) GetEthClient

func (p *ServiceProvider[_]) GetEthClient() *ExecutionClientManager

func (*ServiceProvider[_]) GetHyperdriveClient

func (p *ServiceProvider[_]) GetHyperdriveClient() *client.ApiClient

func (*ServiceProvider[_]) GetHyperdriveConfig added in v0.2.3

func (p *ServiceProvider[_]) GetHyperdriveConfig() *config.HyperdriveConfig

func (*ServiceProvider[ConfigType]) GetModuleConfig added in v0.2.3

func (p *ServiceProvider[ConfigType]) GetModuleConfig() ConfigType

func (*ServiceProvider[_]) GetModuleDir

func (p *ServiceProvider[_]) GetModuleDir() string

func (*ServiceProvider[_]) GetQueryManager

func (p *ServiceProvider[_]) GetQueryManager() *eth.QueryManager

func (*ServiceProvider[_]) GetResources

func (p *ServiceProvider[_]) GetResources() *utils.Resources

func (*ServiceProvider[_]) GetSigner added in v0.2.3

func (p *ServiceProvider[_]) GetSigner() *ModuleSigner

func (*ServiceProvider[_]) GetTransactionManager

func (p *ServiceProvider[_]) GetTransactionManager() *eth.TransactionManager

func (*ServiceProvider[_]) GetUserDir

func (p *ServiceProvider[_]) GetUserDir() string

func (*ServiceProvider[_]) IsDebugMode

func (p *ServiceProvider[_]) IsDebugMode() bool

func (*ServiceProvider[_]) RequireBeaconClientSynced added in v0.2.3

func (sp *ServiceProvider[_]) RequireBeaconClientSynced(ctx context.Context) error

func (*ServiceProvider[_]) RequireEthClientSynced added in v0.2.3

func (sp *ServiceProvider[_]) RequireEthClientSynced(ctx context.Context) error

func (*ServiceProvider[_]) RequireNodeAddress

func (sp *ServiceProvider[_]) RequireNodeAddress() error

func (*ServiceProvider[_]) RequireWalletReady

func (sp *ServiceProvider[_]) RequireWalletReady() error

func (*ServiceProvider[_]) WaitBeaconClientSynced

func (sp *ServiceProvider[_]) WaitBeaconClientSynced(ctx context.Context, verbose bool) error

Wait for the Beacon client to sync; timeout of 0 indicates no timeout

func (*ServiceProvider[_]) WaitEthClientSynced

func (sp *ServiceProvider[_]) WaitEthClientSynced(ctx context.Context, verbose bool) error

Wait for the Executon client to sync; timeout of 0 indicates no timeout

type ValidatorManager

type ValidatorManager struct {
	// contains filtered or unexported fields
}

func NewValidatorManager

func NewValidatorManager(moduleDir string) *ValidatorManager

func (*ValidatorManager) StoreKey

func (m *ValidatorManager) StoreKey(key *types.BLSPrivateKey, derivationPath string) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL