fixes opcode call: simplify gas costs

This commit is contained in:
andri lim 2019-02-15 10:26:27 +07:00 committed by zah
parent 44d05dfdb1
commit d7bd55bd21
1 changed files with 4 additions and 7 deletions

View File

@ -310,12 +310,11 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
# Cextra # Cextra
result.gasCost += static(FeeSchedule[GasCall]) result.gasCost += static(FeeSchedule[GasCall])
let cextra = result.gasCost
# Cgascap # Cgascap
if fork >= FkTangerine: if fork >= FkTangerine:
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md # https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md
result.gasCost = result.gasRefund =
if gasParams.c_gasBalance >= result.gasCost: if gasParams.c_gasBalance >= result.gasCost:
min( min(
`prefix all_but_one_64th`(gasParams.c_gasBalance - result.gasCost), `prefix all_but_one_64th`(gasParams.c_gasBalance - result.gasCost),
@ -324,16 +323,14 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
else: else:
gasParams.c_contractGas gasParams.c_contractGas
else: else:
result.gasCost += gasParams.c_contractGas result.gasRefund += gasParams.c_contractGas
result.gasCost += result.gasRefund
# Ccallgas - Gas sent to the child message # Ccallgas - Gas sent to the child message
result.gasRefund = result.gasCost
if not value.isZero: if not value.isZero:
result.gasRefund += static(FeeSchedule[GasCallStipend]) result.gasRefund += static(FeeSchedule[GasCallStipend])
# Ccall
result.gasCost += cextra
func `prefix gasHalt`(currentMemSize, memOffset, memLength: Natural): GasInt {.nimcall.} = func `prefix gasHalt`(currentMemSize, memOffset, memLength: Natural): GasInt {.nimcall.} =
`prefix gasMemoryExpansion`(currentMemSize, memOffset, memLength) `prefix gasMemoryExpansion`(currentMemSize, memOffset, memLength)