Skip to content

test_auxdata_variations()

Documentation for tests/osaka/eip7692_eof_v1/eip7873_tx_create/test_txcreate.py::test_auxdata_variations@v4.4.0.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7873_tx_create/test_txcreate.py::test_auxdata_variations --fork Osaka

Verifies that auxdata bytes are correctly handled in RETURNCODE.

Source code in tests/osaka/eip7692_eof_v1/eip7873_tx_create/test_txcreate.py
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
@pytest.mark.with_all_evm_code_types
@pytest.mark.parametrize(
    "auxdata_bytes",
    [
        pytest.param(b"", id="zero"),
        pytest.param(b"aabbcc", id="short"),
        pytest.param(b"aabbccddeef", id="one_byte_short"),
        pytest.param(b"aabbccddeeff", id="exact"),
        pytest.param(b"aabbccddeeffg", id="one_byte_long"),
        pytest.param(b"aabbccddeeffgghhii", id="extra"),
    ],
)
def test_auxdata_variations(state_test: StateTestFiller, pre: Alloc, auxdata_bytes: bytes):
    """Verifies that auxdata bytes are correctly handled in RETURNCODE."""
    env = Environment()
    auxdata_size = len(auxdata_bytes)
    pre_deploy_header_data_size = 18
    pre_deploy_data = b"AABBCC"
    deploy_success = len(auxdata_bytes) + len(pre_deploy_data) >= pre_deploy_header_data_size

    runtime_subcontainer = Container(
        name="Runtime Subcontainer with truncated data",
        sections=[
            Section.Code(code=Op.STOP),
            Section.Data(data=pre_deploy_data, custom_size=pre_deploy_header_data_size),
        ],
    )

    initcode_subcontainer = Container(
        name="Initcode Subcontainer",
        sections=[
            Section.Code(
                code=Op.MSTORE(0, Op.PUSH32(auxdata_bytes.ljust(32, b"\0")))
                + Op.RETURNCODE[0](0, auxdata_size),
            ),
            Section.Container(container=runtime_subcontainer),
        ],
    )
    initcode_hash = initcode_subcontainer.hash

    sender = pre.fund_eoa()
    contract_address = pre.deploy_contract(
        code=Op.SSTORE(slot_create_address, Op.TXCREATE(tx_initcode_hash=initcode_hash)) + Op.STOP,
        storage={slot_create_address: value_canary_to_be_overwritten},
    )

    # Storage in 0 should have the address,
    post = {
        contract_address: Account(
            storage={
                slot_create_address: compute_eofcreate_address(contract_address, 0)
                if deploy_success
                else b"\0"
            }
        )
    }

    tx = Transaction(
        to=contract_address,
        gas_limit=10_000_000,
        sender=sender,
        initcodes=[initcode_subcontainer],
    )

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

Parametrized Test Cases

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

Test ID (Abbreviated) evm_code_type auxdata_bytes
...fork_Osaka-evm_code_type_LEGACY-state_test-zero LEGACY
...fork_Osaka-evm_code_type_LEGACY-state_test-short LEGACY 616162626363
...fork_Osaka-evm_code_type_LEGACY-state_test-one_byte_short LEGACY 6161626263636464656566
...fork_Osaka-evm_code_type_LEGACY-state_test-exact LEGACY 616162626363646465656666
...fork_Osaka-evm_code_type_LEGACY-state_test-one_byte_long LEGACY 61616262636364646565666667
...fork_Osaka-evm_code_type_LEGACY-state_test-extra LEGACY 61616262636364646565666667676868 6969
...fork_Osaka-evm_code_type_LEGACY-blockchain_test_from_state_test-zero LEGACY
...fork_Osaka-evm_code_type_LEGACY-blockchain_test_from_state_test-short LEGACY 616162626363
...fork_Osaka-evm_code_type_LEGACY-blockchain_test_from_state_test-one_byte_short LEGACY 6161626263636464656566
...fork_Osaka-evm_code_type_LEGACY-blockchain_test_from_state_test-exact LEGACY 616162626363646465656666
...fork_Osaka-evm_code_type_LEGACY-blockchain_test_from_state_test-one_byte_long LEGACY 61616262636364646565666667
...fork_Osaka-evm_code_type_LEGACY-blockchain_test_from_state_test-extra LEGACY 61616262636364646565666667676868 6969
...fork_Osaka-evm_code_type_EOF_V1-state_test-zero EOF_V1
...fork_Osaka-evm_code_type_EOF_V1-state_test-short EOF_V1 616162626363
...fork_Osaka-evm_code_type_EOF_V1-state_test-one_byte_short EOF_V1 6161626263636464656566
...fork_Osaka-evm_code_type_EOF_V1-state_test-exact EOF_V1 616162626363646465656666
...fork_Osaka-evm_code_type_EOF_V1-state_test-one_byte_long EOF_V1 61616262636364646565666667
...fork_Osaka-evm_code_type_EOF_V1-state_test-extra EOF_V1 61616262636364646565666667676868 6969
...fork_Osaka-evm_code_type_EOF_V1-blockchain_test_from_state_test-zero EOF_V1
...fork_Osaka-evm_code_type_EOF_V1-blockchain_test_from_state_test-short EOF_V1 616162626363
...fork_Osaka-evm_code_type_EOF_V1-blockchain_test_from_state_test-one_byte_short EOF_V1 6161626263636464656566
...fork_Osaka-evm_code_type_EOF_V1-blockchain_test_from_state_test-exact EOF_V1 616162626363646465656666
...fork_Osaka-evm_code_type_EOF_V1-blockchain_test_from_state_test-one_byte_long EOF_V1 61616262636364646565666667
...fork_Osaka-evm_code_type_EOF_V1-blockchain_test_from_state_test-extra EOF_V1 61616262636364646565666667676868 6969