Skip to content

Commit

Permalink
fix: add upper limit for some params
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 committed Jan 30, 2024
1 parent adf418a commit a72cba1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions contracts/BC_fusion/BSCGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -185,27 +185,27 @@ contract BSCGovernor is
if (key.compareStrings("votingDelay")) {
if (value.length != 32) revert InvalidValue(key, value);
uint256 newVotingDelay = value.bytesToUint256(32);
if (newVotingDelay == 0) revert InvalidValue(key, value);
if (newVotingDelay == 0 || newVotingDelay > 24 hours) revert InvalidValue(key, value);
_setVotingDelay(newVotingDelay);
} else if (key.compareStrings("votingPeriod")) {
if (value.length != 32) revert InvalidValue(key, value);
uint256 newVotingPeriod = value.bytesToUint256(32);
if (newVotingPeriod == 0) revert InvalidValue(key, value);
if (newVotingPeriod == 0 || newVotingPeriod > 30 days) revert InvalidValue(key, value);
_setVotingPeriod(newVotingPeriod);
} else if (key.compareStrings("proposalThreshold")) {
if (value.length != 32) revert InvalidValue(key, value);
uint256 newProposalThreshold = value.bytesToUint256(32);
if (newProposalThreshold == 0) revert InvalidValue(key, value);
if (newProposalThreshold == 0 || newProposalThreshold > 10_000 ether) revert InvalidValue(key, value);
_setProposalThreshold(newProposalThreshold);
} else if (key.compareStrings("quorumNumerator")) {
if (value.length != 32) revert InvalidValue(key, value);
uint256 newQuorumNumerator = value.bytesToUint256(32);
if (newQuorumNumerator == 0) revert InvalidValue(key, value);
if (newQuorumNumerator < 5 || newQuorumNumerator > 20) revert InvalidValue(key, value);
_updateQuorumNumerator(newQuorumNumerator);
} else if (key.compareStrings("minPeriodAfterQuorum")) {
if (value.length != 8) revert InvalidValue(key, value);
uint64 newMinPeriodAfterQuorum = value.bytesToUint64(8);
if (newMinPeriodAfterQuorum == 0) revert InvalidValue(key, value);
if (newMinPeriodAfterQuorum == 0 || newMinPeriodAfterQuorum > 2 days) revert InvalidValue(key, value);
_setLateQuorumVoteExtension(newMinPeriodAfterQuorum);
} else {
revert UnknownParam(key, value);
Expand Down
10 changes: 5 additions & 5 deletions contracts/BC_fusion/StakeHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -783,27 +783,27 @@ contract StakeHub is System, Initializable {
if (key.compareStrings("transferGasLimit")) {
if (value.length != 32) revert InvalidValue(key, value);
uint256 newTransferGasLimit = value.bytesToUint256(32);
if (newTransferGasLimit < 2300) revert InvalidValue(key, value);
if (newTransferGasLimit < 2300 || newTransferGasLimit > 10_000) revert InvalidValue(key, value);
transferGasLimit = newTransferGasLimit;
} else if (key.compareStrings("minSelfDelegationBNB")) {
if (value.length != 32) revert InvalidValue(key, value);
uint256 newMinSelfDelegationBNB = value.bytesToUint256(32);
if (newMinSelfDelegationBNB < 1000 ether) revert InvalidValue(key, value);
if (newMinSelfDelegationBNB < 1000 ether || newMinSelfDelegationBNB > 100_000 ether) revert InvalidValue(key, value);
minSelfDelegationBNB = newMinSelfDelegationBNB;
} else if (key.compareStrings("minDelegationBNBChange")) {
if (value.length != 32) revert InvalidValue(key, value);
uint256 newMinDelegationBNBChange = value.bytesToUint256(32);
if (newMinDelegationBNBChange < 0.1 ether) revert InvalidValue(key, value);
if (newMinDelegationBNBChange < 0.1 ether || newMinDelegationBNBChange > 10 ether) revert InvalidValue(key, value);
minDelegationBNBChange = newMinDelegationBNBChange;
} else if (key.compareStrings("maxElectedValidators")) {
if (value.length != 32) revert InvalidValue(key, value);
uint256 newMaxElectedValidators = value.bytesToUint256(32);
if (newMaxElectedValidators < 1 || newMaxElectedValidators > 500) revert InvalidValue(key, value);
if (newMaxElectedValidators == 0 || newMaxElectedValidators > 500) revert InvalidValue(key, value);
maxElectedValidators = newMaxElectedValidators;
} else if (key.compareStrings("unbondPeriod")) {
if (value.length != 32) revert InvalidValue(key, value);
uint256 newUnbondPeriod = value.bytesToUint256(32);
if (newUnbondPeriod < 3 days) revert InvalidValue(key, value);
if (newUnbondPeriod < 3 days || newUnbondPeriod > 30 days) revert InvalidValue(key, value);
unbondPeriod = newUnbondPeriod;
} else if (key.compareStrings("redelegateFeeRate")) {
if (value.length != 32) revert InvalidValue(key, value);
Expand Down

0 comments on commit a72cba1

Please sign in to comment.