IStakeRegistry

Git Source

Inherits: IRegistry

Author: Layr Labs, Inc.

Functions

registerOperator

Registers the operator with operatorId for the specified quorumNumbers.

access restricted to the RegistryCoordinator

*Preconditions (these are assumed, not validated in this contract):

  1. quorumNumbers has no duplicates

  2. quorumNumbers.length != 0

  3. quorumNumbers is ordered in ascending order

  4. the operator is not already registered*

function registerOperator(address operator, bytes32 operatorId, bytes memory quorumNumbers) external;

Parameters

NameTypeDescription

operator

address

The address of the operator to register.

operatorId

bytes32

The id of the operator to register.

quorumNumbers

bytes

The quorum numbers the operator is registering for, where each byte is an 8 bit integer quorumNumber.

deregisterOperator

Deregisters the operator with operatorId for the specified quorumNumbers.

access restricted to the RegistryCoordinator

*Preconditions (these are assumed, not validated in this contract):

  1. quorumNumbers has no duplicates

  2. quorumNumbers.length != 0

  3. quorumNumbers is ordered in ascending order

  4. the operator is not already deregistered

  5. quorumNumbers is a subset of the quorumNumbers that the operator is registered for*

function deregisterOperator(bytes32 operatorId, bytes memory quorumNumbers) external;

Parameters

NameTypeDescription

operatorId

bytes32

The id of the operator to deregister.

quorumNumbers

bytes

The quorum numbers the operator is deregistering from, where each byte is an 8 bit integer quorumNumber.

minimumStakeForQuorum

In order to register for a quorum i, an operator must have at least minimumStakeForQuorum[i]

function minimumStakeForQuorum(uint256 quorumNumber) external view returns (uint96);

getOperatorIdToStakeHistory

Returns the entire operatorIdToStakeHistory[operatorId][quorumNumber] array.

function getOperatorIdToStakeHistory(bytes32 operatorId, uint8 quorumNumber)
    external
    view
    returns (OperatorStakeUpdate[] memory);

Parameters

NameTypeDescription

operatorId

bytes32

The id of the operator of interest.

quorumNumber

uint8

The quorum number to get the stake for.

getLengthOfTotalStakeHistoryForQuorum

function getLengthOfTotalStakeHistoryForQuorum(uint8 quorumNumber) external view returns (uint256);

getTotalStakeUpdateForQuorumFromIndex

Returns the index-th entry in the dynamic array of total stake, totalStakeHistory for quorum quorumNumber.

function getTotalStakeUpdateForQuorumFromIndex(uint8 quorumNumber, uint256 index)
    external
    view
    returns (OperatorStakeUpdate memory);

Parameters

NameTypeDescription

quorumNumber

uint8

The quorum number to get the stake for.

index

uint256

Array index for lookup, within the dynamic array totalStakeHistory[quorumNumber].

getStakeUpdateIndexForOperatorIdForQuorumAtBlockNumber

Returns the indices of the operator stakes for the provided quorumNumber at the given blockNumber

function getStakeUpdateIndexForOperatorIdForQuorumAtBlockNumber(
    bytes32 operatorId,
    uint8 quorumNumber,
    uint32 blockNumber
) external view returns (uint32);

getTotalStakeIndicesByQuorumNumbersAtBlockNumber

Returns the indices of the total stakes for the provided quorumNumbers at the given blockNumber

function getTotalStakeIndicesByQuorumNumbersAtBlockNumber(uint32 blockNumber, bytes calldata quorumNumbers)
    external
    view
    returns (uint32[] memory);

getStakeUpdateForQuorumFromOperatorIdAndIndex

Returns the index-th entry in the operatorIdToStakeHistory[operatorId][quorumNumber] array.

Function will revert if index is out-of-bounds.

function getStakeUpdateForQuorumFromOperatorIdAndIndex(uint8 quorumNumber, bytes32 operatorId, uint256 index)
    external
    view
    returns (OperatorStakeUpdate memory);

Parameters

NameTypeDescription

quorumNumber

uint8

