Test Excess Data Gas¶
Documentation for tests/cancun/eip4844_blobs/test_excess_data_gas.py.
Generate fixtures for these test cases for Cancun with:
Cancun only:
fill -v tests/cancun/eip4844_blobs/test_excess_data_gas.py --fork=Cancun --evm-bin=/path/to/evm-tool-dev-version
fill -v tests/cancun/eip4844_blobs/test_excess_data_gas.py --until=Cancun --evm-bin=/path/to/evm-tool-dev-version
Tests excessDataGas and dataGasUsed block fields for EIP-4844: Shard Blob Transactions
Test excessDataGas and dataGasUsed block fields for EIP-4844: Shard Blob Transactions.
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_data_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.
Spec
dataclass
¶
Parameters from the EIP-4844 specifications as defined at https://eips.ethereum.org/EIPS/eip-4844#parameters
If the parameter is not currently used within the tests, it is commented out.
Source code in tests/cancun/eip4844_blobs/spec.py
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 | |
SpecHelpers
dataclass
¶
Define parameters and helper functions that are tightly coupled to the 4844 spec but not strictly part of it.
Source code in tests/cancun/eip4844_blobs/spec.py
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 | |
test_correct_excess_data_gas_calculation(blockchain_test, env, pre, blocks, post, correct_excess_data_gas)
¶
Test calculation of the excessDataGas 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 data gas
Source code in tests/cancun/eip4844_blobs/test_excess_data_gas.py
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 | |
test_correct_increasing_data_gas_costs(blockchain_test, env, pre, blocks, post, correct_excess_data_gas)
¶
Test calculation of the excessDataGas and data gas tx costs at
value points where the cost increases to interesting amounts:
- At the first data gas cost increase (1 to 2)
- At total transaction data cost increase to
> 2^32 - At data gas wei cost increase to
> 2^32 - At total transaction data cost increase to
> 2^64 - At data gas wei cost increase to
> 2^64 - At data gas wei cost increase of around current total Ether supply
Source code in tests/cancun/eip4844_blobs/test_excess_data_gas.py
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 | |
test_correct_decreasing_data_gas_costs(blockchain_test, env, pre, blocks, post, correct_excess_data_gas)
¶
Test calculation of the excessDataGas and data gas tx costs at
value points where the cost decreases to interesting amounts.
See test_correct_increasing_data_gas_costs.
Source code in tests/cancun/eip4844_blobs/test_excess_data_gas.py
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 | |
test_invalid_zero_excess_data_gas_in_header(blockchain_test, env, pre, blocks, correct_excess_data_gas, header_excess_data_gas)
¶
Test rejection of blocks where the excessDataGas 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_data_gas.py
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 | |
test_invalid_data_gas_used_in_header(blockchain_test, env, pre, blocks, new_blobs, header_data_gas_used)
¶
Test rejection of blocks where the dataGasUsed in the header is invalid:
dataGasUsedis not equal to the number of data blobs in the blockdataGasUsedis the max uint64 value
Source code in tests/cancun/eip4844_blobs/test_excess_data_gas.py
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 | |
test_invalid_excess_data_gas_above_target_change(blockchain_test, env, pre, blocks, correct_excess_data_gas, header_excess_data_gas)
¶
Test rejection of blocks where the excessDataGas
- decreases more than
TARGET_DATA_GAS_PER_BLOCKin a single block with zero blobs - increases more than
TARGET_DATA_GAS_PER_BLOCKin a single block with max blobs
Source code in tests/cancun/eip4844_blobs/test_excess_data_gas.py
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 | |
test_invalid_static_excess_data_gas(blockchain_test, env, pre, blocks, correct_excess_data_gas, parent_excess_data_gas)
¶
Test rejection of blocks where the excessDataGas 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_data_gas.py
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 | |
test_invalid_excess_data_gas_target_blobs_increase_from_zero(blockchain_test, env, pre, blocks, correct_excess_data_gas, header_excess_data_gas)
¶
Test rejection of blocks where the excessDataGas 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_data_gas.py
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 | |
test_invalid_static_excess_data_gas_from_zero_on_blobs_above_target(blockchain_test, env, pre, blocks, correct_excess_data_gas, header_excess_data_gas)
¶
Test rejection of blocks where the excessDataGas 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_data_gas.py
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 | |
test_invalid_excess_data_gas_change(blockchain_test, env, pre, blocks, correct_excess_data_gas, header_excess_data_gas)
¶
Test rejection of blocks where the excessDataGas changes to an invalid
value.
Given a parent block containing [0, MAX_BLOBS_PER_BLOCK] blobs, test an invalid
excessDataGas 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_data_gas.py
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 | |
test_invalid_negative_excess_data_gas(blockchain_test, env, pre, blocks, correct_excess_data_gas, header_excess_data_gas)
¶
Test rejection of blocks where the excessDataGas changes to the two's
complement equivalent of the negative value after subtracting target blobs.
Reasoning is that the excessDataGas 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_data_gas.py
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 | |
test_invalid_non_multiple_excess_data_gas(blockchain_test, env, pre, blocks, correct_excess_data_gas, header_excess_data_gas)
¶
Test rejection of blocks where the excessDataGas changes to a value that
is not a multiple of Spec.DATA_GAS_PER_BLOB`:
- Parent block contains
TARGET_BLOBS_PER_BLOCK + 1blobs, butexcessDataGasis off by ±1 - Parent block contains
TARGET_BLOBS_PER_BLOCK - 1blobs, butexcessDataGasis off by ±1
Source code in tests/cancun/eip4844_blobs/test_excess_data_gas.py
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 | |