169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276 | @EIPChecklist.ModifiedTransactionValidityConstraint.Test.ForkTransition.AcceptedBeforeFork()
@EIPChecklist.ModifiedTransactionValidityConstraint.Test.ForkTransition.RejectedBeforeFork()
@EIPChecklist.ModifiedTransactionValidityConstraint.Test.ForkTransition.AcceptedAfterFork()
@EIPChecklist.ModifiedTransactionValidityConstraint.Test.ForkTransition.RejectedAfterFork()
@pytest.mark.exception_test
def test_access_list_validity_across_amsterdam_transition(
blockchain_test: BlockchainTestFiller,
pre: Alloc,
fork: TransitionFork,
) -> None:
"""
Pin the intrinsic-validity flip across the Amsterdam boundary.
For an access list with one address and two storage keys the
EIP-7981 byte surcharge (plus the EIP-8038 entry repricing) outgrows
the EIP-2780 base reduction, so the post-fork intrinsic is strictly
higher than the pre-fork one. Off-by-one gas limits around each
fork's requirement then pin all four boundary behaviors:
1. Pre-fork block with `gas_limit` one below the pre-fork intrinsic
is rejected.
2. Pre-fork block accepts both the exact pre-fork intrinsic and a
gas limit one below the post-fork intrinsic (the new constraint
is not met, the old one is).
3. Post-fork block with that same one-below gas limit is rejected.
4. Post-fork block with the exact post-fork intrinsic is accepted.
"""
gas_price = 1_000_000_000
access_list = access_list_shape(addresses=1, keys_per_address=2)
pre_fork = fork.fork_at(timestamp=PRE_FORK_TIMESTAMP)
post_fork = fork.fork_at(timestamp=POST_FORK_TIMESTAMP)
intrinsic_pre = pre_fork.transaction_intrinsic_cost_calculator()(
access_list=access_list,
return_cost_deducted_prior_execution=True,
)
intrinsic_post = post_fork.transaction_intrinsic_cost_calculator()(
access_list=access_list,
return_cost_deducted_prior_execution=True,
)
# The gas limit straddling the boundary must be valid pre-fork and
# invalid post-fork.
straddle_gas_limit = intrinsic_post - 1
assert intrinsic_pre <= straddle_gas_limit, (
f"access list shape does not discriminate: pre-fork intrinsic "
f"{intrinsic_pre} exceeds post-fork intrinsic - 1 "
f"({straddle_gas_limit})"
)
# The intrinsic side must bind over the floor on both forks.
for sub_fork, intrinsic in [
(pre_fork, intrinsic_pre),
(post_fork, intrinsic_post),
]:
floor_gas = sub_fork.transaction_data_floor_cost_calculator()(
data=b"", access_list=access_list
)
assert floor_gas <= intrinsic
def make_tx(
gas_limit: int, error: TransactionException | None = None
) -> Transaction:
return Transaction(
sender=pre.fund_eoa(),
to=pre.fund_eoa(amount=0),
gas_limit=gas_limit,
gas_price=gas_price,
access_list=access_list,
error=error,
)
blocks = [
# 1. Rejected before the fork: below the pre-fork intrinsic.
Block(
timestamp=PRE_FORK_TIMESTAMP,
txs=[
make_tx(
intrinsic_pre - 1,
error=TransactionException.INTRINSIC_GAS_TOO_LOW,
)
],
exception=TransactionException.INTRINSIC_GAS_TOO_LOW,
),
# 2. Accepted before the fork: the exact pre-fork intrinsic and
# the straddling gas limit that the post-fork rules will reject.
Block(
timestamp=PRE_FORK_TIMESTAMP,
txs=[make_tx(intrinsic_pre), make_tx(straddle_gas_limit)],
),
# 3. Rejected after the fork: the same straddling gas limit.
Block(
timestamp=POST_FORK_TIMESTAMP,
txs=[
make_tx(
straddle_gas_limit,
error=TransactionException.INTRINSIC_GAS_TOO_LOW,
)
],
exception=TransactionException.INTRINSIC_GAS_TOO_LOW,
),
# 4. Accepted after the fork: the exact post-fork intrinsic.
Block(
timestamp=POST_FORK_TIMESTAMP,
txs=[make_tx(intrinsic_post)],
),
]
blockchain_test(pre=pre, blocks=blocks, post={})
|