本文档介绍了EigenLayer协议中用于处理slash资金的SlashEscrowFactory合约。该工厂合约负责在AVS调用slashOperator后执行escrow延迟,为每次slash部署SlashEscrow合约,并在escrow延迟完成后从escrow合约释放资金。SlashEscrowFactory还定义了初始化和释放escrow的函数。
| 文件 | 备注 | 
|---|---|
SlashEscrowFactory.sol | 
单个 slash escrow 工厂 | 
SlashEscrowFactoryStorage.sol | 
状态变量 | 
ISlashEscrowFactory.sol | 
接口 | 
SlashEscrow:
| 文件 | 备注 | 
|---|---|
SlashEscrow.sol | 
实例,为每个 OperatorSet、slashId 部署,用于存储被罚没的资金 | 
ISlashEscrow.sol | 
接口 | 
SlashEscrowFactory 处理从 EigenLayer 协议中罚没资金的燃烧或重新分配。SlashEscrowFactory 负责 (i) 在 AVS 调用 slashOperator 时,强制执行 escrow 延迟, (ii) 为每次罚没部署 SlashEscrow,以及 (iii) 在 escrow 延迟完成后,从 escrow 合同中释放资金。
DEFAULT_BURN_ADDRESS = 0x00000000000000000000000000000000000E16E4
_globalEscrowDelayBlocks = 28800 (以区块计,4 天)
5 (以区块计,1 分钟)对于 AVS 触发的每次罚没,都会启动一个 escrow。一个 slash 可以包含多个策略,并且对于每个 operatorSet 和 slashId 都是唯一的。
SlashEscrowFactory.initiateSlashEscrow
SlashEscrowFactory.releaseSlashEscrow
*SlashEscrowFactory.releaseSlashEscrowByStrategy
initiateSlashEscrow/**
 * @notice 锁定一个 escrow。
 * @param operatorSet 其 escrow 被锁定的 operator set。
 * @param slashId 被锁定的 escrow 的 slash ID。
 * @param strategy 正在重新分配其底层代币的策略。
 * @dev 对于给定的 `operatorSet` 和 `slashId`,可以多次调用此函数。
 */
function initiateSlashEscrow(
    OperatorSet calldata operatorSet, 
    uint256 slashId, 
    IStrategy strategy) 
external onlyStrategyManager;
为给定的 operatorSet、slashId 和 strategy 启动一个 escrow。 StrategyManager 可以在同一交易中多次调用此函数,因为单个 slash 可以包含多个策略。 operatorSet、slashId 和 strategy 各自存储在 EnumerableSet 中。
影响:
SlashEscrow 合同已部署operatorSet 添加到 pendingOperatorSetsslashId 添加到 operatorSet 的 pendingSlashIdspendingStrategiesForSlashIdStartEscrow 事件要求:
StrategyManager 调用deploySlashEscrow/**
 * @notice 如果代码尚未部署,则部署一个反事实的 `SlashEscrow`。
 * @param operatorSet 其 slash escrow 正在部署的 operator set。
 * @param slashId 正在部署的 slash escrow 的 slash ID。
 */
function _deploySlashEscrow(
    OperatorSet calldata operatorSet, 
    uint256 slashId) 
internal;
内部函数在 initiateEscrow 上调用。 为每个 operatorSet 和 slashId 部署一个唯一的 slash escrow 合同
SlashEscrow 使用 Open Zeppelin 的 Clones Upgradeable Library 以确定方式部署,这是一个最小的、不可升级的代理。 部署 salt 是 operatorSet 和 slashId 的串联,它们共同保证是唯一的。
releaseSlashEscrow/**
 * @notice 通过将代币从 `SlashEscrow` 转移到 operator set 的重新分配接收者来释放 escrow。
 * @param operatorSet 其 escrow 正在释放的 operator set。
 * @param slashId 正在释放的 escrow 的 slash ID。
 * @dev 调用者必须是 escrow 接收者,除非 escrow 接收者
 * 是默认的燃烧地址,在这种情况下,任何人都可以调用。
 * @dev 一旦**所有**策略的延迟都已过去,slash escrow 就会被释放。
 */
function releaseSlashEscrow(
    OperatorSet calldata operatorSet, 
    uint256 slashId)
external onlyWhenNotPaused(PAUSED_RELEASE_ESCROW);
/**
 * @notice 释放 slash 中单个策略的 escrow。
 * @param operatorSet 其 escrow 正在释放的 operator set。
 * @param slashId 正在释放的 escrow 的 slash ID。
 * @param strategy 正在释放其 escrow 的策略。
 * @dev 调用者必须是重新分配接收者,除非重新分配接收者
 * 是默认的燃烧地址,在这种情况下,任何人都可以调用。
 * @dev 一旦**所有**策略的延迟都已过去,slash escrow 就会被释放。
 */
