From d7781ab1e27dc48f0b8b9e7e6cb2bc60a5453910 Mon Sep 17 00:00:00 2001 From: Wei Tang Date: Thu, 29 Aug 2019 21:31:52 +0200 Subject: [PATCH] Implement EIP-1283 reenable transition, EIP-1706 and EIP-2200 (#10191) * Add reentry protection for EIP-1283 * typo: should use <= * Put things behind flag eip1706 * Fix compile * Fix missing config in json and add eip1283_reenable_transition --- ethcore/evm/src/interpreter/gasometer.rs | 3 +++ ethcore/src/spec/spec.rs | 18 +++++++++++++++++- ethcore/vm/src/schedule.rs | 4 ++++ json/src/spec/params.rs | 4 ++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ethcore/evm/src/interpreter/gasometer.rs b/ethcore/evm/src/interpreter/gasometer.rs index 26fec2d9376..b90540d9e9c 100644 --- a/ethcore/evm/src/interpreter/gasometer.rs +++ b/ethcore/evm/src/interpreter/gasometer.rs @@ -121,6 +121,9 @@ impl Gasometer { Request::Gas(Gas::from(1)) }, instructions::SSTORE => { + if schedule.eip1706 && self.current_gas <= Gas::from(schedule.call_stipend) { + return Err(vm::Error::OutOfGas); + } let address = H256::from(stack.peek(0)); let newval = stack.peek(1); let val = U256::from(&*ext.storage_at(&address)?); diff --git a/ethcore/src/spec/spec.rs b/ethcore/src/spec/spec.rs index 68980e68094..f9a54e64ebb 100644 --- a/ethcore/src/spec/spec.rs +++ b/ethcore/src/spec/spec.rs @@ -121,8 +121,12 @@ pub struct CommonParams { pub eip1283_transition: BlockNumber, /// Number of first block where EIP-1283 rules end. pub eip1283_disable_transition: BlockNumber, + /// Number of first block where EIP-1283 rules re-enabled. + pub eip1283_reenable_transition: BlockNumber, /// Number of first block where EIP-1014 rules begin. pub eip1014_transition: BlockNumber, + /// Number of first block where EIP-1706 rules begin. + pub eip1706_transition: BlockNumber, /// Number of first block where EIP-1344 rules begin: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1344.md pub eip1344_transition: BlockNumber, /// Number of first block where EIP-1884 rules begin:https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1884.md @@ -196,7 +200,11 @@ impl CommonParams { schedule.have_bitwise_shifting = block_number >= self.eip145_transition; schedule.have_extcodehash = block_number >= self.eip1052_transition; schedule.have_chain_id = block_number >= self.eip1344_transition; - schedule.eip1283 = block_number >= self.eip1283_transition && !(block_number >= self.eip1283_disable_transition); + schedule.eip1283 = + (block_number >= self.eip1283_transition && + !(block_number >= self.eip1283_disable_transition)) || + block_number >= self.eip1283_reenable_transition; + schedule.eip1706 = block_number >= self.eip1706_transition; if block_number >= self.eip1884_transition { schedule.have_selfbalance = true; @@ -321,6 +329,14 @@ impl From for CommonParams { BlockNumber::max_value, Into::into, ), + eip1283_reenable_transition: p.eip1283_reenable_transition.map_or_else( + BlockNumber::max_value, + Into::into, + ), + eip1706_transition: p.eip1706_transition.map_or_else( + BlockNumber::max_value, + Into::into, + ), eip1014_transition: p.eip1014_transition.map_or_else( BlockNumber::max_value, Into::into, diff --git a/ethcore/vm/src/schedule.rs b/ethcore/vm/src/schedule.rs index 4eeabba9281..6fad8351e6f 100644 --- a/ethcore/vm/src/schedule.rs +++ b/ethcore/vm/src/schedule.rs @@ -132,6 +132,8 @@ pub struct Schedule { pub kill_dust: CleanDustMode, /// Enable EIP-1283 rules pub eip1283: bool, + /// Enable EIP-1706 rules + pub eip1706: bool, /// VM execution does not increase null signed address nonce if this field is true. pub keep_unsigned_nonce: bool, /// Wasm extra schedule settings, if wasm activated @@ -269,6 +271,7 @@ impl Schedule { have_static_call: false, kill_dust: CleanDustMode::Off, eip1283: false, + eip1706: false, keep_unsigned_nonce: false, wasm: None, } @@ -357,6 +360,7 @@ impl Schedule { have_static_call: false, kill_dust: CleanDustMode::Off, eip1283: false, + eip1706: false, keep_unsigned_nonce: false, wasm: None, } diff --git a/json/src/spec/params.rs b/json/src/spec/params.rs index b75e5f9a847..e8b3ded8a90 100644 --- a/json/src/spec/params.rs +++ b/json/src/spec/params.rs @@ -92,8 +92,12 @@ pub struct Params { /// See `CommonParams` docs. pub eip1283_disable_transition: Option, /// See `CommonParams` docs. + pub eip1283_reenable_transition: Option, + /// See `CommonParams` docs. pub eip1014_transition: Option, /// See `CommonParams` docs. + pub eip1706_transition: Option, + /// See `CommonParams` docs. pub eip1344_transition: Option, /// See `CommonParams` docs. pub eip1884_transition: Option,