diff --git a/CHANGELOG.md b/CHANGELOG.md index 32d24f6ad..fe833e661 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ ## OpenEthereum v3.3.0-rc.14 Enhancements: -* Add eip1559BaseFeeFixedValue and eip1559BaseFeeFixedValueTransition spec options -* Activate eip1559BaseFeeFixedValue on xDai at London hardfork block (19040000) +* Add eip1559BaseFeeMinValue and eip1559BaseFeeMinValueTransition spec options +* Activate eip1559BaseFeeMinValue on xDai at London hardfork block (19040000) * Delay difficulty bomb to June 2022 (EIP-4345) ## OpenEthereum v3.3.0-rc.13 diff --git a/crates/ethcore/res/chainspec/xdai.json b/crates/ethcore/res/chainspec/xdai.json index 05570fa8e..33b41fdd6 100644 --- a/crates/ethcore/res/chainspec/xdai.json +++ b/crates/ethcore/res/chainspec/xdai.json @@ -60,9 +60,11 @@ "eip3529Transition": 19040000, "eip3541Transition": 19040000, "eip1559Transition": 19040000, + "eip1559BaseFeeMaxChangeDenominator": "0x8", "eip1559ElasticityMultiplier": "0x2", - "eip1559BaseFeeFixedValue": "0x4A817C800", - "eip1559BaseFeeFixedValueTransition": 19040000, + "eip1559BaseFeeInitialValue": "0x3b9aca00", + "eip1559BaseFeeMinValue": "0x4A817C800", + "eip1559BaseFeeMinValueTransition": 19040000, "eip1559FeeCollector": "0x6BBe78ee9e474842Dbd4AB4987b3CeFE88426A92", "eip1559FeeCollectorTransition": 19040000, "registrar": "0x6B53721D4f2Fb9514B85f5C49b197D857e36Cf03", diff --git a/crates/ethcore/src/machine/impls.rs b/crates/ethcore/src/machine/impls.rs index c5860b9ff..283e1c326 100644 --- a/crates/ethcore/src/machine/impls.rs +++ b/crates/ethcore/src/machine/impls.rs @@ -467,8 +467,8 @@ impl EthereumMachine { /// /// Introduced by EIP1559 to support new market fee mechanism. /// - /// Modified for xDai chain to have an ability to set constant base fee - /// through eip1559BaseFeeFixedValue spec option. The modification made + /// Modified for xDai chain to have an ability to set min base fee + /// through eip1559BaseFeeMinValue spec option. The modification made /// in v3.3.0-rc.14 pub fn calc_base_fee(&self, parent: &Header) -> Option { // Block eip1559_transition - 1 has base_fee = None @@ -476,22 +476,22 @@ impl EthereumMachine { return None; } - // If we use base fee constant value, ignore the code below - if parent.number() + 1 >= self.params().eip1559_base_fee_fixed_value_transition { - let base_fee_fixed_value = match self.params().eip1559_base_fee_fixed_value { - None => panic!("Base fee fixed value must be set in spec."), - Some(fixed_value) => fixed_value, + let base_fee_min_value = + if parent.number() + 1 >= self.params().eip1559_base_fee_min_value_transition { + match self.params().eip1559_base_fee_min_value { + None => panic!("Base fee min value must be set in spec."), + Some(min_value) => min_value, + } + } else { + U256::zero() }; - return Some(base_fee_fixed_value); - } // Block eip1559_transition has base_fee = self.params().eip1559_base_fee_initial_value if parent.number() + 1 == self.params().eip1559_transition { - let base_fee_initial_value = match self.params().eip1559_base_fee_initial_value { - None => panic!("Base fee initial value must be set in spec."), - Some(initial_value) => initial_value, - }; - return Some(base_fee_initial_value); + return Some(max( + self.params().eip1559_base_fee_initial_value, + base_fee_min_value, + )); } // Block eip1559_transition + 1 has base_fee = calculated @@ -509,21 +509,23 @@ impl EthereumMachine { panic!("Can't calculate base fee if parent gas target is zero."); } - if parent.gas_used() == &parent_gas_target { - Some(parent_base_fee) + let result = if parent.gas_used() == &parent_gas_target { + parent_base_fee } else if parent.gas_used() > &parent_gas_target { let gas_used_delta = parent.gas_used() - parent_gas_target; let base_fee_per_gas_delta = max( parent_base_fee * gas_used_delta / parent_gas_target / base_fee_denominator, U256::from(1), ); - Some(parent_base_fee + base_fee_per_gas_delta) + parent_base_fee + base_fee_per_gas_delta } else { let gas_used_delta = parent_gas_target - parent.gas_used(); let base_fee_per_gas_delta = parent_base_fee * gas_used_delta / parent_gas_target / base_fee_denominator; - Some(max(parent_base_fee - base_fee_per_gas_delta, U256::zero())) - } + max(parent_base_fee - base_fee_per_gas_delta, U256::zero()) + }; + + Some(max(result, base_fee_min_value)) } } diff --git a/crates/ethcore/src/spec/spec.rs b/crates/ethcore/src/spec/spec.rs index 08cbe10e9..ca838906c 100644 --- a/crates/ethcore/src/spec/spec.rs +++ b/crates/ethcore/src/spec/spec.rs @@ -182,11 +182,11 @@ pub struct CommonParams { /// Elasticity multiplier pub eip1559_elasticity_multiplier: U256, /// Default value for the block base fee - pub eip1559_base_fee_initial_value: Option, - /// Constant value for the block base fee. - pub eip1559_base_fee_fixed_value: Option, - /// Block at which the constant value for the base fee starts to be used. - pub eip1559_base_fee_fixed_value_transition: BlockNumber, + pub eip1559_base_fee_initial_value: U256, + /// Min value for the block base fee. + pub eip1559_base_fee_min_value: Option, + /// Block at which the min value for the base fee starts to be used. + pub eip1559_base_fee_min_value_transition: BlockNumber, /// Address where EIP-1559 burnt fee will be accrued to. pub eip1559_fee_collector: Option
, /// Block at which the fee collector should start being used. @@ -464,10 +464,12 @@ impl From for CommonParams { eip1559_elasticity_multiplier: p .eip1559_elasticity_multiplier .map_or_else(U256::zero, Into::into), - eip1559_base_fee_initial_value: p.eip1559_base_fee_initial_value.map(Into::into), - eip1559_base_fee_fixed_value: p.eip1559_base_fee_fixed_value.map(Into::into), - eip1559_base_fee_fixed_value_transition: p - .eip1559_base_fee_fixed_value_transition + eip1559_base_fee_initial_value: p + .eip1559_base_fee_initial_value + .map_or_else(U256::zero, Into::into), + eip1559_base_fee_min_value: p.eip1559_base_fee_min_value.map(Into::into), + eip1559_base_fee_min_value_transition: p + .eip1559_base_fee_min_value_transition .map_or_else(BlockNumber::max_value, Into::into), eip1559_fee_collector: p.eip1559_fee_collector.map(Into::into), eip1559_fee_collector_transition: p @@ -749,7 +751,7 @@ impl Spec { params.max_code_size_transition, params.transaction_permission_contract_transition, params.eip1559_fee_collector_transition, - params.eip1559_base_fee_fixed_value_transition, + params.eip1559_base_fee_min_value_transition, ]; // BUG: Rinkeby has homestead transition at block 1 but we can't reflect that in specs for non-Ethash networks if params.network_id == 0x4 { diff --git a/crates/ethjson/src/spec/params.rs b/crates/ethjson/src/spec/params.rs index 14deecdbc..12936323b 100644 --- a/crates/ethjson/src/spec/params.rs +++ b/crates/ethjson/src/spec/params.rs @@ -158,10 +158,10 @@ pub struct Params { pub eip1559_elasticity_multiplier: Option, /// Default value for the block base fee pub eip1559_base_fee_initial_value: Option, - /// Constant value for the block base fee. - pub eip1559_base_fee_fixed_value: Option, - /// Block at which the constant value for the base fee starts to be used. - pub eip1559_base_fee_fixed_value_transition: Option, + /// Min value for the block base fee. + pub eip1559_base_fee_min_value: Option, + /// Block at which the min value for the base fee starts to be used. + pub eip1559_base_fee_min_value_transition: Option, /// Address where EIP-1559 burnt fee will be accrued to. pub eip1559_fee_collector: Option
, /// Block at which the fee collector should start being used.