Skip to content

Commit

Permalink
Merge pull request #55 from uprendis/feature/revert-double-consts-own…
Browse files Browse the repository at this point in the history
…ership

Revert double ownership of ConstantsManager
  • Loading branch information
quan8 authored Dec 19, 2022
2 parents 3646d81 + 8f5d5bc commit a162eb6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
39 changes: 17 additions & 22 deletions contracts/sfc/ConstantsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,52 +34,47 @@ contract ConstantsManager is Ownable {
uint256 public targetGasPowerPerSecond;
uint256 public gasPriceBalancingCounterweight;

address public secondaryOwner;
address private secondaryOwner_erased;

event SecondaryOwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// event SecondaryOwnershipTransferred(address indexed previousOwner, address indexed newOwner);

function initialize() external initializer {
Ownable.initialize(msg.sender);
}

modifier onlyAnyOwner() {
require(isOwner() || msg.sender == secondaryOwner, "Ownable: caller is not the owner");
_;
}

function setSecondaryOwner(address v) onlyOwner external {
emit SecondaryOwnershipTransferred(secondaryOwner, v);
secondaryOwner = v;
}
// function setSecondaryOwner(address v) onlyOwner external {
// emit SecondaryOwnershipTransferred(secondaryOwner, v);
// secondaryOwner = v;
// }

function updateMinSelfStake(uint256 v) onlyAnyOwner external {
function updateMinSelfStake(uint256 v) onlyOwner external {
require(v >= 100000 * 1e18, "too small value");
require(v <= 10000000 * 1e18, "too large value");
minSelfStake = v;
}

function updateMaxDelegatedRatio(uint256 v) onlyAnyOwner external {
function updateMaxDelegatedRatio(uint256 v) onlyOwner external {
require(v >= Decimal.unit(), "too small value");
require(v <= 31 * Decimal.unit(), "too large value");
maxDelegatedRatio = v;
}

function updateValidatorCommission(uint256 v) onlyAnyOwner external {
function updateValidatorCommission(uint256 v) onlyOwner external {
require(v <= Decimal.unit() / 2, "too large value");
validatorCommission = v;
}

function updateBurntFeeShare(uint256 v) onlyAnyOwner external {
function updateBurntFeeShare(uint256 v) onlyOwner external {
require(v <= Decimal.unit() / 2, "too large value");
burntFeeShare = v;
}

function updateTreasuryFeeShare(uint256 v) onlyAnyOwner external {
function updateTreasuryFeeShare(uint256 v) onlyOwner external {
require(v <= Decimal.unit() / 2, "too large value");
treasuryFeeShare = v;
}

function updateUnlockedRewardRatio(uint256 v) onlyAnyOwner external {
function updateUnlockedRewardRatio(uint256 v) onlyOwner external {
require(v >= (5 * Decimal.unit()) / 100, "too small value");
require(v <= Decimal.unit() / 2, "too large value");
unlockedRewardRatio = v;
Expand All @@ -97,31 +92,31 @@ contract ConstantsManager is Ownable {
maxLockupDuration = v;
}

function updateWithdrawalPeriodEpochs(uint256 v) onlyAnyOwner external {
function updateWithdrawalPeriodEpochs(uint256 v) onlyOwner external {
require(v >= 2, "too small value");
require(v <= 100, "too large value");
withdrawalPeriodEpochs = v;
}

function updateWithdrawalPeriodTime(uint256 v) onlyAnyOwner external {
function updateWithdrawalPeriodTime(uint256 v) onlyOwner external {
require(v >= 86400, "too small value");
require(v <= 30 * 86400, "too large value");
withdrawalPeriodTime = v;
}

function updateBaseRewardPerSecond(uint256 v) onlyAnyOwner external {
function updateBaseRewardPerSecond(uint256 v) onlyOwner external {
require(v >= 0.5 * 1e18, "too small value");
require(v <= 32 * 1e18, "too large value");
baseRewardPerSecond = v;
}

function updateOfflinePenaltyThresholdTime(uint256 v) onlyAnyOwner external {
function updateOfflinePenaltyThresholdTime(uint256 v) onlyOwner external {
require(v >= 86400, "too small value");
require(v <= 10 * 86400, "too large value");
offlinePenaltyThresholdTime = v;
}

function updateOfflinePenaltyThresholdBlocksNum(uint256 v) onlyAnyOwner external {
function updateOfflinePenaltyThresholdBlocksNum(uint256 v) onlyOwner external {
require(v >= 100, "too small value");
require(v <= 1000000, "too large value");
offlinePenaltyThresholdBlocksNum = v;
Expand Down
6 changes: 3 additions & 3 deletions contracts/test/UnitTestConstantsManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ pragma solidity ^0.5.0;
import "../sfc/ConstantsManager.sol";

contract UnitTestConstantsManager is ConstantsManager {
function updateMinSelfStake(uint256 v) onlyAnyOwner external {
function updateMinSelfStake(uint256 v) onlyOwner external {
minSelfStake = v;
}

function updateBaseRewardPerSecond(uint256 v) onlyAnyOwner external {
function updateBaseRewardPerSecond(uint256 v) onlyOwner external {
baseRewardPerSecond = v;
}

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

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

Expand Down

0 comments on commit a162eb6

Please sign in to comment.