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: init params error in BSCGovernor #439

Merged
merged 4 commits into from
Dec 11, 2023
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
26 changes: 9 additions & 17 deletions contracts/BC_fusion/BSCGovernor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ contract BSCGovernor is
using Utils for string;

/*----------------- constants -----------------*/
uint256 private constant INIT_VOTING_DELAY = 24 hours;
uint256 private constant INIT_VOTING_PERIOD = 14 days;
/*
@dev caution:
INIT_VOTING_DELAY, INIT_VOTING_PERIOD and INIT_MIN_PERIOD_AFTER_QUORUM are default in number of blocks, not seconds
*/
uint256 private constant BLOCK_INTERVAL = 3 seconds;
uint256 private constant INIT_VOTING_DELAY = 24 hours / BLOCK_INTERVAL;
uint256 private constant INIT_VOTING_PERIOD = 14 days / BLOCK_INTERVAL;
uint256 private constant INIT_PROPOSAL_THRESHOLD = 100 ether; // = 100 BNB
uint256 private constant INIT_QUORUM_NUMERATOR = 10; // for >= 10%

// starting propose requires totalSupply of GovBNB >= 10000000 * 1e18
uint256 private constant PROPOSE_START_GOVBNB_SUPPLY_THRESHOLD = 10_000_000 ether;
// ensures there is a minimum voting period (1 days) after quorum is reached
uint64 private constant INIT_MIN_PERIOD_AFTER_QUORUM = uint64(1 days);
uint64 private constant INIT_MIN_PERIOD_AFTER_QUORUM = uint64(1 days / BLOCK_INTERVAL);

/*----------------- errors -----------------*/
error NotWhitelisted();
Expand Down Expand Up @@ -76,21 +81,8 @@ contract BSCGovernor is
__GovernorVotesQuorumFraction_init(INIT_QUORUM_NUMERATOR);
__GovernorPreventLateQuorum_init(INIT_MIN_PERIOD_AFTER_QUORUM);

whitelistTargets[VALIDATOR_CONTRACT_ADDR] = true;
whitelistTargets[SLASH_CONTRACT_ADDR] = true;
whitelistTargets[SYSTEM_REWARD_ADDR] = true;
whitelistTargets[LIGHT_CLIENT_ADDR] = true;
whitelistTargets[TOKEN_HUB_ADDR] = true;
whitelistTargets[INCENTIVIZE_ADDR] = true;
whitelistTargets[RELAYERHUB_CONTRACT_ADDR] = true;
// BSCGovernor => Timelock => GovHub => system contracts
whitelistTargets[GOV_HUB_ADDR] = true;
whitelistTargets[TOKEN_MANAGER_ADDR] = true;
whitelistTargets[CROSS_CHAIN_CONTRACT_ADDR] = true;
whitelistTargets[STAKING_CONTRACT_ADDR] = true;
whitelistTargets[STAKE_HUB_ADDR] = true;
whitelistTargets[GOVERNOR_ADDR] = true;
whitelistTargets[GOV_TOKEN_ADDR] = true;
whitelistTargets[TIMELOCK_ADDR] = true;

governorProtector = address(0x000000000000000000000000000000000000dEaD); // TODO
}
Expand Down
4 changes: 4 additions & 0 deletions contracts/BC_fusion/BSCTimelock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ contract BSCTimelock is System, Initializable, TimelockControllerUpgradeable {
using Utils for string;

/*----------------- constants -----------------*/
/*
@dev caution:
minDelay using second as unit
*/
uint256 private constant INIT_MINIMAL_DELAY = 24 hours;

/*----------------- init -----------------*/
Expand Down
2 changes: 1 addition & 1 deletion contracts/GovHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ contract GovHub is System, IApplication{
require(false, "receive unexpected fail ack package");
}

function updateParam(string calldata key, bytes calldata value, address target) external onlyGovernor {
function updateParam(string calldata key, bytes calldata value, address target) external onlyGovernorTimelock {
ParamChangePackage memory proposal = ParamChangePackage(key, value, target);
notifyUpdates(proposal);
}
Expand Down
7 changes: 5 additions & 2 deletions contracts/System.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ contract System {
address public constant CROSS_CHAIN_CONTRACT_ADDR = 0x0000000000000000000000000000000000002000;
address public constant STAKING_CONTRACT_ADDR = 0x0000000000000000000000000000000000002001;
address public constant STAKE_HUB_ADDR = 0x0000000000000000000000000000000000002002;
address public constant STAKE_CREDIT_ADDR = 0x0000000000000000000000000000000000002003;
address public constant GOVERNOR_ADDR = 0x0000000000000000000000000000000000002004;
address public constant GOV_TOKEN_ADDR = 0x0000000000000000000000000000000000002005;
address public constant TIMELOCK_ADDR = 0x0000000000000000000000000000000000002006;
address public constant TOKEN_RECOVER_PORTAL_ADDR = 0x0000000000000000000000000000000000003000;

modifier onlyCoinbase() {
Expand Down Expand Up @@ -100,8 +103,8 @@ contract System {
_;
}

modifier onlyGovernor() {
require(msg.sender == GOVERNOR_ADDR, "the msg sender must be governor contract");
modifier onlyGovernorTimelock() {
require(msg.sender == TIMELOCK_ADDR, "the msg sender must be governor timelock contract");
_;
}

Expand Down