implement Tangerine fork gas cost changes

This commit is contained in:
andri lim 2019-04-07 10:58:43 +07:00
parent 4ec1af0fe7
commit 77e9c18f91
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
2 changed files with 9 additions and 3 deletions

View File

@ -303,7 +303,7 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
# Cnew_account # Cnew_account
if gasParams.c_isNewAccount and gasParams.kind == Call: if gasParams.c_isNewAccount and gasParams.kind == Call:
if fork < FkSpurious: when fork < FkSpurious:
# Pre-EIP161 all account creation calls consumed 25000 gas. # Pre-EIP161 all account creation calls consumed 25000 gas.
result.gasCost += static(FeeSchedule[GasNewAccount]) result.gasCost += static(FeeSchedule[GasNewAccount])
else: else:
@ -321,7 +321,7 @@ template gasCosts(fork: Fork, prefix, ResultGasCostsName: untyped) =
result.gasCost += static(FeeSchedule[GasCall]) result.gasCost += static(FeeSchedule[GasCall])
# Cgascap # Cgascap
if fork >= FkTangerine: when 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.gasRefund = result.gasRefund =
if gasParams.c_gasBalance >= result.gasCost: if gasParams.c_gasBalance >= result.gasCost:
@ -578,10 +578,11 @@ func homesteadGasFees(previous_fees: GasFeeSchedule): GasFeeSchedule =
func tangerineGasFees(previous_fees: GasFeeSchedule): GasFeeSchedule = func tangerineGasFees(previous_fees: GasFeeSchedule): GasFeeSchedule =
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md # https://github.com/ethereum/EIPs/blob/master/EIPS/eip-150.md
result = previous_fees result = previous_fees
result[GasExtCode] = 700
result[GasSload] = 200 result[GasSload] = 200
result[GasSelfDestruct] = 5000 result[GasSelfDestruct] = 5000
result[GasBalance] = 400 result[GasBalance] = 400
result[GasCall] = 40 result[GasCall] = 700
func spuriousGasFees(previous_fees: GasFeeSchedule): GasFeeSchedule = func spuriousGasFees(previous_fees: GasFeeSchedule): GasFeeSchedule =
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-160.md # https://github.com/ethereum/EIPs/blob/master/EIPS/eip-160.md

View File

@ -540,8 +540,13 @@ proc canTransfer(computation: BaseComputation, memPos, memLen: int, value: Uint2
proc setupCreate(computation: BaseComputation, memPos, len: int, value: Uint256): BaseComputation = proc setupCreate(computation: BaseComputation, memPos, len: int, value: Uint256): BaseComputation =
let let
callData = computation.memory.read(memPos, len) callData = computation.memory.read(memPos, len)
var
createMsgGas = computation.getGasRemaining() createMsgGas = computation.getGasRemaining()
if getFork(computation) >= FkTangerine:
createMsgGas -= createMsgGas div 64
# Consume gas here that will be passed to child # Consume gas here that will be passed to child
computation.gasMeter.consumeGas(createMsgGas, reason="CREATE") computation.gasMeter.consumeGas(createMsgGas, reason="CREATE")