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@49a16fac.

Generate fixtures for these test cases for Prague with:

fill -v tests/prague/eip7702_set_code_tx/test_set_code_txs.py::test_set_code_call_set_code --fork 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
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
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
@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.

Test ID (Abbreviated) call_opcode evm_code_type value
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test-value_0 STATICCALL LEGACY 0
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test-value_1 STATICCALL LEGACY 1
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-value_0 STATICCALL LEGACY 0
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-value_1 STATICCALL LEGACY 1
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test-value_0 DELEGATECALL LEGACY 0
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test-value_1 DELEGATECALL LEGACY 1
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-value_0 DELEGATECALL LEGACY 0
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-value_1 DELEGATECALL LEGACY 1
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test-value_0 CALL LEGACY 0
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test-value_1 CALL LEGACY 1
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-state_test-value_0 CALL LEGACY 0
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-state_test-value_1 CALL LEGACY 1
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test-value_0 CALLCODE LEGACY 0
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test-value_1 CALLCODE LEGACY 1
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-value_0 CALLCODE LEGACY 0
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-value_1 CALLCODE LEGACY 1
...fork_Osaka-call_opcode_EXTCALL-evm_code_type_EOF_V1-blockchain_test-value_0 EXTCALL EOF_V1 0
...fork_Osaka-call_opcode_EXTCALL-evm_code_type_EOF_V1-blockchain_test-value_1 EXTCALL EOF_V1 1
...fork_Osaka-call_opcode_EXTCALL-evm_code_type_EOF_V1-state_test-value_0 EXTCALL EOF_V1 0
...fork_Osaka-call_opcode_EXTCALL-evm_code_type_EOF_V1-state_test-value_1 EXTCALL EOF_V1 1
...fork_Osaka-call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-blockchain_test-value_0 EXTSTATICCALL EOF_V1 0
...fork_Osaka-call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-blockchain_test-value_1 EXTSTATICCALL EOF_V1 1
...fork_Osaka-call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-state_test-value_0 EXTSTATICCALL EOF_V1 0
...fork_Osaka-call_opcode_EXTSTATICCALL-evm_code_type_EOF_V1-state_test-value_1 EXTSTATICCALL EOF_V1 1
...fork_Osaka-call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-blockchain_test-value_0 EXTDELEGATECALL EOF_V1 0
...fork_Osaka-call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-blockchain_test-value_1 EXTDELEGATECALL EOF_V1 1
...fork_Osaka-call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-state_test-value_0 EXTDELEGATECALL EOF_V1 0
...fork_Osaka-call_opcode_EXTDELEGATECALL-evm_code_type_EOF_V1-state_test-value_1 EXTDELEGATECALL EOF_V1 1
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test-value_0 STATICCALL LEGACY 0
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test-value_1 STATICCALL LEGACY 1
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-value_0 STATICCALL LEGACY 0
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test-value_1 STATICCALL LEGACY 1
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test-value_0 DELEGATECALL LEGACY 0
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test-value_1 DELEGATECALL LEGACY 1
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-value_0 DELEGATECALL LEGACY 0
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test-value_1 DELEGATECALL LEGACY 1
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test-value_0 CALL LEGACY 0
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test-value_1 CALL LEGACY 1
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-state_test-value_0 CALL LEGACY 0
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-state_test-value_1 CALL LEGACY 1
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test-value_0 CALLCODE LEGACY 0
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test-value_1 CALLCODE LEGACY 1
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-value_0 CALLCODE LEGACY 0
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test-value_1 CALLCODE LEGACY 1