Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated validator spec with rules for including execution requests in the beacon block body #3976

Merged
merged 14 commits into from
Oct 11, 2024
2 changes: 1 addition & 1 deletion pysetup/spec_builders/electra.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ElectraSpecBuilder(BaseSpecBuilder):
def imports(cls, preset_name: str):
return f'''
from eth2spec.deneb import {preset_name} as deneb
from eth2spec.utils.ssz.ssz_impl import serialize
from eth2spec.utils.ssz.ssz_impl import serialize, deserialize
'''

@classmethod
Expand Down
54 changes: 54 additions & 0 deletions specs/electra/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@

- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Helpers](#helpers)
- [Modified `GetPayloadResponse`](#modified-getpayloadresponse)
- [Containers](#containers)
- [Modified Containers](#modified-containers)
- [`AggregateAndProof`](#aggregateandproof)
- [`SignedAggregateAndProof`](#signedaggregateandproof)
- [Protocol](#protocol)
- [`ExecutionEngine`](#executionengine)
- [Modified `get_payload`](#modified-get_payload)
- [Block proposal](#block-proposal)
- [Constructing the `BeaconBlockBody`](#constructing-the-beaconblockbody)
- [Attester slashings](#attester-slashings)
- [Attestations](#attestations)
- [Deposits](#deposits)
- [Execution payload](#execution-payload)
- [Execution Requests](#execution-requests)
- [Attesting](#attesting)
- [Construct attestation](#construct-attestation)
- [Attestation aggregation](#attestation-aggregation)
Expand All @@ -38,6 +44,19 @@ All behaviors and definitions defined in this document, and documents it extends
All terminology, constants, functions, and protocol mechanics defined in the updated Beacon Chain doc of [Electra](./beacon-chain.md) are requisite for this document and used throughout.
Please see related Beacon Chain doc before continuing and use them as a reference throughout.

## Helpers

### Modified `GetPayloadResponse`

```python
@dataclass
class GetPayloadResponse(object):
execution_payload: ExecutionPayload
block_value: uint256
blobs_bundle: BlobsBundle
execution_requests: list[bytes] # [New in Electra]
```

## Containers

### Modified Containers
Expand All @@ -59,6 +78,24 @@ class SignedAggregateAndProof(Container):
signature: BLSSignature
```

## Protocol

### `ExecutionEngine`

#### Modified `get_payload`

Given the `payload_id`, `get_payload` returns the most recent version of the execution payload that
has been built since the corresponding call to `notify_forkchoice_updated` method.

```python
def get_payload(self: ExecutionEngine, payload_id: PayloadId) -> GetPayloadResponse:
"""
Return ExecutionPayload, uint256, BlobsBundle and list[bytes] objects.
"""
# pylint: disable=unused-argument
...
```

## Block proposal

### Constructing the `BeaconBlockBody`
Expand Down Expand Up @@ -148,6 +185,23 @@ def prepare_execution_payload(state: BeaconState,
)
```

#### Execution Requests

*[New in Electra]*

1. The execution payload is obtained from the execution engine as defined above using `payload_id`. The response also includes a `execution_requests` entry containing a list of bytes. Each element on the list corresponds to one ssz list of requests as defined
jtraglia marked this conversation as resolved.
Show resolved Hide resolved
in [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685). The index of each element in the array determines the type of request.
2. Set `block.body.execution_requests = get_execution_requests(execution_requests)`, where:

```python
def get_execution_requests(execution_requests: list[bytes]) -> ExecutionRequests:
deposits = deserialize(List[DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD], execution_requests[0])
withdrawals = deserialize(List[WithdrawalRequest, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD], execution_requests[1])
consolidations = deserialize(List[ConsolidationRequest, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD], execution_requests[2])

return ExecutionRequests(deposits, withdrawals, consolidations)
```

## Attesting

### Construct attestation
Expand Down
2 changes: 2 additions & 0 deletions tests/core/pyspec/eth2spec/utils/ssz/ssz_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
def serialize(obj: View) -> bytes:
return obj.encode_bytes()

def deserialize(cls: View, data: bytes) -> object:
jtraglia marked this conversation as resolved.
Show resolved Hide resolved
return cls.decode_bytes(data)

def hash_tree_root(obj: View) -> Bytes32:
return Bytes32(obj.get_backing().merkle_root())
Expand Down
Loading