Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/getting_started/code_standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ Code pushed to @ethereum/execution-spec-tests must fulfill the following checks
- **Relative Imports**: Use relative imports within the same package
- **Error Handling**: Use explicit exception types and meaningful error messages.
- **Type Hints**: All functions should include type annotations.
- **Unused Function Arguments**: When unavoidable, use `del`, e.g., `del unused_var`, at function start to avoid flagging linter errors.
- **Variable Naming**:
- Use `snake_case` for variables, functions, and modules.
- Use `PascalCase` for classes.
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,13 @@ ethereum_test_forks = ["forks/contracts/*.bin"]
line-length = 99

[tool.ruff.lint]
select = ["E", "F", "B", "W", "I", "A", "N", "D", "C"]
select = ["E", "F", "B", "W", "I", "A", "N", "D", "C", "ARG001"]
fixable = ["I", "B", "E", "F", "W", "D", "C"]
ignore = ["D205", "D203", "D212", "D415", "C420", "C901"]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["ARG001"] # TODO: ethereum/execution-spec-tests#2188

[tool.mypy]
disable_error_code = ["import-untyped"]
mypy_path = ["src", "$MYPY_CONFIG_FILE_DIR/stubs"]
Expand Down
15 changes: 1 addition & 14 deletions src/cli/gen_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,6 @@ def count_json_files_exclude_index(start_path: Path) -> int:
required=True,
help="The input directory",
)
@click.option(
"--disable-infer-format",
"-d",
"disable_infer_format",
is_flag=True,
default=False,
expose_value=True,
help="Don't try to guess the fixture format from the json file's path.",
)
@click.option(
"--quiet",
"-q",
Expand All @@ -80,23 +71,19 @@ def count_json_files_exclude_index(start_path: Path) -> int:
expose_value=True,
help="Force re-generation of the index file, even if it already exists.",
)
def generate_fixtures_index_cli(
input_dir: str, quiet_mode: bool, force_flag: bool, disable_infer_format: bool
):
def generate_fixtures_index_cli(input_dir: str, quiet_mode: bool, force_flag: bool):
"""CLI wrapper to an index of all the fixtures in the specified directory."""
generate_fixtures_index(
Path(input_dir),
quiet_mode=quiet_mode,
force_flag=force_flag,
disable_infer_format=disable_infer_format,
)


def generate_fixtures_index(
input_path: Path,
quiet_mode: bool = False,
force_flag: bool = False,
disable_infer_format: bool = False,
):
"""
Generate an index file (index.json) of all the fixtures in the specified
Expand Down
1 change: 1 addition & 0 deletions src/cli/gentest/tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def test_tx_type(pytester, tmp_path, monkeypatch, tx_type, transaction_hash, def
tx = transactions_by_type[tx_type]

def get_mock_context(self: StateTestProvider) -> dict:
del self
return tx

monkeypatch.setattr(StateTestProvider, "get_context", get_mock_context)
Expand Down
2 changes: 2 additions & 0 deletions src/cli/pytest_commands/check_eip_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
@common_pytest_options
def check_eip_versions(pytest_args: List[str], **kwargs) -> None:
"""Run pytest with the `spec_version_checker` plugin."""
del kwargs

command = PytestCommand(
config_file="pytest-check-eip-versions.ini",
argument_processors=[HelpFlagsProcessor("check-eip-versions")],
Expand Down
2 changes: 2 additions & 0 deletions src/cli/pytest_commands/checklist.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def checklist(output: str, eip: tuple, **kwargs) -> None:
uv run checklist --output ./my-checklists

"""
del kwargs

# Add output directory to pytest args
args = ["--checklist-output", output]

Expand Down
8 changes: 6 additions & 2 deletions src/cli/pytest_commands/consume.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def create_consume_command(
)


