fix block 81383 problem

This commit is contained in:
andri lim 2019-02-19 20:14:48 +07:00 committed by zah
parent 345133e8eb
commit 0b9326f955
3 changed files with 12 additions and 12 deletions

View File

@ -208,8 +208,8 @@ 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:
computation.gasMeter.consumeGas(
computation.gasCosts[Create].m_handler(0, 0, contractCode.len),
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

View File

@ -170,9 +170,10 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
result += static(FeeSchedule[GasExpByte]) * (1 + log256(value))
func `prefix gasCreate`(currentMemSize, memOffset, memLength: Natural): GasInt {.nimcall.} =
result =
static(FeeSchedule[GasCreate]) +
static(FeeSchedule[GasCodeDeposit]) * memLength
if currentMemSize + memOffset + memLength == 0:
result = static(FeeSchedule[GasCreate])
else:
result = static(FeeSchedule[GasCodeDeposit]) * memLength
func `prefix gasSha3`(currentMemSize, memOffset, memLength: Natural): GasInt {.nimcall.} =

View File

@ -510,17 +510,14 @@ op create, inline = false, value, startPosition, size:
# TODO: Forked create for Homestead
let (memPos, len) = (startPosition.cleanMemRef, size.cleanMemRef)
let gasCost = computation.gasCosts[Create].m_handler(0, 0, 0)
let reason = &"CREATE: GasCreate + {len} * memory expansion"
computation.gasMeter.consumeGas(
computation.gasCosts[Create].m_handler(computation.memory.len, memPos, len),
reason = &"CREATE: GasCreate + {len} * memory expansion"
)
computation.gasMeter.consumeGas(gasCost, reason = reason)
computation.memory.extend(memPos, len)
let senderBalance =
computation.vmState.getStateDb(
computation.vmState.blockHeader.rlphash).
computation.vmState.readOnlyStateDb().
getBalance(computation.msg.sender)
if senderBalance < value:
@ -552,6 +549,7 @@ op create, inline = false, value, startPosition, size:
let
callData = computation.memory.read(memPos, len)
createMsgGas = computation.getGasRemaining()
# Consume gas here that will be passed to child
computation.gasMeter.consumeGas(createMsgGas, reason="CREATE")
@ -584,6 +582,7 @@ op create, inline = false, value, startPosition, size:
options = MessageOptions(createAddress: contractAddress)
)
childMsg.sender = computation.msg.storageAddress
let childComputation = computation.applyChildComputation(childMsg, Create)
if childComputation.isError: