diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-01-13 16:21:17 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | ba71563f6844a574bdfa9da5585bdae4a9958677 (patch) | |
tree | bf474a36438acec5a799f1777de15ac7341bb359 /params | |
parent | cae038236416efd8a3436664024f9cadee741512 (diff) | |
download | dexon-ba71563f6844a574bdfa9da5585bdae4a9958677.tar.gz dexon-ba71563f6844a574bdfa9da5585bdae4a9958677.tar.zst dexon-ba71563f6844a574bdfa9da5585bdae4a9958677.zip |
consensus: implement DEXON cryptoeconomics v4.0 (#145)
Diffstat (limited to 'params')
-rw-r--r-- | params/config.go | 147 | ||||
-rw-r--r-- | params/gen_dexcon_config.go | 82 |
2 files changed, 126 insertions, 103 deletions
diff --git a/params/config.go b/params/config.go index bc4c5a22c..89b00511f 100644 --- a/params/config.go +++ b/params/config.go @@ -26,8 +26,8 @@ import ( // Genesis hashes to enforce below configs on. var ( - MainnetGenesisHash = common.HexToHash("0x4310c4984de8bf7ac1c509232d21511fae2cd73e8a1bb8365fe4e489042bc407") - TestnetGenesisHash = common.HexToHash("0x1fdd7ca7ccdd7c3a481f4162b8ca02a4db03859b4abaed96f7e259266d818a13") + MainnetGenesisHash = common.HexToHash("0xeffc8ddbc16ebd98411bb902290ba74a9cc699a4bd02652afecbf864ae542008") + TestnetGenesisHash = common.HexToHash("0xde641c0a52093329aaa5096ed19607243c98390285c5a4f4291c635b9f01301c") ) var ( @@ -45,21 +45,23 @@ var ( ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), Dexcon: &DexconConfig{ - GenesisCRSText: "In DEXON, we trust.", - Owner: common.HexToAddress("BF8C48A620bacc46907f9B89732D25E47A2D7Cf7"), - MinStake: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e5)), - LockupPeriod: 86400 * 3 * 1000, - BlockReward: big.NewInt(1e18), - BlockGasLimit: 40000000, - NumChains: 4, - LambdaBA: 250, - LambdaDKG: 2500, - K: 0, - PhiRatio: 0.667, - NotarySetSize: 4, - DKGSetSize: 4, - RoundInterval: 600000, - MinBlockInterval: 900, + GenesisCRSText: "In DEXON, we trust.", + Owner: common.HexToAddress("BF8C48A620bacc46907f9B89732D25E47A2D7Cf7"), + MinStake: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e5)), + LockupPeriod: 86400 * 3 * 1000, + MiningVelocity: 0.1875, + NextHalvingSupply: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(2.5e9)), + LastHalvedAmount: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1.5e9)), + BlockGasLimit: 40000000, + NumChains: 6, + LambdaBA: 250, + LambdaDKG: 2500, + K: 0, + PhiRatio: 0.667, + NotarySetSize: 4, + DKGSetSize: 4, + RoundInterval: 600000, + MinBlockInterval: 1000, FineValues: []*big.Int{ new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e4)), new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e4)), @@ -90,21 +92,23 @@ var ( ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), Dexcon: &DexconConfig{ - GenesisCRSText: "In DEXON, we trust.", - Owner: common.HexToAddress("BF8C48A620bacc46907f9B89732D25E47A2D7Cf7"), - MinStake: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e5)), - LockupPeriod: 86400 * 3 * 1000, - BlockReward: big.NewInt(1e18), - BlockGasLimit: 40000000, - NumChains: 6, - LambdaBA: 250, - LambdaDKG: 2500, - K: 0, - PhiRatio: 0.667, - NotarySetSize: 4, - DKGSetSize: 4, - RoundInterval: 600000, - MinBlockInterval: 900, + GenesisCRSText: "In DEXON, we trust.", + Owner: common.HexToAddress("BF8C48A620bacc46907f9B89732D25E47A2D7Cf7"), + MinStake: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e5)), + LockupPeriod: 86400 * 3 * 1000, + MiningVelocity: 0.1875, + NextHalvingSupply: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(6e6)), + LastHalvedAmount: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(2e6)), + BlockGasLimit: 40000000, + NumChains: 6, + LambdaBA: 250, + LambdaDKG: 2500, + K: 0, + PhiRatio: 0.667, + NotarySetSize: 4, + DKGSetSize: 4, + RoundInterval: 600000, + MinBlockInterval: 1000, FineValues: []*big.Int{ new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e4)), new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e4)), @@ -126,21 +130,23 @@ var ( ConstantinopleBlock: big.NewInt(0), PetersburgBlock: big.NewInt(0), Dexcon: &DexconConfig{ - GenesisCRSText: "In DEXON, we trust.", - Owner: common.HexToAddress("BF8C48A620bacc46907f9B89732D25E47A2D7Cf7"), - MinStake: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e5)), - LockupPeriod: 86400 * 3 * 1000, - BlockReward: big.NewInt(1e18), - BlockGasLimit: 40000000, - NumChains: 6, - LambdaBA: 400, - LambdaDKG: 10000, - K: 0, - PhiRatio: 0.667, - NotarySetSize: 21, - DKGSetSize: 13, - RoundInterval: 3600000, - MinBlockInterval: 900, + GenesisCRSText: "In DEXON, we trust.", + Owner: common.HexToAddress("BF8C48A620bacc46907f9B89732D25E47A2D7Cf7"), + MinStake: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e5)), + LockupPeriod: 86400 * 3 * 1000, + MiningVelocity: 0.1875, + NextHalvingSupply: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(6e6)), + LastHalvedAmount: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(2e6)), + BlockGasLimit: 40000000, + NumChains: 6, + LambdaBA: 400, + LambdaDKG: 10000, + K: 0, + PhiRatio: 0.667, + NotarySetSize: 21, + DKGSetSize: 13, + RoundInterval: 3600000, + MinBlockInterval: 1000, FineValues: []*big.Int{ new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e4)), new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e4)), @@ -274,38 +280,43 @@ func (c *CliqueConfig) String() string { // DexconConfig is the consensus engine configs for DEXON consensus. type DexconConfig struct { - GenesisCRSText string `json:"genesisCRSText"` - Owner common.Address `json:"owner"` - MinStake *big.Int `json:"minStake"` - LockupPeriod uint64 `json:"lockupPeriod"` - BlockReward *big.Int `json:"blockReward"` - BlockGasLimit uint64 `json:"blockGasLimit"` - NumChains uint32 `json:"numChains"` - LambdaBA uint64 `json:"lambdaBA"` - LambdaDKG uint64 `json:"lambdaDKG"` - K uint32 `json:"k"` - PhiRatio float32 `json:"phiRatio"` - NotarySetSize uint32 `json:"notarySetSize"` - DKGSetSize uint32 `json:"dkgSetSize"` - RoundInterval uint64 `json:"roundInterval"` - MinBlockInterval uint64 `json:"minBlockInterval"` - FineValues []*big.Int `json:"fineValues"` + GenesisCRSText string `json:"genesisCRSText"` + Owner common.Address `json:"owner"` + MinStake *big.Int `json:"minStake"` + LockupPeriod uint64 `json:"lockupPeriod"` + MiningVelocity float32 `json:"miningVelocity"` + NextHalvingSupply *big.Int `json:"nextHalvingSupply"` + LastHalvedAmount *big.Int `json:"lastHalvedAmount"` + BlockGasLimit uint64 `json:"blockGasLimit"` + NumChains uint32 `json:"numChains"` + LambdaBA uint64 `json:"lambdaBA"` + LambdaDKG uint64 `json:"lambdaDKG"` + K uint32 `json:"k"` + PhiRatio float32 `json:"phiRatio"` + NotarySetSize uint32 `json:"notarySetSize"` + DKGSetSize uint32 `json:"dkgSetSize"` + RoundInterval uint64 `json:"roundInterval"` + MinBlockInterval uint64 `json:"minBlockInterval"` + FineValues []*big.Int `json:"fineValues"` } type dexconConfigSpecMarshaling struct { - MinStake *math.HexOrDecimal256 - BlockReward *math.HexOrDecimal256 - FineValues []*math.HexOrDecimal256 + MinStake *math.HexOrDecimal256 + NextHalvingSupply *math.HexOrDecimal256 + LastHalvedAmount *math.HexOrDecimal256 + FineValues []*math.HexOrDecimal256 } // String implements the stringer interface, returning the consensus engine details. func (d *DexconConfig) String() string { - return fmt.Sprintf("{GenesisCRSText: %v Owner: %v MinStake: %v LockupPeriod: %v BlockReward: %v BlockGasLimit: %v NumChains: %v LambdaBA: %v LambdaDKG: %v K: %v PhiRatio: %v NotarySetSize: %v DKGSetSize: %v RoundInterval: %v MinBlockInterval: %v FineValues: %v}", + return fmt.Sprintf("{GenesisCRSText: %v Owner: %v MinStake: %v LockupPeriod: %v MiningVelocity: %v NextHalvingSupply: %v LastHalvedAmount: %v BlockGasLimit: %v NumChains: %v LambdaBA: %v LambdaDKG: %v K: %v PhiRatio: %v NotarySetSize: %v DKGSetSize: %v RoundInterval: %v MinBlockInterval: %v FineValues: %v}", d.GenesisCRSText, d.Owner, d.MinStake, d.LockupPeriod, - d.BlockReward, + d.MiningVelocity, + d.NextHalvingSupply, + d.LastHalvedAmount, d.BlockGasLimit, d.NumChains, d.LambdaBA, diff --git a/params/gen_dexcon_config.go b/params/gen_dexcon_config.go index 4ec55c0c9..29ebf2eaf 100644 --- a/params/gen_dexcon_config.go +++ b/params/gen_dexcon_config.go @@ -15,29 +15,33 @@ var _ = (*dexconConfigSpecMarshaling)(nil) // MarshalJSON marshals as JSON. func (d DexconConfig) MarshalJSON() ([]byte, error) { type DexconConfig struct { - GenesisCRSText string `json:"genesisCRSText"` - Owner common.Address `json:"owner"` - MinStake *math.HexOrDecimal256 `json:"minStake"` - LockupPeriod uint64 `json:"lockupPeriod"` - BlockReward *math.HexOrDecimal256 `json:"blockReward"` - BlockGasLimit uint64 `json:"blockGasLimit"` - NumChains uint32 `json:"numChains"` - LambdaBA uint64 `json:"lambdaBA"` - LambdaDKG uint64 `json:"lambdaDKG"` - K uint32 `json:"k"` - PhiRatio float32 `json:"phiRatio"` - NotarySetSize uint32 `json:"notarySetSize"` - DKGSetSize uint32 `json:"dkgSetSize"` - RoundInterval uint64 `json:"roundInterval"` - MinBlockInterval uint64 `json:"minBlockInterval"` - FineValues []*math.HexOrDecimal256 `json:"fineValues"` + GenesisCRSText string `json:"genesisCRSText"` + Owner common.Address `json:"owner"` + MinStake *math.HexOrDecimal256 `json:"minStake"` + LockupPeriod uint64 `json:"lockupPeriod"` + MiningVelocity float32 `json:"miningVelocity"` + NextHalvingSupply *math.HexOrDecimal256 `json:"nextHalvingSupply"` + LastHalvedAmount *math.HexOrDecimal256 `json:"lastHalvedAmount"` + BlockGasLimit uint64 `json:"blockGasLimit"` + NumChains uint32 `json:"numChains"` + LambdaBA uint64 `json:"lambdaBA"` + LambdaDKG uint64 `json:"lambdaDKG"` + K uint32 `json:"k"` + PhiRatio float32 `json:"phiRatio"` + NotarySetSize uint32 `json:"notarySetSize"` + DKGSetSize uint32 `json:"dkgSetSize"` + RoundInterval uint64 `json:"roundInterval"` + MinBlockInterval uint64 `json:"minBlockInterval"` + FineValues []*math.HexOrDecimal256 `json:"fineValues"` } var enc DexconConfig enc.GenesisCRSText = d.GenesisCRSText enc.Owner = d.Owner enc.MinStake = (*math.HexOrDecimal256)(d.MinStake) enc.LockupPeriod = d.LockupPeriod - enc.BlockReward = (*math.HexOrDecimal256)(d.BlockReward) + enc.MiningVelocity = d.MiningVelocity + enc.NextHalvingSupply = (*math.HexOrDecimal256)(d.NextHalvingSupply) + enc.LastHalvedAmount = (*math.HexOrDecimal256)(d.LastHalvedAmount) enc.BlockGasLimit = d.BlockGasLimit enc.NumChains = d.NumChains enc.LambdaBA = d.LambdaBA @@ -60,22 +64,24 @@ func (d DexconConfig) MarshalJSON() ([]byte, error) { // UnmarshalJSON unmarshals from JSON. func (d *DexconConfig) UnmarshalJSON(input []byte) error { type DexconConfig struct { - GenesisCRSText *string `json:"genesisCRSText"` - Owner *common.Address `json:"owner"` - MinStake *math.HexOrDecimal256 `json:"minStake"` - LockupPeriod *uint64 `json:"lockupPeriod"` - BlockReward *math.HexOrDecimal256 `json:"blockReward"` - BlockGasLimit *uint64 `json:"blockGasLimit"` - NumChains *uint32 `json:"numChains"` - LambdaBA *uint64 `json:"lambdaBA"` - LambdaDKG *uint64 `json:"lambdaDKG"` - K *uint32 `json:"k"` - PhiRatio *float32 `json:"phiRatio"` - NotarySetSize *uint32 `json:"notarySetSize"` - DKGSetSize *uint32 `json:"dkgSetSize"` - RoundInterval *uint64 `json:"roundInterval"` - MinBlockInterval *uint64 `json:"minBlockInterval"` - FineValues []*math.HexOrDecimal256 `json:"fineValues"` + GenesisCRSText *string `json:"genesisCRSText"` + Owner *common.Address `json:"owner"` + MinStake *math.HexOrDecimal256 `json:"minStake"` + LockupPeriod *uint64 `json:"lockupPeriod"` + MiningVelocity *float32 `json:"miningVelocity"` + NextHalvingSupply *math.HexOrDecimal256 `json:"nextHalvingSupply"` + LastHalvedAmount *math.HexOrDecimal256 `json:"lastHalvedAmount"` + BlockGasLimit *uint64 `json:"blockGasLimit"` + NumChains *uint32 `json:"numChains"` + LambdaBA *uint64 `json:"lambdaBA"` + LambdaDKG *uint64 `json:"lambdaDKG"` + K *uint32 `json:"k"` + PhiRatio *float32 `json:"phiRatio"` + NotarySetSize *uint32 `json:"notarySetSize"` + DKGSetSize *uint32 `json:"dkgSetSize"` + RoundInterval *uint64 `json:"roundInterval"` + MinBlockInterval *uint64 `json:"minBlockInterval"` + FineValues []*math.HexOrDecimal256 `json:"fineValues"` } var dec DexconConfig if err := json.Unmarshal(input, &dec); err != nil { @@ -93,8 +99,14 @@ func (d *DexconConfig) UnmarshalJSON(input []byte) error { if dec.LockupPeriod != nil { d.LockupPeriod = *dec.LockupPeriod } - if dec.BlockReward != nil { - d.BlockReward = (*big.Int)(dec.BlockReward) + if dec.MiningVelocity != nil { + d.MiningVelocity = *dec.MiningVelocity + } + if dec.NextHalvingSupply != nil { + d.NextHalvingSupply = (*big.Int)(dec.NextHalvingSupply) + } + if dec.LastHalvedAmount != nil { + d.LastHalvedAmount = (*big.Int)(dec.LastHalvedAmount) } if dec.BlockGasLimit != nil { d.BlockGasLimit = *dec.BlockGasLimit |