aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@cobinhood.com>2018-10-18 21:56:12 +0800
committerWei-Ning Huang <w@dexon.org>2018-12-19 20:54:27 +0800
commit22367acba140b2545442016e534c6a2f17bdffc3 (patch)
tree476a4157f9cfd767a21d93d7eaf15e4f5bac3925
parentab787f1ea7365b2befe6cd1bc9135637c32ec453 (diff)
downloaddexon-22367acba140b2545442016e534c6a2f17bdffc3.tar
dexon-22367acba140b2545442016e534c6a2f17bdffc3.tar.gz
dexon-22367acba140b2545442016e534c6a2f17bdffc3.tar.bz2
dexon-22367acba140b2545442016e534c6a2f17bdffc3.tar.lz
dexon-22367acba140b2545442016e534c6a2f17bdffc3.tar.xz
dexon-22367acba140b2545442016e534c6a2f17bdffc3.tar.zst
dexon-22367acba140b2545442016e534c6a2f17bdffc3.zip
core: set governance owner in genesis
-rw-r--r--core/genesis.go4
-rw-r--r--params/config.go28
-rw-r--r--params/gen_dexcon_config.go7
-rw-r--r--test/genesis.json3
4 files changed, 27 insertions, 15 deletions
diff --git a/core/genesis.go b/core/genesis.go
index c8bd05bf1..34f0ad4e7 100644
--- a/core/genesis.go
+++ b/core/genesis.go
@@ -255,7 +255,6 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
govStateHelper := vm.GovernanceStateHelper{statedb}
for addr, account := range g.Alloc {
- fmt.Println(account)
statedb.AddBalance(addr, new(big.Int).Sub(account.Balance, account.Staked))
statedb.SetCode(addr, account.Code)
statedb.SetNonce(addr, account.Nonce)
@@ -277,6 +276,9 @@ func (g *Genesis) ToBlock(db ethdb.Database) *types.Block {
govStateHelper.Stake(addr, account.PublicKey, account.Staked)
}
}
+ // Owner.
+ govStateHelper.SetOwner(g.Config.Dexcon.Owner)
+
// Governance configuration.
govStateHelper.UpdateConfiguration(g.Config.Dexcon)
diff --git a/params/config.go b/params/config.go
index 24be741d9..c0f6f25d9 100644
--- a/params/config.go
+++ b/params/config.go
@@ -191,18 +191,19 @@ func (c *CliqueConfig) String() string {
// DexconConfig is the consensus engine configs for DEXON consensus.
type DexconConfig struct {
- GenesisCRSText string `json:"genesisCRSText"`
- NumChains uint32 `json:"numChains"`
- LambdaBA uint64 `json:"lambdaBA"`
- LambdaDKG uint64 `json:"lambdaDKG"`
- K int `json:"k"`
- PhiRatio float32 `json:"phiRatio"`
- NotarySetSize uint32 `json:"notarySetSize"`
- DKGSetSize uint32 `json:"dkgSetSize"`
- RoundInterval uint64 `json:"roundInterval"`
- MinBlockInterval uint64 `json:"minBlockInterval"`
- MaxBlockInterval uint64 `json:"maxBlockInterval"`
- BlockReward *big.Int `json:"blockReward"`
+ Owner common.Address `json:"owner"`
+ GenesisCRSText string `json:"genesisCRSText"`
+ NumChains uint32 `json:"numChains"`
+ LambdaBA uint64 `json:"lambdaBA"`
+ LambdaDKG uint64 `json:"lambdaDKG"`
+ K int `json:"k"`
+ PhiRatio float32 `json:"phiRatio"`
+ NotarySetSize uint32 `json:"notarySetSize"`
+ DKGSetSize uint32 `json:"dkgSetSize"`
+ RoundInterval uint64 `json:"roundInterval"`
+ MinBlockInterval uint64 `json:"minBlockInterval"`
+ MaxBlockInterval uint64 `json:"maxBlockInterval"`
+ BlockReward *big.Int `json:"blockReward"`
}
type dexconConfigSpecMarshaling struct {
@@ -211,7 +212,8 @@ type dexconConfigSpecMarshaling struct {
// String implements the stringer interface, returning the consensus engine details.
func (d *DexconConfig) String() string {
- return fmt.Sprintf("{GenesisCRSText: %v NumChains: %v LambdaBA: %v LambdaDKG: %v K: %v PhiRatio: %v NotarySetSize: %v DKGSetSize: %v RoundInterval: %v MinBlockInterval: %v MaxBlockInterval: %v BlockReward: %v",
+ return fmt.Sprintf("{Owner: %v GenesisCRSText: %v NumChains: %v LambdaBA: %v LambdaDKG: %v K: %v PhiRatio: %v NotarySetSize: %v DKGSetSize: %v RoundInterval: %v MinBlockInterval: %v MaxBlockInterval: %v BlockReward: %v",
+ d.Owner,
d.GenesisCRSText,
d.NumChains,
d.LambdaBA,
diff --git a/params/gen_dexcon_config.go b/params/gen_dexcon_config.go
index bd169584f..e53560e47 100644
--- a/params/gen_dexcon_config.go
+++ b/params/gen_dexcon_config.go
@@ -6,6 +6,7 @@ import (
"encoding/json"
"math/big"
+ "github.com/dexon-foundation/dexon/common"
"github.com/dexon-foundation/dexon/common/math"
)
@@ -14,6 +15,7 @@ var _ = (*dexconConfigSpecMarshaling)(nil)
// MarshalJSON marshals as JSON.
func (d DexconConfig) MarshalJSON() ([]byte, error) {
type DexconConfig struct {
+ Owner common.Address `json:"owner"`
GenesisCRSText string `json:"genesisCRSText"`
NumChains uint32 `json:"numChains"`
LambdaBA uint64 `json:"lambdaBA"`
@@ -28,6 +30,7 @@ func (d DexconConfig) MarshalJSON() ([]byte, error) {
BlockReward *math.HexOrDecimal256 `json:"blockReward"`
}
var enc DexconConfig
+ enc.Owner = d.Owner
enc.GenesisCRSText = d.GenesisCRSText
enc.NumChains = d.NumChains
enc.LambdaBA = d.LambdaBA
@@ -46,6 +49,7 @@ func (d DexconConfig) MarshalJSON() ([]byte, error) {
// UnmarshalJSON unmarshals from JSON.
func (d *DexconConfig) UnmarshalJSON(input []byte) error {
type DexconConfig struct {
+ Owner *common.Address `json:"owner"`
GenesisCRSText *string `json:"genesisCRSText"`
NumChains *uint32 `json:"numChains"`
LambdaBA *uint64 `json:"lambdaBA"`
@@ -63,6 +67,9 @@ func (d *DexconConfig) UnmarshalJSON(input []byte) error {
if err := json.Unmarshal(input, &dec); err != nil {
return err
}
+ if dec.Owner != nil {
+ d.Owner = *dec.Owner
+ }
if dec.GenesisCRSText != nil {
d.GenesisCRSText = *dec.GenesisCRSText
}
diff --git a/test/genesis.json b/test/genesis.json
index f5bf4036b..ba5965988 100644
--- a/test/genesis.json
+++ b/test/genesis.json
@@ -7,9 +7,10 @@
"eip155Block": 0,
"eip158Block": 0,
"dexcon": {
+ "owner": "0x7C3c31B19395A5e2627F921Cc2802560B71f1caB",
"genesisCRSText": "In DEXON, we trust.",
"numChains": 1,
- "lambdaBA": 250,
+ "lambdaBA": 50,
"lambdaDKG": 2500,
"k": 0,
"phiRatio": 667000,