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
This commit is contained in:
Wei Tang 2019-08-29 21:31:52 +02:00 committed by GitHub
parent dabfa2c663
commit 00124b5a4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 1 deletions

View File

@ -121,6 +121,10 @@ impl<Gas: evm::CostType> Gasometer<Gas> {
Request::Gas(Gas::from(1)) Request::Gas(Gas::from(1))
}, },
instructions::SSTORE => { instructions::SSTORE => {
if schedule.eip1706 && self.current_gas <= Gas::from(schedule.call_stipend) {
return Err(vm::Error::OutOfGas);
}
let address = BigEndianHash::from_uint(stack.peek(0)); let address = BigEndianHash::from_uint(stack.peek(0));
let newval = stack.peek(1); let newval = stack.peek(1);
let val = ext.storage_at(&address)?.into_uint(); let val = ext.storage_at(&address)?.into_uint();

View File

@ -88,8 +88,12 @@ pub struct CommonParams {
pub eip1283_transition: BlockNumber, pub eip1283_transition: BlockNumber,
/// Number of first block where EIP-1283 rules end. /// Number of first block where EIP-1283 rules end.
pub eip1283_disable_transition: BlockNumber, 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. /// Number of first block where EIP-1014 rules begin.
pub eip1014_transition: BlockNumber, 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 /// Number of first block where EIP-1344 rules begin: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1344.md
pub eip1344_transition: BlockNumber, pub eip1344_transition: BlockNumber,
/// Number of first block where EIP-1884 rules begin:https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1884.md /// Number of first block where EIP-1884 rules begin:https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1884.md
@ -166,7 +170,11 @@ impl CommonParams {
schedule.have_bitwise_shifting = block_number >= self.eip145_transition; schedule.have_bitwise_shifting = block_number >= self.eip145_transition;
schedule.have_extcodehash = block_number >= self.eip1052_transition; schedule.have_extcodehash = block_number >= self.eip1052_transition;
schedule.have_chain_id = block_number >= self.eip1344_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 { if block_number >= self.eip1884_transition {
schedule.have_selfbalance = true; schedule.have_selfbalance = true;
@ -290,6 +298,14 @@ impl From<ethjson::spec::Params> for CommonParams {
BlockNumber::max_value, BlockNumber::max_value,
Into::into, 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( eip1014_transition: p.eip1014_transition.map_or_else(
BlockNumber::max_value, BlockNumber::max_value,
Into::into, Into::into,

View File

@ -132,6 +132,8 @@ pub struct Schedule {
pub kill_dust: CleanDustMode, pub kill_dust: CleanDustMode,
/// Enable EIP-1283 rules /// Enable EIP-1283 rules
pub eip1283: bool, pub eip1283: bool,
/// Enable EIP-1706 rules
pub eip1706: bool,
/// VM execution does not increase null signed address nonce if this field is true. /// VM execution does not increase null signed address nonce if this field is true.
pub keep_unsigned_nonce: bool, pub keep_unsigned_nonce: bool,
/// Latest VM version for contract creation transaction. /// Latest VM version for contract creation transaction.
@ -273,6 +275,7 @@ impl Schedule {
have_static_call: false, have_static_call: false,
kill_dust: CleanDustMode::Off, kill_dust: CleanDustMode::Off,
eip1283: false, eip1283: false,
eip1706: false,
keep_unsigned_nonce: false, keep_unsigned_nonce: false,
latest_version: U256::zero(), latest_version: U256::zero(),
versions: HashMap::new(), versions: HashMap::new(),
@ -363,6 +366,7 @@ impl Schedule {
have_static_call: false, have_static_call: false,
kill_dust: CleanDustMode::Off, kill_dust: CleanDustMode::Off,
eip1283: false, eip1283: false,
eip1706: false,
keep_unsigned_nonce: false, keep_unsigned_nonce: false,
latest_version: U256::zero(), latest_version: U256::zero(),
versions: HashMap::new(), versions: HashMap::new(),

View File

@ -92,8 +92,12 @@ pub struct Params {
/// See `CommonParams` docs. /// See `CommonParams` docs.
pub eip1283_disable_transition: Option<Uint>, pub eip1283_disable_transition: Option<Uint>,
/// See `CommonParams` docs. /// See `CommonParams` docs.
pub eip1283_reenable_transition: Option<Uint>,
/// See `CommonParams` docs.
pub eip1014_transition: Option<Uint>, pub eip1014_transition: Option<Uint>,
/// See `CommonParams` docs. /// See `CommonParams` docs.
pub eip1706_transition: Option<Uint>,
/// See `CommonParams` docs.
pub eip1344_transition: Option<Uint>, pub eip1344_transition: Option<Uint>,
/// See `CommonParams` docs. /// See `CommonParams` docs.
pub eip1884_transition: Option<Uint>, pub eip1884_transition: Option<Uint>,