Replace eip1559BaseFeeFixedValue* spec options with eip1559BaseFeeMinValue and eip1559BaseFeeMinValueTransition

This commit is contained in:
POA 2021-11-01 13:20:58 +03:00
parent 437ba9b044
commit f9b2db206a
5 changed files with 43 additions and 37 deletions

View File

@ -1,8 +1,8 @@
## OpenEthereum v3.3.0-rc.14 ## OpenEthereum v3.3.0-rc.14
Enhancements: Enhancements:
* Add eip1559BaseFeeFixedValue and eip1559BaseFeeFixedValueTransition spec options * Add eip1559BaseFeeMinValue and eip1559BaseFeeMinValueTransition spec options
* Activate eip1559BaseFeeFixedValue on xDai at London hardfork block (19040000) * Activate eip1559BaseFeeMinValue on xDai at London hardfork block (19040000)
* Delay difficulty bomb to June 2022 (EIP-4345) * Delay difficulty bomb to June 2022 (EIP-4345)
## OpenEthereum v3.3.0-rc.13 ## OpenEthereum v3.3.0-rc.13

View File

@ -60,9 +60,11 @@
"eip3529Transition": 19040000, "eip3529Transition": 19040000,
"eip3541Transition": 19040000, "eip3541Transition": 19040000,
"eip1559Transition": 19040000, "eip1559Transition": 19040000,
"eip1559BaseFeeMaxChangeDenominator": "0x8",
"eip1559ElasticityMultiplier": "0x2", "eip1559ElasticityMultiplier": "0x2",
"eip1559BaseFeeFixedValue": "0x4A817C800", "eip1559BaseFeeInitialValue": "0x3b9aca00",
"eip1559BaseFeeFixedValueTransition": 19040000, "eip1559BaseFeeMinValue": "0x4A817C800",
"eip1559BaseFeeMinValueTransition": 19040000,
"eip1559FeeCollector": "0x6BBe78ee9e474842Dbd4AB4987b3CeFE88426A92", "eip1559FeeCollector": "0x6BBe78ee9e474842Dbd4AB4987b3CeFE88426A92",
"eip1559FeeCollectorTransition": 19040000, "eip1559FeeCollectorTransition": 19040000,
"registrar": "0x6B53721D4f2Fb9514B85f5C49b197D857e36Cf03", "registrar": "0x6B53721D4f2Fb9514B85f5C49b197D857e36Cf03",

View File

@ -467,8 +467,8 @@ impl EthereumMachine {
/// ///
/// Introduced by EIP1559 to support new market fee mechanism. /// Introduced by EIP1559 to support new market fee mechanism.
/// ///
/// Modified for xDai chain to have an ability to set constant base fee /// Modified for xDai chain to have an ability to set min base fee
/// through eip1559BaseFeeFixedValue spec option. The modification made /// through eip1559BaseFeeMinValue spec option. The modification made
/// in v3.3.0-rc.14 /// in v3.3.0-rc.14
pub fn calc_base_fee(&self, parent: &Header) -> Option<U256> { pub fn calc_base_fee(&self, parent: &Header) -> Option<U256> {
// Block eip1559_transition - 1 has base_fee = None // Block eip1559_transition - 1 has base_fee = None
@ -476,22 +476,22 @@ impl EthereumMachine {
return None; return None;
} }
// If we use base fee constant value, ignore the code below let base_fee_min_value =
if parent.number() + 1 >= self.params().eip1559_base_fee_fixed_value_transition { if parent.number() + 1 >= self.params().eip1559_base_fee_min_value_transition {
let base_fee_fixed_value = match self.params().eip1559_base_fee_fixed_value { match self.params().eip1559_base_fee_min_value {
None => panic!("Base fee fixed value must be set in spec."), None => panic!("Base fee min value must be set in spec."),
Some(fixed_value) => fixed_value, Some(min_value) => min_value,
};
return Some(base_fee_fixed_value);
} }
} else {
U256::zero()
};
// Block eip1559_transition has base_fee = self.params().eip1559_base_fee_initial_value // Block eip1559_transition has base_fee = self.params().eip1559_base_fee_initial_value
if parent.number() + 1 == self.params().eip1559_transition { if parent.number() + 1 == self.params().eip1559_transition {
let base_fee_initial_value = match self.params().eip1559_base_fee_initial_value { return Some(max(
None => panic!("Base fee initial value must be set in spec."), self.params().eip1559_base_fee_initial_value,
Some(initial_value) => initial_value, base_fee_min_value,
}; ));
return Some(base_fee_initial_value);
} }
// Block eip1559_transition + 1 has base_fee = calculated // 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."); panic!("Can't calculate base fee if parent gas target is zero.");
} }
if parent.gas_used() == &parent_gas_target { let result = if parent.gas_used() == &parent_gas_target {
Some(parent_base_fee) parent_base_fee
} else if parent.gas_used() > &parent_gas_target { } else if parent.gas_used() > &parent_gas_target {
let gas_used_delta = parent.gas_used() - parent_gas_target; let gas_used_delta = parent.gas_used() - parent_gas_target;
let base_fee_per_gas_delta = max( let base_fee_per_gas_delta = max(
parent_base_fee * gas_used_delta / parent_gas_target / base_fee_denominator, parent_base_fee * gas_used_delta / parent_gas_target / base_fee_denominator,
U256::from(1), U256::from(1),
); );
Some(parent_base_fee + base_fee_per_gas_delta) parent_base_fee + base_fee_per_gas_delta
} else { } else {
let gas_used_delta = parent_gas_target - parent.gas_used(); let gas_used_delta = parent_gas_target - parent.gas_used();
let base_fee_per_gas_delta = let base_fee_per_gas_delta =
parent_base_fee * gas_used_delta / parent_gas_target / base_fee_denominator; 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))
} }
} }

