Skip to content

test_extra_logs()

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

Generate fixtures for these test cases for Prague with:

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

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

Source code in tests/prague/eip6110_deposits/test_modified_contract.py
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
@pytest.mark.parametrize(
    "include_deposit_event",
    [
        pytest.param(True),
        pytest.param(False),
    ],
)
def test_extra_logs(
    blockchain_test: BlockchainTestFiller,
    pre: Alloc,
    include_deposit_event: bool,
):
    """Test deposit contract emitting more log event types than the ones in mainnet."""
    # Supplant 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"]

    bytecode = Op.LOG3(
        # 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)
        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[Spec.DEPOSIT_CONTRACT_ADDRESS] = Account(
        code=bytecode,
        nonce=1,
        balance=0,
    )
    sender = pre.fund_eoa()

    tx = Transaction(
        to=Spec.DEPOSIT_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

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

Test ID (Abbreviated) include_deposit_event
...fork_Prague-blockchain_test-include_deposit_event_True True
...fork_Prague-blockchain_test-include_deposit_event_False False
...fork_Osaka-blockchain_test-include_deposit_event_True True
...fork_Osaka-blockchain_test-include_deposit_event_False False