Skip to content

Commit 03e0c33

Browse files
fselmomarioevz
authored andcommitted
fix(tests): fix withdrawals test setup while filling
1 parent 8b2adfb commit 03e0c33

3 files changed

Lines changed: 25 additions & 15 deletions

File tree

tests/prague/eip7002_el_triggerable_withdrawals/conftest.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
from .helpers import (
1616
WithdrawalRequest,
17-
WithdrawalRequestContract,
1817
WithdrawalRequestInteractionBase,
1918
)
2019
from .spec import Spec
@@ -107,15 +106,6 @@ def blocks(
107106
block_number=len(blocks) + 1,
108107
timestamp=timestamp,
109108
)
110-
if block_fork.is_eip_enabled(8037):
111-
gas_costs = block_fork.gas_costs()
112-
for r in block_requests:
113-
if isinstance(r, WithdrawalRequestContract):
114-
# Each withdrawal request writes 3 new storage slots
115-
# in the system contract queue (source, pubkey, amount).
116-
r.tx_gas_limit += (
117-
len(r.requests) * 3 * gas_costs.STORAGE_SET
118-
)
119109
header_verify: Header | None = None
120110
if block_fork.header_requests_required():
121111
header_verify = Header(

tests/prague/eip7002_el_triggerable_withdrawals/helpers.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,12 @@ def valid_requests(
146146
class WithdrawalRequestContract(WithdrawalRequestInteractionBase):
147147
"""Class used to describe a withdrawal originated from a contract."""
148148

149-
tx_gas_limit: int = 1_000_000
150-
"""Gas limit for the transaction."""
149+
tx_gas_limit: int = 3_000_000
150+
"""
151+
Gas limit for the transaction. Sized to comfortably cover
152+
`MAX_WITHDRAWAL_REQUESTS_PER_BLOCK` zero-to-nonzero state-set
153+
charges per tx under EIP-8037 plus regular dispatch overhead.
154+
"""
151155

152156
contract_balance: int = 1_000_000_000_000_000_000
153157
"""
@@ -166,6 +170,13 @@ class WithdrawalRequestContract(WithdrawalRequestInteractionBase):
166170
"""Frame depth of the pre-deploy contract when it executes the call."""
167171
extra_code: Bytecode = field(default_factory=Bytecode)
168172
"""Extra code to be added to the contract code."""
173+
fund_state_reservoir: bool = False
174+
"""
175+
When True (and EIP-8037 is active), pad `tx_gas_limit` by exactly the
176+
per-request state-set work so the excess funds the EIP-8037 reservoir.
177+
Use only when `tx_gas_limit` is held at the cap (reservoir would
178+
otherwise be empty) and state work must not drain the regular pool.
179+
"""
169180

170181
@property
171182
def contract_code(self) -> Bytecode:
@@ -196,11 +207,14 @@ def transactions(self, fork: Fork | None = None) -> List[Transaction]:
196207
"""Return a transaction for the withdrawal request."""
197208
assert self.entry_address is not None, "Entry address not initialized"
198209
gas_limit = self.tx_gas_limit
199-
if fork is not None and fork.is_eip_enabled(8037):
210+
if (
211+
self.fund_state_reservoir
212+
and fork is not None
213+
and fork.is_eip_enabled(8037)
214+
):
200215
# Each withdrawal request writes 3 new storage slots
201216
# in the system contract queue (source, pubkey, amount).
202-
gas_costs = fork.gas_costs()
203-
gas_limit += len(self.requests) * 3 * gas_costs.STORAGE_SET
217+
gas_limit += len(self.requests) * 3 * fork.sstore_state_gas()
204218
return [
205219
Transaction(
206220
gas_limit=gas_limit,

tests/prague/eip7002_el_triggerable_withdrawals/test_withdrawal_requests.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,12 @@
328328
],
329329
call_depth=264,
330330
tx_gas_limit=16_777_216,
331+
# tx_gas_limit is held at the cap to test the
332+
# 63/64 drain over the deep call chain. EIP-8037
333+
# state-set work is funded via the reservoir
334+
# rather than the regular pool, which would
335+
# corrupt the boundary the test pins.
336+
fund_state_reservoir=True,
331337
),
332338
],
333339
],

0 commit comments

Comments
 (0)