Skip to content

Commit

Permalink
add supported fork info in help
Browse files Browse the repository at this point in the history
  • Loading branch information
gurukamath committed Jul 14, 2023
1 parent 2da1ad3 commit eb7c698
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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

0 comments on commit eb7c698

Please sign in to comment.