Skip to content

test_extra_logs()

Documentation for tests/prague/eip6110_deposits/test_modified_contract.py::test_extra_logs@ffe48572.

Generate fixtures for these test cases for Bogota with:

fill -v tests/prague/eip6110_deposits/test_modified_contract.py::test_extra_logs --fork Bogota

Test deposit contract emitting more log event types than the ones in mainnet.

Supplants the mainnet contract with a variant that emits a Transfer log. If include_deposit_event is True, it will also emit a DepositEvent log.

Source code in tests/prague/eip6110_deposits/test_modified_contract.py
@pytest.mark.parametrize(
    "include_deposit_event,extra_event_type",
    [
        pytest.param(True, "transfer_log"),
        pytest.param(True, "no_topics"),
        pytest.param(False, "transfer_log"),
        pytest.param(False, "no_topics"),
    ],
)
def test_extra_logs(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    include_deposit_event: bool,
    extra_event_type: str,
) -> None:
    """
    Test deposit contract emitting more log event types than the ones in
    mainnet.

    Supplants the mainnet contract with a variant that emits a `Transfer` log.
    If `include_deposit_event` is `True`, it will also emit a `DepositEvent`
    log.
    """
    # ERC20 token transfer log (Sepolia)
    # https://sepolia.etherscan.io/tx/
    #   0x2d71f3085a796a0539c9cc28acd9073a67cf862260a41475f000dd101279f94f
    # JSON RPC: curl https://sepolia.infura.io/v3/APIKEY \ -X POST \ -H
    # "Content-Type: application/json" \ -d '{"jsonrpc": "2.0", "method":
    # "eth_getLogs", "params": [{"address":
    # "0x7f02C3E3c98b133055B8B348B2Ac625669Ed295D", "blockHash":
    # "0x8062a17fa791f5dbd59ea68891422e3299ca4e80885a89acf3fc706c8bceef53"}],
    # "id": 1}'

    # {"jsonrpc":"2.0","id":1,"result":
    # [{"removed":false,"logIndex":"0x80","transactionIndex":"0x56",
    # "transactionHash":
    #   "0x2d71f3085a796a0539c9cc28acd9073a67cf862260a41475f000dd101279f94f",
    # "blockHash":
    #   "0x8062a17fa791f5dbd59ea68891422e3299ca4e80885a89acf3fc706c8bceef53",
    # "blockNumber":"0x794fb5",
    # "address":"0x7f02c3e3c98b133055b8b348b2ac625669ed295d",
    # "data":
    #   "0x0000000000000000000000000000000000000000000000000000000000000001",
    # "topics":
    #   ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
    # "0x0000000000000000000000006885e36bfcb68cb383dfe90023a462c03bcb2ae5",
    # "0x00000000000000000000000080b5dc88c98e528bf9cb4b7f0f076ac41da24651"]

    if extra_event_type == "no_topics":
        # Log with no topics
        bytecode = Op.LOG0(
            0,
            32,
        )
    else:
        # ERC-20 token transfer log ERC-20 token transfers are LOG3, since the
        # topic, the sender, and receiver are all topics (the sender and
        # receiver are `indexed` in the solidity event)
        bytecode = Op.LOG3(
            0,
            32,
            0xDDF252AD1BE2C89B69C2B068FC378DAA952BA7F163C4A11628F55A4DF523B3EF,
            0x000000000000000000000000AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
            0x000000000000000000000000BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
        )

    requests = Requests()

    if include_deposit_event:
        bytecode += Om.MSTORE(DEFAULT_REQUEST_LOG) + Op.LOG1(
            0,
            len(DEFAULT_REQUEST_LOG),
            Spec.DEPOSIT_EVENT_SIGNATURE_HASH,
        )
        requests = Requests(DEFAULT_DEPOSIT_REQUEST)
    bytecode += Op.STOP

    pre.update_account(DepositRequest.system_contract_address, code=bytecode)
    sender = pre.fund_eoa()

    tx = Transaction(
        to=DepositRequest.system_contract_address,
        sender=sender,
        gas_limit=100_000,
    )

    blockchain_test(
        pre=pre,
        blocks=[
            Block(
                txs=[tx],
                header_verify=Header(
                    requests_hash=requests,
                ),
            ),
        ],
        post={},
    )

Parametrized Test Cases

This test generates 4 parametrized test cases across 4 forks.