Skip to content

Commit f4a253a

Browse files
spencer-tbmarioevz
authored andcommitted
tests: update for bug in EELS.
1 parent 58de977 commit f4a253a

File tree

3 files changed

+69
-153
lines changed

3 files changed

+69
-153
lines changed

tests/prague/eip7742_uncouple_blob_count/test_invalid_cancun_blob_txs.py

Lines changed: 0 additions & 111 deletions
This file was deleted.

tests/prague/eip7742_uncouple_blob_count/test_uncoupled_blob_txs.py

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,19 @@
33
Tests uncoupled blob txs for [EIP-7742: Uncouple blob count between CL and EL](https://eips.ethereum.org/EIPS/eip-7742)
44
""" # noqa: E501
55

6+
import itertools
7+
from typing import List, Tuple
8+
69
import pytest
710

8-
from ethereum_test_tools import Alloc, Environment, StateTestFiller, Transaction
11+
from ethereum_test_tools import (
12+
Alloc,
13+
Block,
14+
BlockchainTestFiller,
15+
Environment,
16+
StateTestFiller,
17+
Transaction,
18+
)
919

1020
from .spec import Spec, ref_spec_7742
1121

@@ -15,17 +25,21 @@
1525

1626
@pytest.mark.parametrize(
1727
"blobs_per_tx",
18-
[(0,)],
28+
[
29+
(Spec.CANCUN_MAX_BLOBS_PER_BLOCK + 1,),
30+
(Spec.CANCUN_MAX_BLOBS_PER_BLOCK + 2,),
31+
(Spec.CANCUN_MAX_BLOBS_PER_BLOCK + 3,),
32+
],
1933
)
2034
@pytest.mark.valid_from("Prague")
21-
def test_zero_blobs_in_blob_tx(
35+
def test_blobs_above_cancun_max(
2236
state_test: StateTestFiller,
2337
pre: Alloc,
2438
state_env: Environment,
2539
txs: list[Transaction],
2640
):
2741
"""
28-
Test that a blob transaction with zero blobs is accepted in Prague (EIP-7742).
42+
Test that transactions with blob counts above the Cancun maximum are accepted in Prague.
2943
"""
3044
state_test(
3145
pre=pre,
@@ -37,21 +51,17 @@ def test_zero_blobs_in_blob_tx(
3751

3852
@pytest.mark.parametrize(
3953
"blobs_per_tx",
40-
[
41-
(Spec.CANCUN_MAX_BLOBS_PER_BLOCK + 1,),
42-
(Spec.CANCUN_MAX_BLOBS_PER_BLOCK + 2,),
43-
(Spec.CANCUN_MAX_BLOBS_PER_BLOCK + 3,),
44-
],
54+
[(i,) for i in range(64, 1024, 64)],
4555
)
4656
@pytest.mark.valid_from("Prague")
47-
def test_blobs_above_cancun_max(
57+
def test_large_number_of_blobs_in_tx(
4858
state_test: StateTestFiller,
4959
pre: Alloc,
5060
state_env: Environment,
5161
txs: list[Transaction],
5262
):
5363
"""
54-
Test that transactions with blob counts above the Cancun maximum are accepted in Prague.
64+
Test transactions with a large number of blobs (64 to 1024 blobs).
5565
"""
5666
state_test(
5767
pre=pre,
@@ -61,23 +71,52 @@ def test_blobs_above_cancun_max(
6171
)
6272

6373

74+
def invalid_cancun_blob_combinations() -> List[Tuple[int, ...]]:
75+
"""
76+
Returns all possible invalid Cancun blob tx combinations for a given block that use up to
77+
`CANCUN_MAX_BLOBS_PER_BLOCK+1` blobs. These combinations are valid from Prague.
78+
"""
79+
all = [
80+
seq
81+
for i in range(
82+
Spec.CANCUN_MAX_BLOBS_PER_BLOCK + 1, 0, -1
83+
) # We can have from 1 to at most MAX_BLOBS_PER_BLOCK blobs per block
84+
for seq in itertools.combinations_with_replacement(
85+
range(1, Spec.CANCUN_MAX_BLOBS_PER_BLOCK + 2), i
86+
) # We iterate through all possible combinations
87+
if sum(seq) == Spec.CANCUN_MAX_BLOBS_PER_BLOCK + 1
88+
]
89+
# We also add the reversed version of each combination, only if it's not
90+
# already in the list. E.g. (4, 1) is added from (1, 4) but not
91+
# (1, 1, 1, 1, 1) because its reversed version is identical.
92+
all += [tuple(reversed(x)) for x in all if tuple(reversed(x)) not in all]
93+
return all
94+
95+
6496
@pytest.mark.parametrize(
6597
"blobs_per_tx",
66-
[(i,) for i in range(64, 1024, 64)],
98+
invalid_cancun_blob_combinations(),
6799
)
68100
@pytest.mark.valid_from("Prague")
69-
def test_large_number_of_blobs_in_tx(
70-
state_test: StateTestFiller,
101+
def test_invalid_cancun_block_blob_count(
102+
blockchain_test: BlockchainTestFiller,
71103
pre: Alloc,
72-
state_env: Environment,
73-
txs: list[Transaction],
104+
env: Environment,
105+
block: Block,
74106
):
75107
"""
76-
Test transactions with a large number of blobs (64 to 1024 blobs).
108+
Tests all invalid blob combinations for the Cancun fork in a single block,
109+
where the sum of all blobs in a block is `CANCUN_MAX_BLOBS_PER_BLOCK + 1`.
110+
111+
This is a copy of the invalid test from:
112+
`tests/cancun/eip4844_blobs/test_blob_txs.py:test_invalid_block_blob_count`.
113+
114+
In Cancun, these blocks are invalid but in Prague they are valid.
77115
"""
78-
state_test(
116+
blockchain_test(
79117
pre=pre,
80118
post={},
81-
tx=txs[0],
82-
env=state_env,
119+
blocks=[block],
120+
genesis_environment=env,
121+
header_verify=block.header_verify,
83122
)

tests/prague/eip7742_uncouple_blob_count/test_uncoupled_blobs_multi_block.py

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -136,42 +136,30 @@ def test_multiple_blocks_varied_blobs(
136136
@pytest.mark.parametrize(
137137
"blob_counts_per_block, tx_counts_per_block",
138138
[
139-
# Incremental 1: 0 to 64 blobs, 1 tx per block, 65 blocks
139+
# Incremental: 1 to 64 blobs, 1 tx per block, 64 blocks
140140
(
141-
[i for i in range(65)],
142-
[1] * 65,
141+
[max(1, i) for i in range(64)],
142+
[1] * 64,
143143
),
144-
# Incremental 2: 0 to 256 blobs, 10 txs per block, 26 blocks
144+
# Decremental: 64 to 1 blobs, 1 tx per block, 65 blocks
145145
(
146-
[i * 10 for i in range(26)],
147-
[10] * 26,
146+
[max(1, i) for i in reversed(range(64))],
147+
[1] * 64,
148148
),
149-
# Decremental 1: 64 to 0 blobs, 1 tx per block, 65 blocks
149+
# Incremental then decremental: 1 to 32 to 1 blobs, 1 tx per block, 66 blocks
150150
(
151-
[i for i in reversed(range(65))],
152-
[1] * 65,
153-
),
154-
# Decremental 2: 256 to 0 blobs, 10 txs per block, 26 blocks
155-
(
156-
[i * 10 for i in reversed(range(26))],
157-
[10] * 26,
158-
),
159-
# Incremental then decremental 1: 0 to 32 to 0 blobs, 1 tx per block, 66 blocks
160-
(
161-
[i for i in range(33)] + [i for i in reversed(range(33))],
151+
[max(1, i) for i in range(33)] + [max(1, i) for i in reversed(range(33))],
162152
[1] * 66,
163153
),
164-
# Decremental then incremental 1: 32 to 0 to 32 blobs, 1 tx per block, 66 blocks
154+
# Decremental then incremental: 32 to 1 to 32 blobs, 1 tx per block, 66 blocks
165155
(
166-
[i for i in reversed(range(33))] + [i for i in range(33)],
156+
[max(1, i) for i in reversed(range(33))] + [max(1, i) for i in range(33)],
167157
[1] * 66,
168158
),
169159
],
170160
ids=[
171161
"incremental_1_tx",
172-
"incremental_10_txs",
173162
"decremental_1_tx",
174-
"decremental_10_txs",
175163
"incremental_then_decremental",
176164
"decremental_then_incremental",
177165
],

0 commit comments

Comments
 (0)