EEVM.HardforkConfig (eevm v0.1.0)

Copy Markdown View Source

Hardfork configuration controlling which EIP rules are active during execution.

The spec_id atom identifies the target hardfork, and enabled?/2 answers whether a given EIP is active under that spec.

Hardfork timeline (oldest → newest):

HardforkNotable EIPs
:frontierbaseline
:homestead—
:tangerine_whistleEIP-150 gas repricing
:spurious_dragonEIP-155, EIP-161, EIP-170 (code size limit)
:byzantiumREVERT, RETURNDATASIZE, RETURNDATACOPY, STATICCALL
:constantinopleCREATE2, SHL/SHR/SAR, EXTCODEHASH
:istanbulEIP-1344 (CHAINID), EIP-1884 (SELFBALANCE), EIP-2200 (SSTORE)
:berlinEIP-2929 (cold/warm access), EIP-2930 (access lists)
:londonEIP-1559 (basefee), EIP-3529 (refund cap), EIP-3541 (0xEF rejection)
:parisThe Merge (PREVRANDAO replaces DIFFICULTY)
:shanghaiEIP-3651 (COINBASE pre-warm), EIP-3855 (PUSH0), EIP-3860 (initcode limit)
:cancunEIP-1153 (TLOAD/TSTORE), EIP-4844 (blobs), EIP-5656 (MCOPY), EIP-6780 (SELFDESTRUCT)
:pragueEIP-2537 (BLS12-381 precompiles), EIP-7623 (calldata floor), EIP-7702 (set-code)
:osakaEIP-7825 (tx gas limit cap), EIP-7918 (blob base fee floor), EIP-7934 (block RLP size limit), EIP-7939 (CLZ)
EIP-7883 (ModExp repricing), EIP-7951 (P256VERIFY precompile)

Summary

Functions

Returns a list of all known spec IDs in chronological order.

Returns the default hardfork config — Cancun, the most-tested hardfork.

Returns true if the given EIP feature flag is active in this hardfork config.

Creates a new hardfork config for the given spec_id.

Types

spec_id()

@type spec_id() ::
  :frontier
  | :homestead
  | :tangerine_whistle
  | :spurious_dragon
  | :byzantium
  | :constantinople
  | :istanbul
  | :berlin
  | :london
  | :paris
  | :shanghai
  | :cancun
  | :prague
  | :osaka

t()

@type t() :: %EEVM.HardforkConfig{spec_id: spec_id()}

Functions

all_spec_ids()

@spec all_spec_ids() :: [spec_id()]

Returns a list of all known spec IDs in chronological order.

default()

@spec default() :: t()

Returns the default hardfork config — Cancun, the most-tested hardfork.

Callers that don't specify a hardfork explicitly get Cancun semantics, preserving backwards compatibility with all existing tests.

enabled?(hardfork_config, eip_flag)

@spec enabled?(t(), atom()) :: boolean()

Returns true if the given EIP feature flag is active in this hardfork config.

Examples

iex> config = EEVM.HardforkConfig.new(:cancun)
iex> EEVM.HardforkConfig.enabled?(config, :eip_6780)
true

iex> config = EEVM.HardforkConfig.new(:london)
iex> EEVM.HardforkConfig.enabled?(config, :eip_6780)
false

iex> config = EEVM.HardforkConfig.new(:berlin)
iex> EEVM.HardforkConfig.enabled?(config, :eip_2929)
true

new(spec_id)

@spec new(spec_id()) :: t()

Creates a new hardfork config for the given spec_id.

Example

iex> EEVM.HardforkConfig.new(:cancun)
%EEVM.HardforkConfig{spec_id: :cancun}