From ad041a980300dd5e727d39881be3d94c33308888 Mon Sep 17 00:00:00 2001 From: Denis Ermolin Date: Mon, 14 Jun 2021 13:43:56 +0700 Subject: [PATCH 1/2] chg: allow to migrate to any non-foundation node --- contracts/staking/stakeManager/StakeManager.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/staking/stakeManager/StakeManager.sol b/contracts/staking/stakeManager/StakeManager.sol index f11909521..dd4382f2f 100644 --- a/contracts/staking/stakeManager/StakeManager.sol +++ b/contracts/staking/stakeManager/StakeManager.sol @@ -523,7 +523,8 @@ contract StakeManager is uint256 toValidatorId, uint256 amount ) public { - require(fromValidatorId < 8 && toValidatorId > 7, "Invalid migration"); + // allow to move to any non-foundation node + require(toValidatorId > 7, "Invalid migration"); IValidatorShare(validators[fromValidatorId].contractAddress).migrateOut(msg.sender, amount); IValidatorShare(validators[toValidatorId].contractAddress).migrateIn(msg.sender, amount); } @@ -1118,7 +1119,6 @@ contract StakeManager is } _removeSigner(validators[validatorId].signer); - _liquidateRewards(validatorId, validator); uint256 targetEpoch = exitEpoch <= currentEpoch ? 0 : exitEpoch; From e954d58a95c861873cd93e8904ec2d4e4e6de8be Mon Sep 17 00:00:00 2001 From: Denis Ermolin Date: Mon, 14 Jun 2021 16:33:23 +0700 Subject: [PATCH 2/2] fix: migration of delegation test --- test/units/staking/stakeManager/StakeManager.test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/units/staking/stakeManager/StakeManager.test.js b/test/units/staking/stakeManager/StakeManager.test.js index 963597e84..53e54801f 100644 --- a/test/units/staking/stakeManager/StakeManager.test.js +++ b/test/units/staking/stakeManager/StakeManager.test.js @@ -2500,8 +2500,8 @@ contract('StakeManager', async function(accounts) { }) }) - describe('when Chad migrates from non-matic validator', function() { - const aliceId = '9' + describe('when Chad migrates to foundation validator', function() { + const foundationNodeId = '2' const bobId = '8' const delegator = wallets[1].getChecksumAddressString() @@ -2511,14 +2511,14 @@ contract('StakeManager', async function(accounts) { await this.stakeToken.approve(this.stakeManager.address, delegationAmount, { from: delegator }) - const aliceValidator = await this.stakeManager.validators(aliceId) - const aliceContract = await ValidatorShare.at(aliceValidator.contractAddress) - await buyVoucher(aliceContract, delegationAmount, delegator) + const nonFoundationValidator = await this.stakeManager.validators(bobId) + const nonFoundationContract = await ValidatorShare.at(nonFoundationValidator.contractAddress) + await buyVoucher(nonFoundationContract, delegationAmount, delegator) }) it('Migration should fail', async function() { await expectRevert( - this.stakeManager.migrateDelegation(aliceId, bobId, migrationAmount, { from: delegator }), + this.stakeManager.migrateDelegation(bobId, foundationNodeId, migrationAmount, { from: delegator }), 'Invalid migration') }) })