Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add supported fork info to evm tools help #813

Merged
merged 1 commit into from
Jul 25, 2023
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
9 changes: 8 additions & 1 deletion src/ethereum_spec_tools/evm_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

from .b11r import B11R, b11r_arguments
from .t8n import T8N, t8n_arguments
from .utils import get_supported_forks

DESCRIPTION = """
DESCRIPTION = (
"""
This is the EVM tool for execution specs. The EVM tool
provides a few useful subcommands to facilitate testing
at the EVM layer.
Expand All @@ -18,7 +20,12 @@
You can use this to run the following tools:
1. t8n: A stateless state transition utility.
2. b11r: The tool is used to assemble and seal full block rlps.
The following forks are supported:
"""
+ get_supported_forks()
)

parser = argparse.ArgumentParser(
description=DESCRIPTION,
Expand Down
23 changes: 23 additions & 0 deletions src/ethereum_spec_tools/evm_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from ethereum.base_types import U64, U256, Uint
from ethereum.crypto.hash import Hash32

from ..forks import Hardfork

W = TypeVar("W", Uint, U64, U256)

EXCEPTION_MAPS = {
Expand Down Expand Up @@ -123,6 +125,27 @@ def get_module_name(forks: Any, options: Any, stdin: Any) -> Tuple[str, int]:
sys.exit(f"Unsupported state fork: {options.state_fork}")


def get_supported_forks() -> str:
"""
Get the supported forks.
"""
supported_forks = [
fork.title_case_name.replace(" ", "") for fork in Hardfork.discover()
]

# Add the exception forks
supported_forks.extend(EXCEPTION_MAPS.keys())

# Remove the unsupported forks
supported_forks = [
fork
for fork in supported_forks
if fork.casefold() not in UNSUPPORTED_FORKS
]

return "\n".join(supported_forks)


def get_stream_logger(name: str) -> Any:
"""
Get a logger that writes to stdout.
Expand Down
Loading