Skip to content

Ethereum Test Forks package

Ethereum test fork definitions.

BPO1

Bases: Osaka

Mainnet BPO1 fork - Blob Parameter Only fork 1.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
class BPO1(
    Osaka,
    bpo_fork=True,
    update_blob_constants={
        "BLOB_BASE_FEE_UPDATE_FRACTION": 8346193,
        "TARGET_BLOBS_PER_BLOCK": 10,
        "MAX_BLOBS_PER_BLOCK": 15,
    },
):
    """Mainnet BPO1 fork - Blob Parameter Only fork 1."""

    pass

BPO2

Bases: BPO1

Mainnet BPO2 fork - Blob Parameter Only fork 2.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
class BPO2(
    BPO1,
    bpo_fork=True,
    update_blob_constants={
        "BLOB_BASE_FEE_UPDATE_FRACTION": 11684671,
        "TARGET_BLOBS_PER_BLOCK": 14,
        "MAX_BLOBS_PER_BLOCK": 21,
    },
):
    """Mainnet BPO2 fork - Blob Parameter Only fork 2."""

    pass

BPO3

Bases: BPO2

Pseudo BPO3 fork - Blob Parameter Only fork 3. For testing purposes only.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
class BPO3(
    BPO2,
    bpo_fork=True,
    deployed=False,
    update_blob_constants={
        "BLOB_BASE_FEE_UPDATE_FRACTION": 20609697,
        "TARGET_BLOBS_PER_BLOCK": 21,
        "MAX_BLOBS_PER_BLOCK": 32,
    },
):
    """
    Pseudo BPO3 fork - Blob Parameter Only fork 3.
    For testing purposes only.
    """

    pass

BPO4

Bases: BPO3

Pseudo BPO4 fork - Blob Parameter Only fork 4. For testing purposes only. Testing a decrease in values from BPO3.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
class BPO4(
    BPO3,
    bpo_fork=True,
    update_blob_constants={
        "BLOB_BASE_FEE_UPDATE_FRACTION": 13739630,
        "TARGET_BLOBS_PER_BLOCK": 14,
        "MAX_BLOBS_PER_BLOCK": 21,
    },
):
    """
    Pseudo BPO4 fork - Blob Parameter Only fork 4.
    For testing purposes only. Testing a decrease in values from BPO3.
    """

    pass

BPO5

Bases: BPO4

Pseudo BPO5 fork - Blob Parameter Only fork 5. For testing purposes only. Required to parse Fusaka devnet genesis files.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
class BPO5(
    BPO4,
    bpo_fork=True,
):
    """
    Pseudo BPO5 fork - Blob Parameter Only fork 5.
    For testing purposes only. Required to parse Fusaka devnet genesis files.
    """

    pass

Amsterdam

Bases: AmsterdamEIPs, BPO2

Amsterdam fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
class Amsterdam(
    AmsterdamEIPs,
    BPO2,
    deployed=False,
):
    """Amsterdam fork."""

    # TODO: We may need to adjust which BPO Amsterdam inherits from as the
    #  related Amsterdam specs change over time, and before Amsterdam is
    #  live on mainnet.

    pass

ArrowGlacier

Bases: London

Arrow Glacier fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1394
1395
1396
1397
1398
1399
1400
1401
class ArrowGlacier(
    London,
    solc_name="london",
    ignore=True,
):
    """Arrow Glacier fork."""

    pass

Berlin

Bases: EIP2930, Istanbul

Berlin fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1373
1374
1375
1376
1377
1378
1379
class Berlin(
    eips.EIP2930,
    Istanbul,
):
    """Berlin fork."""

    pass

Byzantium

Bases: EIP649, EIP214, EIP211, EIP140, EIP198, EIP196, EIP197, SpuriousDragon

Byzantium fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
class Byzantium(
    eips.EIP649,
    eips.EIP214,
    eips.EIP211,
    eips.EIP140,
    eips.EIP198,
    eips.EIP196,
    eips.EIP197,
    SpuriousDragon,
):
    """Byzantium fork."""

    pass

Cancun

Bases: EIP5656, EIP1153, EIP4788, EIP4844, EIP7516, EIP6780, Shanghai

Cancun fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
class Cancun(
    eips.EIP5656,
    eips.EIP1153,
    eips.EIP4788,
    eips.EIP4844,
    eips.EIP7516,
    eips.EIP6780,
    Shanghai,
):
    """Cancun fork."""

    pass

Constantinople

Bases: EIP1234, EIP1052, EIP1014, EIP145, Byzantium

Constantinople fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
class Constantinople(
    eips.EIP1234,
    eips.EIP1052,
    eips.EIP1014,
    eips.EIP145,
    Byzantium,
):
    """Constantinople fork."""

    pass

ConstantinopleFix

Bases: Constantinople

Constantinople Fix fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1339
1340
1341
1342
1343
1344
1345
1346
class ConstantinopleFix(
    Constantinople,
    solc_name="constantinople",
    ruleset_name="PETERSBURG",
):
    """Constantinople Fix fork."""

    pass

Frontier

Bases: BaseFork

