diff options
author | Wei-Ning Huang <w@dexon.org> | 2018-11-05 13:49:08 +0800 |
---|---|---|
committer | Wei-Ning Huang <w@dexon.org> | 2019-03-12 12:19:09 +0800 |
commit | 1a75ec877713fb50021410a5d0474563299b16a0 (patch) | |
tree | 9d6fc5e152769faad486a0b5f4f894c68165ee1e /dex | |
parent | fd48d4b21645ee8fd8cfafe63f7bd2630bb77611 (diff) | |
download | dexon-1a75ec877713fb50021410a5d0474563299b16a0.tar.gz dexon-1a75ec877713fb50021410a5d0474563299b16a0.tar.zst dexon-1a75ec877713fb50021410a5d0474563299b16a0.zip |
core: validate roundHeight mapping in governance contract
Diffstat (limited to 'dex')
-rw-r--r-- | dex/governance.go | 7 |
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 { |