EIPs Explained

EIP-7886 · Stagnant(停滞) · Core(核心) · 2025-02-18

EIP-7886: Delayed execution

一项已停滞的提案:让验证者在运行区块中的交易之前就对执行区块作出证明,只检查廉价的静态规则,把执行结果推迟到下一个区块。

它解决什么问题?

如今验证者必须完整执行区块中的每笔交易,才能证明该区块有效。执行位于每个 slot 的关键路径上:证明者要等待它,而这段等待时间限制了区块能安全增长到多大。

EIP-7886 提出延迟执行。区块的有效与否,取决于只需要上一个状态就能完成的检查,而不是运行该区块的结果。证明者可以在 slot 的早期投票,执行则在之后进行。作者认为这会腾出时间,可以支持高得多的 gas 上限。

它如何运作

区块头携带父区块的结果。 区块头不再承诺自己的执行后状态、收据和日志,而是承诺:

  • pre_state_root:本区块交易之前的状态(即父区块执行之后的状态);
  • 父区块的交易根、收据根、日志布隆过滤器和请求哈希;
  • parent_execution_reverted:父区块的执行是否被丢弃。

因此,每个区块的执行输出要晚一个区块才会被检查。

静态验证(不执行)。 节点检查签名、交易类型和费用字段;每个发送者是否为 EOA(或经 EIP-7702 委托的账户);nonce 是否连续;每个发送者是否付得起可能的最大费用(gas × effective price + blob fees)加上 value。纳入 gas 总量(固有 gas 与 EIP-7623 calldata 下限中较大者)不得超过区块头声明的 gas_used,且 blob gas 必须完全匹配。

带区块级快照的执行。 先向发送者预收取其最大费用,然后运行交易。如果实际使用的 gas 与声明的 gas_used 不同,或者会超过区块 gas 上限,整个载荷就会被回滚:状态回退到快照,收据和日志清空,EIP-7685 的请求被跳过。区块本身仍保留在链上;被丢弃的只是它的执行。

费用市场。 如果某个父区块的执行被回滚,下一个区块的基础费用按照父区块使用了零 gas 来计算。

示例代码

简化的静态检查,改编自规范中的伪代码:

def validate_block(chain, block):
    h = block.header
    # parent's deferred outputs must match what we computed last block
    assert h.pre_state_root == state_root(chain.state)
    assert h.parent_receipt_root == chain.last_receipt_root
    assert h.parent_execution_reverted == chain.last_execution_reverted

    balances, nonces, inclusion_gas = {}, {}, 0
    for tx in block.transactions:
        sender = recover_sender(chain.chain_id, tx)
        if sender not in balances:
            acct = get_account(chain.state, sender)
            assert acct.code == b"" or is_valid_delegation(acct.code)  # EOA only
            balances[sender], nonces[sender] = acct.balance, acct.nonce
        max_fee = tx.gas * effective_gas_price(tx, h.base_fee_per_gas) + blob_fee(tx)
        assert balances[sender] >= max_fee + tx.value
        assert nonces[sender] == tx.nonce
        balances[sender] -= max_fee + tx.value
        nonces[sender] += 1
        inclusion_gas += max(intrinsic_gas(tx), calldata_floor(tx))
    assert inclusion_gas <= h.gas_used

需要注意

  • 状态:Stagnant。 尚未被排入任何分叉,需要硬分叉才能激活。与分离执行和共识相关的扩容工作包括 EIP-7732(ePBS)。
  • 交易必须来自 EOA(或经 7702 委托的账户),因为合约无法被静态地检查余额和 nonce。
  • 声明了错误 gas_used 的提议者会失去该区块的全部执行层奖励,这是诚实声明的主要激励。
  • 即使对于被回滚的区块,节点仍必须存储交易数据(calldata、access list、blob)。规范承认这是一个廉价数据攻击的途径,并认为这并不划算,因为攻击者会丧失区块奖励。

#core #consensus #execution #scaling #gas

详细信息

作者
Francesco D'Amato (@fradamt), Toni Wahrstätter (@nerolation)
状态
Stagnant(停滞)
类型
Standards Track / Core(核心)
创建日期
2025-02-18
依赖的提案

机器可读数据: Markdown · JSON