aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJimmy Hu <jimmy.hu@dexon.org>2018-10-08 13:46:48 +0800
committerWei-Ning Huang <w@dexon.org>2018-12-19 18:55:22 +0800
commit0054f7a1bf23c93033de47bd2183a08d2ad1fa46 (patch)
treedefdd2494e4e0051c13c51c487236fa6c12de353
parent23f38c0c3df14e387a6f464b758cb7f48292502b (diff)
downloaddexon-0054f7a1bf23c93033de47bd2183a08d2ad1fa46.tar
dexon-0054f7a1bf23c93033de47bd2183a08d2ad1fa46.tar.gz
dexon-0054f7a1bf23c93033de47bd2183a08d2ad1fa46.tar.bz2
dexon-0054f7a1bf23c93033de47bd2183a08d2ad1fa46.tar.lz
dexon-0054f7a1bf23c93033de47bd2183a08d2ad1fa46.tar.xz
dexon-0054f7a1bf23c93033de47bd2183a08d2ad1fa46.tar.zst
dexon-0054f7a1bf23c93033de47bd2183a08d2ad1fa46.zip
core: vm: check if caller already staked when adding dkg mpk
-rw-r--r--core/vm/governance.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index c75102f79..652d86357 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -904,6 +904,13 @@ func (g *GovernanceContract) proposeCRS(round *big.Int, signedCRS []byte) ([]byt
}
func (g *GovernanceContract) addDKGMasterPublicKey(round *big.Int, pk []byte) ([]byte, error) {
+ caller := g.contract.Caller()
+ offset := g.state.offset(caller)
+ // Can not add dkg mpk if not staked.
+ if offset.Cmp(big.NewInt(0)) < 0 {
+ return nil, errExecutionReverted
+ }
+
var dkgMasterPK types.DKGMasterPublicKey
if err := rlp.DecodeBytes(pk, &dkgMasterPK); err != nil {
g.penalize()