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

Moving requests out of execution_payload into beacon_block.body #3875

Merged
merged 25 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
355a9a3
Introducing ExecutionPayloadEnvelope
lucassaldanha Aug 9, 2024
ed9b061
Comments
lucassaldanha Aug 9, 2024
f26c9be
Removing EL requests from ExecutionPayload
lucassaldanha Aug 11, 2024
f9ac902
Updated light-client block -> header function
lucassaldanha Aug 11, 2024
e26a3e0
New execution payload global index
lucassaldanha Aug 11, 2024
9a2e088
requests_root
lucassaldanha Aug 12, 2024
858402f
Updated with requests on block body
lucassaldanha Aug 13, 2024
794b942
Undo execution_payload gsync change
lucassaldanha Aug 13, 2024
5c88de8
Remove requests in execution_payload from full-node lightclient spec
lucassaldanha Aug 13, 2024
6669675
Test updates
lucassaldanha Aug 13, 2024
4185c00
Fork fix and tests
lucassaldanha Aug 13, 2024
fa78e0d
PR comments
lucassaldanha Aug 13, 2024
e3ec53f
Fix lint
lucassaldanha Aug 13, 2024
3527a9b
Cleaning unchanged ExecutionPayload
lucassaldanha Aug 14, 2024
b84316d
PR Comments
lucassaldanha Aug 16, 2024
98dd188
Rename requests to execution_requests
lucassaldanha Aug 16, 2024
dc1892e
Updated NewPayloadRequest
lucassaldanha Aug 22, 2024
b8ca7cc
PR comments
lucassaldanha Aug 22, 2024
e445cdf
Merge branch 'dev' into 3865
lucassaldanha Sep 1, 2024
38baa57
Rename ExecutionLayerRequests to ExecutionRequests
lucassaldanha Sep 1, 2024
31225f1
Temp fix for linter on eip-7732 beacon chain spec
lucassaldanha Sep 2, 2024
abf382a
Fix 7732
potuz Sep 4, 2024
beff03d
Updated verify_and_notify_new_payload and notify_new_payload
lucassaldanha Sep 5, 2024
c8dd790
Fix linter
lucassaldanha Sep 5, 2024
622ccd1
Updated ElectraSpecBuilder (NoopExecutionEngine#notify_new_payload)
lucassaldanha Sep 5, 2024
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
169 changes: 34 additions & 135 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
- [`WithdrawalRequest`](#withdrawalrequest)
- [`ConsolidationRequest`](#consolidationrequest)
- [`PendingConsolidation`](#pendingconsolidation)
- [`ExecutionLayerRequests`](#executionlayerrequests)
- [Modified Containers](#modified-containers)
- [`AttesterSlashing`](#attesterslashing)
- [`BeaconBlockBody`](#beaconblockbody)
- [Extended Containers](#extended-containers)
- [`Attestation`](#attestation)
- [`IndexedAttestation`](#indexedattestation)
- [`BeaconBlockBody`](#beaconblockbody)
- [`ExecutionPayload`](#executionpayload)
- [`ExecutionPayloadHeader`](#executionpayloadheader)
- [`BeaconState`](#beaconstate)
- [Helper functions](#helper-functions)
- [Predicates](#predicates)
Expand Down Expand Up @@ -78,8 +77,6 @@
- [Withdrawals](#withdrawals)
- [Modified `get_expected_withdrawals`](#modified-get_expected_withdrawals)
- [Modified `process_withdrawals`](#modified-process_withdrawals)
- [Execution payload](#execution-payload)
- [Modified `process_execution_payload`](#modified-process_execution_payload)
- [Operations](#operations)
- [Modified `process_operations`](#modified-process_operations)
- [Attestations](#attestations)
Expand Down Expand Up @@ -258,36 +255,26 @@ class PendingConsolidation(Container):
target_index: ValidatorIndex
```

### Modified Containers
#### `ExecutionLayerRequests`

#### `AttesterSlashing`
*Note*: This container contains request from the execution layer that are received in the Execution Payload via
Engine API. These requests are required for CL state transition (see **BeaconBlockBody**).
jtraglia marked this conversation as resolved.
Show resolved Hide resolved

```python
class AttesterSlashing(Container):
attestation_1: IndexedAttestation # [Modified in Electra:EIP7549]
attestation_2: IndexedAttestation # [Modified in Electra:EIP7549]
class ExecutionLayerRequests(Container):
ralexstokes marked this conversation as resolved.
Show resolved Hide resolved
deposits: List[DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP6110]
withdrawals: List[WithdrawalRequest, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP7002:EIP7251]
consolidations: List[ConsolidationRequest, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP7251]
```

### Extended Containers

#### `Attestation`

```python
class Attestation(Container):
aggregation_bits: Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT] # [Modified in Electra:EIP7549]
data: AttestationData
signature: BLSSignature
committee_bits: Bitvector[MAX_COMMITTEES_PER_SLOT] # [New in Electra:EIP7549]
```
### Modified Containers

#### `IndexedAttestation`
#### `AttesterSlashing`

```python
class IndexedAttestation(Container):
# [Modified in Electra:EIP7549]
attesting_indices: List[ValidatorIndex, MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]
data: AttestationData
signature: BLSSignature
class AttesterSlashing(Container):
attestation_1: IndexedAttestation # [Modified in Electra:EIP7549]
attestation_2: IndexedAttestation # [Modified in Electra:EIP7549]
```

#### `BeaconBlockBody`
Expand All @@ -305,67 +292,32 @@ class BeaconBlockBody(Container):
voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS]
sync_aggregate: SyncAggregate
# Execution
execution_payload: ExecutionPayload # [Modified in Electra:EIP6110:EIP7002]
execution_payload: ExecutionPayload
bls_to_execution_changes: List[SignedBLSToExecutionChange, MAX_BLS_TO_EXECUTION_CHANGES]
blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
requests: ExecutionLayerRequests # [New in Electra]
mkalinin marked this conversation as resolved.
Show resolved Hide resolved
```

#### `ExecutionPayload`
### Extended Containers

#### `Attestation`

```python
class ExecutionPayload(Container):
# Execution block header fields
parent_hash: Hash32
fee_recipient: ExecutionAddress
state_root: Bytes32
receipts_root: Bytes32
logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM]
prev_randao: Bytes32
block_number: uint64
gas_limit: uint64
gas_used: uint64
timestamp: uint64
extra_data: ByteList[MAX_EXTRA_DATA_BYTES]
base_fee_per_gas: uint256
# Extra payload fields
block_hash: Hash32
transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]
blob_gas_used: uint64
excess_blob_gas: uint64
deposit_requests: List[DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP6110]
# [New in Electra:EIP7002:EIP7251]
withdrawal_requests: List[WithdrawalRequest, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD]
# [New in Electra:EIP7251]
consolidation_requests: List[ConsolidationRequest, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD]
class Attestation(Container):
aggregation_bits: Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT] # [Modified in Electra:EIP7549]
data: AttestationData
signature: BLSSignature
committee_bits: Bitvector[MAX_COMMITTEES_PER_SLOT] # [New in Electra:EIP7549]
```

#### `ExecutionPayloadHeader`
#### `IndexedAttestation`

```python
class ExecutionPayloadHeader(Container):
# Execution block header fields
parent_hash: Hash32
fee_recipient: ExecutionAddress
state_root: Bytes32
receipts_root: Bytes32
logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM]
prev_randao: Bytes32
block_number: uint64
gas_limit: uint64
gas_used: uint64
timestamp: uint64
extra_data: ByteList[MAX_EXTRA_DATA_BYTES]
base_fee_per_gas: uint256
# Extra payload fields
block_hash: Hash32
transactions_root: Root
withdrawals_root: Root
blob_gas_used: uint64
excess_blob_gas: uint64
deposit_requests_root: Root # [New in Electra:EIP6110]
withdrawal_requests_root: Root # [New in Electra:EIP7002:EIP7251]
consolidation_requests_root: Root # [New in Electra:EIP7251]
class IndexedAttestation(Container):
# [Modified in Electra:EIP7549]
attesting_indices: List[ValidatorIndex, MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]
data: AttestationData
signature: BLSSignature
```

#### `BeaconState`
Expand Down Expand Up @@ -875,7 +827,7 @@ def process_pending_balance_deposits(state: BeaconState) -> None:
if processed_amount + deposit.amount > available_for_processing:
break
# Deposit fits in the churn, process it. Increase balance and consume churn.
else:
else:
increase_balance(state, deposit.index, deposit.amount)
processed_amount += deposit.amount
# Regardless of how the deposit was handled, we move on in the queue.
Expand Down Expand Up @@ -1047,59 +999,6 @@ def process_withdrawals(state: BeaconState, payload: ExecutionPayload) -> None:
next_validator_index = ValidatorIndex(next_index % len(state.validators))
state.next_withdrawal_validator_index = next_validator_index
```

#### Execution payload

##### Modified `process_execution_payload`

*Note*: The function `process_execution_payload` is modified to use the new `ExecutionPayloadHeader` type.

```python
def process_execution_payload(state: BeaconState, body: BeaconBlockBody, execution_engine: ExecutionEngine) -> None:
payload = body.execution_payload

# Verify consistency of the parent hash with respect to the previous execution payload header
assert payload.parent_hash == state.latest_execution_payload_header.block_hash
# Verify prev_randao
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state))
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
# Verify commitments are under limit
assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK
# Verify the execution payload is valid
versioned_hashes = [kzg_commitment_to_versioned_hash(commitment) for commitment in body.blob_kzg_commitments]
assert execution_engine.verify_and_notify_new_payload(
NewPayloadRequest(
execution_payload=payload,
ralexstokes marked this conversation as resolved.
Show resolved Hide resolved
versioned_hashes=versioned_hashes,
parent_beacon_block_root=state.latest_block_header.parent_root,
)
)
# Cache execution payload header
state.latest_execution_payload_header = ExecutionPayloadHeader(
parent_hash=payload.parent_hash,
fee_recipient=payload.fee_recipient,
state_root=payload.state_root,
receipts_root=payload.receipts_root,
logs_bloom=payload.logs_bloom,
prev_randao=payload.prev_randao,
block_number=payload.block_number,
gas_limit=payload.gas_limit,
gas_used=payload.gas_used,
timestamp=payload.timestamp,
extra_data=payload.extra_data,
base_fee_per_gas=payload.base_fee_per_gas,
block_hash=payload.block_hash,
transactions_root=hash_tree_root(payload.transactions),
withdrawals_root=hash_tree_root(payload.withdrawals),
blob_gas_used=payload.blob_gas_used,
excess_blob_gas=payload.excess_blob_gas,
deposit_requests_root=hash_tree_root(payload.deposit_requests), # [New in Electra:EIP6110]
withdrawal_requests_root=hash_tree_root(payload.withdrawal_requests), # [New in Electra:EIP7002:EIP7251]
consolidation_requests_root=hash_tree_root(payload.consolidation_requests), # [New in Electra:EIP7251]
)
```

#### Operations

##### Modified `process_operations`
Expand All @@ -1126,11 +1025,11 @@ def process_operations(state: BeaconState, body: BeaconBlockBody) -> None:
for_ops(body.deposits, process_deposit) # [Modified in Electra:EIP7251]
for_ops(body.voluntary_exits, process_voluntary_exit) # [Modified in Electra:EIP7251]
for_ops(body.bls_to_execution_changes, process_bls_to_execution_change)
for_ops(body.execution_payload.deposit_requests, process_deposit_request) # [New in Electra:EIP6110]
for_ops(body.requests.deposits, process_deposit_request) # [New in Electra:EIP6110]
# [New in Electra:EIP7002:EIP7251]
for_ops(body.execution_payload.withdrawal_requests, process_withdrawal_request)
for_ops(body.requests.withdrawals, process_withdrawal_request)
# [New in Electra:EIP7251]
for_ops(body.execution_payload.consolidation_requests, process_consolidation_request)
for_ops(body.requests.consolidations, process_consolidation_request)
jtraglia marked this conversation as resolved.
Show resolved Hide resolved
```

##### Attestations
Expand Down
23 changes: 1 addition & 22 deletions specs/electra/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,7 @@ an irregular state change is made to upgrade to Electra.
```python
def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState:
epoch = deneb.get_current_epoch(pre)
latest_execution_payload_header = ExecutionPayloadHeader(
parent_hash=pre.latest_execution_payload_header.parent_hash,
fee_recipient=pre.latest_execution_payload_header.fee_recipient,
state_root=pre.latest_execution_payload_header.state_root,
receipts_root=pre.latest_execution_payload_header.receipts_root,
logs_bloom=pre.latest_execution_payload_header.logs_bloom,
prev_randao=pre.latest_execution_payload_header.prev_randao,
block_number=pre.latest_execution_payload_header.block_number,
gas_limit=pre.latest_execution_payload_header.gas_limit,
gas_used=pre.latest_execution_payload_header.gas_used,
timestamp=pre.latest_execution_payload_header.timestamp,
extra_data=pre.latest_execution_payload_header.extra_data,
base_fee_per_gas=pre.latest_execution_payload_header.base_fee_per_gas,
block_hash=pre.latest_execution_payload_header.block_hash,
transactions_root=pre.latest_execution_payload_header.transactions_root,
withdrawals_root=pre.latest_execution_payload_header.withdrawals_root,
blob_gas_used=pre.latest_execution_payload_header.blob_gas_used,
excess_blob_gas=pre.latest_execution_payload_header.excess_blob_gas,
deposit_requests_root=Root(), # [New in Electra:EIP6110]
ralexstokes marked this conversation as resolved.
Show resolved Hide resolved
withdrawal_requests_root=Root(), # [New in Electra:EIP7002]
consolidation_requests_root=Root(), # [New in Electra:EIP7251]
)
latest_execution_payload_header = pre.latest_execution_payload_header

exit_epochs = [v.exit_epoch for v in pre.validators if v.exit_epoch != FAR_FUTURE_EPOCH]
if not exit_epochs:
Expand Down
23 changes: 1 addition & 22 deletions specs/electra/light-client/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,7 @@ A Electra `LightClientStore` can still process earlier light client data. In ord
def upgrade_lc_header_to_electra(pre: deneb.LightClientHeader) -> LightClientHeader:
return LightClientHeader(
beacon=pre.beacon,
execution=ExecutionPayloadHeader(
parent_hash=pre.execution.parent_hash,
fee_recipient=pre.execution.fee_recipient,
state_root=pre.execution.state_root,
receipts_root=pre.execution.receipts_root,
logs_bloom=pre.execution.logs_bloom,
prev_randao=pre.execution.prev_randao,
block_number=pre.execution.block_number,
gas_limit=pre.execution.gas_limit,
gas_used=pre.execution.gas_used,
timestamp=pre.execution.timestamp,
extra_data=pre.execution.extra_data,
base_fee_per_gas=pre.execution.base_fee_per_gas,
block_hash=pre.execution.block_hash,
transactions_root=pre.execution.transactions_root,
withdrawals_root=pre.execution.withdrawals_root,
blob_gas_used=pre.execution.blob_gas_used,
excess_blob_gas=pre.execution.blob_gas_used,
deposit_requests_root=Root(), # [New in Electra:EIP6110]
withdrawal_requests_root=Root(), # [New in Electra:EIP7002:EIP7251]
consolidation_requests_root=Root(), # [New in Electra:EIP7251]
),
execution=pre.execution,
execution_branch=pre.execution_branch,
)
```
Expand Down
6 changes: 0 additions & 6 deletions specs/electra/light-client/full-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,6 @@ def block_to_light_client_header(block: SignedBeaconBlock) -> LightClientHeader:
execution_header.blob_gas_used = payload.blob_gas_used
execution_header.excess_blob_gas = payload.excess_blob_gas

# [New in Electra:EIP6110:EIP7002:EIP7251]
if epoch >= ELECTRA_FORK_EPOCH:
execution_header.deposit_requests_root = hash_tree_root(payload.deposit_requests)
execution_header.withdrawal_requests_root = hash_tree_root(payload.withdrawal_requests)
execution_header.consolidation_requests_root = hash_tree_root(payload.consolidation_requests)

execution_branch = ExecutionBranch(
compute_merkle_proof(block.message.body, EXECUTION_PAYLOAD_GINDEX))
else:
Expand Down
9 changes: 0 additions & 9 deletions specs/electra/light-client/sync-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,6 @@ def get_lc_execution_root(header: LightClientHeader) -> Root:
def is_valid_light_client_header(header: LightClientHeader) -> bool:
epoch = compute_epoch_at_slot(header.beacon.slot)

# [New in Electra:EIP6110:EIP7002:EIP7251]
if epoch < ELECTRA_FORK_EPOCH:
if (
header.execution.deposit_requests_root != Root()
or header.execution.withdrawal_requests_root != Root()
or header.execution.consolidation_requests_root != Root()
):
return False

if epoch < DENEB_FORK_EPOCH:
if header.execution.blob_gas_used != uint64(0) or header.execution.excess_blob_gas != uint64(0):
return False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_basic_el_withdrawal_request(spec, state):
validator_pubkey=validator_pubkey,
)
block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.withdrawal_requests = [withdrawal_request]
block.body.requests.withdrawals = [withdrawal_request]
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
signed_block = state_transition_and_sign_block(spec, state, block)

Expand Down Expand Up @@ -77,7 +77,7 @@ def test_basic_btec_and_el_withdrawal_request_in_same_block(spec, state):
source_address=address,
validator_pubkey=validator_pubkey,
)
block.body.execution_payload.withdrawal_requests = [withdrawal_request]
block.body.requests.withdrawals = [withdrawal_request]

block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
signed_block = state_transition_and_sign_block(spec, state, block)
Expand Down Expand Up @@ -130,7 +130,7 @@ def test_basic_btec_before_el_withdrawal_request(spec, state):
validator_pubkey=validator_pubkey,
)
block_2 = build_empty_block_for_next_slot(spec, state)
block_2.body.execution_payload.withdrawal_requests = [withdrawal_request]
block_2.body.requests.withdrawals = [withdrawal_request]
block_2.body.execution_payload.block_hash = compute_el_block_hash(spec, block_2.body.execution_payload, state)
signed_block_2 = state_transition_and_sign_block(spec, state, block_2)

Expand Down Expand Up @@ -163,7 +163,7 @@ def test_cl_exit_and_el_withdrawal_request_in_same_block(spec, state):
)
block = build_empty_block_for_next_slot(spec, state)
block.body.voluntary_exits = signed_voluntary_exits
block.body.execution_payload.withdrawal_requests = [withdrawal_request]
block.body.requests.withdrawals = [withdrawal_request]
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
signed_block = state_transition_and_sign_block(spec, state, block)

Expand Down
Loading
Loading