Documentation
¶
Index ¶
- type Client
- type InstrumentedClient
- func (iec *InstrumentedClient) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
- func (iec *InstrumentedClient) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
- func (iec *InstrumentedClient) BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
- func (iec *InstrumentedClient) BlockNumber(ctx context.Context) (uint64, error)
- func (iec *InstrumentedClient) CallContract(ctx context.Context, call ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
- func (iec *InstrumentedClient) CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) ([]byte, error)
- func (iec *InstrumentedClient) ChainID(ctx context.Context) (*big.Int, error)
- func (iec *InstrumentedClient) CodeAt(ctx context.Context, contract common.Address, blockNumber *big.Int) ([]byte, error)
- func (iec *InstrumentedClient) EstimateGas(ctx context.Context, call ethereum.CallMsg) (uint64, error)
- func (iec *InstrumentedClient) FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, ...) (*ethereum.FeeHistory, error)
- func (iec *InstrumentedClient) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
- func (iec *InstrumentedClient) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
- func (iec *InstrumentedClient) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
- func (iec *InstrumentedClient) NetworkID(ctx context.Context) (*big.Int, error)
- func (iec *InstrumentedClient) NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
- func (iec *InstrumentedClient) PeerCount(ctx context.Context) (uint64, error)
- func (iec *InstrumentedClient) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)
- func (iec *InstrumentedClient) PendingCallContract(ctx context.Context, call ethereum.CallMsg) ([]byte, error)
- func (iec *InstrumentedClient) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
- func (iec *InstrumentedClient) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
- func (iec *InstrumentedClient) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)
- func (iec *InstrumentedClient) PendingTransactionCount(ctx context.Context) (uint, error)
- func (iec *InstrumentedClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (iec *InstrumentedClient) StorageAt(ctx context.Context, account common.Address, key common.Hash, ...) ([]byte, error)
- func (iec *InstrumentedClient) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (iec *InstrumentedClient) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
- func (iec *InstrumentedClient) SuggestGasPrice(ctx context.Context) (*big.Int, error)
- func (iec *InstrumentedClient) SuggestGasTipCap(ctx context.Context) (*big.Int, error)
- func (iec *InstrumentedClient) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
- func (iec *InstrumentedClient) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
- func (iec *InstrumentedClient) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)
- func (iec *InstrumentedClient) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)
- func (iec *InstrumentedClient) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
- func (iec *InstrumentedClient) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)
- func (iec *InstrumentedClient) WaitForTransactionReceipt(ctx context.Context, txHash common.Hash) *types.Receipt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
ChainID(ctx context.Context) (*big.Int, error)
BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error)
BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)
BlockByNumber(ctx context.Context, number *big.Int) (*types.Block, error)
BlockNumber(ctx context.Context) (uint64, error)
CallContract(ctx context.Context, msg ethereum.CallMsg, blockNumber *big.Int) ([]byte, error)
CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) ([]byte, error)
CodeAt(ctx context.Context, account common.Address, blockNumber *big.Int) ([]byte, error)
EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
FeeHistory(
ctx context.Context,
blockCount uint64,
lastBlock *big.Int,
rewardPercentiles []float64,
) (*ethereum.FeeHistory, error)
FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)
HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)
HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error)
NetworkID(ctx context.Context) (*big.Int, error)
NonceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (uint64, error)
PeerCount(ctx context.Context) (uint64, error)
PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)
PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)
PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)
PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)
PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)
PendingTransactionCount(ctx context.Context) (uint, error)
SendTransaction(ctx context.Context, tx *types.Transaction) error
StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)
SuggestGasPrice(ctx context.Context) (*big.Int, error)
SuggestGasTipCap(ctx context.Context) (*big.Int, error)
SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, isPending bool, err error)
TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)
TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)
TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)
TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)
}
type InstrumentedClient ¶
type InstrumentedClient struct {
// contains filtered or unexported fields
}
InstrumentedClient is a wrapper around the geth ethclient that instruments all the calls made to it. It counts each eth_ call made to it, and records the duration of each call, and exposes these as prometheus metrics
TODO: ideally this should be done at the rpcclient level, not the ethclient level, which would make our life much easier... but geth implemented the gethclient using an rpcClient struct instead of interface... see https://github.com/ethereum/go-ethereum/issues/28267
func NewInstrumentedClient ¶
func NewInstrumentedClient(rpcAddress string, rpcCallsCollector *rpccalls.Collector) (*InstrumentedClient, error)
func NewInstrumentedClientFromClient ¶
func NewInstrumentedClientFromClient( client *ethclient.Client, rpcCallsCollector *rpccalls.Collector, ) *InstrumentedClient
func (*InstrumentedClient) BlockByHash ¶
func (*InstrumentedClient) BlockByNumber ¶
func (*InstrumentedClient) BlockNumber ¶
func (iec *InstrumentedClient) BlockNumber(ctx context.Context) (uint64, error)
func (*InstrumentedClient) CallContract ¶
func (*InstrumentedClient) CallContractAtHash ¶
func (*InstrumentedClient) EstimateGas ¶
func (*InstrumentedClient) FeeHistory ¶
func (iec *InstrumentedClient) FeeHistory( ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64, ) (*ethereum.FeeHistory, error)
func (*InstrumentedClient) FilterLogs ¶
func (iec *InstrumentedClient) FilterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error)
func (*InstrumentedClient) HeaderByHash ¶
func (*InstrumentedClient) HeaderByNumber ¶
func (*InstrumentedClient) PeerCount ¶
func (iec *InstrumentedClient) PeerCount(ctx context.Context) (uint64, error)
func (*InstrumentedClient) PendingBalanceAt ¶
func (*InstrumentedClient) PendingCallContract ¶
func (*InstrumentedClient) PendingCodeAt ¶
func (*InstrumentedClient) PendingNonceAt ¶
func (*InstrumentedClient) PendingStorageAt ¶
func (*InstrumentedClient) PendingTransactionCount ¶
func (iec *InstrumentedClient) PendingTransactionCount(ctx context.Context) (uint, error)
func (*InstrumentedClient) SendTransaction ¶
func (iec *InstrumentedClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
func (*InstrumentedClient) SubscribeFilterLogs ¶
func (iec *InstrumentedClient) SubscribeFilterLogs( ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log, ) (ethereum.Subscription, error)
func (*InstrumentedClient) SubscribeNewHead ¶
func (iec *InstrumentedClient) SubscribeNewHead( ctx context.Context, ch chan<- *types.Header, ) (ethereum.Subscription, error)
func (*InstrumentedClient) SuggestGasPrice ¶
func (*InstrumentedClient) SuggestGasTipCap ¶
func (*InstrumentedClient) SyncProgress ¶
func (iec *InstrumentedClient) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)
func (*InstrumentedClient) TransactionByHash ¶
func (iec *InstrumentedClient) TransactionByHash( ctx context.Context, hash common.Hash, ) (tx *types.Transaction, isPending bool, err error)
We write the instrumentation of this function directly because instrumentFunction[] generic fct only takes a single return value
func (*InstrumentedClient) TransactionCount ¶
func (*InstrumentedClient) TransactionInBlock ¶
func (iec *InstrumentedClient) TransactionInBlock( ctx context.Context, blockHash common.Hash, index uint, ) (*types.Transaction, error)
func (*InstrumentedClient) TransactionReceipt ¶
func (*InstrumentedClient) TransactionSender ¶
func (*InstrumentedClient) WaitForTransactionReceipt ¶
func (iec *InstrumentedClient) WaitForTransactionReceipt(ctx context.Context, txHash common.Hash) *types.Receipt
TODO(samlaf): feels weird that we have to write this function ourselves
perhaps the gethClient interface should be the instrumented client, and then ethclient can take an instrumentedGethClient?