aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-23 14:12:10 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:16 +0800
commit18b940c6840e1030be76945207fb5bdf6323d696 (patch)
tree1c006cd2f436fabbcbf0ec173acd86eead8510f3 /core/vm
parent4038a460b537083b2395fc1d443ebffe6a739d23 (diff)
downloadgo-tangerine-18b940c6840e1030be76945207fb5bdf6323d696.tar
go-tangerine-18b940c6840e1030be76945207fb5bdf6323d696.tar.gz
go-tangerine-18b940c6840e1030be76945207fb5bdf6323d696.tar.bz2
go-tangerine-18b940c6840e1030be76945207fb5bdf6323d696.tar.lz
go-tangerine-18b940c6840e1030be76945207fb5bdf6323d696.tar.xz
go-tangerine-18b940c6840e1030be76945207fb5bdf6323d696.tar.zst
go-tangerine-18b940c6840e1030be76945207fb5bdf6323d696.zip
dex: fix DKG round switching
Diffstat (limited to 'core/vm')
-rw-r--r--core/vm/governance.go24
1 files changed, 18 insertions, 6 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index d30987b11..5c5822261 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -475,11 +475,11 @@ const abiJSON = `
"constant": false,
"inputs": [
{
- "name": "round",
+ "name": "Round",
"type": "uint256"
},
{
- "name": "height",
+ "name": "Height",
"type": "uint256"
}
],
@@ -493,6 +493,10 @@ const abiJSON = `
"constant": false,
"inputs": [
{
+ "name": "Round",
+ "type": "uint256"
+ },
+ {
"name": "SignedCRS",
"type": "bytes"
}
@@ -658,11 +662,14 @@ func RunGovernanceContract(evm *EVM, input []byte, contract *Contract) (
}
return g.addDKGFinalize(args.Round, args.Finalize)
case "proposeCRS":
- var signedCRS []byte
- if err := method.Inputs.Unpack(&signedCRS, arguments); err != nil {
+ args := struct {
+ Round *big.Int
+ SignedCRS []byte
+ }{}
+ if err := method.Inputs.Unpack(&args, arguments); err != nil {
return nil, errExecutionReverted
}
- return g.proposeCRS(signedCRS)
+ return g.proposeCRS(args.Round, args.SignedCRS)
case "stake":
var publicKey []byte
if err := method.Inputs.Unpack(&publicKey, arguments); err != nil {
@@ -1548,8 +1555,13 @@ func (g *GovernanceContract) unstake() ([]byte, error) {
return nil, nil
}
-func (g *GovernanceContract) proposeCRS(signedCRS []byte) ([]byte, error) {
+func (g *GovernanceContract) proposeCRS(nextRound *big.Int, signedCRS []byte) ([]byte, error) {
round := g.state.Round()
+
+ if nextRound.Cmp(round) <= 0 {
+ return nil, errExecutionReverted
+ }
+
prevCRS := g.state.CRS(round)
// Prepare DKGMasterPublicKeys.