Skip to content

Commit

Permalink
Withdrawal length constant
Browse files Browse the repository at this point in the history
  • Loading branch information
gurukamath authored and SamWilsn committed Jun 18, 2024
1 parent 7b72f83 commit de4ae4e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/ethereum/prague/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
)
DEPOSIT_REQUEST_TYPE = b"\x00"
WITHDRAWAL_REQUEST_TYPE = b"\x01"
WITHDRAWAL_REQUEST_LENGTH = 76


@slotted_freezable
Expand Down Expand Up @@ -224,7 +225,7 @@ def parse_withdrawal_data(data: Bytes) -> WithdrawalRequest:
"""
Parses Withdrawal Request from the data.
"""
assert len(data) == 76
assert len(data) == WITHDRAWAL_REQUEST_LENGTH
req = WithdrawalRequest(
source_address=Address(data[:20]),
validator_pubkey=Bytes48(data[20:68]),
Expand All @@ -240,13 +241,15 @@ def parse_withdrawal_requests_from_system_tx(
"""
Parse withdrawal requests from the system transaction output.
"""
count_withdrawal_requests = len(evm_call_output) // 76
count_withdrawal_requests = (
len(evm_call_output) // WITHDRAWAL_REQUEST_LENGTH
)

withdrawal_requests: Tuple[Bytes, ...] = ()
for i in range(count_withdrawal_requests):
start = i * 76
start = i * WITHDRAWAL_REQUEST_LENGTH
withdrawal_request = parse_withdrawal_data(
evm_call_output[start : start + 76]
evm_call_output[start : start + WITHDRAWAL_REQUEST_LENGTH]
)
withdrawal_requests += (encode_request(withdrawal_request),)

Expand Down

0 comments on commit de4ae4e

Please sign in to comment.