Test Blob Txs¶
Documentation for tests/cancun/eip4844_blobs/test_blob_txs.py
.
Generate fixtures for these test cases for Cancun with:
Cancun only:
fill -v tests/cancun/eip4844_blobs/test_blob_txs.py --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version
fill -v tests/cancun/eip4844_blobs/test_blob_txs.py --until=Cancun --evm-bin=/path/to/evm-tool-dev-version
abstract: Tests blob type transactions for EIP-4844: Shard Blob Transactions
Test blob type transactions for [EIP-4844: Shard Blob Transactions](https://eips.ethereum.org/EIPS/eip-4844).
note: Adding a new test
Add a function that is named `test_<test_name>` and takes at least the following arguments:
- blockchain_test
- pre
- env
- blocks
All other `pytest.fixture` fixtures can be parametrized to generate new combinations and test cases.
test_valid_blob_tx_combinations(blockchain_test, pre, env, blocks)
¶
Test all valid blob combinations in a single block, assuming a given value of
MAX_BLOBS_PER_BLOCK
.
This assumes a block can include from 1 and up to MAX_BLOBS_PER_BLOCK
transactions where all
transactions contain at least 1 blob, and the sum of all blobs in a block is at
most MAX_BLOBS_PER_BLOCK
.
This test is parametrized with all valid blob transaction combinations for a given block, and
therefore if value of MAX_BLOBS_PER_BLOCK
changes, this test is automatically updated.
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_invalid_tx_max_fee_per_blob_gas(blockchain_test, pre, env, blocks, parent_blobs, non_zero_blob_gas_used_genesis_block)
¶
Reject blocks with invalid blob txs due to:
- tx max_fee_per_blob_gas is barely not enough
- tx max_fee_per_blob_gas is zero
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_invalid_normal_gas(blockchain_test, pre, env, blocks)
¶
Reject blocks with invalid blob txs due to:
- Sufficient max fee per blob gas, but insufficient max fee per gas
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_invalid_block_blob_count(blockchain_test, pre, env, blocks)
¶
Test all invalid blob combinations in a single block, where the sum of all blobs in a block is
at MAX_BLOBS_PER_BLOCK + 1
.
This test is parametrized with all blob transaction combinations exceeding
MAX_BLOBS_PER_BLOCK
by one for a given block, and
therefore if value of MAX_BLOBS_PER_BLOCK
changes, this test is automatically updated.
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_insufficient_balance_blob_tx(blockchain_test, pre, env, blocks)
¶
Reject blocks where user cannot afford the blob gas specified (but max_fee_per_gas would be enough for current block), including:
- Transactions with and without priority fee
- Transactions with and without value
- Transactions with and without calldata
- Transactions with max fee per blob gas lower or higher than the priority fee
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_insufficient_balance_blob_tx_combinations(blockchain_test, pre, env, blocks)
¶
Reject all valid blob transaction combinations in a block, but block is invalid due to:
- The amount of blobs is correct but the user cannot afford the transaction total cost
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_invalid_tx_blob_count(blockchain_test, pre, env, blocks)
¶
Reject blocks that include blob transactions with invalid blob counts:
blob count == 0
in type 3 transactionblob count > MAX_BLOBS_PER_BLOCK
in type 3 transaction
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_invalid_blob_hash_versioning(blockchain_test, pre, env, blocks)
¶
Reject blocks that include blob transactions with invalid blob hash version, including:
- Single blob transaction with single blob with invalid version
- Single blob transaction with multiple blobs all with invalid version
- Single blob transaction with multiple blobs either with invalid version
- Multiple blob transactions with single blob all with invalid version
- Multiple blob transactions with multiple blobs all with invalid version
- Multiple blob transactions with multiple blobs only one with invalid version
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_invalid_blob_tx_contract_creation(blockchain_test, pre, env, blocks)
¶
Reject blocks that include blob transactions that have nil to value (contract creating).
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 |
|
test_blob_tx_attribute_opcodes(blockchain_test, pre, opcode, env, blocks, destination_account)
¶
Test opcodes that read transaction attributes work properly for blob type transactions:
- ORIGIN
- CALLER
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_blob_tx_attribute_value_opcode(blockchain_test, pre, opcode, env, blocks, tx_value, destination_account)
¶
Test the VALUE opcode with different blob type transaction value amounts.
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_blob_tx_attribute_calldata_opcodes(blockchain_test, pre, opcode, env, blocks, destination_account)
¶
Test calldata related opcodes to verify their behavior is not affected by blobs:
- CALLDATALOAD
- CALLDATASIZE
- CALLDATACOPY
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_blob_tx_attribute_gasprice_opcode(blockchain_test, pre, opcode, env, blocks, destination_account)
¶
Test GASPRICE opcode to sanity check that the blob gas fee does not affect its calculation:
- No priority fee
- Priority fee below data fee
- Priority fee above data fee
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|
test_blob_type_tx_pre_fork(blockchain_test, pre, blocks)
¶
Reject blocks with blob type transactions before Cancun fork.
Blocks sent by NewPayloadV2 (Shanghai) that contain blob type transactions, furthermore blobs field within NewPayloadV2 method must be computed as INVALID, due to an invalid block hash.
Source code in tests/cancun/eip4844_blobs/test_blob_txs.py
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 |
|