From 3273425850c523f627af7e7293f4aa3dd6ebb831 Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 22:56:07 +0530 Subject: [PATCH 01/19] Refactor FORK_CRITERIA type annotation --- src/ethereum/forks/frontier/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From d25bc4b022b82cca1e9ab9335bec344d8b69794c Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 22:59:43 +0530 Subject: [PATCH 02/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/tangerine_whistle/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 15bbacaa350df7b964966513844ee5e08ba70c8b Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:01:27 +0530 Subject: [PATCH 03/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/spurious_dragon/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 4b29fad3d0ffdcfec1b0418bf65b6d4fcea6c541 Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:02:53 +0530 Subject: [PATCH 04/19] Import ForkCriteria and update FORK_CRITERIA type --- src/ethereum/forks/shanghai/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 8923db60ca0b7e606de95747af033a0def5ecc9f Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:04:33 +0530 Subject: [PATCH 05/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/prague/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 7301684ab7ea65e206b0071c0c1bf986c5f8bb57 Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:06:14 +0530 Subject: [PATCH 06/19] Update __init__.py --- src/ethereum/forks/paris/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 6e8f87159f3caa20e02a016922970510634fad67 Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:07:51 +0530 Subject: [PATCH 07/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/osaka/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 230d3d305dce79d097e107c89c9fc437cd88c968 Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:09:41 +0530 Subject: [PATCH 08/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/muir_glacier/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 2bfb9c1d0978992d47e2ca91b4019c69fc0ed620 Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:11:15 +0530 Subject: [PATCH 09/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/london/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 7fe2b6b4c31af5279d9edec88374bc31e1804e5e Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:13:22 +0530 Subject: [PATCH 10/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/istanbul/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 49df2b3f55e8bbc0f6a1f3b22f6a013550bafd14 Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:17:27 +0530 Subject: [PATCH 11/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/homestead/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From d769fdc236c897ed6fbc0a43fbbfdd0d00d998fe Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:18:56 +0530 Subject: [PATCH 12/19] Update __init__.py --- src/ethereum/forks/gray_glacier/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From da64846aa3f6f5ef7d42947a55999ca6c6594774 Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:20:32 +0530 Subject: [PATCH 13/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/dao_fork/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From e3e0ec21c6fae3dea5331d309dd99f2796f2f0dd Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:22:34 +0530 Subject: [PATCH 14/19] Update __init__.py --- src/ethereum/forks/constantinople/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From aaca88ed68641859344aeb20fad3a92075f11306 Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:24:16 +0530 Subject: [PATCH 15/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/cancun/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From d305b684d2e711657492da584efac5e1b95c5d6c Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:25:59 +0530 Subject: [PATCH 16/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/byzantium/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 766f15427351d4d1e32a063535d92c5d16cb23f0 Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:27:44 +0530 Subject: [PATCH 17/19] Refactor FORK_CRITERIA to use ForkCriteria type --- src/ethereum/forks/berlin/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 2bd33ddc55bbde3e8a932bb57a70936d183da76f Mon Sep 17 00:00:00 2001 From: Praniti Kubal <140830559+Praniti1594@users.noreply.github.com> Date: Wed, 5 Nov 2025 23:29:20 +0530 Subject: [PATCH 18/19] Add ForkCriteria type annotation to FORK_CRITERIA --- src/ethereum/forks/arrow_glacier/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 3be09ef4993f6f805b080f68b6f31fb6351683f4 Mon Sep 17 00:00:00 2001 From: Praniti1594 Date: Sat, 15 Nov 2025 12:27:56 +0000 Subject: [PATCH 19/19] fix(type): Mypy and style corrections for FORK_CRITERIA annotation (fixes #1753) --- src/ethereum/forks/dao_fork/fork.py | 3 +++ src/ethereum/forks/london/fork.py | 3 +++ 2 files changed, 6 insertions(+) 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/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