blockchain

package
v0.0.0-...-171e6b0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: MIT Imports: 33 Imported by: 22

README

Blockchain Clients

This folder contains the bulk of code that handles integrating with different EVM chains. If you're looking to run tests on a new EVM chain, and are having issues with the default implementation, you've come to the right place.

Some Terminology
  • L2 Chain: A Layer 2 chain "branching" off Ethereum.
  • EVM: Ethereum Virtual Machine that underpins the Ethereum blockchain.
  • EVM Compatible: A chain that has some large, underlying differences from how base Ethereum works, but can still be interacted with largely the same way as Ethereum.
  • EIP-1559: The Ethereum Improvement Proposal that changed how gas fees are calculated and paid on Ethereum
  • Legacy Transactions: Transactions that are sent using the old gas fee calculation method, the one used before EIP-1559.
  • Dynamic Fee Transaction: Transactions that are sent using the new gas fee calculation method, the one used after EIP-1559.

How Client Integrations Work

In order to test Plugin nodes, the plugin-testing-framework needs to be able to interact with the chain that the node is running on. This is done through the blockchain.EVMClient interface. The EVMClient interface is a wrapper around geth to interact with the blockchain. We conduct all our testing blockchain operations through this wrapper, like sending transactions and monitoring on-chain events. The primary implementation of this wrapper is built for Ethereum. Most others, like the Metis and Optimism integrations, extend and modify the base Ethereum implementation.

Do I Need a New Integration?

If you're reading this, probably. The default EVM integration is designed to work with mainnet Ethereum, which covers most other EVM chain interactions, but it's not guaranteed to work with all of them. If you're on a new chain and the test framework is throwing errors while doing basic things like send transactions, receive new headers, or deploy contracts, you'll likely need to create a new integration. The most common issue with new chains (especially L2s) is gas estimations and lack of support for dynamic transactions.

Creating a New Integration

Take a look at the Metis integration as an example. Metis is an L2, EVM compatible chain. It's largely the same as the base Ethereum integration, so we'll extend from that.

type MetisMultinodeClient struct {
  *EthereumMultinodeClient
}

type MetisClient struct {
  *EthereumClient
}

Now we need to let other libraries (like our tests in the main Plugin repo) that this integration exists. So we add the new implementation to the known_networks.go file. We can then add that network to our tests' own known_networks.go file (it's annoying, there are plans to simplify).

Now our Metis integration is the exact same as our base Ethereum one, which doesn't do us too much good. I'm assuming you came here to make some changes, so first let's find out what we need to change. This is a mix of reading developer documentation on the chain you're testing and trial and error. Mostly the latter in later stages. In the case of Metis, like many L2s, they have their own spin on gas fees. They also only support Legacy transactions. So we'll need to override any methods that deal with gas estimations, Fund, DeployContract, and ReturnFunds.

Documentation

Overview

Package blockchain handles connections to various blockchains

Index

Constants

View Source
const (
	// GWei one giga-wei used for gas calculations
	GWei = 1e9
	// ETH one eth in wei
	ETH = 1e18
)
View Source
const (
	FinalizedHeaderKey = "finalizedHeads"
)
View Source
const MaxTimeoutForFinality = 15 * time.Minute

Variables

View Source
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",
		},
		PluginTransactionLimit: 500000,
		Timeout:                StrDuration{2 * time.Minute},
		MinimumConfirmations:   1,
		GasEstimationBuffer:    10000,
	}
)

Functions

func RPCErrorFromError

func RPCErrorFromError(txError error) (string, error)

Types

type ArbitrumClient

type ArbitrumClient struct {
	*EthereumClient
}

ArbitrumClient represents a single node, EVM compatible client for the Arbitrum network

type ArbitrumMultinodeClient

type ArbitrumMultinodeClient struct {
	*EthereumMultinodeClient
}

ArbitrumMultinodeClient represents a multi-node, EVM compatible client for the Arbitrum network

type BSCClient

type BSCClient struct {
	*EthereumClient
}

BSCClient represents a single node, EVM compatible client for the BSC network

type BSCMultinodeClient

type BSCMultinodeClient struct {
	*EthereumMultinodeClient
}

BSCMultinodeClient represents a multi-node, EVM compatible client for the BSC network

type CeloClient

type CeloClient struct {
	*EthereumClient
}

CeloClient represents a single node, EVM compatible client for the Celo network

func (*CeloClient) DeployContract

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

func (e *CeloClient) TransactionOpts(from *EthereumWallet) (*bind.TransactOpts, error)

