Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

[R4R]add mirror sync upgrade #5

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ethcore/res/ethereum/bsc.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"eip1706Transition": "0x0",
"eip1884Transition": "0x0",
"eip2028Transition": "0x0",
"mirrorSyncTransition": "0x4f1a00",
"gasLimitBoundDivisor": "0x100",
"maxCodeSize": "0x6000",
"maxCodeSizeTransition": "0x0",
Expand Down
70 changes: 70 additions & 0 deletions ethcore/src/engines/parlia/contract_upgrade.rs

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions ethcore/src/engines/parlia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

//! Implementation of the Parlia POSA Engine.
#![allow(missing_docs)]
mod contract_upgrade;
mod params;
mod snapshot;
pub mod util;

use block::ExecutedBlock;
use client::{BlockId, EngineClient};
use engines::parlia::contract_upgrade::upgrade_build_in_system_contract;
use engines::{
parlia::{
params::ParliaParams,
Expand Down Expand Up @@ -179,6 +181,10 @@ impl Parlia {
.map(|out| (out, Vec::new()))
})
}

fn upgrade_build_in_system_contract(&self, _block: &mut ExecutedBlock) {
upgrade_build_in_system_contract(self.machine.params(), _block);
}
}

/// whether it is a parlia engine
Expand All @@ -195,6 +201,16 @@ impl Engine<EthereumMachine> for Parlia {
&self.machine
}

fn on_new_block(
&self,
_block: &mut ExecutedBlock,
_epoch_begin: bool,
_ancestry: &mut dyn Iterator<Item = ExtendedHeader>,
) -> Result<(), Error> {
self.upgrade_build_in_system_contract(_block);
Ok(())
}

fn on_close_block(&self, _block: &mut ExecutedBlock) -> Result<(), Error> {
let txs = &_block.transactions;
let header = &_block.header;
Expand Down
6 changes: 6 additions & 0 deletions ethcore/src/spec/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ pub struct CommonParams {
pub eip2028_transition: BlockNumber,
/// Number of first block where EIP-2315 rules begin.
pub eip2315_transition: BlockNumber,
// Number of mirror sync fork begin.
pub mirror_sync_transition: BlockNumber,
/// Number of first block where dust cleanup rules (EIP-168 and EIP169) begin.
pub dust_protection_transition: BlockNumber,
/// Nonce cap increase per block. Nonce cap is only checked if dust protection is enabled.
Expand Down Expand Up @@ -345,6 +347,9 @@ impl From<ethjson::spec::Params> for CommonParams {
eip2315_transition: p
.eip2315_transition
.map_or_else(BlockNumber::max_value, Into::into),
mirror_sync_transition: p
.mirror_sync_transition
.map_or_else(BlockNumber::max_value, Into::into),
dust_protection_transition: p
.dust_protection_transition
.map_or_else(BlockNumber::max_value, Into::into),
Expand Down Expand Up @@ -632,6 +637,7 @@ impl Spec {
params.eip1884_transition,
params.eip2028_transition,
params.eip2315_transition,
params.mirror_sync_transition,
params.dust_protection_transition,
params.wasm_activation_transition,
params.wasm_disable_transition,
Expand Down
2 changes: 2 additions & 0 deletions json/src/spec/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ pub struct Params {
/// See `CommonParams` docs.
pub eip2315_transition: Option<Uint>,
/// See `CommonParams` docs.
pub mirror_sync_transition: Option<Uint>,
/// See `CommonParams` docs.
pub dust_protection_transition: Option<Uint>,
/// See `CommonParams` docs.
pub nonce_cap_increment: Option<Uint>,
Expand Down