Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions specs/gloas/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
- [New `notify_ptc_messages`](#new-notify_ptc_messages)
- [New `is_payload_verified`](#new-is_payload_verified)
- [New `is_payload_timely`](#new-is_payload_timely)
- [New `ptc_voted_payload_untimely`](#new-ptc_voted_payload_untimely)
- [New `is_payload_data_available`](#new-is_payload_data_available)
- [New `ptc_voted_data_unavailable`](#new-ptc_voted_data_unavailable)
- [New `get_parent_payload_status`](#new-get_parent_payload_status)
- [New `is_parent_node_full`](#new-is_parent_node_full)
- [Modified `get_ancestor`](#modified-get_ancestor)
- [Modified `get_checkpoint_block`](#modified-get_checkpoint_block)
- [New `is_supporting_vote`](#new-is_supporting_vote)
- [New `should_build_on_full`](#new-should_build_on_full)
- [New `should_extend_payload`](#new-should_extend_payload)
- [New `get_payload_status_tiebreaker`](#new-get_payload_status_tiebreaker)
- [New `should_apply_proposer_boost`](#new-should_apply_proposer_boost)
Expand Down Expand Up @@ -261,6 +264,26 @@ def is_payload_timely(store: Store, root: Root) -> bool:
return sum(vote is True for vote in votes) > PAYLOAD_TIMELY_THRESHOLD
```

### New `ptc_voted_payload_untimely`

```python
def ptc_voted_payload_untimely(store: Store, root: Root) -> bool:
"""
Return whether the execution payload for the beacon block with root ``root``
was voted as not present by the PTC.
"""
# The beacon block root must be known
assert root in store.payload_timeliness_vote

# If the payload is not locally available, the payload
# is not considered available regardless of the PTC vote
if not is_payload_verified(store, root):
return True

votes = store.payload_timeliness_vote[root]
return sum(vote is False for vote in votes) > PAYLOAD_TIMELY_THRESHOLD
```

### New `is_payload_data_available`

```python
Expand All @@ -281,6 +304,26 @@ def is_payload_data_available(store: Store, root: Root) -> bool:
return sum(vote is True for vote in votes) > DATA_AVAILABILITY_TIMELY_THRESHOLD
```

### New `ptc_voted_data_unavailable`

```python
def ptc_voted_data_unavailable(store: Store, root: Root) -> bool:
"""
Return whether the execution payload for the beacon block with root ``root``
was voted as unavailable by the PTC.
"""
# The beacon block root must be known
assert root in store.payload_timeliness_vote

# If the payload is not locally available, the blob data
# is not considered available regardless of the PTC vote
if not is_payload_verified(store, root):
return True

votes = store.payload_data_availability_vote[root]
return sum(vote is False for vote in votes) > DATA_AVAILABILITY_TIMELY_THRESHOLD
```

### New `get_parent_payload_status`

```python
Expand Down Expand Up @@ -365,6 +408,24 @@ def is_supporting_vote(store: Store, node: ForkChoiceNode, message: LatestMessag
)
```

### New `should_build_on_full`

*Note*: `should_build_on_full` is called by the proposer before deciding if he
should build on top of the empty or full parent pending node. This function is
similar to `should_extend_payload` but it takes into consideration the PTC view
on DA

```python
def should_build_on_full(store: Store, head: ForkChoiceNode) -> bool:
assert head.payload_status != PAYLOAD_STATUS_PENDING
if head.payload_status == PAYLOAD_STATUS_EMPTY:
return False

Comment thread
jtraglia marked this conversation as resolved.
Resolved
if ptc_voted_data_unavailable(store, head.root):
return False
return not ptc_voted_payload_untimely
Comment thread
jtraglia marked this conversation as resolved.
Resolved
```

### New `should_extend_payload`

*Note*: `should_extend_payload` decides whether to extend an available payload
Expand Down
27 changes: 15 additions & 12 deletions specs/gloas/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,13 @@ construct the `payload_attestations` field in `BeaconBlockBody`:
##### Parent execution requests

The `parent_execution_requests` field contains the execution requests from the
parent's execution payload. The proposer constructs this field as follows:
parent's execution payload. Let `head = get_head(store)`. The proposer
constructs this field as follows:

- If the parent block is pre-Gloas (first Gloas block), set
`parent_execution_requests` to an empty `ExecutionRequests()`.
- If `should_extend_payload(store, block.parent_root)` is true (the proposer is
building on the parent's full payload), set `parent_execution_requests` to
- If `should_build_on_full(store, head)` is true (the proposer is building on
the parent's full payload), set `parent_execution_requests` to
`store.payloads[block.parent_root].execution_requests`.
- Otherwise (the proposer is building on the parent's empty variant), set
`parent_execution_requests` to an empty `ExecutionRequests()`.
Expand All @@ -254,19 +255,21 @@ are computed against the post-processing state.
def prepare_execution_payload(
# [New in Gloas:EIP7732]
store: Store,
state: BeaconState,
slot: Slot,
safe_block_hash: Hash32,
finalized_block_hash: Hash32,
suggested_fee_recipient: ExecutionAddress,
execution_engine: ExecutionEngine,
) -> Optional[PayloadId]:
# [New in Gloas:EIP7732]
head = get_head(store)
state = store.block_states[head.root]
# Make a copy of the state to avoid mutability issues
state = copy(state)
process_slots(state, slot)
parent_bid = state.latest_execution_payload_bid
parent_root = hash_tree_root(state.latest_block_header)
if should_extend_payload(store, parent_root):
envelope = store.payloads[parent_root]
# Make a copy of the state to avoid mutability issues
state = copy(state)
if should_build_on_full(store, head):
envelope = store.payloads[head.root]
# Apply parent payload before computing withdrawals
apply_parent_execution_payload(state, envelope.execution_requests)
withdrawals = get_expected_withdrawals(state).withdrawals
Expand All @@ -277,14 +280,14 @@ def prepare_execution_payload(

# Set the forkchoice head and initiate the payload build process
payload_attributes = PayloadAttributes(
timestamp=compute_time_at_slot(state, state.slot),
prev_randao=get_randao_mix(state, get_current_epoch(state)),
timestamp=compute_time_at_slot(state, slot),
prev_randao=get_randao_mix(state, compute_epoch_at_slot(slot)),
suggested_fee_recipient=suggested_fee_recipient,
# [Modified in Gloas:EIP7732]
withdrawals=withdrawals,
parent_beacon_block_root=hash_tree_root(state.latest_block_header),
# [New in Gloas:EIP7843]
slot_number=state.slot,
slot_number=slot,
)
return execution_engine.notify_forkchoice_updated(
# [Modified in Gloas:EIP7732]
Expand Down
Loading