View File

@ -182,11 +182,11 @@ pub struct CommonParams {
/// Elasticity multiplier /// Elasticity multiplier
pub eip1559_elasticity_multiplier: U256, pub eip1559_elasticity_multiplier: U256,
/// Default value for the block base fee /// Default value for the block base fee
pub eip1559_base_fee_initial_value: Option<U256>, pub eip1559_base_fee_initial_value: U256,
/// Constant value for the block base fee. /// Min value for the block base fee.
pub eip1559_base_fee_fixed_value: Option<U256>, pub eip1559_base_fee_min_value: Option<U256>,
/// Block at which the constant value for the base fee starts to be used. /// Block at which the min value for the base fee starts to be used.
pub eip1559_base_fee_fixed_value_transition: BlockNumber, pub eip1559_base_fee_min_value_transition: BlockNumber,
/// Address where EIP-1559 burnt fee will be accrued to. /// Address where EIP-1559 burnt fee will be accrued to.
pub eip1559_fee_collector: Option<Address>, pub eip1559_fee_collector: Option<Address>,
/// Block at which the fee collector should start being used. /// Block at which the fee collector should start being used.
@ -464,10 +464,12 @@ impl From<ethjson::spec::Params> for CommonParams {
eip1559_elasticity_multiplier: p eip1559_elasticity_multiplier: p
.eip1559_elasticity_multiplier .eip1559_elasticity_multiplier
.map_or_else(U256::zero, Into::into), .map_or_else(U256::zero, Into::into),
eip1559_base_fee_initial_value: p.eip1559_base_fee_initial_value.map(Into::into), eip1559_base_fee_initial_value: p
eip1559_base_fee_fixed_value: p.eip1559_base_fee_fixed_value.map(Into::into), .eip1559_base_fee_initial_value
eip1559_base_fee_fixed_value_transition: p .map_or_else(U256::zero, Into::into),
.eip1559_base_fee_fixed_value_transition 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), .map_or_else(BlockNumber::max_value, Into::into),
eip1559_fee_collector: p.eip1559_fee_collector.map(Into::into), eip1559_fee_collector: p.eip1559_fee_collector.map(Into::into),
eip1559_fee_collector_transition: p eip1559_fee_collector_transition: p
@ -749,7 +751,7 @@ impl Spec {
params.max_code_size_transition, params.max_code_size_transition,
params.transaction_permission_contract_transition, params.transaction_permission_contract_transition,
params.eip1559_fee_collector_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 // 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 { if params.network_id == 0x4 {

View File

@ -158,10 +158,10 @@ pub struct Params {
pub eip1559_elasticity_multiplier: Option<Uint>, pub eip1559_elasticity_multiplier: Option<Uint>,
/// Default value for the block base fee /// Default value for the block base fee
pub eip1559_base_fee_initial_value: Option<Uint>, pub eip1559_base_fee_initial_value: Option<Uint>,
/// Constant value for the block base fee. /// Min value for the block base fee.
pub eip1559_base_fee_fixed_value: Option<Uint>, pub eip1559_base_fee_min_value: Option<Uint>,
/// Block at which the constant value for the base fee starts to be used. /// Block at which the min value for the base fee starts to be used.
pub eip1559_base_fee_fixed_value_transition: Option<Uint>, pub eip1559_base_fee_min_value_transition: Option<Uint>,
/// Address where EIP-1559 burnt fee will be accrued to. /// Address where EIP-1559 burnt fee will be accrued to.
pub eip1559_fee_collector: Option<Address>, pub eip1559_fee_collector: Option<Address>,
/// Block at which the fee collector should start being used. /// Block at which the fee collector should start being used.