From ac30783c8248ea6adc57f0e38c89a778659c26e9 Mon Sep 17 00:00:00 2001 From: POA <33550681+poa@users.noreply.github.com> Date: Thu, 14 Oct 2021 16:14:38 +0300 Subject: [PATCH] Add eip1559FeeCollector and eip1559FeeCollectorTransition spec options and bump to v3.3.0-rc.10 --- CHANGELOG.md | 5 +++++ Cargo.lock | 4 ++-- Cargo.toml | 2 +- crates/ethcore/src/executive.rs | 21 +++++++++++++++++---- crates/ethcore/src/spec/spec.rs | 9 +++++++++ crates/ethjson/src/spec/params.rs | 4 ++++ crates/util/version/Cargo.toml | 2 +- 7 files changed, 39 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 431f6228f..b0662afa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## OpenEthereum v3.3.0-rc.10 + +Enhancements: +* Add eip1559FeeCollector and eip1559FeeCollectorTransition spec options + ## OpenEthereum v3.3.0-rc.9 Bug fixes: diff --git a/Cargo.lock b/Cargo.lock index 9094d9c9c..17841567c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2932,7 +2932,7 @@ checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "openethereum" -version = "3.3.0-rc.9" +version = "3.3.0-rc.10" dependencies = [ "ansi_term 0.10.2", "atty", @@ -3282,7 +3282,7 @@ dependencies = [ [[package]] name = "parity-version" -version = "3.3.0-rc.9" +version = "3.3.0-rc.10" dependencies = [ "parity-bytes", "rlp", diff --git a/Cargo.toml b/Cargo.toml index a51019a31..d2747fc10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ description = "OpenEthereum" name = "openethereum" # NOTE Make sure to update util/version/Cargo.toml as well -version = "3.3.0-rc.9" +version = "3.3.0-rc.10" license = "GPL-3.0" authors = [ "OpenEthereum developers", diff --git a/crates/ethcore/src/executive.rs b/crates/ethcore/src/executive.rs index 59539924e..a91da17a2 100644 --- a/crates/ethcore/src/executive.rs +++ b/crates/ethcore/src/executive.rs @@ -1516,18 +1516,20 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> { // Up until now, fees_value is calculated for each type of transaction based on their gas prices // Now, if eip1559 is activated, burn the base fee // miner only receives the inclusion fee; note that the base fee is not given to anyone (it is burned) - let fees_value = fees_value.saturating_sub(if schedule.eip1559 { - let (base_fee, overflow_3) = + let burnt_fee = if schedule.eip1559 && !t.is_service() { + let (fee, overflow_3) = gas_used.overflowing_mul(self.info.base_fee.unwrap_or_default()); if overflow_3 { return Err(ExecutionError::TransactionMalformed( "U256 Overflow".to_string(), )); } - base_fee + fee } else { U256::from(0) - }); + }; + + let fees_value = fees_value.saturating_sub(burnt_fee); trace!("exec::finalize: t.gas={}, sstore_refunds={}, suicide_refunds={}, refunds_bound={}, gas_left_prerefund={}, refunded={}, gas_left={}, gas_used={}, refund_value={}, fees_value={}\n", t.tx().gas, sstore_refunds, suicide_refunds, refunds_bound, gas_left_prerefund, refunded, gas_left, gas_used, refund_value, fees_value); @@ -1552,6 +1554,17 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> { substate.to_cleanup_mode(&schedule), )?; + if burnt_fee > U256::from(0) + && self.machine.params().eip1559_fee_collector.is_some() + && self.info.number >= self.machine.params().eip1559_fee_collector_transition + { + self.state.add_balance( + &self.machine.params().eip1559_fee_collector.unwrap(), + &burnt_fee, + substate.to_cleanup_mode(&schedule), + )?; + }; + // perform suicides for address in &substate.suicides { self.state.kill_account(address); diff --git a/crates/ethcore/src/spec/spec.rs b/crates/ethcore/src/spec/spec.rs index ae3e7acbb..a37fe92ac 100644 --- a/crates/ethcore/src/spec/spec.rs +++ b/crates/ethcore/src/spec/spec.rs @@ -183,6 +183,10 @@ pub struct CommonParams { pub eip1559_elasticity_multiplier: U256, /// Default value for the block base fee pub eip1559_base_fee_initial_value: U256, + /// 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. + pub eip1559_fee_collector_transition: BlockNumber, } impl CommonParams { @@ -459,6 +463,10 @@ impl From for CommonParams { eip1559_base_fee_initial_value: p .eip1559_base_fee_initial_value .map_or_else(U256::zero, Into::into), + eip1559_fee_collector: p.eip1559_fee_collector.map(Into::into), + eip1559_fee_collector_transition: p + .eip1559_fee_collector_transition + .map_or_else(BlockNumber::max_value, Into::into), } } } @@ -734,6 +742,7 @@ impl Spec { params.kip6_transition, params.max_code_size_transition, params.transaction_permission_contract_transition, + params.eip1559_fee_collector_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 218dd1cbe..f321821f2 100644 --- a/crates/ethjson/src/spec/params.rs +++ b/crates/ethjson/src/spec/params.rs @@ -158,6 +158,10 @@ pub struct Params { pub eip1559_elasticity_multiplier: Option, /// Default value for the block base fee pub eip1559_base_fee_initial_value: 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. + pub eip1559_fee_collector_transition: Option, } #[cfg(test)] diff --git a/crates/util/version/Cargo.toml b/crates/util/version/Cargo.toml index 646e1d392..c813d71d9 100644 --- a/crates/util/version/Cargo.toml +++ b/crates/util/version/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "parity-version" # NOTE: this value is used for OpenEthereum version string (via env CARGO_PKG_VERSION) -version = "3.3.0-rc.9" +version = "3.3.0-rc.10" authors = ["Parity Technologies "] build = "build.rs"