Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Extend ethash params by MCIP-3
Browse files Browse the repository at this point in the history
  • Loading branch information
5chdn committed Sep 21, 2017
1 parent 2c2ed16 commit d3831af
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ethcore/src/ethereum/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ pub struct EthashParams {
pub ecip1010_continue_transition: u64,
/// Total block number for one ECIP-1017 era.
pub ecip1017_era_rounds: u64,
/// Number of first block where MCIP-3 begins.

This comment has been minimized.

Copy link
@immartian

immartian Sep 23, 2017

should we have a boolean here to tell if it's musicoin chain? As the following function on _close_block will need to switch case .

or maybe we can get it from somewhere?

This comment has been minimized.

Copy link
@5chdn

5chdn Sep 25, 2017

Author Contributor

No need. It defaults to u64::max_value() if not specified, so only chains defining this parameter will use this for their calculations. So rather then checking the chain we assume any chain could activate MCIP-3 at some point, this is for instance interesting for musicoin testnets or mcip-3 transition tests.

pub mcip3_transition: u64,
/// MCIP-3 Block reward coin-base for miners.
pub mcip3_miner_reward: u64,
/// MCIP-3 Block reward ubi-base for basic income.
pub mcip3_ubi_reward: u64,
/// MCIP-3 contract address for universal basic income.
pub mcip3_ubi_contract: Address,
/// MCIP-3 Block reward dev-base for dev funds.
pub mcip3_dev_reward: u64,
/// MCIP-3 contract address for the developer funds.
pub mcip3_dev_contract: Address,

This comment has been minimized.

Copy link
@rphmeier

rphmeier Sep 25, 2017

Contributor

at some point we should organize portions of the parameters here into structs:
struct Mcip3, struct Ecip1017, etc.

/// Maximum amount of code that can be deploying into a contract.
pub max_code_size: u64,
/// Number of first block where the max gas limit becomes effective.
Expand Down Expand Up @@ -137,6 +149,12 @@ impl From<ethjson::spec::EthashParams> for EthashParams {
ecip1010_pause_transition: p.ecip1010_pause_transition.map_or(u64::max_value(), Into::into),
ecip1010_continue_transition: p.ecip1010_continue_transition.map_or(u64::max_value(), Into::into),
ecip1017_era_rounds: p.ecip1017_era_rounds.map_or(u64::max_value(), Into::into),
mcip3_transition: p.mcip3_transition.map_or(u64::max_value(), Into::into),
mcip3_miner_reward: p.mcip3_miner_reward.map_or(u64::max_value(), Into::into),
mcip3_ubi_reward: p.mcip3_ubi_reward.map_or(u64::max_value(), Into::into),
mcip3_ubi_contract: p.mcip3_ubi_contract.map_or_else(Address::new, Into::into),
mcip3_dev_reward: p.mcip3_dev_reward.map_or(u64::max_value(), Into::into),
mcip3_dev_contract: p.mcip3_dev_contract.map_or_else(Address::new, Into::into),
max_code_size: p.max_code_size.map_or(u64::max_value(), Into::into),
max_gas_limit_transition: p.max_gas_limit_transition.map_or(u64::max_value(), Into::into),
max_gas_limit: p.max_gas_limit.map_or(U256::max_value(), Into::into),
Expand Down
6 changes: 6 additions & 0 deletions ethcore/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ pub fn get_default_ethash_params() -> EthashParams {
ecip1010_pause_transition: u64::max_value(),
ecip1010_continue_transition: u64::max_value(),
ecip1017_era_rounds: u64::max_value(),
mcip3_transition: u64::max_value(),
mcip3_miner_reward: u64::max_value(),
mcip3_ubi_reward: u64::max_value(),
mcip3_ubi_contract: "0000000000000000000000000000000000000001".into(),
mcip3_dev_reward: u64::max_value(),
mcip3_dev_contract: "0000000000000000000000000000000000000001".into(),
max_code_size: u64::max_value(),
max_gas_limit_transition: u64::max_value(),
max_gas_limit: U256::max_value(),
Expand Down
19 changes: 19 additions & 0 deletions json/src/spec/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,25 @@ pub struct EthashParams {
#[serde(rename="ecip1017EraRounds")]
pub ecip1017_era_rounds: Option<Uint>,

/// See main EthashParams docs.
#[serde(rename="mcip3Transition")]
pub mcip3_transition: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="mcip3MinerReward")]
pub mcip3_miner_reward: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="mcip3UbiReward")]
pub mcip3_ubi_reward: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="mcip3UbiContract")]
pub mcip3_ubi_contract: Option<Address>,
/// See main EthashParams docs.
#[serde(rename="mcip3DevReward")]
pub mcip3_dev_reward: Option<Uint>,
/// See main EthashParams docs.
#[serde(rename="mcip3DevContract")]
pub mcip3_dev_contract: Option<Address>,

/// See main EthashParams docs.
#[serde(rename="maxCodeSize")]
pub max_code_size: Option<Uint>,
Expand Down

0 comments on commit d3831af

Please sign in to comment.