test_max_code_size_deposit_gas()
Documentation for tests/amsterdam/eip7954_increase_max_contract_size/test_max_code_size.py::test_max_code_size_deposit_gas@5c024cbb.
Generate fixtures for these test cases for Amsterdam with:
fill -v tests/amsterdam/eip7954_increase_max_contract_size/test_max_code_size.py::test_max_code_size_deposit_gas --fork Amsterdam
Ensure code deposit gas is charged correctly at the new max.
Source code in tests/amsterdam/eip7954_increase_max_contract_size/test_max_code_size.py
126
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 | @pytest.mark.parametrize(
"gas_shortfall",
[
pytest.param(0, id="exact_gas"),
pytest.param(1, id="short_one_gas"),
],
)
def test_max_code_size_deposit_gas(
state_test: StateTestFiller,
pre: Alloc,
fork: Fork,
gas_shortfall: int,
) -> None:
"""Ensure code deposit gas is charged correctly at the new max."""
deploy_code = Op.JUMPDEST * fork.max_code_size()
initcode = Initcode(deploy_code=deploy_code)
alice = pre.fund_eoa()
create_address = compute_create_address(address=alice, nonce=0)
intrinsic_gas = fork.transaction_intrinsic_cost_calculator()(
calldata=initcode,
contract_creation=True,
return_cost_deducted_prior_execution=True,
)
# Under EIP-2780 the created account's NEW_ACCOUNT state gas is
# charged at the top frame, no longer bundled in the intrinsic, so
# add it back into the exact-fit gas limit.
top_frame_state_gas = fork.transaction_top_frame_state_gas(
contract_creation=True,
)
tx = Transaction(
sender=alice,
to=None,
data=initcode,
gas_limit=(
intrinsic_gas
+ top_frame_state_gas
+ initcode.execution_gas(fork)
+ initcode.deployment_gas(fork)
- gas_shortfall
),
)
# With shortfall, code deposit OOGs: tx succeeds but
# contract is not deployed
post = {
create_address: Account(code=deploy_code)
if not gas_shortfall
else Account.NONEXISTENT,
}
state_test(pre=pre, tx=tx, post=post)
|
Parametrized Test Cases
This test generates 2 parametrized test cases across 1 fork.