ValidatorDetails

ValidatorDetails

Modified from KRogLA's work for Lido.

State Variables

PUBKEY_LENGTH

The validator pubkey byte length.

uint256 internal constant PUBKEY_LENGTH = 48;

SIGNATURE_LENGTH

The validator signature byte length.

uint256 internal constant SIGNATURE_LENGTH = 96;

UINT40_MAX

The maximum uint40 value.

uint256 internal constant UINT40_MAX = type(uint40).max;

Functions

computeStorageKeyOffset

Compute the storage key offset.

function computeStorageKeyOffset(bytes32 position, uint8 operatorId, uint256 keyIndex)
    internal
    pure
    returns (uint256);

Parameters

NameTypeDescription

position

bytes32

The storage slot.

operatorId

uint8

The operator ID.

keyIndex

uint256

The key index.

saveValidatorDetails

Store operator details.

function saveValidatorDetails(
    bytes32 position,
    uint8 operatorId,
    uint256 startIndex,
    uint256 keysCount,
    bytes memory pubkeys,
    bytes memory signatures
) internal returns (uint40);

Parameters

NameTypeDescription

position

bytes32

The storage slot.

operatorId

uint8

The operator ID.

startIndex

uint256

The start index.

keysCount

uint256

Keys count to load.

pubkeys

bytes

Keys buffer to read from.

signatures

bytes

Signatures buffer to read from.

Returns

NameTypeDescription

<none>

uint40

totalKeysCount New total keys count.

removeValidatorDetails

Remove validator details from storage.

function removeValidatorDetails(
    bytes32 position,
    uint8 operatorId,
    uint256 startIndex,
    uint256 keysCount,
    uint256 totalKeysCount
) internal returns (uint40);

Parameters

NameTypeDescription

position

bytes32

The storage slot.

operatorId

uint8

The Operator ID.

startIndex

uint256

The start index.

keysCount

uint256

Keys count to load.

totalKeysCount

uint256

Current total keys count for operator.

Returns

NameTypeDescription

<none>

uint40

totalKeysCount New total keys count.

loadValidatorDetails

Load validator details from storage.

function loadValidatorDetails(
    bytes32 position,
    uint8 operatorId,
    uint256 startIndex,
    uint256 keysCount,
    bytes memory pubkeys,
    bytes memory signatures,
    uint256 bufferOffset
) internal view;

Parameters

NameTypeDescription

position

bytes32

The storage slot.

operatorId

uint8

The operator ID.

startIndex

uint256

The start index.

keysCount

uint256

Keys count to load.

pubkeys

bytes

Pre-allocated key buffer to read in.

signatures

bytes

Pre-allocated signature buffer to read in.

bufferOffset

uint256

start offset in pubkeys/signatures buffer to place values (in number of keys).

allocateMemory

Allocate memory for count validator details.

function allocateMemory(uint256 count) internal pure returns (bytes memory, bytes memory);

Parameters

NameTypeDescription

count

uint256

The number of validators.

Events

ValidatorDetailsAdded

Emitted when a new validator signing key is added.

event ValidatorDetailsAdded(uint8 indexed operatorId, bytes pubkey);

Parameters

NameTypeDescription

operatorId

uint8

The operator ID.

pubkey

bytes

The validator public key.

ValidatorDetailsRemoved

Emitted when a validator signing key is removed.

event ValidatorDetailsRemoved(uint8 indexed operatorId, bytes pubkey);

Parameters

NameTypeDescription

operatorId

uint8

The operator ID.

pubkey

bytes

The validator public key.

Errors

INVALID_KEYS_COUNT

Thrown when the number of keys is invalid.

error INVALID_KEYS_COUNT();

LENGTH_MISMATCH

Thrown when the keys and signatures lengths mismatch.

error LENGTH_MISMATCH();

EMPTY_KEY

Thrown when the key is empty.

error EMPTY_KEY();

Last updated