ISlasher

Git Source

Author: Layr Labs, Inc.

Terms of Service: https://docs.eigenlayer.xyz/overview/terms-of-service

See the Slasher contract itself for implementation details.

Functions

optIntoSlashing

Gives the contractAddress permission to slash the funds of the caller.

Typically, this function must be called prior to registering for a middleware.

function optIntoSlashing(address contractAddress) external;

freezeOperator

Used for 'slashing' a certain operator.

Technically the operator is 'frozen' (hence the name of this function), and then subject to slashing pending a decision by a human-in-the-loop.

The operator must have previously given the caller (which should be a contract) the ability to slash them, through a call to optIntoSlashing.

function freezeOperator(address toBeFrozen) external;

Parameters

NameTypeDescription

toBeFrozen

address

The operator to be frozen.

resetFrozenStatus

Removes the 'frozen' status from each of the frozenAddresses

Callable only by the contract owner (i.e. governance).

function resetFrozenStatus(address[] calldata frozenAddresses) external;

recordFirstStakeUpdate

this function is a called by middlewares during an operator's registration to make sure the operator's stake at registration is slashable until serveUntil

adds the middleware's slashing contract to the operator's linked list

function recordFirstStakeUpdate(address operator, uint32 serveUntilBlock) external;

Parameters

NameTypeDescription

operator

address

the operator whose stake update is being recorded

serveUntilBlock

uint32

the block until which the operator's stake at the current block is slashable

recordStakeUpdate

this function is a called by middlewares during a stake update for an operator (perhaps to free pending withdrawals) to make sure the operator's stake at updateBlock is slashable until serveUntil

insertAfter should be calculated offchain before making the transaction that calls this. this is subject to race conditions, but it is anticipated to be rare and not detrimental.

function recordStakeUpdate(address operator, uint32 updateBlock, uint32 serveUntilBlock, uint256 insertAfter)
    external;

Parameters

NameTypeDescription

operator

address

the operator whose stake update is being recorded

updateBlock

uint32

the block for which the stake update is being recorded

serveUntilBlock

uint32

the block until which the operator's stake at updateBlock is slashable

insertAfter

uint256

the element of the operators linked list that the currently updating middleware should be inserted after

recordLastStakeUpdateAndRevokeSlashingAbility

this function is a called by middlewares during an operator's deregistration to make sure the operator's stake at deregistration is slashable until serveUntil

removes the middleware's slashing contract to the operator's linked list and revokes the middleware's (i.e. caller's) ability to slash operator once serveUntil is reached

function recordLastStakeUpdateAndRevokeSlashingAbility(address operator, uint32 serveUntilBlock) external;

Parameters

NameTypeDescription

operator

address

the operator whose stake update is being recorded

serveUntilBlock

uint32

the block until which the operator's stake at the current block is slashable

strategyManager

The StrategyManager contract of EigenLayer

function strategyManager() external view returns (IStrategyManager);

delegation

The DelegationManager contract of EigenLayer

function delegation() external view returns (IDelegationManager);

isFrozen

Used to determine whether staker is actively 'frozen'. If a staker is frozen, then they are potentially subject to slashing of their funds, and cannot cannot deposit or withdraw from the strategyManager until the slashing process is completed and the staker's status is reset (to 'unfrozen').

function isFrozen(address staker) external view returns (bool);

Parameters

NameTypeDescription

staker

address

The staker of interest.

Returns

NameTypeDescription

<none>

bool

Returns 'true' if staker themselves has their status set to frozen, OR if the staker is delegated to an operator who has their status set to frozen. Otherwise returns 'false'.

canSlash

Returns true if slashingContract is currently allowed to slash toBeSlashed.

function canSlash(address toBeSlashed, address slashingContract) external view returns (bool);

contractCanSlashOperatorUntilBlock

Returns the block until which serviceContract is allowed to slash the operator.

function contractCanSlashOperatorUntilBlock(address operator, address serviceContract) external view returns (uint32);

latestUpdateBlock

Returns the block at which the serviceContract last updated its view of the operator's stake

function latestUpdateBlock(address operator, address serviceContract) external view returns (uint32);

getCorrectValueForInsertAfter

A search routine for finding the correct input value of insertAfter to recordStakeUpdate / _updateMiddlewareList.

function getCorrectValueForInsertAfter(address operator, uint32 updateBlock) external view returns (uint256);

canWithdraw

