Skip to content

test_auxdata_variations()

Documentation for tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_auxdata_variations@21fb11c8.

Generate fixtures for these test cases for Osaka with:

fill -v tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py::test_auxdata_variations --fork Osaka

Verifies that auxdata bytes are correctly handled in RETURNCONTRACT.

Source code in tests/osaka/eip7692_eof_v1/eip7620_eof_create/test_eofcreate.py
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
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
@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 RETURNCONTRACT."""
    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.RETURNCONTRACT[0](0, auxdata_size),
            ),
            Section.Container(container=runtime_subcontainer),
        ],
    )

    sender = pre.fund_eoa()
    contract_address = pre.deploy_contract(
        code=Container(
            sections=[
                Section.Code(
                    code=Op.SSTORE(slot_create_address, Op.EOFCREATE[0](0, 0, 0, 0)) + Op.STOP,
                ),
                Section.Container(container=initcode_subcontainer),
            ]
        ),
        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, initcode_subcontainer
                )
                if deploy_success
                else b"\0"
            }
        )
    }

    tx = Transaction(
        to=contract_address,
        gas_limit=10_000_000,
        gas_price=10,
        protected=False,
        sender=sender,
    )

    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) auxdata_bytes
...fork_Osaka-state_test-zero
...fork_Osaka-state_test-short 616162626363
...fork_Osaka-state_test-one_byte_short 6161626263636464656566
...fork_Osaka-state_test-exact 616162626363646465656666
...fork_Osaka-state_test-one_byte_long 61616262636364646565666667
...fork_Osaka-state_test-extra 61616262636364646565666667676868 6969
...fork_Osaka-blockchain_test_from_state_test-zero
...fork_Osaka-blockchain_test_from_state_test-short 616162626363
...fork_Osaka-blockchain_test_from_state_test-one_byte_short 6161626263636464656566
...fork_Osaka-blockchain_test_from_state_test-exact 616162626363646465656666
...fork_Osaka-blockchain_test_from_state_test-one_byte_long 61616262636364646565666667
...fork_Osaka-blockchain_test_from_state_test-extra 61616262636364646565666667676868 6969