Frontier fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
class Frontier(
    BaseFork,
    solc_name="homestead",
):
    """Frontier fork."""

    @classmethod
    def transition_tool_name(cls) -> str:
        """
        Return fork name as it's meant to be passed to the transition tool for
        execution.
        """
        if cls._transition_tool_name is not None:
            return cls._transition_tool_name
        return cls.name()

    @classmethod
    def solc_name(cls) -> str:
        """Return fork name as it's meant to be passed to the solc compiler."""
        if cls._solc_name is not None:
            return cls._solc_name
        return cls.name().lower()

    @classmethod
    def header_base_fee_required(cls) -> bool:
        """At genesis, header must not contain base fee."""
        return False

    @classmethod
    def header_prev_randao_required(cls) -> bool:
        """At genesis, header must not contain Prev Randao value."""
        return False

    @classmethod
    def header_zero_difficulty_required(cls) -> bool:
        """At genesis, header must not have difficulty zero."""
        return False

    @classmethod
    def header_withdrawals_required(cls) -> bool:
        """At genesis, header must not contain withdrawals."""
        return False

    @classmethod
    def header_excess_blob_gas_required(cls) -> bool:
        """At genesis, header must not contain excess blob gas."""
        return False

    @classmethod
    def header_blob_gas_used_required(cls) -> bool:
        """At genesis, header must not contain blob gas used."""
        return False

    @classmethod
    def gas_costs(cls) -> GasCosts:
        """
        Return dataclass with the defined gas costs constants for genesis.
        """
        return GasCosts(
            # Tiers
            BASE=BASE,
            VERY_LOW=VERY_LOW,
            LOW=LOW,
            MID=MID,
            HIGH=HIGH,
            # Access
            WARM_ACCESS=100,
            COLD_ACCOUNT_ACCESS=2_600,
            WARM_SLOAD=100,
            COLD_STORAGE_ACCESS=2_100,
            # Storage
            STORAGE_SET=20_000,
            COLD_STORAGE_WRITE=5_000,
            STORAGE_RESET=2_900,
            # Call
            CALL_VALUE=9_000,
            CALL_STIPEND=2_300,
            NEW_ACCOUNT=25_000,
            # Contract Creation
            CODE_DEPOSIT_PER_BYTE=200,
            CODE_INIT_PER_WORD=2,
            # Authorization
            AUTH_PER_EMPTY_ACCOUNT=0,
            # Utility
            MEMORY_PER_WORD=3,
            # Transactions
            TX_BASE=21_000,
            TX_ACCESS_LIST_ADDRESS=2_400,
            TX_ACCESS_LIST_STORAGE_KEY=1_900,
            TX_DATA_PER_ZERO=4,
            TX_DATA_PER_NON_ZERO=68,
            TX_CREATE=32_000,
            # Refunds
            REFUND_STORAGE_CLEAR=4_800,
            REFUND_AUTH_PER_EXISTING_ACCOUNT=0,
            # Precompiles
            PRECOMPILE_ECRECOVER=3_000,
            PRECOMPILE_SHA256_BASE=60,
            PRECOMPILE_SHA256_PER_WORD=12,
            PRECOMPILE_RIPEMD160_BASE=600,
            PRECOMPILE_RIPEMD160_PER_WORD=120,
            PRECOMPILE_IDENTITY_BASE=15,
            PRECOMPILE_IDENTITY_PER_WORD=3,
            # Static Opcodes
            OPCODE_ADD=VERY_LOW,
            OPCODE_SUB=VERY_LOW,
            OPCODE_MUL=LOW,
            OPCODE_DIV=LOW,
            OPCODE_SDIV=LOW,
            OPCODE_MOD=LOW,
            OPCODE_SMOD=LOW,
            OPCODE_ADDMOD=MID,
            OPCODE_MULMOD=MID,
            OPCODE_SIGNEXTEND=LOW,
            OPCODE_LT=VERY_LOW,
            OPCODE_GT=VERY_LOW,
            OPCODE_SLT=VERY_LOW,
            OPCODE_SGT=VERY_LOW,
            OPCODE_EQ=VERY_LOW,
            OPCODE_ISZERO=VERY_LOW,
            OPCODE_AND=VERY_LOW,
            OPCODE_OR=VERY_LOW,
            OPCODE_XOR=VERY_LOW,
            OPCODE_NOT=VERY_LOW,
            OPCODE_BYTE=VERY_LOW,
            OPCODE_JUMP=MID,
            OPCODE_JUMPI=HIGH,
            OPCODE_JUMPDEST=1,
            OPCODE_CALLDATALOAD=VERY_LOW,
            OPCODE_BLOCKHASH=20,
            OPCODE_COINBASE=BASE,
            OPCODE_PUSH=VERY_LOW,
            OPCODE_DUP=VERY_LOW,
            OPCODE_SWAP=VERY_LOW,
            # Dynamic Opcode Components
            OPCODE_CALLDATACOPY_BASE=VERY_LOW,
            OPCODE_CODECOPY_BASE=VERY_LOW,
            OPCODE_MLOAD_BASE=VERY_LOW,
            OPCODE_MSTORE_BASE=VERY_LOW,
            OPCODE_MSTORE8_BASE=VERY_LOW,
            OPCODE_SELFDESTRUCT_BASE=5_000,
            OPCODE_COPY_PER_WORD=3,
            OPCODE_CREATE_BASE=32_000,
            OPCODE_EXP_BASE=10,
            OPCODE_EXP_PER_BYTE=50,
            OPCODE_LOG_BASE=375,
            OPCODE_LOG_DATA_PER_BYTE=8,
            OPCODE_LOG_TOPIC=375,
            OPCODE_KECCAK256_BASE=30,
            OPCODE_KECCACK256_PER_WORD=6,
            # Zero-initialized: introduced in later forks, set via
            # replace() in the fork that activates them.
            TX_DATA_TOKEN_STANDARD=0,
            TX_DATA_TOKEN_FLOOR=0,
            PRECOMPILE_ECADD=0,
            PRECOMPILE_ECMUL=0,
            PRECOMPILE_ECPAIRING_BASE=0,
            PRECOMPILE_ECPAIRING_PER_POINT=0,
            PRECOMPILE_BLAKE2F_BASE=0,
            PRECOMPILE_BLAKE2F_PER_ROUND=0,
            PRECOMPILE_POINT_EVALUATION=0,
            PRECOMPILE_BLS_G1ADD=0,
            PRECOMPILE_BLS_G1MUL=0,
            PRECOMPILE_BLS_G1MAP=0,
            PRECOMPILE_BLS_G2ADD=0,
            PRECOMPILE_BLS_G2MUL=0,
            PRECOMPILE_BLS_G2MAP=0,
            PRECOMPILE_BLS_PAIRING_BASE=0,
            PRECOMPILE_BLS_PAIRING_PER_PAIR=0,
            PRECOMPILE_P256VERIFY=0,
            BLOCK_ACCESS_LIST_ITEM=0,
        )

    @classmethod
    def _with_memory_expansion(
        cls,
        base_gas: int | Callable[[OpcodeBase], int],
        memory_expansion_gas_calculator: MemoryExpansionGasCalculator,
    ) -> Callable[[OpcodeBase], int]:
        """
        Wrap a gas cost calculator to include memory expansion cost.

        Args:
            base_gas: Either a constant gas cost (int) or a callable that
                      calculates it
            memory_expansion_gas_calculator: Calculator for memory expansion
                                             cost

        Returns:
            A callable that calculates base_gas + memory_expansion_cost

        """

        def wrapper(opcode: OpcodeBase) -> int:
            # Calculate base gas cost
            if callable(base_gas):
                base_cost = base_gas(opcode)
            else:
                base_cost = base_gas

            # Add memory expansion cost if metadata is present
            new_memory_size = opcode.metadata["new_memory_size"]
            old_memory_size = opcode.metadata["old_memory_size"]
            expansion_cost = memory_expansion_gas_calculator(
                new_bytes=new_memory_size, previous_bytes=old_memory_size
            )

            return base_cost + expansion_cost

        return wrapper

    @classmethod
    def _with_account_access(
        cls,
        base_gas: int | Callable[[OpcodeBase], int],
        gas_costs: "GasCosts",
    ) -> Callable[[OpcodeBase], int]:
        """
        Wrap a gas cost calculator to include account access cost.

        Args:
            base_gas: Either a constant gas cost (int) or a callable that
                      calculates it
            gas_costs: The gas costs dataclass for accessing warm/cold costs

        Returns:
            A callable that calculates base_gas + account_access_cost

        """

        def wrapper(opcode: OpcodeBase) -> int:
            # Calculate base gas cost
            if callable(base_gas):
                base_cost = base_gas(opcode)
            else:
                base_cost = base_gas

            # Add account access cost based on warmth
            if opcode.metadata["address_warm"]:
                access_cost = gas_costs.WARM_ACCESS
            else:
                access_cost = gas_costs.COLD_ACCOUNT_ACCESS

            return base_cost + access_cost

        return wrapper

    @classmethod
    def _with_data_copy(
        cls,
        base_gas: int | Callable[[OpcodeBase], int],
        gas_costs: "GasCosts",
    ) -> Callable[[OpcodeBase], int]:
        """
        Wrap a gas cost calculator to include data copy cost.

        Args:
            base_gas: Either a constant gas cost (int) or a callable that
                      calculates it
            gas_costs: The gas costs dataclass for accessing
                       OPCODE_COPY_PER_WORD

        Returns:
            A callable that calculates base_gas + copy_cost

        """

        def wrapper(opcode: OpcodeBase) -> int:
            # Calculate base gas cost
            if callable(base_gas):
                base_cost = base_gas(opcode)
            else:
                base_cost = base_gas

            # Add copy cost based on data size
            data_size = opcode.metadata["data_size"]
            word_count = (data_size + 31) // 32
            copy_cost = gas_costs.OPCODE_COPY_PER_WORD * word_count

            return base_cost + copy_cost

        return wrapper

    @classmethod
    def opcode_gas_map(
        cls,
    ) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
        """
        Return a mapping of opcodes to their gas costs.

        Each entry is either:
        - Constants (int): Direct gas cost values from gas_costs()
        - Callables: Functions that take the opcode instance with metadata and
                     return gas cost
        """
        gas_costs = cls.gas_costs()
        memory_expansion_calculator = cls.memory_expansion_gas_calculator()

        # Define the opcode gas cost mapping
        # Each entry is either:
        # - an int (constant cost)
        # - a callable(opcode) -> int
        return {
            # Stop and arithmetic operations
            Opcodes.STOP: 0,
            Opcodes.ADD: gas_costs.OPCODE_ADD,
            Opcodes.MUL: gas_costs.OPCODE_MUL,
            Opcodes.SUB: gas_costs.OPCODE_SUB,
            Opcodes.DIV: gas_costs.OPCODE_DIV,
            Opcodes.SDIV: gas_costs.OPCODE_SDIV,
            Opcodes.MOD: gas_costs.OPCODE_MOD,
            Opcodes.SMOD: gas_costs.OPCODE_SMOD,
            Opcodes.ADDMOD: gas_costs.OPCODE_ADDMOD,
            Opcodes.MULMOD: gas_costs.OPCODE_MULMOD,
            Opcodes.EXP: lambda op: (
                gas_costs.OPCODE_EXP_BASE
                + gas_costs.OPCODE_EXP_PER_BYTE
                * ((op.metadata["exponent"].bit_length() + 7) // 8)
            ),
            Opcodes.SIGNEXTEND: gas_costs.OPCODE_SIGNEXTEND,
            # Comparison & bitwise logic operations
            Opcodes.LT: gas_costs.OPCODE_LT,
            Opcodes.GT: gas_costs.OPCODE_GT,
            Opcodes.SLT: gas_costs.OPCODE_SLT,
            Opcodes.SGT: gas_costs.OPCODE_SGT,
            Opcodes.EQ: gas_costs.OPCODE_EQ,
            Opcodes.ISZERO: gas_costs.OPCODE_ISZERO,
            Opcodes.AND: gas_costs.OPCODE_AND,
            Opcodes.OR: gas_costs.OPCODE_OR,
            Opcodes.XOR: gas_costs.OPCODE_XOR,
            Opcodes.NOT: gas_costs.OPCODE_NOT,
            Opcodes.BYTE: gas_costs.OPCODE_BYTE,
            # SHA3
            Opcodes.SHA3: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_KECCAK256_BASE
                    + gas_costs.OPCODE_KECCACK256_PER_WORD
                    * ((op.metadata["data_size"] + 31) // 32)
                ),
                memory_expansion_calculator,
            ),
            # Environmental information
            Opcodes.ADDRESS: gas_costs.BASE,
            Opcodes.BALANCE: cls._with_account_access(0, gas_costs),
            Opcodes.ORIGIN: gas_costs.BASE,
            Opcodes.CALLER: gas_costs.BASE,
            Opcodes.CALLVALUE: gas_costs.BASE,
            Opcodes.CALLDATALOAD: gas_costs.OPCODE_CALLDATALOAD,
            Opcodes.CALLDATASIZE: gas_costs.BASE,
            Opcodes.CALLDATACOPY: cls._with_memory_expansion(
                cls._with_data_copy(
                    gas_costs.OPCODE_CALLDATACOPY_BASE, gas_costs
                ),
                memory_expansion_calculator,
            ),
            Opcodes.CODESIZE: gas_costs.BASE,
            Opcodes.CODECOPY: cls._with_memory_expansion(
                cls._with_data_copy(gas_costs.OPCODE_CODECOPY_BASE, gas_costs),
                memory_expansion_calculator,
            ),
            Opcodes.GASPRICE: gas_costs.BASE,
            Opcodes.EXTCODESIZE: cls._with_account_access(0, gas_costs),
            Opcodes.EXTCODECOPY: cls._with_memory_expansion(
                cls._with_data_copy(
                    cls._with_account_access(0, gas_costs),
                    gas_costs,
                ),
                memory_expansion_calculator,
            ),
            # Block information
            Opcodes.BLOCKHASH: gas_costs.OPCODE_BLOCKHASH,
            Opcodes.COINBASE: gas_costs.OPCODE_COINBASE,
            Opcodes.TIMESTAMP: gas_costs.BASE,
            Opcodes.NUMBER: gas_costs.BASE,
            Opcodes.PREVRANDAO: gas_costs.BASE,
            Opcodes.GASLIMIT: gas_costs.BASE,
            # Stack, memory, storage and flow operations
            Opcodes.POP: gas_costs.BASE,
            Opcodes.MLOAD: cls._with_memory_expansion(
                gas_costs.OPCODE_MLOAD_BASE,
                memory_expansion_calculator,
            ),
            Opcodes.MSTORE: cls._with_memory_expansion(
                gas_costs.OPCODE_MSTORE_BASE,
                memory_expansion_calculator,
            ),
            Opcodes.MSTORE8: cls._with_memory_expansion(
                gas_costs.OPCODE_MSTORE8_BASE,
                memory_expansion_calculator,
            ),
            Opcodes.SLOAD: lambda op: (
                gas_costs.WARM_SLOAD
                if op.metadata["key_warm"]
                else gas_costs.COLD_STORAGE_ACCESS
            ),
            Opcodes.SSTORE: lambda op: cls._calculate_sstore_gas(
                op, gas_costs
            ),
            Opcodes.JUMP: gas_costs.OPCODE_JUMP,
            Opcodes.JUMPI: gas_costs.OPCODE_JUMPI,
            Opcodes.PC: gas_costs.BASE,
            Opcodes.MSIZE: gas_costs.BASE,
            Opcodes.GAS: gas_costs.BASE,
            Opcodes.JUMPDEST: gas_costs.OPCODE_JUMPDEST,
            # Push operations (PUSH1 through PUSH32)
            **{
                getattr(Opcodes, f"PUSH{i}"): gas_costs.OPCODE_PUSH
                for i in range(1, 33)
            },
            # Dup operations (DUP1 through DUP16)
            **{
                getattr(Opcodes, f"DUP{i}"): gas_costs.OPCODE_DUP
                for i in range(1, 17)
            },
            # Swap operations (SWAP1 through SWAP16)
            **{
                getattr(Opcodes, f"SWAP{i}"): gas_costs.OPCODE_SWAP
                for i in range(1, 17)
            },
            # Logging operations
            Opcodes.LOG0: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_LOG_BASE
                    + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                    * op.metadata["data_size"]
                ),
                memory_expansion_calculator,
            ),
            Opcodes.LOG1: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_LOG_BASE
                    + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                    * op.metadata["data_size"]
                    + gas_costs.OPCODE_LOG_TOPIC
                ),
                memory_expansion_calculator,
            ),
            Opcodes.LOG2: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_LOG_BASE
                    + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                    * op.metadata["data_size"]
                    + gas_costs.OPCODE_LOG_TOPIC * 2
                ),
                memory_expansion_calculator,
            ),
            Opcodes.LOG3: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_LOG_BASE
                    + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                    * op.metadata["data_size"]
                    + gas_costs.OPCODE_LOG_TOPIC * 3
                ),
                memory_expansion_calculator,
            ),
            Opcodes.LOG4: cls._with_memory_expansion(
                lambda op: (
                    gas_costs.OPCODE_LOG_BASE
                    + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                    * op.metadata["data_size"]
                    + gas_costs.OPCODE_LOG_TOPIC * 4
                ),
                memory_expansion_calculator,
            ),
            # System operations
            Opcodes.CREATE: cls._with_memory_expansion(
                lambda op: cls._calculate_create_gas(op, gas_costs),
                memory_expansion_calculator,
            ),
            Opcodes.CALL: cls._with_memory_expansion(
                lambda op: cls._calculate_call_gas(op, gas_costs),
                memory_expansion_calculator,
            ),
            Opcodes.CALLCODE: cls._with_memory_expansion(
                lambda op: cls._calculate_call_gas(op, gas_costs),
                memory_expansion_calculator,
            ),
            Opcodes.RETURN: cls._with_memory_expansion(
                lambda op: cls._calculate_return_gas(op, gas_costs),
                memory_expansion_calculator,
            ),
            Opcodes.INVALID: 0,
            Opcodes.SELFDESTRUCT: lambda op: cls._calculate_selfdestruct_gas(
                op, gas_costs
            ),
        }

    @classmethod
    def opcode_gas_calculator(cls) -> OpcodeGasCalculator:
        """
        Return callable that calculates the gas cost of a single opcode.
        """
        opcode_gas_map = cls.opcode_gas_map()

        def fn(opcode: OpcodeBase) -> int:
            # Get the gas cost or calculator
            if opcode not in opcode_gas_map:
                raise ValueError(
                    f"No gas cost defined for opcode: {opcode._name_}"
                )
            gas_cost_or_calculator = opcode_gas_map[opcode]

            # If it's a callable, call it with the opcode
            if callable(gas_cost_or_calculator):
                return gas_cost_or_calculator(opcode)

            # Otherwise it's a constant
            return gas_cost_or_calculator

        return fn

    @classmethod
    def opcode_refund_map(
        cls,
    ) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
        """
        Return a mapping of opcodes to their gas refunds.

        Each entry is either:
        - Constants (int): Direct gas refund values
        - Callables: Functions that take the opcode instance with metadata and
                     return gas refund
        """
        gas_costs = cls.gas_costs()

        # Only SSTORE provides refunds
        return {
            Opcodes.SSTORE: lambda op: cls._calculate_sstore_refund(
                op, gas_costs
            ),
        }

    @classmethod
    def opcode_refund_calculator(cls) -> OpcodeGasCalculator:
        """
        Return callable that calculates the gas refund of a single opcode.
        """
        opcode_refund_map = cls.opcode_refund_map()

        def fn(opcode: OpcodeBase) -> int:
            # Get the gas refund or calculator
            if opcode not in opcode_refund_map:
                # Most opcodes don't provide refunds
                return 0
            refund_or_calculator = opcode_refund_map[opcode]

            # If it's a callable, call it with the opcode
            if callable(refund_or_calculator):
                return refund_or_calculator(opcode)

            # Otherwise it's a constant
            return refund_or_calculator

        return fn

    @classmethod
    def _calculate_sstore_refund(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """Calculate SSTORE gas refund based on metadata."""
        metadata = opcode.metadata

        original_value = metadata["original_value"]
        current_value = metadata["current_value"]
        if current_value is None:
            current_value = original_value
        new_value = metadata["new_value"]

        # Refund is provided when setting from non-zero to zero
        refund = 0
        if current_value != new_value:
            if original_value != 0 and current_value != 0 and new_value == 0:
                # Storage is cleared for the first time in the transaction
                refund += gas_costs.REFUND_STORAGE_CLEAR

            if original_value != 0 and current_value == 0:
                # Gas refund issued earlier to be reversed
                refund -= gas_costs.REFUND_STORAGE_CLEAR

            if original_value == new_value:
                # Storage slot being restored to its original value
                if original_value == 0:
                    # Slot was originally empty and was SET earlier
                    refund += gas_costs.STORAGE_SET - gas_costs.WARM_SLOAD
                else:
                    # Slot was originally non-empty and was UPDATED earlier
                    refund += (
                        gas_costs.COLD_STORAGE_WRITE
                        - gas_costs.COLD_STORAGE_ACCESS
                        - gas_costs.WARM_SLOAD
                    )

        return refund

    @classmethod
    def _calculate_sstore_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """Calculate SSTORE gas cost based on metadata."""
        metadata = opcode.metadata

        original_value = metadata["original_value"]
        current_value = metadata["current_value"]
        if current_value is None:
            current_value = original_value
        new_value = metadata["new_value"]

        gas_cost = 0 if metadata["key_warm"] else gas_costs.COLD_STORAGE_ACCESS

        if original_value == current_value and current_value != new_value:
            if original_value == 0:
                gas_cost += gas_costs.STORAGE_SET
            else:
                gas_cost += (
                    gas_costs.COLD_STORAGE_WRITE
                    - gas_costs.COLD_STORAGE_ACCESS
                )
        else:
            gas_cost += gas_costs.WARM_SLOAD

        return gas_cost

    @classmethod
    def _calculate_call_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """
        Calculate CALL/DELEGATECALL/STATICCALL gas cost based on metadata.
        """
        metadata = opcode.metadata

        # Base cost depends on address warmth
        if metadata["address_warm"]:
            base_cost = gas_costs.WARM_ACCESS
        else:
            base_cost = gas_costs.COLD_ACCOUNT_ACCESS

        if metadata["inner_call_cost"]:
            return base_cost + metadata["inner_call_cost"]

        return base_cost

    @classmethod
    def _calculate_create_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """CREATE gas is constant at Frontier."""
        del opcode
        return gas_costs.OPCODE_CREATE_BASE

    @classmethod
    def _calculate_create2_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """
        Calculate CREATE2 gas cost including initcode cost.
        """
        raise NotImplementedError(
            f"CREATE2 opcode is not supported in {cls.name()}"
        )

    @classmethod
    def _calculate_return_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """Calculate RETURN gas cost based on metadata."""
        metadata = opcode.metadata

        # Code deposit cost when returning from initcode
        code_deposit_size = metadata["code_deposit_size"]
        return gas_costs.CODE_DEPOSIT_PER_BYTE * code_deposit_size

    @classmethod
    def _calculate_selfdestruct_gas(
        cls, opcode: OpcodeBase, gas_costs: GasCosts
    ) -> int:
        """Calculate SELFDESTRUCT gas cost based on metadata."""
        metadata = opcode.metadata

        base_cost = gas_costs.OPCODE_SELFDESTRUCT_BASE

        # Check if the beneficiary is cold
        if not metadata["address_warm"]:
            base_cost += gas_costs.COLD_ACCOUNT_ACCESS

        # Check if creating a new account
        if metadata["account_new"]:
            base_cost += gas_costs.NEW_ACCOUNT

        return base_cost

    @classmethod
    def memory_expansion_gas_calculator(cls) -> MemoryExpansionGasCalculator:
        """
        Return callable that calculates the gas cost of memory expansion for
        the fork.
        """
        gas_costs = cls.gas_costs()

        def fn(*, new_bytes: int, previous_bytes: int = 0) -> int:
            if new_bytes <= previous_bytes:
                return 0
            new_words = ceiling_division(new_bytes, 32)
            previous_words = ceiling_division(previous_bytes, 32)

            def c(w: int) -> int:
                return (gas_costs.MEMORY_PER_WORD * w) + ((w * w) // 512)

            return c(new_words) - c(previous_words)

        return fn

    @classmethod
    def calldata_gas_calculator(cls) -> CalldataGasCalculator:
        """
        Return callable that calculates the transaction gas cost for its
        calldata depending on its contents.
        """
        gas_costs = cls.gas_costs()

        def fn(*, data: BytesConvertible, floor: bool = False) -> int:
            del floor

            raw = Bytes(data)
            num_zeros = raw.count(0)
            num_non_zeros = len(raw) - num_zeros
            return (
                num_zeros * gas_costs.TX_DATA_PER_ZERO
                + num_non_zeros * gas_costs.TX_DATA_PER_NON_ZERO
            )

        return fn

    @classmethod
    def base_fee_per_gas_calculator(cls) -> BaseFeePerGasCalculator:
        """
        Return a callable that calculates the base fee per gas at a given fork.
        """
        raise NotImplementedError(
            f"Base fee per gas calculator is not supported in {cls.name()}"
        )

    @classmethod
    def base_fee_change_calculator(cls) -> BaseFeeChangeCalculator:
        """
        Return a callable that calculates the gas that needs to be used to
        change the base fee.
        """
        raise NotImplementedError(
            f"Base fee change calculator is not supported in {cls.name()}"
        )

    @classmethod
    def base_fee_max_change_denominator(cls) -> int:
        """Return the base fee max change denominator at a given fork."""
        raise NotImplementedError(
            f"Base fee max change denominator is not supported in {cls.name()}"
        )

    @classmethod
    def base_fee_elasticity_multiplier(cls) -> int:
        """Return the base fee elasticity multiplier at a given fork."""
        raise NotImplementedError(
            f"Base fee elasticity multiplier is not supported in {cls.name()}"
        )

    @classmethod
    def transaction_data_floor_cost_calculator(
        cls,
    ) -> TransactionDataFloorCostCalculator:
        """At frontier, the transaction data floor cost is a constant zero."""

        def fn(*, data: BytesConvertible) -> int:
            del data
            return 0

        return fn

    @classmethod
    def transaction_intrinsic_cost_calculator(
        cls,
    ) -> TransactionIntrinsicCostCalculator:
        """
        Return callable that calculates the intrinsic gas cost of a transaction
        for the fork.
        """
        gas_costs = cls.gas_costs()
        calldata_gas_calculator = cls.calldata_gas_calculator()

        def fn(
            *,
            calldata: BytesConvertible = b"",
            contract_creation: bool = False,
            access_list: List[AccessList] | None = None,
            authorization_list_or_count: Sized | int | None = None,
            return_cost_deducted_prior_execution: bool = False,
        ) -> int:
            del return_cost_deducted_prior_execution

            assert access_list is None, (
                f"Access list is not supported in {cls.name()}"
            )
            assert authorization_list_or_count is None, (
                f"Authorizations are not supported in {cls.name()}"
            )

            intrinsic_cost: int = gas_costs.TX_BASE

            if contract_creation:
                intrinsic_cost += (
                    gas_costs.CODE_INIT_PER_WORD
                    * ceiling_division(len(Bytes(calldata)), 32)
                )

            return intrinsic_cost + calldata_gas_calculator(data=calldata)

        return fn

    @classmethod
    def blob_gas_price_calculator(cls) -> BlobGasPriceCalculator:
        """
        Return a callable that calculates the blob gas price at a given fork.
        """
        raise NotImplementedError(
            f"Blob gas price calculator is not supported in {cls.name()}"
        )

    @classmethod
    def excess_blob_gas_calculator(cls) -> ExcessBlobGasCalculator:
        """
        Return a callable that calculates the excess blob gas for a block at a
        given fork.
        """
        raise NotImplementedError(
            f"Excess blob gas calculator is not supported in {cls.name()}"
        )

    @classmethod
    def supports_blobs(cls) -> bool:
        """Blobs are not supported at Frontier."""
        return False

    @classmethod
    def blob_reserve_price_active(cls) -> bool:
        """
        Return whether the fork uses a reserve price mechanism for blobs or
        not.
        """
        raise NotImplementedError(
            f"Blob reserve price is not supported in {cls.name()}"
        )

    @classmethod
    def full_blob_tx_wrapper_version(cls) -> int | None:
        """Return the version of the full blob transaction wrapper."""
        raise NotImplementedError(
            "Full blob transaction wrapper version is not supported in "
            f"{cls.name()}"
        )

    @classmethod
    def blob_schedule(cls) -> BlobSchedule | None:
        """At genesis, no blob schedule is used."""
        return None

    @classmethod
    def header_requests_required(cls) -> bool:
        """At genesis, header must not contain beacon chain requests."""
        return False

    @classmethod
    def header_bal_hash_required(cls) -> bool:
        """At genesis, header must not contain block access list hash."""
        return False

    @classmethod
    def empty_block_bal_item_count(cls) -> int:
        """Pre-Amsterdam forks have no block access list."""
        return 0

    @classmethod
    def header_beacon_root_required(cls) -> bool:
        """At genesis, header must not contain parent beacon block root."""
        return False

    @classmethod
    def engine_new_payload_blob_hashes(cls) -> bool:
        """At genesis, payloads do not have blob hashes."""
        return False

    @classmethod
    def engine_new_payload_beacon_root(cls) -> bool:
        """At genesis, payloads do not have a parent beacon block root."""
        return False

    @classmethod
    def engine_new_payload_requests(cls) -> bool:
        """At genesis, payloads do not have requests."""
        return False

    @classmethod
    def engine_execution_payload_block_access_list(cls) -> bool:
        """At genesis, payloads do not have block access list."""
        return False

    @classmethod
    def engine_new_payload_target_blobs_per_block(cls) -> bool:
        """At genesis, payloads do not have target blobs per block."""
        return False

    @classmethod
    def engine_payload_attribute_target_blobs_per_block(cls) -> bool:
        """
        At genesis, payload attributes do not include the target blobs per
        block.
        """
        return False

    @classmethod
    def engine_payload_attribute_max_blobs_per_block(cls) -> bool:
        """
        At genesis, payload attributes do not include the max blobs per block.
        """
        return False

    @classmethod
    def get_reward(cls) -> int:
        """
        At Genesis the expected reward amount in wei is
        5_000_000_000_000_000_000.
        """
        return 5_000_000_000_000_000_000

    @classmethod
    def supports_protected_txs(cls) -> bool:
        """At Genesis, fork has no support for EIP-155 protected txs."""
        return False

    @classmethod
    def tx_types(cls) -> List[int]:
        """At Genesis, only legacy transactions are allowed."""
        return [0]

    @classmethod
    def contract_creating_tx_types(cls) -> List[int]:
        """At Genesis, only legacy transactions are allowed."""
        return [0]

    @classmethod
    def transaction_gas_limit_cap(cls) -> int | None:
        """At Genesis, no transaction gas limit cap is imposed."""
        return None

    @classmethod
    def block_rlp_size_limit(cls) -> int | None:
        """At Genesis, no RLP block size limit is imposed."""
        return None

    @classmethod
    def precompiles(cls) -> List[Address]:
        """
        At Genesis, EC-recover, SHA256, RIPEMD160, and Identity precompiles
        are introduced.
        """
        return [
            Address(1, label="ECREC"),
            Address(2, label="SHA256"),
            Address(3, label="RIPEMD160"),
            Address(4, label="ID"),
        ]

    @classmethod
    def system_contracts(cls) -> List[Address]:
        """At Genesis, no system contracts are present."""
        return []

    @classmethod
    def deterministic_factory_predeploy_address(cls) -> Address | None:
        """At Genesis, no deterministic factory predeploy is present."""
        return None

    @classmethod
    def max_code_size(cls) -> int:
        """
        At genesis, there is no upper bound for code size (bounded by block gas
        limit).

        However, the default is set to the limit of EIP-170 (Spurious Dragon)
        """
        return 0x6000

    @classmethod
    def max_stack_height(cls) -> int:
        """At genesis, the maximum stack height is 1024."""
        return 1024

    @classmethod
    def max_initcode_size(cls) -> int:
        """
        At genesis, there is no upper bound for initcode size.

        However, the default is set to the limit of EIP-3860 (Shanghai).
        """
        return 0xC000

    @classmethod
    def call_opcodes(cls) -> List[Opcodes]:
        """Return list of call opcodes supported by the fork."""
        return [Opcodes.CALL, Opcodes.CALLCODE]

    @classmethod
    def valid_opcodes(cls) -> List[Opcodes]:
        """Return list of Opcodes that are valid to work on this fork."""
        return [
            Opcodes.STOP,
            Opcodes.ADD,
            Opcodes.MUL,
            Opcodes.SUB,
            Opcodes.DIV,
            Opcodes.SDIV,
            Opcodes.MOD,
            Opcodes.SMOD,
            Opcodes.ADDMOD,
            Opcodes.MULMOD,
            Opcodes.EXP,
            Opcodes.SIGNEXTEND,
            Opcodes.LT,
            Opcodes.GT,
            Opcodes.SLT,
            Opcodes.SGT,
            Opcodes.EQ,
            Opcodes.ISZERO,
            Opcodes.AND,
            Opcodes.OR,
            Opcodes.XOR,
            Opcodes.NOT,
            Opcodes.BYTE,
            Opcodes.SHA3,
            Opcodes.ADDRESS,
            Opcodes.BALANCE,
            Opcodes.ORIGIN,
            Opcodes.CALLER,
            Opcodes.CALLVALUE,
            Opcodes.CALLDATALOAD,
            Opcodes.CALLDATASIZE,
            Opcodes.CALLDATACOPY,
            Opcodes.CODESIZE,
            Opcodes.CODECOPY,
            Opcodes.GASPRICE,
            Opcodes.EXTCODESIZE,
            Opcodes.EXTCODECOPY,
            Opcodes.BLOCKHASH,
            Opcodes.COINBASE,
            Opcodes.TIMESTAMP,
            Opcodes.NUMBER,
            Opcodes.PREVRANDAO,
            Opcodes.GASLIMIT,
            Opcodes.POP,
            Opcodes.MLOAD,
            Opcodes.MSTORE,
            Opcodes.MSTORE8,
            Opcodes.SLOAD,
            Opcodes.SSTORE,
            Opcodes.PC,
            Opcodes.MSIZE,
            Opcodes.GAS,
            Opcodes.JUMP,
            Opcodes.JUMPI,
            Opcodes.JUMPDEST,
            Opcodes.PUSH1,
            Opcodes.PUSH2,
            Opcodes.PUSH3,
            Opcodes.PUSH4,
            Opcodes.PUSH5,
            Opcodes.PUSH6,
            Opcodes.PUSH7,
            Opcodes.PUSH8,
            Opcodes.PUSH9,
            Opcodes.PUSH10,
            Opcodes.PUSH11,
            Opcodes.PUSH12,
            Opcodes.PUSH13,
            Opcodes.PUSH14,
            Opcodes.PUSH15,
            Opcodes.PUSH16,
            Opcodes.PUSH17,
            Opcodes.PUSH18,
            Opcodes.PUSH19,
            Opcodes.PUSH20,
            Opcodes.PUSH21,
            Opcodes.PUSH22,
            Opcodes.PUSH23,
            Opcodes.PUSH24,
            Opcodes.PUSH25,
            Opcodes.PUSH26,
            Opcodes.PUSH27,
            Opcodes.PUSH28,
            Opcodes.PUSH29,
            Opcodes.PUSH30,
            Opcodes.PUSH31,
            Opcodes.PUSH32,
            Opcodes.DUP1,
            Opcodes.DUP2,
            Opcodes.DUP3,
            Opcodes.DUP4,
            Opcodes.DUP5,
            Opcodes.DUP6,
            Opcodes.DUP7,
            Opcodes.DUP8,
            Opcodes.DUP9,
            Opcodes.DUP10,
            Opcodes.DUP11,
            Opcodes.DUP12,
            Opcodes.DUP13,
            Opcodes.DUP14,
            Opcodes.DUP15,
            Opcodes.DUP16,
            Opcodes.SWAP1,
            Opcodes.SWAP2,
            Opcodes.SWAP3,
            Opcodes.SWAP4,
            Opcodes.SWAP5,
            Opcodes.SWAP6,
            Opcodes.SWAP7,
            Opcodes.SWAP8,
            Opcodes.SWAP9,
            Opcodes.SWAP10,
            Opcodes.SWAP11,
            Opcodes.SWAP12,
            Opcodes.SWAP13,
            Opcodes.SWAP14,
            Opcodes.SWAP15,
            Opcodes.SWAP16,
            Opcodes.LOG0,
            Opcodes.LOG1,
            Opcodes.LOG2,
            Opcodes.LOG3,
            Opcodes.LOG4,
            Opcodes.CREATE,
            Opcodes.CALL,
            Opcodes.CALLCODE,
            Opcodes.RETURN,
            Opcodes.SELFDESTRUCT,
        ]

    @classmethod
    def create_opcodes(cls) -> List[Opcodes]:
        """At Genesis, only `CREATE` opcode is supported."""
        return [Opcodes.CREATE]

    @classmethod
    def max_refund_quotient(cls) -> int:
        """Return the max refund quotient at Genesis."""
        return 2

    @classmethod
    def max_request_type(cls) -> int:
        """At genesis, no request type is supported, signaled by -1."""
        return -1

    @classmethod
    def pre_allocation(cls) -> Mapping:
        """
        Return whether the fork expects pre-allocation of accounts.

        Frontier does not require pre-allocated accounts
        """
        return {}

    @classmethod
    def pre_allocation_blockchain(cls) -> Mapping:
        """
        Return whether the fork expects pre-allocation of accounts.

        Frontier does not require pre-allocated accounts
        """
        return {}

    @classmethod
    def build_default_block_header(
        cls, *, block_number: int = 0, timestamp: int = 0
    ) -> FixtureHeader:
        """
        Build a default block header for this fork with the given attributes.

        This method automatically detects which header fields are required by
        the fork and assigns appropriate default values. It introspects the
        FixtureHeader model to find fields with HeaderForkRequirement
        annotations and automatically includes them if the fork requires them.

        Args:
            block_number: The block number
            timestamp: The block timestamp

        Returns:
            FixtureHeader instance with default values applied based on fork
            requirements.

        Raises:
            TypeError: If the overrides don't have the correct type.

        """
        from execution_testing.fixtures.blockchain import FixtureHeader

        defaults = {
            "number": ZeroPaddedHexNumber(block_number),
            "timestamp": ZeroPaddedHexNumber(timestamp),
            "fork": cls,
        }

        # Iterate through FixtureHeader fields to populate defaults
        for field_name, field_info in FixtureHeader.model_fields.items():
            if field_name in defaults:
                continue

            # Get default value, checking fork requirements and model defaults
            default_value = FixtureHeader.get_default_from_annotation(
                fork=cls,
                field_name=field_name,
                field_hint=field_info.annotation,
            )
            if default_value is not None:
                defaults[field_name] = default_value

        return FixtureHeader(**defaults)

transition_tool_name() classmethod

Return fork name as it's meant to be passed to the transition tool for execution.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
48
49
50
51
52
53
54
55
56
@classmethod
def transition_tool_name(cls) -> str:
    """
    Return fork name as it's meant to be passed to the transition tool for
    execution.
    """
    if cls._transition_tool_name is not None:
        return cls._transition_tool_name
    return cls.name()

solc_name() classmethod

Return fork name as it's meant to be passed to the solc compiler.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
58
59
60
61
62
63
@classmethod
def solc_name(cls) -> str:
    """Return fork name as it's meant to be passed to the solc compiler."""
    if cls._solc_name is not None:
        return cls._solc_name
    return cls.name().lower()

header_base_fee_required() classmethod

At genesis, header must not contain base fee.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
65
66
67
68
@classmethod
def header_base_fee_required(cls) -> bool:
    """At genesis, header must not contain base fee."""
    return False

header_prev_randao_required() classmethod

At genesis, header must not contain Prev Randao value.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
70
71
72
73
@classmethod
def header_prev_randao_required(cls) -> bool:
    """At genesis, header must not contain Prev Randao value."""
    return False

header_zero_difficulty_required() classmethod

At genesis, header must not have difficulty zero.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
75
76
77
78
@classmethod
def header_zero_difficulty_required(cls) -> bool:
    """At genesis, header must not have difficulty zero."""
    return False

header_withdrawals_required() classmethod

At genesis, header must not contain withdrawals.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
80
81
82
83
@classmethod
def header_withdrawals_required(cls) -> bool:
    """At genesis, header must not contain withdrawals."""
    return False

header_excess_blob_gas_required() classmethod

At genesis, header must not contain excess blob gas.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
85
86
87
88
@classmethod
def header_excess_blob_gas_required(cls) -> bool:
    """At genesis, header must not contain excess blob gas."""
    return False

header_blob_gas_used_required() classmethod

At genesis, header must not contain blob gas used.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
90
91
92
93
@classmethod
def header_blob_gas_used_required(cls) -> bool:
    """At genesis, header must not contain blob gas used."""
    return False

gas_costs() classmethod

Return dataclass with the defined gas costs constants for genesis.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
@classmethod
def gas_costs(cls) -> GasCosts:
    """
    Return dataclass with the defined gas costs constants for genesis.
    """
    return GasCosts(
        # Tiers
        BASE=BASE,
        VERY_LOW=VERY_LOW,
        LOW=LOW,
        MID=MID,
        HIGH=HIGH,
        # Access
        WARM_ACCESS=100,
        COLD_ACCOUNT_ACCESS=2_600,
        WARM_SLOAD=100,
        COLD_STORAGE_ACCESS=2_100,
        # Storage
        STORAGE_SET=20_000,
        COLD_STORAGE_WRITE=5_000,
        STORAGE_RESET=2_900,
        # Call
        CALL_VALUE=9_000,
        CALL_STIPEND=2_300,
        NEW_ACCOUNT=25_000,
        # Contract Creation
        CODE_DEPOSIT_PER_BYTE=200,
        CODE_INIT_PER_WORD=2,
        # Authorization
        AUTH_PER_EMPTY_ACCOUNT=0,
        # Utility
        MEMORY_PER_WORD=3,
        # Transactions
        TX_BASE=21_000,
        TX_ACCESS_LIST_ADDRESS=2_400,
        TX_ACCESS_LIST_STORAGE_KEY=1_900,
        TX_DATA_PER_ZERO=4,
        TX_DATA_PER_NON_ZERO=68,
        TX_CREATE=32_000,
        # Refunds
        REFUND_STORAGE_CLEAR=4_800,
        REFUND_AUTH_PER_EXISTING_ACCOUNT=0,
        # Precompiles
        PRECOMPILE_ECRECOVER=3_000,
        PRECOMPILE_SHA256_BASE=60,
        PRECOMPILE_SHA256_PER_WORD=12,
        PRECOMPILE_RIPEMD160_BASE=600,
        PRECOMPILE_RIPEMD160_PER_WORD=120,
        PRECOMPILE_IDENTITY_BASE=15,
        PRECOMPILE_IDENTITY_PER_WORD=3,
        # Static Opcodes
        OPCODE_ADD=VERY_LOW,
        OPCODE_SUB=VERY_LOW,
        OPCODE_MUL=LOW,
        OPCODE_DIV=LOW,
        OPCODE_SDIV=LOW,
        OPCODE_MOD=LOW,
        OPCODE_SMOD=LOW,
        OPCODE_ADDMOD=MID,
        OPCODE_MULMOD=MID,
        OPCODE_SIGNEXTEND=LOW,
        OPCODE_LT=VERY_LOW,
        OPCODE_GT=VERY_LOW,
        OPCODE_SLT=VERY_LOW,
        OPCODE_SGT=VERY_LOW,
        OPCODE_EQ=VERY_LOW,
        OPCODE_ISZERO=VERY_LOW,
        OPCODE_AND=VERY_LOW,
        OPCODE_OR=VERY_LOW,
        OPCODE_XOR=VERY_LOW,
        OPCODE_NOT=VERY_LOW,
        OPCODE_BYTE=VERY_LOW,
        OPCODE_JUMP=MID,
        OPCODE_JUMPI=HIGH,
        OPCODE_JUMPDEST=1,
        OPCODE_CALLDATALOAD=VERY_LOW,
        OPCODE_BLOCKHASH=20,
        OPCODE_COINBASE=BASE,
        OPCODE_PUSH=VERY_LOW,
        OPCODE_DUP=VERY_LOW,
        OPCODE_SWAP=VERY_LOW,
        # Dynamic Opcode Components
        OPCODE_CALLDATACOPY_BASE=VERY_LOW,
        OPCODE_CODECOPY_BASE=VERY_LOW,
        OPCODE_MLOAD_BASE=VERY_LOW,
        OPCODE_MSTORE_BASE=VERY_LOW,
        OPCODE_MSTORE8_BASE=VERY_LOW,
        OPCODE_SELFDESTRUCT_BASE=5_000,
        OPCODE_COPY_PER_WORD=3,
        OPCODE_CREATE_BASE=32_000,
        OPCODE_EXP_BASE=10,
        OPCODE_EXP_PER_BYTE=50,
        OPCODE_LOG_BASE=375,
        OPCODE_LOG_DATA_PER_BYTE=8,
        OPCODE_LOG_TOPIC=375,
        OPCODE_KECCAK256_BASE=30,
        OPCODE_KECCACK256_PER_WORD=6,
        # Zero-initialized: introduced in later forks, set via
        # replace() in the fork that activates them.
        TX_DATA_TOKEN_STANDARD=0,
        TX_DATA_TOKEN_FLOOR=0,
        PRECOMPILE_ECADD=0,
        PRECOMPILE_ECMUL=0,
        PRECOMPILE_ECPAIRING_BASE=0,
        PRECOMPILE_ECPAIRING_PER_POINT=0,
        PRECOMPILE_BLAKE2F_BASE=0,
        PRECOMPILE_BLAKE2F_PER_ROUND=0,
        PRECOMPILE_POINT_EVALUATION=0,
        PRECOMPILE_BLS_G1ADD=0,
        PRECOMPILE_BLS_G1MUL=0,
        PRECOMPILE_BLS_G1MAP=0,
        PRECOMPILE_BLS_G2ADD=0,
        PRECOMPILE_BLS_G2MUL=0,
        PRECOMPILE_BLS_G2MAP=0,
        PRECOMPILE_BLS_PAIRING_BASE=0,
        PRECOMPILE_BLS_PAIRING_PER_PAIR=0,
        PRECOMPILE_P256VERIFY=0,
        BLOCK_ACCESS_LIST_ITEM=0,
    )

opcode_gas_map() classmethod

Return a mapping of opcodes to their gas costs.

Each entry is either: - Constants (int): Direct gas cost values from gas_costs() - Callables: Functions that take the opcode instance with metadata and return gas cost

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
@classmethod
def opcode_gas_map(
    cls,
) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
    """
    Return a mapping of opcodes to their gas costs.

    Each entry is either:
    - Constants (int): Direct gas cost values from gas_costs()
    - Callables: Functions that take the opcode instance with metadata and
                 return gas cost
    """
    gas_costs = cls.gas_costs()
    memory_expansion_calculator = cls.memory_expansion_gas_calculator()

    # Define the opcode gas cost mapping
    # Each entry is either:
    # - an int (constant cost)
    # - a callable(opcode) -> int
    return {
        # Stop and arithmetic operations
        Opcodes.STOP: 0,
        Opcodes.ADD: gas_costs.OPCODE_ADD,
        Opcodes.MUL: gas_costs.OPCODE_MUL,
        Opcodes.SUB: gas_costs.OPCODE_SUB,
        Opcodes.DIV: gas_costs.OPCODE_DIV,
        Opcodes.SDIV: gas_costs.OPCODE_SDIV,
        Opcodes.MOD: gas_costs.OPCODE_MOD,
        Opcodes.SMOD: gas_costs.OPCODE_SMOD,
        Opcodes.ADDMOD: gas_costs.OPCODE_ADDMOD,
        Opcodes.MULMOD: gas_costs.OPCODE_MULMOD,
        Opcodes.EXP: lambda op: (
            gas_costs.OPCODE_EXP_BASE
            + gas_costs.OPCODE_EXP_PER_BYTE
            * ((op.metadata["exponent"].bit_length() + 7) // 8)
        ),
        Opcodes.SIGNEXTEND: gas_costs.OPCODE_SIGNEXTEND,
        # Comparison & bitwise logic operations
        Opcodes.LT: gas_costs.OPCODE_LT,
        Opcodes.GT: gas_costs.OPCODE_GT,
        Opcodes.SLT: gas_costs.OPCODE_SLT,
        Opcodes.SGT: gas_costs.OPCODE_SGT,
        Opcodes.EQ: gas_costs.OPCODE_EQ,
        Opcodes.ISZERO: gas_costs.OPCODE_ISZERO,
        Opcodes.AND: gas_costs.OPCODE_AND,
        Opcodes.OR: gas_costs.OPCODE_OR,
        Opcodes.XOR: gas_costs.OPCODE_XOR,
        Opcodes.NOT: gas_costs.OPCODE_NOT,
        Opcodes.BYTE: gas_costs.OPCODE_BYTE,
        # SHA3
        Opcodes.SHA3: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_KECCAK256_BASE
                + gas_costs.OPCODE_KECCACK256_PER_WORD
                * ((op.metadata["data_size"] + 31) // 32)
            ),
            memory_expansion_calculator,
        ),
        # Environmental information
        Opcodes.ADDRESS: gas_costs.BASE,
        Opcodes.BALANCE: cls._with_account_access(0, gas_costs),
        Opcodes.ORIGIN: gas_costs.BASE,
        Opcodes.CALLER: gas_costs.BASE,
        Opcodes.CALLVALUE: gas_costs.BASE,
        Opcodes.CALLDATALOAD: gas_costs.OPCODE_CALLDATALOAD,
        Opcodes.CALLDATASIZE: gas_costs.BASE,
        Opcodes.CALLDATACOPY: cls._with_memory_expansion(
            cls._with_data_copy(
                gas_costs.OPCODE_CALLDATACOPY_BASE, gas_costs
            ),
            memory_expansion_calculator,
        ),
        Opcodes.CODESIZE: gas_costs.BASE,
        Opcodes.CODECOPY: cls._with_memory_expansion(
            cls._with_data_copy(gas_costs.OPCODE_CODECOPY_BASE, gas_costs),
            memory_expansion_calculator,
        ),
        Opcodes.GASPRICE: gas_costs.BASE,
        Opcodes.EXTCODESIZE: cls._with_account_access(0, gas_costs),
        Opcodes.EXTCODECOPY: cls._with_memory_expansion(
            cls._with_data_copy(
                cls._with_account_access(0, gas_costs),
                gas_costs,
            ),
            memory_expansion_calculator,
        ),
        # Block information
        Opcodes.BLOCKHASH: gas_costs.OPCODE_BLOCKHASH,
        Opcodes.COINBASE: gas_costs.OPCODE_COINBASE,
        Opcodes.TIMESTAMP: gas_costs.BASE,
        Opcodes.NUMBER: gas_costs.BASE,
        Opcodes.PREVRANDAO: gas_costs.BASE,
        Opcodes.GASLIMIT: gas_costs.BASE,
        # Stack, memory, storage and flow operations
        Opcodes.POP: gas_costs.BASE,
        Opcodes.MLOAD: cls._with_memory_expansion(
            gas_costs.OPCODE_MLOAD_BASE,
            memory_expansion_calculator,
        ),
        Opcodes.MSTORE: cls._with_memory_expansion(
            gas_costs.OPCODE_MSTORE_BASE,
            memory_expansion_calculator,
        ),
        Opcodes.MSTORE8: cls._with_memory_expansion(
            gas_costs.OPCODE_MSTORE8_BASE,
            memory_expansion_calculator,
        ),
        Opcodes.SLOAD: lambda op: (
            gas_costs.WARM_SLOAD
            if op.metadata["key_warm"]
            else gas_costs.COLD_STORAGE_ACCESS
        ),
        Opcodes.SSTORE: lambda op: cls._calculate_sstore_gas(
            op, gas_costs
        ),
        Opcodes.JUMP: gas_costs.OPCODE_JUMP,
        Opcodes.JUMPI: gas_costs.OPCODE_JUMPI,
        Opcodes.PC: gas_costs.BASE,
        Opcodes.MSIZE: gas_costs.BASE,
        Opcodes.GAS: gas_costs.BASE,
        Opcodes.JUMPDEST: gas_costs.OPCODE_JUMPDEST,
        # Push operations (PUSH1 through PUSH32)
        **{
            getattr(Opcodes, f"PUSH{i}"): gas_costs.OPCODE_PUSH
            for i in range(1, 33)
        },
        # Dup operations (DUP1 through DUP16)
        **{
            getattr(Opcodes, f"DUP{i}"): gas_costs.OPCODE_DUP
            for i in range(1, 17)
        },
        # Swap operations (SWAP1 through SWAP16)
        **{
            getattr(Opcodes, f"SWAP{i}"): gas_costs.OPCODE_SWAP
            for i in range(1, 17)
        },
        # Logging operations
        Opcodes.LOG0: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_LOG_BASE
                + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                * op.metadata["data_size"]
            ),
            memory_expansion_calculator,
        ),
        Opcodes.LOG1: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_LOG_BASE
                + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                * op.metadata["data_size"]
                + gas_costs.OPCODE_LOG_TOPIC
            ),
            memory_expansion_calculator,
        ),
        Opcodes.LOG2: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_LOG_BASE
                + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                * op.metadata["data_size"]
                + gas_costs.OPCODE_LOG_TOPIC * 2
            ),
            memory_expansion_calculator,
        ),
        Opcodes.LOG3: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_LOG_BASE
                + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                * op.metadata["data_size"]
                + gas_costs.OPCODE_LOG_TOPIC * 3
            ),
            memory_expansion_calculator,
        ),
        Opcodes.LOG4: cls._with_memory_expansion(
            lambda op: (
                gas_costs.OPCODE_LOG_BASE
                + gas_costs.OPCODE_LOG_DATA_PER_BYTE
                * op.metadata["data_size"]
                + gas_costs.OPCODE_LOG_TOPIC * 4
            ),
            memory_expansion_calculator,
        ),
        # System operations
        Opcodes.CREATE: cls._with_memory_expansion(
            lambda op: cls._calculate_create_gas(op, gas_costs),
            memory_expansion_calculator,
        ),
        Opcodes.CALL: cls._with_memory_expansion(
            lambda op: cls._calculate_call_gas(op, gas_costs),
            memory_expansion_calculator,
        ),
        Opcodes.CALLCODE: cls._with_memory_expansion(
            lambda op: cls._calculate_call_gas(op, gas_costs),
            memory_expansion_calculator,
        ),
        Opcodes.RETURN: cls._with_memory_expansion(
            lambda op: cls._calculate_return_gas(op, gas_costs),
            memory_expansion_calculator,
        ),
        Opcodes.INVALID: 0,
        Opcodes.SELFDESTRUCT: lambda op: cls._calculate_selfdestruct_gas(
            op, gas_costs
        ),
    }