def get_command_logic_test_paths(command_name: str, is_hive: bool) -> List[Path]:
def get_command_logic_test_paths(command_name: str) -> List[Path]:
"""Determine the command paths based on the command name and hive flag."""
base_path = Path("pytest_plugins/consume")
if command_name in ["engine", "rlp"]:
Expand Down Expand Up @@ -66,7 +66,7 @@ def consume_command(is_hive: bool = False) -> Callable[[Callable[..., Any]], cli
def decorator(func: Callable[..., Any]) -> click.Command:
command_name = func.__name__
command_help = func.__doc__
command_logic_test_paths = get_command_logic_test_paths(command_name, is_hive)
command_logic_test_paths = get_command_logic_test_paths(command_name)

@consume.command(
name=command_name,
Expand All @@ -76,6 +76,8 @@ def decorator(func: Callable[..., Any]) -> click.Command:
@common_pytest_options
@functools.wraps(func)
def command(pytest_args: List[str], **kwargs) -> None:
del kwargs

consume_cmd = create_consume_command(
command_logic_test_paths=command_logic_test_paths,
is_hive=is_hive,
Expand Down Expand Up @@ -118,5 +120,7 @@ def sync() -> None:
@common_pytest_options
def cache(pytest_args: List[str], **kwargs) -> None:
"""Consume command to cache test fixtures."""
del kwargs

cache_cmd = create_consume_command(command_logic_test_paths=[], is_hive=False)
cache_cmd.execute(list(pytest_args))
4 changes: 4 additions & 0 deletions src/cli/pytest_commands/fill.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ def create_executions(self, pytest_args: List[str]) -> List[PytestExecution]:
@common_pytest_options
def fill(pytest_args: List[str], **kwargs) -> None:
"""Entry point for the fill command."""
del kwargs

command = FillCommand()
command.execute(list(pytest_args))

Expand All @@ -225,6 +227,8 @@ def fill(pytest_args: List[str], **kwargs) -> None:
@common_pytest_options
def phil(pytest_args: List[str], **kwargs) -> None:
"""Friendly alias for the fill command."""
del kwargs

command = PhilCommand()
command.execute(list(pytest_args))

Expand Down
4 changes: 2 additions & 2 deletions src/cli/show_pre_alloc_group_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def calculate_size_distribution(
return group_distribution, test_distribution


def analyze_pre_alloc_folder(folder: Path, verbose: int = 0) -> Dict:
def analyze_pre_alloc_folder(folder: Path) -> Dict:
"""Analyze pre-allocation folder and return statistics."""
pre_alloc_groups = PreAllocGroups.from_folder(folder, lazy_load=False)

Expand Down Expand Up @@ -480,7 +480,7 @@ def main(pre_alloc_folder: Path, verbose: int):
console = Console()

try:
stats = analyze_pre_alloc_folder(pre_alloc_folder, verbose=verbose)
stats = analyze_pre_alloc_folder(pre_alloc_folder)
display_stats(stats, console, verbose=verbose)
except FileNotFoundError:
console.print(f"[red]Error: Folder not found: {pre_alloc_folder}[/red]")
Expand Down
2 changes: 1 addition & 1 deletion src/cli/tests/test_pytest_execute_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_execute_help_shows_subcommand_docstrings(runner):
assert "Recover funds from test executions" in result.output


def test_execute_subcommands_have_help_text(runner):
def test_execute_subcommands_have_help_text():
"""Test that execute sub-commands have proper help text defined."""
from ..pytest_commands.execute import hive, recover, remote

Expand Down
18 changes: 2 additions & 16 deletions src/ethereum_clis/tests/test_execution_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ethereum_clis import ExecutionSpecsTransitionTool, TransitionTool
from ethereum_test_base_types import to_json
from ethereum_test_forks import Berlin, Fork, Istanbul, London
from ethereum_test_forks import Berlin
from ethereum_test_types import Alloc, Environment, Transaction

FIXTURES_ROOT = Path(os.path.join("src", "ethereum_clis", "tests", "fixtures"))
Expand All @@ -34,9 +34,8 @@ def monkeypatch_path_for_entry_points(monkeypatch):
monkeypatch.setenv("PATH", f"{bin_dir}:{os.environ['PATH']}")


@pytest.mark.parametrize("fork", [London, Istanbul])
@pytest.mark.parametrize(
"alloc,base_fee,expected_hash",
"alloc,expected_hash",
[
(
{
Expand All @@ -47,7 +46,6 @@ def monkeypatch_path_for_entry_points(monkeypatch):
"storage": {},
},
},
7,
bytes.fromhex("51e7c7508e76dca0"),
),
(
Expand All @@ -56,7 +54,6 @@ def monkeypatch_path_for_entry_points(monkeypatch):
"balance": "0x0BA1A9CE0BA1A9CE",
},
},
None,
bytes.fromhex("51e7c7508e76dca0"),
),
(
Expand All @@ -68,7 +65,6 @@ def monkeypatch_path_for_entry_points(monkeypatch):
"storage": {},
},
},
None,
bytes.fromhex("37c2dedbdea6b3af"),
),
(
Expand All @@ -80,25 +76,15 @@ def monkeypatch_path_for_entry_points(monkeypatch):
},
},
},
None,
bytes.fromhex("096122e88929baec"),
),
],
)
def test_calc_state_root(
default_t8n: TransitionTool,
fork: Fork,
alloc: Dict,
base_fee: int | None,
expected_hash: bytes,
) -> None:
"""Test calculation of the state root against expected hash."""

