diff options
author | Wei-Ning Huang <w@dexon.org> | 2019-04-22 15:25:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-22 15:25:54 +0800 |
commit | be497f28e8c911ec13ea18b2ebb1663888998419 (patch) | |
tree | a736e516ed33f7358096c443101f563acf3b8dd9 | |
parent | f52c4e75bb1cc585912f23ce640967e57a1c72ba (diff) | |
download | dexon-be497f28e8c911ec13ea18b2ebb1663888998419.tar.gz dexon-be497f28e8c911ec13ea18b2ebb1663888998419.tar.zst dexon-be497f28e8c911ec13ea18b2ebb1663888998419.zip |
core: vm: add sanity check for updateConfiguration (#383)
-rw-r--r-- | core/vm/oracle_contracts.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/vm/oracle_contracts.go b/core/vm/oracle_contracts.go index 2dc1ce54f..35a9e5861 100644 --- a/core/vm/oracle_contracts.go +++ b/core/vm/oracle_contracts.go @@ -1708,6 +1708,18 @@ func (g *GovernanceContract) updateConfiguration(cfg *rawConfigStruct) ([]byte, return nil, errExecutionReverted } + // Sanity checks. + if cfg.MinStake.Cmp(big.NewInt(0)) <= 0 || + cfg.LockupPeriod.Cmp(big.NewInt(0)) <= 0 || + cfg.BlockGasLimit.Cmp(big.NewInt(0)) <= 0 || + cfg.MinGasPrice.Cmp(big.NewInt(0)) <= 0 || + cfg.LambdaBA.Cmp(big.NewInt(0)) <= 0 || + cfg.LambdaDKG.Cmp(big.NewInt(0)) <= 0 || + cfg.RoundLength.Cmp(big.NewInt(0)) <= 0 || + cfg.MinBlockInterval.Cmp(big.NewInt(0)) <= 0 { + return nil, errExecutionReverted + } + g.state.UpdateConfigurationRaw(cfg) g.state.emitConfigurationChangedEvent() |