opcode_gas_calculator() classmethod

Return callable that calculates the gas cost of a single opcode.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
@classmethod
def opcode_gas_calculator(cls) -> OpcodeGasCalculator:
    """
    Return callable that calculates the gas cost of a single opcode.
    """
    opcode_gas_map = cls.opcode_gas_map()

    def fn(opcode: OpcodeBase) -> int:
        # Get the gas cost or calculator
        if opcode not in opcode_gas_map:
            raise ValueError(
                f"No gas cost defined for opcode: {opcode._name_}"
            )
        gas_cost_or_calculator = opcode_gas_map[opcode]

        # If it's a callable, call it with the opcode
        if callable(gas_cost_or_calculator):
            return gas_cost_or_calculator(opcode)

        # Otherwise it's a constant
        return gas_cost_or_calculator

    return fn

opcode_refund_map() classmethod

Return a mapping of opcodes to their gas refunds.

Each entry is either: - Constants (int): Direct gas refund values - Callables: Functions that take the opcode instance with metadata and return gas refund

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
@classmethod
def opcode_refund_map(
    cls,
) -> Dict[OpcodeBase, int | Callable[[OpcodeBase], int]]:
    """
    Return a mapping of opcodes to their gas refunds.

    Each entry is either:
    - Constants (int): Direct gas refund values
    - Callables: Functions that take the opcode instance with metadata and
                 return gas refund
    """
    gas_costs = cls.gas_costs()

    # Only SSTORE provides refunds
    return {
        Opcodes.SSTORE: lambda op: cls._calculate_sstore_refund(
            op, gas_costs
        ),
    }

