diff --git a/src/ethereum/forks/arrow_glacier/__init__.py b/src/ethereum/forks/arrow_glacier/__init__.py index d09621313e..6e8798e713 100644 --- a/src/ethereum/forks/arrow_glacier/__init__.py +++ b/src/ethereum/forks/arrow_glacier/__init__.py @@ -28,6 +28,6 @@ [nm]: https://github.com/NethermindEth/nethermind/releases/tag/1.11.7 """ # noqa: E501 -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(13773000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(13773000) diff --git a/src/ethereum/forks/berlin/__init__.py b/src/ethereum/forks/berlin/__init__.py index 6f8f866ed6..3bc09c7878 100644 --- a/src/ethereum/forks/berlin/__init__.py +++ b/src/ethereum/forks/berlin/__init__.py @@ -38,6 +38,6 @@ [oe]: https://github.com/openethereum/openethereum/releases/tag/v3.2.0 """ # noqa: E501 -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(12244000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(12244000) diff --git a/src/ethereum/forks/byzantium/__init__.py b/src/ethereum/forks/byzantium/__init__.py index 5eea245f8d..3a39f7c38b 100644 --- a/src/ethereum/forks/byzantium/__init__.py +++ b/src/ethereum/forks/byzantium/__init__.py @@ -45,6 +45,6 @@ [p]: https://github.com/paritytech/parity/releases/tag/v1.7.6 """ -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(4370000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(4370000) diff --git a/src/ethereum/forks/cancun/__init__.py b/src/ethereum/forks/cancun/__init__.py index e4685c450b..fe0e897ee0 100644 --- a/src/ethereum/forks/cancun/__init__.py +++ b/src/ethereum/forks/cancun/__init__.py @@ -44,6 +44,6 @@ [r]: https://github.com/paradigmxyz/reth/releases/tag/v0.1.0-alpha.19 """ # noqa: E501 -from ethereum.fork_criteria import ByTimestamp +from ethereum.fork_criteria import ByTimestamp, ForkCriteria -FORK_CRITERIA = ByTimestamp(1710338135) +FORK_CRITERIA: ForkCriteria = ByTimestamp(1710338135) diff --git a/src/ethereum/forks/constantinople/__init__.py b/src/ethereum/forks/constantinople/__init__.py index d3ab9f2d28..7f40cdd28b 100644 --- a/src/ethereum/forks/constantinople/__init__.py +++ b/src/ethereum/forks/constantinople/__init__.py @@ -46,6 +46,6 @@ [t]: https://github.com/ethereum/trinity/releases/tag/v0.1.0-alpha.23 """ # noqa: E501 -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(7280000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(7280000) diff --git a/src/ethereum/forks/dao_fork/__init__.py b/src/ethereum/forks/dao_fork/__init__.py index bb879891ba..7516eb2de4 100644 --- a/src/ethereum/forks/dao_fork/__init__.py +++ b/src/ethereum/forks/dao_fork/__init__.py @@ -24,6 +24,6 @@ [Geth 1.4.10]: https://github.com/ethereum/go-ethereum/releases/tag/v1.4.10 """ -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(1920000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(1920000) diff --git a/src/ethereum/forks/dao_fork/fork.py b/src/ethereum/forks/dao_fork/fork.py index 147ec2dc13..38eb1e61c2 100644 --- a/src/ethereum/forks/dao_fork/fork.py +++ b/src/ethereum/forks/dao_fork/fork.py @@ -29,6 +29,7 @@ InvalidSenderError, NonceMismatchError, ) +from ethereum.fork_criteria import ByBlockNumber from . import FORK_CRITERIA, vm from .blocks import Block, Header, Log, Receipt @@ -271,6 +272,8 @@ def validate_header(chain: BlockChain, header: Header) -> None: if header.parent_hash != block_parent_hash: raise InvalidBlock + assert isinstance(FORK_CRITERIA, ByBlockNumber) + if ( header.number >= FORK_CRITERIA.block_number and header.number < FORK_CRITERIA.block_number + Uint(10) diff --git a/src/ethereum/forks/frontier/__init__.py b/src/ethereum/forks/frontier/__init__.py index 3a7fed59eb..cc69681a3a 100644 --- a/src/ethereum/forks/frontier/__init__.py +++ b/src/ethereum/forks/frontier/__init__.py @@ -2,6 +2,6 @@ Frontier is the first production-ready iteration of the Ethereum protocol. """ -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(0) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(0) diff --git a/src/ethereum/forks/gray_glacier/__init__.py b/src/ethereum/forks/gray_glacier/__init__.py index a0028106b9..c16a952fb9 100644 --- a/src/ethereum/forks/gray_glacier/__init__.py +++ b/src/ethereum/forks/gray_glacier/__init__.py @@ -29,6 +29,6 @@ [n]: https://github.com/NethermindEth/nethermind/releases/tag/1.13.3 """ # noqa: E501 -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(15050000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(15050000) diff --git a/src/ethereum/forks/homestead/__init__.py b/src/ethereum/forks/homestead/__init__.py index 2d6312d696..8367f4e003 100644 --- a/src/ethereum/forks/homestead/__init__.py +++ b/src/ethereum/forks/homestead/__init__.py @@ -29,6 +29,6 @@ [Geth 1.3.5]: https://github.com/ethereum/go-ethereum/releases/tag/v1.3.5 """ -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(1150000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(1150000) diff --git a/src/ethereum/forks/istanbul/__init__.py b/src/ethereum/forks/istanbul/__init__.py index fdb8b7aa8b..1b4f3b6153 100644 --- a/src/ethereum/forks/istanbul/__init__.py +++ b/src/ethereum/forks/istanbul/__init__.py @@ -48,6 +48,6 @@ [t]: https://github.com/ethereum/trinity/releases/tag/v0.1.0-alpha.31 """ -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(9069000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(9069000) diff --git a/src/ethereum/forks/london/__init__.py b/src/ethereum/forks/london/__init__.py index d4ee7aed3e..95caf15ed4 100644 --- a/src/ethereum/forks/london/__init__.py +++ b/src/ethereum/forks/london/__init__.py @@ -43,6 +43,6 @@ [oe]: https://github.com/openethereum/openethereum/releases/tag/v3.3.0-rc.4 """ # noqa: E501 -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(12965000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(12965000) diff --git a/src/ethereum/forks/london/fork.py b/src/ethereum/forks/london/fork.py index 14e2668987..01309a540a 100644 --- a/src/ethereum/forks/london/fork.py +++ b/src/ethereum/forks/london/fork.py @@ -28,6 +28,7 @@ InvalidSenderError, NonceMismatchError, ) +from ethereum.fork_criteria import ByBlockNumber from . import FORK_CRITERIA, vm from .blocks import Block, Header, Log, Receipt, encode_receipt @@ -319,6 +320,8 @@ def validate_header(chain: BlockChain, header: Header) -> None: if header.gas_used > header.gas_limit: raise InvalidBlock + assert isinstance(FORK_CRITERIA, ByBlockNumber) + expected_base_fee_per_gas = INITIAL_BASE_FEE if header.number != FORK_CRITERIA.block_number: # For every block except the first, calculate the base fee per gas diff --git a/src/ethereum/forks/muir_glacier/__init__.py b/src/ethereum/forks/muir_glacier/__init__.py index a9ee0553f9..a722576f95 100644 --- a/src/ethereum/forks/muir_glacier/__init__.py +++ b/src/ethereum/forks/muir_glacier/__init__.py @@ -33,6 +33,6 @@ [t]: https://github.com/ethereum/trinity/releases/tag/v0.1.0-alpha.34 """ -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(9200000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(9200000) diff --git a/src/ethereum/forks/osaka/__init__.py b/src/ethereum/forks/osaka/__init__.py index cdd21d54b2..c3978b993f 100644 --- a/src/ethereum/forks/osaka/__init__.py +++ b/src/ethereum/forks/osaka/__init__.py @@ -50,6 +50,6 @@ [EIP-7910]: https://eips.ethereum.org/EIPS/eip-7910 """ # noqa: E501 -from ethereum.fork_criteria import ByTimestamp +from ethereum.fork_criteria import ByTimestamp, ForkCriteria -FORK_CRITERIA = ByTimestamp(1764798551) +FORK_CRITERIA: ForkCriteria = ByTimestamp(1764798551) diff --git a/src/ethereum/forks/paris/__init__.py b/src/ethereum/forks/paris/__init__.py index 89642fd88b..9e1f07470d 100644 --- a/src/ethereum/forks/paris/__init__.py +++ b/src/ethereum/forks/paris/__init__.py @@ -34,10 +34,10 @@ [nm]: https://github.com/NethermindEth/nethermind/releases/tag/1.14.1 """ # noqa: E501 -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria # The actual trigger for the Paris hardfork was The Merge occurring when # total difficulty (the sum of the all block difficulties) reached the # Terminal Total Difficulty value (58750000000000000000000 on Mainnet). The # Merge is now a historical event. -FORK_CRITERIA = ByBlockNumber(15537394) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(15537394) diff --git a/src/ethereum/forks/prague/__init__.py b/src/ethereum/forks/prague/__init__.py index 16cdf6a019..9a1202050f 100644 --- a/src/ethereum/forks/prague/__init__.py +++ b/src/ethereum/forks/prague/__init__.py @@ -49,6 +49,6 @@ [EIP-7549]: https://eips.ethereum.org/EIPS/eip-7549 """ # noqa: E501 -from ethereum.fork_criteria import ByTimestamp +from ethereum.fork_criteria import ByTimestamp, ForkCriteria -FORK_CRITERIA = ByTimestamp(1746612311) +FORK_CRITERIA: ForkCriteria = ByTimestamp(1746612311) diff --git a/src/ethereum/forks/shanghai/__init__.py b/src/ethereum/forks/shanghai/__init__.py index 34ce1fe57e..d231ca9648 100644 --- a/src/ethereum/forks/shanghai/__init__.py +++ b/src/ethereum/forks/shanghai/__init__.py @@ -42,6 +42,6 @@ [js]: https://github.com/ethereumjs/ethereumjs-monorepo/releases/tag/%40ethereumjs%2Fvm%406.4.0 """ # noqa: E501 -from ethereum.fork_criteria import ByTimestamp +from ethereum.fork_criteria import ByTimestamp, ForkCriteria -FORK_CRITERIA = ByTimestamp(1681338455) +FORK_CRITERIA: ForkCriteria = ByTimestamp(1681338455) diff --git a/src/ethereum/forks/spurious_dragon/__init__.py b/src/ethereum/forks/spurious_dragon/__init__.py index ae19211a60..da34eee288 100644 --- a/src/ethereum/forks/spurious_dragon/__init__.py +++ b/src/ethereum/forks/spurious_dragon/__init__.py @@ -33,6 +33,6 @@ [rb]: https://github.com/cryptape/ruby-ethereum/releases/tag/v0.11.0 """ -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(2675000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(2675000) diff --git a/src/ethereum/forks/tangerine_whistle/__init__.py b/src/ethereum/forks/tangerine_whistle/__init__.py index f8d67bd3ee..3b3ff486ff 100644 --- a/src/ethereum/forks/tangerine_whistle/__init__.py +++ b/src/ethereum/forks/tangerine_whistle/__init__.py @@ -27,6 +27,6 @@ [p]: https://github.com/openethereum/parity-ethereum/releases/tag/v1.3.8 """ -from ethereum.fork_criteria import ByBlockNumber +from ethereum.fork_criteria import ByBlockNumber, ForkCriteria -FORK_CRITERIA = ByBlockNumber(2463000) +FORK_CRITERIA: ForkCriteria = ByBlockNumber(2463000)