Skip to content

Commit

Permalink
Add eip1559FeeCollector and eip1559FeeCollectorTransition spec option…
Browse files Browse the repository at this point in the history
…s and bump to v3.3.0-rc.10
  • Loading branch information
varasev committed Oct 14, 2021
1 parent 5e9b4c5 commit ac30783
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 17 additions & 4 deletions crates/ethcore/src/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions crates/ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Address>,
/// Block at which the fee collector should start being used.
pub eip1559_fee_collector_transition: BlockNumber,
}

impl CommonParams {
Expand Down Expand Up @@ -459,6 +463,10 @@ impl From<ethjson::spec::Params> 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),
}
}
}
Expand Down Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions crates/ethjson/src/spec/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ pub struct Params {
pub eip1559_elasticity_multiplier: Option<Uint>,
/// Default value for the block base fee
pub eip1559_base_fee_initial_value: Option<Uint>,
/// Address where EIP-1559 burnt fee will be accrued to.
pub eip1559_fee_collector: Option<Address>,
/// Block at which the fee collector should start being used.
pub eip1559_fee_collector_transition: Option<Uint>,
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion crates/util/version/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
build = "build.rs"

Expand Down

0 comments on commit ac30783

Please sign in to comment.