type CeloMultinodeClient

type CeloMultinodeClient struct {
	*EthereumMultinodeClient
}

CeloMultinodeClient represents a multi-node, EVM compatible client for the Celo network

type ClientImplementation

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

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
	GetWalletByAddress(address common.Address) *EthereumWallet
	GetNetworkConfig() *EVMNetwork
	GetNonceSetting() NonceSettings

	GetHeaderSubscriptions() map[string]HeaderEventSubscription

	// Setters
	SetID(id int)
	SetDefaultWallet(num int) error
	SetDefaultWalletByAddress(address common.Address) 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)
	ErrorReason(b ethereum.ContractCaller, tx *types.Transaction, receipt *types.Receipt) (string, 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
	EstimateCostForPluginOperations(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

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

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

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

func NewEVMClientFromNetwork(networkSettings EVMNetwork, logger zerolog.Logger) (EVMClient, error)

NewEVMClientFromNetwork returns a multi-node EVM client connected to the specified network

type EVMNetwork

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 Plugin nodes will use. Used to try to estimate the funds that Plugin
	// nodes require to run the tests.
	PluginTransactionLimit uint64 `toml:"evm_plugin_transaction_limit" json:"evm_plugin_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

func LoadNetworkFromEnvironment() EVMNetwork

LoadNetworkFromEnvironment loads an EVM network from default environment variables. Helpful in soak tests

func (*EVMNetwork) MustPluginTOML

func (e *EVMNetwork) MustPluginTOML(networkDetails string) string

MustPluginTOML 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

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

func (e *EthereumClient) AvgBlockTime(ctx context.Context) (time.Duration, error)

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

func (e *EthereumClient) Backend() bind.ContractBackend

func (*EthereumClient) BalanceAt

func (e *EthereumClient) BalanceAt(ctx context.Context, address common.Address) (*big.Int, error)

BalanceAt returns the ETH balance of the specified address

func (*EthereumClient) CancelFinalityPolling

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

func (e *EthereumClient) ConnectionIssue() chan time.Time

ConnectionIssue returns a channel that will receive a timestamp when the connection is lost

func (*EthereumClient) ConnectionRestored

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

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) ErrorReason

func (e *EthereumClient) ErrorReason(
	b ethereum.ContractCaller,
	tx *types.Transaction,
	receipt *types.Receipt,
) (string, error)

ErrorReason decodes tx revert reason

func (*EthereumClient) EstimateCostForPluginOperations

func (e *EthereumClient) EstimateCostForPluginOperations(amountOfOperations int) (*big.Float, error)

EstimateCostForPluginOperations calculates required amount of ETH for amountOfOperations Plugin operations based on the network's suggested gas price and the plugin 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

func (e *EthereumClient) EstimateGas(callMsg ethereum.CallMsg) (GasEstimations, error)

EstimateGas estimates all gas values based on call data

func (*EthereumClient) EstimateGasPrice

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

func (e *EthereumClient) EstimatedFinalizationTime(ctx context.Context) (time.Duration, error)

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

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

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

func (e *EthereumClient) GetLatestFinalizedBlockHeader(ctx context.Context) (*types.Header, error)

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

func (e *EthereumClient) GetNonce(ctx context.Context, addr common.Address) (uint64, error)

GetNonce keep tracking of nonces per address, add last nonce for addr if the map is empty

func (*EthereumClient) GetNonceSetting

func (e *EthereumClient) GetNonceSetting() NonceSettings

func (*EthereumClient) GetTxReceipt

func (e *EthereumClient) GetTxReceipt(txHash common.Hash) (*types.Receipt, error)

GetTxReceipt returns the receipt of the transaction if available, error otherwise

func (*EthereumClient) GetWalletByAddress

func (e *EthereumClient) GetWalletByAddress(address common.Address) *EthereumWallet

GetWalletByAddress returns the Ethereum wallet by address if it exists, else returns nil

func (*EthereumClient) GetWallets

func (e *EthereumClient) GetWallets() []*EthereumWallet

DefaultWallet returns the default wallet for the network

func (*EthereumClient) HeaderByHash

func (e *EthereumClient) HeaderByHash(ctx context.Context, hash common.Hash) (*SafeEVMHeader, error)

HeaderByHash retrieves a Safe EVM header by hash

func (*EthereumClient) HeaderByNumber

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

func (e *EthereumClient) HeaderHashByNumber(ctx context.Context, bn *big.Int) (string, error)

HeaderHashByNumber gets header hash by block number

func (*EthereumClient) HeaderTimestampByNumber

func (e *EthereumClient) HeaderTimestampByNumber(ctx context.Context, bn *big.Int) (uint64, error)

HeaderTimestampByNumber gets header timestamp by number

func (*EthereumClient) IsEventConfirmed

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

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

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

func (e *EthereumClient) MarkTxAsSentOnL2(tx *types.Transaction) error

MarkTxAsSent On an L2 chain, indicate the tx has been sent

func (*EthereumClient) NetworkSimulated

func (e *EthereumClient) NetworkSimulated() bool

NetworkSimulated returns true if the network is a simulated geth instance, false otherwise

func (*EthereumClient) NewTx

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

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

func (e *EthereumClient) PollFinality() error

PollFinalizedHeader continuously polls the latest finalized header and stores it in the client

func (*EthereumClient) ProcessEvent

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

func (e *EthereumClient) RawJsonRPCCall(ctx context.Context, result interface{}, method string, params ...interface{}) error

func (*EthereumClient) ReturnFunds

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

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

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) SetDefaultWalletByAddress

func (e *EthereumClient) SetDefaultWalletByAddress(address common.Address) error

SetDefaultWalletByAddress sets default wallet by address if it exists, else returns error

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

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

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

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

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

func (e *EthereumClient) WaitForFinalizedTx(txHash common.Hash) (*big.Int, time.Time, error)

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

type EthereumMultinodeClient struct {
	DefaultClient EVMClient
	Clients       []EVMClient
}

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

func (e *EthereumMultinodeClient) AvgBlockTime(ctx context.Context) (time.Duration, error)

func (*EthereumMultinodeClient) Backend

func (*EthereumMultinodeClient) BalanceAt

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

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

func (e *EthereumMultinodeClient) ConnectionIssue() chan time.Time

func (*EthereumMultinodeClient) ConnectionRestored

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

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) ErrorReason

func (e *EthereumMultinodeClient) ErrorReason(b ethereum.ContractCaller, tx *types.Transaction, receipt *types.Receipt) (string, error)

func (*EthereumMultinodeClient) EstimateCostForPluginOperations

func (e *EthereumMultinodeClient) EstimateCostForPluginOperations(amountOfOperations int) (*big.Float, error)

EstimateCostForPluginOperations calculates TXs cost as a dirty estimation based on transactionLimit for that network

func (*EthereumMultinodeClient) EstimateGas

func (e *EthereumMultinodeClient) EstimateGas(callMsg ethereum.CallMsg) (GasEstimations, error)

func (*EthereumMultinodeClient) EstimateGasPrice

func (e *EthereumMultinodeClient) EstimateGasPrice() (*big.Int, error)

func (*EthereumMultinodeClient) EstimateTransactionGasCost

func (e *EthereumMultinodeClient) EstimateTransactionGasCost() (*big.Int, error)

func (*EthereumMultinodeClient) EstimatedFinalizationTime

func (e *EthereumMultinodeClient) EstimatedFinalizationTime(ctx context.Context) (time.Duration, error)

func (*EthereumMultinodeClient) FilterLogs

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

func (e *EthereumMultinodeClient) GetEthClient() *ethclient.Client

func (*EthereumMultinodeClient) GetHeaderSubscriptions

func (e *EthereumMultinodeClient) GetHeaderSubscriptions() map[string]HeaderEventSubscription

func (*EthereumMultinodeClient) GetLatestFinalizedBlockHeader

func (e *EthereumMultinodeClient) GetLatestFinalizedBlockHeader(ctx context.Context) (*types.Header, error)

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

func (e *EthereumMultinodeClient) GetNonceSetting() NonceSettings

func (*EthereumMultinodeClient) GetTxReceipt

func (e *EthereumMultinodeClient) GetTxReceipt(txHash common.Hash) (*types.Receipt, error)

GetTxReceipt returns the receipt of the transaction if available, error otherwise

func (*EthereumMultinodeClient) GetWalletByAddress

func (e *EthereumMultinodeClient) GetWalletByAddress(address common.Address) *EthereumWallet

GetWalletByAddress returns the Ethereum wallet by address if it exists, else returns nil

func (*EthereumMultinodeClient) GetWallets

func (e *EthereumMultinodeClient) GetWallets() []*EthereumWallet

GetWallets returns the default wallet for the network

func (*EthereumMultinodeClient) HeaderByHash

func (e *EthereumMultinodeClient) HeaderByHash(ctx context.Context, hash common.Hash) (*SafeEVMHeader, error)

HeaderByHash retrieves a Safe EVM header by hash

func (*EthereumMultinodeClient) HeaderByNumber

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

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

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

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

func (e *EthereumMultinodeClient) MarkTxAsSentOnL2(tx *types.Transaction) error

MarkTxAsSentOnL2 marks the transaction as sent on L2

func (*EthereumMultinodeClient) NetworkSimulated

func (e *EthereumMultinodeClient) NetworkSimulated() bool

GetNetworkType retrieves the type of network this is running on

func (*EthereumMultinodeClient) NewTx

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

func (e *EthereumMultinodeClient) PollFinality() error

PollFinality polls for finality

func (*EthereumMultinodeClient) ProcessEvent

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

func (e *EthereumMultinodeClient) RawJsonRPCCall(ctx context.Context, result interface{}, method string, params ...interface{}) error

func (*EthereumMultinodeClient) ReturnFunds

func (e *EthereumMultinodeClient) ReturnFunds(fromKey *ecdsa.PrivateKey) error

func (*EthereumMultinodeClient) RevertReasonFromTx

func (e *EthereumMultinodeClient) RevertReasonFromTx(txHash common.Hash, abiString string) (string, interface{}, error)

func (*EthereumMultinodeClient) SendTransaction

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) SetDefaultWalletByAddress

func (e *EthereumMultinodeClient) SetDefaultWalletByAddress(address common.Address) error

SetDefaultWalletByAddress sets default wallet by address if it exists, else returns error

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

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

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

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

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

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

EventConfirmer confirms that an event is confirmed by a certain amount of headers

func NewEventConfirmer

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

func (e *EventConfirmer) Complete() bool

Complete returns if the confirmer is done, whether confirmation was successful or not

func (*EventConfirmer) ReceiveHeader

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

func (e *EventConfirmer) Wait() error

Wait until the event fully presents as complete

type FantomClient

type FantomClient struct {
	*EthereumClient
}

FantomClient represents a single node, EVM compatible client for the Fantom network

type FantomMultinodeClient

type FantomMultinodeClient struct {
	*EthereumMultinodeClient
}

FantomMultinodeClient represents a multi-node, EVM compatible client for the Fantom network

type FinalizedHeader

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

func (f *FinalizedHeader) Complete() bool

Complete returns false as the HeaderEventSubscription should run for the entire course of the test.

func (*FinalizedHeader) ReceiveHeader

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

func (f *FinalizedHeader) Wait() error

Wait is not a blocking call.

type GasEstimations

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

func NewGasStats(nodeID int) *GasStats

NewGasStats creates new gas stats collector

func (*GasStats) AddClientTXData

func (g *GasStats) AddClientTXData(data TXGasData)

AddClientTXData adds client TX data

func (*GasStats) PrintStats

func (g *GasStats) PrintStats()

PrintStats prints gas stats and total TXs cost

type GnosisClient

type GnosisClient struct {
	*EthereumClient
}

GnosisClient represents a single node, EVM compatible client for the Gnosis network

type GnosisMultinodeClient

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

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

func NewInstantConfirmer(
	client EVMClient,
	txHash common.Hash,
	confirmedChan chan bool,
	_ chan error,
	logger zerolog.Logger,
) *InstantConfirmer

func (*InstantConfirmer) Complete

func (l *InstantConfirmer) Complete() bool

Complete returns if the transaction is complete or not

func (*InstantConfirmer) ReceiveHeader

func (l *InstantConfirmer) ReceiveHeader(_ NodeHeader) error

ReceiveHeader does a quick check on if the tx is confirmed already

func (*InstantConfirmer) Wait

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

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

type KromaClient struct {
	*EthereumClient
}

KromaClient represents a single node, EVM compatible client for the Kroma network

func (*KromaClient) EstimateGas

func (o *KromaClient) EstimateGas(callData ethereum.CallMsg) (GasEstimations, error)

type KromaMultinodeClient

type KromaMultinodeClient struct {
	*EthereumMultinodeClient
}

KromaMultinodeClient represents a multi-node, EVM compatible client for the Kroma network

type LineaClient

type LineaClient struct {
	*EthereumClient
}

LineaClient represents a single node, EVM compatible client for the Linea network

type LineaMultinodeClient

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

type NodeHeader struct {
	NodeID int
	SafeEVMHeader
}

NodeHeader header with the ID of the node that received it

type NonceSettings

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

type OptimismClient struct {
	*EthereumClient
}

OptimismClient represents a single node, EVM compatible client for the Optimism network

func (*OptimismClient) EstimateGas

func (o *OptimismClient) EstimateGas(callData ethereum.CallMsg) (GasEstimations, error)

type OptimismMultinodeClient

type OptimismMultinodeClient struct {
	*EthereumMultinodeClient
}

OptimismMultinodeClient represents a multi-node, EVM compatible client for the Optimism network

type PolygonClient

type PolygonClient struct {
	*EthereumClient
}

PolygonClient represents a single node, EVM compatible client for the Polygon network

type PolygonMultinodeClient

type PolygonMultinodeClient struct {
	*EthereumMultinodeClient
}

PolygonMultinodeClient represents a multi-node, EVM compatible client for the Klaytn network

type PolygonZkEvmClient

type PolygonZkEvmClient struct {
	*EthereumClient
}

PolygonZkEvmClient represents a single node, EVM compatible client for the Polygon zkEVM network

type PolygonZkEvmMultinodeClient

type PolygonZkEvmMultinodeClient struct {
	*EthereumMultinodeClient
}

PolygonZkEvmMultinodeClient a multi-node, EVM compatible client for the Polygon zkEVM network

type QuorumClient

type QuorumClient struct {
	*EthereumClient
}

QuorumClient represents a single node, EVM compatible client for the Quorum network

type QuorumMultinodeClient

type QuorumMultinodeClient struct {
	*EthereumMultinodeClient
}

QuorumMultinodeClient represents a multi-node, EVM compatible client for the Quorum network

type RSKClient

type RSKClient struct {
	*EthereumClient
}

RSKClient represents a single node, EVM compatible client for the RSK network

type RSKMultinodeClient

type RSKMultinodeClient struct {
	*EthereumMultinodeClient
}

RSKMultinodeClient represents a multi-node, EVM compatible client for the RSK network

type SafeEVMHeader

type SafeEVMHeader struct {
	Hash      common.Hash
	Number    *big.Int
	Timestamp time.Time
	BaseFee   *big.Int
}

SafeEVMHeader is a wrapper for the EVM header, to allow for the addition/removal of fields without breaking the interface

func (*SafeEVMHeader) UnmarshalJSON

func (h *SafeEVMHeader) UnmarshalJSON(bs []byte) error

UnmarshalJSON enables Geth to unmarshal block headers into our custom type

type ScrollClient

type ScrollClient struct {
	*EthereumClient
}

ScrollClient represents a single node, EVM compatible client for the Scroll network

type ScrollMultinodeClient

type ScrollMultinodeClient struct {
	*EthereumMultinodeClient
}

ScrollMultinodeClient represents a multi-node, EVM compatible client for the Scroll network

type StrDuration

type StrDuration struct {
	time.Duration
}

StrDuration is JSON/TOML friendly duration that can be parsed from "1h2m0s" Go format

func (*StrDuration) MarshalJSON

func (d *StrDuration) MarshalJSON() ([]byte, error)

func (StrDuration) MarshalText

func (d StrDuration) MarshalText() ([]byte, error)

MarshalText implements the text.Marshaler interface (used by toml)

func (*StrDuration) UnmarshalJSON

func (d *StrDuration) UnmarshalJSON(b []byte) error

func (*StrDuration) UnmarshalText

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

func (t *TransactionConfirmer) Complete() bool

Complete returns if the confirmer has completed or not

func (*TransactionConfirmer) ReceiveHeader

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

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

func NewTransactionFinalizer(client EVMClient, txHdr *SafeEVMHeader, txHash common.Hash) *TransactionFinalizer

func (*TransactionFinalizer) Complete

func (tf *TransactionFinalizer) Complete() bool

Complete returns if the finalizer has completed or not

func (*TransactionFinalizer) ReceiveHeader

func (tf *TransactionFinalizer) ReceiveHeader(header NodeHeader) error

func (*TransactionFinalizer) Wait

func (tf *TransactionFinalizer) Wait() error

Wait is a blocking function that waits until the transaction is finalized or the context is cancelled

type WeMixClient

type WeMixClient struct {
	*EthereumClient
}

WeMixClient represents a single node, EVM compatible client for the WeMix network

type WeMixMultinodeClient

type WeMixMultinodeClient struct {
	*EthereumMultinodeClient
}

WeMixMultinodeClient represents a multi-node, EVM compatible client for the WeMix network

Jump to

Keyboard shortcuts

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