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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174 | @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[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={},
)
|