Skip to content

Commit c1e509b

Browse files
authored
Merge pull request #3965 from ethereum/dev
Release v1.5.0-alpha.8
2 parents 30ecf2c + 28f9f07 commit c1e509b

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

pysetup/spec_builders/electra.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class ElectraSpecBuilder(BaseSpecBuilder):
1010
def imports(cls, preset_name: str):
1111
return f'''
1212
from eth2spec.deneb import {preset_name} as deneb
13+
from eth2spec.utils.ssz.ssz_impl import serialize
1314
'''
1415

1516
@classmethod
@@ -28,8 +29,8 @@ class NoopExecutionEngine(ExecutionEngine):
2829
2930
def notify_new_payload(self: ExecutionEngine,
3031
execution_payload: ExecutionPayload,
31-
execution_requests: ExecutionRequests,
32-
parent_beacon_block_root: Root) -> bool:
32+
parent_beacon_block_root: Root,
33+
execution_requests_list: list[bytes]) -> bool:
3334
return True
3435
3536
def notify_forkchoice_updated(self: ExecutionEngine,

specs/electra/beacon-chain.md

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
- [Modified `get_expected_withdrawals`](#modified-get_expected_withdrawals)
8585
- [Modified `process_withdrawals`](#modified-process_withdrawals)
8686
- [Execution payload](#execution-payload)
87+
- [New `get_execution_requests_list`](#new-get_execution_requests_list)
8788
- [Modified `process_execution_payload`](#modified-process_execution_payload)
8889
- [Operations](#operations)
8990
- [Modified `process_operations`](#modified-process_operations)
@@ -990,8 +991,8 @@ class NewPayloadRequest(object):
990991
```python
991992
def notify_new_payload(self: ExecutionEngine,
992993
execution_payload: ExecutionPayload,
993-
execution_requests: ExecutionRequests,
994-
parent_beacon_block_root: Root) -> bool:
994+
parent_beacon_block_root: Root,
995+
execution_requests_list: list[bytes]) -> bool:
995996
"""
996997
Return ``True`` if and only if ``execution_payload`` and ``execution_requests``
997998
are valid with respect to ``self.execution_state``.
@@ -1011,8 +1012,8 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
10111012
Return ``True`` if and only if ``new_payload_request`` is valid with respect to ``self.execution_state``.
10121013
"""
10131014
execution_payload = new_payload_request.execution_payload
1014-
execution_requests = new_payload_request.execution_requests # [New in Electra]
10151015
parent_beacon_block_root = new_payload_request.parent_beacon_block_root
1016+
execution_requests_list = get_execution_requests_list(new_payload_request.execution_requests) # [New in Electra]
10161017

10171018
if not self.is_valid_block_hash(execution_payload, parent_beacon_block_root):
10181019
return False
@@ -1022,9 +1023,9 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
10221023

10231024
# [Modified in Electra]
10241025
if not self.notify_new_payload(
1025-
execution_payload,
1026-
execution_requests,
1027-
parent_beacon_block_root):
1026+
execution_payload,
1027+
parent_beacon_block_root,
1028+
execution_requests_list):
10281029
return False
10291030

10301031
return True
@@ -1139,6 +1140,19 @@ def process_withdrawals(state: BeaconState, payload: ExecutionPayload) -> None:
11391140

11401141
#### Execution payload
11411142

1143+
##### New `get_execution_requests_list`
1144+
1145+
*Note*: Encodes execution requests as defined by [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685).
1146+
1147+
```python
1148+
def get_execution_requests_list(execution_requests: ExecutionRequests) -> list[bytes]:
1149+
deposit_bytes = serialize(execution_requests.deposits)
1150+
withdrawal_bytes = serialize(execution_requests.withdrawals)
1151+
consolidation_bytes = serialize(execution_requests.consolidations)
1152+
1153+
return [deposit_bytes, withdrawal_bytes, consolidation_bytes]
1154+
```
1155+
11421156
##### Modified `process_execution_payload`
11431157

11441158
*Note*: The function `process_execution_payload` is modified to pass `execution_requests` into `execution_engine.verify_and_notify_new_payload` (via the updated `NewPayloadRequest`).
@@ -1160,9 +1174,9 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
11601174
assert execution_engine.verify_and_notify_new_payload(
11611175
NewPayloadRequest(
11621176
execution_payload=payload,
1163-
execution_requests=body.execution_requests, # [New in Electra]
11641177
versioned_hashes=versioned_hashes,
11651178
parent_beacon_block_root=state.latest_block_header.parent_root,
1179+
execution_requests=body.execution_requests, # [New in Electra]
11661180
)
11671181
)
11681182
# Cache execution payload header
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.0-alpha.7
1+
1.5.0-alpha.8

tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_blocks.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ def test_basic_el_withdrawal_request(spec, state):
2828
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
2929
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
3030

31-
yield 'pre', state
32-
3331
validator_index = 0
3432
address = b'\x22' * 20
3533
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address)
3634
assert state.validators[validator_index].exit_epoch == spec.FAR_FUTURE_EPOCH
3735

36+
yield 'pre', state
37+
3838
validator_pubkey = state.validators[validator_index].pubkey
3939
withdrawal_request = spec.WithdrawalRequest(
4040
source_address=address,
@@ -57,10 +57,11 @@ def test_basic_btec_and_el_withdrawal_request_in_same_block(spec, state):
5757
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
5858
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
5959

60-
yield 'pre', state
6160
validator_index = 0
6261
assert state.validators[validator_index].exit_epoch == spec.FAR_FUTURE_EPOCH
6362

63+
yield 'pre', state
64+
6465
block = build_empty_block_for_next_slot(spec, state)
6566

6667
address = b'\x22' * 20
@@ -99,11 +100,11 @@ def test_basic_btec_before_el_withdrawal_request(spec, state):
99100
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
100101
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
101102

102-
yield 'pre', state
103-
104103
validator_index = 0
105104
assert state.validators[validator_index].exit_epoch == spec.FAR_FUTURE_EPOCH
106105

106+
yield 'pre', state
107+
107108
# block_1 contains a BTEC operation of the given validator
108109
address = b'\x22' * 20
109110
signed_address_change = get_signed_address_change(
@@ -146,13 +147,13 @@ def test_cl_exit_and_el_withdrawal_request_in_same_block(spec, state):
146147
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
147148
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH
148149

149-
yield 'pre', state
150-
151150
validator_index = 0
152151
address = b'\x22' * 20
153152
set_eth1_withdrawal_credential_with_balance(spec, state, validator_index, address=address)
154153
assert state.validators[validator_index].exit_epoch == spec.FAR_FUTURE_EPOCH
155154

155+
yield 'pre', state
156+
156157
# CL-Exit
157158
signed_voluntary_exits = prepare_signed_exits(spec, state, indices=[validator_index])
158159
# EL-Exit

tests/generators/operations/main.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
'deposit_request',
5050
'voluntary_exit',
5151
'withdrawal_request',
52+
'withdrawals',
5253
]}
5354
electra_mods = combine_mods(_new_electra_mods, deneb_mods)
5455

0 commit comments

Comments
 (0)