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/block_access_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ethereum_rlp import rlp
from ethereum_types.bytes import Bytes, Bytes32
from ethereum_types.frozen import slotted_freezable
from ethereum_types.numeric import U16, U64, U256, Uint
from ethereum_types.numeric import U16, U64, U256, Uint, ulen

from ethereum.crypto.hash import Hash32, keccak256
from ethereum.state import EMPTY_CODE_HASH, Account, Address, PreState
Expand Down Expand Up @@ -760,7 +760,7 @@ def validate_block_access_list_gas_limit(
unique_slots.add(slot)

# Count each unique storage key as one item
bal_items += Uint(len(unique_slots))
bal_items += ulen(unique_slots)

if bal_items > block_gas_limit // GAS_BLOCK_ACCESS_LIST_ITEM:
raise BlockAccessListGasLimitExceededError(
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/amsterdam/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ethereum_rlp import rlp
from ethereum_types.bytes import Bytes
from ethereum_types.frozen import slotted_freezable
from ethereum_types.numeric import U64, U256, Uint
from ethereum_types.numeric import U64, U256, Uint, ulen

from ethereum.crypto.hash import Hash32, keccak256
from ethereum.exceptions import (
Expand Down Expand Up @@ -854,7 +854,7 @@ def apply_body(

# EIP-7928: Post-execution operations use index N+1
block_env.block_access_list_builder.block_access_index = BlockAccessIndex(
Uint(len(transactions)) + Uint(1)
ulen(transactions) + Uint(1)
)

process_withdrawals(block_env, block_output, withdrawals)
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/amsterdam/vm/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dataclasses import dataclass
from typing import List, Tuple

from ethereum_types.numeric import U64, U256, Uint
from ethereum_types.numeric import U64, U256, Uint, ulen

from ethereum.forks.bpo5.blocks import Header as PreviousHeader
from ethereum.trace import GasAndRefund, evm_trace
Expand Down Expand Up @@ -206,7 +206,7 @@ def calculate_gas_extend_memory(
"""
size_to_extend = Uint(0)
to_be_paid = Uint(0)
current_size = Uint(len(memory))
current_size = ulen(memory)
for start_position, size in extensions:
if size == 0:
continue
Expand Down
4 changes: 1 addition & 3 deletions src/ethereum/forks/amsterdam/vm/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,7 @@ def process_create_message(message: Message) -> Evm:
evm = process_message(message)
if not evm.error:
contract_code = evm.output
contract_code_gas = (
Uint(len(contract_code)) * GAS_CODE_DEPOSIT_PER_BYTE
)
contract_code_gas = ulen(contract_code) * GAS_CODE_DEPOSIT_PER_BYTE
try:
if len(contract_code) > 0:
if contract_code[0] == 0xEF:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Implementation of the `IDENTITY` precompiled contract.
"""

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.numeric import ceil32

Expand All @@ -36,7 +36,7 @@ def identity(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_IDENTITY_BASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import hashlib

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.byte import left_pad_zero_bytes
from ethereum.utils.numeric import ceil32
Expand All @@ -39,7 +39,7 @@ def ripemd160(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_RIPEMD160_BASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import hashlib

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.numeric import ceil32

Expand All @@ -38,7 +38,7 @@ def sha256(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_SHA256_BASE
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/arrow_glacier/vm/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dataclasses import dataclass
from typing import List, Tuple

from ethereum_types.numeric import U256, Uint
from ethereum_types.numeric import U256, Uint, ulen

from ethereum.trace import GasAndRefund, evm_trace
from ethereum.utils.numeric import ceil32
Expand Down Expand Up @@ -165,7 +165,7 @@ def calculate_gas_extend_memory(
"""
size_to_extend = Uint(0)
to_be_paid = Uint(0)
current_size = Uint(len(memory))
current_size = ulen(memory)
for start_position, size in extensions:
if size == 0:
continue
Expand Down
4 changes: 1 addition & 3 deletions src/ethereum/forks/arrow_glacier/vm/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ def process_create_message(message: Message) -> Evm:
evm = process_message(message)
if not evm.error:
contract_code = evm.output
contract_code_gas = (
Uint(len(contract_code)) * GAS_CODE_DEPOSIT_PER_BYTE
)
contract_code_gas = ulen(contract_code) * GAS_CODE_DEPOSIT_PER_BYTE
try:
if len(contract_code) > 0:
if contract_code[0] == 0xEF:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Implementation of the `IDENTITY` precompiled contract.
"""

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.numeric import ceil32

Expand All @@ -36,7 +36,7 @@ def identity(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_IDENTITY_BASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import hashlib

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.byte import left_pad_zero_bytes
from ethereum.utils.numeric import ceil32
Expand All @@ -39,7 +39,7 @@ def ripemd160(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_RIPEMD160_BASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import hashlib

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.numeric import ceil32

Expand All @@ -38,7 +38,7 @@ def sha256(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_SHA256_BASE
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/berlin/vm/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dataclasses import dataclass
from typing import List, Tuple

from ethereum_types.numeric import U256, Uint
from ethereum_types.numeric import U256, Uint, ulen

from ethereum.trace import GasAndRefund, evm_trace
from ethereum.utils.numeric import ceil32
Expand Down Expand Up @@ -166,7 +166,7 @@ def calculate_gas_extend_memory(
"""
size_to_extend = Uint(0)
to_be_paid = Uint(0)
current_size = Uint(len(memory))
current_size = ulen(memory)
for start_position, size in extensions:
if size == 0:
continue
Expand Down
4 changes: 1 addition & 3 deletions src/ethereum/forks/berlin/vm/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,7 @@ def process_create_message(message: Message) -> Evm:
evm = process_message(message)
if not evm.error:
contract_code = evm.output
contract_code_gas = (
Uint(len(contract_code)) * GAS_CODE_DEPOSIT_PER_BYTE
)
contract_code_gas = ulen(contract_code) * GAS_CODE_DEPOSIT_PER_BYTE
try:
charge_gas(evm, contract_code_gas)
if len(contract_code) > MAX_CODE_SIZE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Implementation of the `IDENTITY` precompiled contract.
"""

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.numeric import ceil32

Expand All @@ -36,7 +36,7 @@ def identity(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_IDENTITY_BASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import hashlib

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.byte import left_pad_zero_bytes
from ethereum.utils.numeric import ceil32
Expand All @@ -39,7 +39,7 @@ def ripemd160(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_RIPEMD160_BASE
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/berlin/vm/precompiled_contracts/sha256.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import hashlib

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.numeric import ceil32

Expand All @@ -38,7 +38,7 @@ def sha256(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_SHA256_BASE
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/bpo1/vm/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dataclasses import dataclass
from typing import List, Tuple

from ethereum_types.numeric import U64, U256, Uint
from ethereum_types.numeric import U64, U256, Uint, ulen

from ethereum.trace import GasAndRefund, evm_trace
from ethereum.utils.numeric import ceil32, taylor_exponential
Expand Down Expand Up @@ -186,7 +186,7 @@ def calculate_gas_extend_memory(
"""
size_to_extend = Uint(0)
to_be_paid = Uint(0)
current_size = Uint(len(memory))
current_size = ulen(memory)
for start_position, size in extensions:
if size == 0:
continue
Expand Down
4 changes: 1 addition & 3 deletions src/ethereum/forks/bpo1/vm/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ def process_create_message(message: Message) -> Evm:
evm = process_message(message)
if not evm.error:
contract_code = evm.output
contract_code_gas = (
Uint(len(contract_code)) * GAS_CODE_DEPOSIT_PER_BYTE
)
contract_code_gas = ulen(contract_code) * GAS_CODE_DEPOSIT_PER_BYTE
try:
if len(contract_code) > 0:
if contract_code[0] == 0xEF:
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/bpo1/vm/precompiled_contracts/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Implementation of the `IDENTITY` precompiled contract.
"""

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.numeric import ceil32

Expand All @@ -36,7 +36,7 @@ def identity(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_IDENTITY_BASE
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/bpo1/vm/precompiled_contracts/ripemd160.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import hashlib

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.byte import left_pad_zero_bytes
from ethereum.utils.numeric import ceil32
Expand All @@ -39,7 +39,7 @@ def ripemd160(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_RIPEMD160_BASE
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/bpo1/vm/precompiled_contracts/sha256.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import hashlib

from ethereum_types.numeric import Uint
from ethereum_types.numeric import Uint, ulen

from ethereum.utils.numeric import ceil32

Expand All @@ -38,7 +38,7 @@ def sha256(evm: Evm) -> None:
data = evm.message.data

# GAS
word_count = ceil32(Uint(len(data))) // Uint(32)
word_count = ceil32(ulen(data)) // Uint(32)
charge_gas(
evm,
GAS_PRECOMPILE_SHA256_BASE
Expand Down
4 changes: 2 additions & 2 deletions src/ethereum/forks/bpo2/vm/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dataclasses import dataclass
from typing import List, Tuple

from ethereum_types.numeric import U64, U256, Uint
from ethereum_types.numeric import U64, U256, Uint, ulen

from ethereum.trace import GasAndRefund, evm_trace
from ethereum.utils.numeric import ceil32, taylor_exponential
Expand Down Expand Up @@ -186,7 +186,7 @@ def calculate_gas_extend_memory(
"""
size_to_extend = Uint(0)
to_be_paid = Uint(0)
current_size = Uint(len(memory))
current_size = ulen(memory)
for start_position, size in extensions:
if size == 0:
continue
Expand Down
4 changes: 1 addition & 3 deletions src/ethereum/forks/bpo2/vm/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,7 @@ def process_create_message(message: Message) -> Evm:
evm = process_message(message)
if not evm.error:
contract_code = evm.output
contract_code_gas = (
Uint(len(contract_code)) * GAS_CODE_DEPOSIT_PER_BYTE
)
contract_code_gas = ulen(contract_code) * GAS_CODE_DEPOSIT_PER_BYTE
try:
if len(contract_code) > 0:
if contract_code[0] == 0xEF:
Expand Down
Loading
Loading