Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions specs/gloas/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,9 @@ follows the node's payload status. For a *full* node from the previous slot, it
considers the PTC view on both payload timeliness and data availability.

```python
def should_build_on_full(store: Store, head: ForkChoiceNode) -> bool:
def should_build_on_full(store: Store, head: ForkChoiceNode, slot: Slot) -> bool:
assert head.payload_status != PAYLOAD_STATUS_PENDING
if store.blocks[head.root].slot + 1 != get_current_slot(store):
if store.blocks[head.root].slot + 1 != slot:
return head.payload_status == PAYLOAD_STATUS_FULL
if head.payload_status == PAYLOAD_STATUS_EMPTY:
return False
Expand Down
33 changes: 30 additions & 3 deletions specs/gloas/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ where `store` is the fork choice store, and the alias
limitation defined in the consensus layer -- i.e. validate that
`len(bid.blob_kzg_commitments) <= get_blob_parameters(compute_epoch_at_slot(bid.slot)).max_blobs_per_block`.
- _[IGNORE]_ this is the first signed bid seen with a valid signature from the
given builder for this slot.
given builder for the tuple
`(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
- _[IGNORE]_ this bid is the highest value bid seen for the tuple
`(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
- _[IGNORE]_ `bid.value` is less or equal than the builder's excess balance --
Expand All @@ -438,8 +439,8 @@ where `store` is the fork choice store, and the alias
`is_gas_limit_target_compatible(parent_gas_limit, bid.gas_limit, proposer_preferences.target_gas_limit)`
is `True` where `parent_gas_limit` is the `gas_limit` of that execution
payload.
- _[IGNORE]_ `bid.parent_block_root` is the hash tree root of a known beacon
block in fork choice.
- _[IGNORE]_ The bid is compatible with the current head branch, i.e.
`is_bid_compatible_with_head(store, bid)` returns `True`.
- _[REJECT]_ The bid is for a higher slot than its parent block -- i.e. validate
that `bid.slot` is greater than the slot of the block with root
`bid.parent_block_root`.
Expand Down Expand Up @@ -467,6 +468,32 @@ def is_gas_limit_target_compatible(
return gas_limit == min_gas_limit
```

```python
def is_bid_compatible_with_head(store: Store, bid: ExecutionPayloadBid) -> bool:
"""
Check if ``bid`` is compatible with the head branch.
"""
head_node = get_head(store)
head_block = store.blocks[head_node.root]
head_bid = head_block.body.signed_execution_payload_bid.message

builds_on_parent_block = bid.parent_block_root == head_block.parent_root
builds_on_parent_payload = bid.parent_block_hash == head_bid.parent_block_hash

if builds_on_parent_block and builds_on_parent_payload:
return True

if bid.parent_block_root != head_node.root:
return False

builds_on_head_payload = bid.parent_block_hash == head_bid.block_hash

if should_build_on_full(store, head_node, bid.slot):
Comment thread
jtraglia marked this conversation as resolved.
return builds_on_head_payload

return builds_on_parent_payload
```

*Note*: Implementations SHOULD include DoS prevention measures to mitigate spam
from malicious builders submitting numerous bids with minimal value increments.
Possible strategies include: (1) only forwarding bids that exceed the current
Expand Down
21 changes: 11 additions & 10 deletions specs/gloas/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ top of a `state` MUST take the following actions in order to construct the
- The `bid.slot` is for the proposal block slot.
- The `bid.parent_block_hash` equals
`state.latest_execution_payload_bid.block_hash` if
`should_build_on_full(store, head)` is true, otherwise
`state.latest_execution_payload_bid.parent_block_hash`.
`should_build_on_full(store, head, get_current_slot(store))` is true,
otherwise `state.latest_execution_payload_bid.parent_block_hash`.
- The `bid.parent_block_root` equals the current block's `parent_root`.
- The `bid.prev_randao` equals
`get_randao_mix(state, get_current_epoch(state))`.
Expand Down Expand Up @@ -248,9 +248,9 @@ parent's execution payload. 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_build_on_full(store, head)` returns `True` (the proposer is
building on the parent's full payload), set `parent_execution_requests` to
`store.payloads[head.root].execution_requests`.
- If `should_build_on_full(store, head, get_current_slot(store))` returns `True`
(the proposer is building on the parent's full payload), set
`parent_execution_requests` to `store.payloads[head.root].execution_requests`.
- Otherwise (the proposer is building on the parent's empty variant), set
`parent_execution_requests` to an empty `ExecutionRequests()`.

Expand Down Expand Up @@ -319,10 +319,11 @@ def get_execution_requests(execution_requests_list: Sequence[bytes]) -> Executio
##### ExecutionPayload

*Note*: `prepare_execution_payload` is modified to build on the parent's full
payload or its empty variant, as decided by `should_build_on_full(store, head)`,
which determines the withdrawals source and the execution head for the new
payload. When building on a full parent, `apply_parent_execution_payload` is
called so that withdrawals are computed against the post-processing state.
payload or its empty variant, as decided by
`should_build_on_full(store, head, get_current_slot(store))`, which determines
the withdrawals source and the execution head for the new payload. When building
on a full parent, `apply_parent_execution_payload` is called so that withdrawals
are computed against the post-processing state.

```python
def prepare_execution_payload(
Expand All @@ -340,7 +341,7 @@ def prepare_execution_payload(
) -> Optional[PayloadId]:
# [New in Gloas:EIP7732]
parent_bid = state.latest_execution_payload_bid
if should_build_on_full(store, head):
if should_build_on_full(store, head, get_current_slot(store)):
envelope = store.payloads[head.root]
# Make a copy of the state to avoid mutability issues
state = copy(state)
Expand Down
2 changes: 1 addition & 1 deletion specs/heze/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def prepare_execution_payload(
execution_engine: ExecutionEngine,
) -> Optional[PayloadId]:
parent_bid = state.latest_execution_payload_bid
if should_build_on_full(store, head):
if should_build_on_full(store, head, get_current_slot(store)):
envelope = store.payloads[head.root]
# Make a copy of the state to avoid mutability issues
state = copy(state)
Expand Down