Crate pallet_evm[][src]

EVM Module

The EVM module allows unmodified EVM code to be executed in a Substrate-based blockchain.

EVM Engine

The EVM module 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 module. Substrate based accounts can call the EVM Module to deposit or withdraw balance from the Substrate base-currency into a different balance managed and used by the EVM module. Once a user has populated their balance, they can create and call smart contracts using this module.

There’s one-to-one mapping from Substrate accounts and EVM external accounts that is defined by a conversion function.

EVM Module vs Ethereum Network

The EVM module 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 module in the Substrate runtime.
  • Difficulty and coinbase, which do not make sense in this module 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 module.

The gas configurations are configurable. Right now, a pre-defined Istanbul hard fork configuration option is provided.

Re-exports

pub use crate::runner::Runner;
pub use $crate::traits::GetPalletVersion as _;

Modules

runner

Structs

Account

Basic account information.

AccountCodes
AccountStorages
EVMCurrencyAdapter

Implements the transaction payment for a module implementing the Currency trait (eg. the pallet_balances) using an unbalance handler (implementing OnUnbalanced). Similar to CurrencyAdapter of pallet_transaction_payment

EnsureAddressNever

Ensure that the origin never happens.

EnsureAddressRoot

Ensure that the origin is root.

EnsureAddressSame

Ensure that the EVM address is the same as the Substrate address. This only works if the account ID is H160.

EnsureAddressTruncated

Ensure that the address is truncated hash of the origin. Only works if the account id is AccountId32.

ExecutionInfo
GenesisAccount

Account definition used for genesis block construction.

GenesisConfig

Genesis config for the module, allow to build genesis storage.

HashedAddressMapping

Hashed address mapping.

IdentityAddressMapping

Identity address mapping.

Log
Module
Vicinity

External input from the transaction.

Enums

Call

Dispatchable calls.

Error
ExitError

Exit error reason.

ExitFatal

Exit fatal reason.

ExitReason

Exit reason.

ExitRevert

Exit revert reason.

ExitSucceed

Exit succeed reason.

RawEvent

Events for this module.

Traits

AddressMapping
Config

EVM module trait

EnsureAddressOrigin
FeeCalculator

Trait that outputs the current transaction gas price.

GasWeightMapping

A mapping function that converts Ethereum gas to Substrate weight

LinearCostPrecompile
OnChargeEVMTransaction

Handle withdrawing, refunding and depositing of transaction fees. Similar to OnChargeTransaction of pallet_transaction_payment

Precompile

One single precompile used by EVM engine.

PrecompileSet

Custom precompiles to be used by EVM engine.

Type Definitions

BalanceOf

Type alias for currency balance.

CallInfo
CreateInfo
Event

RawEvent specialized for the configuration Config