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

CHIA-2215 Annotate run_block.py #19128

Merged
merged 1 commit into from
Jan 13, 2025
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: 0 additions & 1 deletion mypy-exclusions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,3 @@ chia._tests.util.time_out_assert
chia._tests.wallet.did_wallet.test_did
chia._tests.wallet.rpc.test_wallet_rpc
tools.analyze-chain
tools.run_block
9 changes: 5 additions & 4 deletions tools/run_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,25 @@

import json
from pathlib import Path
from typing import Any

import click

from chia._tests.util.run_block import run_json_block
from chia.consensus.constants import replace_str_to_bytes
from chia.consensus.constants import ConsensusConstants, replace_str_to_bytes
from chia.consensus.default_constants import DEFAULT_CONSTANTS
from chia.util.config import load_config
from chia.util.default_root import DEFAULT_ROOT_PATH


@click.command()
@click.argument("filename", type=click.Path(exists=True), default="testnet10.396963.json")
def cmd_run_json_block_file(filename):
def cmd_run_json_block_file(filename: str) -> None:
"""`file` is a file containing a FullBlock in JSON format"""
return run_json_block_file(Path(filename))


def run_json_block_file(filename: Path):
def run_json_block_file(filename: Path) -> None:
full_block = json.load(filename.open("rb"))
# pull in current constants from config.yaml
_, constants = get_config_and_constants()
Expand All @@ -68,7 +69,7 @@ def run_json_block_file(filename: Path):
print(cat_list_json)


def get_config_and_constants():
def get_config_and_constants() -> tuple[dict[str, Any], ConsensusConstants]:
config = load_config(DEFAULT_ROOT_PATH, "config.yaml")
network = config["selected_network"]
overrides = config["network_overrides"]["constants"][network]
Expand Down
Loading