The quorum number to get the stake for.

operatorId

bytes32

The id of the operator of interest.

index

uint256

Array index for lookup, within the dynamic array operatorIdToStakeHistory[operatorId][quorumNumber].

getMostRecentStakeUpdateByOperatorId

Returns the most recent stake weight for the operatorId for a certain quorum

Function returns an OperatorStakeUpdate struct with every entry equal to 0 in the event that the operator has no stake history

function getMostRecentStakeUpdateByOperatorId(bytes32 operatorId, uint8 quorumNumber)
    external
    view
    returns (OperatorStakeUpdate memory);

getStakeForQuorumAtBlockNumberFromOperatorIdAndIndex

Returns the stake weight corresponding to operatorId for quorum quorumNumber, at the index-th entry in the operatorIdToStakeHistory[operatorId][quorumNumber] array if the entry corresponds to the operator's stake at blockNumber. Reverts otherwise.

Function will revert if index is out-of-bounds.

used the BLSSignatureChecker to get past stakes of signing operators

function getStakeForQuorumAtBlockNumberFromOperatorIdAndIndex(
    uint8 quorumNumber,
    uint32 blockNumber,
    bytes32 operatorId,
    uint256 index
) external view returns (uint96);

Parameters

NameTypeDescription

quorumNumber

uint8

The quorum number to get the stake for.

blockNumber

uint32

Block number to make sure the stake is from.

operatorId

bytes32

The id of the operator of interest.

index

uint256

Array index for lookup, within the dynamic array operatorIdToStakeHistory[operatorId][quorumNumber].

getTotalStakeAtBlockNumberFromIndex

Returns the total stake weight for quorum quorumNumber, at the index-th entry in the totalStakeHistory[quorumNumber] array if the entry corresponds to the total stake at blockNumber. Reverts otherwise.

Function will revert if index is out-of-bounds.

used the BLSSignatureChecker to get past stakes of signing operators

function getTotalStakeAtBlockNumberFromIndex(uint8 quorumNumber, uint32 blockNumber, uint256 index)
    external
    view
    returns (uint96);

Parameters

NameTypeDescription

quorumNumber

uint8

The quorum number to get the stake for.

blockNumber

uint32

Block number to make sure the stake is from.

index

uint256

Array index for lookup, within the dynamic array totalStakeHistory[quorumNumber].

getCurrentOperatorStakeForQuorum

Returns the most recent stake weight for the operatorId for quorum quorumNumber

Function returns weight of 0 in the event that the operator has no stake history

function getCurrentOperatorStakeForQuorum(bytes32 operatorId, uint8 quorumNumber) external view returns (uint96);

getStakeForOperatorIdForQuorumAtBlockNumber

Returns the stake of the operator for the provided quorumNumber at the given blockNumber

function getStakeForOperatorIdForQuorumAtBlockNumber(bytes32 operatorId, uint8 quorumNumber, uint32 blockNumber)
    external
    view
    returns (uint96);

getCurrentTotalStakeForQuorum

Returns the stake weight from the latest entry in _totalStakeHistory for quorum quorumNumber.

Will revert if _totalStakeHistory[quorumNumber] is empty.

function getCurrentTotalStakeForQuorum(uint8 quorumNumber) external view returns (uint96);

updateStakes

Used for updating information on deposits of nodes.

function updateStakes(address[] memory operators) external;

Parameters

NameTypeDescription

operators

address[]

are the addresses of the operators whose stake information is getting updated

Events

StakeUpdate

emitted whenever the stake of operator is updated

event StakeUpdate(bytes32 indexed operatorId, uint8 quorumNumber, uint96 stake);

MinimumStakeForQuorumUpdated

event MinimumStakeForQuorumUpdated(uint8 indexed quorumNumber, uint96 minimumStake);

Structs

OperatorStakeUpdate

struct used to store the stakes of an individual operator or the sum of all operators' stakes, for storage

struct OperatorStakeUpdate {
    uint32 updateBlockNumber;
    uint32 nextUpdateBlockNumber;
    uint96 stake;
}

Last updated