diff options
author | Jhih-Ming Huang <jm@byzantine-lab.io> | 2019-08-16 16:28:50 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-09-17 16:57:31 +0800 |
commit | 0594f51ee194bc975a75d293a789d98f47f3f4d9 (patch) | |
tree | 552839016bb000cb8000efd91356304ee993b7a5 /params | |
parent | 3430fc0db2e1b0fdba84b97924d0151e446805c9 (diff) | |
download | go-tangerine-0594f51ee194bc975a75d293a789d98f47f3f4d9.tar go-tangerine-0594f51ee194bc975a75d293a789d98f47f3f4d9.tar.gz go-tangerine-0594f51ee194bc975a75d293a789d98f47f3f4d9.tar.bz2 go-tangerine-0594f51ee194bc975a75d293a789d98f47f3f4d9.tar.lz go-tangerine-0594f51ee194bc975a75d293a789d98f47f3f4d9.tar.xz go-tangerine-0594f51ee194bc975a75d293a789d98f47f3f4d9.tar.zst go-tangerine-0594f51ee194bc975a75d293a789d98f47f3f4d9.zip |
core: add p2p whitelist for consortium
Diffstat (limited to 'params')
-rw-r--r-- | params/config.go | 70 | ||||
-rw-r--r-- | params/gen_dexcon_config.go | 12 |
2 files changed, 65 insertions, 17 deletions
diff --git a/params/config.go b/params/config.go index c884b8cdc..b00fc6ee9 100644 --- a/params/config.go +++ b/params/config.go @@ -267,22 +267,24 @@ 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"` - MiningVelocity float32 `json:"miningVelocity"` - NextHalvingSupply *big.Int `json:"nextHalvingSupply"` - LastHalvedAmount *big.Int `json:"lastHalvedAmount"` - MinGasPrice *big.Int `json:"minGasPrice"` - BlockGasLimit uint64 `json:"blockGasLimit"` - LambdaBA uint64 `json:"lambdaBA"` - LambdaDKG uint64 `json:"lambdaDKG"` - NotaryParamAlpha float32 `json:"notaryParamAlpha"` - NotaryParamBeta float32 `json:"notaryParamBeta"` - RoundLength uint64 `json:"roundLength"` - 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"` + MinGasPrice *big.Int `json:"minGasPrice"` + BlockGasLimit uint64 `json:"blockGasLimit"` + LambdaBA uint64 `json:"lambdaBA"` + LambdaDKG uint64 `json:"lambdaDKG"` + NotaryParamAlpha float32 `json:"notaryParamAlpha"` + NotaryParamBeta float32 `json:"notaryParamBeta"` + RoundLength uint64 `json:"roundLength"` + MinBlockInterval uint64 `json:"minBlockInterval"` + FineValues []*big.Int `json:"fineValues"` + IsConsortium bool `json:"isConsortium"` + AddressWhitelist []common.Address `json:"addressWhitelist"` } type dexconConfigSpecMarshaling struct { @@ -295,7 +297,7 @@ type dexconConfigSpecMarshaling struct { // 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 MiningVelocity: %v NextHalvingSupply: %v LastHalvedAmount: %v MinGasPrice: %v BlockGasLimit: %v LambdaBA: %v LambdaDKG: %v NotaryParamAlpha: %v NotaryParamBeta: %v RoundLength: %v MinBlockInterval: %v FineValues: %v}", + return fmt.Sprintf("{GenesisCRSText: %v Owner: %v MinStake: %v LockupPeriod: %v MiningVelocity: %v NextHalvingSupply: %v LastHalvedAmount: %v MinGasPrice: %v BlockGasLimit: %v LambdaBA: %v LambdaDKG: %v NotaryParamAlpha: %v NotaryParamBeta: %v RoundLength: %v MinBlockInterval: %v FineValues: %v IsConsortium: %v AddressWhitelist: %v}", d.GenesisCRSText, d.Owner, d.MinStake, @@ -312,6 +314,8 @@ func (d *DexconConfig) String() string { d.RoundLength, d.MinBlockInterval, d.FineValues, + d.IsConsortium, + d.AddressWhitelist, ) } @@ -552,3 +556,35 @@ func (c *ChainConfig) Rules(num *big.Int) Rules { IsPetersburg: c.IsPetersburg(num), } } + +// NewTestChainConfig is the ChainConfig constructor for test +func NewTestChainConig() *ChainConfig { + return &ChainConfig{big.NewInt(1), 0, big.NewInt(0), nil, false, big.NewInt(0), common.Hash{}, big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), big.NewInt(0), nil, new(EthashConfig), nil, nil, nil} +} + +func NewTestDexonConfig() *DexconConfig { + return &DexconConfig{ + GenesisCRSText: "Tangerine Testnet", + Owner: common.HexToAddress("0x0D54AF942d6bF13870F5CA65D470954f21D3cBE5"), + MinStake: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e6)), + LockupPeriod: 3600, + MiningVelocity: 0.18, + NextHalvingSupply: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(125e6)), + LastHalvedAmount: new(big.Int).Mul(big.NewInt(1e18), big.NewInt(75e6)), + MinGasPrice: new(big.Int).Mul(big.NewInt(1e9), big.NewInt(1)), + BlockGasLimit: 210000000, + LambdaBA: 250, + LambdaDKG: 20000, + NotaryParamAlpha: 70.5, + NotaryParamBeta: 264, + RoundLength: 3600, + MinBlockInterval: 1000, + FineValues: []*big.Int{ + new(big.Int).Mul(big.NewInt(1e18), big.NewInt(100)), + new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1)), + new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e6)), + new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e6)), + new(big.Int).Mul(big.NewInt(1e18), big.NewInt(1e6)), + }, + } +} diff --git a/params/gen_dexcon_config.go b/params/gen_dexcon_config.go index 28e2775ff..2a8d84546 100644 --- a/params/gen_dexcon_config.go +++ b/params/gen_dexcon_config.go @@ -31,6 +31,8 @@ func (d DexconConfig) MarshalJSON() ([]byte, error) { RoundLength uint64 `json:"roundLength"` MinBlockInterval uint64 `json:"minBlockInterval"` FineValues []*math.HexOrDecimal256 `json:"fineValues"` + IsConsortium bool `json:"isConsortium"` + AddressWhitelist []common.Address `json:"addressWhitelist"` } var enc DexconConfig enc.GenesisCRSText = d.GenesisCRSText @@ -54,6 +56,8 @@ func (d DexconConfig) MarshalJSON() ([]byte, error) { enc.FineValues[k] = (*math.HexOrDecimal256)(v) } } + enc.IsConsortium = d.IsConsortium + enc.AddressWhitelist = d.AddressWhitelist return json.Marshal(&enc) } @@ -76,6 +80,8 @@ func (d *DexconConfig) UnmarshalJSON(input []byte) error { RoundLength *uint64 `json:"roundLength"` MinBlockInterval *uint64 `json:"minBlockInterval"` FineValues []*math.HexOrDecimal256 `json:"fineValues"` + IsConsortium *bool `json:"isConsortium"` + AddressWhitelist []common.Address `json:"addressWhitelist"` } var dec DexconConfig if err := json.Unmarshal(input, &dec); err != nil { @@ -132,5 +138,11 @@ func (d *DexconConfig) UnmarshalJSON(input []byte) error { d.FineValues[k] = (*big.Int)(v) } } + if dec.IsConsortium != nil { + d.IsConsortium = *dec.IsConsortium + } + if dec.AddressWhitelist != nil { + d.AddressWhitelist = dec.AddressWhitelist + } return nil } |