EL 的 blobSchedule 中的 max 字段必须等于共识层配置中的 MAX_BLOBS_PER_BLOCK 值。
maxBlobsPerTx 字段是可选的,如果省略,则默认为 max 的值。 共识层不使用它。
修改后的 compute_fork_digest
更新 compute_fork_digest 助手以考虑 BPO 分叉:
@dataclassclassBlobScheduleEntry:epoch:Epochmax_blobs_per_block:uint64# Aligning with the type of MAX_BLOBS_PER_BLOCK
defcompute_fork_digest(current_version:Version,# Unchanged; refers to the baseline hardfork atop which the blob schedule is applied
genesis_validators_root:Root,# Unchanged
current_epoch:Epoch,# New
blob_schedule:Sequence[BlobScheduleEntry]# New
)->ForkDigest:"""
Return the 4-byte fork digest for the ``current_version`` and ``genesis_validators_root``,
bitmasking blob parameters after ``ELECTRA_FORK_VERSION``.
This is a digest primarily used for domain separation on the p2p layer.
4-bytes suffices for practical separation of forks/chains.
"""base_digest=compute_fork_data_root(current_version,genesis_validators_root)[:4]# Find the blob parameters applicable to this epoch.
# 查找适用于此 epoch 的 blob 参数
sorted_schedule=sorted(blob_schedule,key=lambdae:e.epoch,reverse=True)blob_params=Noneforentryinsorted_schedule:ifcurrent_epoch>=entry.epoch:blob_params=entrybreak# This check enables us to roll out the BPO mechanism without a concurrent parameter change.
# 此检查使我们能够在不同时的参数更改的情况下推出 BPO 机制。
ifblob_paramsisNone:returnForkDigest(base_digest)# Safely bitmask blob parameters into the digest.
# 安全地将 blob 参数位掩码到摘要中。
assert0<=blob_params.max_blobs_per_block<=0xFFFFFFFFmask=blob_params.max_blobs_per_block.to_bytes(4,'big')masked_digest=bytes(a^bfora,binzip(base_digest,mask))returnForkDigest(masked_digest)