aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-11-19 22:08:53 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 13:49:57 +0800
commit5f1d585e01283997f84e242f752795b235e0f1c5 (patch)
tree3edbb22b7bd36dede4d28904521f64641f41b255
parentac723d97631fa5abc66c30ad4d8143b24715af2b (diff)
downloaddexon-5f1d585e01283997f84e242f752795b235e0f1c5.tar
dexon-5f1d585e01283997f84e242f752795b235e0f1c5.tar.gz
dexon-5f1d585e01283997f84e242f752795b235e0f1c5.tar.bz2
dexon-5f1d585e01283997f84e242f752795b235e0f1c5.tar.lz
dexon-5f1d585e01283997f84e242f752795b235e0f1c5.tar.xz
dexon-5f1d585e01283997f84e242f752795b235e0f1c5.tar.zst
dexon-5f1d585e01283997f84e242f752795b235e0f1c5.zip
core: vm: change offset type to int256
Since we use -1 to represent the offset of empty value, we should make the return type int256 instead of uint256.
-rw-r--r--core/vm/governance.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/core/vm/governance.go b/core/vm/governance.go
index 36b37b53c..f4c2f4d93 100644
--- a/core/vm/governance.go
+++ b/core/vm/governance.go
@@ -56,7 +56,7 @@ const GovernanceABIJSON = `
"outputs": [
{
"name": "",
- "type": "uint256"
+ "type": "int256"
}
],
"payable": false,
@@ -313,7 +313,7 @@ const GovernanceABIJSON = `
"outputs": [
{
"name": "",
- "type": "uint256"
+ "type": "int256"
}
],
"payable": false,
@@ -2044,6 +2044,11 @@ func (g *GovernanceContract) delegate(nodeAddr common.Address) ([]byte, error) {
caller := g.contract.Caller()
value := g.contract.Value()
+ // Can not delegate if no fund was sent.
+ if value.Cmp(big.NewInt(0)) == 0 {
+ return nil, errExecutionReverted
+ }
+
// Can not delegate if already delegated.
delegatorOffset := g.state.DelegatorsOffset(nodeAddr, caller)
if delegatorOffset.Cmp(big.NewInt(0)) >= 0 {