fix revert opcode at first level computation

This commit is contained in:
andri lim 2019-04-24 13:58:56 +07:00
parent c57295da0b
commit 90e3a4320a
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
7 changed files with 29 additions and 52 deletions

View File

@ -391,13 +391,13 @@ OK: 3/3 Fail: 0/3 Skip: 0/3
CreateOOGafterInitCodeReturndata2.json Skip
+ CreateOOGafterInitCodeReturndata3.json OK
CreateOOGafterInitCodeReturndataSize.json Skip
CreateOOGafterInitCodeRevert.json Skip
CreateOOGafterInitCodeRevert2.json Skip
+ CreateOOGafterInitCodeRevert.json OK
+ CreateOOGafterInitCodeRevert2.json OK
+ TransactionCollisionToEmpty.json OK
+ TransactionCollisionToEmptyButCode.json OK
+ TransactionCollisionToEmptyButNonce.json OK
```
OK: 26/30 Fail: 0/30 Skip: 4/30
OK: 28/30 Fail: 0/30 Skip: 2/30
## stDelegatecallTestHomestead
```diff
Call1024BalanceTooLow.json Skip
@ -1573,9 +1573,9 @@ OK: 19/19 Fail: 0/19 Skip: 0/19
+ returndatacopy_initial_256.json OK
+ returndatacopy_initial_big_sum.json OK
+ returndatacopy_overrun.json OK
returndatasize_after_failing_callcode.json Skip
returndatasize_after_failing_delegatecall.json Skip
returndatasize_after_failing_staticcall.json Skip
+ returndatasize_after_failing_callcode.json OK
+ returndatasize_after_failing_delegatecall.json OK
+ returndatasize_after_failing_staticcall.json OK
+ returndatasize_after_oog_after_deeper.json OK
+ returndatasize_after_successful_callcode.json OK
+ returndatasize_after_successful_delegatecall.json OK
@ -1585,7 +1585,7 @@ OK: 19/19 Fail: 0/19 Skip: 0/19
+ returndatasize_initial.json OK
returndatasize_initial_zero_read.json Skip
```
OK: 23/37 Fail: 0/37 Skip: 14/37
OK: 26/37 Fail: 0/37 Skip: 11/37
## stRevertTest
```diff
LoopCallsDepthThenRevert.json Skip
@ -1601,18 +1601,18 @@ OK: 23/37 Fail: 0/37 Skip: 14/37
RevertInCallCode.json Skip
RevertInCreateInInit.json Skip
RevertInDelegateCall.json Skip
RevertInStaticCall.json Skip
RevertOnEmptyStack.json Skip
RevertOpcode.json Skip
RevertOpcodeCalls.json Skip
RevertOpcodeCreate.json Skip
RevertOpcodeDirectCall.json Skip
RevertOpcodeInCallsOnNonEmptyReturnData.json Skip
RevertOpcodeInCreateReturns.json Skip
RevertOpcodeInInit.json Skip
RevertOpcodeMultipleSubCalls.json Skip
RevertOpcodeReturn.json Skip
RevertOpcodeWithBigOutputInInit.json Skip
+ RevertInStaticCall.json OK
+ RevertOnEmptyStack.json OK
+ RevertOpcode.json OK
+ RevertOpcodeCalls.json OK
+ RevertOpcodeCreate.json OK
+ RevertOpcodeDirectCall.json OK
+ RevertOpcodeInCallsOnNonEmptyReturnData.json OK
+ RevertOpcodeInCreateReturns.json OK
+ RevertOpcodeInInit.json OK
+ RevertOpcodeMultipleSubCalls.json OK
+ RevertOpcodeReturn.json OK
+ RevertOpcodeWithBigOutputInInit.json OK
+ RevertPrecompiledTouch.json OK
+ RevertPrecompiledTouchCC.json OK
+ RevertPrecompiledTouchDC.json OK
@ -1632,7 +1632,7 @@ OK: 23/37 Fail: 0/37 Skip: 14/37
+ TouchToEmptyAccountRevert2.json OK
+ TouchToEmptyAccountRevert3.json OK
```
OK: 22/43 Fail: 0/43 Skip: 21/43
OK: 34/43 Fail: 0/43 Skip: 9/43
## stShift
```diff
+ sar00.json OK
@ -2520,4 +2520,4 @@ OK: 130/133 Fail: 0/133 Skip: 3/133
OK: 130/130 Fail: 0/130 Skip: 0/130
---TOTAL---
OK: 2147/2334 Fail: 0/2334 Skip: 187/2334
OK: 2164/2334 Fail: 0/2334 Skip: 170/2334

View File

