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

The requirements about auctionPeriod are different in two functions. #417

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

Comments

@VictorECDSA
Copy link

This issue and the two preceding issues is about the code at the latest version of the Main branch currently.
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

The requirements about auctionPeriod in the functions startAuction and confirmAuctionBid use two different startEpoch. Because the validator activationEpoch is unchanged, from hope the validator is not continuous auction, I understand two should use auction startEpoch.

    function startAuction(uint256 validatorId, uint256 amount, bool _acceptDelegation, bytes calldata _signerPubkey) external {

// ......

        require(
            (_currentEpoch.sub(validators[validatorId].activationEpoch) % dynasty.add(auctionPeriod)) < auctionPeriod,
            "Invalid auction period"
        );
    function confirmAuctionBid(
        uint256 validatorId,
        uint256 heimdallFee, /** for new validator */
        IStakeManager stakeManager
    ) external {

// ......

       require(
            _currentEpoch.sub(auction.startEpoch) % auctionPeriod.add(dynasty) >= auctionPeriod,
            "Not allowed before auctionPeriod"
        );

Another possible small problem in the confirmAuctionBid function is that once in the logical branch of dethroneAndStake, setting validatorAuction[validatorId].startepoch becomes meaningless, as deactivationEpoch != 0 and can not startAuction any more.

        if (perceivedStake >= auctionAmount && validators[validatorId].deactivationEpoch == 0) {
            require(token.transfer(auctionUser, auctionAmount), "Bid return failed");
            //cleanup auction data
            auction.startEpoch = _currentEpoch;
            logger.logConfirmAuction(validatorId, validatorId, validatorAmount);
        } else {
            stakeManager.dethroneAndStake(
                auctionUser, 
                heimdallFee,
                validatorId,
                auctionAmount,
                auction.acceptDelegation,
                auction.signerPubkey
            );
        }
        uint256 startEpoch = auction.startEpoch;
        delete validatorAuction[validatorId];
        validatorAuction[validatorId].startEpoch = startEpoch;

So, I think replacing 'auction.startEpoch = _currentEpoch' with 'validatorAuction[validatorId].startEpoch = _currentEpoch'. Subsequent logic does not need to set validatorAuction[validatorId].startEpoch.

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