Expand description
§EVM Pallet
The EVM pallet allows unmodified EVM code to be executed in a Substrate-based blockchain.
§EVM Engine
The EVM pallet uses SputnikVM
as the underlying EVM engine.
The engine is overhauled so that it’s modular
.
§Execution Lifecycle
There are a separate set of accounts managed by the EVM pallet. Substrate based accounts can call the EVM Pallet to deposit or withdraw balance from the Substrate base-currency into a different balance managed and used by the EVM pallet. Once a user has populated their balance, they can create and call smart contracts using this pallet.
There’s one-to-one mapping from Substrate accounts and EVM external accounts that is defined by a conversion function.
§EVM Pallet vs Ethereum Network
The EVM pallet should be able to produce nearly identical results compared to the Ethereum mainnet, including gas cost and balance changes.
Observable differences include:
- The available length of block hashes may not be 256 depending on the configuration of the System pallet in the Substrate runtime.
- Difficulty and coinbase, which do not make sense in this pallet and is currently hard coded to zero.
We currently do not aim to make unobservable behaviors, such as state root, to be the same. We also don’t aim to follow the exact same transaction / receipt format. However, given one Ethereum transaction and one Substrate account’s private key, one should be able to convert any Ethereum transaction into a transaction compatible with this pallet.
The gas configurations are configurable. Right now, a pre-defined London hard fork configuration option is provided.
Re-exports§
pub use self::runner::Runner;
pub use self::runner::RunnerError;
pub use self::weights::WeightInfo;
pub use self::pallet::*;
Modules§
- pallet
- The
pallet
module in each FRAME pallet hosts the most important items needed to construct this pallet. - runner
- weights
- Autogenerated weights for pallet_evm
Structs§
- Account
- Basic account information.
- Code
Metadata - Context
- Context of the runtime.
- EVMCurrency
Adapter - Implements the transaction payment for a pallet implementing the
Currency
trait (eg. the pallet_balances) using an unbalance handler (implementingOnUnbalanced
). Similar toCurrencyAdapter
ofpallet_transaction_payment
- EVMFungible
Adapter - Implements transaction payment for a pallet implementing the [
fungible
] trait (eg. pallet_balances) using an unbalance handler (implementing [OnUnbalanced
]). - Ensure
Account Id20 - Ensure that the address is AccountId20.
- Ensure
Address Never - Ensure that the origin never happens.
- Ensure
Address Root - Ensure that the origin is root.
- Ensure
Address Same - Ensure that the EVM address is the same as the Substrate address. This only works if the account
ID is
H160
. - Ensure
Address Truncated - Ensure that the address is truncated hash of the origin. Only works if the account id is
AccountId32
. - Ensure
Allowed Create Address - EvmConfig
- Runtime configuration.
- Execution
Info - Fixed
GasWeight Mapping - Frame
System Account Provider - EVM account provider based on the [
frame_system
] accounts. - Hashed
Address Mapping - Hashed address mapping.
- Identity
Address Mapping - Identity address mapping.
- Log
- Precompile
Output - Data returned by a precompile on success.
- Substrate
Block Hash Mapping - Returns the Substrate block hash by number.
- Vicinity
- External input from the transaction.
Enums§
- Exit
Error - Exit error reason.
- Exit
Fatal - Exit fatal reason.
- Exit
Reason - Exit reason.
- Exit
Revert - Exit revert reason.
- Exit
Succeed - Exit succeed reason.
- IsPrecompile
Result - Precompile
Failure - Data returned by a precompile in case of failure.
- Transaction
Validation Error - Transaction validation errors
Traits§
- Account
Provider - The account provider interface abstraction layer.
- Address
Mapping - Trait to be implemented for evm address mapping.
- Block
Hash Mapping - A trait for getting a block hash by number.
- Ensure
Address Origin - Ensure
Create Origin - FeeCalculator
- Trait that outputs the current transaction gas price.
- Fixed
GasWeight Mapping Associated Types - GasWeight
Mapping - A mapping function that converts Ethereum gas to Substrate weight
- Linear
Cost Precompile - OnChargeEVM
Transaction - Handle withdrawing, refunding and depositing of transaction fees.
Similar to
OnChargeTransaction
ofpallet_transaction_payment
- OnCreate
- Precompile
- One single precompile used by EVM engine.
- Precompile
Handle - Handle provided to a precompile to interact with the EVM.
- Precompile
Set - A set of precompiles.
Type Aliases§
- Account
IdOf - Utility alias for easy access to the
AccountProvider::AccountId
type from a given config. - Balance
Of - Type alias for currency balance.
- Call
Info - Create
Info - Precompile
Result