# 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.

# Functions

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.
ConnectEVMClient returns a multi-node EVM client connected to a specified network, using only URLs.
LoadNetworkFromEnvironment loads an EVM network from default environment variables.
NewEthereumWallet returns the instantiated ETH wallet based on a given private key.
NewEventConfirmer returns a new instance of the event confirmer that waits for on-chain minimum confirmations.
NewEVMClient returns a multi-node EVM client connected to the specified network Note: This should mostly be deprecated in favor of ConnectEVMClient.
NewEVMClientFromNetwork returns a multi-node EVM client connected to the specified network.
NewGasStats creates new gas stats collector.
No description provided by the author
NewTransactionConfirmer returns a new instance of the transaction confirmer that waits for on-chain minimum confirmations.
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ETH one eth in wei.
Ethereum uses the standard EVM implementation, and is considered default.
No description provided by the author
No description provided by the author
No description provided by the author
GWei one giga-wei used for gas calculations.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

SimulatedEVMNetwork ensures that the test will use a default simulated geth instance.

# Structs

ArbitrumClient represents a single node, EVM compatible client for the Arbitrum network.
ArbitrumMultinodeClient represents a multi-node, EVM compatible client for the Arbitrum network.
BSCClient represents a single node, EVM compatible client for the BSC network.
BSCMultinodeClient represents a multi-node, EVM compatible client for the BSC network.
CeloClient represents a single node, EVM compatible client for the Celo network.
CeloMultinodeClient represents a multi-node, EVM compatible client for the Celo network.
EthereumClient wraps the client and the BlockChain network to interact with an EVM based Blockchain.
EthereumMultinodeClient wraps the client and the BlockChain network to interact with an EVM based Blockchain with multiple nodes.
EthereumWallet is the implementation to allow testing with ETH based wallets.
EventConfirmer confirms that an event is confirmed by a certain amount of headers.
EVMNetwork configures all the data the test needs to connect and operate on an EVM compatible network.
FantomClient represents a single node, EVM compatible client for the Fantom network.
FantomMultinodeClient represents a multi-node, EVM compatible client for the Fantom network.
FinalizedHeader is an implementation of the HeaderEventSubscription interface.
GasEstimations is a wrapper for the gas estimations.
GasStats helper struct to determine gas metrics across all txs of a test.
GnosisClient represents a single node, EVM compatible client for the Gnosis network.
GnosisMultinodeClient represents a multi-node, EVM compatible client for the Gnosis network.
InstantConfirmer is a near-instant confirmation method, primarily for optimistic L2s that have near-instant finalization.
KlaytnClient represents a single node, EVM compatible client for the Klaytn network.
KlaytnMultinodeClient represents a multi-node, EVM compatible client for the Klaytn network.
KromaClient represents a single node, EVM compatible client for the Kroma network.
KromaMultinodeClient represents a multi-node, EVM compatible client for the Kroma network.
LineaClient represents a single node, EVM compatible client for the Linea network.
LineaMultinodeClient represents a multi-node, EVM compatible client for the Linea network.
MetisClient represents a single node, EVM compatible client for the Metis network.
MetisMultinodeClient represents a multi-node, EVM compatible client for the Metis network.
NodeHeader header with the ID of the node that received it.
NonceSettings is a convenient wrapper for holding nonce state.
OptimismClient represents a single node, EVM compatible client for the Optimism network.
OptimismMultinodeClient represents a multi-node, EVM compatible client for the Optimism network.
PolygonClient represents a single node, EVM compatible client for the Polygon network.
PolygonMultinodeClient represents a multi-node, EVM compatible client for the Klaytn network.
PolygonZkEvmClient represents a single node, EVM compatible client for the Polygon zkEVM network.
PolygonZkEvmMultinodeClient a multi-node, EVM compatible client for the Polygon zkEVM network.
QuorumClient represents a single node, EVM compatible client for the Quorum network.
QuorumMultinodeClient represents a multi-node, EVM compatible client for the Quorum network.
RSKClient represents a single node, EVM compatible client for the RSK network.
RSKMultinodeClient represents a multi-node, EVM compatible client for the RSK network.
SafeEVMHeader is a wrapper for the EVM header, to allow for the addition/removal of fields without breaking the interface.
ScrollClient represents a single node, EVM compatible client for the Scroll network.
ScrollMultinodeClient represents a multi-node, EVM compatible client for the Scroll network.
StrDuration is JSON/TOML friendly duration that can be parsed from "1h2m0s" Go format.
TransactionConfirmer is an implementation of HeaderEventSubscription that checks whether tx are confirmed.
TransactionFinalizer is an implementation of HeaderEventSubscription that waits for a transaction to be finalized.
TXGasData transaction gas data.
WeMixClient represents a single node, EVM compatible client for the WeMix network.
WeMixMultinodeClient represents a multi-node, EVM compatible client for the WeMix network.

# Interfaces

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,.
HeaderEventSubscription is an interface for allowing callbacks when the client receives a new header.

# Type aliases

ClientImplementation represents the type of EVM client implementation for the framework to use.
ContractDeployer acts as a go-between function for general contract deployment.
ContractLoader helps loading already deployed contracts.