Pack many authorizations into a single transaction near the gas
limit cap and confirm it succeeds.
The authorization count is sized from the per-authorization total
intrinsic (execution + state) and the transaction gas-limit cap, so it
automatically tracks the repriced cost.
Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_set_code_auth_gas.py
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636 | @EIPChecklist.GasCostChanges.Test.GasUpdatesMeasurement()
def test_many_auths_block_limit(
state_test: StateTestFiller,
env: Environment,
pre: Alloc,
fork: Fork,
) -> None:
"""
Pack many authorizations into a single transaction near the gas
limit cap and confirm it succeeds.
The authorization count is sized from the per-authorization total
intrinsic (execution + state) and the transaction gas-limit cap, so it
automatically tracks the repriced cost.
"""
gas_limit_cap = fork.transaction_gas_limit_cap()
assert gas_limit_cap is not None
contract = pre.deploy_contract(code=Op.STOP)
# Per-authorization total for a fresh (empty) authority: the execution
# intrinsic base plus the top-frame account-write, account-creation
# and delegation-write charges, derived from the fork's calculators
# so it tracks the repricing. The probe only feeds the gas
# calculators, so it is signed with a fixed dummy key rather than a
# throwaway pre-state signer.
probe_auth = AuthorizationTuple(
address=contract,
nonce=0,
secret_key=Hash(1),
creates_account=True,
writes_delegation=True,
first_write=True,
)
per_auth_total = (
_execution_per_auth(fork)
+ fork.transaction_top_frame_gas_calculator()(
authorizations=[probe_auth]
)
+ fork.transaction_top_frame_state_gas(authorizations=[probe_auth])
)
base = fork.transaction_intrinsic_cost_calculator()(
authorization_list_or_count=0,
)
# Leave headroom for the base intrinsic and a little slack.
num_auths = (gas_limit_cap - base) // per_auth_total
assert num_auths >= 2
signers = [pre.fund_eoa() for _ in range(num_auths)]
authorization_list = [
AuthorizationTuple(address=contract, nonce=0, signer=signer)
for signer in signers
]
sender = pre.fund_eoa()
tx = Transaction(
to=contract,
authorization_list=authorization_list,
sender=sender,
)
post = {
signer: Account(code=Spec7702.delegation_designation(contract))
for signer in signers
}
state_test(env=env, pre=pre, post=post, tx=tx)
|