From b2b6382ec557ab0895a1bbfe053a265fb470ec81 Mon Sep 17 00:00:00 2001 From: Wei-Ning Huang Date: Mon, 19 Nov 2018 22:08:53 +0800 Subject: 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. --- core/vm/governance.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'core') 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 { -- cgit v1.2.3