@@ -94,13 +94,6 @@ struct PastL1BatchInfo {
94
94
chain_id : SLChainId ,
95
95
}
96
96
97
- #[ derive( Debug ) ]
98
- struct SLChainAccess {
99
- client : Box < dyn EthInterface > ,
100
- chain_id : SLChainId ,
101
- diamond_proxy_addr : Address ,
102
- }
103
-
104
97
/// Provider of tree data loading it from L1 `BlockCommit` events emitted by the diamond proxy contract.
105
98
/// Should be used together with an L2 provider because L1 data can be missing for latest batches,
106
99
/// and the provider implementation uses assumptions that can break in some corner cases.
@@ -113,7 +106,9 @@ struct SLChainAccess {
113
106
/// (provided it's not too far behind the seal timestamp of the batch).
114
107
#[ derive( Debug ) ]
115
108
pub ( super ) struct SLDataProvider {
116
- chain_data : SLChainAccess ,
109
+ client : Box < dyn EthInterface > ,
110
+ chain_id : SLChainId ,
111
+ diamond_proxy_addr : Address ,
117
112
block_commit_signature : H256 ,
118
113
past_l1_batch : Option < PastL1BatchInfo > ,
119
114
}
@@ -130,17 +125,14 @@ impl SLDataProvider {
130
125
l1_diamond_proxy_addr : Address ,
131
126
) -> anyhow:: Result < Self > {
132
127
let l1_chain_id = l1_client. fetch_chain_id ( ) . await ?;
133
- let chain_data = SLChainAccess {
134
- client : l1_client,
135
- chain_id : l1_chain_id,
136
- diamond_proxy_addr : l1_diamond_proxy_addr,
137
- } ;
138
128
let block_commit_signature = zksync_contracts:: hyperchain_contract ( )
139
129
. event ( "BlockCommit" )
140
130
. context ( "missing `BlockCommit` event" ) ?
141
131
. signature ( ) ;
142
132
Ok ( Self {
143
- chain_data,
133
+ client : l1_client,
134
+ chain_id : l1_chain_id,
135
+ diamond_proxy_addr : l1_diamond_proxy_addr,
144
136
block_commit_signature,
145
137
past_l1_batch : None ,
146
138
} )
@@ -215,7 +207,7 @@ impl TreeDataProvider for SLDataProvider {
215
207
info. number < number,
216
208
"`batch_details()` must be called with monotonically increasing numbers"
217
209
) ;
218
- if info. chain_id != self . chain_data . chain_id {
210
+ if info. chain_id != self . chain_id {
219
211
return None ;
220
212
}
221
213
let threshold_timestamp = info. l1_commit_block_timestamp + Self :: L1_BLOCK_RANGE . as_u64 ( ) / 2 ;
@@ -236,7 +228,7 @@ impl TreeDataProvider for SLDataProvider {
236
228
Some ( number) => number,
237
229
None => {
238
230
let ( approximate_block, steps) = Self :: guess_l1_commit_block_number (
239
- self . chain_data . client . as_ref ( ) ,
231
+ self . client . as_ref ( ) ,
240
232
l1_batch_seal_timestamp,
241
233
)
242
234
. await ?;
@@ -254,7 +246,7 @@ impl TreeDataProvider for SLDataProvider {
254
246
255
247
let number_topic = H256 :: from_low_u64_be ( number. 0 . into ( ) ) ;
256
248
let filter = web3:: FilterBuilder :: default ( )
257
- . address ( vec ! [ self . chain_data . diamond_proxy_addr] )
249
+ . address ( vec ! [ self . diamond_proxy_addr] )
258
250
. from_block ( web3:: BlockNumber :: Number ( from_block) )
259
251
. to_block ( web3:: BlockNumber :: Number ( from_block + Self :: L1_BLOCK_RANGE ) )
260
252
. topics (
@@ -264,7 +256,7 @@ impl TreeDataProvider for SLDataProvider {
264
256
None ,
265
257
)
266
258
. build ( ) ;
267
- let mut logs = self . chain_data . client . logs ( & filter) . await ?;
259
+ let mut logs = self . client . logs ( & filter) . await ?;
268
260
logs. retain ( |log| !log. is_removed ( ) && log. block_number . is_some ( ) ) ;
269
261
270
262
match logs. as_slice ( ) {
@@ -285,11 +277,7 @@ impl TreeDataProvider for SLDataProvider {
285
277
{diff} block(s) after the `from` block from the filter"
286
278
) ;
287
279
288
- let l1_commit_block = self
289
- . chain_data
290
- . client
291
- . block ( l1_commit_block_number. into ( ) )
292
- . await ?;
280
+ let l1_commit_block = self . client . block ( l1_commit_block_number. into ( ) ) . await ?;
293
281
let l1_commit_block = l1_commit_block. ok_or_else ( || {
294
282
let err = "Block disappeared from L1 RPC provider" ;
295
283
EnrichedClientError :: new ( ClientError :: Custom ( err. into ( ) ) , "batch_details" )
@@ -299,7 +287,7 @@ impl TreeDataProvider for SLDataProvider {
299
287
number,
300
288
l1_commit_block_number,
301
289
l1_commit_block_timestamp : l1_commit_block. timestamp ,
302
- chain_id : self . chain_data . chain_id ,
290
+ chain_id : self . chain_id ,
303
291
} ) ;
304
292
Ok ( Ok ( root_hash) )
305
293
}
0 commit comments