Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ethereum/forks/amsterdam/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class Withdrawal:
The execution-layer address receiving the withdrawn ETH.
"""

amount: U256
amount: U64
"""
The amount of ETH being withdrawn.
The amount of ETH being withdrawn, in Gwei.
"""


Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/forks/amsterdam/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def process_withdrawals(
rlp.encode(wd),
)

create_ether(wd_state, wd.address, wd.amount * GWEI_TO_WEI)
create_ether(wd_state, wd.address, U256(wd.amount) * GWEI_TO_WEI)

incorporate_tx_into_block(wd_state, block_env.block_access_list_builder)

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/bpo1/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class Withdrawal:
The execution-layer address receiving the withdrawn ETH.
"""

amount: U256
amount: U64
"""
The amount of ETH being withdrawn.
The amount of ETH being withdrawn, in Gwei.
"""


Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/forks/bpo1/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def process_withdrawals(
rlp.encode(wd),
)

create_ether(wd_state, wd.address, wd.amount * U256(10**9))
create_ether(wd_state, wd.address, U256(wd.amount) * U256(10**9))

incorporate_tx_into_block(wd_state)

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/bpo2/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class Withdrawal:
The execution-layer address receiving the withdrawn ETH.
"""

amount: U256
amount: U64
"""
The amount of ETH being withdrawn.
The amount of ETH being withdrawn, in Gwei.
"""


Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/forks/bpo2/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def process_withdrawals(
rlp.encode(wd),
)

create_ether(wd_state, wd.address, wd.amount * U256(10**9))
create_ether(wd_state, wd.address, U256(wd.amount) * U256(10**9))

incorporate_tx_into_block(wd_state)

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/bpo3/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class Withdrawal:
The execution-layer address receiving the withdrawn ETH.
"""

amount: U256
amount: U64
"""
The amount of ETH being withdrawn.
The amount of ETH being withdrawn, in Gwei.
"""


Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/forks/bpo3/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def process_withdrawals(
rlp.encode(wd),
)

create_ether(wd_state, wd.address, wd.amount * U256(10**9))
create_ether(wd_state, wd.address, U256(wd.amount) * U256(10**9))

incorporate_tx_into_block(wd_state)

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/bpo4/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class Withdrawal:
The execution-layer address receiving the withdrawn ETH.
"""

amount: U256
amount: U64
"""
The amount of ETH being withdrawn.
The amount of ETH being withdrawn, in Gwei.
"""


Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/forks/bpo4/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def process_withdrawals(
rlp.encode(wd),
)

create_ether(wd_state, wd.address, wd.amount * U256(10**9))
create_ether(wd_state, wd.address, U256(wd.amount) * U256(10**9))

incorporate_tx_into_block(wd_state)

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/bpo5/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class Withdrawal:
The execution-layer address receiving the withdrawn ETH.
"""

amount: U256
amount: U64
"""
The amount of ETH being withdrawn.
The amount of ETH being withdrawn, in Gwei.
"""


Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/forks/bpo5/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def process_withdrawals(
rlp.encode(wd),
)

create_ether(wd_state, wd.address, wd.amount * U256(10**9))
create_ether(wd_state, wd.address, U256(wd.amount) * U256(10**9))

incorporate_tx_into_block(wd_state)

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/cancun/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ class Withdrawal:
The execution-layer address receiving the withdrawn ETH.
"""

amount: U256
amount: U64
"""
The amount of ETH being withdrawn.
The amount of ETH being withdrawn, in Gwei.
"""


Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/forks/cancun/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def process_withdrawals(
rlp.encode(wd),
)

create_ether(wd_state, wd.address, wd.amount * U256(10**9))
create_ether(wd_state, wd.address, U256(wd.amount) * U256(10**9))

incorporate_tx_into_block(wd_state)

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/osaka/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class Withdrawal:
The execution-layer address receiving the withdrawn ETH.
"""

amount: U256
amount: U64
"""
The amount of ETH being withdrawn.
The amount of ETH being withdrawn, in Gwei.
"""


Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/forks/osaka/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def process_withdrawals(
rlp.encode(wd),
)

