autonity / docs.autonity.org

Documentation for the Autonity Go Client (AGC)
https://docs.autonity.org
2 stars 5 forks source link

Accountability documentation: Add possible integer values of the EventType and Rule ID #195

Open cmjc opened 4 months ago

cmjc commented 4 months ago

Description

The accountability documentation should state the possible values of the accountability event types. It states in https://docs.autonity.org/reference/api/aut/op-prot/#handleevent-accountability-contract:

"the accountability event type, one of: FaultProof (proven misbehaviour), Accusation (pending accusation), InnocenceProof (proven innocence)"

The eventType enumerations are defined in the type here: https://github.com/autonity/autonity/blob/4073f24786ce5c99bef80238aa798482ae13fd33/autonity/solidity/contracts/Accountability.sol#L23:

    enum EventType {
        FaultProof,
        Accusation,
        InnocenceProof
    }

If an accountability transaction input is decoded, though, it returns for the event type an integer, as done for validator state.

For example, in this decoded transaction 'eventType': 1,:

Decoded input:  (<Function handleEvent((uint8,uint8,uint8,uint8,address,address,bytes,uint256,uint256,uint256,uint256,uint256))>, {'_event': {'chunks': 1, 'chunkId': 0, 'eventType': 1, 'rule': 2, 'reporter': '0xC7FC8472D479B1204f9c93293b8FCb2F41b40ea1', 'offender': '0x113B707Bc4aa509e19B78F6e2a1FF63eF3b19e5e', 'rawProof': b'\xf8r\x01\x02\xf8m\x01\xf8j\x01\x80\x83\x0e[\xb1\xa0R>\xa6\x8b\xfa\xe0\xca\x98\x8c\x9d\xa5v\xc0\x89\x1a"\xa5Mo\xaeL7\x05\x8a\x9et\xa7.\x89\xa4]\xf2\xb8A^\xac\xe31\x80\x04\xc0/\xda\x15\'^\xa8C\xc7sI\x9cB\xf5\xf4\nBZZ\xef@\x8a\x83/\xd8\xd2er\xf9\xf9\x8b7\xe7\xd3L\x1d\xee/\x08\xbaM\xf5\xfc\xc6\x89\xf1\xe4\xf8\x90\x8f\xac^`?\xd8\x9c\xf8&\x01\xc0', 'id': 0, 'block': 0, 'epoch': 0, 'reportingBlock': 0, 'messageHash': 0}})

The event type integer values are:

0: FaultProof, 1: Accusation, 2: InnocenceProof

Rationale

The integer to enumeration mapping should be documented for clarity to developers decoding transactions.

Implementation

Document the mapping in:

Also, document the Rule ID in:

Like the event type, an integer is returned not the rule ID string - e.g. in the decoded example above it is 'rule': 2,.