simplify CREATE gasCost
This commit is contained in:
parent
8884627d07
commit
2e8176eb15
|
@ -208,6 +208,7 @@ 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")
|
||||
|
|
|
@ -170,10 +170,9 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
|
|||
result += static(FeeSchedule[GasExpByte]) * (1 + log256(value))
|
||||
|
||||
func `prefix gasCreate`(currentMemSize, memOffset, memLength: Natural): GasInt {.nimcall.} =
|
||||
if currentMemSize + memOffset + memLength == 0:
|
||||
result = static(FeeSchedule[GasCreate])
|
||||
else:
|
||||
result = static(FeeSchedule[GasCodeDeposit]) * memLength
|
||||
# tricky gasCost: 1,0,0 -> createCost. 0,0,x -> depositCost
|
||||
result = currentMemSize * static(FeeSchedule[GasCreate]) +
|
||||
static(FeeSchedule[GasCodeDeposit]) * memLength
|
||||
|
||||
func `prefix gasSha3`(currentMemSize, memOffset, memLength: Natural): GasInt {.nimcall.} =
|
||||
|
||||
|
|
|
@ -510,7 +510,8 @@ 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)
|
||||
# tricky gasCost: 1,0,0 -> createCost. 0,0,x -> depositCost
|
||||
let gasCost = computation.gasCosts[Create].m_handler(1, 0, 0)
|
||||
let reason = &"CREATE: GasCreate + {len} * memory expansion"
|
||||
|
||||
computation.gasMeter.consumeGas(gasCost, reason = reason)
|
||||
|
|
Loading…
Reference in New Issue