Skip to content

Commit

Permalink
feat: remove unused code in stakehub
Browse files Browse the repository at this point in the history
  • Loading branch information
cosinlink committed Aug 28, 2024
1 parent 5cf936a commit c6a2f85
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions contracts/StakeHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -999,57 +999,6 @@ contract StakeHub is SystemV2, Initializable, Protectable {
}

/*----------------- internal functions -----------------*/
function _decodeMigrationSynPackage(
bytes memory msgBytes
) internal pure returns (StakeMigrationPackage memory, bool) {
StakeMigrationPackage memory migrationPackage;

RLPDecode.Iterator memory iter = msgBytes.toRLPItem().iterator();
bool success = false;
uint256 idx = 0;
while (iter.hasNext()) {
if (idx == 0) {
migrationPackage.operatorAddress = address(uint160(iter.next().toAddress()));
} else if (idx == 1) {
migrationPackage.delegator = address(uint160(iter.next().toAddress()));
} else if (idx == 2) {
migrationPackage.refundAddress = address(uint160(iter.next().toAddress()));
} else if (idx == 3) {
migrationPackage.amount = iter.next().toUint();
success = true;
} else {
break;
}
++idx;
}

return (migrationPackage, success);
}

function _doMigration(StakeMigrationPackage memory migrationPkg) internal returns (StakeMigrationRespCode) {
if (blackList[migrationPkg.delegator] || migrationPkg.delegator == address(0)) {
return StakeMigrationRespCode.INVALID_DELEGATOR;
}

if (!_validatorSet.contains(migrationPkg.operatorAddress)) {
return StakeMigrationRespCode.VALIDATOR_NOT_EXISTED;
}

Validator memory valInfo = _validators[migrationPkg.operatorAddress];
if (valInfo.jailed && migrationPkg.delegator != migrationPkg.operatorAddress) {
return StakeMigrationRespCode.VALIDATOR_JAILED;
}

uint256 shares =
IStakeCredit(valInfo.creditContract).delegate{ value: migrationPkg.amount }(migrationPkg.delegator);
emit Delegated(migrationPkg.operatorAddress, migrationPkg.delegator, shares, migrationPkg.amount);
emit MigrateSuccess(migrationPkg.operatorAddress, migrationPkg.delegator, shares, migrationPkg.amount);

IGovToken(GOV_TOKEN_ADDR).sync(valInfo.creditContract, migrationPkg.delegator);

return StakeMigrationRespCode.MIGRATE_SUCCESS;
}

function _checkMoniker(string memory moniker) internal pure returns (bool) {
bytes memory bz = bytes(moniker);

Expand Down Expand Up @@ -1143,8 +1092,6 @@ contract StakeHub is SystemV2, Initializable, Protectable {
}

function _jailValidator(Validator storage valInfo, uint256 jailUntil) internal {
IBSCValidatorSet(VALIDATOR_CONTRACT_ADDR).removeTmpMigratedValidator(valInfo.consensusAddress);

// keep the last eligible validator
bool isLast = (numOfJailed >= _validatorSet.length() - 1);
if (isLast) {
Expand Down

0 comments on commit c6a2f85

Please sign in to comment.