Skip to content

Commit c4bb35b

Browse files
committed
conversion: generalize non-partial and add empty code dimension
Signed-off-by: Ignacio Hagopian <[email protected]>
1 parent ddc9209 commit c4bb35b

File tree

1 file changed

+46
-25
lines changed

1 file changed

+46
-25
lines changed

tests/verkle/eip7748/accounts.py

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import pytest
99
import math
10+
from typing import Optional
1011

1112
from ethereum_test_tools import (
1213
Account,
@@ -97,50 +98,70 @@ def test_non_partial(
9798

9899
@pytest.mark.valid_from("EIP6800Transition")
99100
@pytest.mark.parametrize(
100-
"account_configs",
101+
"storage_slots_overlow",
102+
[
103+
2,
104+
1,
105+
0,
106+
],
107+
ids=[
108+
"Two storage slots overflowed to next block",
109+
"One storage slot overflowed to next block",
110+
"Storage slots fit in one block",
111+
],
112+
)
113+
@pytest.mark.parametrize(
114+
"account_prefix",
101115
[
102-
# No prefix
103-
[AccountConfig(31 * 2 + 1, stride + 2)],
104-
[AccountConfig(31 * 2 + 1, stride + 1)],
105-
[AccountConfig(31 + 2 + 1, stride)],
106-
# EOA prefix
107-
[AccountConfig(0, 0), AccountConfig(42, -1 + stride + 2)],
108-
[AccountConfig(0, 0), AccountConfig(42, -1 + stride + 1)],
109-
[AccountConfig(0, 0), AccountConfig(42, -1 + stride)],
110-
# Contract prefix
111-
[AccountConfig(10, 1), AccountConfig(42, -3 + stride + 2)],
112-
[AccountConfig(10, 1), AccountConfig(42, -3 + stride + 1)],
113-
[AccountConfig(10, 1), AccountConfig(42, -3 + stride)],
116+
None,
117+
AccountConfig(0, 0),
118+
AccountConfig(10, 1),
114119
],
115120
ids=[
116-
"No prefix & boundary at two storage slots before finishing storage trie",
117-
"No prefix & boundary at one storage slot before finishing storage trie",
118-
"No prefix & boundary matching exactly the end of the storage trie",
119-
"EOA prefix & boundary at two storage slots before finishing storage trie",
120-
"EOA prefix & boundary at one storage slot before finishing storage trie",
121-
"EOA prefix & boundary matching exactly the end of the storage trie",
122-
"Contract prefix & boundary at two storage slots before finishing storage trie",
123-
"Contract prefix & boundary at one storage slot before finishing storage trie",
124-
"Contract prefix & boundary matching exactly the end of the storage trie",
121+
"No prefix",
122+
"EOA prefix",
123+
"Contract prefix",
125124
],
126125
)
126+
@pytest.mark.parametrize(
127+
"empty_code",
128+
[True, False],
129+
)
127130
@pytest.mark.parametrize(
128131
"fill_first_block",
129-
[False, True],
132+
[True, False],
130133
)
131134
@pytest.mark.parametrize(
132135
"fill_last_block",
133-
[False, True],
136+
[True, False],
134137
)
135138
def test_partial(
136139
blockchain_test: BlockchainTestFiller,
137-
account_configs: list[AccountConfig],
140+
storage_slots_overlow: int,
141+
account_prefix: Optional[AccountConfig],
142+
empty_code: bool,
138143
fill_first_block: bool,
139144
fill_last_block: bool,
140145
):
141146
"""
142147
Test partial account conversions.
143148
"""
149+
conversion_unit_offset = 0
150+
account_configs = []
151+
if account_prefix is not None:
152+
conversion_unit_offset += 1 # Account basic data
153+
conversion_unit_offset += math.ceil(account_prefix.code_length / 31) # Code-chunks
154+
conversion_unit_offset += account_prefix.storage_slots_count
155+
account_configs.append(account_prefix)
156+
157+
code_length = 0 if empty_code else 31
158+
# For the `stride` quota in this block, we already used `conversion_unit_offset` units from the accounts prefixes.
159+
# For the remaining quota (i.e., `stride-conversion_unit_offset`), we should configure the contract having
160+
# `(stride - conversion_unit_offset)+storage_slots_overlow` so we can overflow the desired storage slots to the
161+
# next block.
162+
num_storage_slots = stride - conversion_unit_offset + storage_slots_overlow
163+
account_configs.append(AccountConfig(code_length, num_storage_slots))
164+
144165
_generic_conversion(blockchain_test, account_configs, fill_first_block, fill_last_block)
145166

146167

0 commit comments

Comments
 (0)