diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-22 15:13:25 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | e5957ec5894b4e13c555460d7b5e10dc5aad0295 (patch) | |
tree | da2c0281872fd39bce29901c39598f9708aa8a61 /dex | |
parent | fc452a397e853a80d4de7edf8e08b96c1ee99314 (diff) | |
download | dexon-e5957ec5894b4e13c555460d7b5e10dc5aad0295.tar dexon-e5957ec5894b4e13c555460d7b5e10dc5aad0295.tar.gz dexon-e5957ec5894b4e13c555460d7b5e10dc5aad0295.tar.bz2 dexon-e5957ec5894b4e13c555460d7b5e10dc5aad0295.tar.lz dexon-e5957ec5894b4e13c555460d7b5e10dc5aad0295.tar.xz dexon-e5957ec5894b4e13c555460d7b5e10dc5aad0295.tar.zst dexon-e5957ec5894b4e13c555460d7b5e10dc5aad0295.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) } } |