Merge pull request #550 from status-im/eip2929

EIP2929 implementation
This commit is contained in:
andri lim 2021-01-13 07:54:53 +07:00 committed by GitHub
commit 39723ee2fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 701 additions and 329 deletions

View File

@ -19,13 +19,13 @@ PrecompileTests
+ ecrecover.json OK
+ identity.json OK
+ modexp.json OK
+ modexp_eip2565.json OK
modexp_eip2565.json Skip
+ pairing.json OK
+ pairing_istanbul.json OK
+ ripemd160.json OK
+ sha256.json OK
```
OK: 22/22 Fail: 0/22 Skip: 0/22
OK: 21/22 Fail: 0/22 Skip: 1/22
---TOTAL---
OK: 22/22 Fail: 0/22 Skip: 0/22
OK: 21/22 Fail: 0/22 Skip: 1/22

View File

@ -2253,20 +2253,20 @@ OK: 11/13 Fail: 0/13 Skip: 2/13
OK: 9/9 Fail: 0/9 Skip: 0/9
## stStaticCall
```diff
+ static_ABAcalls0.json OK
+ static_ABAcalls1.json OK
+ static_ABAcalls2.json OK
+ static_ABAcalls3.json OK
+ static_ABAcallsSuicide0.json OK
+ static_ABAcallsSuicide1.json OK
+ static_CALL_OneVCallSuicide.json OK
+ static_CALL_ZeroVCallSuicide.json OK
+ static_CREATE_ContractSuicideDuringInit.json OK
+ static_CREATE_ContractSuicideDuringInit_ThenStoreThenReturn.jso OK
+ static_CREATE_ContractSuicideDuringInit_WithValue.json OK
+ static_CREATE_EmptyContractAndCallIt_0wei.json OK
+ static_CREATE_EmptyContractWithStorageAndCallIt_0wei.json OK
+ static_Call10.json OK
static_ABAcalls0.json Skip
static_ABAcalls1.json Skip
static_ABAcalls2.json Skip
static_ABAcalls3.json Skip
static_ABAcallsSuicide0.json Skip
static_ABAcallsSuicide1.json Skip
static_CALL_OneVCallSuicide.json Skip
static_CALL_ZeroVCallSuicide.json Skip
static_CREATE_ContractSuicideDuringInit.json Skip
static_CREATE_ContractSuicideDuringInit_ThenStoreThenReturn.jso Skip
static_CREATE_ContractSuicideDuringInit_WithValue.json Skip
static_CREATE_EmptyContractAndCallIt_0wei.json Skip
static_CREATE_EmptyContractWithStorageAndCallIt_0wei.json Skip
static_Call10.json Skip
static_Call1024BalanceTooLow.json Skip
static_Call1024BalanceTooLow2.json Skip
static_Call1024OOG.json Skip
@ -2279,265 +2279,280 @@ OK: 9/9 Fail: 0/9 Skip: 0/9
static_Call50000_identity.json Skip
static_Call50000_identity2.json Skip
static_Call50000_rip160.json Skip
+ static_Call50000bytesContract50_1.json OK
+ static_Call50000bytesContract50_2.json OK
+ static_Call50000bytesContract50_3.json OK
+ static_CallAndCallcodeConsumeMoreGasThenTransactionHas.json OK
+ static_CallAskMoreGasOnDepth2ThenTransactionHas.json OK
+ static_CallContractToCreateContractAndCallItOOG.json OK
+ static_CallContractToCreateContractOOG.json OK
+ static_CallContractToCreateContractOOGBonusGas.json OK
+ static_CallContractToCreateContractWhichWouldCreateContractIfCa OK
+ static_CallEcrecover0.json OK
+ static_CallEcrecover0_0input.json OK
+ static_CallEcrecover0_Gas2999.json OK
+ static_CallEcrecover0_NoGas.json OK
+ static_CallEcrecover0_completeReturnValue.json OK
+ static_CallEcrecover0_gas3000.json OK
+ static_CallEcrecover0_overlappingInputOutput.json OK
+ static_CallEcrecover1.json OK
+ static_CallEcrecover2.json OK
+ static_CallEcrecover3.json OK
+ static_CallEcrecover80.json OK
+ static_CallEcrecoverCheckLength.json OK
+ static_CallEcrecoverCheckLengthWrongV.json OK
+ static_CallEcrecoverH_prefixed0.json OK
+ static_CallEcrecoverR_prefixed0.json OK
+ static_CallEcrecoverS_prefixed0.json OK
+ static_CallEcrecoverV_prefixed0.json OK
+ static_CallGoesOOGOnSecondLevel.json OK
+ static_CallGoesOOGOnSecondLevel2.json OK
+ static_CallIdentitiy_1.json OK
+ static_CallIdentity_1_nonzeroValue.json OK
+ static_CallIdentity_2.json OK
+ static_CallIdentity_3.json OK
+ static_CallIdentity_4.json OK
+ static_CallIdentity_4_gas17.json OK
+ static_CallIdentity_4_gas18.json OK
+ static_CallIdentity_5.json OK
+ static_CallLoseGasOOG.json OK
+ static_CallRecursiveBomb0.json OK
+ static_CallRecursiveBomb0_OOG_atMaxCallDepth.json OK
+ static_CallRecursiveBomb1.json OK
+ static_CallRecursiveBomb2.json OK
+ static_CallRecursiveBomb3.json OK
+ static_CallRecursiveBombLog.json OK
+ static_CallRecursiveBombLog2.json OK
+ static_CallRecursiveBombPreCall.json OK
+ static_CallRecursiveBombPreCall2.json OK
+ static_CallRipemd160_1.json OK
+ static_CallRipemd160_2.json OK
+ static_CallRipemd160_3.json OK
+ static_CallRipemd160_3_postfixed0.json OK
+ static_CallRipemd160_3_prefixed0.json OK
+ static_CallRipemd160_4.json OK
+ static_CallRipemd160_4_gas719.json OK
+ static_CallRipemd160_5.json OK
+ static_CallSha256_1.json OK
+ static_CallSha256_1_nonzeroValue.json OK
+ static_CallSha256_2.json OK
+ static_CallSha256_3.json OK
+ static_CallSha256_3_postfix0.json OK
+ static_CallSha256_3_prefix0.json OK
+ static_CallSha256_4.json OK
+ static_CallSha256_4_gas99.json OK
+ static_CallSha256_5.json OK
+ static_CallToNameRegistrator0.json OK
+ static_CallToReturn1.json OK
+ static_CalltoReturn2.json OK
+ static_CheckCallCostOOG.json OK
+ static_CheckOpcodes.json OK
+ static_CheckOpcodes2.json OK
+ static_CheckOpcodes3.json OK
+ static_CheckOpcodes4.json OK
+ static_CheckOpcodes5.json OK
+ static_ExecuteCallThatAskForeGasThenTrabsactionHas.json OK
+ static_InternalCallHittingGasLimit.json OK
+ static_InternalCallHittingGasLimit2.json OK
+ static_InternlCallStoreClearsOOG.json OK
+ static_LoopCallsDepthThenRevert.json OK
+ static_LoopCallsDepthThenRevert2.json OK
+ static_LoopCallsDepthThenRevert3.json OK
+ static_LoopCallsThenRevert.json OK
+ static_PostToReturn1.json OK
+ static_RETURN_Bounds.json OK
+ static_RETURN_BoundsOOG.json OK
+ static_RawCallGasAsk.json OK
+ static_Return50000_2.json OK
+ static_ReturnTest.json OK
+ static_ReturnTest2.json OK
+ static_RevertDepth2.json OK
+ static_RevertOpcodeCalls.json OK
+ static_ZeroValue_CALL_OOGRevert.json OK
+ static_ZeroValue_SUICIDE_OOGRevert.json OK
+ static_callBasic.json OK
+ static_callChangeRevert.json OK
+ static_callCreate.json OK
+ static_callCreate2.json OK
+ static_callCreate3.json OK
+ static_callOutput1.json OK
+ static_callOutput2.json OK
+ static_callOutput3.json OK
+ static_callOutput3Fail.json OK
+ static_callOutput3partial.json OK
+ static_callOutput3partialFail.json OK
+ static_callToCallCodeOpCodeCheck.json OK
+ static_callToCallOpCodeCheck.json OK
+ static_callToDelCallOpCodeCheck.json OK
+ static_callToStaticOpCodeCheck.json OK
+ static_callWithHighValue.json OK
+ static_callWithHighValueAndGasOOG.json OK
+ static_callWithHighValueAndOOGatTxLevel.json OK
+ static_callWithHighValueOOGinCall.json OK
+ static_call_OOG_additionalGasCosts1.json OK
+ static_call_OOG_additionalGasCosts2.json OK
+ static_call_value_inherit.json OK
+ static_call_value_inherit_from_call.json OK
+ static_callcall_00.json OK
+ static_callcall_00_OOGE.json OK
+ static_callcall_00_OOGE_1.json OK
+ static_callcall_00_OOGE_2.json OK
+ static_callcall_00_SuicideEnd.json OK
+ static_callcallcall_000.json OK
+ static_callcallcall_000_OOGE.json OK
+ static_callcallcall_000_OOGMAfter.json OK
+ static_callcallcall_000_OOGMAfter2.json OK
+ static_callcallcall_000_OOGMBefore.json OK
+ static_callcallcall_000_SuicideEnd.json OK
+ static_callcallcall_000_SuicideMiddle.json OK
+ static_callcallcall_ABCB_RECURSIVE.json OK
+ static_callcallcallcode_001.json OK
+ static_callcallcallcode_001_2.json OK
+ static_callcallcallcode_001_OOGE.json OK
+ static_callcallcallcode_001_OOGE_2.json OK
+ static_callcallcallcode_001_OOGMAfter.json OK
+ static_callcallcallcode_001_OOGMAfter2.json OK
+ static_callcallcallcode_001_OOGMAfter_2.json OK
+ static_callcallcallcode_001_OOGMAfter_3.json OK
+ static_callcallcallcode_001_OOGMBefore.json OK
+ static_callcallcallcode_001_OOGMBefore2.json OK
+ static_callcallcallcode_001_SuicideEnd.json OK
+ static_callcallcallcode_001_SuicideEnd2.json OK
+ static_callcallcallcode_001_SuicideMiddle.json OK
+ static_callcallcallcode_001_SuicideMiddle2.json OK
+ static_callcallcallcode_ABCB_RECURSIVE.json OK
+ static_callcallcallcode_ABCB_RECURSIVE2.json OK
+ static_callcallcode_01_2.json OK
+ static_callcallcode_01_OOGE_2.json OK
+ static_callcallcode_01_SuicideEnd.json OK
+ static_callcallcode_01_SuicideEnd2.json OK
+ static_callcallcodecall_010.json OK
+ static_callcallcodecall_010_2.json OK
+ static_callcallcodecall_010_OOGE.json OK
+ static_callcallcodecall_010_OOGE_2.json OK
+ static_callcallcodecall_010_OOGMAfter.json OK
+ static_callcallcodecall_010_OOGMAfter2.json OK
+ static_callcallcodecall_010_OOGMAfter_2.json OK
+ static_callcallcodecall_010_OOGMAfter_3.json OK
+ static_callcallcodecall_010_OOGMBefore.json OK
+ static_callcallcodecall_010_OOGMBefore2.json OK
+ static_callcallcodecall_010_SuicideEnd.json OK
+ static_callcallcodecall_010_SuicideEnd2.json OK
+ static_callcallcodecall_010_SuicideMiddle.json OK
+ static_callcallcodecall_010_SuicideMiddle2.json OK
+ static_callcallcodecall_ABCB_RECURSIVE.json OK
+ static_callcallcodecall_ABCB_RECURSIVE2.json OK
+ static_callcallcodecallcode_011.json OK
+ static_callcallcodecallcode_011_2.json OK
+ static_callcallcodecallcode_011_OOGE.json OK
+ static_callcallcodecallcode_011_OOGE_2.json OK
+ static_callcallcodecallcode_011_OOGMAfter.json OK
+ static_callcallcodecallcode_011_OOGMAfter2.json OK
+ static_callcallcodecallcode_011_OOGMAfter_1.json OK
+ static_callcallcodecallcode_011_OOGMAfter_2.json OK
+ static_callcallcodecallcode_011_OOGMBefore.json OK
+ static_callcallcodecallcode_011_OOGMBefore2.json OK
+ static_callcallcodecallcode_011_SuicideEnd.json OK
+ static_callcallcodecallcode_011_SuicideEnd2.json OK
+ static_callcallcodecallcode_011_SuicideMiddle.json OK
+ static_callcallcodecallcode_011_SuicideMiddle2.json OK
+ static_callcallcodecallcode_ABCB_RECURSIVE.json OK
+ static_callcallcodecallcode_ABCB_RECURSIVE2.json OK
+ static_callcode_checkPC.json OK
+ static_callcodecall_10.json OK
+ static_callcodecall_10_2.json OK
+ static_callcodecall_10_OOGE.json OK
+ static_callcodecall_10_OOGE_2.json OK
+ static_callcodecall_10_SuicideEnd.json OK
+ static_callcodecall_10_SuicideEnd2.json OK
+ static_callcodecallcall_100.json OK
+ static_callcodecallcall_100_2.json OK
+ static_callcodecallcall_100_OOGE.json OK
+ static_callcodecallcall_100_OOGE2.json OK
+ static_callcodecallcall_100_OOGMAfter.json OK
+ static_callcodecallcall_100_OOGMAfter2.json OK
+ static_callcodecallcall_100_OOGMAfter_2.json OK
+ static_callcodecallcall_100_OOGMAfter_3.json OK
+ static_callcodecallcall_100_OOGMBefore.json OK
+ static_callcodecallcall_100_OOGMBefore2.json OK
+ static_callcodecallcall_100_SuicideEnd.json OK
+ static_callcodecallcall_100_SuicideEnd2.json OK
+ static_callcodecallcall_100_SuicideMiddle.json OK
+ static_callcodecallcall_100_SuicideMiddle2.json OK
+ static_callcodecallcall_ABCB_RECURSIVE.json OK
+ static_callcodecallcall_ABCB_RECURSIVE2.json OK
+ static_callcodecallcallcode_101.json OK
+ static_callcodecallcallcode_101_2.json OK
+ static_callcodecallcallcode_101_OOGE.json OK
+ static_callcodecallcallcode_101_OOGE_2.json OK
+ static_callcodecallcallcode_101_OOGMAfter.json OK
+ static_callcodecallcallcode_101_OOGMAfter2.json OK
+ static_callcodecallcallcode_101_OOGMAfter_1.json OK
+ static_callcodecallcallcode_101_OOGMAfter_3.json OK
+ static_callcodecallcallcode_101_OOGMBefore.json OK
+ static_callcodecallcallcode_101_OOGMBefore2.json OK
+ static_callcodecallcallcode_101_SuicideEnd.json OK
+ static_callcodecallcallcode_101_SuicideEnd2.json OK
+ static_callcodecallcallcode_101_SuicideMiddle.json OK
+ static_callcodecallcallcode_101_SuicideMiddle2.json OK
+ static_callcodecallcallcode_ABCB_RECURSIVE.json OK
+ static_callcodecallcallcode_ABCB_RECURSIVE2.json OK
+ static_callcodecallcodecall_110.json OK
+ static_callcodecallcodecall_1102.json OK
+ static_callcodecallcodecall_110_2.json OK
+ static_callcodecallcodecall_110_OOGE.json OK
+ static_callcodecallcodecall_110_OOGE2.json OK
+ static_callcodecallcodecall_110_OOGMAfter.json OK
+ static_callcodecallcodecall_110_OOGMAfter2.json OK
+ static_callcodecallcodecall_110_OOGMAfter_2.json OK
+ static_callcodecallcodecall_110_OOGMAfter_3.json OK
+ static_callcodecallcodecall_110_OOGMBefore.json OK
+ static_callcodecallcodecall_110_OOGMBefore2.json OK
+ static_callcodecallcodecall_110_SuicideEnd.json OK
+ static_callcodecallcodecall_110_SuicideEnd2.json OK
+ static_callcodecallcodecall_110_SuicideMiddle.json OK
+ static_callcodecallcodecall_110_SuicideMiddle2.json OK
+ static_callcodecallcodecall_ABCB_RECURSIVE.json OK
+ static_callcodecallcodecall_ABCB_RECURSIVE2.json OK
+ static_callcodecallcodecallcode_111_SuicideEnd.json OK
+ static_calldelcode_01.json OK
+ static_calldelcode_01_OOGE.json OK
+ static_contractCreationMakeCallThatAskMoreGasThenTransactionPro OK
+ static_contractCreationOOGdontLeaveEmptyContractViaTransaction. OK
+ static_log0_emptyMem.json OK
+ static_log0_logMemStartTooHigh.json OK
+ static_log0_logMemsizeTooHigh.json OK
+ static_log0_logMemsizeZero.json OK
+ static_log0_nonEmptyMem.json OK
+ static_log0_nonEmptyMem_logMemSize1.json OK
+ static_log0_nonEmptyMem_logMemSize1_logMemStart31.json OK
+ static_log1_MaxTopic.json OK
+ static_log1_emptyMem.json OK
+ static_log1_logMemStartTooHigh.json OK
+ static_log1_logMemsizeTooHigh.json OK
+ static_log1_logMemsizeZero.json OK
+ static_log_Caller.json OK
+ static_makeMoney.json OK
+ static_refund_CallA.json OK
+ static_refund_CallToSuicideNoStorage.json OK
+ static_refund_CallToSuicideTwice.json OK
static_Call50000bytesContract50_1.json Skip
static_Call50000bytesContract50_2.json Skip
static_Call50000bytesContract50_3.json Skip
static_CallAndCallcodeConsumeMoreGasThenTransactionHas.json Skip
static_CallAskMoreGasOnDepth2ThenTransactionHas.json Skip
static_CallContractToCreateContractAndCallItOOG.json Skip
static_CallContractToCreateContractOOG.json Skip
static_CallContractToCreateContractOOGBonusGas.json Skip
static_CallContractToCreateContractWhichWouldCreateContractIfCa Skip
static_CallEcrecover0.json Skip
static_CallEcrecover0_0input.json Skip
static_CallEcrecover0_Gas2999.json Skip
static_CallEcrecover0_NoGas.json Skip
static_CallEcrecover0_completeReturnValue.json Skip
static_CallEcrecover0_gas3000.json Skip
static_CallEcrecover0_overlappingInputOutput.json Skip
static_CallEcrecover1.json Skip
static_CallEcrecover2.json Skip
static_CallEcrecover3.json Skip
static_CallEcrecover80.json Skip
static_CallEcrecoverCheckLength.json Skip
static_CallEcrecoverCheckLengthWrongV.json Skip
static_CallEcrecoverH_prefixed0.json Skip
static_CallEcrecoverR_prefixed0.json Skip
static_CallEcrecoverS_prefixed0.json Skip
static_CallEcrecoverV_prefixed0.json Skip
static_CallGoesOOGOnSecondLevel.json Skip
static_CallGoesOOGOnSecondLevel2.json Skip
static_CallIdentitiy_1.json Skip
static_CallIdentity_1_nonzeroValue.json Skip
static_CallIdentity_2.json Skip
static_CallIdentity_3.json Skip
static_CallIdentity_4.json Skip
static_CallIdentity_4_gas17.json Skip
static_CallIdentity_4_gas18.json Skip
static_CallIdentity_5.json Skip
static_CallLoseGasOOG.json Skip
static_CallRecursiveBomb0.json Skip
static_CallRecursiveBomb0_OOG_atMaxCallDepth.json Skip
static_CallRecursiveBomb1.json Skip
static_CallRecursiveBomb2.json Skip
static_CallRecursiveBomb3.json Skip
static_CallRecursiveBombLog.json Skip
static_CallRecursiveBombLog2.json Skip
static_CallRecursiveBombPreCall.json Skip
static_CallRecursiveBombPreCall2.json Skip
static_CallRipemd160_1.json Skip
static_CallRipemd160_2.json Skip
static_CallRipemd160_3.json Skip
static_CallRipemd160_3_postfixed0.json Skip
static_CallRipemd160_3_prefixed0.json Skip
static_CallRipemd160_4.json Skip
static_CallRipemd160_4_gas719.json Skip
static_CallRipemd160_5.json Skip
static_CallSha256_1.json Skip
static_CallSha256_1_nonzeroValue.json Skip
static_CallSha256_2.json Skip
static_CallSha256_3.json Skip
static_CallSha256_3_postfix0.json Skip
static_CallSha256_3_prefix0.json Skip
static_CallSha256_4.json Skip
static_CallSha256_4_gas99.json Skip
static_CallSha256_5.json Skip
static_CallToNameRegistrator0.json Skip
static_CallToReturn1.json Skip
static_CalltoReturn2.json Skip
static_CheckCallCostOOG.json Skip
static_CheckOpcodes.json Skip
static_CheckOpcodes2.json Skip
static_CheckOpcodes3.json Skip
static_CheckOpcodes4.json Skip
static_CheckOpcodes5.json Skip
static_ExecuteCallThatAskForeGasThenTrabsactionHas.json Skip
static_InternalCallHittingGasLimit.json Skip
static_InternalCallHittingGasLimit2.json Skip
static_InternlCallStoreClearsOOG.json Skip
static_LoopCallsDepthThenRevert.json Skip
static_LoopCallsDepthThenRevert2.json Skip
static_LoopCallsDepthThenRevert3.json Skip
static_LoopCallsThenRevert.json Skip
static_PostToReturn1.json Skip
static_RETURN_Bounds.json Skip
static_RETURN_BoundsOOG.json Skip
static_RawCallGasAsk.json Skip
static_Return50000_2.json Skip
static_ReturnTest.json Skip
static_ReturnTest2.json Skip
static_RevertDepth2.json Skip
static_RevertOpcodeCalls.json Skip
static_ZeroValue_CALL_OOGRevert.json Skip
static_ZeroValue_SUICIDE_OOGRevert.json Skip
static_callBasic.json Skip
static_callChangeRevert.json Skip
static_callCreate.json Skip
static_callCreate2.json Skip
static_callCreate3.json Skip
static_callOutput1.json Skip
static_callOutput2.json Skip
static_callOutput3.json Skip
static_callOutput3Fail.json Skip
static_callOutput3partial.json Skip
static_callOutput3partialFail.json Skip
static_callToCallCodeOpCodeCheck.json Skip
static_callToCallOpCodeCheck.json Skip
static_callToDelCallOpCodeCheck.json Skip
static_callToStaticOpCodeCheck.json Skip
static_callWithHighValue.json Skip
static_callWithHighValueAndGasOOG.json Skip
static_callWithHighValueAndOOGatTxLevel.json Skip
static_callWithHighValueOOGinCall.json Skip
static_call_OOG_additionalGasCosts1.json Skip
static_call_OOG_additionalGasCosts2.json Skip
static_call_value_inherit.json Skip
static_call_value_inherit_from_call.json Skip
static_callcall_00.json Skip
static_callcall_00_OOGE.json Skip
static_callcall_00_OOGE_1.json Skip
static_callcall_00_OOGE_2.json Skip
static_callcall_00_SuicideEnd.json Skip
static_callcallcall_000.json Skip
static_callcallcall_000_OOGE.json Skip
static_callcallcall_000_OOGMAfter.json Skip
static_callcallcall_000_OOGMAfter2.json Skip
static_callcallcall_000_OOGMBefore.json Skip
static_callcallcall_000_SuicideEnd.json Skip
static_callcallcall_000_SuicideMiddle.json Skip
static_callcallcall_ABCB_RECURSIVE.json Skip
static_callcallcallcode_001.json Skip
static_callcallcallcode_001_2.json Skip
static_callcallcallcode_001_OOGE.json Skip
static_callcallcallcode_001_OOGE_2.json Skip
static_callcallcallcode_001_OOGMAfter.json Skip
static_callcallcallcode_001_OOGMAfter2.json Skip
static_callcallcallcode_001_OOGMAfter_2.json Skip
static_callcallcallcode_001_OOGMAfter_3.json Skip
static_callcallcallcode_001_OOGMBefore.json Skip
static_callcallcallcode_001_OOGMBefore2.json Skip
static_callcallcallcode_001_SuicideEnd.json Skip
static_callcallcallcode_001_SuicideEnd2.json Skip
static_callcallcallcode_001_SuicideMiddle.json Skip
static_callcallcallcode_001_SuicideMiddle2.json Skip
static_callcallcallcode_ABCB_RECURSIVE.json Skip
static_callcallcallcode_ABCB_RECURSIVE2.json Skip
static_callcallcode_01_2.json Skip
static_callcallcode_01_OOGE_2.json Skip
static_callcallcode_01_SuicideEnd.json Skip
static_callcallcode_01_SuicideEnd2.json Skip
static_callcallcodecall_010.json Skip
static_callcallcodecall_010_2.json Skip
static_callcallcodecall_010_OOGE.json Skip
static_callcallcodecall_010_OOGE_2.json Skip
static_callcallcodecall_010_OOGMAfter.json Skip
static_callcallcodecall_010_OOGMAfter2.json Skip
static_callcallcodecall_010_OOGMAfter_2.json Skip
static_callcallcodecall_010_OOGMAfter_3.json Skip
static_callcallcodecall_010_OOGMBefore.json Skip
static_callcallcodecall_010_OOGMBefore2.json Skip
static_callcallcodecall_010_SuicideEnd.json Skip
static_callcallcodecall_010_SuicideEnd2.json Skip
static_callcallcodecall_010_SuicideMiddle.json Skip
static_callcallcodecall_010_SuicideMiddle2.json Skip
static_callcallcodecall_ABCB_RECURSIVE.json Skip
static_callcallcodecall_ABCB_RECURSIVE2.json Skip
static_callcallcodecallcode_011.json Skip
static_callcallcodecallcode_011_2.json Skip
static_callcallcodecallcode_011_OOGE.json Skip
static_callcallcodecallcode_011_OOGE_2.json Skip
static_callcallcodecallcode_011_OOGMAfter.json Skip
static_callcallcodecallcode_011_OOGMAfter2.json Skip
static_callcallcodecallcode_011_OOGMAfter_1.json Skip
static_callcallcodecallcode_011_OOGMAfter_2.json Skip
static_callcallcodecallcode_011_OOGMBefore.json Skip
static_callcallcodecallcode_011_OOGMBefore2.json Skip
static_callcallcodecallcode_011_SuicideEnd.json Skip
static_callcallcodecallcode_011_SuicideEnd2.json Skip
static_callcallcodecallcode_011_SuicideMiddle.json Skip
static_callcallcodecallcode_011_SuicideMiddle2.json Skip
static_callcallcodecallcode_ABCB_RECURSIVE.json Skip
static_callcallcodecallcode_ABCB_RECURSIVE2.json Skip
static_callcode_checkPC.json Skip
static_callcodecall_10.json Skip
static_callcodecall_10_2.json Skip
static_callcodecall_10_OOGE.json Skip
static_callcodecall_10_OOGE_2.json Skip
static_callcodecall_10_SuicideEnd.json Skip
static_callcodecall_10_SuicideEnd2.json Skip
static_callcodecallcall_100.json Skip
static_callcodecallcall_100_2.json Skip
static_callcodecallcall_100_OOGE.json Skip
static_callcodecallcall_100_OOGE2.json Skip
static_callcodecallcall_100_OOGMAfter.json Skip
static_callcodecallcall_100_OOGMAfter2.json Skip
static_callcodecallcall_100_OOGMAfter_2.json Skip
static_callcodecallcall_100_OOGMAfter_3.json Skip
static_callcodecallcall_100_OOGMBefore.json Skip
static_callcodecallcall_100_OOGMBefore2.json Skip
static_callcodecallcall_100_SuicideEnd.json Skip
static_callcodecallcall_100_SuicideEnd2.json Skip
static_callcodecallcall_100_SuicideMiddle.json Skip
static_callcodecallcall_100_SuicideMiddle2.json Skip
static_callcodecallcall_ABCB_RECURSIVE.json Skip
static_callcodecallcall_ABCB_RECURSIVE2.json Skip
static_callcodecallcallcode_101.json Skip
static_callcodecallcallcode_101_2.json Skip
static_callcodecallcallcode_101_OOGE.json Skip
static_callcodecallcallcode_101_OOGE_2.json Skip
static_callcodecallcallcode_101_OOGMAfter.json Skip
static_callcodecallcallcode_101_OOGMAfter2.json Skip
static_callcodecallcallcode_101_OOGMAfter_1.json Skip
static_callcodecallcallcode_101_OOGMAfter_3.json Skip
static_callcodecallcallcode_101_OOGMBefore.json Skip
static_callcodecallcallcode_101_OOGMBefore2.json Skip
static_callcodecallcallcode_101_SuicideEnd.json Skip
static_callcodecallcallcode_101_SuicideEnd2.json Skip
static_callcodecallcallcode_101_SuicideMiddle.json Skip
static_callcodecallcallcode_101_SuicideMiddle2.json Skip
static_callcodecallcallcode_ABCB_RECURSIVE.json Skip
static_callcodecallcallcode_ABCB_RECURSIVE2.json Skip
static_callcodecallcodecall_110.json Skip
static_callcodecallcodecall_1102.json Skip
static_callcodecallcodecall_110_2.json Skip
static_callcodecallcodecall_110_OOGE.json Skip
static_callcodecallcodecall_110_OOGE2.json Skip
static_callcodecallcodecall_110_OOGMAfter.json Skip
static_callcodecallcodecall_110_OOGMAfter2.json Skip
static_callcodecallcodecall_110_OOGMAfter_2.json Skip
static_callcodecallcodecall_110_OOGMAfter_3.json Skip
static_callcodecallcodecall_110_OOGMBefore.json Skip
static_callcodecallcodecall_110_OOGMBefore2.json Skip
static_callcodecallcodecall_110_SuicideEnd.json Skip
static_callcodecallcodecall_110_SuicideEnd2.json Skip
static_callcodecallcodecall_110_SuicideMiddle.json Skip
static_callcodecallcodecall_110_SuicideMiddle2.json Skip
static_callcodecallcodecall_ABCB_RECURSIVE.json Skip
static_callcodecallcodecall_ABCB_RECURSIVE2.json Skip
static_callcodecallcodecallcode_111_SuicideEnd.json Skip
static_calldelcode_01.json Skip
static_calldelcode_01_OOGE.json Skip
static_contractCreationMakeCallThatAskMoreGasThenTransactionPro Skip
static_contractCreationOOGdontLeaveEmptyContractViaTransaction. Skip
static_log0_emptyMem.json Skip
static_log0_logMemStartTooHigh.json Skip
static_log0_logMemsizeTooHigh.json Skip
static_log0_logMemsizeZero.json Skip
static_log0_nonEmptyMem.json Skip
static_log0_nonEmptyMem_logMemSize1.json Skip
static_log0_nonEmptyMem_logMemSize1_logMemStart31.json Skip
static_log1_MaxTopic.json Skip
static_log1_emptyMem.json Skip
static_log1_logMemStartTooHigh.json Skip
static_log1_logMemsizeTooHigh.json Skip
static_log1_logMemsizeZero.json Skip
static_log_Caller.json Skip
static_makeMoney.json Skip
static_refund_CallA.json Skip
static_refund_CallToSuicideNoStorage.json Skip
static_refund_CallToSuicideTwice.json Skip
```
OK: 271/283 Fail: 0/283 Skip: 12/283
OK: 0/283 Fail: 0/283 Skip: 283/283
## stSubroutine
```diff
+ beginSubAtEndOfCode.json OK
+ shouldErrorWhenExecuteBeginSub.json OK
+ shouldErrorWhenJumpToJumpDest.json OK
+ shouldErrorWhenReturnStackGrowsAbove1023.json OK
+ shouldErrorWhenSubroutineEnteredViaBeginSub.json OK
shouldSucceedWhenReturnStackGrowsUntil1023.json Skip
+ simpleSubroutine.json OK
+ subroutineAtEndOfCode.json OK
+ subroutineInvalidJump.json OK
+ subroutineShallowReturnStack.json OK
+ twoLevelsSubroutines.json OK
```
OK: 10/11 Fail: 0/11 Skip: 1/11
## stSystemOperationsTest
```diff
+ ABAcalls0.json OK
@ -3538,26 +3553,26 @@ OK: 144/144 Fail: 0/144 Skip: 0/144
OK: 46/46 Fail: 0/46 Skip: 0/46
## vmPerformance
```diff
+ ackermann31.json OK
+ ackermann32.json OK
+ ackermann33.json OK
+ fibonacci10.json OK
+ fibonacci16.json OK
+ loop-add-10M.json OK
+ loop-divadd-10M.json OK
+ loop-divadd-unr100-10M.json OK
+ loop-exp-16b-100k.json OK
+ loop-exp-1b-1M.json OK
+ loop-exp-2b-100k.json OK
+ loop-exp-32b-100k.json OK
+ loop-exp-4b-100k.json OK
+ loop-exp-8b-100k.json OK
+ loop-exp-nop-1M.json OK
+ loop-mul.json OK
+ loop-mulmod-2M.json OK
+ manyFunctions100.json OK
ackermann31.json Skip
ackermann32.json Skip
ackermann33.json Skip
fibonacci10.json Skip
fibonacci16.json Skip
loop-add-10M.json Skip
loop-divadd-10M.json Skip
loop-divadd-unr100-10M.json Skip
loop-exp-16b-100k.json Skip
loop-exp-1b-1M.json Skip
loop-exp-2b-100k.json Skip
loop-exp-32b-100k.json Skip
loop-exp-4b-100k.json Skip
loop-exp-8b-100k.json Skip
loop-exp-nop-1M.json Skip
loop-mul.json Skip
loop-mulmod-2M.json Skip
manyFunctions100.json Skip
```
OK: 18/18 Fail: 0/18 Skip: 0/18
OK: 0/18 Fail: 0/18 Skip: 18/18
## vmPushDupSwapTest
```diff
+ dup1.json OK
@ -3686,4 +3701,4 @@ OK: 7/7 Fail: 0/7 Skip: 0/7
OK: 1/1 Fail: 0/1 Skip: 0/1
---TOTAL---
OK: 3235/3340 Fail: 0/3340 Skip: 105/3340
OK: 2956/3351 Fail: 0/3351 Skip: 395/3351

View File

@ -2135,6 +2135,21 @@ OK: 9/9 Fail: 0/9 Skip: 0/9
+ static_refund_CallToSuicideTwice.json OK
```
OK: 271/283 Fail: 0/283 Skip: 12/283
## stSubroutine
```diff
+ beginSubAtEndOfCode.json OK
+ shouldErrorWhenExecuteBeginSub.json OK
+ shouldErrorWhenJumpToJumpDest.json OK
+ shouldErrorWhenReturnStackGrowsAbove1023.json OK
+ shouldErrorWhenSubroutineEnteredViaBeginSub.json OK
shouldSucceedWhenReturnStackGrowsUntil1023.json Skip
+ simpleSubroutine.json OK
+ subroutineAtEndOfCode.json OK
+ subroutineInvalidJump.json OK
+ subroutineShallowReturnStack.json OK
+ twoLevelsSubroutines.json OK
```
OK: 10/11 Fail: 0/11 Skip: 1/11
## stSystemOperationsTest
```diff
+ ABAcalls0.json OK
@ -2626,4 +2641,4 @@ OK: 133/133 Fail: 0/133 Skip: 0/133
OK: 130/130 Fail: 0/130 Skip: 0/130
---TOTAL---
OK: 2307/2412 Fail: 0/2412 Skip: 105/2412
OK: 2317/2423 Fail: 0/2423 Skip: 106/2423

44
nimbus/db/access_list.nim Normal file
View File

@ -0,0 +1,44 @@
import
tables, sets,
stint,
eth/common
type
SlotSet = HashSet[UInt256]
AccessList* = object
slots: Table[EthAddress, SlotSet]
proc init*(ac: var AccessList) =
ac.slots = initTable[EthAddress, SlotSet]()
proc init*(_: type AccessList): AccessList {.inline.} =
result.init()
func contains*(ac: AccessList, address: EthAddress): bool {.inline.} =
address in ac.slots
# returnValue: (addressPresent, slotPresent)
func contains*(ac: var AccessList, address: EthAddress, slot: UInt256): bool =
ac.slots.withValue(address, val):
result = slot in val[]
proc merge*(ac: var AccessList, other: AccessList) {.inline.} =
for k, v in other.slots:
ac.slots.withValue(k, val):
val[].incl v
do:
ac.slots[k] = v
proc add*(ac: var AccessList, address: EthAddress) =
if address notin ac.slots:
ac.slots[address] = initHashSet[UInt256]()
proc add*(ac: var AccessList, address: EthAddress, slot: UInt256) =
ac.slots.withValue(address, val):
val[].incl slot
do:
ac.slots[address] = toHashSet([slot])
proc clear*(ac: var AccessList) {.inline.} =
ac.slots.clear()

View File

@ -2,7 +2,8 @@ import
tables, hashes, sets,
eth/[common, rlp], eth/trie/[hexary, db, trie_defs],
../constants, ../utils, storage_types,
../../stateless/multi_keys
../../stateless/multi_keys,
./access_list
type
AccountFlag = enum
@ -45,6 +46,7 @@ type
SavePoint* = ref object
parentSavepoint: SavePoint
cache: Table[EthAddress, RefAccount]
accessList: access_list.AccessList
state: TransactionState
const
@ -83,6 +85,7 @@ proc rootHash*(ac: AccountsCache): KeccakHash =
proc beginSavepoint*(ac: var AccountsCache): SavePoint =
new result
result.cache = initTable[EthAddress, RefAccount]()
result.accessList.init()
result.state = Pending
result.parentSavepoint = ac.savePoint
ac.savePoint = result
@ -106,6 +109,8 @@ proc commit*(ac: var AccountsCache, sp: Savepoint) =
ac.savePoint = sp.parentSavepoint
for k, v in sp.cache:
sp.parentSavepoint.cache[k] = v
ac.savePoint.accessList.merge(sp.accessList)
sp.state = Committed
proc dispose*(ac: var AccountsCache, sp: Savepoint) {.inline.} =
@ -447,6 +452,10 @@ proc persist*(ac: var AccountsCache, clearCache: bool = true) =
else:
for x in cleanAccounts:
ac.savePoint.cache.del x
# EIP2929
ac.savePoint.accessList.clear()
ac.isDirty = false
iterator storage*(ac: AccountsCache, address: EthAddress): (UInt256, UInt256) =
@ -514,6 +523,28 @@ proc makeMultiKeys*(ac: AccountsCache): MultikeysRef =
result.add(k, v.codeTouched, multiKeys(v.storageKeys))
result.sort()
proc accessList*(ac: var AccountsCache, address: EthAddress) {.inline.} =
ac.savePoint.accessList.add(address)
proc accessList*(ac: var AccountsCache, address: EthAddress, slot: UInt256) {.inline.} =
ac.savePoint.accessList.add(address, slot)
func inAccessList*(ac: AccountsCache, address: EthAddress): bool =
var sp = ac.savePoint
while sp != nil:
result = sp.accessList.contains(address)
if result:
return
sp = sp.parentSavepoint
func inAccessList*(ac: AccountsCache, address: EthAddress, slot: UInt256): bool =
var sp = ac.savePoint
while sp != nil:
result = sp.accessList.contains(address, slot)
if result:
return
sp = sp.parentSavepoint
proc rootHash*(db: ReadOnlyStateDB): KeccakHash {.borrow.}
proc getCodeHash*(db: ReadOnlyStateDB, address: EthAddress): Hash256 {.borrow.}
proc getStorageRoot*(db: ReadOnlyStateDB, address: EthAddress): Hash256 {.borrow.}
@ -527,3 +558,5 @@ proc accountExists*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.}
proc isDeadAccount*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.}
proc isEmptyAccount*(db: ReadOnlyStateDB, address: EthAddress): bool {.borrow.}
proc getCommittedStorage*(db: ReadOnlyStateDB, address: EthAddress, slot: UInt256): UInt256 {.borrow.}
func inAccessList*(ac: ReadOnlyStateDB, address: EthAddress): bool {.borrow.}
func inAccessList*(ac: ReadOnlyStateDB, address: EthAddress, slot: UInt256): bool {.borrow.}

View File

@ -3,7 +3,7 @@ import options, sets,
../db/[db_chain, accounts_cache],
../utils, ../constants, ../transaction,
../vm_state, ../vm_types, ../vm_state_transactions,
../vm/[computation, message],
../vm/[computation, message, precompiles],
../vm/interpreter/vm_forks,
./dao, ../config
@ -13,6 +13,16 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
trace "Sender", sender
trace "txHash", rlpHash = tx.rlpHash
# EIP2929
if fork >= FkBerlin:
vmState.mutateStateDB:
db.accessList(sender)
if not tx.isContractCreation:
#If it's a create-tx, the destination will be added inside evm.create
db.accessList(tx.getRecipient)
for c in activePrecompiles():
db.accessList(c)
if validateTransaction(vmState, tx, sender, fork):
var c = setupComputation(vmState, tx, sender, fork)
vmState.mutateStateDB:

View File

@ -243,7 +243,7 @@ proc execCall*(c: Computation) =
## https://github.com/ethereum/EIPs/blob/master/EIPS/eip-161.md
## also see: https://github.com/ethereum/EIPs/issues/716
if c.isError or c.fork == FKIstanbul:
if c.isError or c.fork >= FKIstanbul:
if c.msg.contractAddress == ripemdAddr:
# Special case to account for geth+parity bug
c.vmState.touchedAccounts.incl c.msg.contractAddress
@ -258,6 +258,12 @@ proc execCreate*(c: Computation) =
c.vmState.mutateStateDB:
db.incNonce(c.msg.sender)
# We add this to the access list _before_ taking a snapshot.
# Even if the creation fails, the access-list change should not be rolled back
# EIP2929
if c.fork >= FkBerlin:
db.accessList(c.msg.contractAddress)
c.snapshot()
defer:
c.dispose()

View File

@ -115,6 +115,11 @@ type
GasCosts* = array[Op, GasCost]
const
ColdSloadCost* = 2100
ColdAccountAccessCost* = 2600
WarmStorageReadCost* = 100
template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
## Generate the gas cost for each forks and store them in a const
@ -214,13 +219,24 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
func `prefix gasSstore`(value: Uint256, gasParams: Gasparams): GasResult {.nimcall.} =
## Value is word to save
when fork >= FkBerlin:
# EIP2929
const
SLOAD_GAS = WarmStorageReadCost
SSTORE_RESET_GAS = 5000 - ColdSloadCost
else:
const
SLOAD_GAS = FeeSchedule[GasSload]
SSTORE_RESET_GAS = FeeSchedule[GasSreset]
const
NoopGas = FeeSchedule[GasSload] # if the value doesn't change.
DirtyGas = FeeSchedule[GasSload] # if a dirty value is changed.
NoopGas = SLOAD_GAS # if the value doesn't change.
DirtyGas = SLOAD_GAS # if a dirty value is changed.
InitGas = FeeSchedule[GasSset] # from clean zero to non-zero
InitRefund = FeeSchedule[GasSset] - FeeSchedule[GasSload] # resetting to the original zero value
CleanGas = FeeSchedule[GasSreset]# from clean non-zero to something else
CleanRefund = FeeSchedule[GasSreset] - FeeSchedule[GasSload] # resetting to the original non-zero value
InitRefund = FeeSchedule[GasSset] - SLOAD_GAS # resetting to the original zero value
CleanGas = SSTORE_RESET_GAS # from clean non-zero to something else
CleanRefund = SSTORE_RESET_GAS - SLOAD_GAS # resetting to the original non-zero value
ClearRefund = FeeSchedule[RefundsClear]# clearing an originally existing storage slot
when defined(evmc_enabled):
@ -724,6 +740,7 @@ gasCosts(FkTangerine, tangerine, TangerineGasCosts)
gasCosts(FkSpurious, spurious, SpuriousGasCosts)
gasCosts(FkConstantinople, constantinople, ConstantinopleGasCosts)
gasCosts(FkIstanbul, istanbul, IstanbulGasCosts)
gasCosts(FkBerlin, berlin, BerlinGasCosts)
proc forkToSchedule*(fork: Fork): GasCosts =
if fork < FkHomestead:
@ -736,8 +753,10 @@ proc forkToSchedule*(fork: Fork): GasCosts =
ConstantinopleGasCosts # with EIP-1283
elif fork < FkIstanbul:
SpuriousGasCosts
else:
elif fork < FkBerlin:
IstanbulGasCosts
else:
BerlinGasCosts
const
## Precompile costs

View File

@ -23,6 +23,15 @@ logScope:
# ##################################
# Syntactic sugar
proc gasEip2929AccountCheck(c: Computation, address: EthAddress, prevCost = 0.GasInt) =
c.vmState.mutateStateDB:
let gasCost = if not db.inAccessList(address):
db.accessList(address)
ColdAccountAccessCost
else:
WarmStorageReadCost
c.gasMeter.consumeGas(gasCost - prevCost, reason = "gasEIP2929AccountCheck")
template push(x: typed) {.dirty.} =
## Push an expression on the computation stack
c.stack.push x
@ -763,7 +772,7 @@ template genCall(callName: untyped, opCode: Op): untyped =
(memOutPos, memOutLen)
let contractAddress = when opCode in {Call, StaticCall}: destination else: c.msg.contractAddress
var (childGasFee, childGasLimit) = c.gasCosts[opCode].c_handler(
var (gasCost, childGasLimit) = c.gasCosts[opCode].c_handler(
value,
GasParams(kind: opCode,
c_isNewAccount: not c.accountExists(contractAddress),
@ -774,15 +783,19 @@ template genCall(callName: untyped, opCode: Op): untyped =
c_memLength: memLength
))
# EIP 2046
# EIP 2046: temporary disabled
# reduce gas fee for precompiles
# from 700 to 40
when opCode == StaticCall:
if c.fork >= FkBerlin and destination.toInt <= MaxPrecompilesAddr:
childGasFee = childGasFee - 660.GasInt
#when opCode == StaticCall:
# if c.fork >= FkBerlin and destination.toInt <= MaxPrecompilesAddr:
# gasCost = gasCost - 660.GasInt
if childGasFee >= 0:
c.gasMeter.consumeGas(childGasFee, reason = $opCode)
# EIP2929
if c.fork >= FkBerlin:
c.gasEip2929AccountCheck(destination, gasFees[c.fork][GasCall])
if gasCost >= 0:
c.gasMeter.consumeGas(gasCost, reason = $opCode)
c.returnData.setLen(0)
@ -792,7 +805,7 @@ template genCall(callName: untyped, opCode: Op): untyped =
c.gasMeter.returnGas(childGasLimit)
return
if childGasFee < 0 and childGasLimit <= 0:
if gasCost < 0 and childGasLimit <= 0:
raise newException(OutOfGas, "Gas not enough to perform calculation (" & callName.astToStr & ")")
c.memory.extend(memInPos, memInLen)
@ -957,3 +970,87 @@ op sarOp, inline = true:
op extCodeHash, inline = true:
let address = c.stack.popAddress()
push: c.getCodeHash(address)
op balanceEIP2929, inline = true:
## 0x31, Get balance of the given account.
let address = c.stack.popAddress()
c.gasEip2929AccountCheck(address, gasFees[c.fork][GasBalance])
push: c.getBalance(address)
op extCodeHashEIP2929, inline = true:
let address = c.stack.popAddress()
c.gasEip2929AccountCheck(address, gasFees[c.fork][GasExtCodeHash])
push: c.getCodeHash(address)
op extCodeSizeEIP2929, inline = true:
## 0x3b, Get size of an account's code
let address = c.stack.popAddress()
c.gasEip2929AccountCheck(address, gasFees[c.fork][GasExtCode])
push: c.getCodeSize(address)
op extCodeCopyEIP2929, inline = true:
## 0x3c, Copy an account's code to memory.
let address = c.stack.popAddress()
let (memStartPos, codeStartPos, size) = c.stack.popInt(3)
let (memPos, codePos, len) = (memStartPos.cleanMemRef, codeStartPos.cleanMemRef, size.cleanMemRef)
c.gasMeter.consumeGas(
c.gasCosts[ExtCodeCopy].m_handler(c.memory.len, memPos, len),
reason="ExtCodeCopy fee")
c.gasEip2929AccountCheck(address, gasFees[c.fork][GasExtCode])
let codeBytes = c.getCode(address)
c.memory.writePaddedResult(codeBytes, memPos, codePos, len)
op selfDestructEIP2929, inline = false:
checkInStaticContext(c)
let
beneficiary = c.stack.popAddress()
isDead = not c.accountExists(beneficiary)
balance = c.getBalance(c.msg.contractAddress)
let gasParams = GasParams(kind: SelfDestruct,
sd_condition: isDead and not balance.isZero
)
var gasCost = c.gasCosts[SelfDestruct].c_handler(0.u256, gasParams).gasCost
c.vmState.mutateStateDB:
if not db.inAccessList(beneficiary):
db.accessList(beneficiary)
gasCost = gasCost + ColdAccountAccessCost
c.gasMeter.consumeGas(gasCost, reason = "SELFDESTRUCT EIP161")
c.selfDestruct(beneficiary)
op sloadEIP2929, inline = true, slot:
## 0x54, Load word from storage.
c.vmState.mutateStateDB:
let gasCost = if not db.inAccessList(c.msg.contractAddress, slot):
db.accessList(c.msg.contractAddress, slot)
ColdSloadCost - gasFees[c.fork][GasSLoad]
else:
WarmStorageReadCost - gasFees[c.fork][GasSLoad]
c.gasMeter.consumeGas(gasCost, reason = "sloadEIP2929")
push: c.getStorage(slot)
op sstoreEIP2929, inline = false, slot, newValue:
checkInStaticContext(c)
const SentryGasEIP2200 = 2300 # Minimum gas required to be present for an SSTORE call, not consumed
if c.gasMeter.gasRemaining <= SentryGasEIP2200:
raise newException(OutOfGas, "Gas not enough to perform EIP2200 SSTORE")
c.vmState.mutateStateDB:
if not db.inAccessList(c.msg.contractAddress, slot):
db.accessList(c.msg.contractAddress, slot)
c.gasMeter.consumeGas(ColdSloadCost, reason = "sstoreEIP2929")
when evmc_enabled:
sstoreEvmc(c, slot, newValue)
else:
sstoreNetGasMeteringImpl(c, slot, newValue)

View File

@ -235,6 +235,14 @@ proc genBerlinJumpTable(ops: array[Op, NimNode]): array[Op, NimNode] {.compileTi
result[ReturnSub] = newIdentNode "returnSub"
result[JumpSub] = newIdentNode "jumpSub"
result[Balance] = newIdentNode "balanceEIP2929"
result[ExtCodeHash] = newIdentNode "extCodeHashEIP2929"
result[ExtCodeSize] = newIdentNode "extCodeSizeEIP2929"
result[ExtCodeCopy] = newIdentNode "extCodeCopyEIP2929"
result[SelfDestruct] = newIdentNode "selfDestructEIP2929"
result[SLoad] = newIdentNode "sloadEIP2929"
result[SStore] = newIdentNode "sstoreEIP2929"
let BerlinOpDispatch {.compileTime.}: array[Op, NimNode] = genBerlinJumpTable(IstanbulOpDispatch)
proc opTableToCaseStmt(opTable: array[Op, NimNode], c: NimNode): NimNode =

View File

@ -28,6 +28,12 @@ type
paBlsMapG1
paBlsMapG2
iterator activePrecompiles*(): EthAddress =
var res: EthAddress
for c in PrecompileAddresses.low..PrecompileAddresses.high:
res[^1] = c.byte
yield res
proc getSignature(computation: Computation): (array[32, byte], Signature) =
# input is Hash, V, R, S
template data: untyped = computation.msg.data
@ -222,15 +228,20 @@ proc modExpFee(c: Computation, baseLen, expLen, modLen: Uint256, fork: Fork): Ga
max(adjExpLen, 1.u256)
) div divisor
let gasFee = if fork >= FkBerlin: gasCalc(mulComplexityEIP2565, GasQuadDivisorEIP2565)
else: gasCalc(mulComplexity, GasQuadDivisor)
# EIP2565: temporary disabled
#let gasFee = if fork >= FkBerlin: gasCalc(mulComplexityEIP2565, GasQuadDivisorEIP2565)
#else: gasCalc(mulComplexity, GasQuadDivisor)
let gasFee = gasCalc(mulComplexity, GasQuadDivisor)
if gasFee > high(GasInt).u256:
raise newException(OutOfGas, "modExp gas overflow")
result = gasFee.truncate(GasInt)
if fork >= FkBerlin and result < 200.GasInt:
result = 200.GasInt
# EIP2565: temporary disabled
#if fork >= FkBerlin and result < 200.GasInt:
# result = 200.GasInt
proc modExp*(c: Computation, fork: Fork = FkByzantium) =
## Modular exponentiation precompiled contract

@ -1 +1 @@
Subproject commit 0062cc3ec261b771ddc4ee49809da0f8a89d100f
Subproject commit 16fa567686a8cea578a500b0095c4d7f9f3bbe63

View File

@ -87,6 +87,7 @@ func slowGSTTests(folder: string, name: string): bool =
# Istanbul slow tests
"CALLBlake2f_MaxRounds.json",
]
func skipGSTTests*(folder: string, name: string): bool =
@ -94,10 +95,10 @@ func skipGSTTests*(folder: string, name: string): bool =
if slowGSTTests(folder, name):
return true
# bugs related to ethereum/tests/b1248cd40809d219197ff01eb547170bfaaf1bf1
name in @[
# bugs related to ethereum/tests/b1248cd40809d219197ff01eb547170bfaaf1bf1
"RevertPrecompiledTouch.json",
"RevertPrecompiledTouch_storage.json"
"RevertPrecompiledTouch_storage.json",
]
func skipNewGSTTests*(folder: string, name: string): bool =
@ -105,6 +106,11 @@ func skipNewGSTTests*(folder: string, name: string): bool =
if skipGSTTests(folder, name):
return true
name in @[
# a bug in ethereum test that later fixed, skip for now
"shouldSucceedWhenReturnStackGrowsUntil1023.json"
]
func skipVMTests*(folder: string, name: string): bool =
result = (folder == "vmPerformance" and "loop" in name)
@ -121,10 +127,13 @@ func skipBCTests*(folder: string, name: string): bool =
"RevertPrecompiledTouch_d0g0v0.json",
"RevertPrecompiledTouch_d3g0v0.json",
"RevertPrecompiledTouch_storage_d0g0v0.json",
"RevertPrecompiledTouch_storage_d3g0v0.json"
"RevertPrecompiledTouch_storage_d3g0v0.json",
]
func skipNewBCTests*(folder: string, name: string): bool =
if folder == "vmPerformance" or folder == "stStaticCall":
return true
# the new BC tests also contains these slow tests
# for Istanbul fork
if slowGSTTests(folder, name):
@ -133,5 +142,12 @@ func skipNewBCTests*(folder: string, name: string): bool =
name in @[
# BC huge memory consumption
"randomStatetest94.json",
"DelegateCallSpam.json"
"DelegateCallSpam.json",
# a bug in ethereum test that later fixed, skip for now
"shouldSucceedWhenReturnStackGrowsUntil1023.json"
]
func skipPrecompilesTests*(folder: string, name: string): bool =
# EIP2565: temporary disabled
name == "modexp_eip2565.json"

View File

@ -249,8 +249,11 @@ func vmConfiguration(network: string, c: var ChainConfig): VMConfig =
of "Istanbul":
result = [(0, FkIstanbul), (0, FkIstanbul)]
c.istanbulBlock = 0.toBlockNumber
of "Berlin":
result = [(0, FkBerlin), (0, FkBerlin)]
c.berlinBlock = 0.toBlockNumber
else:
raise newException(ValueError, "unsupported network")
raise newException(ValueError, "unsupported network " & network)
func vmConfigToFork(vmConfig: VMConfig, blockNumber: Uint256): Fork =
if blockNumber >= vmConfig[1].blockNumber.u256: return vmConfig[1].fork

View File

@ -9,7 +9,7 @@ import
unittest2, ../nimbus/vm/precompiles, json, stew/byteutils, test_helpers, os, tables,
strformat, strutils, eth/trie/db, eth/common, ../nimbus/db/db_chain,
../nimbus/[vm_types, vm_state], ../nimbus/vm/computation, macros,
../nimbus/vm/interpreter/vm_forks
../nimbus/vm/interpreter/vm_forks, test_allowed_to_fail
proc initAddress(i: byte): EthAddress = result[19] = i
@ -93,7 +93,7 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
proc precompilesMain*() =
suite "Precompiles":
jsonTest("PrecompileTests", testFixture)
jsonTest("PrecompileTests", testFixture, skipPrecompilesTests)
when isMainModule:
precompilesMain()

View File

@ -6,12 +6,13 @@
# at your option. This file may not be copied, modified, or distributed except according to those terms.
import unittest2, eth/trie/[hexary, db],
../nimbus/db/state_db, stew/byteutils, eth/common
../nimbus/db/state_db, stew/[byteutils, endians2], eth/common
include ../nimbus/db/accounts_cache
func initAddr(z: int): EthAddress =
result[^1] = z.byte
const L = sizeof(result)
result[L-sizeof(uint32)..^1] = toBytesBE(z.uint32)
proc stateDBMain*() =
suite "Account State DB":
@ -149,5 +150,69 @@ proc stateDBMain*() =
let key = contractHashKey(hexary.keccak(code))
check acDB.get(key.toOpenArray) == code
test "accessList operations":
proc verifyAddrs(ac: AccountsCache, addrs: varargs[int]): bool =
for c in addrs:
if not ac.inAccessList(c.initAddr):
return false
true
proc verifySlots(ac: AccountsCache, address: int, slots: varargs[int]): bool =
let a = address.initAddr
if not ac.inAccessList(a):
return false
for c in slots:
if not ac.inAccessList(a, c.u256):
return false
true
proc accessList(ac: var AccountsCache, address: int) {.inline.} =
ac.accessList(address.initAddr)
proc accessList(ac: var AccountsCache, address, slot: int) {.inline.} =
ac.accessList(address.initAddr, slot.u256)
var ac = init(AccountsCache, acDB)
ac.accessList(0xaa)
ac.accessList(0xbb, 0x01)
ac.accessList(0xbb, 0x02)
check ac.verifyAddrs(0xaa, 0xbb)
check ac.verifySlots(0xbb, 0x01, 0x02)
check ac.verifySlots(0xaa, 0x01) == false
check ac.verifySlots(0xaa, 0x02) == false
var sp = ac.beginSavepoint
# some new ones
ac.accessList(0xbb, 0x03)
ac.accessList(0xaa, 0x01)
ac.accessList(0xcc, 0x01)
ac.accessList(0xcc)
check ac.verifyAddrs(0xaa, 0xbb, 0xcc)
check ac.verifySlots(0xaa, 0x01)
check ac.verifySlots(0xbb, 0x01, 0x02, 0x03)
check ac.verifySlots(0xcc, 0x01)
ac.rollback(sp)
check ac.verifyAddrs(0xaa, 0xbb)
check ac.verifyAddrs(0xcc) == false
check ac.verifySlots(0xcc, 0x01) == false
sp = ac.beginSavepoint
ac.accessList(0xbb, 0x03)
ac.accessList(0xaa, 0x01)
ac.accessList(0xcc, 0x01)
ac.accessList(0xcc)
ac.accessList(0xdd, 0x04)
ac.commit(sp)
check ac.verifyAddrs(0xaa, 0xbb, 0xcc)
check ac.verifySlots(0xaa, 0x01)
check ac.verifySlots(0xbb, 0x01, 0x02, 0x03)
check ac.verifySlots(0xcc, 0x01)
check ac.verifySlots(0xdd, 0x04)
when isMainModule:
stateDBMain()

View File

@ -2538,6 +2538,21 @@ OK: 9/9 Fail: 0/9 Skip: 0/9
+ static_refund_CallToSuicideTwice.json OK
```
OK: 283/283 Fail: 0/283 Skip: 0/283
## stSubroutine
```diff
+ beginSubAtEndOfCode.json OK
+ shouldErrorWhenExecuteBeginSub.json OK
+ shouldErrorWhenJumpToJumpDest.json OK
+ shouldErrorWhenReturnStackGrowsAbove1023.json OK
+ shouldErrorWhenSubroutineEnteredViaBeginSub.json OK
+ shouldSucceedWhenReturnStackGrowsUntil1023.json OK
+ simpleSubroutine.json OK
+ subroutineAtEndOfCode.json OK
+ subroutineInvalidJump.json OK
+ subroutineShallowReturnStack.json OK
+ twoLevelsSubroutines.json OK
```
OK: 11/11 Fail: 0/11 Skip: 0/11
## stSystemOperationsTest
```diff
+ ABAcalls0.json OK
@ -3686,4 +3701,4 @@ OK: 7/7 Fail: 0/7 Skip: 0/7
OK: 1/1 Fail: 0/1 Skip: 0/1
---TOTAL---
OK: 3340/3340 Fail: 0/3340 Skip: 0/3340
OK: 3351/3351 Fail: 0/3351 Skip: 0/3351

View File

@ -2135,6 +2135,21 @@ OK: 9/9 Fail: 0/9 Skip: 0/9
+ static_refund_CallToSuicideTwice.json OK
```
OK: 283/283 Fail: 0/283 Skip: 0/283
## stSubroutine
```diff
+ beginSubAtEndOfCode.json OK
+ shouldErrorWhenExecuteBeginSub.json OK
+ shouldErrorWhenJumpToJumpDest.json OK
+ shouldErrorWhenReturnStackGrowsAbove1023.json OK
+ shouldErrorWhenSubroutineEnteredViaBeginSub.json OK
+ shouldSucceedWhenReturnStackGrowsUntil1023.json OK
+ simpleSubroutine.json OK
+ subroutineAtEndOfCode.json OK
+ subroutineInvalidJump.json OK
+ subroutineShallowReturnStack.json OK
+ twoLevelsSubroutines.json OK
```
OK: 11/11 Fail: 0/11 Skip: 0/11
## stSystemOperationsTest
```diff
+ ABAcalls0.json OK
@ -2626,4 +2641,4 @@ OK: 133/133 Fail: 0/133 Skip: 0/133
OK: 130/130 Fail: 0/130 Skip: 0/130
---TOTAL---
OK: 2412/2412 Fail: 0/2412 Skip: 0/2412
OK: 2423/2423 Fail: 0/2423 Skip: 0/2423