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

feat: gracePeriod hardcoded to 0 and removed as governance parameter #911

Merged
merged 2 commits into from
Jul 13, 2022
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
2 changes: 1 addition & 1 deletion contracts/Core/RewardManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ contract RewardManager is Initializable, Constants, RewardManagerParams, IReward
uint32 previousAge = thisStaker.age;
uint32 newAge = thisStaker.age;

if (inactiveEpochs > gracePeriod) {
if (inactiveEpochs > 0) {
(newStake, newAge) = _calculateInactivityPenalties(inactiveEpochs, newStake, previousAge);
}
// uint256 currentStake = previousStake;
Expand Down
11 changes: 0 additions & 11 deletions contracts/Core/parameters/Governance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -182,17 +182,6 @@ contract Governance is Initializable, ACL, Constants {
rewardManagerParams.setBlockReward(_blockReward);
}

/**
* @notice changing number of epochs for which the staker wont be given inactivity penalties
* @dev can be called only by the the address that has the governance role
* @param _gracePeriod updated value to be set for gracePeriod
*/
function setGracePeriod(uint16 _gracePeriod) external initialized onlyRole(GOVERNER_ROLE) {
emit ParameterChanged(msg.sender, "gracePeriod", _gracePeriod, block.timestamp);
rewardManagerParams.setGracePeriod(_gracePeriod);
stakeManagerParams.setGracePeriod(_gracePeriod);
}

/**
* @notice changing the maximum age a staker can have
* @dev can be called only by the the address that has the governer role
Expand Down
11 changes: 0 additions & 11 deletions contracts/Core/parameters/child/RewardManagerParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ abstract contract RewardManagerParams is ACL, IRewardManagerParams, Constants {
uint32 public penaltyNotRevealNum = 1000;
/// @notice percentage age penalty to be given out for inactivity
uint32 public penaltyAgeNotRevealNum = 100_000;
/**
* @notice the number of epochs for which the staker wont be given inactivity penalties.
* Stakers inactive for more than grace period will be penalized
*/
uint16 public gracePeriod = 8;
/// @notice maximum age a staker can have
uint32 public maxAge = 100 * 10000;
/// @notice reward given to staker whose block is confirmed
Expand Down Expand Up @@ -41,12 +36,6 @@ abstract contract RewardManagerParams is ACL, IRewardManagerParams, Constants {
blockReward = _blockReward;
}

/// @inheritdoc IRewardManagerParams
function setGracePeriod(uint16 _gracePeriod) external override onlyRole(GOVERNANCE_ROLE) {
// slither-disable-next-line events-maths
gracePeriod = _gracePeriod;
}

/// @inheritdoc IRewardManagerParams
function setMaxAge(uint32 _maxAge) external override onlyRole(GOVERNANCE_ROLE) {
// slither-disable-next-line events-maths
Expand Down
11 changes: 0 additions & 11 deletions contracts/Core/parameters/child/StakeManagerParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ abstract contract StakeManagerParams is ACL, IStakeManagerParams, Constants {
uint8 public maxCommission = 20;
/// @notice maximum commission change a staker can do
uint8 public deltaCommission = 3;
/**
* @notice the number of epochs for which the staker wont be given inactivity penalties.
* Stakers inactive for more than grace period will be penalized
*/
uint16 public gracePeriod = 8;
/// @notice the number of epochs for which a staker cant change commission once set/change
uint16 public epochLimitForUpdateCommission = 100;
/// @notice slashing params being used if staker is slashed. Slash Penalty = bounty + burned + kept == 100%
Expand Down Expand Up @@ -106,12 +101,6 @@ abstract contract StakeManagerParams is ACL, IStakeManagerParams, Constants {
minSafeRazor = _minSafeRazor;
}

/// @inheritdoc IStakeManagerParams
function setGracePeriod(uint16 _gracePeriod) external override onlyRole(GOVERNANCE_ROLE) {
// slither-disable-next-line events-maths
gracePeriod = _gracePeriod;
}

/// @inheritdoc IStakeManagerParams
function setMaxCommission(uint8 _maxCommission) external override onlyRole(GOVERNANCE_ROLE) {
// slither-disable-next-line events-maths
Expand Down
7 changes: 0 additions & 7 deletions contracts/Core/parameters/interfaces/IRewardManagerParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ interface IRewardManagerParams {
*/
function setBlockReward(uint256 _blockReward) external;

/**
* @notice changing number of epochs for which the staker wont be given inactivity penalties
* @dev can be called only by the the address that has the governance role
* @param _gracePeriod updated value to be set for gracePeriod
*/
function setGracePeriod(uint16 _gracePeriod) external;

/**
* @notice changing the maximum age a staker can have
* @dev can be called only by the the address that has the governance role
Expand Down
7 changes: 0 additions & 7 deletions contracts/Core/parameters/interfaces/IStakeManagerParams.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ interface IStakeManagerParams {
*/
function setMinSafeRazor(uint256 _minSafeRazor) external;

/**
* @notice changing number of epochs for which the staker wont be given inactivity penalties
* @dev can be called only by the the address that has the governance role
* @param _gracePeriod updated value to be set for gracePeriod
*/
function setGracePeriod(uint16 _gracePeriod) external;

/**
* @notice changing maximum commission stakers can charge from delegators on their profits
* @dev can be called only by the the address that has the governance role
Expand Down
16 changes: 16 additions & 0 deletions scenarios/scenarios.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ describe('Scenarios', async () => {
await sToken.connect(signers[1]).approve(stakeManager.address, amount);
await stakeManager.connect(signers[1]).unstake(1, amount);
for (let i = 0; i < UNSTAKE_LOCK_PERIOD; i++) {
const secret = await getSecret(signers[1]);
await commit(signers[1], 0, voteManager, collectionManager, secret, blockManager);
await mineToNextState(); // reveal
await reveal(signers[1], 0, voteManager, stakeManager, collectionManager);
await mineToNextEpoch();
}
epoch = await getEpoch();
Expand All @@ -441,6 +445,10 @@ describe('Scenarios', async () => {
assertBNEqual(lock.amount, rAmount, 'Locked amount is not equal to requested lock amount');
assertBNEqual(lock.unlockAfter, epoch + WITHDRAW_LOCK_PERIOD, 'Withdraw after for the lock is incorrect');
for (let i = 0; i < WITHDRAW_LOCK_PERIOD; i++) {
const secret = await getSecret(signers[1]);
await commit(signers[1], 0, voteManager, collectionManager, secret, blockManager);
await mineToNextState(); // reveal
await reveal(signers[1], 0, voteManager, stakeManager, collectionManager);
await mineToNextEpoch();
}
await stakeManager.connect(signers[1]).unlockWithdraw(1);
Expand Down Expand Up @@ -1155,6 +1163,10 @@ describe('Scenarios', async () => {
assertBNEqual(lock.unlockAfter, epoch + UNSTAKE_LOCK_PERIOD, 'Withdraw after for the lock is incorrect');

for (let i = 0; i < UNSTAKE_LOCK_PERIOD; i++) {
const secret = await getSecret(signers[3]);
await commit(signers[3], 0, voteManager, collectionManager, secret, blockManager);
await mineToNextState(); // reveal
await reveal(signers[3], 0, voteManager, stakeManager, collectionManager);
await mineToNextEpoch();
}

Expand All @@ -1171,6 +1183,10 @@ describe('Scenarios', async () => {
assertBNEqual(lock.unlockAfter, epoch + WITHDRAW_LOCK_PERIOD, 'Withdraw after for the lock is incorrect');

for (let i = 0; i < WITHDRAW_LOCK_PERIOD; i++) {
const secret = await getSecret(signers[3]);
await commit(signers[3], 0, voteManager, collectionManager, secret, blockManager);
await mineToNextState(); // reveal
await reveal(signers[3], 0, voteManager, stakeManager, collectionManager);
await mineToNextEpoch();
}

Expand Down
14 changes: 1 addition & 13 deletions test/Governance.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Governance contract Test', async () => {
const unstakeLockPeriod = toBigNumber('1');
const withdrawLockPeriod = toBigNumber('1');
const maxAltBlocks = toBigNumber('5');
const gracePeriod = toBigNumber('8');

const minimumStake = tokenAmount('20000');
const minimumSafeRazor = tokenAmount('10000');
const blockReward = tokenAmount('100');
Expand Down Expand Up @@ -113,9 +113,6 @@ describe('Governance contract Test', async () => {
tx = governance.connect(signers[0]).setMinSafeRazor(toBigNumber('1'));
await assertRevert(tx, expectedRevertMessage);

tx = governance.connect(signers[0]).setGracePeriod(toBigNumber('1'));
await assertRevert(tx, expectedRevertMessage);

tx = governance.connect(signers[0]).setBlockReward(toBigNumber('1'));
await assertRevert(tx, expectedRevertMessage);

Expand Down Expand Up @@ -171,12 +168,6 @@ describe('Governance contract Test', async () => {
const maxAltBlocks = await blockManager.maxAltBlocks();
assertBNEqual(maxAltBlocks, toBigNumber('10'));

await governance.setGracePeriod(toBigNumber('14'));
const gracePeriod = await rewardManager.gracePeriod();
const gracePeriod1 = await stakeManager.gracePeriod();
assertBNEqual(gracePeriod, toBigNumber('14'));
assertBNEqual(gracePeriod1, toBigNumber('14'));

await governance.setMaxTolerance(toBigNumber('15'));
const maxTolerance = await rewardManager.maxTolerance();
const maxTolerance1 = await collectionManager.maxTolerance();
Expand Down Expand Up @@ -285,9 +276,6 @@ describe('Governance contract Test', async () => {
const epochLimitForUpdateCommissionValue = await stakeManager.epochLimitForUpdateCommission();
assertBNEqual(epochLimitForUpdateCommission, epochLimitForUpdateCommissionValue);

const gracePeriodValue = await rewardManager.gracePeriod();
assertBNEqual(gracePeriod, gracePeriodValue);

const toAssignValue = await voteManager.toAssign();
assertBNEqual(toAssign, toAssignValue);
});
Expand Down
Loading