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

ethcore: mcip3 block reward contract #9605

Merged
merged 6 commits into from
Oct 3, 2018
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 1 addition & 6 deletions ethcore/res/ethereum/mcip3_test.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,7 @@
"homesteadTransition":"0x118c30",
"eip100bTransition":"0x7fffffffffffff",
"blockReward":"0x1105a0185b50a80000",
"mcip3Transition":"0x00",
"mcip3MinerReward":"0xd8d726b7177a80000",
"mcip3UbiReward":"0x2b5e3af16b1880000",
"mcip3UbiContract":"0x00efdd5883ec628983e9063c7d969fe268bbf310",
"mcip3DevReward":"0xc249fdd327780000",
"mcip3DevContract":"0x00756cf8159095948496617f5fb17ed95059f536"
"blockRewardContractCode": "0x608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f91c289814610046575b600080fd5b34801561005257600080fd5b50610097600480360381019080803590602001908201803590602001919091929391929390803590602001908201803590602001919091929391929390505050610136565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156100de5780820151818401526020810190506100c3565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015610120578082015181840152602081019050610105565b5050505090500194505050505060405180910390f35b606080606080600080600073fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561018f57600080fd5b888890508b8b90501415156101a357600080fd5b60036040519080825280602002602001820160405280156101d35781602001602082028038833980820191505090505b50945060036040519080825280602002602001820160405280156102065781602001602082028038833980820191505090505b50935072efdd5883ec628983e9063c7d969fe268bbf31085600181518110151561022c57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506802b5e3af16b188000084600181518110151561028157fe5b906020019060200201818152505072756cf8159095948496617f5fb17ed95059f5368560028151811015156102b257fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505067c249fdd32778000084600281518110151561030657fe5b9060200190602002018181525050600092505b8a8a905083101561049d576000898985818110151561033457fe5b9050602002013561ffff1661ffff1614156103eb578a8a84818110151561035757fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1685600081518110151561038357fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050680d8d726b7177a800008460008151811015156103d857fe5b9060200190602002018181525050610490565b606489898581811015156103fb57fe5b9050602002013561ffff1661ffff1610151561048f576064898985818110151561042157fe5b9050602002013561ffff1603915060038260080361ffff16681105a0185b50a80000029060020a90049050610480858c8c86818110151561045e57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff166104b1565b945061048c84826105c3565b93505b5b8280600101935050610319565b848496509650505050505094509492505050565b606080600060018551016040519080825280602002602001820160405280156104e95781602001602082028038833980820191505090505b509150600090505b845181101561056957848181518110151561050857fe5b90602001906020020151828281518110151561052057fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505080806001019150506104f1565b8382600184510381518110151561057c57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050819250505092915050565b606080600060018551016040519080825280602002602001820160405280156105fb5781602001602082028038833980820191505090505b509150600090505b845181101561064d57848181518110151561061a57fe5b90602001906020020151828281518110151561063257fe5b90602001906020020181815250508080600101915050610603565b8382600184510381518110151561066057fe5b90602001906020020181815250508192505050929150505600a165627a7a72305820791053e6997d13a2fb662360f2bd413abd3c2f09c724b5290a09b2f5cbce0ddd0029"
}
}
},
Expand Down
8 changes: 2 additions & 6 deletions ethcore/res/ethereum/mcip6_byz.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
"homesteadTransition": "0x17",
"eip100bTransition": "0x2a",
"blockReward": "0x1105a0185b50a80000",
"mcip3Transition": "0x17",
"mcip3MinerReward": "0xd8d726b7177a80000",
"mcip3UbiReward": "0x2b5e3af16b1880000",
"mcip3UbiContract": "0x00efdd5883ec628983e9063c7d969fe268bbf310",
"mcip3DevReward": "0xc249fdd327780000",
"mcip3DevContract": "0x00756cf8159095948496617f5fb17ed95059f536",
"blockRewardContractTransition": "0x17",
"blockRewardContractCode": "0x608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f91c289814610046575b600080fd5b34801561005257600080fd5b50610097600480360381019080803590602001908201803590602001919091929391929390803590602001908201803590602001919091929391929390505050610136565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156100de5780820151818401526020810190506100c3565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015610120578082015181840152602081019050610105565b5050505090500194505050505060405180910390f35b606080606080600080600073fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561018f57600080fd5b888890508b8b90501415156101a357600080fd5b60036040519080825280602002602001820160405280156101d35781602001602082028038833980820191505090505b50945060036040519080825280602002602001820160405280156102065781602001602082028038833980820191505090505b50935072efdd5883ec628983e9063c7d969fe268bbf31085600181518110151561022c57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506802b5e3af16b188000084600181518110151561028157fe5b906020019060200201818152505072756cf8159095948496617f5fb17ed95059f5368560028151811015156102b257fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505067c249fdd32778000084600281518110151561030657fe5b9060200190602002018181525050600092505b8a8a905083101561049d576000898985818110151561033457fe5b9050602002013561ffff1661ffff1614156103eb578a8a84818110151561035757fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1685600081518110151561038357fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050680d8d726b7177a800008460008151811015156103d857fe5b9060200190602002018181525050610490565b606489898581811015156103fb57fe5b9050602002013561ffff1661ffff1610151561048f576064898985818110151561042157fe5b9050602002013561ffff1603915060038260080361ffff16681105a0185b50a80000029060020a90049050610480858c8c86818110151561045e57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff166104b1565b945061048c84826105c3565b93505b5b8280600101935050610319565b848496509650505050505094509492505050565b606080600060018551016040519080825280602002602001820160405280156104e95781602001602082028038833980820191505090505b509150600090505b845181101561056957848181518110151561050857fe5b90602001906020020151828281518110151561052057fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505080806001019150506104f1565b8382600184510381518110151561057c57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050819250505092915050565b606080600060018551016040519080825280602002602001820160405280156105fb5781602001602082028038833980820191505090505b509150600090505b845181101561064d57848181518110151561061a57fe5b90602001906020020151828281518110151561063257fe5b90602001906020020181815250508080600101915050610603565b8382600184510381518110151561066057fe5b90602001906020020181815250508192505050929150505600a165627a7a72305820791053e6997d13a2fb662360f2bd413abd3c2f09c724b5290a09b2f5cbce0ddd0029",
"difficultyBombDelays": {
"0x2a": 3000000
}
Expand Down
8 changes: 2 additions & 6 deletions ethcore/res/ethereum/musicoin.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
"homesteadTransition":"0x118c30",
"eip100bTransition":"0x21e88e",
"blockReward":"0x1105a0185b50a80000",
"mcip3Transition":"0x124f81",
"mcip3MinerReward":"0xd8d726b7177a80000",
"mcip3UbiReward":"0x2b5e3af16b1880000",
"mcip3UbiContract":"0x00efdd5883ec628983e9063c7d969fe268bbf310",
"mcip3DevReward":"0xc249fdd327780000",
"mcip3DevContract":"0x00756cf8159095948496617f5fb17ed95059f536",
"blockRewardContractTransition": "0x124f81",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be great when we have transition height inside contract

