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

Commit 53deec8

Browse files
Merge pull request #362 from maticnetwork/migrate-delegation-v2
chg: allow to migrate to any non-foundation node
2 parents a22b380 + e954d58 commit 53deec8

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

contracts/staking/stakeManager/StakeManager.sol

+2-2
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ contract StakeManager is
523523
uint256 toValidatorId,
524524
uint256 amount
525525
) public {
526-
require(fromValidatorId < 8 && toValidatorId > 7, "Invalid migration");
526+
// allow to move to any non-foundation node
527+
require(toValidatorId > 7, "Invalid migration");
527528
IValidatorShare(validators[fromValidatorId].contractAddress).migrateOut(msg.sender, amount);
528529
IValidatorShare(validators[toValidatorId].contractAddress).migrateIn(msg.sender, amount);
529530
}
@@ -1118,7 +1119,6 @@ contract StakeManager is
11181119
}
11191120

11201121
_removeSigner(validators[validatorId].signer);
1121-
11221122
_liquidateRewards(validatorId, validator);
11231123

11241124
uint256 targetEpoch = exitEpoch <= currentEpoch ? 0 : exitEpoch;

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -2500,8 +2500,8 @@ contract('StakeManager', async function(accounts) {
25002500
})
25012501
})
25022502

2503-
describe('when Chad migrates from non-matic validator', function() {
2504-
const aliceId = '9'
2503+
describe('when Chad migrates to foundation validator', function() {
2504+
const foundationNodeId = '2'
25052505
const bobId = '8'
25062506
const delegator = wallets[1].getChecksumAddressString()
25072507

@@ -2511,14 +2511,14 @@ contract('StakeManager', async function(accounts) {
25112511
await this.stakeToken.approve(this.stakeManager.address, delegationAmount, {
25122512
from: delegator
25132513
})
2514-
const aliceValidator = await this.stakeManager.validators(aliceId)
2515-
const aliceContract = await ValidatorShare.at(aliceValidator.contractAddress)
2516-
await buyVoucher(aliceContract, delegationAmount, delegator)
2514+
const nonFoundationValidator = await this.stakeManager.validators(bobId)
2515+
const nonFoundationContract = await ValidatorShare.at(nonFoundationValidator.contractAddress)
2516+
await buyVoucher(nonFoundationContract, delegationAmount, delegator)
25172517
})
25182518

25192519
it('Migration should fail', async function() {
25202520
await expectRevert(
2521-
this.stakeManager.migrateDelegation(aliceId, bobId, migrationAmount, { from: delegator }),
2521+
this.stakeManager.migrateDelegation(bobId, foundationNodeId, migrationAmount, { from: delegator }),
25222522
'Invalid migration')
25232523
})
25242524
})

0 commit comments

Comments
 (0)