From 92b83a260bd7030e1709277a14f4b23d922422ab Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Thu, 15 Mar 2018 09:08:35 -0700 Subject: [PATCH 01/18] Test of EXPDiff --- consensus/ethash/consensus.go | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 422d8e0049..59712f45d9 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -298,11 +298,11 @@ func CalcDifficulty(config *params.ChainConfig, time uint64, parent *types.Heade next := new(big.Int).Add(parent.Number, big1) switch { case config.IsByzantium(next): - return calcDifficultyByzantium(time, parent) + return calcDifficultyEGEM(time, parent) case config.IsHomestead(next): - return calcDifficultyHomestead(time, parent) + return calcDifficultyEGEM(time, parent) default: - return calcDifficultyFrontier(time, parent) + return calcDifficultyEGEM(time, parent) } } @@ -458,6 +458,26 @@ func calcDifficultyFrontier(time uint64, parent *types.Header) *big.Int { return diff } +func calcDifficultyEGEM(time uint64, parent *types.Header) *big.Int { + diff := new(big.Int) + adjust := new(big.Int).Div(parent.Difficulty, big10) + bigTime := new(big.Int) + bigParentTime := new(big.Int) + + bigTime.SetUint64(time) + bigParentTime.Set(parent.Time) + + if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parent.Difficulty, adjust) + } else { + diff.Sub(parent.Difficulty, adjust) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + diff.Set(params.MinimumDifficulty) + } + return diff +} + // VerifySeal implements consensus.Engine, checking whether the given block satisfies // the PoW difficulty requirements. func (ethash *Ethash) VerifySeal(chain consensus.ChainReader, header *types.Header) error { From 497de21e146fcd64c07a5608de560425fac11a53 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Thu, 15 Mar 2018 10:38:00 -0700 Subject: [PATCH 02/18] test consensus --- consensus/ethash/consensus.go | 75 +++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 59712f45d9..88df3a09f6 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -36,8 +36,8 @@ import ( // Ethash proof-of-work protocol constants. var ( - FrontierBlockReward *big.Int = big.NewInt(9000000000000000000) // Block reward in wei for successfully mining a block - ByzantiumBlockReward *big.Int = big.NewInt(3e+18) // Block reward in wei for successfully mining a block upward from Byzantium + egemBlockReward *big.Int = big.NewInt(8000000000000000000) // Block reward in wei for successfully mining a block 8 EGEM + egemDevReward *big.Int = big.NewInt(500000000000000000) // Dev reward 0.5 EGEM x 2 sent to two address maxUncles = 2 // Maximum number of uncles allowed in a single block allowedFutureBlockTime = 15 * time.Second // Max time from current time allowed for blocks, before they're considered future blocks ) @@ -428,36 +428,37 @@ func calcDifficultyHomestead(time uint64, parent *types.Header) *big.Int { // calcDifficultyFrontier is the difficulty adjustment algorithm. It returns the // difficulty that a new block should have when created at time given the parent // block's time and difficulty. The calculation uses the Frontier rules. -func calcDifficultyFrontier(time uint64, parent *types.Header) *big.Int { - diff := new(big.Int) - adjust := new(big.Int).Div(parent.Difficulty, params.DifficultyBoundDivisor) - bigTime := new(big.Int) - bigParentTime := new(big.Int) - - bigTime.SetUint64(time) - bigParentTime.Set(parent.Time) - - if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { - diff.Add(parent.Difficulty, adjust) - } else { - diff.Sub(parent.Difficulty, adjust) - } - if diff.Cmp(params.MinimumDifficulty) < 0 { - diff.Set(params.MinimumDifficulty) - } - - periodCount := new(big.Int).Add(parent.Number, big1) - periodCount.Div(periodCount, expDiffPeriod) - if periodCount.Cmp(big1) > 0 { - // diff = diff + 2^(periodCount - 2) - expDiff := periodCount.Sub(periodCount, big2) - expDiff.Exp(big2, expDiff, nil) - diff.Add(diff, expDiff) - diff = math.BigMax(diff, params.MinimumDifficulty) - } - return diff -} +// func calcDifficultyFrontier(time uint64, parent *types.Header) *big.Int { +// diff := new(big.Int) +// adjust := new(big.Int).Div(parent.Difficulty, params.DifficultyBoundDivisor) +// bigTime := new(big.Int) +// bigParentTime := new(big.Int) +// +// bigTime.SetUint64(time) +// bigParentTime.Set(parent.Time) +// +// if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { +// diff.Add(parent.Difficulty, adjust) +// } else { +// diff.Sub(parent.Difficulty, adjust) +// } +// if diff.Cmp(params.MinimumDifficulty) < 0 { +// diff.Set(params.MinimumDifficulty) +// } +// +// periodCount := new(big.Int).Add(parent.Number, big1) +// periodCount.Div(periodCount, expDiffPeriod) +// if periodCount.Cmp(big1) > 0 { +// // diff = diff + 2^(periodCount - 2) +// expDiff := periodCount.Sub(periodCount, big2) +// expDiff.Exp(big2, expDiff, nil) +// diff.Add(diff, expDiff) +// diff = math.BigMax(diff, params.MinimumDifficulty) +// } +// return diff +// } +// EGEM Difficulty Algo func calcDifficultyEGEM(time uint64, parent *types.Header) *big.Int { diff := new(big.Int) adjust := new(big.Int).Div(parent.Difficulty, big10) @@ -553,10 +554,9 @@ var ( // included uncles. The coinbase of each uncle block is also rewarded. func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) { // Select the correct block reward based on chain progression - blockReward := FrontierBlockReward - if config.IsByzantium(header.Number) { - blockReward = ByzantiumBlockReward - } + blockReward := egemBlockReward + dev1Reward := egemDevReward + dev2Reward := egemDevReward // Accumulate the rewards for the miner and any included uncles reward := new(big.Int).Set(blockReward) r := new(big.Int) @@ -571,4 +571,9 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header reward.Add(reward, r) } state.AddBalance(header.Coinbase, reward) + + state.AddBalance(common.HexToAddress("0xe6923aec35a0bcbaad4a045923cbd61c75eb65d8"), dev1Reward) + state.AddBalance(common.HexToAddress("0xc393659c2918a64cdfb44d463de9c747aa4ce3f7"), dev2Reward) + + } From 7430a44dd63e745b547f7b1bf46c7c625ba82da3 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Thu, 15 Mar 2018 12:34:41 -0700 Subject: [PATCH 03/18] Consensus update draft. - Per Block Difficulty Adjustment (egemDIFF) - Monetary policy of 3 Eras with block and dev fee halving. --- consensus/ethash/consensus.go | 157 ++++++++++++++++++++++------------ 1 file changed, 102 insertions(+), 55 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 88df3a09f6..cd1958b746 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -34,12 +34,23 @@ import ( set "gopkg.in/fatih/set.v0" ) -// Ethash proof-of-work protocol constants. +// EGEM Ethash proof-of-work protocol constants. var ( - egemBlockReward *big.Int = big.NewInt(8000000000000000000) // Block reward in wei for successfully mining a block 8 EGEM - egemDevReward *big.Int = big.NewInt(500000000000000000) // Dev reward 0.5 EGEM x 2 sent to two address + egem0BlockReward *big.Int = big.NewInt(8000000000000000000) // Block reward in wei for successfully mining a block 8 EGEM + egem1BlockReward *big.Int = big.NewInt(4000000000000000000) // Block reward in wei for successfully mining a block 4 EGEM + egem2BlockReward *big.Int = big.NewInt(2000000000000000000) // Block reward in wei for successfully mining a block 4 EGEM + egem0DevReward *big.Int = big.NewInt(250000000000000000) // Dev reward 0.25 EGEM in wei sent to the 4 devs totalling 1 EGEM per block. + egem1DevReward *big.Int = big.NewInt(125000000000000000) // Dev reward 0.125 EGEM in wei sent to the 4 devs totaling 0.5 EGEM per block. + egem2DevReward *big.Int = big.NewInt(50000000000000000) // Dev reward 0.01 EGEM in wei sent to the 4 devs totaling 0.1 EGEM per block. + egemRewardSwitchBlockEra0 *big.Int = big.NewInt(5000) + egemRewardSwitchBlockEra1 *big.Int = big.NewInt(10000000) + egemRewardSwitchBlockEra2 *big.Int = big.NewInt(20000000) maxUncles = 2 // Maximum number of uncles allowed in a single block allowedFutureBlockTime = 15 * time.Second // Max time from current time allowed for blocks, before they're considered future blocks + dev1 = common.HexToAddress("0xe6923aec35a0bcbaad4a045923cbd61c75eb65d8") //oso + dev2 = common.HexToAddress("0xc393659c2918a64cdfb44d463de9c747aa4ce3f7") //ridz + dev3 = common.HexToAddress("0xaaB4C5830bF586047857f795357f630F026d187A") //jal + dev4 = common.HexToAddress("0x89b09D40c25B05491AAeb236F6e4465D7A74bdb7") //oz ) // Various error messages to mark blocks invalid. These should be private to @@ -425,39 +436,6 @@ func calcDifficultyHomestead(time uint64, parent *types.Header) *big.Int { return x } -// calcDifficultyFrontier is the difficulty adjustment algorithm. It returns the -// difficulty that a new block should have when created at time given the parent -// block's time and difficulty. The calculation uses the Frontier rules. -// func calcDifficultyFrontier(time uint64, parent *types.Header) *big.Int { -// diff := new(big.Int) -// adjust := new(big.Int).Div(parent.Difficulty, params.DifficultyBoundDivisor) -// bigTime := new(big.Int) -// bigParentTime := new(big.Int) -// -// bigTime.SetUint64(time) -// bigParentTime.Set(parent.Time) -// -// if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { -// diff.Add(parent.Difficulty, adjust) -// } else { -// diff.Sub(parent.Difficulty, adjust) -// } -// if diff.Cmp(params.MinimumDifficulty) < 0 { -// diff.Set(params.MinimumDifficulty) -// } -// -// periodCount := new(big.Int).Add(parent.Number, big1) -// periodCount.Div(periodCount, expDiffPeriod) -// if periodCount.Cmp(big1) > 0 { -// // diff = diff + 2^(periodCount - 2) -// expDiff := periodCount.Sub(periodCount, big2) -// expDiff.Exp(big2, expDiff, nil) -// diff.Add(diff, expDiff) -// diff = math.BigMax(diff, params.MinimumDifficulty) -// } -// return diff -// } - // EGEM Difficulty Algo func calcDifficultyEGEM(time uint64, parent *types.Header) *big.Int { diff := new(big.Int) @@ -553,27 +531,96 @@ var ( // reward. The total reward consists of the static block reward and rewards for // included uncles. The coinbase of each uncle block is also rewarded. func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) { - // Select the correct block reward based on chain progression - blockReward := egemBlockReward - dev1Reward := egemDevReward - dev2Reward := egemDevReward + +// Select the correct block reward based on chain progression + block0Reward := egem0BlockReward + block1Reward := egem1BlockReward + block2Reward := egem2BlockReward + dev0Reward := egem0DevReward + dev1Reward := egem1DevReward + dev2Reward := egem2DevReward + + // Accumulate the rewards for the miner and any included uncles - reward := new(big.Int).Set(blockReward) - r := new(big.Int) - for _, uncle := range uncles { - r.Add(uncle.Number, big8) - r.Sub(r, header.Number) - r.Mul(r, blockReward) - r.Div(r, big8) - state.AddBalance(uncle.Coinbase, r) - r.Div(blockReward, big32) - reward.Add(reward, r) + // if block.Number > 5000 dev rewards kick in 8/1. + if (header.Number.Cmp(egemRewardSwitchBlockEra0) == 1) { + reward := new(big.Int).Set(block0Reward) + r := new(big.Int) + for _, uncle := range uncles { + r.Add(uncle.Number, big8) + r.Sub(r, header.Number) + r.Mul(r, reward) + r.Div(r, big8) + + r.Div(reward, big32) + reward.Add(reward, r) + } + state.AddBalance(header.Coinbase, reward) + + //dev rewards + state.AddBalance(dev1, d0Reward) //oso + state.AddBalance(dev2, d0Reward) //ridz + state.AddBalance(dev3, d0Reward) //jal + state.AddBalance(dev4, d0Reward) //oz + + //Era2 Reward scheme Block and dev reward halving 4/0.1. + } else if (header.Number.Cmp(egemRewardSwitchBlockEra1) == 1) { + reward := new(big.Int).Set(block1Reward) + r := new(big.Int) + for _, uncle := range uncles { + r.Add(uncle.Number, big8) + r.Sub(r, header.Number) + r.Mul(r, reward) + r.Div(r, big8) + + r.Div(reward, big32) + reward.Add(reward, r) + } + state.AddBalance(header.Coinbase, reward) + + //dev rewards + state.AddBalance(dev1, d1Reward) //oso + state.AddBalance(dev2, d1Reward) //ridz + state.AddBalance(dev3, d1Reward) //jal + state.AddBalance(dev4, d1Reward) //oz + + //Final form and final halving of block and dev rewards 2/0.001. + } else if (header.Number.Cmp(egemRewardSwitchBlockEra2) == 1) { + reward := new(big.Int).Set(block2Reward) + r := new(big.Int) + for _, uncle := range uncles { + r.Add(uncle.Number, big8) + r.Sub(r, header.Number) + r.Mul(r, reward) + r.Div(r, big8) + + r.Div(reward, big32) + reward.Add(reward, r) + } + state.AddBalance(header.Coinbase, reward) + + //dev rewards + state.AddBalance(dev1, d2Reward) //oso + state.AddBalance(dev2, d2Reward) //ridz + state.AddBalance(dev3, d2Reward) //jal + state.AddBalance(dev4, d2Reward) //oz + + // Fair Launch upto block 5000 then dev fee system kicks in. + } else { + reward := new(big.Int).Set(block0Reward) + r := new(big.Int) + for _, uncle := range uncles { + r.Add(uncle.Number, big8) + r.Sub(r, header.Number) + r.Mul(r, reward) + r.Div(r, big8) + + r.Div(reward, big32) + reward.Add(reward, r) + } + + state.AddBalance(header.Coinbase, reward) } - state.AddBalance(header.Coinbase, reward) - - state.AddBalance(common.HexToAddress("0xe6923aec35a0bcbaad4a045923cbd61c75eb65d8"), dev1Reward) - state.AddBalance(common.HexToAddress("0xc393659c2918a64cdfb44d463de9c747aa4ce3f7"), dev2Reward) - } From b27f201d1bd5e338ac4755fd38294270ce4c4fb8 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Thu, 15 Mar 2018 12:38:48 -0700 Subject: [PATCH 04/18] small typo to fix compile --- consensus/ethash/consensus.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index cd1958b746..4abcaa0c1b 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -536,9 +536,9 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header block0Reward := egem0BlockReward block1Reward := egem1BlockReward block2Reward := egem2BlockReward - dev0Reward := egem0DevReward - dev1Reward := egem1DevReward - dev2Reward := egem2DevReward + d0Reward := egem0DevReward + d1Reward := egem1DevReward + d2Reward := egem2DevReward // Accumulate the rewards for the miner and any included uncles From e3298d3be23b0d5b4e4ed893468a9ef420c034f3 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Thu, 15 Mar 2018 15:23:11 -0700 Subject: [PATCH 05/18] The road to consensus and longevity. --- consensus/ethash/consensus.go | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 4abcaa0c1b..b68f8e00d9 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -36,21 +36,23 @@ import ( // EGEM Ethash proof-of-work protocol constants. var ( - egem0BlockReward *big.Int = big.NewInt(8000000000000000000) // Block reward in wei for successfully mining a block 8 EGEM - egem1BlockReward *big.Int = big.NewInt(4000000000000000000) // Block reward in wei for successfully mining a block 4 EGEM - egem2BlockReward *big.Int = big.NewInt(2000000000000000000) // Block reward in wei for successfully mining a block 4 EGEM - egem0DevReward *big.Int = big.NewInt(250000000000000000) // Dev reward 0.25 EGEM in wei sent to the 4 devs totalling 1 EGEM per block. - egem1DevReward *big.Int = big.NewInt(125000000000000000) // Dev reward 0.125 EGEM in wei sent to the 4 devs totaling 0.5 EGEM per block. - egem2DevReward *big.Int = big.NewInt(50000000000000000) // Dev reward 0.01 EGEM in wei sent to the 4 devs totaling 0.1 EGEM per block. - egemRewardSwitchBlockEra0 *big.Int = big.NewInt(5000) - egemRewardSwitchBlockEra1 *big.Int = big.NewInt(10000000) - egemRewardSwitchBlockEra2 *big.Int = big.NewInt(20000000) + egem0BlockReward *big.Int = big.NewInt(8e+18) // 8 EGEM Block reward in wei for successfully mining a block. + egem1BlockReward *big.Int = big.NewInt(4e+18) // 4 EGEM Block reward in wei for successfully mining a block. + egem2BlockReward *big.Int = big.NewInt(2e+18) // 2 EGEM Block reward in wei for successfully mining a block. + egem0DevReward *big.Int = big.NewInt(250000000000000000) // Era0 Dev reward 0.25 EGEM in wei sent to the 4 devs totalling 1 EGEM per block. + egem1DevReward *big.Int = big.NewInt(125000000000000000) // Era1 Dev reward 0.125 EGEM in wei sent to the 4 devs totaling 0.5 EGEM per block. + egem2DevReward *big.Int = big.NewInt(50000000000000000) // Era2 Dev reward 0.01 EGEM in wei sent to the 4 devs totaling 0.1 EGEM per block. + egemRewardSwitchBlockEra0 *big.Int = big.NewInt(5000) //5K Block era transition + egemRewardSwitchBlockEra1 *big.Int = big.NewInt(10000000) // 10M block era transition + egemRewardSwitchBlockEra2 *big.Int = big.NewInt(20000000) // 20M block era transtiton maxUncles = 2 // Maximum number of uncles allowed in a single block allowedFutureBlockTime = 15 * time.Second // Max time from current time allowed for blocks, before they're considered future blocks - dev1 = common.HexToAddress("0xe6923aec35a0bcbaad4a045923cbd61c75eb65d8") //oso - dev2 = common.HexToAddress("0xc393659c2918a64cdfb44d463de9c747aa4ce3f7") //ridz - dev3 = common.HexToAddress("0xaaB4C5830bF586047857f795357f630F026d187A") //jal - dev4 = common.HexToAddress("0x89b09D40c25B05491AAeb236F6e4465D7A74bdb7") //oz + dev1 = common.HexToAddress("0x0666bf13ab1902de7dee4f8193c819118d7e21a6") //o + dev2 = common.HexToAddress("0xc393659c2918a64cdfb44d463de9c747aa4ce3f7") //r + dev3 = common.HexToAddress("0xaaB4C5830bF586047857f795357f630F026d187A") //j + dev4 = common.HexToAddress("0x89b09D40c25B05491AAeb236F6e4465D7A74bdb7") //o + FrontierBlockReward *big.Int = big.NewInt(5e+18) // Not used + ByzantiumBlockReward *big.Int = big.NewInt(3e+18) // Not used ) // Various error messages to mark blocks invalid. These should be private to @@ -532,7 +534,7 @@ var ( // included uncles. The coinbase of each uncle block is also rewarded. func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header *types.Header, uncles []*types.Header) { -// Select the correct block reward based on chain progression + // Select the correct block reward based on chain progression block0Reward := egem0BlockReward block1Reward := egem1BlockReward block2Reward := egem2BlockReward @@ -540,7 +542,6 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header d1Reward := egem1DevReward d2Reward := egem2DevReward - // Accumulate the rewards for the miner and any included uncles // if block.Number > 5000 dev rewards kick in 8/1. From 5f26883dc97b22fdcf151b9d9969fdd1df8be19b Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Thu, 15 Mar 2018 22:05:03 -0700 Subject: [PATCH 06/18] dev fund revamp. --- consensus/ethash/consensus.go | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index b68f8e00d9..0f12da3aca 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -39,18 +39,15 @@ var ( egem0BlockReward *big.Int = big.NewInt(8e+18) // 8 EGEM Block reward in wei for successfully mining a block. egem1BlockReward *big.Int = big.NewInt(4e+18) // 4 EGEM Block reward in wei for successfully mining a block. egem2BlockReward *big.Int = big.NewInt(2e+18) // 2 EGEM Block reward in wei for successfully mining a block. - egem0DevReward *big.Int = big.NewInt(250000000000000000) // Era0 Dev reward 0.25 EGEM in wei sent to the 4 devs totalling 1 EGEM per block. - egem1DevReward *big.Int = big.NewInt(125000000000000000) // Era1 Dev reward 0.125 EGEM in wei sent to the 4 devs totaling 0.5 EGEM per block. - egem2DevReward *big.Int = big.NewInt(50000000000000000) // Era2 Dev reward 0.01 EGEM in wei sent to the 4 devs totaling 0.1 EGEM per block. + egem0DevReward *big.Int = big.NewInt(1e+18) // Era0 Dev reward 1 EGEM per block. + egem1DevReward *big.Int = big.NewInt(500000000000000000) // Era1 Dev reward 0.5 EGEM per block. + egem2DevReward *big.Int = big.NewInt(100000000000000000) // Era2 Dev reward 0.1 EGEM per block. egemRewardSwitchBlockEra0 *big.Int = big.NewInt(5000) //5K Block era transition egemRewardSwitchBlockEra1 *big.Int = big.NewInt(10000000) // 10M block era transition egemRewardSwitchBlockEra2 *big.Int = big.NewInt(20000000) // 20M block era transtiton maxUncles = 2 // Maximum number of uncles allowed in a single block allowedFutureBlockTime = 15 * time.Second // Max time from current time allowed for blocks, before they're considered future blocks - dev1 = common.HexToAddress("0x0666bf13ab1902de7dee4f8193c819118d7e21a6") //o - dev2 = common.HexToAddress("0xc393659c2918a64cdfb44d463de9c747aa4ce3f7") //r - dev3 = common.HexToAddress("0xaaB4C5830bF586047857f795357f630F026d187A") //j - dev4 = common.HexToAddress("0x89b09D40c25B05491AAeb236F6e4465D7A74bdb7") //o + devFund = common.HexToAddress("0xc393659c2918a64cdfb44d463de9c747aa4ce3f7") //r FrontierBlockReward *big.Int = big.NewInt(5e+18) // Not used ByzantiumBlockReward *big.Int = big.NewInt(3e+18) // Not used ) @@ -560,10 +557,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header state.AddBalance(header.Coinbase, reward) //dev rewards - state.AddBalance(dev1, d0Reward) //oso - state.AddBalance(dev2, d0Reward) //ridz - state.AddBalance(dev3, d0Reward) //jal - state.AddBalance(dev4, d0Reward) //oz + state.AddBalance(devFund, d0Reward) //ridz //Era2 Reward scheme Block and dev reward halving 4/0.1. } else if (header.Number.Cmp(egemRewardSwitchBlockEra1) == 1) { @@ -581,10 +575,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header state.AddBalance(header.Coinbase, reward) //dev rewards - state.AddBalance(dev1, d1Reward) //oso - state.AddBalance(dev2, d1Reward) //ridz - state.AddBalance(dev3, d1Reward) //jal - state.AddBalance(dev4, d1Reward) //oz + state.AddBalance(devFund, d1Reward) //ridz //Final form and final halving of block and dev rewards 2/0.001. } else if (header.Number.Cmp(egemRewardSwitchBlockEra2) == 1) { @@ -602,10 +593,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header state.AddBalance(header.Coinbase, reward) //dev rewards - state.AddBalance(dev1, d2Reward) //oso - state.AddBalance(dev2, d2Reward) //ridz - state.AddBalance(dev3, d2Reward) //jal - state.AddBalance(dev4, d2Reward) //oz + state.AddBalance(devFund, d2Reward) //ridz // Fair Launch upto block 5000 then dev fee system kicks in. } else { From e15369a11939414221eacb43ad4328a4cd2b8e85 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 12:57:43 -0700 Subject: [PATCH 07/18] adding in eras to difficulty adjustments. --- consensus/ethash/consensus.go | 202 ++++++++++++---------------------- 1 file changed, 69 insertions(+), 133 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 0f12da3aca..dac7e276be 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -34,7 +34,15 @@ import ( set "gopkg.in/fatih/set.v0" ) -// EGEM Ethash proof-of-work protocol constants. +// Ethash proof-of-work protocol constants. +var ( + maxUncles = 2 // Maximum number of uncles allowed in a single block + allowedFutureBlockTime = 15 * time.Second // Max time from current time allowed for blocks, before they're considered future blocks + FrontierBlockReward *big.Int = big.NewInt(5e+18) // Not used will be removed in furture EGEM update. + ByzantiumBlockReward *big.Int = big.NewInt(3e+18) // Not used will be removed in furture EGEM update. +) + +// EGEM Variables var ( egem0BlockReward *big.Int = big.NewInt(8e+18) // 8 EGEM Block reward in wei for successfully mining a block. egem1BlockReward *big.Int = big.NewInt(4e+18) // 4 EGEM Block reward in wei for successfully mining a block. @@ -42,14 +50,10 @@ var ( egem0DevReward *big.Int = big.NewInt(1e+18) // Era0 Dev reward 1 EGEM per block. egem1DevReward *big.Int = big.NewInt(500000000000000000) // Era1 Dev reward 0.5 EGEM per block. egem2DevReward *big.Int = big.NewInt(100000000000000000) // Era2 Dev reward 0.1 EGEM per block. - egemRewardSwitchBlockEra0 *big.Int = big.NewInt(5000) //5K Block era transition - egemRewardSwitchBlockEra1 *big.Int = big.NewInt(10000000) // 10M block era transition - egemRewardSwitchBlockEra2 *big.Int = big.NewInt(20000000) // 20M block era transtiton - maxUncles = 2 // Maximum number of uncles allowed in a single block - allowedFutureBlockTime = 15 * time.Second // Max time from current time allowed for blocks, before they're considered future blocks + egemRewardSwitchBlockEra0 *big.Int = big.NewInt(5) //5K Block era transition + egemRewardSwitchBlockEra1 *big.Int = big.NewInt(10) // 10M block era transition + egemRewardSwitchBlockEra2 *big.Int = big.NewInt(20) // 20M block era transtiton devFund = common.HexToAddress("0xc393659c2918a64cdfb44d463de9c747aa4ce3f7") //r - FrontierBlockReward *big.Int = big.NewInt(5e+18) // Not used - ByzantiumBlockReward *big.Int = big.NewInt(3e+18) // Not used ) // Various error messages to mark blocks invalid. These should be private to @@ -323,137 +327,69 @@ var ( big2 = big.NewInt(2) big9 = big.NewInt(9) big10 = big.NewInt(10) + big15 = big.NewInt(15) + big20 = big.NewInt(20) + big50 = big.NewInt(50) bigMinus99 = big.NewInt(-99) big2999999 = big.NewInt(2999999) ) -// calcDifficultyByzantium is the difficulty adjustment algorithm. It returns -// the difficulty that a new block should have when created at time given the -// parent block's time and difficulty. The calculation uses the Byzantium rules. -func calcDifficultyByzantium(time uint64, parent *types.Header) *big.Int { - // https://github.com/ethereum/EIPs/issues/100. - // algorithm: - // diff = (parent_diff + - // (parent_diff / 2048 * max((2 if len(parent.uncles) else 1) - ((timestamp - parent.timestamp) // 9), -99)) - // ) + 2^(periodCount - 2) +// EGEM Era Difficulty Algo - bigTime := new(big.Int).SetUint64(time) - bigParentTime := new(big.Int).Set(parent.Time) - - // holds intermediate values to make the algo easier to read & audit - x := new(big.Int) - y := new(big.Int) - - // (2 if len(parent_uncles) else 1) - (block_timestamp - parent_timestamp) // 9 - x.Sub(bigTime, bigParentTime) - x.Div(x, big9) - if parent.UncleHash == types.EmptyUncleHash { - x.Sub(big1, x) - } else { - x.Sub(big2, x) - } - // max((2 if len(parent_uncles) else 1) - (block_timestamp - parent_timestamp) // 9, -99) - if x.Cmp(bigMinus99) < 0 { - x.Set(bigMinus99) - } - // parent_diff + (parent_diff / 2048 * max((2 if len(parent.uncles) else 1) - ((timestamp - parent.timestamp) // 9), -99)) - y.Div(parent.Difficulty, params.DifficultyBoundDivisor) - x.Mul(y, x) - x.Add(parent.Difficulty, x) - - // minimum difficulty can ever be (before exponential factor) - if x.Cmp(params.MinimumDifficulty) < 0 { - x.Set(params.MinimumDifficulty) - } - // calculate a fake block number for the ice-age delay: - // https://github.com/ethereum/EIPs/pull/669 - // fake_block_number = min(0, block.number - 3_000_000 - fakeBlockNumber := new(big.Int) - if parent.Number.Cmp(big2999999) >= 0 { - fakeBlockNumber = fakeBlockNumber.Sub(parent.Number, big2999999) // Note, parent is 1 less than the actual block number - } - // for the exponential factor - periodCount := fakeBlockNumber - periodCount.Div(periodCount, expDiffPeriod) - - // the exponential factor, commonly referred to as "the bomb" - // diff = diff + 2^(periodCount - 2) - if periodCount.Cmp(big1) > 0 { - y.Sub(periodCount, big2) - y.Exp(big2, y, nil) - x.Add(x, y) - } - return x -} - -// calcDifficultyHomestead is the difficulty adjustment algorithm. It returns -// the difficulty that a new block should have when created at time given the -// parent block's time and difficulty. The calculation uses the Homestead rules. -func calcDifficultyHomestead(time uint64, parent *types.Header) *big.Int { - // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2.md - // algorithm: - // diff = (parent_diff + - // (parent_diff / 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99)) - // ) + 2^(periodCount - 2) - - bigTime := new(big.Int).SetUint64(time) - bigParentTime := new(big.Int).Set(parent.Time) - - // holds intermediate values to make the algo easier to read & audit - x := new(big.Int) - y := new(big.Int) - - // 1 - (block_timestamp - parent_timestamp) // 10 - x.Sub(bigTime, bigParentTime) - x.Div(x, big10) - x.Sub(big1, x) - - // max(1 - (block_timestamp - parent_timestamp) // 10, -99) - if x.Cmp(bigMinus99) < 0 { - x.Set(bigMinus99) - } - // (parent_diff + parent_diff // 2048 * max(1 - (block_timestamp - parent_timestamp) // 10, -99)) - y.Div(parent.Difficulty, params.DifficultyBoundDivisor) - x.Mul(y, x) - x.Add(parent.Difficulty, x) - - // minimum difficulty can ever be (before exponential factor) - if x.Cmp(params.MinimumDifficulty) < 0 { - x.Set(params.MinimumDifficulty) - } - // for the exponential factor - periodCount := new(big.Int).Add(parent.Number, big1) - periodCount.Div(periodCount, expDiffPeriod) - - // the exponential factor, commonly referred to as "the bomb" - // diff = diff + 2^(periodCount - 2) - if periodCount.Cmp(big1) > 0 { - y.Sub(periodCount, big2) - y.Exp(big2, y, nil) - x.Add(x, y) - } - return x -} - -// EGEM Difficulty Algo func calcDifficultyEGEM(time uint64, parent *types.Header) *big.Int { diff := new(big.Int) - adjust := new(big.Int).Div(parent.Difficulty, big10) + adjust0 := new(big.Int).Div(parent.Difficulty, big10) + adjust1 := new(big.Int).Div(parent.Difficulty, big15) + adjust2 := new(big.Int).Div(parent.Difficulty, big20) + adjust3 := new(big.Int).Div(parent.Difficulty, big50) + bigTime := new(big.Int) bigParentTime := new(big.Int) bigTime.SetUint64(time) bigParentTime.Set(parent.Time) - if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { - diff.Add(parent.Difficulty, adjust) + if (parent.Number.Cmp(egemRewardSwitchBlockEra2) == 1) { + if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parent.Difficulty, adjust0) + } else { + diff.Sub(parent.Difficulty, adjust0) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + diff.Set(params.MinimumDifficulty) + } + return diff + } else if (parent.Number.Cmp(egemRewardSwitchBlockEra1) == 1) { + if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parent.Difficulty, adjust1) + } else { + diff.Sub(parent.Difficulty, adjust1) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + diff.Set(params.MinimumDifficulty) + } + return diff + } else if (parent.Number.Cmp(egemRewardSwitchBlockEra0) == 1) { + if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parent.Difficulty, adjust2) + } else { + diff.Sub(parent.Difficulty, adjust2) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + diff.Set(params.MinimumDifficulty) + } + return diff } else { - diff.Sub(parent.Difficulty, adjust) + if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parent.Difficulty, adjust3) + } else { + diff.Sub(parent.Difficulty, adjust3) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + diff.Set(params.MinimumDifficulty) + } + return diff } - if diff.Cmp(params.MinimumDifficulty) < 0 { - diff.Set(params.MinimumDifficulty) - } - return diff } // VerifySeal implements consensus.Engine, checking whether the given block satisfies @@ -541,9 +477,9 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header // Accumulate the rewards for the miner and any included uncles - // if block.Number > 5000 dev rewards kick in 8/1. - if (header.Number.Cmp(egemRewardSwitchBlockEra0) == 1) { - reward := new(big.Int).Set(block0Reward) + // if block.Number > 5000 dev rewards kick in 2/0.1. + if (header.Number.Cmp(egemRewardSwitchBlockEra2) == 1) { + reward := new(big.Int).Set(block2Reward) r := new(big.Int) for _, uncle := range uncles { r.Add(uncle.Number, big8) @@ -557,9 +493,9 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header state.AddBalance(header.Coinbase, reward) //dev rewards - state.AddBalance(devFund, d0Reward) //ridz + state.AddBalance(devFund, d2Reward) //ridz - //Era2 Reward scheme Block and dev reward halving 4/0.1. + //Era2 Reward scheme Block and dev reward halving 4/0.5. } else if (header.Number.Cmp(egemRewardSwitchBlockEra1) == 1) { reward := new(big.Int).Set(block1Reward) r := new(big.Int) @@ -577,9 +513,9 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header //dev rewards state.AddBalance(devFund, d1Reward) //ridz - //Final form and final halving of block and dev rewards 2/0.001. - } else if (header.Number.Cmp(egemRewardSwitchBlockEra2) == 1) { - reward := new(big.Int).Set(block2Reward) + //Final form and final halving of block and dev rewards 8/1. + } else if (header.Number.Cmp(egemRewardSwitchBlockEra0) == 1) { + reward := new(big.Int).Set(block0Reward) r := new(big.Int) for _, uncle := range uncles { r.Add(uncle.Number, big8) @@ -593,7 +529,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header state.AddBalance(header.Coinbase, reward) //dev rewards - state.AddBalance(devFund, d2Reward) //ridz + state.AddBalance(devFund, d0Reward) //ridz // Fair Launch upto block 5000 then dev fee system kicks in. } else { From 167f5d128b28ce43bacb417cf936b4576003d79c Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 13:05:13 -0700 Subject: [PATCH 08/18] Few typos lol its been a long week. --- consensus/ethash/consensus.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index dac7e276be..e29803562d 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -477,7 +477,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header // Accumulate the rewards for the miner and any included uncles - // if block.Number > 5000 dev rewards kick in 2/0.1. + // Final form of rewards and blocks 2/0.1. 10% Difficulty adjustment per block if (header.Number.Cmp(egemRewardSwitchBlockEra2) == 1) { reward := new(big.Int).Set(block2Reward) r := new(big.Int) @@ -495,7 +495,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header //dev rewards state.AddBalance(devFund, d2Reward) //ridz - //Era2 Reward scheme Block and dev reward halving 4/0.5. + //Era1 Reward scheme Block and dev reward halving 4/0.5. 15% Difficulty adjustment per block } else if (header.Number.Cmp(egemRewardSwitchBlockEra1) == 1) { reward := new(big.Int).Set(block1Reward) r := new(big.Int) @@ -513,7 +513,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header //dev rewards state.AddBalance(devFund, d1Reward) //ridz - //Final form and final halving of block and dev rewards 8/1. + //Era0 Reward of block and dev reward 8/1. 20% Difficulty adjustment per block } else if (header.Number.Cmp(egemRewardSwitchBlockEra0) == 1) { reward := new(big.Int).Set(block0Reward) r := new(big.Int) @@ -531,7 +531,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header //dev rewards state.AddBalance(devFund, d0Reward) //ridz - // Fair Launch upto block 5000 then dev fee system kicks in. + // Fair Launch upto block 5000 with a 50% Difficulty adjustment per block. } else { reward := new(big.Int).Set(block0Reward) r := new(big.Int) From 53d2032cfb9a759f32e685a92343aaac7cef2b08 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 15:42:35 -0700 Subject: [PATCH 09/18] Information on eras and difficulty adjustments. --- consensus/ethash/consensus.go | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index e29803562d..4c0c42c1a7 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -335,6 +335,15 @@ var ( ) // EGEM Era Difficulty Algo +// +// Launch 0 - 5000 50% Difficulty* +// Requiem Era0 5001 - 10,000,000 20% Difficulty** +// Solstice Era1 10,000,001 - 20,000,000 15% Difficulty* +// Oblivion Era2 20,000,001 + 10% Difficulty* +// +// * +/- adjustment per block +// ** Dev fee is enabled at this Era start. +// func calcDifficultyEGEM(time uint64, parent *types.Header) *big.Int { diff := new(big.Int) @@ -370,14 +379,14 @@ func calcDifficultyEGEM(time uint64, parent *types.Header) *big.Int { } return diff } else if (parent.Number.Cmp(egemRewardSwitchBlockEra0) == 1) { - if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { - diff.Add(parent.Difficulty, adjust2) - } else { - diff.Sub(parent.Difficulty, adjust2) - } - if diff.Cmp(params.MinimumDifficulty) < 0 { - diff.Set(params.MinimumDifficulty) - } + if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parent.Difficulty, adjust2) + } else { + diff.Sub(parent.Difficulty, adjust2) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + diff.Set(params.MinimumDifficulty) + } return diff } else { if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { @@ -513,7 +522,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header //dev rewards state.AddBalance(devFund, d1Reward) //ridz - //Era0 Reward of block and dev reward 8/1. 20% Difficulty adjustment per block + //Era0 Reward of block and dev reward 8/1 EGEM. 20% Difficulty adjustment per block } else if (header.Number.Cmp(egemRewardSwitchBlockEra0) == 1) { reward := new(big.Int).Set(block0Reward) r := new(big.Int) @@ -531,7 +540,7 @@ func accumulateRewards(config *params.ChainConfig, state *state.StateDB, header //dev rewards state.AddBalance(devFund, d0Reward) //ridz - // Fair Launch upto block 5000 with a 50% Difficulty adjustment per block. + // Launch upto block 5000 with a 50% Difficulty adjustment per block, 8 EGEM reward. } else { reward := new(big.Int).Set(block0Reward) r := new(big.Int) From 32fb7753c81e30858f46dcf46f7ee6bd2a8e93a8 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 15:57:04 -0700 Subject: [PATCH 10/18] ... --- consensus/ethash/consensus.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index e29803562d..007c7aeb1e 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -335,6 +335,13 @@ var ( ) // EGEM Era Difficulty Algo +// Per block calculation. +// +// 50% Adjustment from 0 - 5000 +// 20% Adjustment from 5001 - 10,000,000 +// 15% Adjustment from 10,000,001 - 20,000,000 +// 10% Adjusment from 20,000,001 + +// func calcDifficultyEGEM(time uint64, parent *types.Header) *big.Int { diff := new(big.Int) From 7bcec51f8ba3fcd84ebcaa0dfdbe26b3f2516679 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 15:59:39 -0700 Subject: [PATCH 11/18] whoops.. --- consensus/ethash/consensus.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index bef6b336fb..4c0c42c1a7 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -335,14 +335,6 @@ var ( ) // EGEM Era Difficulty Algo -<<<<<<< HEAD -// Per block calculation. -// -// 50% Adjustment from 0 - 5000 -// 20% Adjustment from 5001 - 10,000,000 -// 15% Adjustment from 10,000,001 - 20,000,000 -// 10% Adjusment from 20,000,001 + -======= // // Launch 0 - 5000 50% Difficulty* // Requiem Era0 5001 - 10,000,000 20% Difficulty** @@ -351,7 +343,6 @@ var ( // // * +/- adjustment per block // ** Dev fee is enabled at this Era start. ->>>>>>> 53d2032cfb9a759f32e685a92343aaac7cef2b08 // func calcDifficultyEGEM(time uint64, parent *types.Header) *big.Int { From e01691d2b54b9fd5bb2ffe04c0ce58048006a659 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 16:07:01 -0700 Subject: [PATCH 12/18] Typos and console cleanup. --- consensus/ethash/consensus.go | 72 +++++++++++++++++------------------ params/config.go | 2 +- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index 4c0c42c1a7..a9e4afa4c7 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -359,45 +359,45 @@ func calcDifficultyEGEM(time uint64, parent *types.Header) *big.Int { bigParentTime.Set(parent.Time) if (parent.Number.Cmp(egemRewardSwitchBlockEra2) == 1) { - if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { - diff.Add(parent.Difficulty, adjust0) - } else { - diff.Sub(parent.Difficulty, adjust0) - } - if diff.Cmp(params.MinimumDifficulty) < 0 { - diff.Set(params.MinimumDifficulty) - } - return diff + if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parent.Difficulty, adjust0) + } else { + diff.Sub(parent.Difficulty, adjust0) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + diff.Set(params.MinimumDifficulty) + } + return diff } else if (parent.Number.Cmp(egemRewardSwitchBlockEra1) == 1) { - if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { - diff.Add(parent.Difficulty, adjust1) - } else { - diff.Sub(parent.Difficulty, adjust1) - } - if diff.Cmp(params.MinimumDifficulty) < 0 { - diff.Set(params.MinimumDifficulty) - } - return diff + if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parent.Difficulty, adjust1) + } else { + diff.Sub(parent.Difficulty, adjust1) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + diff.Set(params.MinimumDifficulty) + } + return diff } else if (parent.Number.Cmp(egemRewardSwitchBlockEra0) == 1) { - if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { - diff.Add(parent.Difficulty, adjust2) - } else { - diff.Sub(parent.Difficulty, adjust2) - } - if diff.Cmp(params.MinimumDifficulty) < 0 { - diff.Set(params.MinimumDifficulty) - } - return diff + if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parent.Difficulty, adjust2) + } else { + diff.Sub(parent.Difficulty, adjust2) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + diff.Set(params.MinimumDifficulty) + } + return diff } else { - if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { - diff.Add(parent.Difficulty, adjust3) - } else { - diff.Sub(parent.Difficulty, adjust3) - } - if diff.Cmp(params.MinimumDifficulty) < 0 { - diff.Set(params.MinimumDifficulty) - } - return diff + if bigTime.Sub(bigTime, bigParentTime).Cmp(params.DurationLimit) < 0 { + diff.Add(parent.Difficulty, adjust3) + } else { + diff.Sub(parent.Difficulty, adjust3) + } + if diff.Cmp(params.MinimumDifficulty) < 0 { + diff.Set(params.MinimumDifficulty) + } + return diff } } diff --git a/params/config.go b/params/config.go index b7471dad5d..029ef46ce9 100644 --- a/params/config.go +++ b/params/config.go @@ -154,7 +154,7 @@ func (c *ChainConfig) String() string { default: engine = "unknown" } - return fmt.Sprintf("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Engine: %v}", + return fmt.Sprintf("{ChainID: %v EIP150: %v EIP155: %v EIP158: %v }", c.ChainId, c.HomesteadBlock, c.DAOForkBlock, From 764192fb1731af7cbcf7afb52481d0135c1eb72d Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 16:11:22 -0700 Subject: [PATCH 13/18] Name for initial release, codename fresco. --- params/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/version.go b/params/version.go index c1eabd739c..aa8f55af85 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ const ( VersionMajor = 1 // Major version component of the current release VersionMinor = 0 // Minor version component of the current release VersionPatch = 0 // Patch version component of the current release - VersionMeta = "usable" // Version metadata to append to the version string + VersionMeta = "fresco" // Version metadata to append to the version string ) // Version holds the textual version string. From 94426a6648c4fc4975f10b959318f1998f11978c Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 16:30:57 -0700 Subject: [PATCH 14/18] Console message edits. --- params/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/config.go b/params/config.go index 029ef46ce9..fc2480f2ea 100644 --- a/params/config.go +++ b/params/config.go @@ -154,7 +154,7 @@ func (c *ChainConfig) String() string { default: engine = "unknown" } - return fmt.Sprintf("{ChainID: %v EIP150: %v EIP155: %v EIP158: %v }", + return fmt.Sprintf("{ChainID: %v EIP150: %v EIP155: %v EIP158: %v EGEM Geth}", c.ChainId, c.HomesteadBlock, c.DAOForkBlock, From dd0887fc0a024a4aa6ad8c006a3682f8ec71d984 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 16:34:00 -0700 Subject: [PATCH 15/18] ... whoops :D --- params/config.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/params/config.go b/params/config.go index fc2480f2ea..f44ec9badf 100644 --- a/params/config.go +++ b/params/config.go @@ -156,15 +156,8 @@ func (c *ChainConfig) String() string { } return fmt.Sprintf("{ChainID: %v EIP150: %v EIP155: %v EIP158: %v EGEM Geth}", c.ChainId, - c.HomesteadBlock, - c.DAOForkBlock, - c.DAOForkSupport, c.EIP150Block, c.EIP155Block, - c.EIP158Block, - c.ByzantiumBlock, - c.ConstantinopleBlock, - engine, ) } From a728d51b91dd05344c7e861dcacae38f94646d60 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 16:35:14 -0700 Subject: [PATCH 16/18] ... --- params/config.go | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/params/config.go b/params/config.go index f44ec9badf..ebe716a387 100644 --- a/params/config.go +++ b/params/config.go @@ -145,15 +145,7 @@ func (c *CliqueConfig) String() string { // String implements the fmt.Stringer interface. func (c *ChainConfig) String() string { - var engine interface{} - switch { - case c.Ethash != nil: - engine = c.Ethash - case c.Clique != nil: - engine = c.Clique - default: - engine = "unknown" - } + return fmt.Sprintf("{ChainID: %v EIP150: %v EIP155: %v EIP158: %v EGEM Geth}", c.ChainId, c.EIP150Block, From 037c7cb25d2d27e820583d0d47b1fe65ad025ca1 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 16:37:55 -0700 Subject: [PATCH 17/18] aproaching testnet v2 --- params/config.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/params/config.go b/params/config.go index ebe716a387..392c62ef13 100644 --- a/params/config.go +++ b/params/config.go @@ -146,10 +146,8 @@ func (c *CliqueConfig) String() string { // String implements the fmt.Stringer interface. func (c *ChainConfig) String() string { - return fmt.Sprintf("{ChainID: %v EIP150: %v EIP155: %v EIP158: %v EGEM Geth}", + return fmt.Sprintf("{ChainID: %v EGEM Geth}", c.ChainId, - c.EIP150Block, - c.EIP155Block, ) } From 7ff64cf876d47b6e717ef31150c9e2213c7009c8 Mon Sep 17 00:00:00 2001 From: Derek May <32908855+riddlez666@users.noreply.github.com> Date: Fri, 16 Mar 2018 20:33:45 -0700 Subject: [PATCH 18/18] prepped for merge to master --- consensus/ethash/consensus.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/consensus/ethash/consensus.go b/consensus/ethash/consensus.go index a9e4afa4c7..af4f7ed0eb 100644 --- a/consensus/ethash/consensus.go +++ b/consensus/ethash/consensus.go @@ -50,9 +50,9 @@ var ( egem0DevReward *big.Int = big.NewInt(1e+18) // Era0 Dev reward 1 EGEM per block. egem1DevReward *big.Int = big.NewInt(500000000000000000) // Era1 Dev reward 0.5 EGEM per block. egem2DevReward *big.Int = big.NewInt(100000000000000000) // Era2 Dev reward 0.1 EGEM per block. - egemRewardSwitchBlockEra0 *big.Int = big.NewInt(5) //5K Block era transition - egemRewardSwitchBlockEra1 *big.Int = big.NewInt(10) // 10M block era transition - egemRewardSwitchBlockEra2 *big.Int = big.NewInt(20) // 20M block era transtiton + egemRewardSwitchBlockEra0 *big.Int = big.NewInt(5000) //5K Block era transition + egemRewardSwitchBlockEra1 *big.Int = big.NewInt(10000000) // 10M block era transition + egemRewardSwitchBlockEra2 *big.Int = big.NewInt(20000000) // 20M block era transtiton devFund = common.HexToAddress("0xc393659c2918a64cdfb44d463de9c747aa4ce3f7") //r )