the same Validator maybe unstake twice
This issue, and all previous issues, are based on the latest version of the Main branch. Author: Jaynti Kanani [email protected]#mailto:[email protected] Date: 6 months ago (2022/1/26 16:43:04) Committer: GitHub [email protected]#mailto:[email protected] Commit hash: 5dace23fd378b89aef3ef9ad6407cc44eac4d7db Children: 61170c6a82#gitext://gotocommit/61170c6a824468800dc2187be73f2869ed82b82b 5d82635a65#gitext://gotocommit/5d82635a65fdc7c76fe5d281c3f208b3e955b6cc Parent(s): 7c0af26ec3#gitext://gotocommit/7c0af26ec34ccedadda6ccf5a1f57f65e03b0af2 746dfd6f61#gitext://gotocommit/746dfd6f61a6052c8c3985d34c408737d3bc1740
Assume that there is a Validator belong to Alice. And then Bob startAuction for this Validator.
Later, Alice is slashed to validatorStakeSlashed == 0, then _unstake.
function slash(bytes calldata _slashingInfoList) external returns (uint256) {
//......
for (; i < slashingInfoList.length; i++) {
//......
if (validatorStakeSlashed == 0) {
_unstake(validatorId, currentEpoch);
So the deactivationEpoch != 0.
function _unstake(uint256 validatorId, uint256 exitEpoch) internal {
//......
validators[validatorId].deactivationEpoch = exitEpoch;
And then later Bob confirmAuctionBid for this Validator. Then enter the logical branch of dethroneAndStake.
function confirmAuctionBid(
uint256 validatorId,
uint256 heimdallFee, /** for new validator */
IStakeManager stakeManager
) external {
//......
if (perceivedStake >= auctionAmount && validators[validatorId].deactivationEpoch == 0) {
//......
} else {
stakeManager.dethroneAndStake(
auctionUser,
heimdallFee,
validatorId,
auctionAmount,
auction.acceptDelegation,
auction.signerPubkey
);
}
And then dethroneAndStake will invoke _unstake again.
function dethroneAndStake(
address auctionUser,
uint256 heimdallFee,
uint256 validatorId,
uint256 auctionAmount,
bool acceptDelegation,
bytes calldata signerPubkey
) external {
//......
_unstake(validatorId, currentEpoch);
Therefore, the same Validator maybe unstake twice.