EIP-7918 · Final(最终) · Core(核心) · 2025-03-25
EIP-7918: Blob base fee bounded by execution cost
为 blob 基础费用设置与执行层基础费用挂钩的下限,使 blob 费用市场继续运转,而不会在执行成本占主导时坍缩到 1 wei。
它解决什么问题?
EIP-4844 为 blob 设立了独立的费用市场:如果区块使用的 blob gas 超过目标,blob 基础费用上升;低于目标则下降。这只有在 blob 费用是 rollup 实际支付成本中有意义的一部分时才有效。
实际上,rollup 发布 blob 的成本主要由携带 blob 的交易的执行 gas(加上证明验证和小费)决定。当 blob 需求低于目标时,blob 基础费用不断下降,直到停在 1 wei,此时费用变化 10 % 对 rollup 总成本几乎没有影响。需求回升时,需要连续很多个几乎满载的区块才能爬回市场出清价格,其间用户退回到通过小费竞价,体验更差。
还有成本方面的理由:节点必须为每个 blob 验证 KZG 证明,这是实实在在的计算。实际上近乎免费的 blob,对这项工作的补偿不足。
它如何运作
EIP-7918 在 calc_excess_blob_gas() 中增加一个 if 分支和一个常量 BLOB_BASE_COST = 2**13(8192)。
- 如果一个 blob 的价格(
GAS_PER_BLOB * blob_base_fee)低于BLOB_BASE_COST单位执行 gas 的价格,协议在更新excess_blob_gas时不再减去 target。此时 blob 基础费用只能上升,上升速度的上限与之前相同。 - 否则,适用正常的 EIP-4844 更新。
其效果是一个保留价格:blob 基础费用不会稳定在 BLOB_BASE_COST * base_fee_per_gas / GAS_PER_BLOB 以下,即每单位 blob gas 为执行层基础费用的 1/16。由于下限跟随执行层基础费用,当执行变便宜时它会自动下降,而不是一个随着以太坊扩容需要重新调整的固定数值。
它使用 EIP-7840 引入的按分叉划分的 blobSchedule(target、max、update fraction)。
示例代码
规范中修改后的函数:
BLOB_BASE_COST = 2**13
def calc_excess_blob_gas(parent: Header) -> int:
target_blob_gas = GAS_PER_BLOB * blobSchedule.target
if parent.excess_blob_gas + parent.blob_gas_used < target_blob_gas:
return 0
if BLOB_BASE_COST * parent.base_fee_per_gas > GAS_PER_BLOB * get_base_fee_per_blob_gas(parent):
# execution-fee-led regime: only allow the blob fee to rise
return parent.excess_blob_gas + parent.blob_gas_used * (blobSchedule.max - blobSchedule.target) // blobSchedule.max
else:
return parent.excess_blob_gas + parent.blob_gas_used - target_blob_gas
使用 ethers v6 检查下限是否生效:
const block = await provider.send("eth_getBlockByNumber", ["latest", false]);
const blobBaseFee = BigInt(await provider.send("eth_blobBaseFee", []));
const reserve = (8192n * BigInt(block.baseFeePerGas)) / 131072n; // GAS_PER_BLOB = 2**17
console.log(blobBaseFee <= reserve ? "at/below reserve" : "market-led");