Skip to content

test_identity_return_overwrite()

Documentation for tests/homestead/identity_precompile/test_identity.py::test_identity_return_overwrite@88e9fb8f.

Generate fixtures for these test cases for Osaka with:

fill -v tests/homestead/identity_precompile/test_identity.py::test_identity_return_overwrite --fork Osaka

Test the return data of the identity precompile overwriting its input.

Source code in tests/homestead/identity_precompile/test_identity.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
@pytest.mark.with_all_call_opcodes()
@pytest.mark.valid_from("Byzantium")
def test_identity_return_overwrite(
    state_test: StateTestFiller,
    pre: Alloc,
    call_opcode: Op,
) -> None:
    """
    Test the return data of the identity precompile overwriting its input.
    """
    code = (
        sum(Op.MSTORE8(offset=i, value=(i + 1)) for i in range(4))  # memory = [1, 2, 3, 4]
        + call_opcode(
            address=4,
            args_offset=0,
            args_size=4,  # args = [1, 2, 3, 4]
            ret_offset=1,
            ret_size=4,
        )  # memory = [1, 1, 2, 3, 4]
        + Op.RETURNDATACOPY(
            dest_offset=0, offset=0, size=Op.RETURNDATASIZE()
        )  # memory correct = [1, 2, 3, 4, 4], corrupt = [1, 1, 2, 3, 4]
        + Op.SSTORE(1, Op.SHA3(offset=0, size=Op.MSIZE))
    )
    contract_address = pre.deploy_contract(
        code=code,
    )
    tx = Transaction(
        sender=pre.fund_eoa(),
        to=contract_address,
        gas_limit=100_000,
    )

    post = {
        contract_address: Account(
            storage={
                1: keccak256(bytes([1, 2, 3, 4, 4]).ljust(32, b"\0")),
            },
        ),
    }

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

Parametrized Test Cases

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

Test ID (Abbreviated) call_opcode evm_code_type
...fork_Byzantium-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Byzantium-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Byzantium-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Byzantium-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Byzantium-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Byzantium-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Byzantium-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Byzantium-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_Constantinople-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Constantinople-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Constantinople-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Constantinople-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Constantinople-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Constantinople-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Constantinople-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Constantinople-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_ConstantinopleFix-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_ConstantinopleFix-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_ConstantinopleFix-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_ConstantinopleFix-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_ConstantinopleFix-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_ConstantinopleFix-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_ConstantinopleFix-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_ConstantinopleFix-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_Istanbul-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Istanbul-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Istanbul-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Istanbul-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Istanbul-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Istanbul-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Istanbul-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Istanbul-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_Berlin-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Berlin-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Berlin-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Berlin-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Berlin-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Berlin-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Berlin-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Berlin-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_London-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_London-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_London-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_London-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_London-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_London-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_London-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_London-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_Paris-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Paris-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Paris-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Paris-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Paris-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Paris-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Paris-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Paris-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_Shanghai-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Shanghai-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Shanghai-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Shanghai-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Shanghai-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Shanghai-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Shanghai-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Shanghai-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_Cancun-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Cancun-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Cancun-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Cancun-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Cancun-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Cancun-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Cancun-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Cancun-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Prague-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Prague-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Prague-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Prague-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-state_test STATICCALL LEGACY
...fork_Osaka-call_opcode_STATICCALL-evm_code_type_LEGACY-blockchain_test_from_state_test STATICCALL LEGACY
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-state_test DELEGATECALL LEGACY
...fork_Osaka-call_opcode_DELEGATECALL-evm_code_type_LEGACY-blockchain_test_from_state_test DELEGATECALL LEGACY
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-state_test CALL LEGACY
...fork_Osaka-call_opcode_CALL-evm_code_type_LEGACY-blockchain_test_from_state_test CALL LEGACY
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-state_test CALLCODE LEGACY
...fork_Osaka-call_opcode_CALLCODE-evm_code_type_LEGACY-blockchain_test_from_state_test CALLCODE LEGACY