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

Commit

Permalink
Merge pull request #362 from maticnetwork/migrate-delegation-v2
Browse files Browse the repository at this point in the history
chg: allow to migrate to any non-foundation node
  • Loading branch information
coinsandsteeldev authored Jun 14, 2021
2 parents a22b380 + e954d58 commit 53deec8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions contracts/staking/stakeManager/StakeManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -1118,7 +1119,6 @@ contract StakeManager is
}

_removeSigner(validators[validatorId].signer);

_liquidateRewards(validatorId, validator);

uint256 targetEpoch = exitEpoch <= currentEpoch ? 0 : exitEpoch;
Expand Down
12 changes: 6 additions & 6 deletions test/units/staking/stakeManager/StakeManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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')
})
})
Expand Down

0 comments on commit 53deec8

Please sign in to comment.