"blockRewardContractCode": "0x608060405260043610610041576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063f91c289814610046575b600080fd5b34801561005257600080fd5b50610097600480360381019080803590602001908201803590602001919091929391929390803590602001908201803590602001919091929391929390505050610136565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156100de5780820151818401526020810190506100c3565b50505050905001838103825284818151815260200191508051906020019060200280838360005b83811015610120578082015181840152602081019050610105565b5050505090500194505050505060405180910390f35b606080606080600080600073fffffffffffffffffffffffffffffffffffffffe73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561018f57600080fd5b888890508b8b90501415156101a357600080fd5b60036040519080825280602002602001820160405280156101d35781602001602082028038833980820191505090505b50945060036040519080825280602002602001820160405280156102065781602001602082028038833980820191505090505b50935072efdd5883ec628983e9063c7d969fe268bbf31085600181518110151561022c57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff16815250506802b5e3af16b188000084600181518110151561028157fe5b906020019060200201818152505072756cf8159095948496617f5fb17ed95059f5368560028151811015156102b257fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505067c249fdd32778000084600281518110151561030657fe5b9060200190602002018181525050600092505b8a8a905083101561049d576000898985818110151561033457fe5b9050602002013561ffff1661ffff1614156103eb578a8a84818110151561035757fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff1685600081518110151561038357fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050680d8d726b7177a800008460008151811015156103d857fe5b9060200190602002018181525050610490565b606489898581811015156103fb57fe5b9050602002013561ffff1661ffff1610151561048f576064898985818110151561042157fe5b9050602002013561ffff1603915060038260080361ffff16681105a0185b50a80000029060020a90049050610480858c8c86818110151561045e57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff166104b1565b945061048c84826105c3565b93505b5b8280600101935050610319565b848496509650505050505094509492505050565b606080600060018551016040519080825280602002602001820160405280156104e95781602001602082028038833980820191505090505b509150600090505b845181101561056957848181518110151561050857fe5b90602001906020020151828281518110151561052057fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505080806001019150506104f1565b8382600184510381518110151561057c57fe5b9060200190602002019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff1681525050819250505092915050565b606080600060018551016040519080825280602002602001820160405280156105fb5781602001602082028038833980820191505090505b509150600090505b845181101561064d57848181518110151561061a57fe5b90602001906020020151828281518110151561063257fe5b90602001906020020181815250508080600101915050610603565b8382600184510381518110151561066057fe5b90602001906020020181815250508192505050929150505600a165627a7a72305820791053e6997d13a2fb662360f2bd413abd3c2f09c724b5290a09b2f5cbce0ddd0029",
"difficultyBombDelays": {
"0x21e88e": 3000000
}
Expand Down
4 changes: 3 additions & 1 deletion ethcore/src/engines/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use self::epoch::PendingTransition;

