Skip to content
This repository was archived by the owner on Mar 1, 2024. It is now read-only.

Commit 2dd5fe5

Browse files
author
Denis Ermolin
committed
chg
1 parent fc58f80 commit 2dd5fe5

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

contracts/staking/stakeManager/StakeManager.sol

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,14 @@ contract StakeManager is
535535
require(delegationEnabled, "Delegation is disabled");
536536
}
537537

538-
if (validators[validatorId].deactivationEpoch == 0) { // modify timeline only if validator didn't unstake
538+
uint256 deactivationEpoch = validators[validatorId].deactivationEpoch;
539+
540+
if (deactivationEpoch == 0) { // modify timeline only if validator didn't unstake
539541
updateTimeline(amount, 0, 0);
542+
} else if (deactivationEpoch > currentEpoch) { // validator just unstaked, need to wait till next checkpoint
543+
revert("unstaking");
540544
}
545+
541546

542547
if (amount >= 0) {
543548
increaseValidatorDelegatedAmount(validatorId, uint256(amount));

test/units/staking/stakeManager/StakeManager.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2482,7 +2482,9 @@ contract('StakeManager', async function(accounts) {
24822482
totalStakeAfterUnstake = await this.stakeManager.currentValidatorSetTotalStake()
24832483
})
24842484

2485-
testMigration()
2485+
it('reverts', async function() {
2486+
await expectRevert(this.stakeManager.migrateDelegation(aliceId, bobId, delegationAmount, { from: delegator }), 'unstaking');
2487+
})
24862488
})
24872489
})
24882490

0 commit comments

Comments
 (0)