Returns 'true' if operator can currently complete a withdrawal started at the withdrawalStartBlock, with middlewareTimesIndex used to specify the index of a MiddlewareTimes struct in the operator's list (i.e. an index in operatorToMiddlewareTimes[operator]). The specified struct is consulted as proof of the operator's ability (or lack thereof) to complete the withdrawal. This function will return 'false' if the operator cannot currently complete a withdrawal started at the withdrawalStartBlock, or in the event that an incorrect middlewareTimesIndex is supplied, even if one or more correct inputs exist.

The correct middlewareTimesIndex input should be computable off-chain.

function canWithdraw(address operator, uint32 withdrawalStartBlock, uint256 middlewareTimesIndex)
    external
    returns (bool);

Parameters

NameTypeDescription

operator

address

Either the operator who queued the withdrawal themselves, or if the withdrawing party is a staker who delegated to an operator, this address is the operator who the staker was delegated to at the time of the withdrawalStartBlock.

withdrawalStartBlock

uint32

The block number at which the withdrawal was initiated.

middlewareTimesIndex

uint256

Indicates an index in operatorToMiddlewareTimes[operator] to consult as proof of the operator's ability to withdraw

operatorToMiddlewareTimes

operator => [ ( the least recent update block of all of the middlewares it's serving/served, latest time that the stake bonded at that update needed to serve until ) ]

function operatorToMiddlewareTimes(address operator, uint256 arrayIndex)
    external
    view
    returns (MiddlewareTimes memory);

middlewareTimesLength

Getter function for fetching operatorToMiddlewareTimes[operator].length

function middlewareTimesLength(address operator) external view returns (uint256);

getMiddlewareTimesIndexStalestUpdateBlock

Getter function for fetching operatorToMiddlewareTimes[operator][index].stalestUpdateBlock.

function getMiddlewareTimesIndexStalestUpdateBlock(address operator, uint32 index) external view returns (uint32);

getMiddlewareTimesIndexServeUntilBlock

Getter function for fetching operatorToMiddlewareTimes[operator][index].latestServeUntil.

function getMiddlewareTimesIndexServeUntilBlock(address operator, uint32 index) external view returns (uint32);

operatorWhitelistedContractsLinkedListSize

Getter function for fetching _operatorToWhitelistedContractsByUpdate[operator].size.

function operatorWhitelistedContractsLinkedListSize(address operator) external view returns (uint256);

operatorWhitelistedContractsLinkedListEntry

Getter function for fetching a single node in the operator's linked list (_operatorToWhitelistedContractsByUpdate[operator]).

function operatorWhitelistedContractsLinkedListEntry(address operator, address node)
    external
    view
    returns (bool, uint256, uint256);

Events

MiddlewareTimesAdded

Emitted when a middleware times is added to operator's array.

event MiddlewareTimesAdded(address operator, uint256 index, uint32 stalestUpdateBlock, uint32 latestServeUntilBlock);

OptedIntoSlashing

Emitted when operator begins to allow contractAddress to slash them.

event OptedIntoSlashing(address indexed operator, address indexed contractAddress);

SlashingAbilityRevoked

Emitted when contractAddress signals that it will no longer be able to slash operator after the contractCanSlashOperatorUntilBlock.

event SlashingAbilityRevoked(
    address indexed operator, address indexed contractAddress, uint32 contractCanSlashOperatorUntilBlock
);

OperatorFrozen

Emitted when slashingContract 'freezes' the slashedOperator.

The slashingContract must have permission to slash the slashedOperator, i.e. canSlash(slasherOperator, slashingContract) must return 'true'.

event OperatorFrozen(address indexed slashedOperator, address indexed slashingContract);

FrozenStatusReset

Emitted when previouslySlashedAddress is 'unfrozen', allowing them to again move deposited funds within EigenLayer.

event FrozenStatusReset(address indexed previouslySlashedAddress);

Structs

MiddlewareTimes

struct used to store information about the current state of an operator's obligations to middlewares they are serving

struct MiddlewareTimes {
    uint32 stalestUpdateBlock;
    uint32 latestServeUntilBlock;
}

MiddlewareDetails

struct used to store details relevant to a single middleware that an operator has opted-in to serving

struct MiddlewareDetails {
    uint32 registrationMayBeginAtBlock;
    uint32 contractCanSlashOperatorUntilBlock;
    uint32 latestUpdateBlock;
}

Last updated