EIP-7742 · Stagnant(停滞) · Core(核心) · 2024-07-12
EIP-7742: Uncouple blob count between CL and EL
提议让共识层掌管 blob 上限,并把每个区块的 blob 目标值传给执行层,这样修改 blob 参数时就不必在两种客户端里协调修改硬编码值。
它解决什么问题?
EIP-4844 引入 blob 时带有两个硬编码数值:每个区块的 blob 最大数量(防 DoS 的上限)和目标数量(用于按 EIP-1559 的方式调整 blob 基础费用)。目标值固定为最大值的一半。
这两个值都硬编码在执行客户端(EL)里,最大值还硬编码在共识客户端(CL)里。因此,提高 blob 吞吐量(以太坊扩容路线图的关键部分)需要两类客户端同步修改,而且 target == max / 2 的关系也过于僵化。
EIP-7742 提议在两层之间解耦这些值。
它如何运作
- 在 EL 中去掉最大值检查。 CL 已经强制执行最大值,EL 则通过 Engine API 中的 versioned hash 一致性检查继承了这项检查。因此,可以移除 EL 的
MAX_BLOB_GAS_PER_BLOCK逻辑,而不会削弱安全性。 - 由 CL 发送目标值。 Engine API 在每个 payload 中传递
target_blobs_per_block。EL 区块头新增一个 64 位字段target_blobs_per_block,必须与 CL 提供的值一致(类似于提款的验证方式)。把它放在区块头中可以保持 optimistic sync 的安全性。 - 用区块头中的目标值计算费用。 excess blob gas 根据父区块的目标值计算,而不是使用常量。
- 区块构建。 CL 请求 EL 构建 payload 时,同时传入目标值和最大值。
CL 保留最大值(DoS 防护),EL 保留费用核算,从而保持职责分离。
示例代码
规范中更新后的 excess blob gas 计算:
def calc_excess_blob_gas(parent: Header) -> int:
target_blob_gas = parent.target_blobs_per_block * GAS_PER_BLOB
if parent.excess_blob_gas + parent.blob_gas_used < target_blob_gas:
return 0
else:
return parent.excess_blob_gas + parent.blob_gas_used - target_blob_gas
概念性的区块头扩展:
class Header:
...
blob_gas_used: uint64
excess_blob_gas: uint64
target_blobs_per_block: uint64 # new, supplied by the CL via the Engine API