use account_provider::AccountProvider;
use builtin::Builtin;
use vm::{EnvInfo, Schedule, CreateContractAddress};
use vm::{EnvInfo, Schedule, CreateContractAddress, CallType, ActionValue};
use error::Error;
use header::{Header, BlockNumber};
use snapshot::SnapshotComponents;
Expand Down Expand Up @@ -163,8 +163,10 @@ pub fn default_system_or_code_call<'a>(machine: &'a ::machine::EthereumMachine,
None,
Some(code),
Some(code_hash),
Some(ActionValue::Apparent(U256::zero())),
U256::max_value(),
Some(data),
Some(CallType::StaticCall),
)
},
};
Expand Down
42 changes: 2 additions & 40 deletions ethcore/src/ethereum/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use std::sync::Arc;
use hash::{KECCAK_EMPTY_LIST_RLP};
use engines::block_reward::{self, BlockRewardContract, RewardKind};
use ethash::{self, quick_get_difficulty, slow_hash_block_number, EthashManager, OptimizeFor};
use ethereum_types::{H256, H64, U256, Address};
use ethereum_types::{H256, H64, U256};
use unexpected::{OutOfBounds, Mismatch};
use block::*;
use error::{BlockError, Error};
Expand Down Expand Up @@ -98,18 +98,6 @@ 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.
pub mcip3_transition: u64,
/// MCIP-3 Block reward coin-base for miners.
pub mcip3_miner_reward: U256,
/// MCIP-3 Block reward ubi-base for basic income.
pub mcip3_ubi_reward: U256,
/// 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: U256,
/// MCIP-3 contract address for the developer funds.
pub mcip3_dev_contract: Address,
/// Block reward in base units.
pub block_reward: BTreeMap<BlockNumber, U256>,
/// EXPIP-2 block height
Expand Down Expand Up @@ -140,12 +128,6 @@ 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_else(Default::default, Into::into),
mcip3_ubi_reward: p.mcip3_ubi_reward.map_or(U256::from(0), 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(U256::from(0), Into::into),
mcip3_dev_contract: p.mcip3_dev_contract.map_or_else(Address::new, Into::into),
block_reward: p.block_reward.map_or_else(
|| {
let mut ret = BTreeMap::new();
Expand Down Expand Up @@ -287,21 +269,7 @@ impl Engine<EthereumMachine> for Arc<Ethash> {
// Bestow block rewards.
let mut result_block_reward = reward + reward.shr(5) * U256::from(n_uncles);

if number >= self.ethash_params.mcip3_transition {
result_block_reward = self.ethash_params.mcip3_miner_reward;

let ubi_contract = self.ethash_params.mcip3_ubi_contract;
let ubi_reward = self.ethash_params.mcip3_ubi_reward;
let dev_contract = self.ethash_params.mcip3_dev_contract;
let dev_reward = self.ethash_params.mcip3_dev_reward;

rewards.push((author, RewardKind::Author, result_block_reward));
rewards.push((ubi_contract, RewardKind::External, ubi_reward));
rewards.push((dev_contract, RewardKind::External, dev_reward));

} else {
rewards.push((author, RewardKind::Author, result_block_reward));
}
rewards.push((author, RewardKind::Author, result_block_reward));

// Bestow uncle rewards.
for u in LiveBlock::uncles(&*block) {
Expand Down Expand Up @@ -549,12 +517,6 @@ mod tests {
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: 0.into(),
mcip3_ubi_reward: 0.into(),
mcip3_ubi_contract: "0000000000000000000000000000000000000001".into(),
mcip3_dev_reward: 0.into(),
mcip3_dev_contract: "0000000000000000000000000000000000000001".into(),
expip2_transition: u64::max_value(),
expip2_duration_limit: 30,
block_reward_contract: None,
Expand Down
12 changes: 8 additions & 4 deletions ethcore/src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ impl EthereumMachine {
Some(contract_address),
code,
code_hash,
None,
gas,
data
data,
None,
)
}

Expand All @@ -149,8 +151,10 @@ impl EthereumMachine {
contract_address: Option<Address>,
code: Option<Arc<Vec<u8>>>,
code_hash: Option<H256>,
value: Option<ActionValue>,
gas: U256,
data: Option<Vec<u8>>
data: Option<Vec<u8>>,
call_type: Option<CallType>,
) -> Result<Vec<u8>, Error> {
let env_info = {
let mut env_info = block.env_info();
Expand All @@ -167,11 +171,11 @@ impl EthereumMachine {
origin: SYSTEM_ADDRESS,
gas,
gas_price: 0.into(),
value: ActionValue::Transfer(0.into()),
value: value.unwrap_or(ActionValue::Transfer(0.into())),
code,
code_hash,
data,
call_type: CallType::Call,
call_type: call_type.unwrap_or(CallType::Call),
params_type: ParamsType::Separate,
};
let schedule = self.schedule(env_info.number);
Expand Down
31 changes: 0 additions & 31 deletions json/src/spec/ethash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,25 +105,6 @@ 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>,

/// Delays of difficulty bombs.
#[serde(rename="difficultyBombDelays")]
pub difficulty_bomb_delays: Option<BTreeMap<Uint, Uint>>,
Expand Down Expand Up @@ -236,12 +217,6 @@ mod tests {
ecip1010_pause_transition: None,
ecip1010_continue_transition: None,
ecip1017_era_rounds: None,
mcip3_transition: None,
mcip3_miner_reward: None,
mcip3_ubi_reward: None,
mcip3_ubi_contract: None,
mcip3_dev_reward: None,
mcip3_dev_contract: None,
expip2_transition: None,
expip2_duration_limit: None,
difficulty_bomb_delays: None,
Expand Down Expand Up @@ -281,12 +256,6 @@ mod tests {
ecip1010_pause_transition: None,
ecip1010_continue_transition: None,
ecip1017_era_rounds: None,
mcip3_transition: None,
mcip3_miner_reward: None,
mcip3_ubi_reward: None,
mcip3_ubi_contract: None,
mcip3_dev_reward: None,
mcip3_dev_contract: None,
expip2_transition: None,
expip2_duration_limit: None,
difficulty_bomb_delays: None,
Expand Down