CSStrikes
CSStrikes.sol
is a utility contract that stores information about strikes assigned to the CSM validators by CSM Performance Oracle. It has a permissionless method to prove that a particular validator should be ejected because the number of strikes is above the threshold for this validator. It calls CSEjector.sol
to perform a strikes threshold check and eject the validator.
Upgradability
The contract uses OssifiableProxy for upgradability.
State Variables
ORACLE
address public immutable ORACLE;
MODULE
ICSModule public immutable MODULE;
ACCOUNTING
ICSAccounting public immutable ACCOUNTING;
EXIT_PENALTIES
ICSExitPenalties public immutable EXIT_PENALTIES;
PARAMETERS_REGISTRY
ICSParametersRegistry public immutable PARAMETERS_REGISTRY;
ejector
ICSEjector public ejector;
treeRoot
The latest Merkle Tree root
bytes32 public treeRoot;
treeCid
CID of the last published Merkle tree
string public treeCid;
Functions
setEjector
Set the address of the Ejector contract
function setEjector(address _ejector) external onlyRole(DEFAULT_ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
_ejector | address | Address of the Ejector contract |
processOracleReport
Receive the data of the Merkle tree from the Oracle contract and process it
New tree might be empty and it is valid value because of strikesLifetime
function processOracleReport(bytes32 _treeRoot, string calldata _treeCid) external onlyOracle;
Parameters
Name | Type | Description |
---|---|---|
_treeRoot | bytes32 | Root of the Merkle tree |
_treeCid | string | an IPFS CID of the tree |
processBadPerformanceProof
Report multiple CSM keys as bad performing
function processBadPerformanceProof(
KeyStrikes[] calldata keyStrikesList,
bytes32[] calldata proof,
bool[] calldata proofFlags,
address refundRecipient
) external payable;
Parameters
Name | Type | Description |
---|---|---|
keyStrikesList | KeyStrikes[] | List of KeyStrikes structs |
proof | bytes32[] | Multi-proof of the strikes |
proofFlags | bool[] | Flags to process the multi-proof, see OZ processMultiProof |
refundRecipient | address | Address to send the refund to |
getInitializedVersion
Returns the initialized version of the contract
function getInitializedVersion() external view returns (uint64);
verifyProof
Check the contract accepts the provided multi-proof
function verifyProof(
KeyStrikes[] calldata keyStrikesList,
bytes[] memory pubkeys,
bytes32[] calldata proof,
bool[] calldata proofFlags
) public view returns (bool);
Parameters
Name | Type | Description |
---|---|---|
keyStrikesList | KeyStrikes[] | List of KeyStrikes structs |
pubkeys | bytes[] | |
proof | bytes32[] | Multi-proof of the strikes |
proofFlags | bool[] | Flags to process the multi-proof, see OZ processMultiProof |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool True if proof is accepted |
hashLeaf
Get a hash of a leaf a tree of strikes
Double hash the leaf to prevent second pre-image attacks
function hashLeaf(KeyStrikes calldata keyStrikes, bytes memory pubkey) public pure returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
keyStrikes | KeyStrikes | KeyStrikes struct |
pubkey | bytes | Public key |
Returns
Name | Type | Description |
---|---|---|
<none> | bytes32 | Hash of the leaf |
Events
StrikesDataUpdated
Emitted when strikes data is updated
event StrikesDataUpdated(bytes32 treeRoot, string treeCid);
StrikesDataWiped
Emitted when strikes is updated from non-empty to empty
event StrikesDataWiped();
EjectorSet
event EjectorSet(address ejector);