Skip to content

test_intrinsic_decomposition_across_tx_types()

Documentation for tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py::test_intrinsic_decomposition_across_tx_types@26332146.

Generate fixtures for these test cases for Amsterdam with:

fill -v tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py::test_intrinsic_decomposition_across_tx_types --fork Amsterdam

The decomposed intrinsic keys on the transaction's fields, not its type: every type pays the same recipient and value primitives, with type-specific costs riding on top.

Source code in tests/amsterdam/eip2780_reduce_intrinsic_tx_gas/test_value_moving_transactions.py
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
@pytest.mark.with_all_tx_types
def test_intrinsic_decomposition_across_tx_types(
    fork: Fork,
    pre: Alloc,
    state_test: StateTestFiller,
    tx_type: int,
) -> None:
    """
    The decomposed intrinsic keys on the transaction's fields, not its
    type: every type pays the same recipient and value primitives, with
    type-specific costs riding on top.
    """
    value = 1
    sender = pre.fund_eoa()
    recipient = pre.fund_eoa(amount=EOA_INITIAL_BALANCE)

    scenario = (
        build_authorization(pre, AuthorizationAction.SETS_NEW_DELEGATION)
        if tx_type == 4
        else None
    )
    authorizations = [scenario.authorization] if scenario else []

    blob_versioned_hashes = (
        add_kzg_version([Hash(1)], EIP4844_Spec.BLOB_COMMITMENT_VERSION_KZG)
        if tx_type == 3
        else None
    )

    intrinsic_gas = fork.transaction_intrinsic_cost_calculator()(
        sends_value=True,
        recipient_type=RecipientType.EOA,
        authorization_list_or_count=authorizations,
        return_cost_deducted_prior_execution=True,
    )
    top_frame_gas = fork.transaction_top_frame_gas_calculator()(
        sends_value=True,
        recipient_type=RecipientType.EOA,
        authorizations=authorizations,
    )
    top_frame_state_gas = fork.transaction_top_frame_state_gas(
        sends_value=True,
        recipient_type=RecipientType.EOA,
        authorizations=authorizations,
    )
    total_gas_cost = intrinsic_gas + top_frame_gas + top_frame_state_gas

    tx = Transaction(
        ty=tx_type,
        sender=sender,
        to=recipient,
        value=value,
        authorization_list=authorizations or None,
        blob_versioned_hashes=blob_versioned_hashes,
        gas_limit=total_gas_cost,
        expected_receipt=TransactionReceipt(
            cumulative_gas_used=total_gas_cost,
            logs=[transfer_log(sender, recipient, value)],
        ),
    )

    post: dict[Address, Account] = {
        sender: Account(nonce=1),
        recipient: Account(balance=EOA_INITIAL_BALANCE + value),
    }
    if scenario:
        post[scenario.authority] = scenario.applied_account

    state_test(pre=pre, tx=tx, post=post)

Parametrized Test Cases

This test generates 5 parametrized test cases across 1 fork.