From ced93e4c6668ac2fc9614e42ec6cd3528ae015bf Mon Sep 17 00:00:00 2001 From: dean65 Date: Wed, 2 Mar 2022 14:42:25 +0800 Subject: [PATCH] fix update maxNumOfMaintaining --- contracts/BSCValidatorSet.sol | 6 +++++- contracts/BSCValidatorSet.template | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/contracts/BSCValidatorSet.sol b/contracts/BSCValidatorSet.sol index c84fc420..e08f0551 100644 --- a/contracts/BSCValidatorSet.sol +++ b/contracts/BSCValidatorSet.sol @@ -538,7 +538,11 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica } else if (Memory.compareStrings(key, "maxNumOfMaintaining")) { require(value.length == 32, "length of maxNumOfMaintaining mismatch"); uint256 newMaxNumOfMaintaining = BytesToTypes.bytesToUint256(32, value); - require(newMaxNumOfMaintaining < MAX_NUM_OF_VALIDATORS, "the maxNumOfMaintaining must be less than MAX_NUM_OF_VALIDATORS"); + uint256 _numOfCabinets = numOfCabinets; + if (_numOfCabinets == 0) { + _numOfCabinets = INIT_NUM_OF_CABINETS; + } + require(newMaxNumOfMaintaining < _numOfCabinets, "the maxNumOfMaintaining must be less than numOfCaninates"); maxNumOfMaintaining = newMaxNumOfMaintaining; } else if (Memory.compareStrings(key, "maintainSlashScale")) { require(value.length == 32, "length of maintainSlashScale mismatch"); diff --git a/contracts/BSCValidatorSet.template b/contracts/BSCValidatorSet.template index 4bf64317..6c6533fc 100644 --- a/contracts/BSCValidatorSet.template +++ b/contracts/BSCValidatorSet.template @@ -538,7 +538,11 @@ contract BSCValidatorSet is IBSCValidatorSet, System, IParamSubscriber, IApplica } else if (Memory.compareStrings(key, "maxNumOfMaintaining")) { require(value.length == 32, "length of maxNumOfMaintaining mismatch"); uint256 newMaxNumOfMaintaining = BytesToTypes.bytesToUint256(32, value); - require(newMaxNumOfMaintaining < MAX_NUM_OF_VALIDATORS, "the maxNumOfMaintaining must be less than MAX_NUM_OF_VALIDATORS"); + uint256 _numOfCabinets = numOfCabinets; + if (_numOfCabinets == 0) { + _numOfCabinets = INIT_NUM_OF_CABINETS; + } + require(newMaxNumOfMaintaining < _numOfCabinets, "the maxNumOfMaintaining must be less than numOfCaninates"); maxNumOfMaintaining = newMaxNumOfMaintaining; } else if (Memory.compareStrings(key, "maintainSlashScale")) { require(value.length == 32, "length of maintainSlashScale mismatch");