Skip to content

Commit

Permalink
Update constants manager
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-CZ committed Dec 13, 2024
1 parent 7c57e0e commit 4d29843
Show file tree
Hide file tree
Showing 5 changed files with 342 additions and 44 deletions.
29 changes: 2 additions & 27 deletions contracts/sfc/ConstantsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ contract ConstantsManager is Ownable {
uint256 public baseRewardPerSecond;
uint256 public offlinePenaltyThresholdBlocksNum;
uint256 public offlinePenaltyThresholdTime;
uint256 public targetGasPowerPerSecond;
uint256 public gasPriceBalancingCounterweight;

// The number of epochs to calculate the average uptime ratio from, acceptable bound [10, 87600].
// Is also the minimum number of epochs necessary for deactivation of offline validators.
Expand Down Expand Up @@ -81,14 +79,14 @@ contract ConstantsManager is Ownable {
}

function updateBurntFeeShare(uint256 v) external virtual onlyOwner {
if (v > Decimal.unit() / 2) {
if (v + treasuryFeeShare > Decimal.unit()) {
revert ValueTooLarge();
}
burntFeeShare = v;
}

function updateTreasuryFeeShare(uint256 v) external virtual onlyOwner {
if (v > Decimal.unit() / 2) {
if (v + burntFeeShare > Decimal.unit()) {
revert ValueTooLarge();
}
treasuryFeeShare = v;
Expand All @@ -115,9 +113,6 @@ contract ConstantsManager is Ownable {
}

function updateBaseRewardPerSecond(uint256 v) external virtual onlyOwner {
if (v < 0.5 * 1e18) {
revert ValueTooSmall();
}
if (v > 32 * 1e18) {
revert ValueTooLarge();
}
Expand All @@ -144,26 +139,6 @@ contract ConstantsManager is Ownable {
offlinePenaltyThresholdBlocksNum = v;
}

function updateTargetGasPowerPerSecond(uint256 v) external virtual onlyOwner {
if (v < 1000000) {
revert ValueTooSmall();
}
if (v > 500000000) {
revert ValueTooLarge();
}
targetGasPowerPerSecond = v;
}

function updateGasPriceBalancingCounterweight(uint256 v) external virtual onlyOwner {
if (v < 100) {
revert ValueTooSmall();
}
if (v > 10 * 86400) {
revert ValueTooLarge();
}
gasPriceBalancingCounterweight = v;
}

function updateAverageUptimeEpochWindow(uint32 v) external virtual onlyOwner {
if (v < 10) {
// needs to be long enough to allow permissible downtime for validators maintenance
Expand Down
12 changes: 5 additions & 7 deletions contracts/sfc/NetworkInitializer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,16 @@ contract NetworkInitializer {
NodeDriverAuth(_auth).initialize(_sfc, _driver, _owner);

ConstantsManager consts = new ConstantsManager(address(this));
consts.updateMinSelfStake(500000 * 1e18);
consts.updateMinSelfStake(500_000 * 1e18);
consts.updateMaxDelegatedRatio(16 * Decimal.unit());
consts.updateValidatorCommission((15 * Decimal.unit()) / 100);
consts.updateBurntFeeShare((20 * Decimal.unit()) / 100);
consts.updateTreasuryFeeShare((10 * Decimal.unit()) / 100);
consts.updateBurntFeeShare(0);
consts.updateTreasuryFeeShare((90 * Decimal.unit()) / 100);
consts.updateWithdrawalPeriodEpochs(3);
consts.updateWithdrawalPeriodTime(60 * 60 * 24 * 7);
consts.updateBaseRewardPerSecond(2668658453701531600);
consts.updateBaseRewardPerSecond(1_000);
consts.updateOfflinePenaltyThresholdTime(5 days);
consts.updateOfflinePenaltyThresholdBlocksNum(1000);
consts.updateTargetGasPowerPerSecond(2000000);
consts.updateGasPriceBalancingCounterweight(3600);
consts.updateOfflinePenaltyThresholdBlocksNum(1_000);
consts.updateAverageUptimeEpochWindow(100);
consts.updateMinAverageUptime(0); // check disabled by default
consts.transferOwnership(_owner);
Expand Down
8 changes: 0 additions & 8 deletions contracts/test/UnitTestConstantsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,7 @@ contract UnitTestConstantsManager is ConstantsManager {
baseRewardPerSecond = v;
}

function updateGasPriceBalancingCounterweight(uint256 v) external override onlyOwner {
gasPriceBalancingCounterweight = v;
}

function updateOfflinePenaltyThresholdTime(uint256 v) external override onlyOwner {
offlinePenaltyThresholdTime = v;
}

function updateTargetGasPowerPerSecond(uint256 v) external override onlyOwner {
targetGasPowerPerSecond = v;
}
}
2 changes: 0 additions & 2 deletions contracts/test/UnitTestSFC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ contract UnitTestNetworkInitializer {
consts.updateBaseRewardPerSecond(6183414351851851852);
consts.updateOfflinePenaltyThresholdTime(3 days);
consts.updateOfflinePenaltyThresholdBlocksNum(1000);
consts.updateTargetGasPowerPerSecond(2000000);
consts.updateGasPriceBalancingCounterweight(6 * 60 * 60);
consts.updateAverageUptimeEpochWindow(10);
consts.updateMinAverageUptime(0); // check disabled by default
consts.transferOwnership(_owner);
Expand Down
Loading

0 comments on commit 4d29843

Please sign in to comment.