Skip to content

Commit

Permalink
post-review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
gurukamath committed May 13, 2024
1 parent 4dcfb25 commit 7dfd46f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
18 changes: 12 additions & 6 deletions src/ethereum/prague/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,22 @@ class Receipt:
logs: Tuple[Log, ...]


def validate_requests(requests: Tuple[Bytes, ...]) -> bool:
def validate_requests(requests: Tuple[Bytes, ...]) -> None:
"""
Validate a list of requests.
"""
current_request_type = b"\x00"
for request in requests:
if request[:1] < current_request_type:
return False
current_request_type = request[:1]
return True
request_type = request[:1]

# Ensure that no undefined requests are present.
if request_type != DEPOSIT_REQUEST_TYPE:
raise InvalidBlock("BlockException.INVALID_REQUESTS")

# Ensure that requests are in order.
if request_type < current_request_type:
raise InvalidBlock("BlockException.INVALID_REQUESTS")
current_request_type = request_type


@slotted_freezable
Expand All @@ -144,7 +150,7 @@ class DepositRequest:
index: U64


Request = DepositRequest
Request = Union[DepositRequest]


def encode_request(req: Request) -> Bytes:
Expand Down
3 changes: 1 addition & 2 deletions src/ethereum/prague/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,7 @@ def apply_body(
destroy_account(state, wd.address)

# Requests are to be in ascending order of request type
if not validate_requests(requests):
raise InvalidBlock
validate_requests(requests)

validate_deposit_requests(receipts, requests)
for i, request in enumerate(requests):
Expand Down

0 comments on commit 7dfd46f

Please sign in to comment.