fix evm msg contract creation, GST +3

This commit is contained in:
andri lim 2019-04-18 12:42:37 +07:00
parent f7338b7d76
commit 1883472104
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
8 changed files with 25 additions and 28 deletions

View File

@ -515,7 +515,7 @@ OK: 5/5 Fail: 0/5 Skip: 0/5
```diff
+ CallContractToCreateContractAndCallItOOG.json OK
+ CallContractToCreateContractNoCash.json OK
CallContractToCreateContractOOG.json Skip
+ CallContractToCreateContractOOG.json OK
+ CallContractToCreateContractOOGBonusGas.json OK
+ CallContractToCreateContractWhichWouldCreateContractIfCalled.jsonOK
+ CallContractToCreateContractWhichWouldCreateContractInInitCode.jsonOK
@ -532,7 +532,7 @@ OK: 5/5 Fail: 0/5 Skip: 0/5
+ TransactionCreateStopInInitcode.json OK
+ TransactionCreateSuicideInInitcode.json OK
```
OK: 17/18 Fail: 0/18 Skip: 1/18
OK: 18/18 Fail: 0/18 Skip: 0/18
## stLogTests
```diff
+ log0_emptyMem.json OK
@ -1706,14 +1706,14 @@ OK: 16/16 Fail: 0/16 Skip: 0/16
+ StackDepthLimitSEC.json OK
block504980.json Skip
+ deploymentError.json OK
failed_tx_xcf416c53.json Skip
+ failed_tx_xcf416c53.json OK
gasPrice0.json Skip
+ makeMoney.json OK
sha3_deja.json Skip
txCost-sec73.json Skip
+ tx_e1c174e2.json OK
```
OK: 7/13 Fail: 0/13 Skip: 6/13
OK: 8/13 Fail: 0/13 Skip: 5/13
## stStackTests
```diff
shallowStack.json Skip
@ -2123,7 +2123,7 @@ OK: 63/67 Fail: 0/67 Skip: 4/67
+ TransactionNonceCheck.json OK
+ TransactionNonceCheck2.json OK
+ TransactionSendingToEmpty.json OK
TransactionSendingToZero.json Skip
+ TransactionSendingToZero.json OK
+ TransactionToAddressh160minusOne.json OK
+ TransactionToItself.json OK
+ TransactionToItselfNotEnoughFounds.json OK
@ -2131,7 +2131,7 @@ OK: 63/67 Fail: 0/67 Skip: 4/67
+ UserTransactionZeroCost.json OK
+ UserTransactionZeroCostWithData.json OK
```
OK: 43/44 Fail: 0/44 Skip: 1/44
OK: 44/44 Fail: 0/44 Skip: 0/44
## stTransitionTest
```diff
+ createNameRegistratorPerTxsAfter.json OK
@ -2520,4 +2520,4 @@ OK: 5/133 Fail: 0/133 Skip: 128/133
OK: 0/130 Fail: 0/130 Skip: 130/130
---TOTAL---
OK: 1507/2334 Fail: 0/2334 Skip: 827/2334
OK: 1510/2334 Fail: 0/2334 Skip: 824/2334

View File

@ -9,6 +9,9 @@ const
INT_256_MAX_AS_UINT256* = high(Uint256) shr 1
UINT160CEILING*: UInt256 = 2.u256.pow(160)
ZERO_ADDRESS* = default(EthAddress)
# TODO: use Option[EthAddress]?
# create contract address cannot be ZERO_ADDRESS
# because actual zero address exists
CREATE_CONTRACT_ADDRESS* = ZERO_ADDRESS
ZERO_HASH32* = Hash256()

View File

@ -82,6 +82,7 @@ proc prepareChildMessage*(
value: UInt256,
data: seq[byte],
code: seq[byte],
contractCreation: bool,
options: MessageOptions = newMessageOptions()): Message =
var childOptions = options
@ -94,6 +95,7 @@ proc prepareChildMessage*(
value,
data,
code,
contractCreation,
childOptions)
proc snapshot*(comp: BaseComputation) =

View File

@ -576,6 +576,7 @@ proc setupCreate(computation: BaseComputation, memPos, len: int, value: Uint256)
value = value,
data = @[],
code = callData,
contractCreation = true,
options = MessageOptions(createAddress: contractAddress)
)
@ -741,6 +742,7 @@ template genCall(callName: untyped, opCode: Op): untyped =
value,
callData,
code.toSeq,
false,
MessageOptions(flags: flags)
)

View File

@ -43,6 +43,7 @@ proc newMessage*(
value: UInt256,
data: seq[byte],
code: seq[byte],
contractCreation: bool,
options: MessageOptions = newMessageOptions()): Message =
validateGte(options.depth, minimum=0, title="Message.depth")
@ -55,7 +56,8 @@ proc newMessage*(
value = value,
depth = options.depth,
storageAddress = options.createAddress,
codeAddress = options.codeAddress
codeAddress = options.codeAddress,
contractCreation = contractCreation
new(result)
result.gas = gas
@ -69,6 +71,7 @@ proc newMessage*(
result.codeAddress = options.codeAddress
result.flags = options.flags
result.code = code
result.contractCreation = contractCreation
if options.origin != ZERO_ADDRESS:
result.internalOrigin = options.origin
@ -97,4 +100,4 @@ proc `storageAddress`*(message: Message): EthAddress =
message.destination
proc isCreate*(message: Message): bool =
message.destination == CREATE_CONTRACT_ADDRESS
message.contractCreation

View File

@ -62,6 +62,7 @@ proc setupComputation*(vmState: BaseVMState, tx: Transaction, sender, recipient:
value = tx.value,
data = data,
code = code,
tx.isContractCreation,
options = newMessageOptions(origin = sender,
createAddress = recipient))

View File

@ -99,37 +99,24 @@ type
Message* = ref object
# A message for VM computation
# https://github.com/ethereum/evmc/blob/master/include/evmc/evmc.h
# depth = None
# code = None
# codeAddress = None
# createAddress = None
# logger = logging.getLogger("evm.vm.message.Message")
destination*: EthAddress
sender*: EthAddress
value*: UInt256
data*: seq[byte]
# size_t input_size;
codeHash*: UInt256
create2Salt*: Uint256
gas*: GasInt
gasPrice*: GasInt
depth*: int
kind*: CallKind
#kind*: CallKind
flags*: MsgFlags
# Not in EVMC API
# TODO: Done via callback function (v)table in EVMC
code*: seq[byte]
internalOrigin*: EthAddress
internalCodeAddress*: EthAddress
internalStorageAddress*: EthAddress
contractCreation*: bool
MessageOptions* = ref object
origin*: EthAddress

View File

@ -21,10 +21,9 @@ func allowedFailingGeneralStateTest*(folder, name: string): bool =
"doubleSelfdestructTest2.json",
# Spurious Dragon failed GST
"CallContractToCreateContractOOG.json",
"failed_tx_xcf416c53.json",
"TransactionSendingToZero.json"
#"CallContractToCreateContractOOG.json",
#"failed_tx_xcf416c53.json",
#"TransactionSendingToZero.json"
#"OutOfGasContractCreation.json",
#"OutOfGasPrefundedContractCreation.json",
#"RevertOpcodeInInit.json",