Skip to content

test_auth_intrinsic_at_transition()

Documentation for tests/amsterdam/eip8038_state_access_gas_cost_increase/test_fork_transition.py::test_auth_intrinsic_at_transition@2867859a.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8038_state_access_gas_cost_increase/test_fork_transition.py::test_auth_intrinsic_at_transition --fork Amsterdam

The 7702 authorization intrinsic falls across the boundary. EIP-2780 moves the state-dependent authorization costs (account creation and the delegation-write base) out of the intrinsic and into the top frame, leaving only EXECUTION_PER_AUTH_BASE_COST in the intrinsic. The post-fork single-authorization intrinsic is therefore strictly smaller than the pre-fork one, so a tx whose gas_limit equals the (lower) post-fork intrinsic is rejected with INTRINSIC_GAS_TOO_LOW before the fork but valid after.

Source code in tests/amsterdam/eip8038_state_access_gas_cost_increase/test_fork_transition.py
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
@EIPChecklist.GasCostChanges.Test.ForkTransition.Before()
@EIPChecklist.GasCostChanges.Test.ForkTransition.After()
@pytest.mark.exception_test
def test_auth_intrinsic_at_transition(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    The ``7702`` authorization intrinsic *falls* across the boundary.
    EIP-2780 moves the state-dependent authorization costs (account
    creation and the delegation-write base) out of the intrinsic and into
    the top frame, leaving only ``EXECUTION_PER_AUTH_BASE_COST`` in the
    intrinsic. The post-fork single-authorization intrinsic is
    therefore strictly smaller than the pre-fork one, so a tx whose
    ``gas_limit`` equals the (lower) post-fork intrinsic is rejected with
    ``INTRINSIC_GAS_TOO_LOW`` before the fork but valid after.
    """
    before = fork.fork_at(timestamp=BEFORE_TS)
    after = fork.fork_at(timestamp=AFTER_TS)

    intrinsic_before = before.transaction_intrinsic_cost_calculator()(
        authorization_list_or_count=1,
        return_cost_deducted_prior_execution=True,
    )
    intrinsic_after = after.transaction_intrinsic_cost_calculator()(
        authorization_list_or_count=1,
        return_cost_deducted_prior_execution=True,
    )
    # The post-fork intrinsic is below the pre-fork one, so the same
    # gas_limit straddles validity at the boundary.
    assert intrinsic_after < intrinsic_before
    gas_limit = intrinsic_after

    target_before = pre.deploy_contract(code=Op.STOP)
    target_after = pre.deploy_contract(code=Op.STOP)

    auth_before = pre.fund_eoa()
    auth_after = pre.fund_eoa()

    blocks = [
        # Before the fork: gas_limit is below the (higher) old auth
        # intrinsic, so the tx is rejected.
        Block(
            timestamp=BEFORE_TS,
            txs=[
                Transaction(
                    to=auth_before,
                    gas_limit=gas_limit,
                    authorization_list=[
                        AuthorizationTuple(
                            address=target_before,
                            nonce=0,
                            signer=auth_before,
                        ),
                    ],
                    sender=pre.fund_eoa(),
                    error=TransactionException.INTRINSIC_GAS_TOO_LOW,
                ),
            ],
            exception=TransactionException.INTRINSIC_GAS_TOO_LOW,
        ),
        # After the fork: the auth intrinsic dropped to exactly this
        # gas_limit, so the tx is now valid (included). It has no gas left
        # for the top-frame delegation, so execution runs out of gas and
        # the delegation rolls back, but the block itself is valid.
        Block(
            timestamp=AFTER_TS,
            txs=[
                Transaction(
                    to=auth_after,
                    gas_limit=gas_limit,
                    authorization_list=[
                        AuthorizationTuple(
                            address=target_after,
                            nonce=0,
                            signer=auth_after,
                        ),
                    ],
                    sender=pre.fund_eoa(),
                ),
            ],
        ),
    ]

    blockchain_test(pre=pre, blocks=blocks, post={})

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.