@@ -6,7 +6,7 @@ use std::{
6
6
} ;
7
7
8
8
use graph:: {
9
- blockchain:: ChainIdentifier ,
9
+ blockchain:: { BlockchainKind , ChainIdentifier } ,
10
10
components:: store:: BlockStore as BlockStoreTrait ,
11
11
prelude:: { error, warn, BlockNumber , BlockPtr , Logger } ,
12
12
} ;
@@ -200,7 +200,7 @@ impl BlockStore {
200
200
pub fn new (
201
201
logger : Logger ,
202
202
// (network, ident, shard)
203
- chains : Vec < ( String , Vec < ChainIdentifier > , Shard ) > ,
203
+ chains : Vec < ( String , Vec < ( ChainIdentifier , BlockchainKind ) > , Shard ) > ,
204
204
// shard -> pool
205
205
pools : HashMap < Shard , ConnectionPool > ,
206
206
sender : Arc < NotificationSender > ,
@@ -222,11 +222,28 @@ impl BlockStore {
222
222
chain_head_cache,
223
223
} ;
224
224
225
+ let chains: Vec < ( String , Vec < ChainIdentifierExt > , Shard ) > = chains
226
+ . into_iter ( )
227
+ . map ( |( name, idents, shard) | {
228
+ let idents = idents
229
+ . into_iter ( )
230
+ . map ( |( ident, kind) | ChainIdentifierExt { ident, kind } )
231
+ . collect ( ) ;
232
+ ( name, idents, shard)
233
+ } )
234
+ . collect ( ) ;
235
+
236
+ #[ derive( Debug , Eq , PartialEq , Hash , Clone ) ]
237
+ struct ChainIdentifierExt {
238
+ ident : ChainIdentifier ,
239
+ kind : BlockchainKind ,
240
+ }
241
+
225
242
fn reduce_idents (
226
243
chain_name : & str ,
227
- idents : Vec < ChainIdentifier > ,
228
- ) -> Result < Option < ChainIdentifier > , StoreError > {
229
- let mut idents: HashSet < ChainIdentifier > = HashSet :: from_iter ( idents. into_iter ( ) ) ;
244
+ idents : Vec < ChainIdentifierExt > ,
245
+ ) -> Result < Option < ChainIdentifierExt > , StoreError > {
246
+ let mut idents: HashSet < ChainIdentifierExt > = HashSet :: from_iter ( idents. into_iter ( ) ) ;
230
247
match idents. len ( ) {
231
248
0 => Ok ( None ) ,
232
249
1 => Ok ( idents. drain ( ) . next ( ) ) ,
@@ -245,7 +262,7 @@ impl BlockStore {
245
262
logger : & Logger ,
246
263
chain : & primary:: Chain ,
247
264
shard : & Shard ,
248
- ident : & Option < ChainIdentifier > ,
265
+ ident : & Option < ChainIdentifierExt > ,
249
266
) -> bool {
250
267
if & chain. shard != shard {
251
268
error ! (
@@ -258,7 +275,7 @@ impl BlockStore {
258
275
return false ;
259
276
}
260
277
match ident {
261
- Some ( ident) => {
278
+ Some ( ChainIdentifierExt { ident, kind : _ } ) => {
262
279
if chain. net_version != ident. net_version {
263
280
error ! ( logger,
264
281
"the net version for chain {} has changed from {} to {} since the last time we ran" ,
@@ -301,16 +318,21 @@ impl BlockStore {
301
318
} else {
302
319
ChainStatus :: ReadOnly
303
320
} ;
304
- block_store. add_chain_store ( chain, status, false ) ?;
321
+ block_store. add_chain_store ( chain, status, ident . map ( |id| id . kind ) , false ) ?;
305
322
}
306
323
( None , Some ( ident) ) => {
307
324
let chain = primary:: add_chain (
308
325
block_store. mirror . primary ( ) ,
309
326
& chain_name,
310
- & ident,
327
+ & ident. ident ,
311
328
& shard,
312
329
) ?;
313
- block_store. add_chain_store ( & chain, ChainStatus :: Ingestible , true ) ?;
330
+ block_store. add_chain_store (
331
+ & chain,
332
+ ChainStatus :: Ingestible ,
333
+ Some ( ident. kind ) ,
334
+ true ,
335
+ ) ?;
314
336
}
315
337
( None , None ) => {
316
338
error ! (
@@ -335,7 +357,9 @@ impl BlockStore {
335
357
. iter ( )
336
358
. filter ( |chain| !configured_chains. contains ( & chain. name ) )
337
359
{
338
- block_store. add_chain_store ( chain, ChainStatus :: ReadOnly , false ) ?;
360
+ // Here we pass None to blockchain kind because we don't have a way of knowing whether this chain was an EVM chain.
361
+ // This should only affect the determinism of the meta block in
362
+ block_store. add_chain_store ( chain, ChainStatus :: ReadOnly , None , false ) ?;
339
363
}
340
364
Ok ( block_store)
341
365
}
@@ -352,6 +376,7 @@ impl BlockStore {
352
376
& self ,
353
377
chain : & primary:: Chain ,
354
378
status : ChainStatus ,
379
+ kind : Option < BlockchainKind > ,
355
380
create : bool ,
356
381
) -> Result < Arc < ChainStore > , StoreError > {
357
382
let pool = self
@@ -372,6 +397,7 @@ impl BlockStore {
372
397
status,
373
398
sender,
374
399
pool,
400
+ kind,
375
401
) ;
376
402
if create {
377
403
store. create ( & ident) ?;
@@ -425,7 +451,7 @@ impl BlockStore {
425
451
self . mirror . read ( |conn| {
426
452
primary:: find_chain ( conn, chain) . and_then ( |chain| {
427
453
chain
428
- . map ( |chain| self . add_chain_store ( & chain, ChainStatus :: ReadOnly , false ) )
454
+ . map ( |chain| self . add_chain_store ( & chain, ChainStatus :: ReadOnly , None , false ) )
429
455
. transpose ( )
430
456
} )
431
457
} )
0 commit comments