ethcore: mcip3 block reward contract (#9605)
* Use static call and apparent value transfer for block reward contract code * ethcore: implement musicoin block reward logic with contract * ethcore: update musicoin block reward contract bytecode * ethcore: add comment with source of musicoin block reward contract * ethcore: remove unused mcip6_byz chain spec
This commit is contained in:
parent
2fc1679886
commit
5b87327a43
@ -10,12 +10,7 @@
|
||||
"homesteadTransition":"0x118c30",
|
||||
"eip100bTransition":"0x7fffffffffffff",
|
||||
"blockReward":"0x1105a0185b50a80000",
|
||||
"mcip3Transition":"0x00",
|
||||
"mcip3MinerReward":"0xd8d726b7177a80000",
|
||||
"mcip3UbiReward":"0x2b5e3af16b1880000",
|
||||
"mcip3UbiContract":"0x00efdd5883ec628983e9063c7d969fe268bbf310",
|
||||
"mcip3DevReward":"0xc249fdd327780000",
|
||||
"mcip3DevContract":"0x00756cf8159095948496617f5fb17ed95059f536"
|
||||
"blockRewardContractCode": "0x6080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663f91c28988114610045575b600080fd5b34801561005157600080fd5b50610071602460048035828101929082013591813591820191013561010a565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156100b557818101518382015260200161009d565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156100f45781810151838201526020016100dc565b5050505090500194505050505060405180910390f35b6060808080600080803373fffffffffffffffffffffffffffffffffffffffe1461013357600080fd5b89881461013f57600080fd5b60408051600380825260808201909252906020820160608038833950506040805160038082526080820190925292975090506020820160608038833901905050935072efdd5883ec628983e9063c7d969fe268bbf3108560018151811015156101a457fe5b73ffffffffffffffffffffffffffffffffffffffff90921660209283029091019091015283516802b5e3af16b188000090859060019081106101e257fe5b60209081029091010152845172756cf8159095948496617f5fb17ed95059f536908690600290811061021057fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830290910190910152835167c249fdd327780000908590600290811061024d57fe5b60209081029091010152600092505b898310156103b75788888481811061027057fe5b9050602002013561ffff1661ffff166000141561030c578a8a8481811061029357fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff168560008151811015156102bf57fe5b73ffffffffffffffffffffffffffffffffffffffff9092166020928302909101909101528351680d8d726b7177a8000090859060009081106102fd57fe5b602090810290910101526103ac565b606489898581811061031a57fe5b9050602002013561ffff1661ffff161015156103ac57606489898581811061033e57fe5b9050602002013561ffff1603915060038260080361ffff16681105a0185b50a80000029060020a9004905061039d858c8c86818110151561037b57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff166103c8565b94506103a9848261049f565b93505b60019092019161025c565b509299919850909650505050505050565b606080600084516001016040519080825280602002602001820160405280156103fb578160200160208202803883390190505b509150600090505b845181101561045e57848181518110151561041a57fe5b90602001906020020151828281518110151561043257fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830290910190910152600101610403565b8382600184510381518110151561047157fe5b73ffffffffffffffffffffffffffffffffffffffff9290921660209283029190910190910152509392505050565b606080600084516001016040519080825280602002602001820160405280156104d2578160200160208202803883390190505b509150600090505b845181101561051b5784818151811015156104f157fe5b90602001906020020151828281518110151561050957fe5b602090810290910101526001016104da565b8382600184510381518110151561052e57fe5b60209081029190910101525093925050505600a165627a7a72305820c9ab92a56245040e76af5fc4f3ac4cf4315336b503db06677c21aa1e00aaa8e20029"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -1,162 +0,0 @@
|
||||
{
|
||||
"name": "Musicoin Byzantium Test",
|
||||
"dataDir": "mcip6test",
|
||||
"engine": {
|
||||
"Ethash": {
|
||||
"params": {
|
||||
"minimumDifficulty": "0x020000",
|
||||
"difficultyBoundDivisor": "0x0800",
|
||||
"durationLimit": "0x0d",
|
||||
"homesteadTransition": "0x17",
|
||||
"eip100bTransition": "0x2a",
|
||||
"blockReward": "0x1105a0185b50a80000",
|
||||
"mcip3Transition": "0x17",
|
||||
"mcip3MinerReward": "0xd8d726b7177a80000",
|
||||
"mcip3UbiReward": "0x2b5e3af16b1880000",
|
||||
"mcip3UbiContract": "0x00efdd5883ec628983e9063c7d969fe268bbf310",
|
||||
"mcip3DevReward": "0xc249fdd327780000",
|
||||
"mcip3DevContract": "0x00756cf8159095948496617f5fb17ed95059f536",
|
||||
"difficultyBombDelays": {
|
||||
"0x2a": 3000000
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"params": {
|
||||
"gasLimitBoundDivisor": "0x0400",
|
||||
"registrar": "0x5C271c4C9A67E7D73b7b3669d47504741354f21D",
|
||||
"accountStartNonce": "0x00",
|
||||
"maximumExtraDataSize": "0x20",
|
||||
"minGasLimit": "0x1388",
|
||||
"networkID": "0x76740c",
|
||||
"forkBlock": "0x2b",
|
||||
"forkCanonHash": "0x23c3171e864a5d513a3ef85e4cf86dac4cc36b89e5b8e63bf0ebcca68b9e43c9",
|
||||
"eip150Transition": "0x2a",
|
||||
"eip160Transition": "0x7fffffffffffff",
|
||||
"eip161abcTransition": "0x7fffffffffffff",
|
||||
"eip161dTransition": "0x7fffffffffffff",
|
||||
"eip98Transition": "0x7fffffffffffff",
|
||||
"eip140Transition": "0x2a",
|
||||
"eip155Transition": "0x2a",
|
||||
"eip211Transition": "0x2a",
|
||||
"eip214Transition": "0x2a",
|
||||
"eip658Transition": "0x2a",
|
||||
"maxCodeSize": "0x6000",
|
||||
"maxCodeSizeTransition": "0x7fffffffffffff"
|
||||
},
|
||||
"genesis": {
|
||||
"seal": {
|
||||
"ethereum": {
|
||||
"nonce": "0x000000000000002a",
|
||||
"mixHash": "0x00000000000000000000000000000000000000647572616c65787365646c6578"
|
||||
}
|
||||
},
|
||||
"difficulty": "0x3d0900",
|
||||
"author": "0x0000000000000000000000000000000000000000",
|
||||
"timestamp": "0x00",
|
||||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"extraData": "",
|
||||
"gasLimit": "0x7a1200"
|
||||
},
|
||||
"nodes": [
|
||||
"enode://5ddc110733f6d34101973cdef3f9b43484159acf6f816d3b1ee92bc3c98ea453e857bb1207edf0ec0242008ab3a0f9f05eeaee99d47bd414c08a5bdf4847de13@176.9.3.148:30303",
|
||||
"enode://38f074f4db8e64dfbaf87984bf290eef67772a901a7113d1b62f36216be152b8450c393d6fc562a5e38f04f99bc8f439a99010a230b1d92dc1df43bf0bd00615@176.9.3.148:30403"
|
||||
],
|
||||
"accounts": {
|
||||
"0000000000000000000000000000000000000001": {
|
||||
"balance": "1",
|
||||
"builtin": {
|
||||
"name": "ecrecover",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 3000,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000002": {
|
||||
"balance": "1",
|
||||
"builtin": {
|
||||
"name": "sha256",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 60,
|
||||
"word": 12
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000003": {
|
||||
"balance": "1",
|
||||
"builtin": {
|
||||
"name": "ripemd160",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 600,
|
||||
"word": 120
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000004": {
|
||||
"balance": "1",
|
||||
"builtin": {
|
||||
"name": "identity",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 15,
|
||||
"word": 3
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000005": {
|
||||
"builtin": {
|
||||
"name": "modexp",
|
||||
"activate_at": "0x2a",
|
||||
"pricing": {
|
||||
"modexp": {
|
||||
"divisor": 20
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000006": {
|
||||
"builtin": {
|
||||
"name": "alt_bn128_add",
|
||||
"activate_at": "0x2a",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 500,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000007": {
|
||||
"builtin": {
|
||||
"name": "alt_bn128_mul",
|
||||
"activate_at": "0x2a",
|
||||
"pricing": {
|
||||
"linear": {
|
||||
"base": 40000,
|
||||
"word": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"0000000000000000000000000000000000000008": {
|
||||
"builtin": {
|
||||
"name": "alt_bn128_pairing",
|
||||
"activate_at": "0x2a",
|
||||
"pricing": {
|
||||
"alt_bn128_pairing": {
|
||||
"base": 100000,
|
||||
"pair": 80000
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -10,12 +10,8 @@
|
||||
"homesteadTransition":"0x118c30",
|
||||
"eip100bTransition":"0x21e88e",
|
||||
"blockReward":"0x1105a0185b50a80000",
|
||||
"mcip3Transition":"0x124f81",
|
||||
"mcip3MinerReward":"0xd8d726b7177a80000",
|
||||
"mcip3UbiReward":"0x2b5e3af16b1880000",
|
||||
"mcip3UbiContract":"0x00efdd5883ec628983e9063c7d969fe268bbf310",
|
||||
"mcip3DevReward":"0xc249fdd327780000",
|
||||
"mcip3DevContract":"0x00756cf8159095948496617f5fb17ed95059f536",
|
||||
"blockRewardContractTransition": "0x124f81",
|
||||
"blockRewardContractCode": "0x6080604052600436106100405763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663f91c28988114610045575b600080fd5b34801561005157600080fd5b50610071602460048035828101929082013591813591820191013561010a565b604051808060200180602001838103835285818151815260200191508051906020019060200280838360005b838110156100b557818101518382015260200161009d565b50505050905001838103825284818151815260200191508051906020019060200280838360005b838110156100f45781810151838201526020016100dc565b5050505090500194505050505060405180910390f35b6060808080600080803373fffffffffffffffffffffffffffffffffffffffe1461013357600080fd5b89881461013f57600080fd5b60408051600380825260808201909252906020820160608038833950506040805160038082526080820190925292975090506020820160608038833901905050935072efdd5883ec628983e9063c7d969fe268bbf3108560018151811015156101a457fe5b73ffffffffffffffffffffffffffffffffffffffff90921660209283029091019091015283516802b5e3af16b188000090859060019081106101e257fe5b60209081029091010152845172756cf8159095948496617f5fb17ed95059f536908690600290811061021057fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830290910190910152835167c249fdd327780000908590600290811061024d57fe5b60209081029091010152600092505b898310156103b75788888481811061027057fe5b9050602002013561ffff1661ffff166000141561030c578a8a8481811061029357fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff168560008151811015156102bf57fe5b73ffffffffffffffffffffffffffffffffffffffff9092166020928302909101909101528351680d8d726b7177a8000090859060009081106102fd57fe5b602090810290910101526103ac565b606489898581811061031a57fe5b9050602002013561ffff1661ffff161015156103ac57606489898581811061033e57fe5b9050602002013561ffff1603915060038260080361ffff16681105a0185b50a80000029060020a9004905061039d858c8c86818110151561037b57fe5b9050602002013573ffffffffffffffffffffffffffffffffffffffff166103c8565b94506103a9848261049f565b93505b60019092019161025c565b509299919850909650505050505050565b606080600084516001016040519080825280602002602001820160405280156103fb578160200160208202803883390190505b509150600090505b845181101561045e57848181518110151561041a57fe5b90602001906020020151828281518110151561043257fe5b73ffffffffffffffffffffffffffffffffffffffff909216602092830290910190910152600101610403565b8382600184510381518110151561047157fe5b73ffffffffffffffffffffffffffffffffffffffff9290921660209283029190910190910152509392505050565b606080600084516001016040519080825280602002602001820160405280156104d2578160200160208202803883390190505b509150600090505b845181101561051b5784818151811015156104f157fe5b90602001906020020151828281518110151561050957fe5b602090810290910101526001016104da565b8382600184510381518110151561052e57fe5b60209081029190910101525093925050505600a165627a7a72305820c9ab92a56245040e76af5fc4f3ac4cf4315336b503db06677c21aa1e00aaa8e20029",
|
||||
"difficultyBombDelays": {
|
||||
"0x21e88e": 3000000
|
||||
}
|
||||
|
@ -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};
|
||||
@ -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
|
||||
@ -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();
|
||||
@ -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) {
|
||||
@ -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,
|
||||
|
@ -69,6 +69,8 @@ pub fn new_expanse<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
|
||||
|
||||
/// Create a new Musicoin mainnet chain spec.
|
||||
pub fn new_musicoin<'a, T: Into<SpecParams<'a>>>(params: T) -> Spec {
|
||||
// The musicoin chain spec uses a block reward contract which can be found at
|
||||
// https://gist.github.com/andresilva/6f2afaf9486732a0797f4bdeae018ee9
|
||||
load(params.into(), include_bytes!("../../res/ethereum/musicoin.json"))
|
||||
}
|
||||
|
||||
|
@ -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>>,
|
||||
@ -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,
|
||||
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user