@ -44,7 +44,8 @@ proc processTransaction*(tx: Transaction, sender: EthAddress, vmState: BaseVMSta
db.subBalance(sender, upfrontGasCost)
if tx.isContractCreation and isCollision: break
if execComputation(computation):
execComputation(computation)
if not computation.shouldBurnGas:
gasUsed = computation.refundGas(tx, sender)
if computation.isSuicided(vmState.blockHeader.coinbase):

View File

@ -325,7 +325,7 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) =
value = if call.value.isSome: call.value.get else: 0.u256
comp = setupComputation(vmState, header.blockNumber, value, data, sender, destination, gasLimit, gasPrice, call.to.isNone)
discard comp.execComputation
comp.execComputation
result = ("0x" & nimcrypto.toHex(comp.output)).HexDataStr
rpcsrv.rpc("eth_estimateGas") do(call: EthCall, quantityTag: string) -> GasInt:

View File

@ -103,12 +103,6 @@ proc snapshot*(comp: BaseComputation) =
comp.dbsnapshot.intermediateRoot = comp.vmState.accountDb.rootHash
comp.vmState.blockHeader.stateRoot = comp.vmState.accountDb.rootHash
proc revert*(comp: BaseComputation, burnsGas = false) =
comp.dbsnapshot.transaction.rollback()
comp.vmState.accountDb.rootHash = comp.dbsnapshot.intermediateRoot
comp.vmState.blockHeader.stateRoot = comp.dbsnapshot.intermediateRoot
comp.error = Error(info: getCurrentExceptionMsg(), burnsGas: burnsGas)
proc commit*(comp: BaseComputation) =
comp.dbsnapshot.transaction.commit()
comp.vmState.accountDb.rootHash = comp.vmState.blockHeader.stateRoot

View File

@ -60,7 +60,7 @@ proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender, recipient:
result = newBaseComputation(vmState, vmState.blockNumber, msg, some(fork))
doAssert result.isOriginComputation
proc execComputation*(computation: var BaseComputation): bool =
proc execComputation*(computation: var BaseComputation) =
if computation.msg.isCreate:
computation.applyMessage(Create)
else:
@ -79,9 +79,8 @@ proc execComputation*(computation: var BaseComputation): bool =
if computation.getFork >= FkSpurious:
computation.collectTouchedAccounts(computation.vmState.touchedAccounts)
result = computation.isSuccess
computation.vmstate.status = result
if result:
computation.vmstate.status = computation.isSuccess
if computation.isSuccess:
computation.vmState.addLogs(computation.logEntries)
proc refundGas*(computation: BaseComputation, tx: Transaction, sender: EthAddress): GasInt =

View File

@ -233,10 +233,10 @@ proc runVM*(blockNumber: Uint256, chainDB: BaseChainDB, boa: Assembler): bool =
var computation = initComputation(blockNumber, chainDB, boa.code, boa.data)
let gas = computation.gasMeter.gasRemaining
let computationResult = execComputation(computation)
execComputation(computation)
let gasUsed = gas - computation.gasMeter.gasRemaining
if computationResult:
if computation.isSuccess:
if boa.success == false:
error "different success value", expected=boa.success, actual=true
return false

View File

@ -25,40 +25,23 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
"sha3_deja.json",
"delegatecallNonConst.json",
"returndatasize_after_failing_delegatecall.json",
"returndatacopy_following_revert_in_create.json",
"returndatasize_initial_zero_read.json",
"returndatacopy_after_successful_callcode.json",
"returndatacopy_afterFailing_create.json",
"returndatacopy_after_successful_delegatecall.json",
"returndatacopy_following_revert.json",
"returndatasize_after_failing_staticcall.json",
"returndatacopy_after_successful_staticcall.json",
"returndatacopy_following_call.json",
"returndatacopy_after_revert_in_staticcall.json",
"returndatasize_after_failing_callcode.json",
"CreateOOGafterInitCodeRevert.json",
"CreateOOGafterInitCodeReturndataSize.json",
"CreateOOGafterInitCodeRevert2.json",
"static_RevertOpcodeCalls.json",
"PythonRevertTestTue201814-1430.json",
"RevertOpcodeDirectCall.json",
"RevertInCallCode.json",
"RevertOpcodeReturn.json",
"RevertOnEmptyStack.json",
"RevertInDelegateCall.json",
"RevertOpcodeCalls.json",
"RevertOpcode.json",
"RevertOpcodeInInit.json",
"RevertOpcodeWithBigOutputInInit.json",
"RevertOpcodeInCreateReturns.json",
"RevertOpcodeCreate.json",
"RevertOpcodeMultipleSubCalls.json",
"RevertOpcodeInCallsOnNonEmptyReturnData.json",
"RevertInCreateInInit.json",
"RevertInStaticCall.json",
"modexpRandomInput.json",
"modexp_9_37111_37111_1000000.json",