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

the same Validator maybe unstake twice #419

Open
VictorECDSA opened this issue Aug 4, 2022 · 0 comments
Open

the same Validator maybe unstake twice #419

VictorECDSA opened this issue Aug 4, 2022 · 0 comments

Comments

@VictorECDSA
Copy link

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: 5dace23
Children: 61170c6#gitext://gotocommit/61170c6a824468800dc2187be73f2869ed82b82b 5d82635#gitext://gotocommit/5d82635a65fdc7c76fe5d281c3f208b3e955b6cc
Parent(s): 7c0af26#gitext://gotocommit/7c0af26ec34ccedadda6ccf5a1f57f65e03b0af2 746dfd6#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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant