diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-10-25 11:17:52 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-04-09 21:32:52 +0800 |
commit | 2d1ed5288cab621aba39c3a81aae7042ead14fd5 (patch) | |
tree | 3312352700814c6e97305b84a58672ee1f059e66 /dex | |
parent | f5fa30b21ea123d66cf5fdaf527f546ef5a2f46b (diff) | |
download | dexon-2d1ed5288cab621aba39c3a81aae7042ead14fd5.tar dexon-2d1ed5288cab621aba39c3a81aae7042ead14fd5.tar.gz dexon-2d1ed5288cab621aba39c3a81aae7042ead14fd5.tar.bz2 dexon-2d1ed5288cab621aba39c3a81aae7042ead14fd5.tar.lz dexon-2d1ed5288cab621aba39c3a81aae7042ead14fd5.tar.xz dexon-2d1ed5288cab621aba39c3a81aae7042ead14fd5.tar.zst dexon-2d1ed5288cab621aba39c3a81aae7042ead14fd5.zip |
vendor: sync consensus core and fix conflict
Diffstat (limited to 'dex')
-rw-r--r-- | dex/app.go | 5 | ||||
-rw-r--r-- | dex/governance.go | 19 | ||||
-rw-r--r-- | dex/handler.go | 9 | ||||
-rw-r--r-- | dex/network.go | 7 | ||||
-rw-r--r-- | dex/peer.go | 17 |
5 files changed, 30 insertions, 27 deletions
diff --git a/dex/app.go b/dex/app.go index d5b7d3556..b1558b46f 100644 --- a/dex/app.go +++ b/dex/app.go @@ -261,9 +261,8 @@ func (d *DexconApp) PrepareWitness(consensusHeight uint64) (witness coreTypes.Wi } return coreTypes.Witness{ - Timestamp: time.Unix(witnessBlock.Time().Int64(), 0), - Height: witnessBlock.NumberU64(), - Data: witnessData, + Height: witnessBlock.NumberU64(), + Data: witnessData, }, nil } diff --git a/dex/governance.go b/dex/governance.go index c7ea440dd..69c1e217f 100644 --- a/dex/governance.go +++ b/dex/governance.go @@ -12,6 +12,7 @@ import ( coreCrypto "github.com/dexon-foundation/dexon-consensus-core/core/crypto" coreEcdsa "github.com/dexon-foundation/dexon-consensus-core/core/crypto/ecdsa" coreTypes "github.com/dexon-foundation/dexon-consensus-core/core/types" + dkgTypes "github.com/dexon-foundation/dexon-consensus-core/core/types/dkg" "github.com/dexon-foundation/dexon/common" "github.com/dexon-foundation/dexon/core/types" @@ -204,7 +205,7 @@ func (d *DexconGovernance) NotifyRoundHeight(targetRound, consensusHeight uint64 } // AddDKGComplaint adds a DKGComplaint. -func (d *DexconGovernance) AddDKGComplaint(round uint64, complaint *coreTypes.DKGComplaint) { +func (d *DexconGovernance) AddDKGComplaint(round uint64, complaint *dkgTypes.Complaint) { method := vm.GovernanceContractName2Method["addDKGComplaint"] encoded, err := rlp.EncodeToBytes(complaint) @@ -227,11 +228,11 @@ func (d *DexconGovernance) AddDKGComplaint(round uint64, complaint *coreTypes.DK } // DKGComplaints gets all the DKGComplaints of round. -func (d *DexconGovernance) DKGComplaints(round uint64) []*coreTypes.DKGComplaint { +func (d *DexconGovernance) DKGComplaints(round uint64) []*dkgTypes.Complaint { s := d.getGovState() - var dkgComplaints []*coreTypes.DKGComplaint + var dkgComplaints []*dkgTypes.Complaint for _, pk := range s.DKGComplaints(big.NewInt(int64(round))) { - x := new(coreTypes.DKGComplaint) + x := new(dkgTypes.Complaint) if err := rlp.DecodeBytes(pk, x); err != nil { panic(err) } @@ -241,7 +242,7 @@ func (d *DexconGovernance) DKGComplaints(round uint64) []*coreTypes.DKGComplaint } // AddDKGMasterPublicKey adds a DKGMasterPublicKey. -func (d *DexconGovernance) AddDKGMasterPublicKey(round uint64, masterPublicKey *coreTypes.DKGMasterPublicKey) { +func (d *DexconGovernance) AddDKGMasterPublicKey(round uint64, masterPublicKey *dkgTypes.MasterPublicKey) { method := vm.GovernanceContractName2Method["addDKGMasterPublicKey"] encoded, err := rlp.EncodeToBytes(masterPublicKey) @@ -264,11 +265,11 @@ func (d *DexconGovernance) AddDKGMasterPublicKey(round uint64, masterPublicKey * } // DKGMasterPublicKeys gets all the DKGMasterPublicKey of round. -func (d *DexconGovernance) DKGMasterPublicKeys(round uint64) []*coreTypes.DKGMasterPublicKey { +func (d *DexconGovernance) DKGMasterPublicKeys(round uint64) []*dkgTypes.MasterPublicKey { s := d.getGovState() - var dkgMasterPKs []*coreTypes.DKGMasterPublicKey + var dkgMasterPKs []*dkgTypes.MasterPublicKey for _, pk := range s.DKGMasterPublicKeys(big.NewInt(int64(round))) { - x := new(coreTypes.DKGMasterPublicKey) + x := new(dkgTypes.MasterPublicKey) if err := rlp.DecodeBytes(pk, x); err != nil { panic(err) } @@ -278,7 +279,7 @@ func (d *DexconGovernance) DKGMasterPublicKeys(round uint64) []*coreTypes.DKGMas } // AddDKGFinalize adds a DKG finalize message. -func (d *DexconGovernance) AddDKGFinalize(round uint64, final *coreTypes.DKGFinalize) { +func (d *DexconGovernance) AddDKGFinalize(round uint64, final *dkgTypes.Finalize) { method := vm.GovernanceContractName2Method["addDKGFinalize"] encoded, err := rlp.EncodeToBytes(final) diff --git a/dex/handler.go b/dex/handler.go index 2b7e1cee1..be50cb43d 100644 --- a/dex/handler.go +++ b/dex/handler.go @@ -28,6 +28,7 @@ import ( coreCrypto "github.com/dexon-foundation/dexon-consensus-core/core/crypto" coreTypes "github.com/dexon-foundation/dexon-consensus-core/core/types" + dkgTypes "github.com/dexon-foundation/dexon-consensus-core/core/types/dkg" "github.com/dexon-foundation/dexon/common" "github.com/dexon-foundation/dexon/consensus" @@ -736,14 +737,14 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { pm.receiveCh <- &randomness case msg.Code == DKGPrivateShareMsg: // Do not relay this msg - var ps coreTypes.DKGPrivateShare + var ps dkgTypes.PrivateShare if err := msg.Decode(&ps); err != nil { return errResp(ErrDecode, "msg %v: %v", msg, err) } pm.receiveCh <- &ps case msg.Code == DKGPartialSignatureMsg: // broadcast in DKG set - var psig coreTypes.DKGPartialSignature + var psig dkgTypes.PartialSignature if err := msg.Decode(&psig); err != nil { return errResp(ErrDecode, "msg %v: %v", msg, err) } @@ -896,7 +897,7 @@ func (pm *ProtocolManager) SendDKGPrivateShare( } func (pm *ProtocolManager) BroadcastDKGPrivateShare( - privateShare *coreTypes.DKGPrivateShare) { + privateShare *dkgTypes.PrivateShare) { label := peerLabel{set: dkgset, round: privateShare.Round} for _, peer := range pm.peers.PeersWithLabel(label) { if !peer.knownDKGPrivateShares.Contains(rlpHash(privateShare)) { @@ -906,7 +907,7 @@ func (pm *ProtocolManager) BroadcastDKGPrivateShare( } func (pm *ProtocolManager) BroadcastDKGPartialSignature( - psig *coreTypes.DKGPartialSignature) { + psig *dkgTypes.PartialSignature) { label := peerLabel{set: dkgset, round: psig.Round} for _, peer := range pm.peers.PeersWithLabel(label) { if !peer.knownDKGPartialSignatures.Contains(rlpHash(psig)) { diff --git a/dex/network.go b/dex/network.go index e99b4f5b1..0d45973ec 100644 --- a/dex/network.go +++ b/dex/network.go @@ -3,6 +3,7 @@ package dex import ( "github.com/dexon-foundation/dexon-consensus-core/core/crypto" "github.com/dexon-foundation/dexon-consensus-core/core/types" + dkgTypes "github.com/dexon-foundation/dexon-consensus-core/core/types/dkg" ) type DexconNetwork struct { @@ -25,20 +26,20 @@ func (n *DexconNetwork) BroadcastBlock(block *types.Block) { // SendDKGPrivateShare sends PrivateShare to a DKG participant. func (n *DexconNetwork) SendDKGPrivateShare( - pub crypto.PublicKey, prvShare *types.DKGPrivateShare) { + pub crypto.PublicKey, prvShare *dkgTypes.PrivateShare) { n.pm.SendDKGPrivateShare(pub, prvShare) } // BroadcastDKGPrivateShare broadcasts PrivateShare to all DKG participants. func (n *DexconNetwork) BroadcastDKGPrivateShare( - prvShare *types.DKGPrivateShare) { + prvShare *dkgTypes.PrivateShare) { n.pm.BroadcastDKGPrivateShare(prvShare) } // BroadcastDKGPartialSignature broadcasts partialSignature to all // DKG participants. func (n *DexconNetwork) BroadcastDKGPartialSignature( - psig *types.DKGPartialSignature) { + psig *dkgTypes.PartialSignature) { n.pm.BroadcastDKGPartialSignature(psig) } diff --git a/dex/peer.go b/dex/peer.go index a5e0dd21a..195be920e 100644 --- a/dex/peer.go +++ b/dex/peer.go @@ -25,6 +25,7 @@ import ( mapset "github.com/deckarep/golang-set" coreTypes "github.com/dexon-foundation/dexon-consensus-core/core/types" + dkgTypes "github.com/dexon-foundation/dexon-consensus-core/core/types/dkg" "github.com/dexon-foundation/dexon/common" "github.com/dexon-foundation/dexon/core/types" @@ -138,8 +139,8 @@ type peer struct { queuedVotes chan *coreTypes.Vote queuedAgreements chan *coreTypes.AgreementResult queuedRandomnesses chan *coreTypes.BlockRandomnessResult - queuedDKGPrivateShares chan *coreTypes.DKGPrivateShare - queuedDKGPartialSignatures chan *coreTypes.DKGPartialSignature + queuedDKGPrivateShares chan *dkgTypes.PrivateShare + queuedDKGPartialSignatures chan *dkgTypes.PartialSignature term chan struct{} // Termination channel to stop the broadcaster } @@ -166,8 +167,8 @@ func newPeer(version int, p *p2p.Peer, rw p2p.MsgReadWriter) *peer { queuedVotes: make(chan *coreTypes.Vote, maxQueuedVotes), queuedAgreements: make(chan *coreTypes.AgreementResult, maxQueuedAgreements), queuedRandomnesses: make(chan *coreTypes.BlockRandomnessResult, maxQueuedRandomnesses), - queuedDKGPrivateShares: make(chan *coreTypes.DKGPrivateShare, maxQueuedDKGPrivateShare), - queuedDKGPartialSignatures: make(chan *coreTypes.DKGPartialSignature, maxQueuedDKGParitialSignature), + queuedDKGPrivateShares: make(chan *dkgTypes.PrivateShare, maxQueuedDKGPrivateShare), + queuedDKGPartialSignatures: make(chan *dkgTypes.PartialSignature, maxQueuedDKGParitialSignature), term: make(chan struct{}), } } @@ -443,12 +444,12 @@ func (p *peer) AsyncSendRandomness(randomness *coreTypes.BlockRandomnessResult) } } -func (p *peer) SendDKGPrivateShare(privateShare *coreTypes.DKGPrivateShare) error { +func (p *peer) SendDKGPrivateShare(privateShare *dkgTypes.PrivateShare) error { p.knownDKGPrivateShares.Add(rlpHash(privateShare)) return p2p.Send(p.rw, DKGPrivateShareMsg, privateShare) } -func (p *peer) AsyncSendDKGPrivateShare(privateShare *coreTypes.DKGPrivateShare) { +func (p *peer) AsyncSendDKGPrivateShare(privateShare *dkgTypes.PrivateShare) { select { case p.queuedDKGPrivateShares <- privateShare: p.knownDKGPrivateShares.Add(rlpHash(privateShare)) @@ -457,12 +458,12 @@ func (p *peer) AsyncSendDKGPrivateShare(privateShare *coreTypes.DKGPrivateShare) } } -func (p *peer) SendDKGPartialSignature(psig *coreTypes.DKGPartialSignature) error { +func (p *peer) SendDKGPartialSignature(psig *dkgTypes.PartialSignature) error { p.knownDKGPartialSignatures.Add(rlpHash(psig)) return p2p.Send(p.rw, DKGPartialSignatureMsg, psig) } -func (p *peer) AsyncSendDKGPartialSignature(psig *coreTypes.DKGPartialSignature) { +func (p *peer) AsyncSendDKGPartialSignature(psig *dkgTypes.PartialSignature) { select { case p.queuedDKGPartialSignatures <- psig: p.knownDKGPartialSignatures.Add(rlpHash(psig)) |