opcode_refund_calculator() classmethod

Return callable that calculates the gas refund of a single opcode.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
@classmethod
def opcode_refund_calculator(cls) -> OpcodeGasCalculator:
    """
    Return callable that calculates the gas refund of a single opcode.
    """
    opcode_refund_map = cls.opcode_refund_map()

    def fn(opcode: OpcodeBase) -> int:
        # Get the gas refund or calculator
        if opcode not in opcode_refund_map:
            # Most opcodes don't provide refunds
            return 0
        refund_or_calculator = opcode_refund_map[opcode]

        # If it's a callable, call it with the opcode
        if callable(refund_or_calculator):
            return refund_or_calculator(opcode)

        # Otherwise it's a constant
        return refund_or_calculator

    return fn

memory_expansion_gas_calculator() classmethod

Return callable that calculates the gas cost of memory expansion for the fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
@classmethod
def memory_expansion_gas_calculator(cls) -> MemoryExpansionGasCalculator:
    """
    Return callable that calculates the gas cost of memory expansion for
    the fork.
    """
    gas_costs = cls.gas_costs()

    def fn(*, new_bytes: int, previous_bytes: int = 0) -> int:
        if new_bytes <= previous_bytes:
            return 0
        new_words = ceiling_division(new_bytes, 32)
        previous_words = ceiling_division(previous_bytes, 32)

        def c(w: int) -> int:
            return (gas_costs.MEMORY_PER_WORD * w) + ((w * w) // 512)

        return c(new_words) - c(previous_words)

    return fn

calldata_gas_calculator() classmethod

Return callable that calculates the transaction gas cost for its calldata depending on its contents.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
@classmethod
def calldata_gas_calculator(cls) -> CalldataGasCalculator:
    """
    Return callable that calculates the transaction gas cost for its
    calldata depending on its contents.
    """
    gas_costs = cls.gas_costs()

    def fn(*, data: BytesConvertible, floor: bool = False) -> int:
        del floor

        raw = Bytes(data)
        num_zeros = raw.count(0)
        num_non_zeros = len(raw) - num_zeros
        return (
            num_zeros * gas_costs.TX_DATA_PER_ZERO
            + num_non_zeros * gas_costs.TX_DATA_PER_NON_ZERO
        )

    return fn

base_fee_per_gas_calculator() classmethod

Return a callable that calculates the base fee per gas at a given fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
775
776
777
778
779
780
781
782
@classmethod
def base_fee_per_gas_calculator(cls) -> BaseFeePerGasCalculator:
    """
    Return a callable that calculates the base fee per gas at a given fork.
    """
    raise NotImplementedError(
        f"Base fee per gas calculator is not supported in {cls.name()}"
    )

base_fee_change_calculator() classmethod

Return a callable that calculates the gas that needs to be used to change the base fee.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
784
785
786
787
788
789
790
791
792
@classmethod
def base_fee_change_calculator(cls) -> BaseFeeChangeCalculator:
    """
    Return a callable that calculates the gas that needs to be used to
    change the base fee.
    """
    raise NotImplementedError(
        f"Base fee change calculator is not supported in {cls.name()}"
    )

base_fee_max_change_denominator() classmethod

Return the base fee max change denominator at a given fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
794
795
796
797
798
799
@classmethod
def base_fee_max_change_denominator(cls) -> int:
    """Return the base fee max change denominator at a given fork."""
    raise NotImplementedError(
        f"Base fee max change denominator is not supported in {cls.name()}"
    )

base_fee_elasticity_multiplier() classmethod

Return the base fee elasticity multiplier at a given fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
801
802
803
804
805
806
@classmethod
def base_fee_elasticity_multiplier(cls) -> int:
    """Return the base fee elasticity multiplier at a given fork."""
    raise NotImplementedError(
        f"Base fee elasticity multiplier is not supported in {cls.name()}"
    )

transaction_data_floor_cost_calculator() classmethod

At frontier, the transaction data floor cost is a constant zero.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
808
809
810
811
812
813
814
815
816
817
818
@classmethod
def transaction_data_floor_cost_calculator(
    cls,
) -> TransactionDataFloorCostCalculator:
    """At frontier, the transaction data floor cost is a constant zero."""

    def fn(*, data: BytesConvertible) -> int:
        del data
        return 0

    return fn

transaction_intrinsic_cost_calculator() classmethod

Return callable that calculates the intrinsic gas cost of a transaction for the fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
@classmethod
def transaction_intrinsic_cost_calculator(
    cls,
) -> TransactionIntrinsicCostCalculator:
    """
    Return callable that calculates the intrinsic gas cost of a transaction
    for the fork.
    """
    gas_costs = cls.gas_costs()
    calldata_gas_calculator = cls.calldata_gas_calculator()

    def fn(
        *,
        calldata: BytesConvertible = b"",
        contract_creation: bool = False,
        access_list: List[AccessList] | None = None,
        authorization_list_or_count: Sized | int | None = None,
        return_cost_deducted_prior_execution: bool = False,
    ) -> int:
        del return_cost_deducted_prior_execution

        assert access_list is None, (
            f"Access list is not supported in {cls.name()}"
        )
        assert authorization_list_or_count is None, (
            f"Authorizations are not supported in {cls.name()}"
        )

        intrinsic_cost: int = gas_costs.TX_BASE

        if contract_creation:
            intrinsic_cost += (
                gas_costs.CODE_INIT_PER_WORD
                * ceiling_division(len(Bytes(calldata)), 32)
            )

        return intrinsic_cost + calldata_gas_calculator(data=calldata)

    return fn

blob_gas_price_calculator() classmethod

Return a callable that calculates the blob gas price at a given fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
860
861
862
863
864
865
866
867
@classmethod
def blob_gas_price_calculator(cls) -> BlobGasPriceCalculator:
    """
    Return a callable that calculates the blob gas price at a given fork.
    """
    raise NotImplementedError(
        f"Blob gas price calculator is not supported in {cls.name()}"
    )

excess_blob_gas_calculator() classmethod

Return a callable that calculates the excess blob gas for a block at a given fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
869
870
871
872
873
874
875
876
877
@classmethod
def excess_blob_gas_calculator(cls) -> ExcessBlobGasCalculator:
    """
    Return a callable that calculates the excess blob gas for a block at a
    given fork.
    """
    raise NotImplementedError(
        f"Excess blob gas calculator is not supported in {cls.name()}"
    )

supports_blobs() classmethod

Blobs are not supported at Frontier.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
879
880
881
882
@classmethod
def supports_blobs(cls) -> bool:
    """Blobs are not supported at Frontier."""
    return False

blob_reserve_price_active() classmethod

Return whether the fork uses a reserve price mechanism for blobs or not.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
884
885
886
887
888
889
890
891
892
@classmethod
def blob_reserve_price_active(cls) -> bool:
    """
    Return whether the fork uses a reserve price mechanism for blobs or
    not.
    """
    raise NotImplementedError(
        f"Blob reserve price is not supported in {cls.name()}"
    )

full_blob_tx_wrapper_version() classmethod

Return the version of the full blob transaction wrapper.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
894
895
896
897
898
899
900
@classmethod
def full_blob_tx_wrapper_version(cls) -> int | None:
    """Return the version of the full blob transaction wrapper."""
    raise NotImplementedError(
        "Full blob transaction wrapper version is not supported in "
        f"{cls.name()}"
    )

blob_schedule() classmethod

At genesis, no blob schedule is used.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
902
903
904
905
@classmethod
def blob_schedule(cls) -> BlobSchedule | None:
    """At genesis, no blob schedule is used."""
    return None

header_requests_required() classmethod

At genesis, header must not contain beacon chain requests.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
907
908
909
910
@classmethod
def header_requests_required(cls) -> bool:
    """At genesis, header must not contain beacon chain requests."""
    return False

header_bal_hash_required() classmethod

At genesis, header must not contain block access list hash.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
912
913
914
915
@classmethod
def header_bal_hash_required(cls) -> bool:
    """At genesis, header must not contain block access list hash."""
    return False

empty_block_bal_item_count() classmethod

Pre-Amsterdam forks have no block access list.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
917
918
919
920
@classmethod
def empty_block_bal_item_count(cls) -> int:
    """Pre-Amsterdam forks have no block access list."""
    return 0

header_beacon_root_required() classmethod

At genesis, header must not contain parent beacon block root.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
922
923
924
925
@classmethod
def header_beacon_root_required(cls) -> bool:
    """At genesis, header must not contain parent beacon block root."""
    return False

engine_new_payload_blob_hashes() classmethod

At genesis, payloads do not have blob hashes.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
927
928
929
930
@classmethod
def engine_new_payload_blob_hashes(cls) -> bool:
    """At genesis, payloads do not have blob hashes."""
    return False

engine_new_payload_beacon_root() classmethod

At genesis, payloads do not have a parent beacon block root.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
932
933
934
935
@classmethod
def engine_new_payload_beacon_root(cls) -> bool:
    """At genesis, payloads do not have a parent beacon block root."""
    return False

engine_new_payload_requests() classmethod

At genesis, payloads do not have requests.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
937
938
939
940
@classmethod
def engine_new_payload_requests(cls) -> bool:
    """At genesis, payloads do not have requests."""
    return False

engine_execution_payload_block_access_list() classmethod

At genesis, payloads do not have block access list.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
942
943
944
945
@classmethod
def engine_execution_payload_block_access_list(cls) -> bool:
    """At genesis, payloads do not have block access list."""
    return False

engine_new_payload_target_blobs_per_block() classmethod

At genesis, payloads do not have target blobs per block.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
947
948
949
950
@classmethod
def engine_new_payload_target_blobs_per_block(cls) -> bool:
    """At genesis, payloads do not have target blobs per block."""
    return False

engine_payload_attribute_target_blobs_per_block() classmethod

At genesis, payload attributes do not include the target blobs per block.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
952
953
954
955
956
957
958
@classmethod
def engine_payload_attribute_target_blobs_per_block(cls) -> bool:
    """
    At genesis, payload attributes do not include the target blobs per
    block.
    """
    return False

engine_payload_attribute_max_blobs_per_block() classmethod

At genesis, payload attributes do not include the max blobs per block.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
960
961
962
963
964
965
@classmethod
def engine_payload_attribute_max_blobs_per_block(cls) -> bool:
    """
    At genesis, payload attributes do not include the max blobs per block.
    """
    return False

get_reward() classmethod

At Genesis the expected reward amount in wei is 5_000_000_000_000_000_000.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
967
968
969
970
971
972
973
@classmethod
def get_reward(cls) -> int:
    """
    At Genesis the expected reward amount in wei is
    5_000_000_000_000_000_000.
    """
    return 5_000_000_000_000_000_000

supports_protected_txs() classmethod

At Genesis, fork has no support for EIP-155 protected txs.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
975
976
977
978
@classmethod
def supports_protected_txs(cls) -> bool:
    """At Genesis, fork has no support for EIP-155 protected txs."""
    return False

tx_types() classmethod

At Genesis, only legacy transactions are allowed.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
980
981
982
983
@classmethod
def tx_types(cls) -> List[int]:
    """At Genesis, only legacy transactions are allowed."""
    return [0]

contract_creating_tx_types() classmethod

At Genesis, only legacy transactions are allowed.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
985
986
987
988
@classmethod
def contract_creating_tx_types(cls) -> List[int]:
    """At Genesis, only legacy transactions are allowed."""
    return [0]

transaction_gas_limit_cap() classmethod

At Genesis, no transaction gas limit cap is imposed.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
990
991
992
993
@classmethod
def transaction_gas_limit_cap(cls) -> int | None:
    """At Genesis, no transaction gas limit cap is imposed."""
    return None

block_rlp_size_limit() classmethod

At Genesis, no RLP block size limit is imposed.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
995
996
997
998
@classmethod
def block_rlp_size_limit(cls) -> int | None:
    """At Genesis, no RLP block size limit is imposed."""
    return None

precompiles() classmethod

At Genesis, EC-recover, SHA256, RIPEMD160, and Identity precompiles are introduced.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
@classmethod
def precompiles(cls) -> List[Address]:
    """
    At Genesis, EC-recover, SHA256, RIPEMD160, and Identity precompiles
    are introduced.
    """
    return [
        Address(1, label="ECREC"),
        Address(2, label="SHA256"),
        Address(3, label="RIPEMD160"),
        Address(4, label="ID"),
    ]

system_contracts() classmethod

At Genesis, no system contracts are present.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1013
1014
1015
1016
@classmethod
def system_contracts(cls) -> List[Address]:
    """At Genesis, no system contracts are present."""
    return []

deterministic_factory_predeploy_address() classmethod

At Genesis, no deterministic factory predeploy is present.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1018
1019
1020
1021
@classmethod
def deterministic_factory_predeploy_address(cls) -> Address | None:
    """At Genesis, no deterministic factory predeploy is present."""
    return None

max_code_size() classmethod

At genesis, there is no upper bound for code size (bounded by block gas limit).

However, the default is set to the limit of EIP-170 (Spurious Dragon)

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1023
1024
1025
1026
1027
1028
1029
1030
1031
@classmethod
def max_code_size(cls) -> int:
    """
    At genesis, there is no upper bound for code size (bounded by block gas
    limit).

    However, the default is set to the limit of EIP-170 (Spurious Dragon)
    """
    return 0x6000

max_stack_height() classmethod

At genesis, the maximum stack height is 1024.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1033
1034
1035
1036
@classmethod
def max_stack_height(cls) -> int:
    """At genesis, the maximum stack height is 1024."""
    return 1024

max_initcode_size() classmethod

At genesis, there is no upper bound for initcode size.

However, the default is set to the limit of EIP-3860 (Shanghai).

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1038
1039
1040
1041
1042
1043
1044
1045
@classmethod
def max_initcode_size(cls) -> int:
    """
    At genesis, there is no upper bound for initcode size.

    However, the default is set to the limit of EIP-3860 (Shanghai).
    """
    return 0xC000

call_opcodes() classmethod

Return list of call opcodes supported by the fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1047
1048
1049
1050
@classmethod
def call_opcodes(cls) -> List[Opcodes]:
    """Return list of call opcodes supported by the fork."""
    return [Opcodes.CALL, Opcodes.CALLCODE]

valid_opcodes() classmethod

Return list of Opcodes that are valid to work on this fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
@classmethod
def valid_opcodes(cls) -> List[Opcodes]:
    """Return list of Opcodes that are valid to work on this fork."""
    return [
        Opcodes.STOP,
        Opcodes.ADD,
        Opcodes.MUL,
        Opcodes.SUB,
        Opcodes.DIV,
        Opcodes.SDIV,
        Opcodes.MOD,
        Opcodes.SMOD,
        Opcodes.ADDMOD,
        Opcodes.MULMOD,
        Opcodes.EXP,
        Opcodes.SIGNEXTEND,
        Opcodes.LT,
        Opcodes.GT,
        Opcodes.SLT,
        Opcodes.SGT,
        Opcodes.EQ,
        Opcodes.ISZERO,
        Opcodes.AND,
        Opcodes.OR,
        Opcodes.XOR,
        Opcodes.NOT,
        Opcodes.BYTE,
        Opcodes.SHA3,
        Opcodes.ADDRESS,
        Opcodes.BALANCE,
        Opcodes.ORIGIN,
        Opcodes.CALLER,
        Opcodes.CALLVALUE,
        Opcodes.CALLDATALOAD,
        Opcodes.CALLDATASIZE,
        Opcodes.CALLDATACOPY,
        Opcodes.CODESIZE,
        Opcodes.CODECOPY,
        Opcodes.GASPRICE,
        Opcodes.EXTCODESIZE,
        Opcodes.EXTCODECOPY,
        Opcodes.BLOCKHASH,
        Opcodes.COINBASE,
        Opcodes.TIMESTAMP,
        Opcodes.NUMBER,
        Opcodes.PREVRANDAO,
        Opcodes.GASLIMIT,
        Opcodes.POP,
        Opcodes.MLOAD,
        Opcodes.MSTORE,
        Opcodes.MSTORE8,
        Opcodes.SLOAD,
        Opcodes.SSTORE,
        Opcodes.PC,
        Opcodes.MSIZE,
        Opcodes.GAS,
        Opcodes.JUMP,
        Opcodes.JUMPI,
        Opcodes.JUMPDEST,
        Opcodes.PUSH1,
        Opcodes.PUSH2,
        Opcodes.PUSH3,
        Opcodes.PUSH4,
        Opcodes.PUSH5,
        Opcodes.PUSH6,
        Opcodes.PUSH7,
        Opcodes.PUSH8,
        Opcodes.PUSH9,
        Opcodes.PUSH10,
        Opcodes.PUSH11,
        Opcodes.PUSH12,
        Opcodes.PUSH13,
        Opcodes.PUSH14,
        Opcodes.PUSH15,
        Opcodes.PUSH16,
        Opcodes.PUSH17,
        Opcodes.PUSH18,
        Opcodes.PUSH19,
        Opcodes.PUSH20,
        Opcodes.PUSH21,
        Opcodes.PUSH22,
        Opcodes.PUSH23,
        Opcodes.PUSH24,
        Opcodes.PUSH25,
        Opcodes.PUSH26,
        Opcodes.PUSH27,
        Opcodes.PUSH28,
        Opcodes.PUSH29,
        Opcodes.PUSH30,
        Opcodes.PUSH31,
        Opcodes.PUSH32,
        Opcodes.DUP1,
        Opcodes.DUP2,
        Opcodes.DUP3,
        Opcodes.DUP4,
        Opcodes.DUP5,
        Opcodes.DUP6,
        Opcodes.DUP7,
        Opcodes.DUP8,
        Opcodes.DUP9,
        Opcodes.DUP10,
        Opcodes.DUP11,
        Opcodes.DUP12,
        Opcodes.DUP13,
        Opcodes.DUP14,
        Opcodes.DUP15,
        Opcodes.DUP16,
        Opcodes.SWAP1,
        Opcodes.SWAP2,
        Opcodes.SWAP3,
        Opcodes.SWAP4,
        Opcodes.SWAP5,
        Opcodes.SWAP6,
        Opcodes.SWAP7,
        Opcodes.SWAP8,
        Opcodes.SWAP9,
        Opcodes.SWAP10,
        Opcodes.SWAP11,
        Opcodes.SWAP12,
        Opcodes.SWAP13,
        Opcodes.SWAP14,
        Opcodes.SWAP15,
        Opcodes.SWAP16,
        Opcodes.LOG0,
        Opcodes.LOG1,
        Opcodes.LOG2,
        Opcodes.LOG3,
        Opcodes.LOG4,
        Opcodes.CREATE,
        Opcodes.CALL,
        Opcodes.CALLCODE,
        Opcodes.RETURN,
        Opcodes.SELFDESTRUCT,
    ]

create_opcodes() classmethod

At Genesis, only CREATE opcode is supported.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1187
1188
1189
1190
@classmethod
def create_opcodes(cls) -> List[Opcodes]:
    """At Genesis, only `CREATE` opcode is supported."""
    return [Opcodes.CREATE]

max_refund_quotient() classmethod

Return the max refund quotient at Genesis.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1192
1193
1194
1195
@classmethod
def max_refund_quotient(cls) -> int:
    """Return the max refund quotient at Genesis."""
    return 2

max_request_type() classmethod

At genesis, no request type is supported, signaled by -1.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1197
1198
1199
1200
@classmethod
def max_request_type(cls) -> int:
    """At genesis, no request type is supported, signaled by -1."""
    return -1

pre_allocation() classmethod

Return whether the fork expects pre-allocation of accounts.

Frontier does not require pre-allocated accounts

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1202
1203
1204
1205
1206
1207
1208
1209
@classmethod
def pre_allocation(cls) -> Mapping:
    """
    Return whether the fork expects pre-allocation of accounts.

    Frontier does not require pre-allocated accounts
    """
    return {}

pre_allocation_blockchain() classmethod

Return whether the fork expects pre-allocation of accounts.

Frontier does not require pre-allocated accounts

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1211
1212
1213
1214
1215
1216
1217
1218
@classmethod
def pre_allocation_blockchain(cls) -> Mapping:
    """
    Return whether the fork expects pre-allocation of accounts.

    Frontier does not require pre-allocated accounts
    """
    return {}

build_default_block_header(*, block_number=0, timestamp=0) classmethod

Build a default block header for this fork with the given attributes.

This method automatically detects which header fields are required by the fork and assigns appropriate default values. It introspects the FixtureHeader model to find fields with HeaderForkRequirement annotations and automatically includes them if the fork requires them.

Parameters:

Name Type Description Default
block_number int

The block number

0
timestamp int

The block timestamp

0

Returns:

Type Description
FixtureHeader

FixtureHeader instance with default values applied based on fork

FixtureHeader

requirements.

Raises:

Type Description
TypeError

If the overrides don't have the correct type.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
@classmethod
def build_default_block_header(
    cls, *, block_number: int = 0, timestamp: int = 0
) -> FixtureHeader:
    """
    Build a default block header for this fork with the given attributes.

    This method automatically detects which header fields are required by
    the fork and assigns appropriate default values. It introspects the
    FixtureHeader model to find fields with HeaderForkRequirement
    annotations and automatically includes them if the fork requires them.

    Args:
        block_number: The block number
        timestamp: The block timestamp

    Returns:
        FixtureHeader instance with default values applied based on fork
        requirements.

    Raises:
        TypeError: If the overrides don't have the correct type.

    """
    from execution_testing.fixtures.blockchain import FixtureHeader

    defaults = {
        "number": ZeroPaddedHexNumber(block_number),
        "timestamp": ZeroPaddedHexNumber(timestamp),
        "fork": cls,
    }

    # Iterate through FixtureHeader fields to populate defaults
    for field_name, field_info in FixtureHeader.model_fields.items():
        if field_name in defaults:
            continue

        # Get default value, checking fork requirements and model defaults
        default_value = FixtureHeader.get_default_from_annotation(
            fork=cls,
            field_name=field_name,
            field_hint=field_info.annotation,
        )
        if default_value is not None:
            defaults[field_name] = default_value

    return FixtureHeader(**defaults)

GrayGlacier

Bases: ArrowGlacier

Gray Glacier fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1404
1405
1406
1407
1408
1409
1410
1411
class GrayGlacier(
    ArrowGlacier,
    solc_name="london",
    ignore=True,
):
    """Gray Glacier fork."""

    pass

Homestead

Bases: EIP7, EIP2, Frontier

Homestead fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1269
1270
1271
1272
1273
1274
1275
1276
class Homestead(
    eips.EIP7,
    eips.EIP2,
    Frontier,
):
    """Homestead fork."""

    pass

Istanbul

Bases: EIP2028, EIP1884, EIP1344, EIP1108, EIP152, ConstantinopleFix

Istanbul fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
class Istanbul(
    eips.EIP2028,
    eips.EIP1884,
    eips.EIP1344,
    eips.EIP1108,
    eips.EIP152,
    ConstantinopleFix,
):
    """Istanbul fork."""

    pass

London

Bases: EIP3529, EIP3198, EIP1559, Berlin

London fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1382
1383
1384
1385
1386
1387
1388
1389
1390
class London(
    eips.EIP3529,
    eips.EIP3198,
    eips.EIP1559,
    Berlin,
):
    """London fork."""

    pass

MuirGlacier

Bases: Istanbul

Muir Glacier fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1363
1364
1365
1366
1367
1368
1369
1370
class MuirGlacier(
    Istanbul,
    solc_name="istanbul",
    ignore=True,
):
    """Muir Glacier fork."""

    pass

Osaka

Bases: EIP7939, EIP7934, EIP7825, EIP7918, EIP7594, EIP7951, Prague

Osaka fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
class Osaka(
    eips.EIP7939,
    eips.EIP7934,
    eips.EIP7825,
    eips.EIP7918,
    eips.EIP7594,
    eips.EIP7951,
    Prague,
    solc_name="cancun",
):
    """Osaka fork."""

    pass

Paris

Bases: EIP3675, London

Paris (Merge) fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1414
1415
1416
1417
1418
1419
1420
1421
1422
class Paris(
    eips.EIP3675,
    London,
    transition_tool_name="Merge",
    ruleset_name="MERGE",
):
    """Paris (Merge) fork."""

    pass

Prague

Bases: EIP7691, EIP7685, EIP2935, EIP7251, EIP7002, EIP6110, EIP7623, EIP7702, EIP2537, Cancun

Prague fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
class Prague(
    eips.EIP7691,
    eips.EIP7685,
    eips.EIP2935,
    eips.EIP7251,
    eips.EIP7002,
    eips.EIP6110,
    eips.EIP7623,
    eips.EIP7702,
    eips.EIP2537,
    Cancun,
):
    """Prague fork."""

    pass

Shanghai

Bases: EIP3855, EIP3860, EIP4895, Paris

Shanghai fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
class Shanghai(
    eips.EIP3855,
    eips.EIP3860,
    eips.EIP4895,
    Paris,
    fork_by_timestamp=True,
):
    """Shanghai fork."""

    pass

SpuriousDragon

Bases: EIP170, EIP161, EIP155, TangerineWhistle

SpuriousDragon fork.

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
class SpuriousDragon(
    eips.EIP170,
    eips.EIP161,
    eips.EIP155,
    TangerineWhistle,
    ignore=True,
    ruleset_name="SPURIOUS",
):
    """SpuriousDragon fork."""

    pass

TangerineWhistle

Bases: DAOFork

TangerineWhistle fork (EIP-150).

Source code in packages/testing/src/execution_testing/forks/forks/forks.py
1289
1290
1291
1292
1293
1294
1295
1296
class TangerineWhistle(
    DAOFork,
    ignore=True,
    ruleset_name="TANGERINE",
):
    """TangerineWhistle fork (EIP-150)."""

    pass

BerlinToLondonAt5

Bases: TransitionBaseClass

Berlin to London transition at Block 5.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
21
22
23
24
25
@transition_fork(to_fork=London, from_fork=Berlin, at_block=5)
class BerlinToLondonAt5(TransitionBaseClass):
    """Berlin to London transition at Block 5."""

    pass

BPO1ToBPO2AtTime15k

Bases: TransitionBaseClass

BPO1 to BPO2 transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
63
64
65
66
67
@transition_fork(to_fork=BPO2, from_fork=BPO1, at_timestamp=15_000)
class BPO1ToBPO2AtTime15k(TransitionBaseClass):
    """BPO1 to BPO2 transition at Timestamp 15k."""

    pass

BPO2ToAmsterdamAtTime15k

Bases: TransitionBaseClass

BPO2 to Amsterdam transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
70
71
72
73
74
75
76
77
78
@transition_fork(to_fork=Amsterdam, from_fork=BPO2, at_timestamp=15_000)
class BPO2ToAmsterdamAtTime15k(TransitionBaseClass):
    """BPO2 to Amsterdam transition at Timestamp 15k."""

    # TODO: We may need to adjust which BPO Amsterdam inherits from as the
    #  related Amsterdam specs change over time, and before Amsterdam is
    #  live on mainnet.

    pass

BPO2ToBPO3AtTime15k

Bases: TransitionBaseClass

BPO2 to BPO3 transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
81
82
83
84
85
@transition_fork(to_fork=BPO3, from_fork=BPO2, at_timestamp=15_000)
class BPO2ToBPO3AtTime15k(TransitionBaseClass):
    """BPO2 to BPO3 transition at Timestamp 15k."""

    pass

BPO3ToBPO4AtTime15k

Bases: TransitionBaseClass

BPO3 to BPO4 transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
88
89
90
91
92
@transition_fork(to_fork=BPO4, from_fork=BPO3, at_timestamp=15_000)
class BPO3ToBPO4AtTime15k(TransitionBaseClass):
    """BPO3 to BPO4 transition at Timestamp 15k."""

    pass

CancunToPragueAtTime15k

Bases: TransitionBaseClass

Cancun to Prague transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
42
43
44
45
46
@transition_fork(to_fork=Prague, from_fork=Cancun, at_timestamp=15_000)
class CancunToPragueAtTime15k(TransitionBaseClass):
    """Cancun to Prague transition at Timestamp 15k."""

    pass

OsakaToBPO1AtTime15k

Bases: TransitionBaseClass

Osaka to BPO1 transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
56
57
58
59
60
@transition_fork(to_fork=BPO1, from_fork=Osaka, at_timestamp=15_000)
class OsakaToBPO1AtTime15k(TransitionBaseClass):
    """Osaka to BPO1 transition at Timestamp 15k."""

    pass

ParisToShanghaiAtTime15k

Bases: TransitionBaseClass

Paris to Shanghai transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
28
29
30
31
32
@transition_fork(to_fork=Shanghai, from_fork=Paris, at_timestamp=15_000)
class ParisToShanghaiAtTime15k(TransitionBaseClass):
    """Paris to Shanghai transition at Timestamp 15k."""

    pass

PragueToOsakaAtTime15k

Bases: TransitionBaseClass

Prague to Osaka transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
49
50
51
52
53
@transition_fork(to_fork=Osaka, from_fork=Prague, at_timestamp=15_000)
class PragueToOsakaAtTime15k(TransitionBaseClass):
    """Prague to Osaka transition at Timestamp 15k."""

    pass

ShanghaiToCancunAtTime15k

Bases: TransitionBaseClass

Shanghai to Cancun transition at Timestamp 15k.

Source code in packages/testing/src/execution_testing/forks/forks/transition.py
35
36
37
38
39
@transition_fork(to_fork=Cancun, from_fork=Shanghai, at_timestamp=15_000)
class ShanghaiToCancunAtTime15k(TransitionBaseClass):
    """Shanghai to Cancun transition at Timestamp 15k."""

    pass

GasCosts dataclass

Class that contains the gas cost constants for any fork.

Source code in packages/testing/src/execution_testing/forks/gas_costs.py
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
@dataclass(kw_only=True, frozen=True)
class GasCosts:
    """Class that contains the gas cost constants for any fork."""

    # Tiers
    BASE: int
    VERY_LOW: int
    LOW: int
    MID: int
    HIGH: int

    # Access
    WARM_ACCESS: int
    COLD_ACCOUNT_ACCESS: int
    WARM_SLOAD: int
    COLD_STORAGE_ACCESS: int

    # Storage
    STORAGE_SET: int
    COLD_STORAGE_WRITE: int
    STORAGE_RESET: int

    # Call
    CALL_VALUE: int
    CALL_STIPEND: int
    NEW_ACCOUNT: int

    # Contract Creation
    CODE_DEPOSIT_PER_BYTE: int
    CODE_INIT_PER_WORD: int

    # Authorization
    AUTH_PER_EMPTY_ACCOUNT: int

    # Utility
    MEMORY_PER_WORD: int

    # Transactions
    TX_BASE: int
    TX_CREATE: int
    TX_DATA_PER_ZERO: int
    TX_DATA_PER_NON_ZERO: int
    TX_DATA_TOKEN_STANDARD: int
    TX_DATA_TOKEN_FLOOR: int
    TX_ACCESS_LIST_ADDRESS: int
    TX_ACCESS_LIST_STORAGE_KEY: int

    # Refunds
    REFUND_STORAGE_CLEAR: int
    REFUND_AUTH_PER_EXISTING_ACCOUNT: int

    # Precompiles
    PRECOMPILE_ECRECOVER: int
    PRECOMPILE_SHA256_BASE: int
    PRECOMPILE_SHA256_PER_WORD: int
    PRECOMPILE_RIPEMD160_BASE: int
    PRECOMPILE_RIPEMD160_PER_WORD: int
    PRECOMPILE_IDENTITY_BASE: int
    PRECOMPILE_IDENTITY_PER_WORD: int
    PRECOMPILE_ECADD: int
    PRECOMPILE_ECMUL: int
    PRECOMPILE_ECPAIRING_BASE: int
    PRECOMPILE_ECPAIRING_PER_POINT: int
    PRECOMPILE_BLAKE2F_BASE: int
    PRECOMPILE_BLAKE2F_PER_ROUND: int
    PRECOMPILE_POINT_EVALUATION: int
    PRECOMPILE_BLS_G1ADD: int
    PRECOMPILE_BLS_G1MUL: int
    PRECOMPILE_BLS_G1MAP: int
    PRECOMPILE_BLS_G2ADD: int
    PRECOMPILE_BLS_G2MUL: int
    PRECOMPILE_BLS_G2MAP: int
    PRECOMPILE_BLS_PAIRING_BASE: int
    PRECOMPILE_BLS_PAIRING_PER_PAIR: int
    PRECOMPILE_P256VERIFY: int

    # Block Access Lists
    BLOCK_ACCESS_LIST_ITEM: int

    # Opcodes
    OPCODE_ADD: int
    OPCODE_SUB: int
    OPCODE_MUL: int
    OPCODE_DIV: int
    OPCODE_SDIV: int
    OPCODE_MOD: int
    OPCODE_SMOD: int
    OPCODE_ADDMOD: int
    OPCODE_MULMOD: int
    OPCODE_SIGNEXTEND: int
    OPCODE_LT: int
    OPCODE_GT: int
    OPCODE_SLT: int
    OPCODE_SGT: int
    OPCODE_EQ: int
    OPCODE_ISZERO: int
    OPCODE_AND: int
    OPCODE_OR: int
    OPCODE_XOR: int
    OPCODE_NOT: int
    OPCODE_BYTE: int
    OPCODE_JUMP: int
    OPCODE_JUMPI: int
    OPCODE_JUMPDEST: int
    OPCODE_CALLDATALOAD: int
    OPCODE_BLOCKHASH: int
    OPCODE_COINBASE: int
    OPCODE_PUSH: int
    OPCODE_DUP: int
    OPCODE_SWAP: int

    # Dynamic Opcode Components
    OPCODE_CALLDATACOPY_BASE: int
    OPCODE_CODECOPY_BASE: int
    OPCODE_MLOAD_BASE: int
    OPCODE_MSTORE_BASE: int
    OPCODE_MSTORE8_BASE: int
    OPCODE_SELFDESTRUCT_BASE: int
    OPCODE_COPY_PER_WORD: int
    OPCODE_CREATE_BASE: int
    OPCODE_EXP_BASE: int
    OPCODE_EXP_PER_BYTE: int
    OPCODE_LOG_BASE: int
    OPCODE_LOG_DATA_PER_BYTE: int
    OPCODE_LOG_TOPIC: int
    OPCODE_KECCAK256_BASE: int
    OPCODE_KECCACK256_PER_WORD: int

    # Defined post-Frontier
    OPCODE_SHL: int = 0
    OPCODE_SHR: int = 0
    OPCODE_SAR: int = 0
    OPCODE_RETURNDATACOPY_BASE: int = 0
    OPCODE_BLOBHASH: int = 0
    OPCODE_MCOPY_BASE: int = 0
    OPCODE_CLZ: int = 0

ForkRangeDescriptor

Bases: BaseModel

Fork descriptor parsed from string normally contained in ethereum/tests fillers.

Source code in packages/testing/src/execution_testing/forks/helpers.py
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
class ForkRangeDescriptor(BaseModel):
    """
    Fork descriptor parsed from string normally contained in ethereum/tests
    fillers.
    """

    greater_equal: Type[BaseFork] | None = None
    less_than: Type[BaseFork] | None = None
    model_config = ConfigDict(frozen=True)

    def fork_in_range(self, fork: Type[BaseFork]) -> bool:
        """Return whether the given fork is within range."""
        if self.greater_equal is not None and fork < self.greater_equal:
            return False
        if self.less_than is not None and fork >= self.less_than:
            return False
        return True

    @model_validator(mode="wrap")
    @classmethod
    def validate_fork_range_descriptor(
        cls, v: Any, handler: ValidatorFunctionWrapHandler
    ) -> "ForkRangeDescriptor":
        """
        Validate the fork range descriptor from a string.

        Examples:
          - ">=Osaka" validates to {greater_equal=Osaka, less_than=None}

          - ">=Prague<Osaka" validates to {greater_equal=Prague,
                                           less_than=Osaka}

        """
        if isinstance(v, str):
            # Decompose the string into its parts
            descriptor_string = re.sub(r"\s+", "", v.strip())
            v = {}
            if m := re.search(r">=(\w+)", descriptor_string):
                fork: Type[BaseFork] | None = get_fork_by_name(m.group(1))
                if fork is None:
                    raise Exception(f"Unable to parse fork name: {m.group(1)}")
                v["greater_equal"] = fork
                descriptor_string = re.sub(r">=(\w+)", "", descriptor_string)
            if m := re.search(r"<(\w+)", descriptor_string):
                fork = get_fork_by_name(m.group(1))
                if fork is None:
                    raise Exception(f"Unable to parse fork name: {m.group(1)}")
                v["less_than"] = fork
                descriptor_string = re.sub(r"<(\w+)", "", descriptor_string)
            if descriptor_string:
                raise Exception(
                    "Unable to completely parse fork range descriptor. "
                    + f'Remaining string: "{descriptor_string}"'
                )
        return handler(v)

fork_in_range(fork)

Return whether the given fork is within range.

Source code in packages/testing/src/execution_testing/forks/helpers.py
364
365
366
367
368
369
370
def fork_in_range(self, fork: Type[BaseFork]) -> bool:
    """Return whether the given fork is within range."""
    if self.greater_equal is not None and fork < self.greater_equal:
        return False
    if self.less_than is not None and fork >= self.less_than:
        return False
    return True

validate_fork_range_descriptor(v, handler) classmethod

Validate the fork range descriptor from a string.

Examples:

  • ">=Osaka" validates to {greater_equal=Osaka, less_than=None}

  • ">=Prague

Source code in packages/testing/src/execution_testing/forks/helpers.py
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
@model_validator(mode="wrap")
@classmethod
def validate_fork_range_descriptor(
    cls, v: Any, handler: ValidatorFunctionWrapHandler
) -> "ForkRangeDescriptor":
    """
    Validate the fork range descriptor from a string.

    Examples:
      - ">=Osaka" validates to {greater_equal=Osaka, less_than=None}

      - ">=Prague<Osaka" validates to {greater_equal=Prague,
                                       less_than=Osaka}

    """
    if isinstance(v, str):
        # Decompose the string into its parts
        descriptor_string = re.sub(r"\s+", "", v.strip())
        v = {}
        if m := re.search(r">=(\w+)", descriptor_string):
            fork: Type[BaseFork] | None = get_fork_by_name(m.group(1))
            if fork is None:
                raise Exception(f"Unable to parse fork name: {m.group(1)}")
            v["greater_equal"] = fork
            descriptor_string = re.sub(r">=(\w+)", "", descriptor_string)
        if m := re.search(r"<(\w+)", descriptor_string):
            fork = get_fork_by_name(m.group(1))
            if fork is None:
                raise Exception(f"Unable to parse fork name: {m.group(1)}")
            v["less_than"] = fork
            descriptor_string = re.sub(r"<(\w+)", "", descriptor_string)
        if descriptor_string:
            raise Exception(
                "Unable to completely parse fork range descriptor. "
                + f'Remaining string: "{descriptor_string}"'
            )
    return handler(v)

InvalidForkError

Bases: Exception

Invalid fork error raised when the fork specified is not found or incompatible.

Source code in packages/testing/src/execution_testing/forks/helpers.py
31
32
33
34
35
36
37
38
39
class InvalidForkError(Exception):
    """
    Invalid fork error raised when the fork specified is not found or
    incompatible.
    """

    def __init__(self, message: str) -> None:
        """Initialize the InvalidForkError exception."""
        super().__init__(message)

__init__(message)

Initialize the InvalidForkError exception.

Source code in packages/testing/src/execution_testing/forks/helpers.py
37
38
39
def __init__(self, message: str) -> None:
    """Initialize the InvalidForkError exception."""
    super().__init__(message)

forks_from(fork, deployed_only=True)

Return specified fork and all forks after it.

Source code in packages/testing/src/execution_testing/forks/helpers.py
302
303
304
305
306
307
308
309
310
def forks_from(
    fork: Type[BaseFork], deployed_only: bool = True
) -> List[Type[BaseFork]]:
    """Return specified fork and all forks after it."""
    if deployed_only:
        latest_fork = get_deployed_forks()[-1]
    else:
        latest_fork = get_forks()[-1]
    return forks_from_until(fork, latest_fork)

forks_from_until(fork_from, fork_until)

Return specified fork and all forks after it until and including the second specified fork.

Source code in packages/testing/src/execution_testing/forks/helpers.py
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
def forks_from_until(
    fork_from: Type[BaseFork], fork_until: Type[BaseFork]
) -> List[Type[BaseFork]]:
    """
    Return specified fork and all forks after it until and including the second
    specified fork.
    """
    prev_fork: Type[BaseFork] | None = fork_until

    forks: List[Type[BaseFork]] = []

    while prev_fork is not None and prev_fork != fork_from:
        forks.insert(0, prev_fork)

        prev_fork = prev_fork.parent()

    if prev_fork == BaseFork:
        return []

    forks.insert(0, fork_from)

    return forks

get_closest_fork(fork)

Return None if BaseFork is passed, otherwise return the fork itself.

Source code in packages/testing/src/execution_testing/forks/helpers.py
108
109
110
111
112
def get_closest_fork(fork: Type[BaseFork]) -> Optional[Type[BaseFork]]:
    """Return None if BaseFork is passed, otherwise return the fork itself."""
    if fork is BaseFork:
        return None
    return fork

get_deployed_forks()

Return all fork classes that have been deployed to mainnet.

Chronologically ordered by deployment. BPO (Blob Parameter Only) forks are excluded as they are handled separately.

Source code in packages/testing/src/execution_testing/forks/helpers.py
85
86
87
88
89
90
91
92
93
94
95
96
def get_deployed_forks() -> List[Type[BaseFork]]:
    """
    Return all fork classes that have been deployed to mainnet.

    Chronologically ordered by deployment. BPO (Blob Parameter Only) forks
    are excluded as they are handled separately.
    """
    return [
        fork
        for fork in get_forks()
        if fork.is_deployed() and not fork.ignore() and not fork.bpo_fork()
    ]

get_development_forks()

Return all fork classes not yet deployed and under development.

The list is ordered by their planned deployment date.

Source code in packages/testing/src/execution_testing/forks/helpers.py
 99
100
101
102
103
104
105
def get_development_forks() -> List[Type[BaseFork]]:
    """
    Return all fork classes not yet deployed and under development.

    The list is ordered by their planned deployment date.
    """
    return [fork for fork in get_forks() if not fork.is_deployed()]

get_fork_by_name(fork_name)

Get a fork by name.

Source code in packages/testing/src/execution_testing/forks/helpers.py
346
347
348
349
350
351
def get_fork_by_name(fork_name: str) -> Type[BaseFork] | None:
    """Get a fork by name."""
    for fork in get_forks():
        if fork.name() == fork_name:
            return fork
    return None

get_forks()

Return all fork classes implemented by execution_testing.forks.

Ordered chronologically by deployment.

Source code in packages/testing/src/execution_testing/forks/helpers.py
76
77
78
79
80
81
82
def get_forks() -> List[Type[BaseFork]]:
    """
    Return all fork classes implemented by `execution_testing.forks`.

    Ordered chronologically by deployment.
    """
    return all_forks[:]

get_forks_with_no_descendants(forks)

Get forks with no descendants in the inheritance hierarchy.

Source code in packages/testing/src/execution_testing/forks/helpers.py
169
170
171
172
173
174
175
176
177
178
179
180
181
182
def get_forks_with_no_descendants(
    forks: Set[Type[BaseFork]],
) -> Set[Type[BaseFork]]:
    """Get forks with no descendants in the inheritance hierarchy."""
    resulting_forks: Set[Type[BaseFork]] = set()
    for fork in forks:
        descendants = False
        for next_fork in forks - {fork}:
            if next_fork > fork:
                descendants = True
                break
        if not descendants:
            resulting_forks = resulting_forks | {fork}
    return resulting_forks

get_forks_with_no_parents(forks)

Get forks with no parents in the inheritance hierarchy.

Source code in packages/testing/src/execution_testing/forks/helpers.py
153
154
155
156
157
158
159
160
161
162
163
164
165
166
def get_forks_with_no_parents(
    forks: Set[Type[BaseFork]] | FrozenSet[Type[BaseFork]],
) -> Set[Type[BaseFork]]:
    """Get forks with no parents in the inheritance hierarchy."""
    resulting_forks: Set[Type[BaseFork]] = set()
    for fork in forks:
        parents = False
        for next_fork in forks - {fork}:
            if next_fork < fork:
                parents = True
                break
        if not parents:
            resulting_forks = resulting_forks | {fork}
    return resulting_forks

get_from_until_fork_set(forks, forks_from, forks_until)

Get fork range from forks_from to forks_until.

Source code in packages/testing/src/execution_testing/forks/helpers.py
138
139
140
141
142
143
144
145
146
147
148
149
150
def get_from_until_fork_set(
    forks: Set[Type[BaseFork]] | FrozenSet[Type[BaseFork]],
    forks_from: Set[Type[BaseFork]],
    forks_until: Set[Type[BaseFork]],
) -> Set[Type[BaseFork]]:
    """Get fork range from forks_from to forks_until."""
    resulting_set = set()
    for fork_from in forks_from:
        for fork_until in forks_until:
            for fork in forks:
                if fork <= fork_until and fork >= fork_from:
                    resulting_set.add(fork)
    return resulting_set

get_last_descendants(forks, forks_from)

Get last descendant of a class in the inheritance hierarchy.

Source code in packages/testing/src/execution_testing/forks/helpers.py
185
186
187
188
189
190
191
192
193
194
195
def get_last_descendants(
    forks: Set[Type[BaseFork]], forks_from: Set[Type[BaseFork]]
) -> Set[Type[BaseFork]]:
    """Get last descendant of a class in the inheritance hierarchy."""
    resulting_forks: Set[Type[BaseFork]] = set()
    forks = get_forks_with_no_descendants(forks)
    for fork_from in forks_from:
        for fork in forks:
            if fork >= fork_from:
                resulting_forks = resulting_forks | {fork}
    return resulting_forks

get_relative_fork_markers(fork_identifier, strict_mode=True)

Return a list of marker names for a given fork.

For a base fork (e.g. Shanghai), return [ Shanghai ]. For a transition fork (e.g. ShanghaiToCancunAtTime15k which transitions to Cancun), return [ ShanghaiToCancunAtTime15k, Cancun ].

If strict_mode is set to True, raise an InvalidForkError if the fork is not found, otherwise, simply return the provided (str) fork_identifier (this is required to run consume with forks that are unknown to EEST).

Source code in packages/testing/src/execution_testing/forks/helpers.py
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
def get_relative_fork_markers(
    fork_identifier: Type[BaseFork] | str, strict_mode: bool = True
) -> list[str]:
    """
    Return a list of marker names for a given fork.

    For a base fork (e.g. `Shanghai`), return [ `Shanghai` ]. For a transition
    fork (e.g. `ShanghaiToCancunAtTime15k` which transitions to `Cancun`),
    return [ `ShanghaiToCancunAtTime15k`, `Cancun` ].

    If `strict_mode` is set to `True`, raise an `InvalidForkError` if the fork
    is not found, otherwise, simply return the provided (str) `fork_identifier`
    (this is required to run `consume` with forks that are unknown to EEST).
    """
    all_forks = set(get_forks()) | set(get_transition_forks())
    if isinstance(fork_identifier, str):
        fork_class = None
        for candidate in all_forks:
            if candidate.name() == fork_identifier:
                fork_class = candidate
                break
        if strict_mode and fork_class is None:
            raise InvalidForkError(f"Unknown fork: {fork_identifier}")
        return [fork_identifier]
    else:
        fork_class = fork_identifier

    if issubclass(fork_class, TransitionBaseClass):
        return [fork_class.name(), fork_class.transitions_to().name()]
    else:
        return [fork_class.name()]

get_selected_fork_set(*, single_fork, forks_from, forks_until, transition_forks=True)

Process sets derived from --fork, --until and --from to return an unified fork set.

Source code in packages/testing/src/execution_testing/forks/helpers.py
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
def get_selected_fork_set(
    *,
    single_fork: Set[Type[BaseFork]],
    forks_from: Set[Type[BaseFork]],
    forks_until: Set[Type[BaseFork]],
    transition_forks: bool = True,
) -> Set[Type[BaseFork | TransitionBaseClass]]:
    """
    Process sets derived from `--fork`, `--until` and `--from` to return an
    unified fork set.
    """
    selected_fork_set: Set[Type[BaseFork]] = set()
    if single_fork:
        selected_fork_set |= single_fork
    else:
        if not forks_from:
            forks_from = get_forks_with_no_parents(ALL_FORKS)
        if not forks_until:
            forks_until = get_last_descendants(
                set(get_deployed_forks()), forks_from
            )
        selected_fork_set |= get_from_until_fork_set(
            ALL_FORKS, forks_from, forks_until
        )
        # Transition fork comparison operators resolve to
        # transitions_to(), so an --until transition fork boundary
        # incorrectly includes its target in the normal fork set.
        for fork_until in forks_until:
            if issubclass(fork_until, TransitionBaseClass):
                selected_fork_set.discard(fork_until.transitions_to())
    selected_fork_set_with_transitions: Set[
        Type[BaseFork | TransitionBaseClass]
    ] = set() | selected_fork_set
    if transition_forks:
        for normal_fork in list(selected_fork_set):
            transition_fork_set = transition_fork_to(normal_fork)
            selected_fork_set_with_transitions |= transition_fork_set
        # Explicitly add transition fork boundaries whose target fork
        # was removed above (transition_fork_to won't find them).
        if not single_fork:
            for fork in forks_from | forks_until:
                if issubclass(fork, TransitionBaseClass):
                    selected_fork_set_with_transitions.add(fork)
    return selected_fork_set_with_transitions

get_transition_fork_predecessor(transition_fork)

Return the fork from which the transition fork transitions.

Source code in packages/testing/src/execution_testing/forks/helpers.py
120
121
122
123
124
125
126
def get_transition_fork_predecessor(
    transition_fork: Type[BaseFork | TransitionBaseClass],
) -> Type[BaseFork]:
    """Return the fork from which the transition fork transitions."""
    if not issubclass(transition_fork, TransitionBaseClass):
        raise InvalidForkError(f"{transition_fork} is not a transition fork.")
    return transition_fork.transitions_from()

get_transition_fork_successor(transition_fork)

Return the fork to which the transition fork transitions.

Source code in packages/testing/src/execution_testing/forks/helpers.py
129
130
131
132
133
134
135
def get_transition_fork_successor(
    transition_fork: Type[BaseFork],
) -> Type[BaseFork]:
    """Return the fork to which the transition fork transitions."""
    if not issubclass(transition_fork, TransitionBaseClass):
        raise InvalidForkError(f"{transition_fork} is not a transition fork.")
    return transition_fork.transitions_to()

get_transition_forks()

Return all the transition forks.

Source code in packages/testing/src/execution_testing/forks/helpers.py
115
116
117
def get_transition_forks() -> Set[Type[TransitionBaseClass]]:
    """Return all the transition forks."""
    return set(ALL_TRANSITION_FORKS)

transition_fork_from_to(fork_from, fork_to)

Return transition fork that transitions to and from the specified forks.

Source code in packages/testing/src/execution_testing/forks/helpers.py
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
def transition_fork_from_to(
    fork_from: Type[BaseFork], fork_to: Type[BaseFork]
) -> Type[TransitionBaseClass] | None:
    """
    Return transition fork that transitions to and from the specified forks.
    """
    for transition_fork in get_transition_forks():
        if not issubclass(transition_fork, TransitionBaseClass):
            continue
        if (
            transition_fork.transitions_to() == fork_to
            and transition_fork.transitions_from() == fork_from
        ):
            return transition_fork

    return None

transition_fork_to(fork_to)

Return transition fork that transitions to the specified fork.

Source code in packages/testing/src/execution_testing/forks/helpers.py
262
263
264
265
266
267
268
269
270
271
272
273
274
275
def transition_fork_to(
    fork_to: Type[BaseFork | TransitionBaseClass],
) -> Set[Type[TransitionBaseClass]]:
    """Return transition fork that transitions to the specified fork."""
    selected_forks: Set[Type[TransitionBaseClass]] = set()
    if issubclass(fork_to, TransitionBaseClass):
        return selected_forks
    for transition_fork in get_transition_forks():
        if not issubclass(transition_fork, TransitionBaseClass):
            continue
        if transition_fork.transitions_to() == fork_to:
            selected_forks.add(transition_fork)

    return selected_forks