From 9ad9394d1caeaa2631ac9359497734e53615c572 Mon Sep 17 00:00:00 2001 From: meows Date: Tue, 11 Feb 2020 07:57:09 -0500 Subject: [PATCH] core/vm,params/vars: implement missing SLOAD gas cost change - https://eips.ethereum.org/EIPS/eip-2200 - https://eips.ethereum.org/EIPS/eip-1884 EIP2200 is implemented simultaneously with 1884 on the ETH nets, rendering this somewhat redundant. But other networks may care, and this changeset should be handled carefully, since either or both 2200 1884 may be live with or without the other. Signed-off-by: meows --- core/vm/eips.go | 3 ++- params/vars/protocol_params.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/core/vm/eips.go b/core/vm/eips.go index 2daa44bf87..4a2988a805 100644 --- a/core/vm/eips.go +++ b/core/vm/eips.go @@ -56,9 +56,9 @@ func enableSelfBalance(jt *JumpTable) { // - Define SELFBALANCE, with cost GasFastStep (5) func enable1884(jt *JumpTable) { // Gas cost changes + jt[SLOAD].constantGas = vars.SloadGasEIP1884 jt[BALANCE].constantGas = vars.BalanceGasEIP1884 jt[EXTCODEHASH].constantGas = vars.ExtcodeHashGasEIP1884 - jt[SLOAD].constantGas = vars.SloadGasEIP1884 // New opcode enableSelfBalance(jt) @@ -92,5 +92,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 = vars.SloadGasEIP2200 jt[SSTORE].dynamicGas = gasSStoreEIP2200 } diff --git a/params/vars/protocol_params.go b/params/vars/protocol_params.go index 62a8c85f61..94102650be 100644 --- a/params/vars/protocol_params.go +++ b/params/vars/protocol_params.go @@ -104,6 +104,7 @@ var ( 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)