Skip to content

Commit

Permalink
Create2 [EIP-1014] (#426)
Browse files Browse the repository at this point in the history
* check if create2 is supported

* fix configuration for create2

* implement create2 adress generation

* fix init code in create2

* fix positional arguments for create2 address generation

* fix create2 in static_call

* update skipped tests

* fix doctest

* update dialyzer ignore file

* move <<255>> to named variable

* fix dialyzer

* rewrite selfdestruct signature as one line
  • Loading branch information
ayrat555 authored Sep 18, 2018
1 parent 4d8f8a0 commit 88ce5f0
Show file tree
Hide file tree
Showing 20 changed files with 221 additions and 181 deletions.
26 changes: 13 additions & 13 deletions .dialyzer.ignore-warnings
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,22 @@

# evm warnings

apps/evm/lib/evm/functions.ex:187: Function 'not_enough_gas?'/2 has no local return
apps/evm/lib/evm/functions.ex:194: Function 'out_of_memory_bounds?'/3 will never be called
apps/evm/lib/evm/functions.ex:210: Function 'is_invalid_jump_destination?'/3 will never be called
apps/evm/lib/evm/functions.ex:220: Function 'static_state_modification?'/2 will never be called
apps/evm/lib/evm/functions.ex:190: Function 'not_enough_gas?'/2 has no local return
apps/evm/lib/evm/functions.ex:197: Function 'out_of_memory_bounds?'/3 will never be called
apps/evm/lib/evm/functions.ex:213: Function 'is_invalid_jump_destination?'/3 will never be called
apps/evm/lib/evm/functions.ex:223: Function 'static_state_modification?'/2 will never be called
apps/evm/lib/evm/gas.ex:138: Function cost/2 has no local return
apps/evm/lib/evm/gas.ex:138: Function cost/3 has no local return
apps/evm/lib/evm/gas.ex:143: The call 'Elixir.EVM.Gas':operation_cost(atom(),_inputs@1::[integer()],_machine_state@1::#{'__struct__':='Elixir.EVM.MachineState', 'active_words':=integer(), 'gas':=integer(), 'last_return_data':=binary(), 'memory':=binary(), 'previously_active_words':=integer(), 'program_counter':=integer(), 'stack':=[integer()]},_exec_env@1::#{'__struct__':='Elixir.EVM.ExecEnv', 'account_interface':=atom(), 'address':=<<_:160>>, 'block_interface':=atom(), 'config':=atom(), 'data':=binary(), 'gas_price':=integer(), 'machine_code':=binary(), 'originator':=<<_:160>>, 'sender':=<<_:160>>, 'stack_depth':=integer(), 'static':=boolean(), 'value_in_wei':=integer()}) breaks the contract (atom(),['Elixir.EVM':val()],['Elixir.EVM':val()],'Elixir.EVM.MachineState':t()) -> t() | 'nil'
apps/evm/lib/evm/gas.ex:304: Function operation_cost/0 has no local return
apps/evm/lib/evm/gas.ex:304: The call 'Elixir.EVM.Gas':operation_cost('nil','nil','nil','nil') breaks the contract (atom(),['Elixir.EVM':val()],['Elixir.EVM':val()],'Elixir.EVM.MachineState':t()) -> t() | 'nil'
apps/evm/lib/evm/gas.ex:304: Function operation_cost/1 has no local return
apps/evm/lib/evm/gas.ex:304: The call 'Elixir.EVM.Gas':operation_cost(__@1::any(),'nil','nil','nil') breaks the contract (atom(),['Elixir.EVM':val()],['Elixir.EVM':val()],'Elixir.EVM.MachineState':t()) -> t() | 'nil'
apps/evm/lib/evm/gas.ex:304: Function operation_cost/2 has no local return
apps/evm/lib/evm/gas.ex:304: The call 'Elixir.EVM.Gas':operation_cost(__@1::any(),__@2::any(),'nil','nil') breaks the contract (atom(),['Elixir.EVM':val()],['Elixir.EVM':val()],'Elixir.EVM.MachineState':t()) -> t() | 'nil'
apps/evm/lib/evm/gas.ex:304: Function operation_cost/3 has no local return
apps/evm/lib/evm/gas.ex:304: The call 'Elixir.EVM.Gas':operation_cost(__@1::any(),__@2::any(),__@3::any(),'nil') breaks the contract (atom(),['Elixir.EVM':val()],['Elixir.EVM':val()],'Elixir.EVM.MachineState':t()) -> t() | 'nil'
apps/evm/lib/evm/gas.ex:566: Function gas_cost_for_nested_operation/2 will never be called
apps/evm/lib/evm/gas.ex:308: Function operation_cost/0 has no local return
apps/evm/lib/evm/gas.ex:308: The call 'Elixir.EVM.Gas':operation_cost('nil','nil','nil','nil') breaks the contract (atom(),['Elixir.EVM':val()],['Elixir.EVM':val()],'Elixir.EVM.MachineState':t()) -> t() | 'nil'
apps/evm/lib/evm/gas.ex:308: Function operation_cost/1 has no local return
apps/evm/lib/evm/gas.ex:308: The call 'Elixir.EVM.Gas':operation_cost(__@1::any(),'nil','nil','nil') breaks the contract (atom(),['Elixir.EVM':val()],['Elixir.EVM':val()],'Elixir.EVM.MachineState':t()) -> t() | 'nil'
apps/evm/lib/evm/gas.ex:308: Function operation_cost/2 has no local return
apps/evm/lib/evm/gas.ex:308: The call 'Elixir.EVM.Gas':operation_cost(__@1::any(),__@2::any(),'nil','nil') breaks the contract (atom(),['Elixir.EVM':val()],['Elixir.EVM':val()],'Elixir.EVM.MachineState':t()) -> t() | 'nil'
apps/evm/lib/evm/gas.ex:308: Function operation_cost/3 has no local return
apps/evm/lib/evm/gas.ex:308: The call 'Elixir.EVM.Gas':operation_cost(__@1::any(),__@2::any(),__@3::any(),'nil') breaks the contract (atom(),['Elixir.EVM':val()],['Elixir.EVM':val()],'Elixir.EVM.MachineState':t()) -> t() | 'nil'
apps/evm/lib/evm/gas.ex:573: Function gas_cost_for_nested_operation/2 will never be called
apps/evm/lib/evm/machine_state.ex:53: Function subtract_gas/2 has no local return
apps/evm/lib/evm/operation/environmental_information.ex:114: Function calldataload/2 has no local return
apps/evm/lib/evm/operation/environmental_information.ex:117: The call 'Elixir.EVM.Helpers':decode_signed(binary()) breaks the contract (integer() | 'nil') -> 'Elixir.EVM':val() | 'nil'
Expand Down
14 changes: 12 additions & 2 deletions apps/blockchain/lib/blockchain/contract/create_contract.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule Blockchain.Contract.CreateContract do
init_code: <<>>,
stack_depth: 0,
block_header: nil,
new_account_address: nil,
config: EVM.Configuration.Frontier.new()

@typedoc """
Expand All @@ -42,13 +43,13 @@ defmodule Blockchain.Contract.CreateContract do
init_code: EVM.MachineCode.t(),
stack_depth: integer(),
block_header: Header.t(),
new_account_address: nil | EVM.address(),
config: EVM.Configuration.t()
}

@spec execute(t()) :: {:ok | :error, {EVM.state(), EVM.Gas.t(), EVM.SubState.t()}}
def execute(params) do
sender_account = Account.get_account(params.state, params.sender)
contract_address = Account.Address.new(params.sender, sender_account.nonce)
contract_address = new_account_address(params)
account = Account.get_account(params.state, contract_address)

if Account.exists?(account) do
Expand Down Expand Up @@ -198,4 +199,13 @@ defmodule Blockchain.Contract.CreateContract do

data_size * Gas.codedeposit_cost()
end

defp new_account_address(params) do
if params.new_account_address do
params.new_account_address
else
sender_account = Account.get_account(params.state, params.sender)
Account.Address.new(params.sender, sender_account.nonce)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ defimpl EVM.Interface.AccountInterface, for: Blockchain.Interface.AccountInterfa
...> |> MerklePatriciaTree.Trie.new()
...> |> Blockchain.Account.put_account(<<0x10::160>>, %Blockchain.Account{balance: 11, nonce: 5})
...> |> Blockchain.Interface.AccountInterface.new()
...> |> EVM.Interface.AccountInterface.create_contract(<<0x10::160>>, <<0x10::160>>, 1000, 1, 5, EVM.MachineCode.compile([:push1, 3, :push1, 5, :add, :push1, 0x00, :mstore, :push1, 32, :push1, 0, :return]), 5, %Block.Header{nonce: 1}, EVM.Configuration.Frontier.new())
...> |> EVM.Interface.AccountInterface.create_contract(<<0x10::160>>, <<0x10::160>>, 1000, 1, 5, EVM.MachineCode.compile([:push1, 3, :push1, 5, :add, :push1, 0x00, :mstore, :push1, 32, :push1, 0, :return]), 5, %Block.Header{nonce: 1}, nil, EVM.Configuration.Frontier.new())
iex> account_interface.state.root_hash
<<226, 121, 240, 77, 157, 98, 127, 111, 137, 201, 186, 41, 100, 239,
227, 209, 92, 247, 21, 58, 119, 4, 191, 255, 84, 144, 86, 99, 178,
Expand All @@ -382,6 +382,7 @@ defimpl EVM.Interface.AccountInterface, for: Blockchain.Interface.AccountInterfa
EVM.MachineCode.t(),
integer(),
Block.Header.t(),
EVM.address() | nil,
EVM.Configuration.t()
) :: {:ok | :error, {AccountInterface.t(), EVM.Gas.t(), EVM.SubState.t()}}
def create_contract(
Expand All @@ -394,6 +395,7 @@ defimpl EVM.Interface.AccountInterface, for: Blockchain.Interface.AccountInterfa
init_code,
stack_depth,
block_header,
new_account_address,
config
) do
sender = Account.Address.from(evm_sender)
Expand All @@ -409,6 +411,7 @@ defimpl EVM.Interface.AccountInterface, for: Blockchain.Interface.AccountInterfa
init_code: init_code,
stack_depth: stack_depth,
block_header: block_header,
new_account_address: new_account_address,
config: config
}

Expand Down
22 changes: 0 additions & 22 deletions apps/blockchain/test/blockchain/state_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ defmodule Blockchain.StateTest do
"stZeroKnowledge2/ecmul_0-3_5616_28000_96"
],
"Constantinople" => [
"stCreate2/CREATE2_ContractSuicideDuringInit_ThenStoreThenReturn",
"stCreate2/CREATE2_Suicide",
"stCreate2/Create2OOGafterInitCode",
"stCreate2/Create2OOGafterInitCodeReturndata2",
"stCreate2/Create2OOGafterInitCodeReturndataSize",
"stCreate2/Create2OOGafterInitCodeRevert",
"stCreate2/Create2OOGafterInitCodeRevert2",
"stCreate2/Create2OnDepth1023",
"stCreate2/Create2OnDepth1024",
"stCreate2/Create2Recursive",
"stCreate2/CreateMessageReverted",
"stCreate2/CreateMessageRevertedOOGInInit",
"stCreate2/RevertDepthCreate2OOG",
"stCreate2/RevertDepthCreateAddressCollision",
"stCreate2/RevertInCreateInInit",
Expand All @@ -58,18 +46,8 @@ defmodule Blockchain.StateTest do
"stCreate2/create2callPrecompiles",
"stCreate2/create2checkFieldsInInitcode",
"stCreate2/create2collisionBalance",
"stCreate2/create2collisionCode",
"stCreate2/create2collisionCode2",
"stCreate2/create2collisionNonce",
"stCreate2/create2collisionSelfdestructed",
"stCreate2/create2collisionSelfdestructed2",
"stCreate2/create2collisionSelfdestructedRevert",
"stCreate2/create2collisionStorage",
"stCreate2/create2noCash",
"stCreate2/returndatacopy_0_0_following_successful_create",
"stCreate2/returndatacopy_afterFailing_create",
"stCreate2/returndatacopy_following_revert_in_create",
"stCreate2/returndatasize_following_successful_create",
"stRevertTest/RevertOpcodeMultipleSubCalls",
"stZeroKnowledge2/ecmul_0-3_5616_28000_96"
],
Expand Down
58 changes: 1 addition & 57 deletions apps/blockchain/test/blockchain_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,6 @@ defmodule BlockchainTest do
],
"Byzantium" => String.split(@failing_byzantium_tests, "\n"),
"Constantinople" => [
"GeneralStateTests/stCreate2/CREATE2_ContractSuicideDuringInit_ThenStoreThenReturn_d0g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d0g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d10g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d11g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d1g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d2g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d3g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d4g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d5g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d6g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d7g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d8g0v0.json",
"GeneralStateTests/stCreate2/CREATE2_Suicide_d9g0v0.json",
"GeneralStateTests/stCreate2/Create2OOGafterInitCodeReturndata2_d0g1v0.json",
"GeneralStateTests/stCreate2/Create2OOGafterInitCodeReturndataSize_d0g0v0.json",
"GeneralStateTests/stCreate2/Create2OOGafterInitCodeRevert2_d0g0v0.json",
"GeneralStateTests/stCreate2/Create2OOGafterInitCodeRevert_d0g0v0.json",
"GeneralStateTests/stCreate2/Create2OOGafterInitCode_d0g0v0.json",
"GeneralStateTests/stCreate2/Create2OOGafterInitCode_d0g1v0.json",
"GeneralStateTests/stCreate2/Create2OnDepth1023_d0g0v0.json",
"GeneralStateTests/stCreate2/Create2OnDepth1024_d0g0v0.json",
"GeneralStateTests/stCreate2/Create2Recursive_d0g0v0.json",
Expand Down Expand Up @@ -70,25 +51,12 @@ defmodule BlockchainTest do
"GeneralStateTests/stCreate2/RevertOpcodeInCreateReturns_d0g0v0.json",
"GeneralStateTests/stCreate2/call_outsize_then_create2_successful_then_returndatasize_d0g0v0.json",
"GeneralStateTests/stCreate2/call_then_create2_successful_then_returndatasize_d0g0v0.json",
"GeneralStateTests/stCreate2/create2InitCodes_d0g0v0.json",
"GeneralStateTests/stCreate2/create2InitCodes_d1g0v0.json",
"GeneralStateTests/stCreate2/create2InitCodes_d2g0v0.json",
"GeneralStateTests/stCreate2/create2InitCodes_d3g0v0.json",
"GeneralStateTests/stCreate2/create2InitCodes_d4g0v0.json",
"GeneralStateTests/stCreate2/create2InitCodes_d5g0v0.json",
"GeneralStateTests/stCreate2/create2InitCodes_d6g0v0.json",
"GeneralStateTests/stCreate2/create2InitCodes_d7g0v0.json",
"GeneralStateTests/stCreate2/create2InitCodes_d8g0v0.json",
"GeneralStateTests/stCreate2/create2SmartInitCode_d0g0v0.json",
"GeneralStateTests/stCreate2/create2SmartInitCode_d1g0v0.json",
"GeneralStateTests/stCreate2/create2callPrecompiles_d0g0v0.json",
"GeneralStateTests/stCreate2/create2callPrecompiles_d1g0v0.json",
"GeneralStateTests/stCreate2/create2callPrecompiles_d2g0v0.json",
"GeneralStateTests/stCreate2/create2callPrecompiles_d3g0v0.json",
"GeneralStateTests/stCreate2/create2callPrecompiles_d4g0v0.json",
"GeneralStateTests/stCreate2/create2callPrecompiles_d5g0v0.json",
"GeneralStateTests/stCreate2/create2callPrecompiles_d6g0v0.json",
"GeneralStateTests/stCreate2/create2callPrecompiles_d7g0v0.json",
"GeneralStateTests/stCreate2/create2checkFieldsInInitcode_d0g0v0.json",
"GeneralStateTests/stCreate2/create2checkFieldsInInitcode_d1g0v0.json",
"GeneralStateTests/stCreate2/create2checkFieldsInInitcode_d2g0v0.json",
Expand All @@ -97,32 +65,9 @@ defmodule BlockchainTest do
"GeneralStateTests/stCreate2/create2checkFieldsInInitcode_d5g0v0.json",
"GeneralStateTests/stCreate2/create2checkFieldsInInitcode_d6g0v0.json",
"GeneralStateTests/stCreate2/create2checkFieldsInInitcode_d7g0v0.json",
"GeneralStateTests/stCreate2/create2collisionBalance_d0g0v0.json",
"GeneralStateTests/stCreate2/create2collisionBalance_d1g0v0.json",
"GeneralStateTests/stCreate2/create2collisionBalance_d2g0v0.json",
"GeneralStateTests/stCreate2/create2collisionBalance_d3g0v0.json",
"GeneralStateTests/stCreate2/create2collisionCode2_d0g0v0.json",
"GeneralStateTests/stCreate2/create2collisionCode2_d1g0v0.json",
"GeneralStateTests/stCreate2/create2collisionCode_d0g0v0.json",
"GeneralStateTests/stCreate2/create2collisionCode_d1g0v0.json",
"GeneralStateTests/stCreate2/create2collisionCode_d2g0v0.json",
"GeneralStateTests/stCreate2/create2collisionNonce_d0g0v0.json",
"GeneralStateTests/stCreate2/create2collisionNonce_d1g0v0.json",
"GeneralStateTests/stCreate2/create2collisionNonce_d2g0v0.json",
"GeneralStateTests/stCreate2/create2collisionSelfdestructed2_d0g0v0.json",
"GeneralStateTests/stCreate2/create2collisionSelfdestructed2_d1g0v0.json",
"GeneralStateTests/stCreate2/create2collisionSelfdestructedRevert_d0g0v0.json",
"GeneralStateTests/stCreate2/create2collisionSelfdestructedRevert_d1g0v0.json",
"GeneralStateTests/stCreate2/create2collisionSelfdestructedRevert_d2g0v0.json",
"GeneralStateTests/stCreate2/create2collisionSelfdestructed_d0g0v0.json",
"GeneralStateTests/stCreate2/create2collisionSelfdestructed_d1g0v0.json",
"GeneralStateTests/stCreate2/create2collisionSelfdestructed_d2g0v0.json",
"GeneralStateTests/stCreate2/create2collisionStorage_d0g0v0.json",
"GeneralStateTests/stCreate2/create2collisionStorage_d1g0v0.json",
"GeneralStateTests/stCreate2/create2collisionStorage_d2g0v0.json",
"GeneralStateTests/stCreate2/create2noCash_d0g0v0.json",
"GeneralStateTests/stCreate2/create2noCash_d1g0v0.json",
"GeneralStateTests/stCreate2/returndatacopy_0_0_following_successful_create_d0g0v0.json",
"GeneralStateTests/stCreate2/returndatacopy_afterFailing_create_d0g0v0.json",
"GeneralStateTests/stCreate2/returndatacopy_following_revert_in_create_d0g0v0.json",
"GeneralStateTests/stCreate2/returndatacopy_following_successful_create_d0g0v0.json",
Expand All @@ -133,8 +78,7 @@ defmodule BlockchainTest do
"GeneralStateTests/stReturnDataTest/modexp_modsize0_returndatasize_d0g3v0.json",
"GeneralStateTests/stSpecialTest/push32withoutByte_d0g0v0.json",
"bcStateTests/blockhashNonConstArg.json",
"bcStateTests/create2collisionwithSelfdestructSameBlock.json",
"bcStateTests/suicideStorageCheckVCreate2.json"
"bcStateTests/create2collisionwithSelfdestructSameBlock.json"
],
# the rest are not implemented yet
"EIP158ToByzantiumAt5" => [],
Expand Down
32 changes: 32 additions & 0 deletions apps/evm/lib/evm/address.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,38 @@ defmodule EVM.Address do
|> EVM.Helpers.take_n_last_bytes(@size)
end

@doc """
Returns an address for create2 opcode.
"""
@spec new(integer() | binary(), integer() | binary(), binary() | integer()) :: binary()
def new(address, salt, init_code) do
binary_address = new(address)

new_address_start = <<255>>

binary_salt =
if is_binary(salt) do
EVM.Helpers.left_pad_bytes(salt, 32)
else
salt
|> :binary.encode_unsigned()
|> EVM.Helpers.left_pad_bytes(32)
end

binary_init_code =
if is_binary(init_code) do
init_code
else
:binary.encode_unsigned(init_code)
end

code_hash = Keccak.kec(binary_init_code)

(new_address_start <> binary_address <> binary_salt <> code_hash)
|> Keccak.kec()
|> EVM.Helpers.take_n_last_bytes(@size)
end

@doc """
Returns an address given a private key
## Examples
Expand Down
4 changes: 4 additions & 0 deletions apps/evm/lib/evm/configuration.ex
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,8 @@ defprotocol EVM.Configuration do
# EIP1052
@spec has_extcodehash?(t) :: boolean()
def has_extcodehash?(t)

# EIP1014
@spec has_create2?(t) :: boolean()
def has_create2?(t)
end
3 changes: 3 additions & 0 deletions apps/evm/lib/evm/configuration/byzantium.ex
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,7 @@ defimpl EVM.Configuration, for: EVM.Configuration.Byzantium do

@spec has_extcodehash?(Configuration.t()) :: boolean()
def has_extcodehash?(config), do: Configuration.has_extcodehash?(config.fallback_config)

@spec has_create2?(Configuration.t()) :: boolean()
def has_create2?(config), do: Configuration.has_create2?(config.fallback_config)
end
6 changes: 5 additions & 1 deletion apps/evm/lib/evm/configuration/constantinople.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
defmodule EVM.Configuration.Constantinople do
defstruct fallback_config: EVM.Configuration.Byzantium.new(),
has_shift_operations: true,
has_extcodehash: true
has_extcodehash: true,
has_create2: true

def new do
%__MODULE__{}
Expand Down Expand Up @@ -96,4 +97,7 @@ defimpl EVM.Configuration, for: EVM.Configuration.Constantinople do

@spec has_extcodehash?(Configuration.t()) :: boolean()
def has_extcodehash?(config), do: config.has_extcodehash

@spec has_create2?(Configuration.t()) :: boolean()
def has_create2?(config), do: config.has_create2
end
3 changes: 3 additions & 0 deletions apps/evm/lib/evm/configuration/eip150.ex
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,7 @@ defimpl EVM.Configuration, for: EVM.Configuration.EIP150 do

@spec has_extcodehash?(Configuration.t()) :: boolean()
def has_extcodehash?(config), do: Configuration.has_extcodehash?(config.fallback_config)

@spec has_create2?(Configuration.t()) :: boolean()
def has_create2?(config), do: Configuration.has_create2?(config.fallback_config)
end
3 changes: 3 additions & 0 deletions apps/evm/lib/evm/configuration/eip158.ex
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,7 @@ defimpl EVM.Configuration, for: EVM.Configuration.EIP158 do

@spec has_extcodehash?(Configuration.t()) :: boolean()
def has_extcodehash?(config), do: Configuration.has_extcodehash?(config.fallback_config)

@spec has_create2?(Configuration.t()) :: boolean()
def has_create2?(config), do: Configuration.has_create2?(config.fallback_config)
end
6 changes: 5 additions & 1 deletion apps/evm/lib/evm/configuration/frontier.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ defmodule EVM.Configuration.Frontier do
has_ec_mult_builtin: false,
has_ec_pairing_builtin: false,
has_shift_operations: false,
has_extcodehash: false
has_extcodehash: false,
has_create2: false

def new do
%__MODULE__{}
Expand Down Expand Up @@ -108,4 +109,7 @@ defimpl EVM.Configuration, for: EVM.Configuration.Frontier do

@spec has_extcodehash?(Configuration.t()) :: boolean()
def has_extcodehash?(config), do: config.has_extcodehash

@spec has_create2?(Configuration.t()) :: boolean()
def has_create2?(config), do: config.has_create2
end
3 changes: 3 additions & 0 deletions apps/evm/lib/evm/configuration/homestead.ex
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ defimpl EVM.Configuration, for: EVM.Configuration.Homestead do

@spec has_extcodehash?(Configuration.t()) :: boolean()
def has_extcodehash?(config), do: Configuration.has_extcodehash?(config.fallback_config)

@spec has_create2?(Configuration.t()) :: boolean()
def has_create2?(config), do: Configuration.has_create2?(config.fallback_config)
end
Loading

0 comments on commit 88ce5f0

Please sign in to comment.