-
Notifications
You must be signed in to change notification settings - Fork 154
chore(tests|forks): add max blobs per tx limit #1884
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
spencer-tb
wants to merge
9
commits into
main
Choose a base branch
from
eip-7594-max-blobs-per-tx
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
992d223
chore(tests|forks): add max blobs per tx limit.
spencer-tb dec85c8
chore(forks): fix typecheck for `max_blobs_per_tx()`.
spencer-tb 2c6cff5
chore(forks): bug fix - move max per tx to osaka.
spencer-tb dba59be
feat(tests): update eip-4844 spec for blob per tx limit.
spencer-tb d686e68
feat(tests): fixes for eip-4844.
spencer-tb 1fcfbe0
chore(tests): more tweaks for eip-4844.
spencer-tb b7f3dd0
chore(tests): fix genesis dummy block.
spencer-tb 1a23b2d
feat(tests): add specific max blob per tx limit tests.
spencer-tb 31b8ffc
chore(tests): fix coverage for 4844 changes.
spencer-tb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
import pytest | ||
|
||
from ethereum_test_forks import Fork | ||
from ethereum_test_forks import Fork, Osaka | ||
from ethereum_test_tools import Alloc, Block, Environment, Hash, Transaction, add_kzg_version | ||
|
||
from .spec import Spec | ||
|
@@ -26,6 +26,12 @@ def max_blobs_per_block(fork: Fork) -> int: | |
return fork.max_blobs_per_block() | ||
|
||
|
||
@pytest.fixture | ||
def max_blobs_per_tx(fork: Fork) -> int: | ||
"""Return max number of blobs per transaction.""" | ||
return fork.max_blobs_per_tx() | ||
|
||
|
||
@pytest.fixture | ||
def blob_gas_per_blob(fork: Fork) -> int: | ||
"""Return default blob gas cost per blob.""" | ||
|
@@ -269,6 +275,10 @@ def non_zero_blob_gas_used_genesis_block( | |
genesis value, expecting an appropriate drop to the intermediate block. | ||
Similarly, we must add parent_blobs to the intermediate block within | ||
a blob tx such that an equivalent blobGasUsed field is wrote. | ||
|
||
For forks >= Osaka where the MAX_BLOBS_PER_TX is introduced, we | ||
split the blobs across multiple transactions to respect the | ||
MAX_BLOBS_PER_TX limit. | ||
""" | ||
if parent_blobs == 0: | ||
return None | ||
|
@@ -287,30 +297,38 @@ def non_zero_blob_gas_used_genesis_block( | |
) | ||
|
||
sender = pre.fund_eoa(10**27) | ||
|
||
# Address that contains no code, nor balance and is not a contract. | ||
empty_account_destination = pre.fund_eoa(0) | ||
|
||
blob_gas_price_calculator = fork.blob_gas_price_calculator(block_number=1) | ||
|
||
return Block( | ||
txs=[ | ||
Transaction( | ||
ty=Spec.BLOB_TX_TYPE, | ||
sender=sender, | ||
to=empty_account_destination, | ||
value=1, | ||
gas_limit=21_000, | ||
max_fee_per_gas=tx_max_fee_per_gas, | ||
max_priority_fee_per_gas=0, | ||
max_fee_per_blob_gas=blob_gas_price_calculator( | ||
excess_blob_gas=parent_excess_blob_gas | ||
), | ||
access_list=[], | ||
blob_versioned_hashes=add_kzg_version( | ||
[Hash(x) for x in range(parent_blobs)], | ||
Spec.BLOB_COMMITMENT_VERSION_KZG, | ||
), | ||
) | ||
] | ||
) | ||
# Split blobs into chunks for forks >= Osaka only to respect MAX_BLOBS_PER_TX limits. | ||
# This allows us to keep the creation of single transactions for Cancun/Prague where the | ||
# MAX_BLOBS_PER_TX is not enforced, hitting coverage for block level blob gas validation | ||
# when parent_blobs > MAX_BLOBS_PER_BLOCK. | ||
max_blobs_per_tx = fork.max_blobs_per_tx() if fork >= Osaka else parent_blobs | ||
blob_chunks = [ | ||
range(i, min(i + max_blobs_per_tx, parent_blobs)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice. |
||
for i in range(0, parent_blobs, max_blobs_per_tx) | ||
] | ||
|
||
def create_blob_transaction(blob_range): | ||
return Transaction( | ||
ty=Spec.BLOB_TX_TYPE, | ||
sender=sender, | ||
to=empty_account_destination, | ||
value=1, | ||
gas_limit=21_000, | ||
max_fee_per_gas=tx_max_fee_per_gas, | ||
max_priority_fee_per_gas=0, | ||
max_fee_per_blob_gas=blob_gas_price_calculator( | ||
excess_blob_gas=parent_excess_blob_gas, | ||
), | ||
access_list=[], | ||
blob_versioned_hashes=add_kzg_version( | ||
[Hash(x) for x in blob_range], | ||
Spec.BLOB_COMMITMENT_VERSION_KZG, | ||
), | ||
) | ||
|
||
txs = [create_blob_transaction(chunk) for chunk in blob_chunks] | ||
|
||
return Block(txs=txs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could check whether max per block != max per tx instead of checking explicitly for Osaka.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think I had this initially but changed it to this to see if it would fix the coverage! I will revert back.