Skip to content

test_existing_account_no_refund()

Documentation for tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_existing_account_no_refund@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py::test_existing_account_no_refund --fork Amsterdam

An existing-authority delegation is charged the reduced top-frame cost directly, with no refund.

The authority is an existing funded EOA gaining a fresh delegation. Its leaf exists, so set_delegation charges neither NEW_ACCOUNT nor ACCOUNT_WRITE (and, unlike the superseded EIP-8037 behaviour, refunds neither); it charges only the top-frame AUTH_BASE. The receipt gas is therefore exactly the execution intrinsic plus AUTH_BASE.

Source code in tests/amsterdam/eip8037_state_creation_gas_cost_increase/test_state_gas_set_code.py
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
277
278
279
280
281
282
283
284
285
286
287
288
@pytest.mark.valid_from("EIP8037")
def test_existing_account_no_refund(
    state_test: StateTestFiller,
    pre: Alloc,
    fork: Fork,
) -> None:
    """
    An existing-authority delegation is charged the reduced top-frame
    cost directly, with no refund.

    The authority is an existing funded EOA gaining a fresh delegation.
    Its leaf exists, so ``set_delegation`` charges neither ``NEW_ACCOUNT``
    nor ``ACCOUNT_WRITE`` (and, unlike the superseded EIP-8037 behaviour,
    refunds neither); it charges only the top-frame ``AUTH_BASE``. The
    receipt gas is therefore exactly the execution intrinsic plus
    ``AUTH_BASE``.
    """
    contract = pre.deploy_contract(code=Op.STOP)

    signer = pre.fund_eoa()
    authorization_list = [
        AuthorizationTuple(
            address=contract,
            nonce=0,
            signer=signer,
            creates_account=False,
            writes_delegation=True,
        ),
    ]

    intrinsic_execution, top_frame_execution, top_frame_state = _auth_gas(
        fork, authorization_list
    )
    cumulative_gas_used, header_gas_used = _receipt_and_header(
        intrinsic_execution, top_frame_execution, top_frame_state
    )

    tx = Transaction(
        to=contract,
        authorization_list=authorization_list,
        sender=pre.fund_eoa(),
        expected_receipt=TransactionReceipt(
            cumulative_gas_used=cumulative_gas_used,
        ),
    )

    post = {signer: Account(code=Spec7702.delegation_designation(contract))}
    state_test(
        pre=pre,
        post=post,
        tx=tx,
        blockchain_test_header_verify=Header(gas_used=header_gas_used),
    )

Parametrized Test Cases

This test generates 1 parametrized test case across 1 fork.