fix applyCreateMessage

This commit is contained in:
andri lim 2019-02-28 13:19:30 +07:00 committed by zah
parent 0518802690
commit a15805e41a
1 changed files with 13 additions and 12 deletions

View File

@ -199,21 +199,22 @@ proc applyCreateMessage(fork: Fork, computation: var BaseComputation, opCode: st
raise newException(OutOfGas, &"Contract code size exceeds EIP170 limit of {EIP170_CODE_SIZE_LIMIT}. Got code of size: {contractCode.len}")
try:
# tricky gasCost: 1,0,0 -> createCost. 0,0,x -> depositCost
let gasCost = computation.gasCosts[Create].m_handler(0, 0, contractCode.len)
computation.gasMeter.consumeGas(gasCost,
reason = "Write contract code for CREATE")
let storageAddr = computation.msg.storageAddress
trace "SETTING CODE",
address = storageAddr.toHex,
length = len(contract_code),
hash = contractCode.rlpHash
if not computation.isSuicided(storageAddr):
# tricky gasCost: 1,0,0 -> createCost. 0,0,x -> depositCost
let gasCost = computation.gasCosts[Create].m_handler(0, 0, contractCode.len)
computation.gasMeter.consumeGas(gasCost,
reason = "Write contract code for CREATE")
computation.vmState.mutateStateDb:
db.setCode(storageAddr, contractCode.toRange)
trace "SETTING CODE",
address = storageAddr.toHex,
length = len(contract_code),
hash = contractCode.rlpHash
snapshot.commit()
computation.vmState.mutateStateDb:
db.setCode(storageAddr, contractCode.toRange)
snapshot.commit()
except OutOfGas:
debug "applyCreateMessage failed: ",
msg = getCurrentExceptionMsg(),