Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eip160 change byte cost for exp op #346

Merged
merged 3 commits into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions .dialyzer.ignore-warnings
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,18 @@
apps/evm/lib/evm/functions.ex:154: Function 'not_enough_gas?'/2 has no local return
apps/evm/lib/evm/functions.ex:166: Function 'is_invalid_jump_destination?'/3 will never be called
apps/evm/lib/evm/functions.ex:180: Function 'is_invalid_jump_destination?'/3 will never be called
apps/evm/lib/evm/gas.ex:135: Function cost/2 has no local return
apps/evm/lib/evm/gas.ex:135: Function cost/3 has no local return
apps/evm/lib/evm/gas.ex:140: 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':=[integer
()], '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(), 'value_in_wei':=integer()}) breaks the contract (atom(),['Elixir.E
VM':val()],['Elixir.EVM':val()],'Elixir.EVM.MachineState':t()) -> t() | 'nil'
apps/evm/lib/evm/gas.ex:299: Function operation_cost/0 has no local return
apps/evm/lib/evm/gas.ex:299: 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:299: Function operation_cost/1 has no local return
apps/evm/lib/evm/gas.ex:299: 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:299: Function operation_cost/2 has no local return
apps/evm/lib/evm/gas.ex:299: 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:299: Function operation_cost/3 has no local return
apps/evm/lib/evm/gas.ex:299: 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:528: Function gas_cost_for_nested_operation/2 will never be called
apps/evm/lib/evm/gas.ex:133: Function cost/2 has no local return
apps/evm/lib/evm/gas.ex:133: Function cost/3 has no local return
apps/evm/lib/evm/gas.ex:138: 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':=[integer()], '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(), 'created_accounts':=[<<_:160>>], 'data':=binary(), 'gas_price':=integer(), 'initial_account_interface':=_, 'machine_code':=binary(), 'originator':=<<_:160>>, 'sender':=<<_:160>>, 'stack_depth':=integer(), '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:297: Function operation_cost/0 has no local return
apps/evm/lib/evm/gas.ex:297: 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:297: Function operation_cost/1 has no local return
apps/evm/lib/evm/gas.ex:297: 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:297: Function operation_cost/2 has no local return
apps/evm/lib/evm/gas.ex:297: 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:297: Function operation_cost/3 has no local return
apps/evm/lib/evm/gas.ex:297: 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:526: 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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,10 @@ Ethereum common tests are created for all clients to test against. We plan to pr
- [GeneralStateTests](https://github.com/ethereum/tests/tree/develop/GeneralStateTests) 2024/2062 = 98.2% passing
- [x] EIP150
- [BlockchainTests](https://github.com/ethereum/tests/tree/develop/BlockchainTests) (Includes GeneralStateTests) 1274/1275 = 99.9% passing
- [GeneralStateTests](https://github.com/ethereum/tests/tree/develop/GeneralStateTests) 1088/1114= 97.7% passing
- [ ] EIP158
- [GeneralStateTests](https://github.com/ethereum/tests/tree/develop/GeneralStateTests) 1088/1114 = 97.7% passing
- [x] EIP158
- [BlockchainTests](https://github.com/ethereum/tests/tree/develop/BlockchainTests) (Includes GeneralStateTests) 1031/1233 = 83.6%
- [GeneralStateTests](https://github.com/ethereum/tests/tree/develop/GeneralStateTests) 859/1181 = 72.7% passing
- [ ] Byzantium
- [ ] Constantinople: View the community [Constantinople Project Tracker](https://github.com/ethereum/pm/issues/53).
Expand Down
9 changes: 8 additions & 1 deletion apps/blockchain/scripts/generate_blockchain_tests.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ defmodule GenerateBlockchainTests do
def run(args) do
hardfork = List.first(args)

if !Enum.member?(["Frontier", "Homestead", "EIP150"], hardfork), do: raise(RuntimeError)
if !Enum.member?(["Frontier", "Homestead", "EIP150", "EIP158"], hardfork),
do: raise(RuntimeError)

{passing_count, failing_count} =
Enum.reduce(
Expand Down Expand Up @@ -105,6 +106,9 @@ defmodule GenerateBlockchainTests do
"EIP150" ->
Chain.load_chain(:eip150_test, config)

"EIP158" ->
Chain.load_chain(:eip150_test, config)

_ ->
nil
end
Expand All @@ -121,6 +125,9 @@ defmodule GenerateBlockchainTests do
"EIP150" ->
EVM.Configuration.EIP150.new()

"EIP158" ->
EVM.Configuration.EIP158.new()

_ ->
nil
end
Expand Down
13 changes: 10 additions & 3 deletions apps/blockchain/scripts/generate_state_tests.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ defmodule GenerateStateTests do

use EthCommonTest.Harness

@hardforks ["EIP158", "EIP150", "Homestead", "Frontier"]

def run(_args) do
initial_state = %{
passing: %{
"Homestead" => [],
"Frontier" => [],
"EIP150" => []
"EIP150" => [],
"EIP158" => []
},
failing: %{
"Homestead" => [],
"Frontier" => [],
"EIP150" => []
"EIP150" => [],
"EIP158" => []
}
}

Expand Down Expand Up @@ -46,7 +50,7 @@ defmodule GenerateStateTests do
IO.puts("Failing tests")
IO.puts(inspect(failing_tests, limit: :infinity))

for hardfork <- ["EIP150", "Homestead", "Frontier"] do
for hardfork <- @hardforks do
passing_tests = length(completed_tests[:passing][hardfork])
failing_tests = length(completed_tests[:failing][hardfork])
total_tests = passing_tests + failing_tests
Expand Down Expand Up @@ -172,6 +176,9 @@ defmodule GenerateStateTests do
"EIP150" ->
EVM.Configuration.EIP150.new()

"EIP158" ->
EVM.Configuration.EIP158.new()

_ ->
nil
end
Expand Down
187 changes: 187 additions & 0 deletions apps/blockchain/test/blockchain/state_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,190 @@ defmodule Blockchain.StateTest do
"stInitCodeTest/OutOfGasContractCreation",
"stInitCodeTest/NotEnoughCashContractCreation"
],
"EIP158" => [
"stZeroCallsTest/ZeroValue_TransactionCALLwithData_ToOneStorageKey",
"stZeroCallsTest/ZeroValue_TransactionCALLwithData_ToEmpty",
"stZeroCallsTest/ZeroValue_TransactionCALLwithData",
"stZeroCallsTest/ZeroValue_TransactionCALL_ToOneStorageKey",
"stZeroCallsTest/ZeroValue_TransactionCALL_ToEmpty",
"stZeroCallsTest/ZeroValue_TransactionCALL",
"stZeroCallsTest/ZeroValue_SUICIDE_ToOneStorageKey",
"stZeroCallsTest/ZeroValue_SUICIDE_ToNonZeroBalance",
"stZeroCallsTest/ZeroValue_SUICIDE_ToEmpty",
"stZeroCallsTest/ZeroValue_SUICIDE",
"stZeroCallsTest/ZeroValue_CALL_ToOneStorageKey",
"stZeroCallsTest/ZeroValue_CALL_ToEmpty",
"stZeroCallsTest/ZeroValue_CALL",
"stWalletTest/walletConstructionPartial",
"stWalletTest/walletConstructionOOG",
"stWalletTest/walletConstruction",
"stWalletTest/multiOwnedConstructionCorrect",
"stWalletTest/dayLimitConstructionPartial",
"stWalletTest/dayLimitConstruction",
"stTransitionTest/createNameRegistratorPerTxsBefore",
"stTransitionTest/createNameRegistratorPerTxsAt",
"stTransitionTest/createNameRegistratorPerTxsAfter",
"stTransactionTest/UserTransactionZeroCostWithData",
"stTransactionTest/UserTransactionZeroCost",
"stTransactionTest/TransactionSendingToEmpty",
"stTransactionTest/TransactionDataCosts652",
"stTransactionTest/SuicidesStopAfterSuicide",
"stTransactionTest/SuicidesMixingCoinbase",
"stTransactionTest/SuicidesAndSendMoneyToItselfEtherDestroyed",
"stTransactionTest/SuicidesAndInternlCallSuicidesSuccess",
"stTransactionTest/SuicidesAndInternlCallSuicidesOOG",
"stTransactionTest/SuicidesAndInternlCallSuicidesBonusGasAtCallFailed",
"stTransactionTest/SuicidesAndInternlCallSuicidesBonusGasAtCall",
"stTransactionTest/StoreGasOnCreate",
"stTransactionTest/OverflowGasRequire2",
"stTransactionTest/Opcodes_TransactionInit",
"stTransactionTest/EmptyTransaction3",
"stTransactionTest/EmptyTransaction2",
"stTransactionTest/CreateTransactionSuccess",
"stTransactionTest/CreateMessageSuccess",
"stSystemOperationsTest/testRandomTest",
"stSystemOperationsTest/suicideSendEtherToMe",
"stSystemOperationsTest/suicideSendEtherPostDeath",
"stSystemOperationsTest/suicideOrigin",
"stSystemOperationsTest/suicideNotExistingAccount",
"stSystemOperationsTest/suicideCoinbase",
"stSystemOperationsTest/suicideCallerAddresTooBigRight",
"stSystemOperationsTest/suicideCallerAddresTooBigLeft",
"stSystemOperationsTest/suicideCaller",
"stSystemOperationsTest/suicideAddress",
"stSystemOperationsTest/extcodecopy",
"stSystemOperationsTest/doubleSelfdestructTest2",
"stSystemOperationsTest/doubleSelfdestructTest",
"stSystemOperationsTest/createNameRegistratorZeroMemExpansion",
"stSystemOperationsTest/createNameRegistratorZeroMem2",
"stSystemOperationsTest/createNameRegistratorZeroMem",
"stSystemOperationsTest/createNameRegistrator",
"stSystemOperationsTest/CreateHashCollision",
"stSystemOperationsTest/ABAcallsSuicide1",
"stSystemOperationsTest/ABAcallsSuicide0",
"stSpecialTest/tx_e1c174e2",
"stSpecialTest/failed_tx_xcf416c53",
"stSpecialTest/deploymentError",
"stSpecialTest/StackDepthLimitSEC",
"stSolidityTest/RecursiveCreateContractsCreate4Contracts",
"stSolidityTest/RecursiveCreateContracts",
"stSolidityTest/CreateContractFromMethod",
"stRevertTest/TouchToEmptyAccountRevert3",
"stRevertTest/RevertRemoteSubCallStorageOOG2",
"stRevertTest/RevertRemoteSubCallStorageOOG",
"stRevertTest/RevertPrefoundEmptyCall",
"stRevertTest/RevertPrefoundEmpty",
"stRevertTest/RevertPrefound",
"stRevertTest/RevertOpcodeMultipleSubCalls",
"stRevertTest/RevertDepthCreateOOG",
"stRevertTest/NashatyrevSuicideRevert",
"stRevertTest/LoopCallsDepthThenRevert3",
"stRevertTest/LoopCallsDepthThenRevert2",
"stRefundTest/refund_singleSuicide",
"stRefundTest/refund_multimpleSuicide",
"stRefundTest/refund_TxToSuicide",
"stRefundTest/refund_CallToSuicideTwice",
"stRefundTest/refund_CallToSuicideStorage",
"stRefundTest/refund_CallToSuicideNoStorage",
"stRefundTest/refundSuicide50procentCap",
"stRecursiveCreate/recursiveCreateReturnValue",
"stRecursiveCreate/recursiveCreate",
"stQuadraticComplexityTest/Create1000Byzantium",
"stQuadraticComplexityTest/Create1000",
"stPreCompiledContracts2/CallSha256_5",
"stPreCompiledContracts2/CallSha256_4_gas99",
"stPreCompiledContracts2/CallSha256_4",
"stPreCompiledContracts2/CallSha256_3_prefix0",
"stPreCompiledContracts2/CallSha256_3_postfix0",
"stPreCompiledContracts2/CallSha256_3",
"stPreCompiledContracts2/CallSha256_2",
"stPreCompiledContracts2/CallSha256_1",
"stPreCompiledContracts2/CallSha256_0",
"stPreCompiledContracts2/CallRipemd160_5",
"stPreCompiledContracts2/CallRipemd160_4_gas719",
"stPreCompiledContracts2/CallRipemd160_4",
"stPreCompiledContracts2/CallRipemd160_3_prefixed0",
"stPreCompiledContracts2/CallRipemd160_3_postfixed0",
"stPreCompiledContracts2/CallRipemd160_3",
"stPreCompiledContracts2/CallRipemd160_2",
"stPreCompiledContracts2/CallRipemd160_1",
"stPreCompiledContracts2/CallRipemd160_0",
"stPreCompiledContracts2/CallIdentity_5",
"stPreCompiledContracts2/CallIdentity_4_gas18",
"stPreCompiledContracts2/CallIdentity_4_gas17",
"stPreCompiledContracts2/CallIdentity_4",
"stPreCompiledContracts2/CallIdentity_3",
"stPreCompiledContracts2/CallIdentity_2",
"stPreCompiledContracts2/CallIdentitiy_1",
"stPreCompiledContracts2/CallIdentitiy_0",
"stPreCompiledContracts2/CallEcrecoverV_prefixed0",
"stPreCompiledContracts2/CallEcrecoverS_prefixed0",
"stPreCompiledContracts2/CallEcrecoverR_prefixed0",
"stPreCompiledContracts2/CallEcrecoverH_prefixed0",
"stPreCompiledContracts2/CallEcrecoverCheckLengthWrongV",
"stPreCompiledContracts2/CallEcrecoverCheckLength",
"stPreCompiledContracts2/CallEcrecover80",
"stPreCompiledContracts2/CallEcrecover3",
"stPreCompiledContracts2/CallEcrecover2",
"stPreCompiledContracts2/CallEcrecover1",
"stPreCompiledContracts2/CallEcrecover0_overlappingInputOutput",
"stPreCompiledContracts2/CallEcrecover0_gas3000",
"stPreCompiledContracts2/CallEcrecover0_completeReturnValue",
"stPreCompiledContracts2/CallEcrecover0_Gas2999",
"stPreCompiledContracts2/CallEcrecover0_0input",
"stPreCompiledContracts2/CallEcrecover0",
"stNonZeroCallsTest/NonZeroValue_SUICIDE_ToOneStorageKey",
"stNonZeroCallsTest/NonZeroValue_SUICIDE_ToNonNonZeroBalance",
"stNonZeroCallsTest/NonZeroValue_SUICIDE_ToEmpty",
"stNonZeroCallsTest/NonZeroValue_SUICIDE",
"stNonZeroCallsTest/NonZeroValue_CALL_ToOneStorageKey",
"stNonZeroCallsTest/NonZeroValue_CALL_ToEmpty",
"stMemExpandingEIP150Calls/NewGasPriceForCodesWithMemExpandingCalls",
"stMemExpandingEIP150Calls/CreateAndGasInsideCreateWithMemExpandingCalls",
"stInitCodeTest/TransactionCreateStopInInitcode",
"stInitCodeTest/TransactionCreateAutoSuicideContract",
"stInitCodeTest/OutOfGasContractCreation",
"stInitCodeTest/CallTheContractToCreateEmptyContract",
"stInitCodeTest/CallRecursiveContract",
"stInitCodeTest/CallContractToCreateContractWhichWouldCreateContractInInitCode",
"stInitCodeTest/CallContractToCreateContractWhichWouldCreateContractIfCalled",
"stInitCodeTest/CallContractToCreateContractOOGBonusGas",
"stInitCodeTest/CallContractToCreateContractOOG",
"stInitCodeTest/CallContractToCreateContractAndCallItOOG",
"stEIP158Specific/vitalikTransactionTest",
"stEIP158Specific/CALL_ZeroVCallSuicide",
"stEIP158Specific/CALL_OneVCallSuicide",
"stDelegatecallTestHomestead/delegatecodeDynamicCode",
"stCreateTest/TransactionCollisionToEmpty",
"stCreateTest/CreateCollisionToEmpty",
"stCreateTest/CREATE_empty000CreateinInitCode_Transaction",
"stCreateTest/CREATE_EmptyContractWithStorageAndCallIt_1wei",
"stCreateTest/CREATE_EmptyContractWithStorageAndCallIt_0wei",
"stCreateTest/CREATE_EmptyContractWithStorage",
"stCreateTest/CREATE_EmptyContractWithBalance",
"stCreateTest/CREATE_EmptyContractAndCallIt_1wei",
"stCreateTest/CREATE_EmptyContractAndCallIt_0wei",
"stCreateTest/CREATE_EmptyContract",
"stCreateTest/CREATE_EContract_ThenCALLToNonExistentAcc",
"stCreateTest/CREATE_EContractCreateNEContractInInit_Tr",
"stCreateTest/CREATE_EContractCreateNEContractInInitOOG_Tr",
"stCreateTest/CREATE_EContractCreateEContractInInit_Tr",
"stCreateTest/CREATE_ContractSuicideDuringInit_WithValueToItself",
"stCreateTest/CREATE_ContractSuicideDuringInit_WithValue",
"stCreateTest/CREATE_ContractSuicideDuringInit_ThenStoreThenReturn",
"stCreateTest/CREATE_ContractSuicideDuringInit",
"stCreateTest/CREATE_ContractSSTOREDuringInit",
"stCreateTest/CREATE_AcreateB_BSuicide_BStore",
"stCodeSizeLimit/codesizeValid",
"stCodeSizeLimit/codesizeOOGInvalidSize",
"stCodeSizeLimit/codesizeInit",
"stCallCreateCallCodeTest/createNameRegistratorPerTxs",
"stCallCodes/callcodeDynamicCode",
"stCallCodes/call_OOG_additionalGasCosts1",
"stBadOpcode/badOpcodes",
"stAttackTest/CrashingTransaction",
"stAttackTest/ContractCreationSpam"
],
"Frontier" => [
"stTransactionTest/UserTransactionGasLimitIsTooLowWhenZeroCost",
"stTransactionTest/TransactionToItselfNotEnoughFounds",
Expand Down Expand Up @@ -184,6 +368,9 @@ defmodule Blockchain.StateTest do
"EIP150" ->
EVM.Configuration.EIP150.new()

"EIP158" ->
EVM.Configuration.EIP158.new()

_ ->
nil
end
Expand Down
Loading