Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accountability Contract: canSlash contract call reverts correctly but doesn't return a revert reason #151

Closed
cmjc opened this issue Mar 28, 2024 · 2 comments

Comments

@cmjc
Copy link
Contributor

cmjc commented Mar 28, 2024

Description

Calling canSlash with autcli to see if a validator is slashable:

aut contract call --address 0x5a443704dd4B594B382c22a083e2BD3090A6feF3 canSlash 0x4B241e33CEFbeF5fFE87CF81C56f19D6321536c4 10 1245

returns reverted, but without a revert reason:

web3.exceptions.ContractLogicError: execution reverted

If calling getValidatorAccusation and there are no accusations, a revert reason of no accusation is returned:

aut contract call --address 0x5a443704dd4B594B382c22a083e2BD3090A6feF3 getValidatorAccusation 0x6558D2cEEb4a9Fe9c9cF19A3F6EBE7D45C30efaF
web3.exceptions.ContractLogicError: execution reverted: no accusation

System Information

Rationale

Returning a revert reason would be more informative to the user.

@cmjc
Copy link
Contributor Author

cmjc commented Mar 28, 2024

Originally raised in autonity repo - transferred here per comment by @Jason-Zhangxin-Chen , see closed issue autonity/autonity#954

Hi @cmjc, from your context, rule NO. 10 is not defined in the rule set:

    // Must match autonity/types.go
    enum Rule {
        PN,
        PO,
        PVN,
        PVO,
        PVO12,
        C,
        C1,

        InvalidProposal, // The value proposed by proposer cannot pass the blockchain's validation.
        InvalidProposer, // A proposal sent from none proposer nodes of the committee.
        Equivocation    // Multiple distinguish votes(proposal, prevote, precommit) sent by validator.
    }

    // @dev return true if sending the event can lead to slashing
    function canSlash(address _offender, Rule _rule, uint256 _block) public view returns (bool) {
        uint256 _severity = _ruleSeverity(_rule);
        uint256 _epoch = autonity.getEpochFromBlock(_block);

        return slashingHistory[_offender][_epoch] < _severity ;
    }

As the typing system limits the input of _rule should be a type of Rule, from inside the canSlash funtion we cannot capture such error. Thus from AUT tool side, we can do some check on it. This issue so move to Aut tool.

@aiman
Copy link
Contributor

aiman commented Mar 28, 2024

@cmjc I'm not satisfied that this is an autcli issue and so I'm reopening the original ticket.

@aiman aiman closed this as completed Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants