SlashEscrowFactory:Slash资金托管工厂

  • Layr-Labs
  • 发布于 2025-07-03 22:38
  • 阅读 21

本文档介绍了EigenLayer协议中用于处理slash资金的SlashEscrowFactory合约。该工厂合约负责在AVS调用slashOperator后执行escrow延迟,为每次slash部署SlashEscrow合约,并在escrow延迟完成后从escrow合约释放资金。SlashEscrowFactory还定义了初始化和释放escrow的函数。

文件 备注
SlashEscrowFactory.sol 单个 slash escrow 工厂
SlashEscrowFactoryStorage.sol 状态变量
ISlashEscrowFactory.sol 接口

SlashEscrow:

文件 备注
SlashEscrow.sol 实例,为每个 OperatorSetslashId 部署,用于存储被罚没的资金
ISlashEscrow.sol 接口

概览

SlashEscrowFactory 处理从 EigenLayer 协议中罚没资金的燃烧或重新分配。SlashEscrowFactory 负责 (i) 在 AVS 调用 slashOperator 时,强制执行 escrow 延迟, (ii) 为每次罚没部署 SlashEscrow,以及 (iii) 在 escrow 延迟完成后,从 escrow 合同中释放资金。

参数化

  • DEFAULT_BURN_ADDRESS = 0x00000000000000000000000000000000000E16E4
    • 燃烧资金发送到的地址
  • _globalEscrowDelayBlocks = 28800 (以区块计,4 天)
    • 在测试网上,该值为 5 (以区块计,1 分钟)

启动和释放 Escrow

对于 AVS 触发的每次罚没,都会启动一个 escrow。一个 slash 可以包含多个策略,并且对于每个 operatorSetslashId 都是唯一的。

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;

为给定的 operatorSetslashIdstrategy 启动一个 escrow。 StrategyManager 可以在同一交易中多次调用此函数,因为单个 slash 可以包含多个策略。 operatorSetslashIdstrategy 各自存储在 EnumerableSet 中。

影响:

  • 如果 operatorSet 和 slashID 尚未设置为 pending:
    • SlashEscrow 合同已部署
    • operatorSet 添加到 pendingOperatorSets
    • slashId 添加到 operatorSet 的 pendingSlashIds
  • 将策略添加到 pendingStrategiesForSlashId
  • 发出 StartEscrow 事件

要求:

  • 只能由 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 上调用。 为每个 operatorSetslashId 部署一个唯一的 slash escrow 合同

SlashEscrow 使用 Open Zeppelin 的 Clones Upgradeable Library 以确定方式部署,这是一个最小的、不可升级的代理。 部署 salt 是 operatorSetslashId 的串联,它们共同保证是唯一的。

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 合同转移到 operatorSetredistributionRecipient

对于 slash 中的每个 strategy,代币将从 slash 唯一的 SlashEscrow 合同转移到 redistributionRecipient

为了适应可以添加到 operatorSet 的无限数量的策略,以及阻止其他代币释放的代币转账还原,用户可以通过 releaseSlashEscrowByStrategy 从 escrow 中释放单个策略。

影响:

  • 调用 StrategyManager.clearBurnOrRedistributableShares。 此函数可能已事先调用过,如果是这样,它将不执行任何操作。 我们再次调用它以确保所有代币都转移到 SlashEscrow 合同。 对于 releaseEscrowByStrategy,我们调用按策略的变体:StrategyManager.clearBurnOrRedistributableSharesByStrategy
  • 对于每个策略:
  • 如果 operatorSet/slashId 中的所有策略都已释放:
    • _pendingSlashIds 中删除 slashId
    • 删除 slashId 的开始区块
  • 如果 operatorSet 没有更多 pending slashes,则将其从 pendingOperatorSets 中删除

要求:

  • 必须未设置全局暂停状态:PAUSED_RELEASE_ESCROW
  • 必须未设置 escrow 暂停状态:pauseEscrow
  • 如果 operatorSet 可重新分配,则调用者必须是 redistributionRecipient
  • escrow 延迟必须已经过去

SlashEscrow

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 的余额发送给 recipientslashEscrowFactoryslashEscrowImplementationoperatorSetslashId 被传入以验证合同的部署参数,从而使此合同没有存储。

影响:

  • 将策略的 underlyingToken 的余额转移到 redistributionRecipient

要求:

  • 传入的 Calldata 必须与 ClonesUpgradeable.predictDeterministicAddress 的输出匹配
  • 调用者必须是 SlashEscrowFactory

系统配置

SlashEscrowFactoryowner 可以更新 _globalEscrowDelayBlocks 和每个策略的 _strategyEscrowDelayBlocks。 对于给定的策略,其延迟由 max(_globalEscrowDelayBlocks, _strategyEscrowDelayBlocks) 给出。 对于具有多个策略的 escrow,释放它的总时间是每个策略延迟的最大值。

以下方法涉及 owner 及其在 SlashEscrowFactory 中的能力

setGlobalEscrowDelay

/**
 * @notice 全局设置所有策略底层代币的 escrow 延迟。
 * @param delay escrow 的延迟。
 */
function setGlobalEscrowDelay(
    uint32 delay
) external onlyOwner;

设置所有策略观察到的全局 escrow 延迟。 注意:如果此值已更新,则所有先前的 escrow 都将观察到新的延迟。

影响:

  • 设置 _globalEscrowDelayBlocks
  • 发出 GlobalEscrowDelaySet 事件

要求:

  • 调用者必须是 owner

setStrategyEscrowDelay

/**
 * @notice 设置策略底层代币的 escrow 延迟。
 * @dev 使用策略和全局延迟的最大值
 * @param strategy 其 escrow 延迟正在设置的策略。
 * @param delay escrow 的延迟。
 */
function setStrategyEscrowDelay(
    IStrategy strategy, 
    uint32 delay
) external onlyOwner;

设置给定策略的延迟。 注意:如果此值已更新,则所有先前的 escrow 都将观察到新的延迟。

影响:

  • 更新给定 strategy_strategyEscrowDelayBlocks
  • 发出 StrategyEscrowDelaySet 事件

要求:

  • 调用者必须是 owner
  • 原文链接: github.com/Layr-Labs/eig...
  • 登链社区 AI 助手,为大家转译优秀英文文章,如有翻译不通的地方,还请包涵~
点赞 0
收藏 0
分享
本文参与登链社区写作激励计划 ,好文好收益,欢迎正在阅读的你也加入。

0 条评论

请先 登录 后评论
Layr-Labs
Layr-Labs
江湖只有他的大名,没有他的介绍。