# Penalizer

The Penalizer Implementation

This Penalizer supports parsing Legacy, Type 1 and Type 2 raw RLP Encoded transactions.

# Functions

# constructor(uint256 _penalizeBlockDelay, uint256 _penalizeBlockExpiration)

(public)


# supportsInterface(bytes4 interfaceId)

→ bool (public)

Returns true if this contract implements the interface defined by interfaceId. See the corresponding https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] to learn more about how these ids are created. This function call must use less than 30 000 gas.


# getPenalizeBlockDelay()

→ uint256 (external)

# Return values

minimum delay between commit and reveal steps.


# getPenalizeBlockExpiration()

→ uint256 (external)

# Return values

maximum delay between commit and reveal steps.


# isLegacyTransaction(bytes rawTransaction)

→ bool (internal)


# isTransactionType1(bytes rawTransaction)

→ bool (internal)


# isTransactionType2(bytes rawTransaction)

→ bool (internal)


# isTransactionTypeValid(bytes rawTransaction)

→ bool (public)

# Return values

raw transaction is of types Legacy, 1 or 2. false otherwise.


# decodeTransaction(bytes rawTransaction)

→ struct IPenalizer.Transaction transaction (public)

# Return values

The details that the Penalizer needs to decide if the transaction is penalizable.


# commit(bytes32 commitHash)

(external)

Called by the reporter as the first step in the commit-reveal process. Any sender can call it to make sure no-one can front-run it to claim this penalization.

commitHash: The hash of the report of a penalizable behaviour the reporter wants to reveal. Calculated as commit(keccak(encodedPenalizeFunction)).


# penalizeRepeatedNonce(bytes unsignedTx1, bytes signature1, bytes unsignedTx2, bytes signature2, contract IRelayHub hub, uint256 randomValue)

(public)

Called by the reporter as the second step in the commit-reveal process. If a Relay Worker attacked the system by signing multiple transactions with same nonce so only one is accepted, anyone can grab both transactions from the blockchain and submit them here. Check whether unsignedTx1 != unsignedTx2, that both are signed by the same address, and that unsignedTx1.nonce == unsignedTx2.nonce. If all conditions are met, relay is considered an "offending relay". The offending relay will be unregistered immediately, its stake will be forfeited and given to the address who reported it (the msg.sender), thus incentivizing anyone to report offending relays.


# penalizeIllegalTransaction(bytes unsignedTx, bytes signature, contract IRelayHub hub, uint256 randomValue)

(public)

Called by the reporter as the second step in the commit-reveal process. The Relay Workers are not allowed to make calls other than to the relayCall method.


# Modifiers

# commitRevealOnly()

Modifier that verifies there was a commit operation before this call that has not expired yet.