ValidatorDetails

Git Source

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.

swapValidatorDetails

Swap operator detail indexes in storage.

function swapValidatorDetails(
    bytes32 position,
    uint8 operatorId,
    uint256 startIndex1,
    uint256 startIndex2,
    uint256 keysCount
) internal;

Parameters

NameTypeDescription

position

bytes32

The storage slot.

operatorId

uint8

The operator ID.

startIndex1

uint256

The start index of the first set of keys.

startIndex2

uint256

The start index of the second set of keys.

keysCount

uint256

Keys count to swap.

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).

allocateMemoryForPubKeys

Allocate memory for keyCount public keys.

function allocateMemoryForPubKeys(uint256 keyCount) internal pure returns (bytes memory);

Parameters

NameTypeDescription

keyCount

uint256

The number of public 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.

ValidatorDetailsSwapped

Emitted when the indexes of two validator signing keys are swapped.

event ValidatorDetailsSwapped(uint8 indexed operatorId, bytes pubkey1, bytes pubkey2);

Parameters

NameTypeDescription

operatorId

uint8

The operator ID.

pubkey1

bytes

The first validator public key.

pubkey2

bytes

The second validator public key.

Errors

INVALID_KEYS_COUNT

Thrown when the number of keys is invalid.

error INVALID_KEYS_COUNT();

INDEXES_OVERLAP

Thrown when the indexes of keys overlap.

error INDEXES_OVERLAP();

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