From 4be88401200699a8afe0602e1a8624e6e10989c1 Mon Sep 17 00:00:00 2001 From: Gregory Markou <16929357+GregTheGreek@users.noreply.github.com> Date: Tue, 18 Feb 2020 06:07:41 -0800 Subject: [PATCH] core/vm: use dedicated SLOAD gas constant for EIP-2200 (#20646) --- core/vm/eips.go | 3 ++- params/protocol_params.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/vm/eips.go b/core/vm/eips.go index 075f5b7606..062d40779e 100644 --- a/core/vm/eips.go +++ b/core/vm/eips.go @@ -46,9 +46,9 @@ func EnableEIP(eipNum int, jt *JumpTable) error { // - Define SELFBALANCE, with cost GasFastStep (5) func enable1884(jt *JumpTable) { // Gas cost changes + jt[SLOAD].constantGas = params.SloadGasEIP1884 jt[BALANCE].constantGas = params.BalanceGasEIP1884 jt[EXTCODEHASH].constantGas = params.ExtcodeHashGasEIP1884 - jt[SLOAD].constantGas = params.SloadGasEIP1884 // New opcode jt[SELFBALANCE] = operation{ @@ -88,5 +88,6 @@ func opChainID(pc *uint64, interpreter *EVMInterpreter, contract *Contract, memo // enable2200 applies EIP-2200 (Rebalance net-metered SSTORE) func enable2200(jt *JumpTable) { + jt[SLOAD].constantGas = params.SloadGasEIP2200 jt[SSTORE].dynamicGas = gasSStoreEIP2200 } diff --git a/params/protocol_params.go b/params/protocol_params.go index 11b858a61c..ad2c5db643 100644 --- a/params/protocol_params.go +++ b/params/protocol_params.go @@ -90,6 +90,7 @@ const ( SloadGasFrontier uint64 = 50 SloadGasEIP150 uint64 = 200 SloadGasEIP1884 uint64 = 800 // Cost of SLOAD after EIP 1884 (part of Istanbul) + SloadGasEIP2200 uint64 = 800 // Cost of SLOAD after EIP 2200 (part of Istanbul) ExtcodeHashGasConstantinople uint64 = 400 // Cost of EXTCODEHASH (introduced in Constantinople) ExtcodeHashGasEIP1884 uint64 = 700 // Cost of EXTCODEHASH after EIP 1884 (part in Istanbul) SelfdestructGasEIP150 uint64 = 5000 // Cost of SELFDESTRUCT post EIP 150 (Tangerine)