Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add upper limit for some params #481

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
14 changes: 9 additions & 5 deletions contracts/BC_fusion/StakeHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -783,27 +783,31 @@ 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
Loading