aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-10-20 16:08:40 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:50 +0800
commita18db064261a0336d7cf5b375583ece163d42dbb (patch)
tree8ad9c926426289eed2d36e285a3f5e4af767da05 /core
parent3fdfa4474ca257ef6e289c0a5c3b1c3e490d7e02 (diff)
downloaddexon-a18db064261a0336d7cf5b375583ece163d42dbb.tar
dexon-a18db064261a0336d7cf5b375583ece163d42dbb.tar.gz
dexon-a18db064261a0336d7cf5b375583ece163d42dbb.tar.bz2
dexon-a18db064261a0336d7cf5b375583ece163d42dbb.tar.lz
dexon-a18db064261a0336d7cf5b375583ece163d42dbb.tar.xz
dexon-a18db064261a0336d7cf5b375583ece163d42dbb.tar.zst
dexon-a18db064261a0336d7cf5b375583ece163d42dbb.zip
dex: use RLP to encode contract payload data
Diffstat (limited to 'core')
-rw-r--r--core/vm/governance.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index b2bb531f2..b5d703fd7 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -18,7 +18,6 @@
package vm
import (
- "encoding/json"
"math/big"
"strings"
@@ -27,6 +26,7 @@ import (
"github.com/dexon-foundation/dexon/core/types"
"github.com/dexon-foundation/dexon/crypto"
"github.com/dexon-foundation/dexon/params"
+ "github.com/dexon-foundation/dexon/rlp"
coreCommon "github.com/dexon-foundation/dexon-consensus-core/common"
"github.com/dexon-foundation/dexon-consensus-core/core"
@@ -1388,7 +1388,7 @@ func (g *GovernanceContract) addDKGComplaint(round *big.Int, comp []byte) ([]byt
}
var dkgComplaint coreTypes.DKGComplaint
- if err := json.Unmarshal(comp, &dkgComplaint); err != nil {
+ if err := rlp.DecodeBytes(comp, &dkgComplaint); err != nil {
g.penalize()
return nil, errExecutionReverted
}
@@ -1427,7 +1427,7 @@ func (g *GovernanceContract) addDKGMasterPublicKey(round *big.Int, mpk []byte) (
}
var dkgMasterPK coreTypes.DKGMasterPublicKey
- if err := json.Unmarshal(mpk, &dkgMasterPK); err != nil {
+ if err := rlp.DecodeBytes(mpk, &dkgMasterPK); err != nil {
g.penalize()
return nil, errExecutionReverted
}
@@ -1460,7 +1460,7 @@ func (g *GovernanceContract) addDKGFinalize(round *big.Int, finalize []byte) ([]
caller := g.contract.Caller()
var dkgFinalize coreTypes.DKGFinalize
- if err := json.Unmarshal(finalize, &dkgFinalize); err != nil {
+ if err := rlp.DecodeBytes(finalize, &dkgFinalize); err != nil {
g.penalize()
return nil, errExecutionReverted
}
@@ -1556,7 +1556,7 @@ func (g *GovernanceContract) proposeCRS(signedCRS []byte) ([]byte, error) {
var dkgMasterPKs []*coreTypes.DKGMasterPublicKey
for _, mpk := range g.state.DKGMasterPublicKeys(round) {
x := new(coreTypes.DKGMasterPublicKey)
- if err := json.Unmarshal(mpk, x); err != nil {
+ if err := rlp.DecodeBytes(mpk, x); err != nil {
panic(err)
}
dkgMasterPKs = append(dkgMasterPKs, x)
@@ -1566,7 +1566,7 @@ func (g *GovernanceContract) proposeCRS(signedCRS []byte) ([]byte, error) {
var dkgComplaints []*coreTypes.DKGComplaint
for _, comp := range g.state.DKGComplaints(round) {
x := new(coreTypes.DKGComplaint)
- if err := json.Unmarshal(comp, x); err != nil {
+ if err := rlp.DecodeBytes(comp, x); err != nil {
panic(err)
}
dkgComplaints = append(dkgComplaints, x)