diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-22 15:13:25 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2018-12-19 20:54:27 +0800 |
commit | 9320531a4a2add2ac3132257d04761aff078ff17 (patch) | |
tree | 630a1bad52730c978ffd464e82f02ce45552590e /dex | |
parent | ee081f7614985e02053dc8d0bba6513806ec1b19 (diff) | |
download | dexon-9320531a4a2add2ac3132257d04761aff078ff17.tar dexon-9320531a4a2add2ac3132257d04761aff078ff17.tar.gz dexon-9320531a4a2add2ac3132257d04761aff078ff17.tar.bz2 dexon-9320531a4a2add2ac3132257d04761aff078ff17.tar.lz dexon-9320531a4a2add2ac3132257d04761aff078ff17.tar.xz dexon-9320531a4a2add2ac3132257d04761aff078ff17.tar.zst dexon-9320531a4a2add2ac3132257d04761aff078ff17.zip |
dex: misc fixes
Diffstat (limited to 'dex')
-rw-r--r-- | dex/governance.go | 23 | ||||
-rw-r--r-- | dex/handler.go | 2 |
2 files changed, 17 insertions, 8 deletions
diff --git a/dex/governance.go b/dex/governance.go index 7e6f2b2f6..11b97080d 100644 --- a/dex/governance.go +++ b/dex/governance.go @@ -86,6 +86,12 @@ func (d *DexconGovernance) DexconConfiguration(round uint64) *params.DexconConfi // Configuration returns the system configuration for consensus core to use. func (d *DexconGovernance) Configuration(round uint64) *coreTypes.Config { + // Configuration in round r is activiated on round r + 2. + if round < 2 { + round = 0 + } else { + round -= 2 + } s := d.getGovStateAtRound(round) c := s.Configuration() @@ -114,15 +120,13 @@ func (d *DexconGovernance) sendGovTx(ctx context.Context, data []byte) error { return err } - if nonce > 0 { - nonce += 1 - } + log.Info("sendGovTx", "nonce", nonce) tx := types.NewTransaction( nonce, vm.GovernanceContractAddress, big.NewInt(0), - uint64(200000), + uint64(2000000), gasPrice, data) @@ -132,6 +136,9 @@ func (d *DexconGovernance) sendGovTx(ctx context.Context, data []byte) error { if err != nil { return err } + + log.Info("Send governance transaction", "fullhash", tx.Hash().Hex()) + return d.b.SendTx(ctx, tx) } @@ -202,7 +209,7 @@ func (d *DexconGovernance) AddDKGComplaint(round uint64, complaint *coreTypes.DK encoded, err := rlp.EncodeToBytes(complaint) if err != nil { - log.Error("failed to JSON encode complaint to bytes", "err", err) + log.Error("failed to RLP encode complaint to bytes", "err", err) return } @@ -239,7 +246,7 @@ func (d *DexconGovernance) AddDKGMasterPublicKey(round uint64, masterPublicKey * encoded, err := rlp.EncodeToBytes(masterPublicKey) if err != nil { - log.Error("failed to JSON encode mpk to bytes", "err", err) + log.Error("failed to RLP encode mpk to bytes", "err", err) return } @@ -276,7 +283,7 @@ func (d *DexconGovernance) AddDKGFinalize(round uint64, final *coreTypes.DKGFina encoded, err := rlp.EncodeToBytes(final) if err != nil { - log.Error("failed to JSON encode finalize to bytes", "err", err) + log.Error("failed to RLP encode finalize to bytes", "err", err) return } @@ -295,7 +302,7 @@ func (d *DexconGovernance) AddDKGFinalize(round uint64, final *coreTypes.DKGFina // IsDKGFinal checks if DKG is final. func (d *DexconGovernance) IsDKGFinal(round uint64) bool { - s := d.getGovStateAtRound(round) + s := d.getGovState() threshold := 2*s.DKGSetSize().Uint64()/3 + 1 count := s.DKGFinalizedsCount(big.NewInt(int64(round))).Uint64() return count >= threshold diff --git a/dex/handler.go b/dex/handler.go index ce6a0366c..87f8b6b1d 100644 --- a/dex/handler.go +++ b/dex/handler.go @@ -886,6 +886,8 @@ func (pm *ProtocolManager) SendDKGPrivateShare( id := string(pub.Bytes()[1:]) if p := pm.peers.Peer(id); p != nil { p.AsyncSendDKGPrivateShare(privateShare) + } else { + log.Error("Failed to send DKG private share", "publicKey", id) } } |