PR comments

This commit is contained in:
Lucas Saldanha 2024-08-13 21:24:28 +12:00
parent 4185c00d23
commit fa78e0d301
6 changed files with 30 additions and 57 deletions

View File

@ -30,7 +30,7 @@
- [`WithdrawalRequest`](#withdrawalrequest)
- [`ConsolidationRequest`](#consolidationrequest)
- [`PendingConsolidation`](#pendingconsolidation)
- [`ValidatorRequests`](#validatorrequests)
- [`ExecutionLayerRequests`](#executionlayerrequests)
- [Modified Containers](#modified-containers)
- [`AttesterSlashing`](#attesterslashing)
- [`BeaconBlockBody`](#beaconblockbody)
@ -256,13 +256,16 @@ class PendingConsolidation(Container):
target_index: ValidatorIndex
```
#### `ValidatorRequests`
#### `ExecutionLayerRequests`
*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**).
```python
class ValidatorRequests(Container):
deposit_requests: List[DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP6110]
withdrawal_requests: List[WithdrawalRequest, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP7002:EIP7251]
consolidation_requests: List[ConsolidationRequest, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP7251]
class ExecutionLayerRequests(Container):
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]
```
### Modified Containers
@ -293,7 +296,7 @@ class BeaconBlockBody(Container):
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: ValidatorRequests # [New in Electra:EIP????]
requests: ExecutionLayerRequests # [New in Electra]
```
### Extended Containers
@ -921,8 +924,8 @@ def process_effective_balance_updates(state: BeaconState) -> None:
```python
def process_block(state: BeaconState, block: BeaconBlock) -> None:
process_block_header(state, block)
process_withdrawals(state, block.body.execution_payload) # [Modified in Electra:EIP7251:EIP????]
process_execution_payload(state, block.body, EXECUTION_ENGINE) # [Modified in Electra:EIP6110:EIP????]
process_withdrawals(state, block.body.execution_payload) # [Modified in Electra:EIP7251]
process_execution_payload(state, block.body, EXECUTION_ENGINE) # [Modified in Electra:EIP6110]
process_randao(state, block.body)
process_eth1_data(state, block.body)
process_operations(state, block.body) # [Modified in Electra:EIP6110:EIP7002:EIP7549:EIP7251]
@ -1048,11 +1051,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.requests.deposit_requests, process_deposit_request) # [New in Electra:EIP6110:EIP????]
# [New in Electra:EIP7002:EIP7251:EIP????]
for_ops(body.requests.withdrawal_requests, process_withdrawal_request)
# [New in Electra:EIP7251:EIP????]
for_ops(body.requests.consolidation_requests, process_consolidation_request)
for_ops(body.requests.deposits, process_deposit_request) # [New in Electra:EIP6110]
# [New in Electra:EIP7002:EIP7251]
for_ops(body.requests.withdrawals, process_withdrawal_request)
# [New in Electra:EIP7251]
for_ops(body.requests.consolidations, process_consolidation_request)
```
##### Attestations

View File

@ -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,
)
```

View File

@ -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

View File

@ -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.requests.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)
@ -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.requests.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)
@ -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.requests.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)
@ -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.requests.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)

View File

@ -38,7 +38,7 @@ def run_deposit_transition_block(spec, state, block, top_up_keys=[], valid=True)
# Check that deposits are applied
if valid:
expected_pubkeys = [d.data.pubkey for d in block.body.deposits]
deposit_requests = block.body.requests.deposit_requests
deposit_requests = block.body.requests.deposits
expected_pubkeys = expected_pubkeys + [d.pubkey for d in deposit_requests if (d.pubkey not in top_up_keys)]
actual_pubkeys = [v.pubkey for v in state.validators[len(state.validators) - len(expected_pubkeys):]]
@ -102,7 +102,7 @@ def prepare_state_and_block(spec,
# Assign deposits and deposit requests
block.body.deposits = deposits
block.body.requests.deposit_requests = deposit_requests
block.body.requests.deposits = deposit_requests
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
return state, block
@ -120,7 +120,7 @@ def test_deposit_transition__start_index_is_set(spec, state):
yield from run_deposit_transition_block(spec, state, block)
# deposit_requests_start_index must be set to the index of the first request
assert state.deposit_requests_start_index == block.body.requests.deposit_requests[0].index
assert state.deposit_requests_start_index == block.body.requests.deposits[0].index
@with_phases([ELECTRA])
@ -219,7 +219,7 @@ def test_deposit_transition__deposit_and_top_up_same_block(spec, state):
# Artificially assign deposit's pubkey to a deposit request of the same block
top_up_keys = [block.body.deposits[0].data.pubkey]
block.body.requests.deposit_requests[0].pubkey = top_up_keys[0]
block.body.requests.deposits[0].pubkey = top_up_keys[0]
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload, state)
pre_pending_deposits = len(state.pending_balance_deposits)
@ -229,5 +229,5 @@ def test_deposit_transition__deposit_and_top_up_same_block(spec, state):
# Check the top up
assert len(state.pending_balance_deposits) == pre_pending_deposits + 2
assert state.pending_balance_deposits[pre_pending_deposits].amount == block.body.deposits[0].data.amount
amount_from_deposit = block.body.requests.deposit_requests[0].amount
amount_from_deposit = block.body.requests.deposits[0].amount
assert state.pending_balance_deposits[pre_pending_deposits + 1].amount == amount_from_deposit

View File

@ -127,9 +127,9 @@ def build_empty_block(spec, state, slot=None, proposer_index=None):
empty_block.body.execution_payload = build_empty_execution_payload(spec, state)
if is_post_electra(spec):
empty_block.body.requests.deposit_requests = []
empty_block.body.requests.withdrawal_requests = []
empty_block.body.requests.consolidation_requests = []
empty_block.body.requests.deposits = []
empty_block.body.requests.withdrawals = []
empty_block.body.requests.consolidations = []
if is_post_whisk(spec):
# Whisk opening proof