Documentation ¶
Overview ¶
Package blockchain handles connections to various blockchains
Index ¶
- Constants
- Variables
- func RPCErrorFromError(txError error) (string, error)
- type ArbitrumClient
- type ArbitrumMultinodeClient
- type BSCClient
- type BSCMultinodeClient
- type CeloClient
- type CeloMultinodeClient
- type ClientImplementation
- type ContractDeployer
- type ContractLoader
- type EVMClient
- func ConcurrentEVMClient(networkSettings EVMNetwork, env *environment.Environment, existing EVMClient, ...) (EVMClient, error)
- func ConnectEVMClient(networkSettings EVMNetwork, logger zerolog.Logger) (EVMClient, error)
- func NewEVMClient(networkSettings EVMNetwork, env *environment.Environment, ...) (EVMClient, error)
- func NewEVMClientFromNetwork(networkSettings EVMNetwork, logger zerolog.Logger) (EVMClient, error)
- type EVMNetwork
- type EthereumClient
- func (e *EthereumClient) AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)
- func (e *EthereumClient) AvgBlockTime(ctx context.Context) (time.Duration, error)
- func (e *EthereumClient) Backend() bind.ContractBackend
- func (e *EthereumClient) BalanceAt(ctx context.Context, address common.Address) (*big.Int, error)
- func (e *EthereumClient) CancelFinalityPolling()
- func (e *EthereumClient) Close() error
- func (e *EthereumClient) ConnectionIssue() chan time.Time
- func (e *EthereumClient) ConnectionRestored() chan time.Time
- func (e *EthereumClient) DeleteHeaderEventSubscription(key string)
- func (e *EthereumClient) DeployBackend() bind.DeployBackend
- func (e *EthereumClient) DeployContract(contractName string, deployer ContractDeployer) (*common.Address, *types.Transaction, interface{}, error)
- func (e *EthereumClient) EstimateCostForChainlinkOperations(amountOfOperations int) (*big.Float, error)
- func (e *EthereumClient) EstimateGas(callMsg ethereum.CallMsg) (GasEstimations, error)
- func (e *EthereumClient) EstimateGasPrice() (*big.Int, error)
- func (e *EthereumClient) EstimateTransactionGasCost() (*big.Int, error)
- func (e *EthereumClient) EstimatedFinalizationTime(ctx context.Context) (time.Duration, error)
- func (e *EthereumClient) FilterLogs(ctx context.Context, filterQuery ethereum.FilterQuery) ([]types.Log, error)
- func (e *EthereumClient) Fund(toAddress string, amount *big.Float, gasEstimations GasEstimations) error
- func (e *EthereumClient) GasStats() *GasStats
- func (e *EthereumClient) Get() interface{}
- func (e *EthereumClient) GetChainID() *big.Int
- func (e *EthereumClient) GetClients() []EVMClient
- func (e *EthereumClient) GetDefaultWallet() *EthereumWallet
- func (e *EthereumClient) GetEthClient() *ethclient.Client
- func (e *EthereumClient) GetHeaderSubscriptions() map[string]HeaderEventSubscription
- func (e *EthereumClient) GetLatestFinalizedBlockHeader(ctx context.Context) (*types.Header, error)
- func (e *EthereumClient) GetNetworkConfig() *EVMNetwork
- func (e *EthereumClient) GetNetworkName() string
- func (e *EthereumClient) GetNonce(ctx context.Context, addr common.Address) (uint64, error)
- func (e *EthereumClient) GetNonceSetting() NonceSettings
- func (e *EthereumClient) GetTxReceipt(txHash common.Hash) (*types.Receipt, error)
- func (e *EthereumClient) GetWallets() []*EthereumWallet
- func (e *EthereumClient) HeaderByHash(ctx context.Context, hash common.Hash) (*SafeEVMHeader, error)
- func (e *EthereumClient) HeaderByNumber(ctx context.Context, number *big.Int) (*SafeEVMHeader, error)
- func (e *EthereumClient) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error)
- func (e *EthereumClient) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error)
- func (e *EthereumClient) IsEventConfirmed(event *types.Log) (confirmed, removed bool, err error)
- func (e *EthereumClient) IsTxConfirmed(txHash common.Hash) (bool, error)
- func (e *EthereumClient) IsTxHeadFinalized(txHdr, header *SafeEVMHeader) (bool, *big.Int, time.Time, error)
- func (e *EthereumClient) LatestBlockNumber(ctx context.Context) (uint64, error)
- func (e *EthereumClient) LoadContract(contractName string, contractAddress common.Address, loader ContractLoader) (interface{}, error)
- func (e *EthereumClient) LoadWallets(cfg EVMNetwork) error
- func (e *EthereumClient) MarkTxAsSentOnL2(tx *types.Transaction) error
- func (e *EthereumClient) NetworkSimulated() bool
- func (e *EthereumClient) NewTx(fromPrivateKey *ecdsa.PrivateKey, nonce uint64, to common.Address, ...) (*types.Transaction, error)
- func (e *EthereumClient) ParallelTransactions(enabled bool)
- func (e *EthereumClient) PeekPendingNonce(addr common.Address) (uint64, error)
- func (e *EthereumClient) PollFinality() error
- func (e *EthereumClient) ProcessEvent(name string, event *types.Log, confirmedChan chan bool, errorChan chan error) error
- func (e *EthereumClient) ProcessTransaction(tx *types.Transaction) error
- func (e *EthereumClient) RawJsonRPCCall(ctx context.Context, result interface{}, method string, params ...interface{}) error
- func (e *EthereumClient) ReturnFunds(fromKey *ecdsa.PrivateKey) error
- func (e *EthereumClient) RevertReasonFromTx(txHash common.Hash, abiString string) (string, interface{}, error)
- func (e *EthereumClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (e *EthereumClient) SetDefaultWallet(num int) error
- func (e *EthereumClient) SetID(id int)
- func (e *EthereumClient) SetWallets(wallets []*EthereumWallet)
- func (e *EthereumClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
- func (e *EthereumClient) SubscribeNewHeaders(ctx context.Context, headerChan chan *SafeEVMHeader) (ethereum.Subscription, error)
- func (e *EthereumClient) SwitchNode(_ int) error
- func (e *EthereumClient) SyncNonce(c EVMClient)
- func (e *EthereumClient) TimeBetweenFinalizedBlocks(ctx context.Context, maxTimeToWait time.Duration) (time.Duration, error)
- func (e *EthereumClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error)
- func (e *EthereumClient) WaitForEvents() error
- func (e *EthereumClient) WaitForFinalizedTx(txHash common.Hash) (*big.Int, time.Time, error)
- type EthereumMultinodeClient
- func (e *EthereumMultinodeClient) AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)
- func (e *EthereumMultinodeClient) AvgBlockTime(ctx context.Context) (time.Duration, error)
- func (e *EthereumMultinodeClient) Backend() bind.ContractBackend
- func (e *EthereumMultinodeClient) BalanceAt(ctx context.Context, address common.Address) (*big.Int, error)
- func (e *EthereumMultinodeClient) CancelFinalityPolling()
- func (e *EthereumMultinodeClient) Close() error
- func (e *EthereumMultinodeClient) ConnectionIssue() chan time.Time
- func (e *EthereumMultinodeClient) ConnectionRestored() chan time.Time
- func (e *EthereumMultinodeClient) DeleteHeaderEventSubscription(key string)
- func (e *EthereumMultinodeClient) DeployBackend() bind.DeployBackend
- func (e *EthereumMultinodeClient) DeployContract(contractName string, deployer ContractDeployer) (*common.Address, *types.Transaction, interface{}, error)
- func (e *EthereumMultinodeClient) EstimateCostForChainlinkOperations(amountOfOperations int) (*big.Float, error)
- func (e *EthereumMultinodeClient) EstimateGas(callMsg ethereum.CallMsg) (GasEstimations, error)
- func (e *EthereumMultinodeClient) EstimateGasPrice() (*big.Int, error)
- func (e *EthereumMultinodeClient) EstimateTransactionGasCost() (*big.Int, error)
- func (e *EthereumMultinodeClient) EstimatedFinalizationTime(ctx context.Context) (time.Duration, error)
- func (e *EthereumMultinodeClient) FilterLogs(ctx context.Context, filterQuery ethereum.FilterQuery) ([]types.Log, error)
- func (e *EthereumMultinodeClient) Fund(toAddress string, nativeAmount *big.Float, gasEstimations GasEstimations) error
- func (e *EthereumMultinodeClient) GasStats() *GasStats
- func (e *EthereumMultinodeClient) Get() interface{}
- func (e *EthereumMultinodeClient) GetChainID() *big.Int
- func (e *EthereumMultinodeClient) GetClients() []EVMClient
- func (e *EthereumMultinodeClient) GetDefaultWallet() *EthereumWallet
- func (e *EthereumMultinodeClient) GetEthClient() *ethclient.Client
- func (e *EthereumMultinodeClient) GetHeaderSubscriptions() map[string]HeaderEventSubscription
- func (e *EthereumMultinodeClient) GetLatestFinalizedBlockHeader(ctx context.Context) (*types.Header, error)
- func (e *EthereumMultinodeClient) GetNetworkConfig() *EVMNetwork
- func (e *EthereumMultinodeClient) GetNetworkName() string
- func (e *EthereumMultinodeClient) GetNonceSetting() NonceSettings
- func (e *EthereumMultinodeClient) GetTxReceipt(txHash common.Hash) (*types.Receipt, error)
- func (e *EthereumMultinodeClient) GetWallets() []*EthereumWallet
- func (e *EthereumMultinodeClient) HeaderByHash(ctx context.Context, hash common.Hash) (*SafeEVMHeader, error)
- func (e *EthereumMultinodeClient) HeaderByNumber(ctx context.Context, number *big.Int) (*SafeEVMHeader, error)
- func (e *EthereumMultinodeClient) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error)
- func (e *EthereumMultinodeClient) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error)
- func (e *EthereumMultinodeClient) IsEventConfirmed(event *types.Log) (confirmed, removed bool, err error)
- func (e *EthereumMultinodeClient) IsTxConfirmed(txHash common.Hash) (bool, error)
- func (e *EthereumMultinodeClient) IsTxHeadFinalized(txHdr, header *SafeEVMHeader) (bool, *big.Int, time.Time, error)
- func (e *EthereumMultinodeClient) LatestBlockNumber(ctx context.Context) (uint64, error)
- func (e *EthereumMultinodeClient) LoadContract(contractName string, address common.Address, loader ContractLoader) (interface{}, error)
- func (e *EthereumMultinodeClient) LoadWallets(cfg EVMNetwork) error
- func (e *EthereumMultinodeClient) MarkTxAsSentOnL2(tx *types.Transaction) error
- func (e *EthereumMultinodeClient) NetworkSimulated() bool
- func (e *EthereumMultinodeClient) NewTx(fromPrivateKey *ecdsa.PrivateKey, nonce uint64, to common.Address, ...) (*types.Transaction, error)
- func (e *EthereumMultinodeClient) ParallelTransactions(enabled bool)
- func (e *EthereumMultinodeClient) PollFinality() error
- func (e *EthereumMultinodeClient) ProcessEvent(name string, event *types.Log, confirmedChan chan bool, errorChan chan error) error
- func (e *EthereumMultinodeClient) ProcessTransaction(tx *types.Transaction) error
- func (e *EthereumMultinodeClient) RawJsonRPCCall(ctx context.Context, result interface{}, method string, params ...interface{}) error
- func (e *EthereumMultinodeClient) ReturnFunds(fromKey *ecdsa.PrivateKey) error
- func (e *EthereumMultinodeClient) RevertReasonFromTx(txHash common.Hash, abiString string) (string, interface{}, error)
- func (e *EthereumMultinodeClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
- func (e *EthereumMultinodeClient) SetDefaultWallet(num int) error
- func (e *EthereumMultinodeClient) SetID(id int)
- func (e *EthereumMultinodeClient) SetWallets(wallets []*EthereumWallet)
- func (e *EthereumMultinodeClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, logs chan<- types.Log) (ethereum.Subscription, error)
- func (e *EthereumMultinodeClient) SubscribeNewHeaders(ctx context.Context, headerChan chan *SafeEVMHeader) (ethereum.Subscription, error)
- func (e *EthereumMultinodeClient) SwitchNode(clientID int) error
- func (e *EthereumMultinodeClient) SyncNonce(c EVMClient)
- func (e *EthereumMultinodeClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error)
- func (e *EthereumMultinodeClient) WaitForEvents() error
- func (e *EthereumMultinodeClient) WaitForFinalizedTx(txHash common.Hash) (*big.Int, time.Time, error)
- type EthereumWallet
- type EventConfirmer
- type FantomClient
- type FantomMultinodeClient
- type FinalizedHeader
- type GasEstimations
- type GasStats
- type GnosisClient
- type GnosisMultinodeClient
- type HeaderEventSubscription
- type InstantConfirmer
- type KlaytnClient
- type KlaytnMultinodeClient
- type KromaClient
- type KromaMultinodeClient
- type LineaClient
- type LineaMultinodeClient
- type MetisClient
- type MetisMultinodeClient
- type NodeHeader
- type NonceSettings
- type OptimismClient
- type OptimismMultinodeClient
- type PolygonClient
- type PolygonMultinodeClient
- type PolygonZkEvmClient
- type PolygonZkEvmMultinodeClient
- type QuorumClient
- type QuorumMultinodeClient
- type RSKClient
- type RSKMultinodeClient
- type SafeEVMHeader
- type ScrollClient
- type ScrollMultinodeClient
- type StrDuration
- type TXGasData
- type TransactionConfirmer
- type TransactionFinalizer
- type WeMixClient
- type WeMixMultinodeClient
Constants ¶
const ( // GWei one giga-wei used for gas calculations GWei = 1e9 // ETH one eth in wei ETH = 1e18 )
const (
FinalizedHeaderKey = "finalizedHeads"
)
const MaxTimeoutForFinality = 15 * time.Minute
Variables ¶
var ( // SimulatedEVMNetwork ensures that the test will use a default simulated geth instance SimulatedEVMNetwork = EVMNetwork{ Name: "Simulated Geth", ClientImplementation: EthereumClientImplementation, Simulated: true, ChainID: 1337, URLs: []string{"ws://geth:8546"}, HTTPURLs: []string{"http://geth:8544"}, PrivateKeys: []string{ "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", "59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d", "5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a", "8d351f5fc88484c65c15d44c7d3aa8779d12383373fb42d802e4576a50f765e5", "44fd8327d465031c71b20d7a5ba60bb01d33df8256fba406467bcb04e6f7262c", "809871f5c72d01a953f44f65d8b7bd0f3e39aee084d8cd0bc17ba3c386391814", "f29f5fda630ac9c0e39a8b05ec5b4b750a2e6ef098e612b177c6641bb5a675e1", "99b256477c424bb0102caab28c1792a210af906b901244fa67e2b704fac5a2bb", "bb74c3a9439ca83d09bcb4d3e5e65d8bc4977fc5b94be4db73772b22c3ff3d1a", "58845406a51d98fb2026887281b4e91b8843bbec5f16b89de06d5b9a62b231e8", }, ChainlinkTransactionLimit: 500000, Timeout: StrDuration{2 * time.Minute}, MinimumConfirmations: 1, GasEstimationBuffer: 10000, } )
Functions ¶
func RPCErrorFromError ¶ added in v1.13.0
Types ¶
type ArbitrumClient ¶ added in v1.5.3
type ArbitrumClient struct {
*EthereumClient
}
ArbitrumClient represents a single node, EVM compatible client for the Arbitrum network
type ArbitrumMultinodeClient ¶ added in v1.5.3
type ArbitrumMultinodeClient struct {
*EthereumMultinodeClient
}
ArbitrumMultinodeClient represents a multi-node, EVM compatible client for the Arbitrum network
type BSCClient ¶ added in v1.15.1
type BSCClient struct {
*EthereumClient
}
BSCClient represents a single node, EVM compatible client for the BSC network
type BSCMultinodeClient ¶ added in v1.15.1
type BSCMultinodeClient struct {
*EthereumMultinodeClient
}
BSCMultinodeClient represents a multi-node, EVM compatible client for the BSC network
type CeloClient ¶ added in v1.10.10
type CeloClient struct {
*EthereumClient
}
CeloClient represents a single node, EVM compatible client for the Celo network
func (*CeloClient) DeployContract ¶ added in v1.10.10
func (e *CeloClient) DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error)
DeployContract uses legacy txs for Celo to bypass Geth checking Celo headers which do not have a required sha3Uncles field
func (*CeloClient) TransactionOpts ¶ added in v1.10.10
func (e *CeloClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error)
type CeloMultinodeClient ¶ added in v1.10.10
type CeloMultinodeClient struct {
*EthereumMultinodeClient
}
CeloMultinodeClient represents a multi-node, EVM compatible client for the Celo network
type ClientImplementation ¶ added in v1.7.0
type ClientImplementation string
ClientImplementation represents the type of EVM client implementation for the framework to use
const ( // Ethereum uses the standard EVM implementation, and is considered default EthereumClientImplementation ClientImplementation = "Ethereum" MetisClientImplementation ClientImplementation = "Metis" KlaytnClientImplementation ClientImplementation = "Klaytn" OptimismClientImplementation ClientImplementation = "Optimism" ArbitrumClientImplementation ClientImplementation = "Arbitrum" PolygonClientImplementation ClientImplementation = "Polygon" RSKClientImplementation ClientImplementation = "RSK" CeloClientImplementation ClientImplementation = "Celo" QuorumClientImplementation ClientImplementation = "Quorum" ScrollClientImplementation ClientImplementation = "Scroll" BSCClientImplementation ClientImplementation = "BSC" LineaClientImplementation ClientImplementation = "Linea" PolygonZkEvmClientImplementation ClientImplementation = "PolygonZkEvm" FantomClientImplementation ClientImplementation = "Fantom" WeMixClientImplementation ClientImplementation = "WeMix" KromaClientImplementation ClientImplementation = "Kroma" GnosisClientImplementation ClientImplementation = "Gnosis" )
type ContractDeployer ¶
type ContractDeployer func(auth *bind.TransactOpts, backend bind.ContractBackend) ( common.Address, *types.Transaction, interface{}, error, )
ContractDeployer acts as a go-between function for general contract deployment
type ContractLoader ¶ added in v1.7.0
type ContractLoader func(address common.Address, backend bind.ContractBackend) ( interface{}, error, )
ContractLoader helps loading already deployed contracts
type EVMClient ¶
type EVMClient interface { // Getters Get() interface{} GetNetworkName() string NetworkSimulated() bool GetChainID() *big.Int GetClients() []EVMClient GetDefaultWallet() *EthereumWallet GetWallets() []*EthereumWallet GetNetworkConfig() *EVMNetwork GetNonceSetting() NonceSettings GetHeaderSubscriptions() map[string]HeaderEventSubscription // Setters SetID(id int) SetDefaultWallet(num int) error SetWallets([]*EthereumWallet) LoadWallets(ns EVMNetwork) error SwitchNode(node int) error SyncNonce(c EVMClient) // On-chain Operations BalanceAt(ctx context.Context, address common.Address) (*big.Int, error) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error) LatestBlockNumber(ctx context.Context) (uint64, error) GetLatestFinalizedBlockHeader(ctx context.Context) (*types.Header, error) AvgBlockTime(ctx context.Context) (time.Duration, error) EstimatedFinalizationTime(ctx context.Context) (time.Duration, error) SendTransaction(ctx context.Context, tx *types.Transaction) error Fund(toAddress string, amount *big.Float, gasEstimations GasEstimations) error ReturnFunds(fromKey *ecdsa.PrivateKey) error DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error) // TODO: Load and Deploy need to both agree to use an address pointer, there's unnecessary casting going on LoadContract(contractName string, address common.Address, loader ContractLoader) (interface{}, error) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error) NewTx( fromPrivateKey *ecdsa.PrivateKey, nonce uint64, to common.Address, value *big.Int, gasEstimations GasEstimations, ) (*types.Transaction, error) ProcessTransaction(tx *types.Transaction) error MarkTxAsSentOnL2(tx *types.Transaction) error ProcessEvent(name string, event *types.Log, confirmedChan chan bool, errorChan chan error) error IsEventConfirmed(event *types.Log) (confirmed, removed bool, err error) IsTxConfirmed(txHash common.Hash) (bool, error) IsTxHeadFinalized(txHdr, header *SafeEVMHeader) (bool, *big.Int, time.Time, error) WaitForFinalizedTx(txHash common.Hash) (*big.Int, time.Time, error) PollFinality() error CancelFinalityPolling() GetTxReceipt(txHash common.Hash) (*types.Receipt, error) RevertReasonFromTx(txHash common.Hash, abiString string) (string, interface{}, error) ParallelTransactions(enabled bool) Close() error Backend() bind.ContractBackend DeployBackend() bind.DeployBackend // Deal with wrapped headers SubscribeNewHeaders(ctx context.Context, headerChan chan *SafeEVMHeader) (ethereum.Subscription, error) HeaderByNumber(ctx context.Context, number *big.Int) (*SafeEVMHeader, error) HeaderByHash(ctx context.Context, hash common.Hash) (*SafeEVMHeader, error) // Gas Operations EstimateCostForChainlinkOperations(amountOfOperations int) (*big.Float, error) EstimateTransactionGasCost() (*big.Int, error) GasStats() *GasStats // EstimateGas provides all gas stats needed, best for estimating gas and prices for a specific transaction EstimateGas(callMsg ethereum.CallMsg) (GasEstimations, error) // EstimateGasPrice provides a plain gas price estimate, best for quick checks and contract deployments EstimateGasPrice() (*big.Int, error) // Connection Status // ConnectionIssue returns a channel that will receive a timestamp when the connection is lost ConnectionIssue() chan time.Time // ConnectionRestored returns a channel that will receive a timestamp when the connection is restored ConnectionRestored() chan time.Time // Event Subscriptions AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription) DeleteHeaderEventSubscription(key string) WaitForEvents() error SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error) // Polling Events FilterLogs(ctx context.Context, filterQuery ethereum.FilterQuery) ([]types.Log, error) RawJsonRPCCall(ctx context.Context, result interface{}, method string, params ...interface{}) error GetEthClient() *ethclient.Client }
EVMClient is the interface that wraps a given client implementation for a blockchain, to allow for switching of network types within the test suite EVMClient can be connected to a single or multiple nodes,
func ConcurrentEVMClient ¶ added in v1.9.1
func ConcurrentEVMClient(networkSettings EVMNetwork, env *environment.Environment, existing EVMClient, logger zerolog.Logger) (EVMClient, error)
ConcurrentEVMClient returns a multi-node EVM client connected to a specified network It is used for concurrent interactions from different threads with the same network and from same owner account. This ensures that correct nonce value is fetched when an instance of EVMClient is initiated using this method. This is mainly useful for simulated networks as we don't use global nonce manager for them.
func ConnectEVMClient ¶ added in v1.15.0
func ConnectEVMClient(networkSettings EVMNetwork, logger zerolog.Logger) (EVMClient, error)
ConnectEVMClient returns a multi-node EVM client connected to a specified network, using only URLs. Should mostly be used for inside K8s, non-simulated tests.
func NewEVMClient ¶ added in v1.5.0
func NewEVMClient(networkSettings EVMNetwork, env *environment.Environment, logger zerolog.Logger) (EVMClient, error)
NewEVMClient returns a multi-node EVM client connected to the specified network Note: This should mostly be deprecated in favor of ConnectEVMClient. This is really only used when needing to connect to simulated networks
func NewEVMClientFromNetwork ¶ added in v1.15.0
func NewEVMClientFromNetwork(networkSettings EVMNetwork, logger zerolog.Logger) (EVMClient, error)
NewEVMClientFromNetwork returns a multi-node EVM client connected to the specified network
type EVMNetwork ¶ added in v1.4.0
type EVMNetwork struct { // Human-readable name of the network: Name string `toml:"evm_name" json:"evm_name"` // Chain ID for the blockchain ChainID int64 `toml:"evm_chain_id" json:"evm_chain_id"` // List of websocket URLs you want to connect to URLs []string `toml:"evm_urls" json:"evm_urls"` // List of websocket URLs you want to connect to HTTPURLs []string `toml:"evm_http_urls" json:"evm_http_urls"` // True if the network is simulated like a geth instance in dev mode. False if the network is a real test or mainnet Simulated bool `toml:"evm_simulated" json:"evm_simulated"` // Type of chain client node. Values: "none" | "geth" | "besu" SimulationType string `toml:"evm_simulation_type" json:"evm_simulation_type"` // List of private keys to fund the tests PrivateKeys []string `toml:"evm_keys" json:"evm_keys"` // Default gas limit to assume that Chainlink nodes will use. Used to try to estimate the funds that Chainlink // nodes require to run the tests. ChainlinkTransactionLimit uint64 `toml:"evm_chainlink_transaction_limit" json:"evm_chainlink_transaction_limit"` // How long to wait for on-chain operations before timing out an on-chain operation Timeout StrDuration `toml:"evm_transaction_timeout" json:"evm_transaction_timeout"` // How many block confirmations to wait to confirm on-chain events MinimumConfirmations int `toml:"evm_minimum_confirmations" json:"evm_minimum_confirmations"` // How much WEI to add to gas estimations for sending transactions GasEstimationBuffer uint64 `toml:"evm_gas_estimation_buffer" json:"evm_gas_estimation_buffer"` // ClientImplementation is the blockchain client to use when interacting with the test chain ClientImplementation ClientImplementation `toml:"client_implementation" json:"client_implementation"` // SupportsEIP1559 indicates if the client should try to use EIP1559 style gas and transactions SupportsEIP1559 bool `toml:"evm_supports_eip1559" json:"evm_supports_eip1559"` // Default gaslimit to use when sending transactions. If set this will override the transactionOptions gaslimit in case the // transactionOptions gaslimit is lesser than the defaultGasLimit. DefaultGasLimit uint64 `toml:"evm_default_gas_limit" json:"evm_default_gas_limit"` // Few chains use finality tags to mark blocks as finalized. This is used to determine if the chain uses finality tags. FinalityTag bool `toml:"evm_finality_tag" json:"evm_finality_tag"` // If the chain does not use finality tags, this is used to determine how many blocks to wait for before considering a block finalized. FinalityDepth uint64 `toml:"evm_finality_depth" json:"evm_finality_depth"` // TimeToReachFinality is the time it takes for a block to be considered final. This is used to determine how long to wait for a block to be considered final. TimeToReachFinality StrDuration `toml:"evm_time_to_reach_finality" json:"evm_time_to_reach_finality"` // Only used internally, do not set URL string `ignored:"true"` }
EVMNetwork configures all the data the test needs to connect and operate on an EVM compatible network
func LoadNetworkFromEnvironment ¶ added in v1.4.0
func LoadNetworkFromEnvironment() EVMNetwork
LoadNetworkFromEnvironment loads an EVM network from default environment variables. Helpful in soak tests
func (*EVMNetwork) MustChainlinkTOML ¶ added in v1.8.2
func (e *EVMNetwork) MustChainlinkTOML(networkDetails string) string
MustChainlinkTOML marshals EVM network values into a TOML setting snippet. Will fail if error is encountered Can provide more detailed config for the network if non-default behaviors are desired.
func (*EVMNetwork) ToMap ¶ added in v1.4.0
func (e *EVMNetwork) ToMap() map[string]interface{}
ToMap marshalls the network's values to a generic map, useful for setting env vars on instances like the remote runner Map Structure "envconfig_key": stringValue
type EthereumClient ¶
type EthereumClient struct { ID int Client *ethclient.Client NetworkConfig EVMNetwork Wallets []*EthereumWallet DefaultWallet *EthereumWallet NonceSettings *NonceSettings FinalizedHeader atomic.Pointer[FinalizedHeader] // contains filtered or unexported fields }
EthereumClient wraps the client and the BlockChain network to interact with an EVM based Blockchain
func (*EthereumClient) AddHeaderEventSubscription ¶
func (e *EthereumClient) AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)
AddHeaderEventSubscription adds a new header subscriber within the client to receive new headers
func (*EthereumClient) AvgBlockTime ¶ added in v1.11.7
AvgBlockTime calculates the average block time over the last 100 blocks for non-simulated networks and the last 10 blocks for simulated networks.
func (*EthereumClient) Backend ¶ added in v1.9.1
func (e *EthereumClient) Backend() bind.ContractBackend
func (*EthereumClient) BalanceAt ¶ added in v1.2.3
BalanceAt returns the ETH balance of the specified address
func (*EthereumClient) CancelFinalityPolling ¶ added in v1.15.2
func (e *EthereumClient) CancelFinalityPolling()
CancelFinalityPolling stops polling for the latest finalized header
func (*EthereumClient) Close ¶
func (e *EthereumClient) Close() error
Close tears down the current open Ethereum client
func (*EthereumClient) ConnectionIssue ¶ added in v1.13.1
func (e *EthereumClient) ConnectionIssue() chan time.Time
ConnectionIssue returns a channel that will receive a timestamp when the connection is lost
func (*EthereumClient) ConnectionRestored ¶ added in v1.13.1
func (e *EthereumClient) ConnectionRestored() chan time.Time
ConnectionRestored returns a channel that will receive a timestamp when the connection is restored
func (*EthereumClient) DeleteHeaderEventSubscription ¶
func (e *EthereumClient) DeleteHeaderEventSubscription(key string)
DeleteHeaderEventSubscription removes a header subscriber from the map
func (*EthereumClient) DeployBackend ¶ added in v1.17.7
func (e *EthereumClient) DeployBackend() bind.DeployBackend
func (*EthereumClient) DeployContract ¶
func (e *EthereumClient) DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error)
DeployContract acts as a general contract deployment tool to an ethereum chain
func (*EthereumClient) EstimateCostForChainlinkOperations ¶
func (e *EthereumClient) EstimateCostForChainlinkOperations(amountOfOperations int) (*big.Float, error)
EstimateCostForChainlinkOperations calculates required amount of ETH for amountOfOperations Chainlink operations based on the network's suggested gas price and the chainlink gas limit. This is fairly imperfect and should be used as only a rough, upper-end estimate instead of an exact calculation. See https://ethereum.org/en/developers/docs/gas/#post-london for info on how gas calculation works
func (*EthereumClient) EstimateGas ¶ added in v1.11.7
func (e *EthereumClient) EstimateGas(callMsg ethereum.CallMsg) (GasEstimations, error)
EstimateGas estimates all gas values based on call data
func (*EthereumClient) EstimateGasPrice ¶ added in v1.17.8
func (e *EthereumClient) EstimateGasPrice() (*big.Int, error)
func (*EthereumClient) EstimateTransactionGasCost ¶
func (e *EthereumClient) EstimateTransactionGasCost() (*big.Int, error)
EstimateTransactionGasCost estimates the current total gas cost for a simple transaction
func (*EthereumClient) EstimatedFinalizationTime ¶ added in v1.11.9
EstimatedFinalizationTime returns the estimated time it takes for a block to be finalized for networks with finality tag enabled, it returns the time between the current and next finalized block for networks with finality depth enabled, it returns the time to mine blocks equal to finality depth
func (*EthereumClient) FilterLogs ¶ added in v1.11.9
func (e *EthereumClient) FilterLogs(ctx context.Context, filterQuery ethereum.FilterQuery) ([]types.Log, error)
FilterLogs executes a filter query
func (*EthereumClient) Fund ¶
func (e *EthereumClient) Fund( toAddress string, amount *big.Float, gasEstimations GasEstimations, ) error
Fund sends some ETH to an address using the default wallet
func (*EthereumClient) GasStats ¶
func (e *EthereumClient) GasStats() *GasStats
GasStats retrieves all information on gas spent by this client
func (*EthereumClient) Get ¶
func (e *EthereumClient) Get() interface{}
Get returns the underlying client type to be used generically across the framework for switching network types
func (*EthereumClient) GetChainID ¶
func (e *EthereumClient) GetChainID() *big.Int
GetChainID retrieves the ChainID of the network that the client interacts with
func (*EthereumClient) GetClients ¶
func (e *EthereumClient) GetClients() []EVMClient
GetClients not used, only applicable to EthereumMultinodeClient
func (*EthereumClient) GetDefaultWallet ¶
func (e *EthereumClient) GetDefaultWallet() *EthereumWallet
DefaultWallet returns the default wallet for the network
func (*EthereumClient) GetEthClient ¶ added in v1.27.0
func (e *EthereumClient) GetEthClient() *ethclient.Client
func (*EthereumClient) GetHeaderSubscriptions ¶
func (e *EthereumClient) GetHeaderSubscriptions() map[string]HeaderEventSubscription
GetHeaderSubscriptions returns a duplicate map of the queued transactions
func (*EthereumClient) GetLatestFinalizedBlockHeader ¶ added in v1.11.7
GetLatestFinalizedBlockHeader returns the latest finalized block header if finality tag is enabled, it returns the latest finalized block header otherwise it returns the block header for the block obtained by latest block number - finality depth
func (*EthereumClient) GetNetworkConfig ¶
func (e *EthereumClient) GetNetworkConfig() *EVMNetwork
DefaultWallet returns the default wallet for the network
func (*EthereumClient) GetNetworkName ¶
func (e *EthereumClient) GetNetworkName() string
GetNetworkName retrieves the ID of the network that the client interacts with
func (*EthereumClient) GetNonce ¶
GetNonce keep tracking of nonces per address, add last nonce for addr if the map is empty
func (*EthereumClient) GetNonceSetting ¶ added in v1.9.1
func (e *EthereumClient) GetNonceSetting() NonceSettings
func (*EthereumClient) GetTxReceipt ¶ added in v1.2.4
GetTxReceipt returns the receipt of the transaction if available, error otherwise
func (*EthereumClient) GetWallets ¶
func (e *EthereumClient) GetWallets() []*EthereumWallet
DefaultWallet returns the default wallet for the network
func (*EthereumClient) HeaderByHash ¶ added in v1.10.10
func (e *EthereumClient) HeaderByHash(ctx context.Context, hash common.Hash) (*SafeEVMHeader, error)
HeaderByHash retrieves a Safe EVM header by hash
func (*EthereumClient) HeaderByNumber ¶ added in v1.10.10
func (e *EthereumClient) HeaderByNumber( ctx context.Context, number *big.Int, ) (*SafeEVMHeader, error)
HeaderByNumber retrieves a Safe EVM header by number, nil for latest
func (*EthereumClient) HeaderHashByNumber ¶
HeaderHashByNumber gets header hash by block number
func (*EthereumClient) HeaderTimestampByNumber ¶
HeaderTimestampByNumber gets header timestamp by number
func (*EthereumClient) IsEventConfirmed ¶ added in v1.5.6
func (e *EthereumClient) IsEventConfirmed(event *types.Log) (confirmed, removed bool, err error)
IsEventConfirmed returns if eth client can confirm that the event happened
func (*EthereumClient) IsTxConfirmed ¶
func (e *EthereumClient) IsTxConfirmed(txHash common.Hash) (bool, error)
IsTxConfirmed checks if the transaction is confirmed on chain or not
func (*EthereumClient) IsTxHeadFinalized ¶ added in v1.15.2
func (e *EthereumClient) IsTxHeadFinalized(txHdr, header *SafeEVMHeader) (bool, *big.Int, time.Time, error)
IsTxHeadFinalized checks if the transaction is finalized on chain in case of network with finality tag if the tx is not finalized it returns false, the latest finalized header number and the time at which it was finalized if the tx is finalized it returns true, the finalized header number by which the tx was considered finalized and the time at which it was finalized
func (*EthereumClient) LatestBlockNumber ¶
func (e *EthereumClient) LatestBlockNumber(ctx context.Context) (uint64, error)
BlockNumber gets latest block number
func (*EthereumClient) LoadContract ¶ added in v1.7.0
func (e *EthereumClient) LoadContract(contractName string, contractAddress common.Address, loader ContractLoader) (interface{}, error)
LoadContract load already deployed contract instance
func (*EthereumClient) LoadWallets ¶
func (e *EthereumClient) LoadWallets(cfg EVMNetwork) error
LoadWallets loads wallets from config
func (*EthereumClient) MarkTxAsSentOnL2 ¶ added in v1.20.2
func (e *EthereumClient) MarkTxAsSentOnL2(tx *types.Transaction) error
MarkTxAsSent On an L2 chain, indicate the tx has been sent
func (*EthereumClient) NetworkSimulated ¶ added in v1.4.0
func (e *EthereumClient) NetworkSimulated() bool
NetworkSimulated returns true if the network is a simulated geth instance, false otherwise
func (*EthereumClient) NewTx ¶ added in v1.11.7
func (e *EthereumClient) NewTx( fromPrivateKey *ecdsa.PrivateKey, nonce uint64, to common.Address, value *big.Int, gasEstimations GasEstimations, ) (*types.Transaction, error)
func (*EthereumClient) ParallelTransactions ¶
func (e *EthereumClient) ParallelTransactions(enabled bool)
ParallelTransactions when enabled, sends the transaction without waiting for transaction confirmations. The hashes are then stored within the client and confirmations can be waited on by calling WaitForEvents.
func (*EthereumClient) PeekPendingNonce ¶ added in v1.9.3
func (e *EthereumClient) PeekPendingNonce(addr common.Address) (uint64, error)
PeekPendingNonce returns the current pending nonce for the address. Does not change any nonce settings state
func (*EthereumClient) PollFinality ¶ added in v1.15.2
func (e *EthereumClient) PollFinality() error
PollFinalizedHeader continuously polls the latest finalized header and stores it in the client
func (*EthereumClient) ProcessEvent ¶ added in v1.5.6
func (e *EthereumClient) ProcessEvent(name string, event *types.Log, confirmedChan chan bool, errorChan chan error) error
ProcessEvent will queue or wait on an event depending on whether parallel transactions are enabled
func (*EthereumClient) ProcessTransaction ¶
func (e *EthereumClient) ProcessTransaction(tx *types.Transaction) error
ProcessTransaction will queue or wait on a transaction depending on whether parallel transactions are enabled
func (*EthereumClient) RawJsonRPCCall ¶ added in v1.23.3
func (e *EthereumClient) RawJsonRPCCall(ctx context.Context, result interface{}, method string, params ...interface{}) error
func (*EthereumClient) ReturnFunds ¶ added in v1.7.0
func (e *EthereumClient) ReturnFunds(fromKey *ecdsa.PrivateKey) error
ReturnFunds achieves a lazy method of fund return as too many guarantees get too complex
func (*EthereumClient) RevertReasonFromTx ¶ added in v1.15.0
func (e *EthereumClient) RevertReasonFromTx(txHash common.Hash, abiString string) (string, interface{}, error)
RevertReasonFromTx returns the revert reason for the transaction error by parsing through abi defined error list
func (*EthereumClient) SendTransaction ¶ added in v1.9.3
func (e *EthereumClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
func (*EthereumClient) SetDefaultWallet ¶
func (e *EthereumClient) SetDefaultWallet(num int) error
SetDefaultWallet sets default wallet
func (*EthereumClient) SetID ¶
func (e *EthereumClient) SetID(id int)
SetID sets client id, only used for multi-node networks
func (*EthereumClient) SetWallets ¶
func (e *EthereumClient) SetWallets(wallets []*EthereumWallet)
SetWallets sets all wallets to be used by the client
func (*EthereumClient) SubscribeFilterLogs ¶ added in v1.4.2
func (e *EthereumClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs subscribes to the results of a streaming filter query.
func (*EthereumClient) SubscribeNewHeaders ¶ added in v1.10.10
func (e *EthereumClient) SubscribeNewHeaders( ctx context.Context, headerChan chan *SafeEVMHeader, ) (ethereum.Subscription, error)
func (*EthereumClient) SwitchNode ¶
func (e *EthereumClient) SwitchNode(_ int) error
SwitchNode not used, only applicable to EthereumMultinodeClient
func (*EthereumClient) SyncNonce ¶ added in v1.9.1
func (e *EthereumClient) SyncNonce(c EVMClient)
SyncNonce sets the NonceMu and Nonces value based on existing EVMClient it ensures the instance of EthereumClient is synced with passed EVMClient's nonce updates.
func (*EthereumClient) TimeBetweenFinalizedBlocks ¶ added in v1.11.9
func (e *EthereumClient) TimeBetweenFinalizedBlocks(ctx context.Context, maxTimeToWait time.Duration) (time.Duration, error)
TimeBetweenFinalizedBlocks is used to calculate the time between finalized blocks for chains with finality tag enabled
func (*EthereumClient) TransactionOpts ¶
func (e *EthereumClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error)
TransactionOpts returns the base Tx options for 'transactions' that interact with a smart contract. Since most contract interactions in this framework are designed to happen through abigen calls, it's intentionally quite bare.
func (*EthereumClient) WaitForEvents ¶
func (e *EthereumClient) WaitForEvents() error
WaitForEvents is a blocking function that waits for all event subscriptions that have been queued within the client.
func (*EthereumClient) WaitForFinalizedTx ¶ added in v1.15.2
WaitForFinalizedTx waits for a transaction to be finalized If the network is simulated, it will return immediately otherwise it waits for the transaction to be finalized and returns the block number and time of the finalization
type EthereumMultinodeClient ¶
EthereumMultinodeClient wraps the client and the BlockChain network to interact with an EVM based Blockchain with multiple nodes
func (*EthereumMultinodeClient) AddHeaderEventSubscription ¶
func (e *EthereumMultinodeClient) AddHeaderEventSubscription(key string, subscriber HeaderEventSubscription)
AddHeaderEventSubscription adds a new header subscriber within the client to receive new headers
func (*EthereumMultinodeClient) AvgBlockTime ¶ added in v1.11.7
func (*EthereumMultinodeClient) Backend ¶ added in v1.9.1
func (e *EthereumMultinodeClient) Backend() bind.ContractBackend
func (*EthereumMultinodeClient) BalanceAt ¶ added in v1.2.3
func (e *EthereumMultinodeClient) BalanceAt(ctx context.Context, address common.Address) (*big.Int, error)
BalanceAt returns the ETH balance of the specified address
func (*EthereumMultinodeClient) CancelFinalityPolling ¶ added in v1.15.2
func (e *EthereumMultinodeClient) CancelFinalityPolling()
StopPollingForFinality stops polling for finality
func (*EthereumMultinodeClient) Close ¶
func (e *EthereumMultinodeClient) Close() error
Close tears down the all the clients
func (*EthereumMultinodeClient) ConnectionIssue ¶ added in v1.13.1
func (e *EthereumMultinodeClient) ConnectionIssue() chan time.Time
func (*EthereumMultinodeClient) ConnectionRestored ¶ added in v1.13.1
func (e *EthereumMultinodeClient) ConnectionRestored() chan time.Time
func (*EthereumMultinodeClient) DeleteHeaderEventSubscription ¶
func (e *EthereumMultinodeClient) DeleteHeaderEventSubscription(key string)
DeleteHeaderEventSubscription removes a header subscriber from the map
func (*EthereumMultinodeClient) DeployBackend ¶ added in v1.17.7
func (e *EthereumMultinodeClient) DeployBackend() bind.DeployBackend
func (*EthereumMultinodeClient) DeployContract ¶
func (e *EthereumMultinodeClient) DeployContract( contractName string, deployer ContractDeployer, ) (*common.Address, *types.Transaction, interface{}, error)
DeployContract deploys a specified contract
func (*EthereumMultinodeClient) EstimateCostForChainlinkOperations ¶
func (e *EthereumMultinodeClient) EstimateCostForChainlinkOperations(amountOfOperations int) (*big.Float, error)
EstimateCostForChainlinkOperations calculates TXs cost as a dirty estimation based on transactionLimit for that network
func (*EthereumMultinodeClient) EstimateGas ¶ added in v1.11.7
func (e *EthereumMultinodeClient) EstimateGas(callMsg ethereum.CallMsg) (GasEstimations, error)
func (*EthereumMultinodeClient) EstimateGasPrice ¶ added in v1.17.8
func (e *EthereumMultinodeClient) EstimateGasPrice() (*big.Int, error)
func (*EthereumMultinodeClient) EstimateTransactionGasCost ¶
func (e *EthereumMultinodeClient) EstimateTransactionGasCost() (*big.Int, error)
func (*EthereumMultinodeClient) EstimatedFinalizationTime ¶ added in v1.11.9
func (*EthereumMultinodeClient) FilterLogs ¶ added in v1.11.9
func (e *EthereumMultinodeClient) FilterLogs(ctx context.Context, filterQuery ethereum.FilterQuery) ([]types.Log, error)
FilterLogs executes a filter query
func (*EthereumMultinodeClient) Fund ¶
func (e *EthereumMultinodeClient) Fund(toAddress string, nativeAmount *big.Float, gasEstimations GasEstimations) error
Fund funds a specified address with ETH from the given wallet
func (*EthereumMultinodeClient) GasStats ¶
func (e *EthereumMultinodeClient) GasStats() *GasStats
GasStats gets gas stats instance
func (*EthereumMultinodeClient) Get ¶
func (e *EthereumMultinodeClient) Get() interface{}
Get gets default client as an interface{}
func (*EthereumMultinodeClient) GetChainID ¶
func (e *EthereumMultinodeClient) GetChainID() *big.Int
GetChainID retrieves the ChainID of the network that the client interacts with
func (*EthereumMultinodeClient) GetClients ¶
func (e *EthereumMultinodeClient) GetClients() []EVMClient
GetClients gets clients for all nodes connected
func (*EthereumMultinodeClient) GetDefaultWallet ¶
func (e *EthereumMultinodeClient) GetDefaultWallet() *EthereumWallet
GetDefaultWallet returns the default wallet for the network
func (*EthereumMultinodeClient) GetEthClient ¶ added in v1.27.0
func (e *EthereumMultinodeClient) GetEthClient() *ethclient.Client
func (*EthereumMultinodeClient) GetHeaderSubscriptions ¶ added in v1.17.7
func (e *EthereumMultinodeClient) GetHeaderSubscriptions() map[string]HeaderEventSubscription
func (*EthereumMultinodeClient) GetLatestFinalizedBlockHeader ¶ added in v1.11.7
func (*EthereumMultinodeClient) GetNetworkConfig ¶
func (e *EthereumMultinodeClient) GetNetworkConfig() *EVMNetwork
GetNetworkConfig return the network config
func (*EthereumMultinodeClient) GetNetworkName ¶
func (e *EthereumMultinodeClient) GetNetworkName() string
GetNetworkName gets the ID of the chain that the clients are connected to
func (*EthereumMultinodeClient) GetNonceSetting ¶ added in v1.9.1
func (e *EthereumMultinodeClient) GetNonceSetting() NonceSettings
func (*EthereumMultinodeClient) GetTxReceipt ¶ added in v1.2.4
GetTxReceipt returns the receipt of the transaction if available, error otherwise
func (*EthereumMultinodeClient) GetWallets ¶
func (e *EthereumMultinodeClient) GetWallets() []*EthereumWallet
GetWallets returns the default wallet for the network
func (*EthereumMultinodeClient) HeaderByHash ¶ added in v1.10.10
func (e *EthereumMultinodeClient) HeaderByHash(ctx context.Context, hash common.Hash) (*SafeEVMHeader, error)
HeaderByHash retrieves a Safe EVM header by hash
func (*EthereumMultinodeClient) HeaderByNumber ¶ added in v1.10.10
func (e *EthereumMultinodeClient) HeaderByNumber( ctx context.Context, number *big.Int, ) (*SafeEVMHeader, error)
HeaderByNumber retrieves a Safe EVM header by number, nil for latest
func (*EthereumMultinodeClient) HeaderHashByNumber ¶
func (e *EthereumMultinodeClient) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error)
HeaderHashByNumber gets header hash by block number
func (*EthereumMultinodeClient) HeaderTimestampByNumber ¶
func (e *EthereumMultinodeClient) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error)
HeaderTimestampByNumber gets header timestamp by number
func (*EthereumMultinodeClient) IsEventConfirmed ¶ added in v1.5.6
func (e *EthereumMultinodeClient) IsEventConfirmed(event *types.Log) (confirmed, removed bool, err error)
IsEventConfirmed returns if the default client can confirm the event has happened
func (*EthereumMultinodeClient) IsTxConfirmed ¶
func (e *EthereumMultinodeClient) IsTxConfirmed(txHash common.Hash) (bool, error)
IsTxConfirmed returns the default client's transaction confirmations
func (*EthereumMultinodeClient) IsTxHeadFinalized ¶ added in v1.15.2
func (e *EthereumMultinodeClient) IsTxHeadFinalized(txHdr, header *SafeEVMHeader) (bool, *big.Int, time.Time, error)
IsTxFinalized returns if the default client can confirm the transaction has been finalized
func (*EthereumMultinodeClient) LatestBlockNumber ¶
func (e *EthereumMultinodeClient) LatestBlockNumber(ctx context.Context) (uint64, error)
LatestBlockNumber gets the latest block number from the default client
func (*EthereumMultinodeClient) LoadContract ¶ added in v1.7.0
func (e *EthereumMultinodeClient) LoadContract(contractName string, address common.Address, loader ContractLoader) (interface{}, error)
LoadContract load already deployed contract instance
func (*EthereumMultinodeClient) LoadWallets ¶
func (e *EthereumMultinodeClient) LoadWallets(cfg EVMNetwork) error
LoadWallets loads wallets using private keys provided in the config
func (*EthereumMultinodeClient) MarkTxAsSentOnL2 ¶ added in v1.20.2
func (e *EthereumMultinodeClient) MarkTxAsSentOnL2(tx *types.Transaction) error
MarkTxAsSentOnL2 marks the transaction as sent on L2
func (*EthereumMultinodeClient) NetworkSimulated ¶ added in v1.4.0
func (e *EthereumMultinodeClient) NetworkSimulated() bool
GetNetworkType retrieves the type of network this is running on
func (*EthereumMultinodeClient) NewTx ¶ added in v1.11.7
func (e *EthereumMultinodeClient) NewTx( fromPrivateKey *ecdsa.PrivateKey, nonce uint64, to common.Address, value *big.Int, gasEstimations GasEstimations, ) (*types.Transaction, error)
func (*EthereumMultinodeClient) ParallelTransactions ¶
func (e *EthereumMultinodeClient) ParallelTransactions(enabled bool)
ParallelTransactions when enabled, sends the transaction without waiting for transaction confirmations. The hashes are then stored within the client and confirmations can be waited on by calling WaitForEvents. When disabled, the minimum confirmations are waited on when the transaction is sent, so parallelisation is disabled.
func (*EthereumMultinodeClient) PollFinality ¶ added in v1.15.2
func (e *EthereumMultinodeClient) PollFinality() error
PollFinality polls for finality
func (*EthereumMultinodeClient) ProcessEvent ¶ added in v1.5.6
func (e *EthereumMultinodeClient) ProcessEvent(name string, event *types.Log, confirmedChan chan bool, errorChan chan error) error
ProcessEvent returns the result of the default client's processed event
func (*EthereumMultinodeClient) ProcessTransaction ¶
func (e *EthereumMultinodeClient) ProcessTransaction(tx *types.Transaction) error
ProcessTransaction returns the result of the default client's processed transaction
func (*EthereumMultinodeClient) RawJsonRPCCall ¶ added in v1.23.3
func (e *EthereumMultinodeClient) RawJsonRPCCall(ctx context.Context, result interface{}, method string, params ...interface{}) error
func (*EthereumMultinodeClient) ReturnFunds ¶ added in v1.7.0
func (e *EthereumMultinodeClient) ReturnFunds(fromKey *ecdsa.PrivateKey) error
func (*EthereumMultinodeClient) RevertReasonFromTx ¶ added in v1.15.0
func (*EthereumMultinodeClient) SendTransaction ¶ added in v1.9.3
func (e *EthereumMultinodeClient) SendTransaction(ctx context.Context, tx *types.Transaction) error
SendTransaction wraps ethereum's SendTransaction to make it safe with instant transaction types
func (*EthereumMultinodeClient) SetDefaultWallet ¶
func (e *EthereumMultinodeClient) SetDefaultWallet(num int) error
SetDefaultWallet sets default wallet
func (*EthereumMultinodeClient) SetID ¶
func (e *EthereumMultinodeClient) SetID(id int)
SetID sets client ID in a multi-node environment
func (*EthereumMultinodeClient) SetWallets ¶
func (e *EthereumMultinodeClient) SetWallets(wallets []*EthereumWallet)
SetWallets sets the default client's wallets
func (*EthereumMultinodeClient) SubscribeFilterLogs ¶ added in v1.4.2
func (e *EthereumMultinodeClient) SubscribeFilterLogs(ctx context.Context, q ethereum.FilterQuery, logs chan<- types.Log) (ethereum.Subscription, error)
SubscribeFilterLogs subscribes to the results of a streaming filter query.
func (*EthereumMultinodeClient) SubscribeNewHeaders ¶ added in v1.10.10
func (e *EthereumMultinodeClient) SubscribeNewHeaders( ctx context.Context, headerChan chan *SafeEVMHeader, ) (ethereum.Subscription, error)
func (*EthereumMultinodeClient) SwitchNode ¶
func (e *EthereumMultinodeClient) SwitchNode(clientID int) error
SwitchNode sets default client to perform calls to the network
func (*EthereumMultinodeClient) SyncNonce ¶ added in v1.9.1
func (e *EthereumMultinodeClient) SyncNonce(c EVMClient)
func (*EthereumMultinodeClient) TransactionOpts ¶
func (e *EthereumMultinodeClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error)
TransactionOpts returns the base Tx options for 'transactions' that interact with a smart contract. Since most contract interactions in this framework are designed to happen through abigen calls, it's intentionally quite bare.
func (*EthereumMultinodeClient) WaitForEvents ¶
func (e *EthereumMultinodeClient) WaitForEvents() error
WaitForEvents is a blocking function that waits for all event subscriptions for all clients
func (*EthereumMultinodeClient) WaitForFinalizedTx ¶ added in v1.15.2
func (e *EthereumMultinodeClient) WaitForFinalizedTx(txHash common.Hash) (*big.Int, time.Time, error)
WaitForTxTobeFinalized waits for the transaction to be finalized
type EthereumWallet ¶
type EthereumWallet struct {
// contains filtered or unexported fields
}
EthereumWallet is the implementation to allow testing with ETH based wallets
func NewEthereumWallet ¶
func NewEthereumWallet(pk string) (*EthereumWallet, error)
NewEthereumWallet returns the instantiated ETH wallet based on a given private key
func (*EthereumWallet) Address ¶
func (e *EthereumWallet) Address() string
Address returns the ETH address for a given wallet
func (*EthereumWallet) PrivateKey ¶
func (e *EthereumWallet) PrivateKey() string
PrivateKey returns the private key for a given Ethereum wallet
func (*EthereumWallet) RawPrivateKey ¶
func (e *EthereumWallet) RawPrivateKey() interface{}
RawPrivateKey returns raw private key if it has some encoding or in bytes
type EventConfirmer ¶ added in v1.5.6
type EventConfirmer struct {
// contains filtered or unexported fields
}
EventConfirmer confirms that an event is confirmed by a certain amount of headers
func NewEventConfirmer ¶ added in v1.5.6
func NewEventConfirmer( eventName string, client EVMClient, event *types.Log, minConfirmations int, confirmedChan chan bool, errorChan chan error, ) *EventConfirmer
NewEventConfirmer returns a new instance of the event confirmer that waits for on-chain minimum confirmations
func (*EventConfirmer) Complete ¶ added in v1.5.6
func (e *EventConfirmer) Complete() bool
Complete returns if the confirmer is done, whether confirmation was successful or not
func (*EventConfirmer) ReceiveHeader ¶ added in v1.5.12
func (e *EventConfirmer) ReceiveHeader(header NodeHeader) error
ReceiveHeader will attempt to confirm an event for the chain's configured minimum confirmed headers. Errors encountered are sent along the eventErrorChan, and the result of confirming the event is sent to eventConfirmedChan.
func (*EventConfirmer) Wait ¶ added in v1.5.6
func (e *EventConfirmer) Wait() error
Wait until the event fully presents as complete
type FantomClient ¶ added in v1.17.13
type FantomClient struct {
*EthereumClient
}
FantomClient represents a single node, EVM compatible client for the Fantom network
type FantomMultinodeClient ¶ added in v1.17.13
type FantomMultinodeClient struct {
*EthereumMultinodeClient
}
FantomMultinodeClient represents a multi-node, EVM compatible client for the Fantom network
type FinalizedHeader ¶ added in v1.15.2
type FinalizedHeader struct { LatestFinalized atomic.Value // *big.Int FinalizedAt atomic.Value // time.Time // contains filtered or unexported fields }
FinalizedHeader is an implementation of the HeaderEventSubscription interface. It keeps track of the latest finalized header for a network.
func (*FinalizedHeader) Complete ¶ added in v1.15.2
func (f *FinalizedHeader) Complete() bool
Complete returns false as the HeaderEventSubscription should run for the entire course of the test.
func (*FinalizedHeader) ReceiveHeader ¶ added in v1.15.2
func (f *FinalizedHeader) ReceiveHeader(header NodeHeader) error
ReceiveHeader is called whenever a new header is received. During the course of test whenever a new header is received, ReceiveHeader checks if there is a new finalized header tagged.
func (*FinalizedHeader) Wait ¶ added in v1.15.2
func (f *FinalizedHeader) Wait() error
Wait is not a blocking call.
type GasEstimations ¶ added in v1.11.7
type GasEstimations struct { GasUnits uint64 // How many units of gas the transaction will use GasPrice *big.Int // Gas price of the transaction (for Legacy transactions) GasTipCap *big.Int // Gas tip cap of the transaction (for DynamicFee transactions) GasFeeCap *big.Int // Gas fee cap of the transaction (for DynamicFee transactions) TotalGasCost *big.Int // Total gas cost of the transaction (gas units * total gas price) }
GasEstimations is a wrapper for the gas estimations
type GasStats ¶
type GasStats struct { NodeID int TotalGasUsed int64 SeenHashes map[string]bool ClientTXs []TXGasData // contains filtered or unexported fields }
GasStats helper struct to determine gas metrics across all txs of a test
func NewGasStats ¶
NewGasStats creates new gas stats collector
func (*GasStats) AddClientTXData ¶
AddClientTXData adds client TX data
func (*GasStats) PrintStats ¶
func (g *GasStats) PrintStats()
PrintStats prints gas stats and total TXs cost
type GnosisClient ¶ added in v1.22.8
type GnosisClient struct {
*EthereumClient
}
GnosisClient represents a single node, EVM compatible client for the Gnosis network
type GnosisMultinodeClient ¶ added in v1.22.8
type GnosisMultinodeClient struct {
*EthereumMultinodeClient
}
GnosisMultinodeClient represents a multi-node, EVM compatible client for the Gnosis network
type HeaderEventSubscription ¶
type HeaderEventSubscription interface { ReceiveHeader(header NodeHeader) error Wait() error Complete() bool }
HeaderEventSubscription is an interface for allowing callbacks when the client receives a new header
type InstantConfirmer ¶ added in v1.5.12
type InstantConfirmer struct {
// contains filtered or unexported fields
}
InstantConfirmer is a near-instant confirmation method, primarily for optimistic L2s that have near-instant finalization
func NewInstantConfirmer ¶ added in v1.5.12
func (*InstantConfirmer) Complete ¶ added in v1.5.12
func (l *InstantConfirmer) Complete() bool
Complete returns if the transaction is complete or not
func (*InstantConfirmer) ReceiveHeader ¶ added in v1.5.12
func (l *InstantConfirmer) ReceiveHeader(_ NodeHeader) error
ReceiveHeader does a quick check on if the tx is confirmed already
func (*InstantConfirmer) Wait ¶ added in v1.5.12
func (l *InstantConfirmer) Wait() error
Wait checks every header if the tx has been included on chain or not
type KlaytnClient ¶
type KlaytnClient struct {
*EthereumClient
}
KlaytnClient represents a single node, EVM compatible client for the Klaytn network
func (*KlaytnClient) EstimateGas ¶ added in v1.11.7
func (k *KlaytnClient) EstimateGas(callData ethereum.CallMsg) (GasEstimations, error)
type KlaytnMultinodeClient ¶
type KlaytnMultinodeClient struct {
*EthereumMultinodeClient
}
KlaytnMultinodeClient represents a multi-node, EVM compatible client for the Klaytn network
type KromaClient ¶ added in v1.18.4
type KromaClient struct {
*EthereumClient
}
KromaClient represents a single node, EVM compatible client for the Kroma network
func (*KromaClient) EstimateGas ¶ added in v1.18.4
func (o *KromaClient) EstimateGas(callData ethereum.CallMsg) (GasEstimations, error)
type KromaMultinodeClient ¶ added in v1.18.4
type KromaMultinodeClient struct {
*EthereumMultinodeClient
}
KromaMultinodeClient represents a multi-node, EVM compatible client for the Kroma network
type LineaClient ¶ added in v1.17.0
type LineaClient struct {
*EthereumClient
}
LineaClient represents a single node, EVM compatible client for the Linea network
type LineaMultinodeClient ¶ added in v1.17.0
type LineaMultinodeClient struct {
*EthereumMultinodeClient
}
LineaMultinodeClient represents a multi-node, EVM compatible client for the Linea network
type MetisClient ¶
type MetisClient struct {
*EthereumClient
}
MetisClient represents a single node, EVM compatible client for the Metis network
type MetisMultinodeClient ¶
type MetisMultinodeClient struct {
*EthereumMultinodeClient
}
MetisMultinodeClient represents a multi-node, EVM compatible client for the Metis network
type NodeHeader ¶ added in v1.5.12
type NodeHeader struct { NodeID int SafeEVMHeader }
NodeHeader header with the ID of the node that received it
type NonceSettings ¶ added in v1.9.1
type NonceSettings struct { NonceMu *sync.Mutex Nonces map[string]uint64 // contains filtered or unexported fields }
NonceSettings is a convenient wrapper for holding nonce state
type OptimismClient ¶ added in v1.6.4
type OptimismClient struct {
*EthereumClient
}
OptimismClient represents a single node, EVM compatible client for the Optimism network
func (*OptimismClient) EstimateGas ¶ added in v1.11.7
func (o *OptimismClient) EstimateGas(callData ethereum.CallMsg) (GasEstimations, error)
type OptimismMultinodeClient ¶ added in v1.6.4
type OptimismMultinodeClient struct {
*EthereumMultinodeClient
}
OptimismMultinodeClient represents a multi-node, EVM compatible client for the Optimism network
type PolygonClient ¶ added in v1.8.5
type PolygonClient struct {
*EthereumClient
}
PolygonClient represents a single node, EVM compatible client for the Polygon network
type PolygonMultinodeClient ¶ added in v1.8.5
type PolygonMultinodeClient struct {
*EthereumMultinodeClient
}
PolygonMultinodeClient represents a multi-node, EVM compatible client for the Klaytn network
type PolygonZkEvmClient ¶ added in v1.17.7
type PolygonZkEvmClient struct {
*EthereumClient
}
PolygonZkEvmClient represents a single node, EVM compatible client for the Polygon zkEVM network
type PolygonZkEvmMultinodeClient ¶ added in v1.17.7
type PolygonZkEvmMultinodeClient struct {
*EthereumMultinodeClient
}
PolygonZkEvmMultinodeClient a multi-node, EVM compatible client for the Polygon zkEVM network
type QuorumClient ¶ added in v1.11.5
type QuorumClient struct {
*EthereumClient
}
QuorumClient represents a single node, EVM compatible client for the Quorum network
type QuorumMultinodeClient ¶ added in v1.11.5
type QuorumMultinodeClient struct {
*EthereumMultinodeClient
}
QuorumMultinodeClient represents a multi-node, EVM compatible client for the Quorum network
type RSKClient ¶ added in v1.7.9
type RSKClient struct {
*EthereumClient
}
RSKClient represents a single node, EVM compatible client for the RSK network
type RSKMultinodeClient ¶ added in v1.7.9
type RSKMultinodeClient struct {
*EthereumMultinodeClient
}
RSKMultinodeClient represents a multi-node, EVM compatible client for the RSK network
type SafeEVMHeader ¶ added in v1.10.10
SafeEVMHeader is a wrapper for the EVM header, to allow for the addition/removal of fields without breaking the interface
func (*SafeEVMHeader) UnmarshalJSON ¶ added in v1.10.10
func (h *SafeEVMHeader) UnmarshalJSON(bs []byte) error
UnmarshalJSON enables Geth to unmarshal block headers into our custom type
type ScrollClient ¶ added in v1.15.2
type ScrollClient struct {
*EthereumClient
}
ScrollClient represents a single node, EVM compatible client for the Scroll network
type ScrollMultinodeClient ¶ added in v1.15.2
type ScrollMultinodeClient struct {
*EthereumMultinodeClient
}
ScrollMultinodeClient represents a multi-node, EVM compatible client for the Scroll network
type StrDuration ¶ added in v1.23.0
StrDuration is JSON/TOML friendly duration that can be parsed from "1h2m0s" Go format
func (*StrDuration) MarshalJSON ¶ added in v1.23.0
func (d *StrDuration) MarshalJSON() ([]byte, error)
func (StrDuration) MarshalText ¶ added in v1.23.0
func (d StrDuration) MarshalText() ([]byte, error)
MarshalText implements the text.Marshaler interface (used by toml)
func (*StrDuration) UnmarshalJSON ¶ added in v1.23.0
func (d *StrDuration) UnmarshalJSON(b []byte) error
func (*StrDuration) UnmarshalText ¶ added in v1.23.0
func (d *StrDuration) UnmarshalText(b []byte) error
UnmarshalText implements the text.Unmarshaler interface (used by toml)
type TXGasData ¶
type TXGasData struct { TXHash string Value uint64 GasLimit uint64 GasUsed uint64 GasPrice uint64 CumulativeGasUsed uint64 }
TXGasData transaction gas data
type TransactionConfirmer ¶
type TransactionConfirmer struct {
// contains filtered or unexported fields
}
TransactionConfirmer is an implementation of HeaderEventSubscription that checks whether tx are confirmed
func NewTransactionConfirmer ¶
func NewTransactionConfirmer(client EVMClient, tx *types.Transaction, minConfirmations int, logger zerolog.Logger) *TransactionConfirmer
NewTransactionConfirmer returns a new instance of the transaction confirmer that waits for on-chain minimum confirmations
func (*TransactionConfirmer) Complete ¶ added in v1.5.6
func (t *TransactionConfirmer) Complete() bool
Complete returns if the confirmer has completed or not
func (*TransactionConfirmer) ReceiveHeader ¶ added in v1.5.12
func (t *TransactionConfirmer) ReceiveHeader(header NodeHeader) error
ReceiveHeader the implementation of the HeaderEventSubscription that receives each header and checks tx confirmation
func (*TransactionConfirmer) Wait ¶
func (t *TransactionConfirmer) Wait() error
Wait is a blocking function that waits until the transaction is complete
type TransactionFinalizer ¶ added in v1.15.2
type TransactionFinalizer struct { FinalizedBy *big.Int FinalizedAt time.Time // contains filtered or unexported fields }
TransactionFinalizer is an implementation of HeaderEventSubscription that waits for a transaction to be finalized.
func NewTransactionFinalizer ¶ added in v1.15.2
func NewTransactionFinalizer(client EVMClient, txHdr *SafeEVMHeader, txHash common.Hash) *TransactionFinalizer
func (*TransactionFinalizer) Complete ¶ added in v1.15.2
func (tf *TransactionFinalizer) Complete() bool
Complete returns if the finalizer has completed or not
func (*TransactionFinalizer) ReceiveHeader ¶ added in v1.15.2
func (tf *TransactionFinalizer) ReceiveHeader(header NodeHeader) error
func (*TransactionFinalizer) Wait ¶ added in v1.15.2
func (tf *TransactionFinalizer) Wait() error
Wait is a blocking function that waits until the transaction is finalized or the context is cancelled
type WeMixClient ¶ added in v1.18.4
type WeMixClient struct {
*EthereumClient
}
WeMixClient represents a single node, EVM compatible client for the WeMix network
type WeMixMultinodeClient ¶ added in v1.18.4
type WeMixMultinodeClient struct {
*EthereumMultinodeClient
}
WeMixMultinodeClient represents a multi-node, EVM compatible client for the WeMix network
Source Files ¶
- arbitrum.go
- blockchain.go
- bsc.go
- celo.go
- config.go
- ethereum.go
- fantom.go
- finalized_headers.go
- gas_stats.go
- gnosis.go
- klaytn.go
- known_networks.go
- kroma.go
- linea.go
- metis.go
- nonce_settings.go
- optimism.go
- polygon.go
- polygon_zk_evm.go
- quorum.go
- rsk.go
- scroll.go
- transaction_confirmers.go
- wallet.go
- wemix.go