aboutsummaryrefslogtreecommitdiffstats
path: root/dex
diff options
context:
space:
mode:
authorWei-Ning Huang <w@dexon.org>2018-11-05 13:49:08 +0800
committerWei-Ning Huang <w@dexon.org>2019-04-09 21:32:52 +0800
commitc66af2d7f54b14e856c3d3b6a98a961daf617216 (patch)
tree9f9ceb4abf1ead399de23abe9efe7f8ebbfe510b /dex
parenta2daec1ea649de60557c382bb3756ddf2466b2b2 (diff)
downloaddexon-c66af2d7f54b14e856c3d3b6a98a961daf617216.tar
dexon-c66af2d7f54b14e856c3d3b6a98a961daf617216.tar.gz
dexon-c66af2d7f54b14e856c3d3b6a98a961daf617216.tar.bz2
dexon-c66af2d7f54b14e856c3d3b6a98a961daf617216.tar.lz
dexon-c66af2d7f54b14e856c3d3b6a98a961daf617216.tar.xz
dexon-c66af2d7f54b14e856c3d3b6a98a961daf617216.tar.zst
dexon-c66af2d7f54b14e856c3d3b6a98a961daf617216.zip
core: validate roundHeight mapping in governance contract
Diffstat (limited to 'dex')
-rw-r--r--dex/governance.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/dex/governance.go b/dex/governance.go
index 766920a62..d9a1fa467 100644
--- a/dex/governance.go
+++ b/dex/governance.go
@@ -24,6 +24,8 @@ import (
"github.com/dexon-foundation/dexon/rpc"
)
+const configActivationOffset = 2
+
type DexconGovernance struct {
b *DexAPIBackend
chainConfig *params.ChainConfig
@@ -66,6 +68,11 @@ func (d *DexconGovernance) getGovState() *vm.GovernanceStateHelper {
}
func (d *DexconGovernance) getGovStateAtRound(round uint64) *vm.GovernanceStateHelper {
+ if round < configActivationOffset {
+ round = 0
+ } else {
+ round -= configActivationOffset
+ }
ctx := context.Background()
blockHeight, err := d.getRoundHeight(ctx, round)
if err != nil {