diff options
-rw-r--r-- | core/vm/governance.go | 6 | ||||
-rw-r--r-- | dex/governance.go | 23 | ||||
-rw-r--r-- | dex/handler.go | 2 |
3 files changed, 20 insertions, 11 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go index b5d703fd7..5e6cc0b4d 100644 --- a/core/vm/governance.go +++ b/core/vm/governance.go @@ -877,7 +877,7 @@ const ( crsLoc dkgMasterPublicKeysLoc dkgComplaintsLoc - dkgFinailizedLoc + dkgFinalizedLoc dkgFinalizedsCountLoc ownerLoc blockRewardLoc @@ -1174,12 +1174,12 @@ func (s *GovernanceStateHelper) PushDKGComplaint(round *big.Int, complaint []byt // mapping(address => bool)[] public dkgFinalized; func (s *GovernanceStateHelper) DKGFinalized(round *big.Int, addr common.Address) bool { - baseLoc := new(big.Int).Add(s.getSlotLoc(big.NewInt(dkgFinailizedLoc)), round) + baseLoc := new(big.Int).Add(s.getSlotLoc(big.NewInt(dkgFinalizedLoc)), round) mapLoc := s.getMapLoc(baseLoc, addr.Bytes()) return s.getStateBigInt(mapLoc).Cmp(big.NewInt(0)) != 0 } func (s *GovernanceStateHelper) PutDKGFinalized(round *big.Int, addr common.Address, finalized bool) { - baseLoc := new(big.Int).Add(s.getSlotLoc(big.NewInt(dkgFinailizedLoc)), round) + baseLoc := new(big.Int).Add(s.getSlotLoc(big.NewInt(dkgFinalizedLoc)), round) mapLoc := s.getMapLoc(baseLoc, addr.Bytes()) res := big.NewInt(0) if finalized { 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) } } |