create_ether(wd_state, wd.address, wd.amount * U256(10**9))
create_ether(wd_state, wd.address, U256(wd.amount) * U256(10**9))

incorporate_tx_into_block(wd_state)

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/prague/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class Withdrawal:
The execution-layer address receiving the withdrawn ETH.
"""

amount: U256
amount: U64
"""
The amount of ETH being withdrawn.
The amount of ETH being withdrawn, in Gwei.
"""


Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/forks/prague/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ def process_withdrawals(
rlp.encode(wd),
)

create_ether(wd_state, wd.address, wd.amount * U256(10**9))
create_ether(wd_state, wd.address, U256(wd.amount) * U256(10**9))

incorporate_tx_into_block(wd_state)

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/shanghai/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ class Withdrawal:
The execution-layer address receiving the withdrawn ETH.
"""

amount: U256
amount: U64
"""
The amount of ETH being withdrawn.
The amount of ETH being withdrawn, in Gwei.
"""


Expand Down
2 changes: 1 addition & 1 deletion src/ethereum/forks/shanghai/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ def process_withdrawals(
rlp.encode(wd),
)

create_ether(wd_state, wd.address, wd.amount * U256(10**9))
create_ether(wd_state, wd.address, U256(wd.amount) * U256(10**9))

incorporate_tx_into_block(wd_state)

Expand Down
4 changes: 2 additions & 2 deletions src/ethereum_spec_tools/evm_tools/b11r/b11r_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Body:

transactions: rlp.Extended
ommers: rlp.Extended
withdrawals: Optional[List[Tuple[U64, U64, Bytes20, Uint]]]
withdrawals: Optional[List[Tuple[U64, U64, Bytes20, U64]]]

def __init__(self, options: Any, stdin: Any = None):
# Parse transactions
Expand Down Expand Up @@ -83,7 +83,7 @@ def __init__(self, options: Any, stdin: Any = None):
parse_hex_or_int(wd["index"], U64),
parse_hex_or_int(wd["validatorIndex"], U64),
Bytes20(hex_to_bytes(wd["address"])),
parse_hex_or_int(wd["amount"], Uint),
parse_hex_or_int(wd["amount"], U64),
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def json_to_withdrawals(self, raw: Any) -> Any:
hex_to_u64(raw.get("index")),
hex_to_u64(raw.get("validatorIndex")),
self.fork.hex_to_address(raw.get("address")),
hex_to_u256(raw.get("amount")),
hex_to_u64(raw.get("amount")),
]

return self.fork.Withdrawal(*parameters)
Expand Down
2 changes: 1 addition & 1 deletion src/ethereum_spec_tools/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ def make_block(self, json: Any, ommers: Any) -> Any:
self.module("utils.hexadecimal").hex_to_address(
j["address"]
),
hex_to_u256(j["amount"]),
hex_to_u64(j["amount"]),
)
)

Expand Down
28 changes: 28 additions & 0 deletions tests/json_loader/test_withdrawal_codec.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""Test that withdrawal amounts decode as 64-bit unsigned integers."""

import pytest
from ethereum_rlp import rlp
from ethereum_rlp.exceptions import RLPException
from ethereum_types.numeric import U64, U256

from ethereum.forks.amsterdam.blocks import Withdrawal
from ethereum.state import Address


def test_decode_max_withdrawal_amount() -> None:
"""Round-trip a withdrawal with the largest valid amount."""
withdrawal = Withdrawal(
index=U64(0),
validator_index=U64(0),
address=Address(b"\x00" * 20),
amount=U64(2**64 - 1),
)
encoded = rlp.encode(withdrawal)
assert rlp.decode_to(Withdrawal, encoded) == withdrawal


def test_decode_oversized_withdrawal_amount() -> None:
"""Reject a withdrawal whose amount does not fit in 64 bits."""
encoded = rlp.encode((U64(0), U64(0), Address(b"\x00" * 20), U256(2**64)))
with pytest.raises(RLPException):
rlp.decode_to(Withdrawal, encoded)