Skip to content

Commit b2e8dba

Browse files
committed
simplify compute_fork_digest to reuse get_max_blobs_per_block.
1 parent 41f2322 commit b2e8dba

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

specs/fulu/beacon-chain.md

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,32 +61,25 @@ def compute_fork_digest(
6161
current_version: Version,
6262
genesis_validators_root: Root,
6363
current_epoch: Epoch, # [New in Fulu:EIP7892]
64-
blob_schedule: Sequence[BlobScheduleEntry] # [New in Fulu:EIP7892]
6564
) -> ForkDigest:
6665
"""
6766
Return the 4-byte fork digest for the ``current_version`` and ``genesis_validators_root``,
68-
bitmasking blob parameters after ``ELECTRA_FORK_VERSION``.
67+
with a XOR bitmask of the big-endian byte representation of current max_blobs_per_block.
6968
7069
This is a digest primarily used for domain separation on the p2p layer.
7170
4-bytes suffices for practical separation of forks/chains.
7271
"""
7372
base_digest = compute_fork_data_root(current_version, genesis_validators_root)[:4]
7473

75-
# Find the blob parameters applicable to this epoch
76-
sorted_schedule = sorted(blob_schedule, key=lambda e: e.epoch, reverse=True)
77-
blob_params = None
78-
for entry in sorted_schedule:
79-
if current_epoch >= entry.epoch:
80-
blob_params = entry
81-
break
74+
if current_epoch < FULU_FORK_EPOCH:
75+
return base_digest
8276

83-
# This check enables us to roll out the BPO mechanism without a concurrent parameter change
84-
if blob_params is None:
85-
return ForkDigest(base_digest)
77+
# Find the blob parameters applicable to this epoch
78+
max_blobs_per_block = get_max_blobs_per_block(current_epoch)
8679

8780
# Safely bitmask blob parameters into the digest
88-
assert 0 <= blob_params.max_blobs_per_block <= 0xFFFFFFFF
89-
mask = blob_params.max_blobs_per_block.to_bytes(4, 'big')
81+
# If Fulu is deployed with no concurrent blob parameter changes, we'll bitmask Electra's value.
82+
mask = max_blobs_per_block.to_bytes(4, 'big')
9083
masked_digest = bytes(a ^ b for a, b in zip(base_digest, mask))
9184
return ForkDigest(masked_digest)
9285
```

0 commit comments

Comments
 (0)