function releaseSlashEscrowByStrategy(
    OperatorSet calldata operatorSet,
    uint256 slashId,
    IStrategy strategy
) external;
在 getEscrowCompleteBlock 之时或之后,代币将从 SlashEscrow 合同转移到 operatorSet 的 redistributionRecipient。
对于 slash 中的每个 strategy,代币将从 slash 唯一的 SlashEscrow 合同转移到 redistributionRecipient。
为了适应可以添加到 operatorSet 的无限数量的策略,以及阻止其他代币释放的代币转账还原,用户可以通过 releaseSlashEscrowByStrategy 从 escrow 中释放单个策略。
影响:
StrategyManager.clearBurnOrRedistributableShares。 此函数可能已事先调用过,如果是这样,它将不执行任何操作。 我们再次调用它以确保所有代币都转移到 SlashEscrow 合同。 对于 releaseEscrowByStrategy,我们调用按策略的变体:StrategyManager.clearBurnOrRedistributableSharesByStrategySlashEscrow.releaseTokensEscrowComplete_pendingStrategiesForSlashId 中删除 strategy_pendingSlashIds 中删除 slashIdslashId 的开始区块operatorSet 没有更多 pending slashes,则将其从 pendingOperatorSets 中删除要求:
PAUSED_RELEASE_ESCROWpauseEscrowredistributionRecipient从 SlashEscrowFactory 部署的最小代理合同。 此合同在 escrow 过期后释放资金。
releaseTokens/**
 * @notice 燃烧或重新分配策略的底层代币。
 * @param slashEscrowFactory 创建 slash escrow 的工厂合同。
 * @param slashEscrowImplementation 用于创建 slash escrow 的实现合同。
 * @param operatorSet 用于创建 slash escrow 的 operator set。
 * @param slashId 用于创建 slash escrow 的 slash ID。
 * @param recipient 底层代币的接收者。
 * @param strategy 用于创建 slash escrow 的策略。
 */
function releaseTokens(
    ISlashEscrowFactory slashEscrowFactory,
    ISlashEscrow slashEscrowImplementation,
    OperatorSet calldata operatorSet,
    uint256 slashId,
    address recipient,
    IStrategy strategy
) external;
将此合同针对给定 strategy 的 underlyingToken 的余额发送给 recipient。 slashEscrowFactory、slashEscrowImplementation、operatorSet 和 slashId 被传入以验证合同的部署参数,从而使此合同没有存储。
影响:
underlyingToken 的余额转移到 redistributionRecipient要求:
ClonesUpgradeable.predictDeterministicAddress 的输出匹配SlashEscrowFactorySlashEscrowFactory 的 owner 可以更新 _globalEscrowDelayBlocks 和每个策略的 _strategyEscrowDelayBlocks。 对于给定的策略,其延迟由 max(_globalEscrowDelayBlocks, _strategyEscrowDelayBlocks) 给出。 对于具有多个策略的 escrow,释放它的总时间是每个策略延迟的最大值。
以下方法涉及 owner 及其在 SlashEscrowFactory 中的能力
setGlobalEscrowDelay/**
 * @notice 全局设置所有策略底层代币的 escrow 延迟。
 * @param delay escrow 的延迟。
 */
function setGlobalEscrowDelay(
    uint32 delay
) external onlyOwner;
设置所有策略观察到的全局 escrow 延迟。 注意:如果此值已更新,则所有先前的 escrow 都将观察到新的延迟。
影响:
_globalEscrowDelayBlocksGlobalEscrowDelaySet 事件要求:
ownersetStrategyEscrowDelay/**
 * @notice 设置策略底层代币的 escrow 延迟。
 * @dev 使用策略和全局延迟的最大值
 * @param strategy 其 escrow 延迟正在设置的策略。
 * @param delay escrow 的延迟。
 */
function setStrategyEscrowDelay(
    IStrategy strategy, 
    uint32 delay
) external onlyOwner;
设置给定策略的延迟。 注意:如果此值已更新,则所有先前的 escrow 都将观察到新的延迟。
影响:
strategy 的 _strategyEscrowDelayBlocksStrategyEscrowDelaySet 事件要求:
owner
- 原文链接: github.com/Layr-Labs/eig...
 - 登链社区 AI 助手,为大家转译优秀英文文章,如有翻译不通的地方,还请包涵~
 
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!