Skip to content

Commit 09c77a4

Browse files
authored
Add missing dependent block checks to on_inclusion_list (#5599)
This PR adds missing dependent block's slot and dependent root validity checks to `on_inclusion_list`.
1 parent c467ca4 commit 09c77a4

4 files changed

Lines changed: 31 additions & 23 deletions

File tree

specs/gloas/fork-choice.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
- [Modified `get_head`](#modified-get_head)
4141
- [Modified `get_latest_message_epoch`](#modified-get_latest_message_epoch)
4242
- [New `verify_execution_payload_envelope`](#new-verify_execution_payload_envelope)
43+
- [New `is_valid_dependent_root`](#new-is_valid_dependent_root)
4344
- [Modified `get_attestation_due_ms`](#modified-get_attestation_due_ms)
4445
- [Modified `get_aggregate_due_ms`](#modified-get_aggregate_due_ms)
4546
- [Modified `get_sync_message_due_ms`](#modified-get_sync_message_due_ms)
@@ -697,6 +698,24 @@ def verify_execution_payload_envelope(
697698
)
698699
```
699700

701+
### New `is_valid_dependent_root`
702+
703+
```python
704+
def is_valid_dependent_root(store: Store, root: Root, dependent_slot: Slot) -> bool:
705+
"""
706+
Check if the block with the given ``root`` is a possible dependent block
707+
for the given ``dependent_slot``, meaning that on some branch it is, or
708+
could become, the latest block at or before ``dependent_slot``.
709+
"""
710+
if root == get_head(store).root:
711+
return True
712+
for block in store.blocks.values():
713+
if block.parent_root == root:
714+
if block.slot > dependent_slot:
715+
return True
716+
return False
717+
```
718+
700719
### Modified `get_attestation_due_ms`
701720

702721
```python

specs/gloas/p2p-interface.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
- [New `is_past_slot`](#new-is_past_slot)
2727
- [New `is_gas_limit_target_compatible`](#new-is_gas_limit_target_compatible)
2828
- [New `is_bid_compatible_with_head`](#new-is_bid_compatible_with_head)
29-
- [New `is_valid_dependent_root`](#new-is_valid_dependent_root)
3029
- [New `compute_shuffling_dependent_epoch`](#new-compute_shuffling_dependent_epoch)
3130
- [New `verify_attestation_payload_status`](#new-verify_attestation_payload_status)
3231
- [New `verify_block_body_operation_limits`](#new-verify_block_body_operation_limits)
@@ -381,25 +380,6 @@ def is_bid_compatible_with_head(store: Store, bid: ExecutionPayloadBid) -> bool:
381380
return builds_on_parent_payload
382381
```
383382

384-
### New `is_valid_dependent_root`
385-
386-
```python
387-
def is_valid_dependent_root(store: Store, root: Root, epoch: Epoch) -> bool:
388-
"""
389-
Check if the block with the given ``root`` is a possible dependent block
390-
for the given ``epoch``, meaning that on some branch it is, or could
391-
become, the latest block prior to the start of the epoch.
392-
"""
393-
epoch_start_slot = compute_start_slot_at_epoch(epoch)
394-
for block in store.blocks.values():
395-
if block.parent_root == root:
396-
if block.slot >= epoch_start_slot:
397-
return True
398-
if root == get_head(store).root:
399-
return True
400-
return False
401-
```
402-
403383
### New `compute_shuffling_dependent_epoch`
404384

405385
```python
@@ -1132,8 +1112,8 @@ def validate_proposer_preferences_gossip(
11321112
if store.blocks[preferences.dependent_root].slot > dependent_slot:
11331113
raise GossipReject("dependent block is after the shuffling dependent slot")
11341114

1135-
# [IGNORE] The dependent block is a possible dependent block for the lookahead epoch
1136-
if not is_valid_dependent_root(store, preferences.dependent_root, lookahead_epoch):
1115+
# [IGNORE] The dependent block is a possible dependent block for the proposer lookahead
1116+
if not is_valid_dependent_root(store, preferences.dependent_root, dependent_slot):
11371117
raise GossipIgnore("dependent block is not a possible dependent block")
11381118

11391119
# [REJECT] The validator is the proposer for the given slot in the proposer lookahead

specs/heze/fork-choice.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,17 @@ def on_inclusion_list(store: Store, signed_inclusion_list: SignedInclusionList)
281281
assert inclusion_list.slot + MIN_SLOTS_FOR_INCLUSION_LISTS_REQUESTS >= current_slot
282282

283283
# The dependent block must be known
284+
assert inclusion_list.dependent_root in store.blocks
284285
assert inclusion_list.dependent_root in store.block_states
285286

287+
# The dependent block's slot must not be after the shuffling dependent slot
288+
epoch = compute_epoch_at_slot(inclusion_list.slot)
289+
dependent_slot = compute_shuffling_dependent_slot(epoch)
290+
assert store.blocks[inclusion_list.dependent_root].slot <= dependent_slot
291+
292+
# The dependent block must be a possible dependent block for the inclusion list committee lookahead
293+
assert is_valid_dependent_root(store, inclusion_list.dependent_root, dependent_slot)
294+
286295
# Verify the validator is in the inclusion list committee
287296
dependent_state = store.block_states[inclusion_list.dependent_root].copy()
288297
if dependent_state.slot < inclusion_list.slot:

tests/core/pyspec/eth_consensus_specs/test/heze/unittests/inclusion_list/test_inclusion_list_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def run_func():
192192
transactions=transactions,
193193
)
194194
signed_inclusion_list_0 = sign_inclusion_list(spec, state, inclusion_list_0)
195+
spec.on_inclusion_list(forkchoice_store, signed_inclusion_list_0)
195196

196197
# Make a fork branch off the head.
197198
head_root = spec.get_head(forkchoice_store).root
@@ -219,7 +220,6 @@ def run_func():
219220

220221
# Both inclusion lists are valid, with different dependent roots.
221222
assert inclusion_list_0.dependent_root != inclusion_list_1.dependent_root
222-
spec.on_inclusion_list(forkchoice_store, signed_inclusion_list_0)
223223
spec.on_inclusion_list(forkchoice_store, signed_inclusion_list_1)
224224

225225
# Only the inclusion list stored under the given dependent root is returned.

0 commit comments

Comments
 (0)