aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/vm/governance.go24
-rw-r--r--dex/governance.go6
-rw-r--r--test/genesis.json2
3 files changed, 22 insertions, 10 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.
diff --git a/dex/governance.go b/dex/governance.go
index 11b97080d..c7ea440dd 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -144,7 +144,7 @@ func (d *DexconGovernance) sendGovTx(ctx context.Context, data []byte) error {
// CRS returns the CRS for a given round.
func (d *DexconGovernance) CRS(round uint64) coreCommon.Hash {
- s := d.getGovStateAtRound(round)
+ s := d.getGovState()
return coreCommon.Hash(s.CRS(big.NewInt(int64(round))))
}
@@ -154,10 +154,10 @@ func (d *DexconGovernance) LenCRS() uint64 {
}
// ProposeCRS send proposals of a new CRS
-func (d *DexconGovernance) ProposeCRS(signedCRS []byte) {
+func (d *DexconGovernance) ProposeCRS(round uint64, signedCRS []byte) {
method := vm.GovernanceContractName2Method["proposeCRS"]
- res, err := method.Inputs.Pack(signedCRS)
+ res, err := method.Inputs.Pack(big.NewInt(int64(round)), signedCRS)
if err != nil {
log.Error("failed to pack proposeCRS input", "err", err)
return
diff --git a/test/genesis.json b/test/genesis.json
index 131977cd3..ed5e9b7ce 100644
--- a/test/genesis.json
+++ b/test/genesis.json
@@ -17,7 +17,7 @@
"phiRatio": 667000,
"notarySetSize": 4,
"dkgSetSize": 4,
- "roundInterval": 180000,
+ "roundInterval": 300000,
"minBlockInterval": 900,
"maxBlockInterval": 1100
}