Test Excess Blob Gas¶
Documentation for tests/cancun/eip4844_blobs/test_excess_blob_gas.py
.
Generate fixtures for these test cases for Cancun with:
Cancun only:
fill -v tests/cancun/eip4844_blobs/test_excess_blob_gas.py --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version
fill -v tests/cancun/eip4844_blobs/test_excess_blob_gas.py --until=Cancun --evm-bin=/path/to/evm-tool-dev-version
abstract: Tests excessBlobGas
and blobGasUsed
block fields for EIP-4844: Shard Blob Transactions
Test `excessBlobGas` and `blobGasUsed` block fields 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
- env
- pre
- blocks
- post
- correct_excess_blob_gas
The following arguments *need* to be parametrized or the test will not be generated:
- new_blobs
All other `pytest.fixture` fixtures can be parametrized to generate new combinations and test
cases.
test_correct_excess_blob_gas_calculation(blockchain_test, env, pre, blocks, post, correct_excess_blob_gas)
¶
Test calculation of the excessBlobGas
increase/decrease across
multiple blocks with and without blobs:
- With parent block containing
[0, MAX_BLOBS_PER_BLOCK]
blobs - With parent block containing
[0, TARGET_BLOBS_PER_BLOCK]
equivalent value of excess blob gas
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|
test_correct_increasing_blob_gas_costs(blockchain_test, env, pre, blocks, post, correct_excess_blob_gas)
¶
Test calculation of the excessBlobGas
and blob gas tx costs at
value points where the cost increases to interesting amounts:
- At the first blob gas cost increase (1 to 2)
- At total transaction data cost increase to
> 2^32
- At blob gas wei cost increase to
> 2^32
- At total transaction data cost increase to
> 2^64
- At blob gas wei cost increase to
> 2^64
- At blob gas wei cost increase of around current total Ether supply
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|
test_correct_decreasing_blob_gas_costs(blockchain_test, env, pre, blocks, post, correct_excess_blob_gas)
¶
Test calculation of the excessBlobGas
and blob gas tx costs at
value points where the cost decreases to interesting amounts.
See test_correct_increasing_blob_gas_costs.
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|
test_invalid_zero_excess_blob_gas_in_header(blockchain_test, env, pre, blocks, correct_excess_blob_gas, header_excess_blob_gas)
¶
Test rejection of blocks where the excessBlobGas
in the header drops to
zero in a block with or without data blobs, but the excess blobs in the parent are
greater than target.
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|
test_invalid_blob_gas_used_in_header(blockchain_test, env, pre, blocks, new_blobs, header_blob_gas_used)
¶
Test rejection of blocks where the blobGasUsed
in the header is invalid:
blobGasUsed
is not equal to the number of data blobs in the blockblobGasUsed
is the max uint64 value
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|
test_invalid_excess_blob_gas_above_target_change(blockchain_test, env, pre, blocks, correct_excess_blob_gas, header_excess_blob_gas)
¶
Test rejection of blocks where the excessBlobGas
- decreases more than
TARGET_BLOB_GAS_PER_BLOCK
in a single block with zero blobs - increases more than
TARGET_BLOB_GAS_PER_BLOCK
in a single block with max blobs
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|
test_invalid_static_excess_blob_gas(blockchain_test, env, pre, blocks, correct_excess_blob_gas, parent_excess_blob_gas)
¶
Test rejection of blocks where the excessBlobGas
remains unchanged
but the parent blobs included are not TARGET_BLOBS_PER_BLOCK
.
Test is parametrized to MAX_BLOBS_PER_BLOCK
and TARGET_BLOBS_PER_BLOCK
.
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|
test_invalid_excess_blob_gas_target_blobs_increase_from_zero(blockchain_test, env, pre, blocks, correct_excess_blob_gas, header_excess_blob_gas)
¶
Test rejection of blocks where the excessBlobGas
increases from zero,
even when the included blobs are on or below target.
Test is parametrized according to [0, TARGET_BLOBS_PER_BLOCK
new blobs.
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|
test_invalid_static_excess_blob_gas_from_zero_on_blobs_above_target(blockchain_test, env, pre, blocks, correct_excess_blob_gas, header_excess_blob_gas)
¶
Test rejection of blocks where the excessBlobGas
does not increase from
zero, even when the included blobs is above target.
Test is parametrized to [TARGET_BLOBS_PER_BLOCK+1, MAX_BLOBS_PER_BLOCK]
new blobs.
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.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 639 640 641 642 643 644 645 |
|
test_invalid_excess_blob_gas_change(blockchain_test, env, pre, blocks, correct_excess_blob_gas, header_excess_blob_gas)
¶
Test rejection of blocks where the excessBlobGas
changes to an invalid
value.
Given a parent block containing [0, MAX_BLOBS_PER_BLOCK]
blobs, test an invalid
excessBlobGas
value by changing it by [-TARGET_BLOBS_PER_BLOCK, TARGET_BLOBS_PER_BLOCK]
from the correct value.
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|
test_invalid_negative_excess_blob_gas(blockchain_test, env, pre, blocks, correct_excess_blob_gas, header_excess_blob_gas)
¶
Test rejection of blocks where the excessBlobGas
changes to the two's
complement equivalent of the negative value after subtracting target blobs.
Reasoning is that the excessBlobGas
is a uint64
, so it cannot be negative, and
we test for a potential underflow here.
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|
test_invalid_non_multiple_excess_blob_gas(blockchain_test, env, pre, blocks, correct_excess_blob_gas, header_excess_blob_gas)
¶
Test rejection of blocks where the excessBlobGas
changes to a value that
is not a multiple of Spec.GAS_PER_BLOB`:
- Parent block contains
TARGET_BLOBS_PER_BLOCK + 1
blobs, butexcessBlobGas
is off by ±1 - Parent block contains
TARGET_BLOBS_PER_BLOCK - 1
blobs, butexcessBlobGas
is off by ±1
Source code in tests/cancun/eip4844_blobs/test_excess_blob_gas.py
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 |
|