Skip to content

test_set_code_call_set_code()

Documentation for tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_call_set_code@verkle@v0.0.6.

Generate fixtures for these test cases for Prague with:

Prague only:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_call_set_code --fork=Prague --evm-bin=/path/to/evm-tool-dev-version

For all forks up to and including Prague:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_call_set_code --until=Prague

Test the calling a set-code account from another set-code account.

Source code in tests/prague/eip7702_set_code_tx/test_set_code_txs.py
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
@pytest.mark.with_all_call_opcodes
@pytest.mark.parametrize(
    "value",
    [0, 1],
)
def test_set_code_call_set_code(
    state_test: StateTestFiller,
    pre: Alloc,
    call_opcode: Op,
    value: int,
):
    """
    Test the calling a set-code account from another set-code account.
    """
    auth_signer_1 = pre.fund_eoa(auth_account_start_balance)
    storage_1 = Storage()

    static_call = call_opcode in [Op.STATICCALL, Op.EXTSTATICCALL]

    set_code_1_call_result_slot = storage_1.store_next(
        call_return_code(opcode=call_opcode, success=not static_call)
    )
    set_code_1_success = storage_1.store_next(True)

    auth_signer_2 = pre.fund_eoa(auth_account_start_balance)
    storage_2 = Storage().set_next_slot(storage_1.peek_slot())
    set_code_2_success = storage_2.store_next(not static_call)

    set_code_1 = (
        Op.SSTORE(set_code_1_call_result_slot, call_opcode(address=auth_signer_2, value=value))
        + Op.SSTORE(set_code_1_success, 1)
        + Op.STOP
    )
    set_code_to_address_1 = pre.deploy_contract(set_code_1)

    set_code_2 = Op.SSTORE(set_code_2_success, 1) + Op.STOP
    set_code_to_address_2 = pre.deploy_contract(set_code_2)

    tx = Transaction(
        gas_limit=10_000_000,
        to=auth_signer_1,
        value=value,
        authorization_list=[
            AuthorizationTuple(
                address=set_code_to_address_1,
                nonce=0,
                signer=auth_signer_1,
            ),
            AuthorizationTuple(
                address=set_code_to_address_2,
                nonce=0,
                signer=auth_signer_2,
            ),
        ],
        sender=pre.fund_eoa(),
    )

    state_test(
        env=Environment(),
        pre=pre,
        tx=tx,
        post={
            set_code_to_address_1: Account(storage={k: 0 for k in storage_1}),
            set_code_to_address_2: Account(storage={k: 0 for k in storage_2}),
            auth_signer_1: Account(
                nonce=1,
                code=Spec.delegation_designation(set_code_to_address_1),
                storage=(
                    storage_1
                    if call_opcode in [Op.CALL, Op.STATICCALL, Op.EXTCALL, Op.EXTSTATICCALL]
                    else storage_1 + storage_2
                ),
                balance=(0 if call_opcode in [Op.CALL, Op.EXTCALL] else value)
                + auth_account_start_balance,
            ),
            auth_signer_2: Account(
                nonce=1,
                code=Spec.delegation_designation(set_code_to_address_2),
                storage=storage_2 if call_opcode in [Op.CALL, Op.EXTCALL] else {},
                balance=(value if call_opcode in [Op.CALL, Op.EXTCALL] else 0)
                + auth_account_start_balance,
            ),
        },
    )

Parametrized Test Cases

The interactive table below is also available as a standalone page.

Skipped Parameters

For more concise readability, the table below does not list the following parameter values: fork, blockchain_test, state_test, state_test_only, eof_test, eof_state_test.

Test ID call_opcode evm_code_type value
call_opcode_EXTCALL-evm_code_type_EOF_V1-value_0 EXTCALL EOF_V1 0
call_opcode_EXTCALL-evm_code_type_EOF_V1-value_1 EXTCALL EOF_V1 1
call_opcode_EXTCALL-evm_code_type_EOF_V1-value_0 EXTCALL EOF_V1 0
call_opcode_EXTCALL-evm_code_type_EOF_V1-value_1 EXTCALL EOF_V1 1
call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-value_0 EXTSTATICCALL EOF_V1 0
call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-value_1 EXTSTATICCALL EOF_V1 1
call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-value_0 EXTSTATICCALL EOF_V1 0
call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-value_1 EXTSTATICCALL EOF_V1 1
call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-value_0 EXTDELEGATECALL EOF_V1 0
call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-value_1 EXTDELEGATECALL EOF_V1 1
call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-value_0 EXTDELEGATECALL EOF_V1 0
call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-value_1 EXTDELEGATECALL EOF_V1 1
call_opcode_STATICCALL-evm_code_type_LEGACY-value_0 STATICCALL LEGACY 0
call_opcode_STATICCALL-evm_code_type_LEGACY-value_1 STATICCALL LEGACY 1
call_opcode_STATICCALL-evm_code_type_LEGACY-value_0 STATICCALL LEGACY 0
call_opcode_STATICCALL-evm_code_type_LEGACY-value_1 STATICCALL LEGACY 1
call_opcode_DELEGATECALL-evm_code_type_LEGACY-value_0 DELEGATECALL LEGACY 0
call_opcode_DELEGATECALL-evm_code_type_LEGACY-value_1 DELEGATECALL LEGACY 1
call_opcode_DELEGATECALL-evm_code_type_LEGACY-value_0 DELEGATECALL LEGACY 0
call_opcode_DELEGATECALL-evm_code_type_LEGACY-value_1 DELEGATECALL LEGACY 1
call_opcode_CALL-evm_code_type_LEGACY-value_0 CALL LEGACY 0
call_opcode_CALL-evm_code_type_LEGACY-value_1 CALL LEGACY 1
call_opcode_CALL-evm_code_type_LEGACY-value_0 CALL LEGACY 0
call_opcode_CALL-evm_code_type_LEGACY-value_1 CALL LEGACY 1
call_opcode_CALLCODE-evm_code_type_LEGACY-value_0 CALLCODE LEGACY 0
call_opcode_CALLCODE-evm_code_type_LEGACY-value_1 CALLCODE LEGACY 1
call_opcode_CALLCODE-evm_code_type_LEGACY-value_0 CALLCODE LEGACY 0
call_opcode_CALLCODE-evm_code_type_LEGACY-value_1 CALLCODE LEGACY 1