diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-22 19:53:24 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@byzantine-lab.io> | 2019-06-12 17:27:16 +0800 |
commit | e8326992de2ed9b961570b7379b0c091f1f9e051 (patch) | |
tree | 419073b0b59f3b39f7dfc67d0d4d50877378ef57 | |
parent | 2a38e14fa33bebd002451561f3fc618cc8e4fb61 (diff) | |
download | go-tangerine-e8326992de2ed9b961570b7379b0c091f1f9e051.tar.gz go-tangerine-e8326992de2ed9b961570b7379b0c091f1f9e051.tar.zst go-tangerine-e8326992de2ed9b961570b7379b0c091f1f9e051.zip |
dex: fix round switching and initialize dMoment correctly
-rw-r--r-- | core/vm/governance.go | 3 | ||||
-rw-r--r-- | dex/backend.go | 9 | ||||
-rw-r--r-- | test/genesis.json | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go index 5e6cc0b4d..d30987b11 100644 --- a/core/vm/governance.go +++ b/core/vm/governance.go @@ -1413,7 +1413,8 @@ func (g *GovernanceContract) addDKGComplaint(round *big.Int, comp []byte) ([]byt } func (g *GovernanceContract) addDKGMasterPublicKey(round *big.Int, mpk []byte) ([]byte, error) { - if round.Cmp(g.state.Round()) != 0 { + // Can only add DKG master public key of current and next round. + if round.Cmp(new(big.Int).Add(g.state.Round(), big.NewInt(1))) > 0 { g.penalize() return nil, errExecutionReverted } diff --git a/dex/backend.go b/dex/backend.go index 9c931ee2c..2ad7c16be 100644 --- a/dex/backend.go +++ b/dex/backend.go @@ -174,7 +174,14 @@ func New(ctx *node.ServiceContext, config *Config) (*Dexon, error) { dex.network = NewDexconNetwork(pm) privKey := coreEcdsa.NewPrivateKeyFromECDSA(config.PrivateKey) - dMoment := time.Date(2018, 10, 15, 6, 0, 0, 0, time.UTC) + + // TODO(w): set this correctly in config. + now := time.Now() + dMoment := time.Date( + now.Year(), now.Month(), now.Day(), + now.Hour(), now.Minute(), (now.Second()/5+1)*5, + 0, now.Location()) + dex.consensus = dexCore.NewConsensus(dMoment, dex.app, dex.governance, db, dex.network, privKey, log.Root()) return dex, nil diff --git a/test/genesis.json b/test/genesis.json index b5bca5ac7..131977cd3 100644 --- a/test/genesis.json +++ b/test/genesis.json @@ -12,12 +12,12 @@ "blockReward": "1000000000000000000", "numChains": 4, "lambdaBA": 250, - "lambdaDKG": 2500, + "lambdaDKG": 4000, "k": 0, "phiRatio": 667000, "notarySetSize": 4, "dkgSetSize": 4, - "roundInterval": 99999999999, + "roundInterval": 180000, "minBlockInterval": 900, "maxBlockInterval": 1100 } |