From de4ae4eff73f150aa3842e3be19a784bd75e0192 Mon Sep 17 00:00:00 2001 From: Guruprasad Kamath Date: Tue, 18 Jun 2024 16:02:37 +0200 Subject: [PATCH] Withdrawal length constant --- src/ethereum/prague/blocks.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ethereum/prague/blocks.py b/src/ethereum/prague/blocks.py index 30509812b2..5e3aa58d00 100644 --- a/src/ethereum/prague/blocks.py +++ b/src/ethereum/prague/blocks.py @@ -39,6 +39,7 @@ ) DEPOSIT_REQUEST_TYPE = b"\x00" WITHDRAWAL_REQUEST_TYPE = b"\x01" +WITHDRAWAL_REQUEST_LENGTH = 76 @slotted_freezable @@ -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]), @@ -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),)