diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-22 15:13:25 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:50 +0800 |
commit | defdcafc514226b73050467ac42c787ef3f7cfea (patch) | |
tree | e73fee8888f1d1bb8056e8d161298504d17f07e3 /dex | |
parent | bbc777cf41dffea2fc63e0946e5ce3a7ddce1be7 (diff) | |
download | go-tangerine-defdcafc514226b73050467ac42c787ef3f7cfea.tar go-tangerine-defdcafc514226b73050467ac42c787ef3f7cfea.tar.gz go-tangerine-defdcafc514226b73050467ac42c787ef3f7cfea.tar.bz2 go-tangerine-defdcafc514226b73050467ac42c787ef3f7cfea.tar.lz go-tangerine-defdcafc514226b73050467ac42c787ef3f7cfea.tar.xz go-tangerine-defdcafc514226b73050467ac42c787ef3f7cfea.tar.zst go-tangerine-defdcafc514226b73050467ac42c787ef3f7cfea.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) } } |