class TestEnv:
base_fee: int | None

env = TestEnv()
env.base_fee = base_fee
assert Alloc(alloc).state_root().startswith(expected_hash)


Expand Down
2 changes: 2 additions & 0 deletions src/ethereum_clis/tests/test_transition_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ def __init__(self, stdout):
self.returncode = 0

def mock_which(self):
del self
return which_result

def mock_run(args, **kwargs):
del args, kwargs
return MockCompletedProcess(read_result.encode())

monkeypatch.setattr(shutil, "which", mock_which)
Expand Down
2 changes: 2 additions & 0 deletions src/ethereum_test_base_types/tests/test_reference_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def test_git_reference_spec(monkeypatch):
"""Test Git reference spec."""

def mock_get(self, headers=None):
del self, headers

class Response:
content = (
'{"content": "'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def extract_markdown_ids(markdown_content: str) -> Set[str]:
return ids


def get_all_checklist_ids(obj, current_path="") -> Set[str]:
def get_all_checklist_ids(obj) -> Set[str]:
"""Recursively extract all checklist IDs from EIPChecklist and its children."""
ids = set()

Expand Down
11 changes: 11 additions & 0 deletions src/ethereum_test_forks/forks/forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ def calldata_gas_calculator(
gas_costs = cls.gas_costs(block_number, timestamp)

def fn(*, data: BytesConvertible, floor: bool = False) -> int:
del floor

cost = 0
for b in Bytes(data):
if b == 0:
Expand Down Expand Up @@ -201,6 +203,7 @@ def transaction_data_floor_cost_calculator(
"""At frontier, the transaction data floor cost is a constant zero."""

def fn(*, data: BytesConvertible) -> int:
del data
return 0

return fn
Expand All @@ -221,6 +224,8 @@ def fn(
authorization_list_or_count: Sized | int | None = None,
return_cost_deducted_prior_execution: bool = False,
) -> int:
del return_cost_deducted_prior_execution

assert access_list is None, f"Access list is not supported in {cls.name()}"
assert authorization_list_or_count is None, (
f"Authorizations are not supported in {cls.name()}"
Expand Down Expand Up @@ -694,6 +699,8 @@ def fn(
authorization_list_or_count: Sized | int | None = None,
return_cost_deducted_prior_execution: bool = False,
) -> int:
del return_cost_deducted_prior_execution

intrinsic_cost: int = super_fn(
calldata=calldata,
contract_creation=contract_creation,
Expand Down Expand Up @@ -885,6 +892,8 @@ def fn(
authorization_list_or_count: Sized | int | None = None,
return_cost_deducted_prior_execution: bool = False,
) -> int:
del return_cost_deducted_prior_execution

intrinsic_cost: int = super_fn(
calldata=calldata,
contract_creation=contract_creation,
Expand Down Expand Up @@ -1207,6 +1216,8 @@ def fn(
parent_blob_count: int | None = None,
parent_base_fee_per_gas: int, # Required for Osaka as using this as base
) -> int:
del parent_base_fee_per_gas

if parent_excess_blob_gas is None:
assert parent_excess_blobs is not None, "Parent excess blobs are required"
parent_excess_blob_gas = parent_excess_blobs * blob_gas_per_blob
Expand Down
3 changes: 1 addition & 2 deletions src/ethereum_test_forks/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
ValidatorFunctionWrapHandler,
model_validator,
)
from semver import Version

from .base_fork import BaseFork
from .forks import forks, transition
Expand Down Expand Up @@ -86,7 +85,7 @@ def get_parent_fork(fork: Type[BaseFork]) -> Type[BaseFork]:
return parent_fork


def get_closest_fork(fork: Type[BaseFork], solc_version: Version) -> Optional[Type[BaseFork]]:
def get_closest_fork(fork: Type[BaseFork]) -> Optional[Type[BaseFork]]:
"""Return None if BaseFork is passed, otherwise return the fork itself."""
if fork is BaseFork:
return None
Expand Down
2 changes: 2 additions & 0 deletions src/ethereum_test_forks/transition_base_fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def transition_method(
block_number: int = ALWAYS_TRANSITIONED_BLOCK_NUMBER,
timestamp: int = ALWAYS_TRANSITIONED_BLOCK_TIMESTAMP,
):
del cls

kwargs = {}
if "block_number" in base_method_parameters:
kwargs["block_number"] = block_number
Expand Down
3 changes: 2 additions & 1 deletion src/ethereum_test_types/block_access_list/modifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ def transform(bal: BlockAccessList) -> BlockAccessList:
def clear_all() -> Callable[[BlockAccessList], BlockAccessList]:
"""Return an empty BAL."""

def transform(_bal: BlockAccessList) -> BlockAccessList:
def transform(bal: BlockAccessList) -> BlockAccessList:
del bal
return BlockAccessList(root=[])

return transform
Expand Down
1 change: 0 additions & 1 deletion src/ethereum_test_types/tests/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@
],
)
def test_transaction_signing(
request,
tx: Transaction,
expected_signature: Tuple[int, int, int],
expected_sender: str,
Expand Down
1 change: 0 additions & 1 deletion src/pytest_plugins/consume/consume.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@ def pytest_configure(config): # noqa: D103
config.fixtures_source.path,
quiet_mode=False,
force_flag=False,
disable_infer_format=False,
)

index = IndexFile.model_validate_json(index_file.read_text())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def __init__(self, *args: object) -> None:

def wait_for_sync(
sync_eth_rpc: EthRPC,
sync_engine_rpc: EngineRPC,
expected_block_hash: str | Hash,
timeout: int = 10,
poll_interval: float = 1.0,
Expand Down Expand Up @@ -105,7 +104,6 @@ def test_blockchain_via_sync(
eth_rpc: EthRPC,
engine_rpc: EngineRPC,
net_rpc: NetRPC,
admin_rpc: AdminRPC,
sync_eth_rpc: EthRPC,
sync_engine_rpc: EngineRPC,
sync_net_rpc: NetRPC,
Expand Down Expand Up @@ -472,7 +470,7 @@ def test_blockchain_via_sync(
# Final verification
assert sync_eth_rpc is not None, "sync_eth_rpc is required"
assert sync_engine_rpc is not None, "sync_engine_rpc is required"
if wait_for_sync(sync_eth_rpc, sync_engine_rpc, last_valid_block_hash, timeout=5):
if wait_for_sync(sync_eth_rpc, last_valid_block_hash, timeout=5):
logger.info("Sync verification successful!")

# Verify the final state
Expand Down
Loading
Loading