aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-12-12 10:08:01 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:54 +0800
commit88803153c916098d65c04125a05f4848ab75c2c4 (patch)
tree0176d51d7efa09fa4061f911ccfb8a25cd37f2ad /core/vm
parent877339db1c966b1ec00dc94327a8aa8d00383234 (diff)
downloaddexon-88803153c916098d65c04125a05f4848ab75c2c4.tar
dexon-88803153c916098d65c04125a05f4848ab75c2c4.tar.gz
dexon-88803153c916098d65c04125a05f4848ab75c2c4.tar.bz2
dexon-88803153c916098d65c04125a05f4848ab75c2c4.tar.lz
dexon-88803153c916098d65c04125a05f4848ab75c2c4.tar.xz
dexon-88803153c916098d65c04125a05f4848ab75c2c4.tar.zst
dexon-88803153c916098d65c04125a05f4848ab75c2c4.zip
core: governance interface should return correct DKG master public keys (#85)
Diffstat (limited to 'core/vm')
-rw-r--r--core/vm/governance.go35
1 files changed, 20 insertions, 15 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index f4c2f4d93..8c6f70a04 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -1608,6 +1608,25 @@ func (s *GovernanceStateHelper) DKGMasterPublicKeys(round *big.Int) [][]byte {
func (s *GovernanceStateHelper) PushDKGMasterPublicKey(round *big.Int, mpk []byte) {
s.appendTo2DByteArray(big.NewInt(dkgMasterPublicKeysLoc), round, mpk)
}
+func (s *GovernanceStateHelper) UniqueDKGMasterPublicKeys(round *big.Int) []*dkgTypes.MasterPublicKey {
+ // Prepare DKGMasterPublicKeys.
+ var dkgMasterPKs []*dkgTypes.MasterPublicKey
+ existence := make(map[coreTypes.NodeID]struct{})
+ for _, mpk := range s.DKGMasterPublicKeys(round) {
+ x := new(dkgTypes.MasterPublicKey)
+ if err := rlp.DecodeBytes(mpk, x); err != nil {
+ panic(err)
+ }
+
+ // Only the first DKG MPK submission is valid.
+ if _, exists := existence[x.ProposerID]; exists {
+ continue
+ }
+ existence[x.ProposerID] = struct{}{}
+ dkgMasterPKs = append(dkgMasterPKs, x)
+ }
+ return dkgMasterPKs
+}
// bytes[][] public dkgComplaints;
func (s *GovernanceStateHelper) DKGComplaints(round *big.Int) [][]byte {
@@ -2214,21 +2233,7 @@ func (g *GovernanceContract) proposeCRS(nextRound *big.Int, signedCRS []byte) ([
prevCRS := g.state.CRS(round)
// Prepare DKGMasterPublicKeys.
- var dkgMasterPKs []*dkgTypes.MasterPublicKey
- existence := make(map[coreTypes.NodeID]struct{})
- for _, mpk := range g.state.DKGMasterPublicKeys(round) {
- x := new(dkgTypes.MasterPublicKey)
- if err := rlp.DecodeBytes(mpk, x); err != nil {
- panic(err)
- }
-
- // Only the first DKG MPK submission is valid.
- if _, exists := existence[x.ProposerID]; exists {
- continue
- }
- existence[x.ProposerID] = struct{}{}
- dkgMasterPKs = append(dkgMasterPKs, x)
- }
+ dkgMasterPKs := g.state.UniqueDKGMasterPublicKeys(round)
// Prepare DKGComplaints.
var dkgComplaints []*dkgTypes.Complaint