Use Sequence for serialized execution requests

This commit is contained in:
Justin Traglia 2024-10-10 08:39:06 -05:00
parent 2a163adda2
commit 04a40d2afb
No known key found for this signature in database
GPG Key ID: F099C9CD25DF82A1
2 changed files with 7 additions and 7 deletions

View File

@ -992,9 +992,9 @@ class NewPayloadRequest(object):
def notify_new_payload(self: ExecutionEngine, def notify_new_payload(self: ExecutionEngine,
execution_payload: ExecutionPayload, execution_payload: ExecutionPayload,
parent_beacon_block_root: Root, parent_beacon_block_root: Root,
execution_requests_list: list[bytes]) -> bool: execution_requests_list: Sequence[bytes]) -> bool:
""" """
Return ``True`` if and only if ``execution_payload`` and ``execution_requests`` Return ``True`` if and only if ``execution_payload`` and ``execution_requests``
are valid with respect to ``self.execution_state``. are valid with respect to ``self.execution_state``.
""" """
... ...
@ -1145,7 +1145,7 @@ def process_withdrawals(state: BeaconState, payload: ExecutionPayload) -> None:
*Note*: Encodes execution requests as defined by [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685). *Note*: Encodes execution requests as defined by [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685).
```python ```python
def get_execution_requests_list(execution_requests: ExecutionRequests) -> list[bytes]: def get_execution_requests_list(execution_requests: ExecutionRequests) -> Sequence[bytes]:
deposit_bytes = serialize(execution_requests.deposits) deposit_bytes = serialize(execution_requests.deposits)
withdrawal_bytes = serialize(execution_requests.withdrawals) withdrawal_bytes = serialize(execution_requests.withdrawals)
consolidation_bytes = serialize(execution_requests.consolidations) consolidation_bytes = serialize(execution_requests.consolidations)

View File

@ -54,7 +54,7 @@ class GetPayloadResponse(object):
execution_payload: ExecutionPayload execution_payload: ExecutionPayload
block_value: uint256 block_value: uint256
blobs_bundle: BlobsBundle blobs_bundle: BlobsBundle
execution_requests: List[bytes] # [New in Electra] execution_requests: Sequence[bytes] # [New in Electra]
``` ```
## Containers ## Containers
@ -90,7 +90,7 @@ has been built since the corresponding call to `notify_forkchoice_updated` metho
```python ```python
def get_payload(self: ExecutionEngine, payload_id: PayloadId) -> GetPayloadResponse: def get_payload(self: ExecutionEngine, payload_id: PayloadId) -> GetPayloadResponse:
""" """
Return ExecutionPayload, uint256, BlobsBundle and List[bytes] objects. Return ExecutionPayload, uint256, BlobsBundle and Sequence[bytes] objects.
""" """
# pylint: disable=unused-argument # pylint: disable=unused-argument
... ...
@ -194,10 +194,10 @@ in [EIP-7685](https://eips.ethereum.org/EIPS/eip-7685). The index of each elemen
2. Set `block.body.execution_requests = get_execution_requests(execution_requests)`, where: 2. Set `block.body.execution_requests = get_execution_requests(execution_requests)`, where:
```python ```python
def get_execution_requests(execution_requests: List[bytes]) -> ExecutionRequests: def get_execution_requests(execution_requests: Sequence[bytes]) -> ExecutionRequests:
deposits = deserialize(List[DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD], execution_requests[0]) deposits = deserialize(List[DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD], execution_requests[0])
withdrawals = deserialize(List[WithdrawalRequest, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD], execution_requests[1]) withdrawals = deserialize(List[WithdrawalRequest, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD], execution_requests[1])
consolidations = deserialize(List[ConsolidationRequest, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD], consolidations = deserialize(List[ConsolidationRequest, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD],
execution_requests[2]) execution_requests[2])
return ExecutionRequests(deposits, withdrawals, consolidations) return ExecutionRequests(deposits, withdrawals, consolidations)