Skip to content

Commit

Permalink
Use Hardfork.consensus to test consensus type
Browse files Browse the repository at this point in the history
  • Loading branch information
petertdavies committed Aug 3, 2023
1 parent 29efa45 commit 21427b9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/ethereum_optimized/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from importlib import import_module
from typing import Any, Optional, cast

from ethereum.fork_criteria import ByBlockNumber
from ethereum_spec_tools.forks import Hardfork

from .fork import get_optimized_pow_patches
Expand Down Expand Up @@ -73,8 +72,5 @@ def monkey_patch(state_path: Optional[str]) -> None:
monkey_patch_optimized_state_db(fork.short_name, state_path)

# Only patch the POW code on POW forks
if (
isinstance(fork.criteria, ByBlockNumber)
and fork.short_name != "paris"
):
if fork.consensus.is_pow():
monkey_patch_optimized_spec(fork.short_name)
6 changes: 6 additions & 0 deletions src/ethereum_optimized/fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ def get_optimized_pow_patches(_fork_name: str) -> Dict[str, Any]:
patches: Dict[str, Any] = {}

mod = cast(Any, import_module("ethereum." + _fork_name + ".fork"))

if not hasattr(mod, "validate_proof_of_work"):
raise Exception(
"Attempted to get optimized pow patches for non-pow fork"
)

generate_header_hash_for_pow = mod.generate_header_hash_for_pow

@add_item(patches)
Expand Down

0 comments on commit 21427b9

Please sign in to comment.