aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-11-19 22:08:53 +0800
committerWei-Ning Huang <w@byzantine-lab.io>2019-06-12 17:27:18 +0800
commitf80773bea1a400c23ed2b626827a4e50b4921c2e (patch)
treee510a609465b21c679eedd080c04bb5dc71fca0d /core
parent78dac82d810fe4a1ad6878adbc789f909155f472 (diff)
downloadgo-tangerine-f80773bea1a400c23ed2b626827a4e50b4921c2e.tar.gz
go-tangerine-f80773bea1a400c23ed2b626827a4e50b4921c2e.tar.zst
go-tangerine-f80773bea1a400c23ed2b626827a4e50b4921c2e.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.
Diffstat (limited to 'core')
-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 {