Merge branch 'jangko-evm_transform'
This commit is contained in:
commit
4d29677f5a
|
@ -52,10 +52,10 @@ GeneralStateTests
|
|||
OK: 0/46 Fail: 0/46 Skip: 46/46
|
||||
## stAttackTest
|
||||
```diff
|
||||
ContractCreationSpam.json Skip
|
||||
+ ContractCreationSpam.json OK
|
||||
+ CrashingTransaction.json OK
|
||||
```
|
||||
OK: 1/2 Fail: 0/2 Skip: 1/2
|
||||
OK: 2/2 Fail: 0/2 Skip: 0/2
|
||||
## stBadOpcode
|
||||
```diff
|
||||
+ badOpcodes.json OK
|
||||
|
@ -89,7 +89,7 @@ OK: 2/3 Fail: 0/3 Skip: 1/3
|
|||
+ callcallcallcode_001_OOGMBefore.json OK
|
||||
+ callcallcallcode_001_SuicideEnd.json OK
|
||||
+ callcallcallcode_001_SuicideMiddle.json OK
|
||||
callcallcallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcallcallcode_ABCB_RECURSIVE.json OK
|
||||
+ callcallcode_01.json OK
|
||||
+ callcallcode_01_OOGE.json OK
|
||||
+ callcallcode_01_SuicideEnd.json OK
|
||||
|
@ -99,14 +99,14 @@ OK: 2/3 Fail: 0/3 Skip: 1/3
|
|||
+ callcallcodecall_010_OOGMBefore.json OK
|
||||
+ callcallcodecall_010_SuicideEnd.json OK
|
||||
+ callcallcodecall_010_SuicideMiddle.json OK
|
||||
callcallcodecall_ABCB_RECURSIVE.json Skip
|
||||
+ callcallcodecall_ABCB_RECURSIVE.json OK
|
||||
+ callcallcodecallcode_011.json OK
|
||||
+ callcallcodecallcode_011_OOGE.json OK
|
||||
+ callcallcodecallcode_011_OOGMAfter.json OK
|
||||
+ callcallcodecallcode_011_OOGMBefore.json OK
|
||||
+ callcallcodecallcode_011_SuicideEnd.json OK
|
||||
+ callcallcodecallcode_011_SuicideMiddle.json OK
|
||||
callcallcodecallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcallcodecallcode_ABCB_RECURSIVE.json OK
|
||||
+ callcodeDynamicCode.json OK
|
||||
+ callcodeDynamicCode2SelfCall.json OK
|
||||
+ callcodeEmptycontract.json OK
|
||||
|
@ -124,14 +124,14 @@ OK: 2/3 Fail: 0/3 Skip: 1/3
|
|||
+ callcodecallcall_100_OOGMBefore.json OK
|
||||
+ callcodecallcall_100_SuicideEnd.json OK
|
||||
+ callcodecallcall_100_SuicideMiddle.json OK
|
||||
callcodecallcall_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcall_ABCB_RECURSIVE.json OK
|
||||
+ callcodecallcallcode_101.json OK
|
||||
+ callcodecallcallcode_101_OOGE.json OK
|
||||
+ callcodecallcallcode_101_OOGMAfter.json OK
|
||||
+ callcodecallcallcode_101_OOGMBefore.json OK
|
||||
+ callcodecallcallcode_101_SuicideEnd.json OK
|
||||
+ callcodecallcallcode_101_SuicideMiddle.json OK
|
||||
callcodecallcallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcallcode_ABCB_RECURSIVE.json OK
|
||||
+ callcodecallcode_11.json OK
|
||||
+ callcodecallcode_11_OOGE.json OK
|
||||
+ callcodecallcode_11_SuicideEnd.json OK
|
||||
|
@ -141,25 +141,25 @@ OK: 2/3 Fail: 0/3 Skip: 1/3
|
|||
+ callcodecallcodecall_110_OOGMBefore.json OK
|
||||
+ callcodecallcodecall_110_SuicideEnd.json OK
|
||||
+ callcodecallcodecall_110_SuicideMiddle.json OK
|
||||
callcodecallcodecall_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcodecall_ABCB_RECURSIVE.json OK
|
||||
+ callcodecallcodecallcode_111.json OK
|
||||
+ callcodecallcodecallcode_111_OOGE.json OK
|
||||
+ callcodecallcodecallcode_111_OOGMAfter.json OK
|
||||
+ callcodecallcodecallcode_111_OOGMBefore.json OK
|
||||
+ callcodecallcodecallcode_111_SuicideEnd.json OK
|
||||
+ callcodecallcodecallcode_111_SuicideMiddle.json OK
|
||||
callcodecallcodecallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcodecallcode_ABCB_RECURSIVE.json OK
|
||||
```
|
||||
OK: 72/79 Fail: 0/79 Skip: 7/79
|
||||
OK: 79/79 Fail: 0/79 Skip: 0/79
|
||||
## stCallCreateCallCodeTest
|
||||
```diff
|
||||
Call1024BalanceTooLow.json Skip
|
||||
Call1024OOG.json Skip
|
||||
Call1024PreCalls.json Skip
|
||||
+ Call1024BalanceTooLow.json OK
|
||||
+ Call1024OOG.json OK
|
||||
+ Call1024PreCalls.json OK
|
||||
+ CallLoseGasOOG.json OK
|
||||
CallRecursiveBombPreCall.json Skip
|
||||
+ CallRecursiveBombPreCall.json OK
|
||||
+ Callcode1024BalanceTooLow.json OK
|
||||
Callcode1024OOG.json Skip
|
||||
+ Callcode1024OOG.json OK
|
||||
+ CallcodeLoseGasOOG.json OK
|
||||
+ callOutput1.json OK
|
||||
+ callOutput2.json OK
|
||||
|
@ -193,7 +193,7 @@ OK: 72/79 Fail: 0/79 Skip: 7/79
|
|||
+ createNameRegistratorPreStore1NotEnoughGas.json OK
|
||||
+ createNameRegistratorendowmentTooHigh.json OK
|
||||
```
|
||||
OK: 34/39 Fail: 0/39 Skip: 5/39
|
||||
OK: 39/39 Fail: 0/39 Skip: 0/39
|
||||
## stCallDelegateCodesCallCodeHomestead
|
||||
```diff
|
||||
+ callcallcallcode_001.json OK
|
||||
|
@ -202,7 +202,7 @@ OK: 34/39 Fail: 0/39 Skip: 5/39
|
|||
+ callcallcallcode_001_OOGMBefore.json OK
|
||||
+ callcallcallcode_001_SuicideEnd.json OK
|
||||
+ callcallcallcode_001_SuicideMiddle.json OK
|
||||
callcallcallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcallcallcode_ABCB_RECURSIVE.json OK
|
||||
+ callcallcode_01.json OK
|
||||
+ callcallcode_01_OOGE.json OK
|
||||
+ callcallcode_01_SuicideEnd.json OK
|
||||
|
@ -212,14 +212,14 @@ OK: 34/39 Fail: 0/39 Skip: 5/39
|
|||
+ callcallcodecall_010_OOGMBefore.json OK
|
||||
+ callcallcodecall_010_SuicideEnd.json OK
|
||||
+ callcallcodecall_010_SuicideMiddle.json OK
|
||||
callcallcodecall_ABCB_RECURSIVE.json Skip
|
||||
+ callcallcodecall_ABCB_RECURSIVE.json OK
|
||||
+ callcallcodecallcode_011.json OK
|
||||
+ callcallcodecallcode_011_OOGE.json OK
|
||||
+ callcallcodecallcode_011_OOGMAfter.json OK
|
||||
+ callcallcodecallcode_011_OOGMBefore.json OK
|
||||
+ callcallcodecallcode_011_SuicideEnd.json OK
|
||||
+ callcallcodecallcode_011_SuicideMiddle.json OK
|
||||
callcallcodecallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcallcodecallcode_ABCB_RECURSIVE.json OK
|
||||
+ callcodecall_10.json OK
|
||||
+ callcodecall_10_OOGE.json OK
|
||||
+ callcodecall_10_SuicideEnd.json OK
|
||||
|
@ -229,14 +229,14 @@ OK: 34/39 Fail: 0/39 Skip: 5/39
|
|||
+ callcodecallcall_100_OOGMBefore.json OK
|
||||
+ callcodecallcall_100_SuicideEnd.json OK
|
||||
+ callcodecallcall_100_SuicideMiddle.json OK
|
||||
callcodecallcall_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcall_ABCB_RECURSIVE.json OK
|
||||
+ callcodecallcallcode_101.json OK
|
||||
+ callcodecallcallcode_101_OOGE.json OK
|
||||
+ callcodecallcallcode_101_OOGMAfter.json OK
|
||||
+ callcodecallcallcode_101_OOGMBefore.json OK
|
||||
+ callcodecallcallcode_101_SuicideEnd.json OK
|
||||
+ callcodecallcallcode_101_SuicideMiddle.json OK
|
||||
callcodecallcallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcallcode_ABCB_RECURSIVE.json OK
|
||||
+ callcodecallcode_11.json OK
|
||||
+ callcodecallcode_11_OOGE.json OK
|
||||
+ callcodecallcode_11_SuicideEnd.json OK
|
||||
|
@ -246,16 +246,16 @@ OK: 34/39 Fail: 0/39 Skip: 5/39
|
|||
+ callcodecallcodecall_110_OOGMBefore.json OK
|
||||
+ callcodecallcodecall_110_SuicideEnd.json OK
|
||||
+ callcodecallcodecall_110_SuicideMiddle.json OK
|
||||
callcodecallcodecall_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcodecall_ABCB_RECURSIVE.json OK
|
||||
+ callcodecallcodecallcode_111.json OK
|
||||
+ callcodecallcodecallcode_111_OOGE.json OK
|
||||
+ callcodecallcodecallcode_111_OOGMAfter.json OK
|
||||
+ callcodecallcodecallcode_111_OOGMBefore.json OK
|
||||
+ callcodecallcodecallcode_111_SuicideEnd.json OK
|
||||
+ callcodecallcodecallcode_111_SuicideMiddle.json OK
|
||||
callcodecallcodecallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcodecallcode_ABCB_RECURSIVE.json OK
|
||||
```
|
||||
OK: 51/58 Fail: 0/58 Skip: 7/58
|
||||
OK: 58/58 Fail: 0/58 Skip: 0/58
|
||||
## stCallDelegateCodesHomestead
|
||||
```diff
|
||||
+ callcallcallcode_001.json OK
|
||||
|
@ -264,7 +264,7 @@ OK: 51/58 Fail: 0/58 Skip: 7/58
|
|||
+ callcallcallcode_001_OOGMBefore.json OK
|
||||
+ callcallcallcode_001_SuicideEnd.json OK
|
||||
+ callcallcallcode_001_SuicideMiddle.json OK
|
||||
callcallcallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcallcallcode_ABCB_RECURSIVE.json OK
|
||||
+ callcallcode_01.json OK
|
||||
+ callcallcode_01_OOGE.json OK
|
||||
+ callcallcode_01_SuicideEnd.json OK
|
||||
|
@ -274,14 +274,14 @@ OK: 51/58 Fail: 0/58 Skip: 7/58
|
|||
+ callcallcodecall_010_OOGMBefore.json OK
|
||||
+ callcallcodecall_010_SuicideEnd.json OK
|
||||
+ callcallcodecall_010_SuicideMiddle.json OK
|
||||
callcallcodecall_ABCB_RECURSIVE.json Skip
|
||||
+ callcallcodecall_ABCB_RECURSIVE.json OK
|
||||
+ callcallcodecallcode_011.json OK
|
||||
+ callcallcodecallcode_011_OOGE.json OK
|
||||
+ callcallcodecallcode_011_OOGMAfter.json OK
|
||||
+ callcallcodecallcode_011_OOGMBefore.json OK
|
||||
+ callcallcodecallcode_011_SuicideEnd.json OK
|
||||
+ callcallcodecallcode_011_SuicideMiddle.json OK
|
||||
callcallcodecallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcallcodecallcode_ABCB_RECURSIVE.json OK
|
||||
+ callcodecall_10.json OK
|
||||
+ callcodecall_10_OOGE.json OK
|
||||
+ callcodecall_10_SuicideEnd.json OK
|
||||
|
@ -291,14 +291,14 @@ OK: 51/58 Fail: 0/58 Skip: 7/58
|
|||
+ callcodecallcall_100_OOGMBefore.json OK
|
||||
+ callcodecallcall_100_SuicideEnd.json OK
|
||||
+ callcodecallcall_100_SuicideMiddle.json OK
|
||||
callcodecallcall_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcall_ABCB_RECURSIVE.json OK
|
||||
+ callcodecallcallcode_101.json OK
|
||||
+ callcodecallcallcode_101_OOGE.json OK
|
||||
+ callcodecallcallcode_101_OOGMAfter.json OK
|
||||
+ callcodecallcallcode_101_OOGMBefore.json OK
|
||||
+ callcodecallcallcode_101_SuicideEnd.json OK
|
||||
+ callcodecallcallcode_101_SuicideMiddle.json OK
|
||||
callcodecallcallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcallcode_ABCB_RECURSIVE.json OK
|
||||
+ callcodecallcode_11.json OK
|
||||
+ callcodecallcode_11_OOGE.json OK
|
||||
+ callcodecallcode_11_SuicideEnd.json OK
|
||||
|
@ -308,20 +308,20 @@ OK: 51/58 Fail: 0/58 Skip: 7/58
|
|||
+ callcodecallcodecall_110_OOGMBefore.json OK
|
||||
+ callcodecallcodecall_110_SuicideEnd.json OK
|
||||
+ callcodecallcodecall_110_SuicideMiddle.json OK
|
||||
callcodecallcodecall_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcodecall_ABCB_RECURSIVE.json OK
|
||||
+ callcodecallcodecallcode_111.json OK
|
||||
+ callcodecallcodecallcode_111_OOGE.json OK
|
||||
+ callcodecallcodecallcode_111_OOGMAfter.json OK
|
||||
+ callcodecallcodecallcode_111_OOGMBefore.json OK
|
||||
+ callcodecallcodecallcode_111_SuicideEnd.json OK
|
||||
+ callcodecallcodecallcode_111_SuicideMiddle.json OK
|
||||
callcodecallcodecallcode_ABCB_RECURSIVE.json Skip
|
||||
+ callcodecallcodecallcode_ABCB_RECURSIVE.json OK
|
||||
```
|
||||
OK: 51/58 Fail: 0/58 Skip: 7/58
|
||||
OK: 58/58 Fail: 0/58 Skip: 0/58
|
||||
## stChangedEIP150
|
||||
```diff
|
||||
Call1024BalanceTooLow.json Skip
|
||||
Call1024PreCalls.json Skip
|
||||
+ Call1024BalanceTooLow.json OK
|
||||
+ Call1024PreCalls.json OK
|
||||
+ Callcode1024BalanceTooLow.json OK
|
||||
+ callcall_00_OOGE_1.json OK
|
||||
+ callcall_00_OOGE_2.json OK
|
||||
|
@ -351,7 +351,7 @@ OK: 51/58 Fail: 0/58 Skip: 7/58
|
|||
+ contractCreationMakeCallThatAskMoreGasThenTransactionProvided.jsonOK
|
||||
+ createInitFail_OOGduringInit.json OK
|
||||
```
|
||||
OK: 28/30 Fail: 0/30 Skip: 2/30
|
||||
OK: 30/30 Fail: 0/30 Skip: 0/30
|
||||
## stCodeCopyTest
|
||||
```diff
|
||||
+ ExtCodeCopyTests.json OK
|
||||
|
@ -400,14 +400,14 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
|
|||
OK: 23/30 Fail: 0/30 Skip: 7/30
|
||||
## stDelegatecallTestHomestead
|
||||
```diff
|
||||
Call1024BalanceTooLow.json Skip
|
||||
Call1024OOG.json Skip
|
||||
Call1024PreCalls.json Skip
|
||||
+ Call1024BalanceTooLow.json OK
|
||||
+ Call1024OOG.json OK
|
||||
+ Call1024PreCalls.json OK
|
||||
+ CallLoseGasOOG.json OK
|
||||
CallRecursiveBombPreCall.json Skip
|
||||
+ CallRecursiveBombPreCall.json OK
|
||||
+ CallcodeLoseGasOOG.json OK
|
||||
Delegatecall1024.json Skip
|
||||
Delegatecall1024OOG.json Skip
|
||||
+ Delegatecall1024.json OK
|
||||
+ Delegatecall1024OOG.json OK
|
||||
+ callOutput1.json OK
|
||||
+ callOutput2.json OK
|
||||
+ callOutput3.json OK
|
||||
|
@ -435,7 +435,7 @@ OK: 23/30 Fail: 0/30 Skip: 7/30
|
|||
+ delegatecodeDynamicCode.json OK
|
||||
+ delegatecodeDynamicCode2SelfCall.json OK
|
||||
```
|
||||
OK: 28/34 Fail: 0/34 Skip: 6/34
|
||||
OK: 34/34 Fail: 0/34 Skip: 0/34
|
||||
## stEIP150Specific
|
||||
```diff
|
||||
CallAndCallcodeConsumeMoreGasThenTransactionHas.json Skip
|
||||
|
@ -1518,10 +1518,10 @@ OK: 321/327 Fail: 0/327 Skip: 6/327
|
|||
OK: 223/227 Fail: 0/227 Skip: 4/227
|
||||
## stRecursiveCreate
|
||||
```diff
|
||||
recursiveCreate.json Skip
|
||||
recursiveCreateReturnValue.json Skip
|
||||
+ recursiveCreate.json OK
|
||||
+ recursiveCreateReturnValue.json OK
|
||||
```
|
||||
OK: 0/2 Fail: 0/2 Skip: 2/2
|
||||
OK: 2/2 Fail: 0/2 Skip: 0/2
|
||||
## stRefundTest
|
||||
```diff
|
||||
+ refund50_1.json OK
|
||||
|
@ -1700,8 +1700,8 @@ OK: 16/16 Fail: 0/16 Skip: 0/16
|
|||
## stSpecialTest
|
||||
```diff
|
||||
+ FailedCreateRevertsDeletion.json OK
|
||||
JUMPDEST_Attack.json Skip
|
||||
JUMPDEST_AttackwithJump.json Skip
|
||||
+ JUMPDEST_Attack.json OK
|
||||
+ JUMPDEST_AttackwithJump.json OK
|
||||
OverflowGasMakeMoney.json Skip
|
||||
+ StackDepthLimitSEC.json OK
|
||||
block504980.json Skip
|
||||
|
@ -1713,7 +1713,7 @@ OK: 16/16 Fail: 0/16 Skip: 0/16
|
|||
txCost-sec73.json Skip
|
||||
+ tx_e1c174e2.json OK
|
||||
```
|
||||
OK: 5/13 Fail: 0/13 Skip: 8/13
|
||||
OK: 7/13 Fail: 0/13 Skip: 6/13
|
||||
## stStackTests
|
||||
```diff
|
||||
shallowStack.json Skip
|
||||
|
@ -2016,19 +2016,19 @@ OK: 0/284 Fail: 0/284 Skip: 284/284
|
|||
## stSystemOperationsTest
|
||||
```diff
|
||||
+ ABAcalls0.json OK
|
||||
ABAcalls1.json Skip
|
||||
ABAcalls2.json Skip
|
||||
+ ABAcalls1.json OK
|
||||
+ ABAcalls2.json OK
|
||||
+ ABAcalls3.json OK
|
||||
+ ABAcallsSuicide0.json OK
|
||||
+ ABAcallsSuicide1.json OK
|
||||
+ Call10.json OK
|
||||
CallRecursiveBomb0.json Skip
|
||||
CallRecursiveBomb0_OOG_atMaxCallDepth.json Skip
|
||||
CallRecursiveBomb1.json Skip
|
||||
CallRecursiveBomb2.json Skip
|
||||
+ CallRecursiveBomb0.json OK
|
||||
+ CallRecursiveBomb0_OOG_atMaxCallDepth.json OK
|
||||
+ CallRecursiveBomb1.json OK
|
||||
+ CallRecursiveBomb2.json OK
|
||||
+ CallRecursiveBomb3.json OK
|
||||
CallRecursiveBombLog.json Skip
|
||||
CallRecursiveBombLog2.json Skip
|
||||
+ CallRecursiveBombLog.json OK
|
||||
+ CallRecursiveBombLog2.json OK
|
||||
+ CallToNameRegistrator0.json OK
|
||||
+ CallToNameRegistratorAddressTooBigLeft.json OK
|
||||
+ CallToNameRegistratorAddressTooBigRight.json OK
|
||||
|
@ -2083,7 +2083,7 @@ OK: 0/284 Fail: 0/284 Skip: 284/284
|
|||
+ suicideSendEtherToMe.json OK
|
||||
+ testRandomTest.json OK
|
||||
```
|
||||
OK: 57/67 Fail: 0/67 Skip: 10/67
|
||||
OK: 65/67 Fail: 0/67 Skip: 2/67
|
||||
## stTransactionTest
|
||||
```diff
|
||||
+ ContractStoreClearsOOG.json OK
|
||||
|
@ -2377,13 +2377,13 @@ OK: 24/24 Fail: 0/24 Skip: 0/24
|
|||
ecpairing_two_point_match_5.json Skip
|
||||
ecpairing_two_point_oog.json Skip
|
||||
ecpairing_two_points_with_one_g2_zero.json Skip
|
||||
pairingTest.json Skip
|
||||
pointAdd.json Skip
|
||||
pointAddTrunc.json Skip
|
||||
pointMulAdd.json Skip
|
||||
pointMulAdd2.json Skip
|
||||
+ pairingTest.json OK
|
||||
+ pointAdd.json OK
|
||||
+ pointAddTrunc.json OK
|
||||
+ pointMulAdd.json OK
|
||||
+ pointMulAdd2.json OK
|
||||
```
|
||||
OK: 0/133 Fail: 0/133 Skip: 133/133
|
||||
OK: 5/133 Fail: 0/133 Skip: 128/133
|
||||
## stZeroKnowledge2
|
||||
```diff
|
||||
ecadd_0-0_0-0_21000_0.json Skip
|
||||
|
@ -2520,4 +2520,4 @@ OK: 0/133 Fail: 0/133 Skip: 133/133
|
|||
OK: 0/130 Fail: 0/130 Skip: 130/130
|
||||
|
||||
---TOTAL---
|
||||
OK: 1433/2334 Fail: 0/2334 Skip: 901/2334
|
||||
OK: 1485/2334 Fail: 0/2334 Skip: 849/2334
|
||||
|
|
|
@ -34,6 +34,9 @@ proc newBaseComputation*(vmState: BaseVMState, blockNumber: UInt256, message: Me
|
|||
else:
|
||||
blockNumber.toFork.forkToSchedule
|
||||
result.forkOverride = forkOverride
|
||||
# a dummy/terminus continuation proc
|
||||
result.nextProc = proc() =
|
||||
discard
|
||||
|
||||
proc isOriginComputation*(c: BaseComputation): bool =
|
||||
# Is this computation the computation initiated by a transaction
|
||||
|
@ -61,7 +64,7 @@ func output*(c: BaseComputation): seq[byte] =
|
|||
else:
|
||||
c.rawOutput
|
||||
|
||||
func `output=`*(c: var BaseComputation, value: openarray[byte]) =
|
||||
func `output=`*(c: BaseComputation, value: openarray[byte]) =
|
||||
c.rawOutput = @value
|
||||
|
||||
proc outputHex*(c: BaseComputation): string =
|
||||
|
@ -69,11 +72,11 @@ proc outputHex*(c: BaseComputation): string =
|
|||
return "0x"
|
||||
c.rawOutput.bytesToHex
|
||||
|
||||
proc isSuicided*(c: var BaseComputation, address: EthAddress): bool =
|
||||
proc isSuicided*(c: BaseComputation, address: EthAddress): bool =
|
||||
result = address in c.accountsToDelete
|
||||
|
||||
proc prepareChildMessage*(
|
||||
c: var BaseComputation,
|
||||
c: BaseComputation,
|
||||
gas: GasInt,
|
||||
to: EthAddress,
|
||||
value: UInt256,
|
||||
|
@ -111,6 +114,14 @@ proc commit*(comp: BaseComputation) =
|
|||
proc dispose*(comp: BaseComputation) {.inline.} =
|
||||
comp.dbsnapshot.transaction.dispose()
|
||||
|
||||
proc rollback*(comp: BaseComputation) =
|
||||
comp.dbsnapshot.transaction.rollback()
|
||||
comp.vmState.accountDb.rootHash = comp.dbsnapshot.intermediateRoot
|
||||
comp.vmState.blockHeader.stateRoot = comp.dbsnapshot.intermediateRoot
|
||||
|
||||
proc setError*(comp: BaseComputation, msg: string, burnsGas = false) {.inline.} =
|
||||
comp.error = Error(info: msg, burnsGas: burnsGas)
|
||||
|
||||
proc getFork*(computation: BaseComputation): Fork =
|
||||
result =
|
||||
if computation.forkOverride.isSome:
|
||||
|
@ -118,7 +129,7 @@ proc getFork*(computation: BaseComputation): Fork =
|
|||
else:
|
||||
computation.vmState.blockNumber.toFork
|
||||
|
||||
proc writeContract*(computation: var BaseComputation, fork: Fork): bool =
|
||||
proc writeContract*(computation: BaseComputation, fork: Fork): bool =
|
||||
result = true
|
||||
|
||||
let contractCode = computation.output
|
||||
|
@ -142,65 +153,68 @@ proc writeContract*(computation: var BaseComputation, fork: Fork): bool =
|
|||
if fork < FkHomestead: computation.output = @[]
|
||||
result = false
|
||||
|
||||
proc transferBalance(computation: var BaseComputation, opCode: static[Op]): bool =
|
||||
proc transferBalance(computation: BaseComputation, opCode: static[Op]) =
|
||||
if computation.msg.depth > MaxCallDepth:
|
||||
debug "Stack depth limit reached", depth=computation.msg.depth
|
||||
return false
|
||||
computation.setError(&"Stack depth limit reached depth={computation.msg.depth}")
|
||||
return
|
||||
|
||||
let senderBalance = computation.vmState.readOnlyStateDb().
|
||||
getBalance(computation.msg.sender)
|
||||
|
||||
if senderBalance < computation.msg.value:
|
||||
debug "insufficient funds", available=senderBalance, needed=computation.msg.value
|
||||
return false
|
||||
computation.setError(&"insufficient funds available={senderBalance}, needed={computation.msg.value}")
|
||||
return
|
||||
|
||||
when opCode in {Call, Create}:
|
||||
computation.vmState.mutateStateDb:
|
||||
db.subBalance(computation.msg.sender, computation.msg.value)
|
||||
db.addBalance(computation.msg.storageAddress, computation.msg.value)
|
||||
|
||||
result = true
|
||||
template continuation*(comp: BaseComputation, body: untyped) =
|
||||
# this is a helper template to implement continuation
|
||||
# passing and convert all recursion into tail call
|
||||
var tmpNext = comp.nextProc
|
||||
comp.nextProc = proc() =
|
||||
body
|
||||
tmpNext()
|
||||
|
||||
proc executeOpcodes*(computation: var BaseComputation) {.gcsafe.}
|
||||
proc postExecuteVM(computation: BaseComputation) =
|
||||
if computation.isSuccess and computation.msg.isCreate:
|
||||
let fork = computation.getFork
|
||||
let contractFailed = not computation.writeContract(fork)
|
||||
if contractFailed and fork == FkHomestead:
|
||||
computation.setError(&"writeContract failed, depth={computation.msg.depth}", true)
|
||||
|
||||
proc applyMessage*(computation: var BaseComputation, opCode: static[Op]): bool =
|
||||
if computation.isSuccess:
|
||||
computation.commit()
|
||||
else:
|
||||
computation.rollback()
|
||||
|
||||
proc executeOpcodes*(computation: BaseComputation) {.gcsafe.}
|
||||
|
||||
proc applyMessage*(computation: BaseComputation, opCode: static[Op]) =
|
||||
computation.snapshot()
|
||||
defer: computation.dispose()
|
||||
defer:
|
||||
computation.dispose()
|
||||
|
||||
when opCode in {CallCode, Call, Create}:
|
||||
if not computation.transferBalance(opCode):
|
||||
computation.revert()
|
||||
computation.transferBalance(opCode)
|
||||
if computation.isError():
|
||||
computation.rollback()
|
||||
computation.nextProc()
|
||||
return
|
||||
|
||||
if computation.gasMeter.gasRemaining < 0:
|
||||
computation.commit()
|
||||
computation.nextProc()
|
||||
return
|
||||
|
||||
try:
|
||||
executeOpcodes(computation)
|
||||
result = not computation.isError
|
||||
except VMError:
|
||||
result = false
|
||||
debug "applyMessage VM Error",
|
||||
msg = getCurrentExceptionMsg(),
|
||||
depth = computation.msg.depth
|
||||
except ValueError:
|
||||
result = false
|
||||
debug "applyMessage Value Error",
|
||||
msg = getCurrentExceptionMsg(),
|
||||
depth = computation.msg.depth
|
||||
continuation(computation):
|
||||
postExecuteVM(computation)
|
||||
|
||||
if result and computation.msg.isCreate:
|
||||
var fork = computation.getFork
|
||||
let contractFailed = not computation.writeContract(fork)
|
||||
result = not(contractFailed and fork == FkHomestead)
|
||||
executeOpcodes(computation)
|
||||
|
||||
if result:
|
||||
computation.commit()
|
||||
else:
|
||||
computation.revert(true)
|
||||
|
||||
proc addChildComputation(computation: var BaseComputation, child: BaseComputation) =
|
||||
proc addChildComputation*(computation: BaseComputation, child: BaseComputation) =
|
||||
if child.isError:
|
||||
if child.msg.isCreate:
|
||||
computation.returnData = child.output
|
||||
|
@ -216,21 +230,19 @@ proc addChildComputation(computation: var BaseComputation, child: BaseComputatio
|
|||
for k, v in child.accountsToDelete:
|
||||
computation.accountsToDelete[k] = v
|
||||
computation.logEntries.add child.logEntries
|
||||
|
||||
if not child.shouldBurnGas:
|
||||
computation.gasMeter.returnGas(child.gasMeter.gasRemaining)
|
||||
computation.children.add(child)
|
||||
|
||||
proc applyChildComputation*(parentComp, childComp: var BaseComputation, opCode: static[Op]) =
|
||||
## Apply the vm message childMsg as a child computation.
|
||||
discard childComp.applyMessage(opCode)
|
||||
parentComp.addChildComputation(childComp)
|
||||
|
||||
proc registerAccountForDeletion*(c: var BaseComputation, beneficiary: EthAddress) =
|
||||
proc registerAccountForDeletion*(c: BaseComputation, beneficiary: EthAddress) =
|
||||
if c.msg.storageAddress in c.accountsToDelete:
|
||||
raise newException(ValueError,
|
||||
"invariant: should be impossible for an account to be " &
|
||||
"registered for deletion multiple times")
|
||||
c.accountsToDelete[c.msg.storageAddress] = beneficiary
|
||||
|
||||
proc addLogEntry*(c: var BaseComputation, log: Log) {.inline.} =
|
||||
proc addLogEntry*(c: BaseComputation, log: Log) {.inline.} =
|
||||
c.logEntries.add(log)
|
||||
|
||||
# many methods are basically TODO, but they still return valid values
|
||||
|
|
|
@ -452,7 +452,7 @@ op sstore, inline = false, slot, value:
|
|||
computation.vmState.mutateStateDB:
|
||||
db.setStorage(computation.msg.storageAddress, slot, value)
|
||||
|
||||
proc jumpImpl(computation: var BaseComputation, jumpTarget: UInt256) =
|
||||
proc jumpImpl(computation: BaseComputation, jumpTarget: UInt256) =
|
||||
if jumpTarget >= computation.code.len.u256:
|
||||
raise newException(InvalidJumpDestination, "Invalid Jump Destination")
|
||||
|
||||
|
@ -537,7 +537,7 @@ proc canTransfer(computation: BaseComputation, memPos, memLen: int, value: Uint2
|
|||
|
||||
result = true
|
||||
|
||||
proc setupCreate(computation: var BaseComputation, memPos, len: int, value: Uint256): BaseComputation =
|
||||
proc setupCreate(computation: BaseComputation, memPos, len: int, value: Uint256): BaseComputation =
|
||||
let
|
||||
callData = computation.memory.read(memPos, len)
|
||||
createMsgGas = computation.getGasRemaining()
|
||||
|
@ -593,17 +593,18 @@ op create, inline = false, value, startPosition, size:
|
|||
var childComp = setupCreate(computation, memPos, len, value)
|
||||
if childComp.isNil: return
|
||||
|
||||
computation.applyChildComputation(childComp, Create)
|
||||
computation.child = childComp
|
||||
continuation(childComp):
|
||||
computation.addChildComputation(childComp)
|
||||
|
||||
if childComp.isError:
|
||||
push: 0
|
||||
else:
|
||||
push: childComp.msg.storageAddress
|
||||
if childComp.isError:
|
||||
push: 0
|
||||
else:
|
||||
push: childComp.msg.storageAddress
|
||||
|
||||
if not childComp.shouldBurnGas:
|
||||
computation.gasMeter.returnGas(childComp.gasMeter.gasRemaining)
|
||||
childComp.applyMessage(Create)
|
||||
|
||||
proc callParams(computation: var BaseComputation): (UInt256, UInt256, EthAddress, EthAddress, EthAddress, UInt256, UInt256, UInt256, UInt256, MsgFlags) =
|
||||
proc callParams(computation: BaseComputation): (UInt256, UInt256, EthAddress, EthAddress, EthAddress, UInt256, UInt256, UInt256, UInt256, MsgFlags) =
|
||||
let gas = computation.stack.popInt()
|
||||
let codeAddress = computation.stack.popAddress()
|
||||
|
||||
|
@ -625,7 +626,7 @@ proc callParams(computation: var BaseComputation): (UInt256, UInt256, EthAddress
|
|||
memoryOutputSize,
|
||||
computation.msg.flags)
|
||||
|
||||
proc callCodeParams(computation: var BaseComputation): (UInt256, UInt256, EthAddress, EthAddress, EthAddress, UInt256, UInt256, UInt256, UInt256, MsgFlags) =
|
||||
proc callCodeParams(computation: BaseComputation): (UInt256, UInt256, EthAddress, EthAddress, EthAddress, UInt256, UInt256, UInt256, UInt256, MsgFlags) =
|
||||
let gas = computation.stack.popInt()
|
||||
let to = computation.stack.popAddress()
|
||||
|
||||
|
@ -644,7 +645,7 @@ proc callCodeParams(computation: var BaseComputation): (UInt256, UInt256, EthAdd
|
|||
memoryOutputSize,
|
||||
computation.msg.flags)
|
||||
|
||||
proc delegateCallParams(computation: var BaseComputation): (UInt256, UInt256, EthAddress, EthAddress, EthAddress, UInt256, UInt256, UInt256, UInt256, MsgFlags) =
|
||||
proc delegateCallParams(computation: BaseComputation): (UInt256, UInt256, EthAddress, EthAddress, EthAddress, UInt256, UInt256, UInt256, UInt256, MsgFlags) =
|
||||
let gas = computation.stack.popInt()
|
||||
let codeAddress = computation.stack.popAddress()
|
||||
|
||||
|
@ -666,7 +667,7 @@ proc delegateCallParams(computation: var BaseComputation): (UInt256, UInt256, Et
|
|||
memoryOutputSize,
|
||||
computation.msg.flags)
|
||||
|
||||
proc staticCallParams(computation: var BaseComputation): (UInt256, UInt256, EthAddress, EthAddress, EthAddress, UInt256, UInt256, UInt256, UInt256, MsgFlags) =
|
||||
proc staticCallParams(computation: BaseComputation): (UInt256, UInt256, EthAddress, EthAddress, EthAddress, UInt256, UInt256, UInt256, UInt256, MsgFlags) =
|
||||
let gas = computation.stack.popInt()
|
||||
let to = computation.stack.popAddress()
|
||||
|
||||
|
@ -685,7 +686,7 @@ proc staticCallParams(computation: var BaseComputation): (UInt256, UInt256, EthA
|
|||
emvcStatic) # is_static
|
||||
|
||||
template genCall(callName: untyped, opCode: Op): untyped =
|
||||
proc `callName Setup`(computation: var BaseComputation, callNameStr: string): (BaseComputation, int, int) =
|
||||
proc `callName Setup`(computation: BaseComputation, callNameStr: string): BaseComputation =
|
||||
let (gas, value, to, sender,
|
||||
codeAddress,
|
||||
memoryInputStartPosition, memoryInputSize,
|
||||
|
@ -752,32 +753,33 @@ template genCall(callName: untyped, opCode: Op): untyped =
|
|||
childMsg,
|
||||
some(computation.getFork))
|
||||
|
||||
result = (childComp, memOutPos, memOutLen)
|
||||
computation.memOutPos = memOutPos
|
||||
computation.memOutLen = memOutLen
|
||||
result = childComp
|
||||
|
||||
op callName, inline = false:
|
||||
## CALL, 0xf1, Message-Call into an account
|
||||
## CALLCODE, 0xf2, Message-call into this account with an alternative account's code.
|
||||
## DELEGATECALL, 0xf4, Message-call into this account with an alternative account's code, but persisting the current values for sender and value.
|
||||
## STATICCALL, 0xfa, Static message-call into an account.
|
||||
var (childComp, memOutPos, memOutLen) = `callName Setup`(computation, callName.astToStr)
|
||||
var childComp = `callName Setup`(computation, callName.astToStr)
|
||||
|
||||
applyChildComputation(computation, childComp, opCode)
|
||||
computation.child = childComp
|
||||
continuation(childComp):
|
||||
addChildComputation(computation, childComp)
|
||||
|
||||
if childComp.isError:
|
||||
push: 0
|
||||
else:
|
||||
push: 1
|
||||
if childComp.isError:
|
||||
push: 0
|
||||
else:
|
||||
push: 1
|
||||
|
||||
if not childComp.shouldEraseReturnData:
|
||||
let actualOutputSize = min(memOutLen, childComp.output.len)
|
||||
computation.memory.write(
|
||||
memOutPos,
|
||||
childComp.output.toOpenArray(0, actualOutputSize - 1))
|
||||
if not childComp.shouldBurnGas:
|
||||
computation.gasMeter.returnGas(childComp.gasMeter.gasRemaining)
|
||||
if not childComp.shouldEraseReturnData:
|
||||
let actualOutputSize = min(computation.memOutLen, childComp.output.len)
|
||||
computation.memory.write(
|
||||
computation.memOutPos,
|
||||
childComp.output.toOpenArray(0, actualOutputSize - 1))
|
||||
|
||||
if computation.gasMeter.gasRemaining <= 0:
|
||||
raise newException(OutOfGas, "computation out of gas after contract call (" & callName.astToStr & ")")
|
||||
childComp.applyMessage(opCode)
|
||||
|
||||
genCall(call, Call)
|
||||
genCall(callCode, CallCode)
|
||||
|
|
|
@ -59,12 +59,12 @@ macro op*(procname: untyped, inline: static[bool], stackParams_body: varargs[unt
|
|||
# TODO: replace by func to ensure no side effects
|
||||
if inline:
|
||||
result = quote do:
|
||||
proc `procname`*(`computation`: var BaseComputation) {.inline.} =
|
||||
proc `procname`*(`computation`: BaseComputation) {.inline.} =
|
||||
`popStackStmt`
|
||||
`body`
|
||||
else:
|
||||
result = quote do:
|
||||
proc `procname`*(`computation`: var BaseComputation) =
|
||||
proc `procname`*(`computation`: BaseComputation) =
|
||||
`popStackStmt`
|
||||
`body`
|
||||
|
||||
|
@ -76,7 +76,7 @@ macro genPush*(): untyped =
|
|||
for size in 1 .. 32:
|
||||
let name = genName(size)
|
||||
result.add quote do:
|
||||
func `name`*(computation: var BaseComputation) {.inline.}=
|
||||
func `name`*(computation: BaseComputation) {.inline.}=
|
||||
## Push `size`-byte(s) on the stack
|
||||
computation.stack.push computation.code.readVmWord(`size`)
|
||||
|
||||
|
@ -87,7 +87,7 @@ macro genDup*(): untyped =
|
|||
for pos in 1 .. 16:
|
||||
let name = genName(pos)
|
||||
result.add quote do:
|
||||
func `name`*(computation: var BaseComputation) {.inline.}=
|
||||
func `name`*(computation: BaseComputation) {.inline.}=
|
||||
computation.stack.dup(`pos`)
|
||||
|
||||
macro genSwap*(): untyped =
|
||||
|
@ -97,10 +97,10 @@ macro genSwap*(): untyped =
|
|||
for pos in 1 .. 16:
|
||||
let name = genName(pos)
|
||||
result.add quote do:
|
||||
func `name`*(computation: var BaseComputation) {.inline.}=
|
||||
func `name`*(computation: BaseComputation) {.inline.}=
|
||||
computation.stack.swap(`pos`)
|
||||
|
||||
proc logImpl(c: var BaseComputation, opcode: Op, topicCount: int) =
|
||||
proc logImpl(c: BaseComputation, opcode: Op, topicCount: int) =
|
||||
doAssert(topicCount in 0 .. 4)
|
||||
let (memStartPosition, size) = c.stack.popInt(2)
|
||||
let (memPos, len) = (memStartPosition.cleanMemRef, size.cleanMemRef)
|
||||
|
@ -122,8 +122,8 @@ proc logImpl(c: var BaseComputation, opcode: Op, topicCount: int) =
|
|||
c.addLogEntry(log)
|
||||
|
||||
template genLog*() =
|
||||
proc log0*(c: var BaseComputation) {.inline.} = logImpl(c, Log0, 0)
|
||||
proc log1*(c: var BaseComputation) {.inline.} = logImpl(c, Log1, 1)
|
||||
proc log2*(c: var BaseComputation) {.inline.} = logImpl(c, Log2, 2)
|
||||
proc log3*(c: var BaseComputation) {.inline.} = logImpl(c, Log3, 3)
|
||||
proc log4*(c: var BaseComputation) {.inline.} = logImpl(c, Log4, 4)
|
||||
proc log0*(c: BaseComputation) {.inline.} = logImpl(c, Log0, 0)
|
||||
proc log1*(c: BaseComputation) {.inline.} = logImpl(c, Log1, 1)
|
||||
proc log2*(c: BaseComputation) {.inline.} = logImpl(c, Log2, 2)
|
||||
proc log3*(c: BaseComputation) {.inline.} = logImpl(c, Log3, 3)
|
||||
proc log4*(c: BaseComputation) {.inline.} = logImpl(c, Log4, 4)
|
||||
|
|
|
@ -16,7 +16,7 @@ import
|
|||
logScope:
|
||||
topics = "vm opcode"
|
||||
|
||||
func invalidInstruction*(computation: var BaseComputation) {.inline.} =
|
||||
func invalidInstruction*(computation: BaseComputation) {.inline.} =
|
||||
raise newException(InvalidInstruction, "Invalid instruction, received an opcode not implemented in the current fork.")
|
||||
|
||||
let FrontierOpDispatch {.compileTime.}: array[Op, NimNode] = block:
|
||||
|
@ -211,7 +211,6 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
|
|||
`opImpl`(`computation`)
|
||||
if `computation`.tracingEnabled:
|
||||
`computation`.traceOpCodeEnded(`asOp`, `computation`.opIndex)
|
||||
`instr` = `computation`.code.next()
|
||||
else:
|
||||
quote do:
|
||||
if `computation`.tracingEnabled:
|
||||
|
@ -221,8 +220,6 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
|
|||
`computation`.traceOpCodeEnded(`asOp`, `computation`.opIndex)
|
||||
when `asOp` in {Return, Revert, SelfDestruct}:
|
||||
break
|
||||
else:
|
||||
`instr` = `computation`.code.next()
|
||||
|
||||
result.add nnkOfBranch.newTree(
|
||||
newIdentNode($op),
|
||||
|
@ -233,9 +230,11 @@ proc opTableToCaseStmt(opTable: array[Op, NimNode], computation: NimNode): NimNo
|
|||
result = quote do:
|
||||
if `computation`.tracingEnabled:
|
||||
`computation`.prepareTracer()
|
||||
`computation`.instr = `computation`.code.next()
|
||||
while true:
|
||||
{.computedGoto.}
|
||||
`instr` = `computation`.code.next()
|
||||
#{.computedGoto.}
|
||||
# computed goto causing stack overflow, it consumes a lot of space
|
||||
# we could use manual jump table instead
|
||||
# TODO lots of macro magic here to unravel, with chronicles...
|
||||
# `computation`.logger.log($`computation`.stack & "\n\n", fgGreen)
|
||||
`result`
|
||||
|
@ -246,18 +245,14 @@ macro genFrontierDispatch(computation: BaseComputation): untyped =
|
|||
macro genHomesteadDispatch(computation: BaseComputation): untyped =
|
||||
result = opTableToCaseStmt(HomesteadOpDispatch, computation)
|
||||
|
||||
proc frontierVM(computation: var BaseComputation) =
|
||||
if not computation.execPrecompiles:
|
||||
genFrontierDispatch(computation)
|
||||
proc frontierVM(computation: BaseComputation) =
|
||||
genFrontierDispatch(computation)
|
||||
|
||||
proc homesteadVM(computation: var BaseComputation) =
|
||||
if not computation.execPrecompiles:
|
||||
genHomesteadDispatch(computation)
|
||||
proc homesteadVM(computation: BaseComputation) =
|
||||
genHomesteadDispatch(computation)
|
||||
|
||||
proc executeOpcodes(computation: var BaseComputation) =
|
||||
proc selectVM(computation: BaseComputation, fork: Fork) =
|
||||
# TODO: Optimise getting fork and updating opCodeExec only when necessary
|
||||
let fork = computation.getFork
|
||||
|
||||
case fork
|
||||
of FkFrontier..FkThawing:
|
||||
computation.frontierVM()
|
||||
|
@ -265,3 +260,15 @@ proc executeOpcodes(computation: var BaseComputation) =
|
|||
computation.homesteadVM()
|
||||
else:
|
||||
raise newException(VMError, "Unknown or not implemented fork: " & $fork)
|
||||
|
||||
proc executeOpcodes(computation: BaseComputation) =
|
||||
try:
|
||||
let fork = computation.getFork
|
||||
if `computation`.execPrecompiles(fork):
|
||||
computation.nextProc()
|
||||
return
|
||||
computation.selectVM(fork)
|
||||
except:
|
||||
let msg = getCurrentExceptionMsg()
|
||||
computation.setError(&"Opcode Dispatch Error msg={msg}, depth={computation.msg.depth}", true)
|
||||
computation.nextProc()
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
import
|
||||
../vm_types, interpreter/[gas_meter, gas_costs, utils/utils_numeric],
|
||||
../vm_types, interpreter/[gas_meter, gas_costs, utils/utils_numeric, vm_forks],
|
||||
../errors, stint, eth/[keys, common], chronicles, tables, macros,
|
||||
message, math, nimcrypto, bncurve/[fields, groups]
|
||||
|
||||
type
|
||||
PrecompileAddresses* = enum
|
||||
# Frontier to Spurious Dragron
|
||||
paEcRecover = 1,
|
||||
paSha256,
|
||||
paRipeMd160,
|
||||
paIdentity,
|
||||
#
|
||||
# Byzantium onward
|
||||
paModExp,
|
||||
paEcAdd,
|
||||
paEcMul,
|
||||
|
@ -62,7 +63,7 @@ proc getFR(data: openarray[byte]): FR =
|
|||
if not result.fromBytes2(data):
|
||||
raise newException(ValidationError, "Could not get FR value")
|
||||
|
||||
proc ecRecover*(computation: var BaseComputation) =
|
||||
proc ecRecover*(computation: BaseComputation) =
|
||||
computation.gasMeter.consumeGas(
|
||||
GasECRecover,
|
||||
reason="ECRecover Precompile")
|
||||
|
@ -78,7 +79,7 @@ proc ecRecover*(computation: var BaseComputation) =
|
|||
computation.rawOutput[12..31] = pubKey.toCanonicalAddress()
|
||||
trace "ECRecover precompile", derivedKey = pubKey.toCanonicalAddress()
|
||||
|
||||
proc sha256*(computation: var BaseComputation) =
|
||||
proc sha256*(computation: BaseComputation) =
|
||||
let
|
||||
wordCount = wordCount(computation.msg.data.len)
|
||||
gasFee = GasSHA256 + wordCount * GasSHA256Word
|
||||
|
@ -87,7 +88,7 @@ proc sha256*(computation: var BaseComputation) =
|
|||
computation.rawOutput = @(nimcrypto.sha_256.digest(computation.msg.data).data)
|
||||
trace "SHA256 precompile", output = computation.rawOutput.toHex
|
||||
|
||||
proc ripemd160*(computation: var BaseComputation) =
|
||||
proc ripemd160*(computation: BaseComputation) =
|
||||
let
|
||||
wordCount = wordCount(computation.msg.data.len)
|
||||
gasFee = GasRIPEMD160 + wordCount * GasRIPEMD160Word
|
||||
|
@ -97,7 +98,7 @@ proc ripemd160*(computation: var BaseComputation) =
|
|||
computation.rawOutput[12..31] = @(nimcrypto.ripemd160.digest(computation.msg.data).data)
|
||||
trace "RIPEMD160 precompile", output = computation.rawOutput.toHex
|
||||
|
||||
proc identity*(computation: var BaseComputation) =
|
||||
proc identity*(computation: BaseComputation) =
|
||||
let
|
||||
wordCount = wordCount(computation.msg.data.len)
|
||||
gasFee = GasIdentity + wordCount * GasIdentityWord
|
||||
|
@ -106,7 +107,7 @@ proc identity*(computation: var BaseComputation) =
|
|||
computation.rawOutput = computation.msg.data
|
||||
trace "Identity precompile", output = computation.rawOutput.toHex
|
||||
|
||||
proc modExpInternal(computation: var BaseComputation, base_len, exp_len, mod_len: int, T: type StUint) =
|
||||
proc modExpInternal(computation: BaseComputation, base_len, exp_len, mod_len: int, T: type StUint) =
|
||||
template rawMsg: untyped {.dirty.} =
|
||||
computation.msg.data
|
||||
|
||||
|
@ -170,7 +171,7 @@ proc modExpInternal(computation: var BaseComputation, base_len, exp_len, mod_len
|
|||
else:
|
||||
computation.rawOutput = @(powmod(base, exp, modulo).toByteArrayBE)
|
||||
|
||||
proc modExp*(computation: var BaseComputation) =
|
||||
proc modExp*(computation: BaseComputation) =
|
||||
## Modular exponentiation precompiled contract
|
||||
## Yellow Paper Appendix E
|
||||
## EIP-198 - https://github.com/ethereum/EIPs/blob/master/EIPS/eip-198.md
|
||||
|
@ -199,7 +200,7 @@ proc modExp*(computation: var BaseComputation) =
|
|||
else:
|
||||
raise newException(ValueError, "The Nimbus VM doesn't support modular exponentiation with numbers larger than uint8192")
|
||||
|
||||
proc bn256ecAdd*(computation: var BaseComputation) =
|
||||
proc bn256ecAdd*(computation: BaseComputation) =
|
||||
var
|
||||
input: array[128, byte]
|
||||
output: array[64, byte]
|
||||
|
@ -219,7 +220,7 @@ proc bn256ecAdd*(computation: var BaseComputation) =
|
|||
# computation.gasMeter.consumeGas(gasFee, reason = "ecAdd Precompile")
|
||||
computation.rawOutput = @output
|
||||
|
||||
proc bn256ecMul*(computation: var BaseComputation) =
|
||||
proc bn256ecMul*(computation: BaseComputation) =
|
||||
var
|
||||
input: array[96, byte]
|
||||
output: array[64, byte]
|
||||
|
@ -241,7 +242,7 @@ proc bn256ecMul*(computation: var BaseComputation) =
|
|||
# computation.gasMeter.consumeGas(gasFee, reason="ecMul Precompile")
|
||||
computation.rawOutput = @output
|
||||
|
||||
proc bn256ecPairing*(computation: var BaseComputation) =
|
||||
proc bn256ecPairing*(computation: BaseComputation) =
|
||||
var output: array[32, byte]
|
||||
|
||||
let msglen = len(computation.msg.data)
|
||||
|
@ -274,12 +275,13 @@ proc bn256ecPairing*(computation: var BaseComputation) =
|
|||
# computation.gasMeter.consumeGas(gasFee, reason="ecPairing Precompile")
|
||||
computation.rawOutput = @output
|
||||
|
||||
proc execPrecompiles*(computation: var BaseComputation): bool {.inline.} =
|
||||
proc execPrecompiles*(computation: BaseComputation, fork: Fork): bool {.inline.} =
|
||||
for i in 0..18:
|
||||
if computation.msg.codeAddress[i] != 0: return
|
||||
|
||||
let lb = computation.msg.codeAddress[19]
|
||||
if lb in PrecompileAddresses.low.byte .. PrecompileAddresses.high.byte:
|
||||
let maxPrecompileAddr = if fork < FkByzantium: paIdentity else: PrecompileAddresses.high
|
||||
if lb in PrecompileAddresses.low.byte .. maxPrecompileAddr.byte:
|
||||
result = true
|
||||
let precompile = PrecompileAddresses(lb)
|
||||
trace "Call precompile", precompile = precompile, codeAddr = computation.msg.codeAddress
|
||||
|
|
|
@ -65,9 +65,9 @@ proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender, recipient:
|
|||
|
||||
proc execComputation*(computation: var BaseComputation): bool =
|
||||
if computation.msg.isCreate:
|
||||
result = computation.applyMessage(Create)
|
||||
computation.applyMessage(Create)
|
||||
else:
|
||||
result = computation.applyMessage(Call)
|
||||
computation.applyMessage(Call)
|
||||
|
||||
computation.vmState.mutateStateDB:
|
||||
var suicidedCount = 0
|
||||
|
@ -79,6 +79,7 @@ proc execComputation*(computation: var BaseComputation): bool =
|
|||
const RefundSelfDestruct = 24_000
|
||||
computation.gasMeter.refundGas(RefundSelfDestruct * suicidedCount)
|
||||
|
||||
result = computation.isSuccess
|
||||
if result:
|
||||
computation.vmState.addLogs(computation.logEntries)
|
||||
else:
|
||||
|
|
|
@ -67,6 +67,11 @@ type
|
|||
dbsnapshot*: Snapshot
|
||||
instr*: Op
|
||||
opIndex*: int
|
||||
# continuation helpers
|
||||
nextProc*: proc()
|
||||
memOutLen*: int
|
||||
memOutPos*: int
|
||||
child*: BaseComputation
|
||||
|
||||
Error* = ref object
|
||||
info*: string
|
||||
|
|
|
@ -283,7 +283,7 @@
|
|||
"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"0000000000000000000000000000000000000000000000000000000000000060"
|
||||
],
|
||||
"error": ""
|
||||
"error": "Opcode Dispatch Error msg=Out of gas: Needed 20000 - Remaining 412 - Reason: SSTORE: 9a049f5d18c239efaa258af9f3e7002949a977a0[0] -> 924236965777326770894530693462975209021625492404 (0), depth=0"
|
||||
}
|
||||
],
|
||||
"stateDiff": {
|
||||
|
@ -704,7 +704,7 @@
|
|||
"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"0000000000000000000000000000000000000000000000000000000000000060"
|
||||
],
|
||||
"error": ""
|
||||
"error": "Opcode Dispatch Error msg=Out of gas: Needed 20000 - Remaining 412 - Reason: SSTORE: 9a049f5d18c239efaa258af9f3e7002949a977a0[0] -> 924236965777326770894530693462975209021625492404 (0), depth=0"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -13,16 +13,10 @@
|
|||
# being mostly used for short-term regression prevention.
|
||||
func allowedFailingGeneralStateTest*(folder, name: string): bool =
|
||||
let allowedFailingGeneralStateTests = @[
|
||||
"randomStatetest14.json",
|
||||
"randomStatetest85.json",
|
||||
# 2019-02-17:
|
||||
"pairingTest.json",
|
||||
"pointAdd.json",
|
||||
"pointAddTrunc.json",
|
||||
"pointMulAdd.json",
|
||||
"pointMulAdd2.json",
|
||||
"randomStatetest14.json", # SHA3 offset
|
||||
"randomStatetest85.json", # CALL* memoffset
|
||||
# Homestead recursives
|
||||
"ContractCreationSpam.json",
|
||||
#["ContractCreationSpam.json",
|
||||
"Call1024OOG.json",
|
||||
"Call1024PreCalls.json",
|
||||
"CallRecursiveBombPreCall.json",
|
||||
|
@ -49,6 +43,6 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
|
|||
"callcodecallcallcode_ABCB_RECURSIVE.json",
|
||||
"callcodecallcodecall_ABCB_RECURSIVE.json",
|
||||
"callcodecallcodecallcode_ABCB_RECURSIVE.json",
|
||||
"callcallcallcode_ABCB_RECURSIVE.json",
|
||||
"callcallcallcode_ABCB_RECURSIVE.json",]#
|
||||
]
|
||||
result = name in allowedFailingGeneralStateTests
|
||||
|
|
|
@ -56,11 +56,8 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) =
|
|||
createAddress = toAddress))
|
||||
|
||||
var computation = newBaseComputation(vmState, header.blockNumber, message)
|
||||
try:
|
||||
computation.executeOpcodes()
|
||||
except VMError:
|
||||
computation.error = Error(info: getCurrentExceptionMsg())
|
||||
|
||||
computation.executeOpcodes()
|
||||
|
||||
if not fixture{"post"}.isNil:
|
||||
# Success checks
|
||||
check(not computation.isError)
|
||||
|
|
Loading…
Reference in New Issue