-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add Musicoin and MCIP-3 UBI hardfork. #6621
Changes from 23 commits
ec65195
71b5108
e8d519d
ce70df4
fef6698
5dc2a33
3442144
41dfbfc
2c2ed16
d3831af
07dbdb8
7940bf6
7ca83d9
fa65407
1cfbea4
77a3ba8
f292915
44ca37f
d2ecacf
939354c
36a852a
1b9cdfb
6c087c2
072ba1d
c6198a9
4c9ead3
e4532f9
8319991
d7db848
b43006e
d747307
12cd04c
d0d8f1c
babb3a3
f49aa0b
559d9a9
4e9e8c9
21f27b5
5a21744
0cb6303
dd36b4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
{ | ||
"name": "Musicoin", | ||
"dataDir": "musicoin", | ||
"engine": { | ||
"Ethash": { | ||
"params": { | ||
"minimumDifficulty": "0x20000", | ||
"difficultyBoundDivisor": "0x800", | ||
"durationLimit": "0xd", | ||
"homesteadTransition": "0x7fffffffffffff", | ||
"eip150Transition": "0x7fffffffffffff", | ||
"eip160Transition": "0x7fffffffffffff", | ||
"eip161abcTransition": "0x7fffffffffffff", | ||
"eip161dTransition": "0x7fffffffffffff", | ||
"blockReward": "0x1105a0185b50a80000", | ||
"mcip3Transition": "0x124f81", | ||
"mcip3MinerReward": "0xd8d726b7177a80000", | ||
"mcip3UbiReward": "0x2b5e3af16b1880000", | ||
"mcip3UbiContract": "0x00efdd5883ec628983e9063c7d969fe268bbf310", | ||
"mcip3DevReward": "0xc249fdd327780000", | ||
"mcip3DevContract": "0x00756cf8159095948496617f5fb17ed95059f536" | ||
} | ||
} | ||
}, | ||
"params": { | ||
"gasLimitBoundDivisor": "0x400", | ||
"registrar": "0x5C271c4C9A67E7D73b7b3669d47504741354f21D", | ||
"accountStartNonce": "0x0", | ||
"maximumExtraDataSize": "0x20", | ||
"minGasLimit": "0x1388", | ||
"networkID": "0x76740f", | ||
"forkBlock": "0x5b6", | ||
"forkCanonHash": "0xa5e88ad9e34d113e264e307bc27e8471452c8fc13780324bb3abb96fd0558343", | ||
"eip155Transition": "0x7fffffffffffff", | ||
"eip98Transition": "0x7fffffffffffff", | ||
"eip86Transition": "0x7fffffffffffff" | ||
}, | ||
"genesis": { | ||
"seal": { | ||
"ethereum": { | ||
"nonce": "0x000000000000002a", | ||
"mixHash": "0x00000000000000000000000000000000000000647572616c65787365646c6578" | ||
} | ||
}, | ||
"difficulty": "0x3d0900", | ||
"author": "0x0000000000000000000000000000000000000000", | ||
"timestamp": "0x00", | ||
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"extraData": "", | ||
"gasLimit": "0x7a1200" | ||
}, | ||
"nodes": [ | ||
"enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303", | ||
"enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe079415aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0a99@13.93.211.84:30303", | ||
"enode://78de8a0916848093c73790ead81d1928bec737d565119932b98c6b100d944b7a95e94f847f689fc723399d2e31129d182f7ef3863f2b4c820abbf3ab2722344d@191.235.84.50:30303", | ||
"enode://158f8aab45f6d19c6cbf4a089c2670541a8da11978a2f90dbf6a502a4a3bab80d288afdbeb7ec0ef6d92de563767f3b1ea9e8e334ca711e9f8e2df5a0385e8e6@13.75.154.138:30303", | ||
"enode://1118980bf48b0a3640bdba04e0fe78b1add18e1cd99bf22d53daac1fd9972ad650df52176e7c7d89d1114cfef2bc23a2959aa54998a46afcf7d91809f0855082@52.74.57.123:30303", | ||
"enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303", | ||
"enode://d302f52c8789ad87ee528f1431a67f1aa646c9bec17babb4665dfb3d61de5b9119a70aa77b2147a5f28854092ba09769323c1c552a6ac6f6a34cbcf767e2d2fe@158.69.248.48:30303", | ||
"enode://c72564bce8331ae298fb8ece113a456e3927d7e5989c2be3e445678b3600579f722410ef9bbfe339335d676af77343cb21b5b1703b7bebc32be85fce937a2220@191.252.185.71:30303", | ||
"enode://e3ae4d25ee64791ff98bf17c37acf90933359f2505c00f65c84f6863231a32a94153cadb0a462e428f18f35ded6bd91cd91033d26576a28558c22678be9cfaee@5.63.158.137:35555" | ||
], | ||
"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 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ use hash::{KECCAK_EMPTY_LIST_RLP}; | |
use ethash::{quick_get_difficulty, slow_hash_block_number, EthashManager, OptimizeFor}; | ||
use bigint::prelude::U256; | ||
use bigint::hash::{H256, H64}; | ||
use util::Address; | ||
use unexpected::{OutOfBounds, Mismatch}; | ||
use block::*; | ||
use error::{BlockError, Error}; | ||
|
@@ -69,6 +70,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. | ||
pub mcip3_transition: u64, | ||
/// MCIP-3 Block reward coin-base for miners. | ||
pub mcip3_miner_reward: Option<U256>, | ||
/// MCIP-3 Block reward ubi-base for basic income. | ||
pub mcip3_ubi_reward: Option<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: Option<U256>, | ||
/// MCIP-3 contract address for the developer funds. | ||
pub mcip3_dev_contract: Address, | ||
/// Block reward in base units. | ||
pub block_reward: U256, | ||
/// EIP-649 transition block. | ||
|
@@ -95,6 +108,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(Into::into), | ||
mcip3_ubi_reward: p.mcip3_ubi_reward.map(Into::into), | ||
mcip3_ubi_contract: p.mcip3_ubi_contract.map_or_else(Address::new, Into::into), | ||
mcip3_dev_reward: p.mcip3_dev_reward.map(Into::into), | ||
mcip3_dev_contract: p.mcip3_dev_contract.map_or_else(Address::new, Into::into), | ||
block_reward: p.block_reward.map_or_else(Default::default, Into::into), | ||
eip649_transition: p.eip649_transition.map_or(u64::max_value(), Into::into), | ||
eip649_delay: p.eip649_delay.map_or(DEFAULT_EIP649_DELAY, Into::into), | ||
|
@@ -186,24 +205,38 @@ impl Engine<EthereumMachine> for Arc<Ethash> { | |
let author = *LiveBlock::header(&*block).author(); | ||
let number = LiveBlock::header(&*block).number(); | ||
|
||
// Applies EIP-649 reward. | ||
let reward = if number >= self.ethash_params.eip649_transition { | ||
self.ethash_params.eip649_reward.unwrap_or(self.ethash_params.block_reward) | ||
} else { | ||
self.ethash_params.block_reward | ||
}; | ||
|
||
// Applies ECIP-1017 eras. | ||
let eras_rounds = self.ethash_params.ecip1017_era_rounds; | ||
let (eras, reward) = ecip1017_eras_block_reward(eras_rounds, reward, number); | ||
|
||
let n_uncles = LiveBlock::uncles(&*block).len(); | ||
|
||
// Bestow block reward | ||
// Bestow block rewards. | ||
let result_block_reward = reward + reward.shr(5) * U256::from(n_uncles); | ||
let mut uncle_rewards = Vec::with_capacity(n_uncles); | ||
|
||
self.machine.add_balance(block, &author, &result_block_reward)?; | ||
if number >= self.ethash_params.mcip3_transition { | ||
let miner_reward = self.ethash_params.mcip3_miner_reward.unwrap(); | ||
let ubi_contract = self.ethash_params.mcip3_ubi_contract; | ||
let ubi_reward = self.ethash_params.mcip3_ubi_reward.unwrap(); | ||
let dev_contract = self.ethash_params.mcip3_dev_contract; | ||
let dev_reward = self.ethash_params.mcip3_dev_reward.unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes sense. I have rewritten the logic, now a malformed mcip3 spec will just behave like a default block reward scheme. |
||
|
||
// bestow uncle rewards. | ||
self.machine.add_balance(block, &author, &miner_reward)?; | ||
self.machine.add_balance(block, &ubi_contract, &ubi_reward)?; | ||
self.machine.add_balance(block, &dev_contract, &dev_reward)?; | ||
} else { | ||
self.machine.add_balance(block, &author, &result_block_reward)?; | ||
} | ||
|
||
// Bestow uncle rewards. | ||
for u in LiveBlock::uncles(&*block) { | ||
let uncle_author = u.author(); | ||
let result_uncle_reward = if eras == 0 { | ||
|
@@ -219,7 +252,7 @@ impl Engine<EthereumMachine> for Arc<Ethash> { | |
self.machine.add_balance(block, a, reward)?; | ||
} | ||
|
||
// note and trace. | ||
// Note and trace. | ||
self.machine.note_rewards(block, &[(author, result_block_reward)], &uncle_rewards) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. without altering this line, block rewards from this change won't be traced. I would recommend using a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or a separate call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@grbIzl tracing does handle multiple block rewards correctly, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @rphmeier it should. It's pretty straightforward. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good. @5chdn then you would say the correct implementation traces only the miner reward and not any of the others? LGTM if so. |
||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to write tests for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, would be lucky to do that. Do I just add tests at the bottom of ethash.rs? Can I reuse the
test_spec()
or should I create a new test chain that includes the transition? Edit: Created tests for the block rewards.