Validator slashing and jail management for network security
Overview
The Slashing precompile provides an interface to the Ontomir SDK's x/slashing module, which is responsible for penalizing validators for misbehavior, such as downtime or double-signing. This precompile allows smart contracts to unjail validators and query slashing-related information, including validator signing info and module parameters.
# Note: Replace <RPC_URL> and the placeholder consensus address with your actual data.
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
{
"to": "0x0000000000000000000000000000000000000806",
"data": "0x3f554612000000000000000000000000d8da6bf26964af9d7eed9e03e53415d37aa96045"
},
"latest"
],
"id": 1
}' -H "Content-Type: application/json" <RPC_URL>
```bash cURL expandable lines
# This example queries for the first 10 validators' signing info.
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
{
"to": "0x0000000000000000000000000000000000000806",
"data": "0x5f993f4300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000"
},
"latest"
],
"id": 1
}' -H "Content-Type: application/json" <RPC_URL>
**Note**: The slashing `getParams()` function may return empty data if slashing parameters are not configured on your network. The cURL method will still demonstrate the correct function call format.
```bash cURL expandable lines
# Note: Replace <RPC_URL> with your actual RPC endpoint.
curl -X POST --data '{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
{
"to": "0x0000000000000000000000000000000000000806",
"data": "0x4035236b"
},
"latest"
],
"id": 1
}' -H "Content-Type: application/json" <RPC_URL>
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.8.17;
import "../common/Types.sol";
/// @dev The ISlashing contract's address.
address constant SLASHING_PRECOMPILE_ADDRESS = 0x0000000000000000000000000000000000000806;
/// @dev The ISlashing contract's instance.
ISlashing constant SLASHING_CONTRACT = ISlashing(SLASHING_PRECOMPILE_ADDRESS);
/// @dev SigningInfo defines a validator's signing info for monitoring their
/// liveness activity.
struct SigningInfo {
/// @dev Address of the validator
address validatorAddress;
/// @dev Height at which validator was first a candidate OR was unjailed
int64 startHeight;
/// @dev Index offset into signed block bit array
int64 indexOffset;
/// @dev Timestamp until which validator is jailed due to liveness downtime
int64 jailedUntil;
/// @dev Whether or not a validator has been tombstoned (killed out of validator set)
bool tombstoned;
/// @dev Missed blocks counter (to avoid scanning the array every time)
int64 missedBlocksCounter;
}
/// @dev Params defines the parameters for the slashing module.
struct Params {
/// @dev SignedBlocksWindow defines how many blocks the validator should have signed
int64 signedBlocksWindow;
/// @dev MinSignedPerWindow defines the minimum blocks signed per window to avoid slashing
Dec minSignedPerWindow;
/// @dev DowntimeJailDuration defines how long the validator will be jailed for downtime
int64 downtimeJailDuration;
/// @dev SlashFractionDoubleSign defines the percentage of slash for double sign
Dec slashFractionDoubleSign;
/// @dev SlashFractionDowntime defines the percentage of slash for downtime
Dec slashFractionDowntime;
}
/// @author Evmos Team
/// @title Slashing Precompiled Contract
/// @dev The interface through which solidity contracts will interact with slashing.
/// We follow this same interface including four-byte function selectors, in the precompile that
/// wraps the pallet.
/// @custom:address 0x0000000000000000000000000000000000000806
interface ISlashing {
/// @dev Emitted when a validator is unjailed
/// @param validator The address of the validator
event ValidatorUnjailed(address indexed validator);
/// @dev GetSigningInfo returns the signing info for a specific validator.
/// @param consAddress The validator consensus address
/// @return signingInfo The validator signing info
function getSigningInfo(
address consAddress
) external view returns (SigningInfo memory signingInfo);
/// @dev GetSigningInfos returns the signing info for all validators.
/// @param pagination Pagination configuration for the query
/// @return signingInfos The list of validator signing info
/// @return pageResponse Pagination information for the response
function getSigningInfos(
PageRequest calldata pagination
) external view returns (SigningInfo[] memory signingInfos, PageResponse memory pageResponse);
/// @dev Unjail allows validators to unjail themselves after being jailed for downtime
/// @param validatorAddress The validator operator address to unjail
/// @return success true if the unjail operation was successful
function unjail(address validatorAddress) external returns (bool success);
/// @dev GetParams returns the slashing module parameters
/// @return params The slashing module parameters
function getParams() external view returns (Params memory params);
}