forked from ethereum/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from EthereumCommonwealth/CLOMonetaryPolicy
Testnet launched - Monetary Policy rewards
- Loading branch information
Showing
10 changed files
with
216 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package ethash | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/core/types" | ||
"github.com/ethereum/go-ethereum/params" | ||
) | ||
|
||
func calcDifficultyCallisto(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) | ||
|
||
bigTime := new(big.Int).SetUint64(time) | ||
bigParentTime := new(big.Int).SetUint64(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) | ||
} | ||
|
||
return x | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package ethash | ||
|
||
import ( | ||
"math/big" | ||
|
||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
var ( | ||
// CLOMinerReward - Block reward in wei for successfully mining a block upward for Callisto Network | ||
CLOMinerReward = new(big.Int).Mul(big.NewInt(420), big.NewInt(1e+18)) | ||
// CLOTreasuryReward - Block reward in wei for successfully mining a block upward for Callisto Network | ||
CLOTreasuryReward = new(big.Int).Mul(big.NewInt(120), big.NewInt(1e+18)) | ||
// CLOStakeReward - Block reward in wei for successfully mining a block upward for Callisto Network | ||
CLOStakeReward = new(big.Int).Mul(big.NewInt(60), big.NewInt(1e+18)) | ||
// CLOHF1TreasuryReward - Block reward in wei for successfully mining a block upward for Callisto Network | ||
CLOHF1TreasuryReward = new(big.Int).Mul(big.NewInt(60), big.NewInt(1e+18)) | ||
// CLOHF1StakeReward - Block reward in wei for successfully mining a block upward for Callisto Network | ||
CLOHF1StakeReward = new(big.Int).Mul(big.NewInt(120), big.NewInt(1e+18)) | ||
// CLOTreasuryAddress - Treasury Address | ||
CLOTreasuryAddress = common.HexToAddress("0x74682Fc32007aF0b6118F259cBe7bCCC21641600") | ||
// CLOStakeAddress - Stake Address before HF1 | ||
CLOStakeAddress = common.HexToAddress("0x3c06f218Ce6dD8E2c535a8925A2eDF81674984D9") | ||
// CLOHF1StakeAddress - Stake Address HF1 | ||
CLOHF1StakeAddress = common.HexToAddress("0xd813419749b3c2cdc94a2f9cfcf154113264a9d6") | ||
) | ||
|
||
func calcBigNumber(reward float64) *big.Int { | ||
bigReward := new(big.Float).Mul(big.NewFloat(reward), big.NewFloat(1e+18)) | ||
bigRewardInt := new(big.Int) | ||
bigReward.Int(bigRewardInt) | ||
return bigRewardInt | ||
} | ||
|
||
func getCLOMonetaryPolicyMinerReward(blockNumber *big.Int) *big.Int { | ||
switch { | ||
case big.NewInt(2900001).Cmp(blockNumber) == 0: | ||
return calcBigNumber(234) | ||
case big.NewInt(4400001).Cmp(blockNumber) == 0: | ||
return calcBigNumber(129.6) | ||
case big.NewInt(5900001).Cmp(blockNumber) == 0: | ||
return calcBigNumber(71.28) | ||
} | ||
return calcBigNumber(38.88) | ||
} | ||
|
||
func getCLOMonetaryPolicyTreasury(blockNumber *big.Int) *big.Int { | ||
switch { | ||
case big.NewInt(2900001).Cmp(blockNumber) == 0: | ||
return calcBigNumber(36) | ||
case big.NewInt(4400001).Cmp(blockNumber) == 0: | ||
return calcBigNumber(21.6) | ||
case big.NewInt(5900001).Cmp(blockNumber) == 0: | ||
return calcBigNumber(12.96) | ||
} | ||
return calcBigNumber(7.77) | ||
} | ||
|
||
func getCLOMonetaryPolicyStake(blockNumber *big.Int) *big.Int { | ||
switch { | ||
case big.NewInt(2900001).Cmp(blockNumber) == 0: | ||
return calcBigNumber(90) | ||
case big.NewInt(4400001).Cmp(blockNumber) == 0: | ||
return calcBigNumber(64.8) | ||
case big.NewInt(5900001).Cmp(blockNumber) == 0: | ||
return calcBigNumber(45.36) | ||
} | ||
return calcBigNumber(31.1) | ||
} | ||
|
||
func getMonetaryPolicyStepMainnet(blockNumber *big.Int) *big.Int { | ||
if blockNumber.Cmp(big.NewInt(4400001)) == -1 { | ||
return big.NewInt(2900001) | ||
} else if blockNumber.Cmp(big.NewInt(5900001)) == -1 { | ||
return big.NewInt(4400001) | ||
} else if blockNumber.Cmp(big.NewInt(7400001)) == -1 { | ||
return big.NewInt(5900001) | ||
} | ||
return big.NewInt(7400001) | ||
} | ||
|
||
func getMonetaryPolicyStepTestnet(blockNumber *big.Int) *big.Int { | ||
if blockNumber.Cmp(big.NewInt(2000)) == -1 { | ||
return big.NewInt(2900001) | ||
} else if blockNumber.Cmp(big.NewInt(3000)) == -1 { | ||
return big.NewInt(4400001) | ||
} else if blockNumber.Cmp(big.NewInt(4000)) == -1 { | ||
return big.NewInt(5900001) | ||
} | ||
return big.NewInt(7400001) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.