diff --git a/core/src/subgraph/instance_manager.rs b/core/src/subgraph/instance_manager.rs index d905766f55e..7243088ffb0 100644 --- a/core/src/subgraph/instance_manager.rs +++ b/core/src/subgraph/instance_manager.rs @@ -182,7 +182,7 @@ impl SubgraphInstanceManager { // that is done store.start_subgraph_deployment(&logger).await?; - let (manifest, manifest_idx_and_name) = { + let (manifest, manifest_idx_and_name, static_data_sources) = { info!(logger, "Resolve subgraph files using IPFS"); let mut manifest = SubgraphManifest::resolve_from_raw( @@ -218,20 +218,27 @@ impl SubgraphInstanceManager { info!(logger, "Successfully resolved subgraph files using IPFS"); - // Add dynamic data sources to the subgraph - manifest.data_sources.extend(data_sources); - info!( logger, "Data source count at start: {}", manifest.data_sources.len() ); - (manifest, manifest_idx_and_name) + let static_data_sources = manifest.data_sources.clone(); + + // Add dynamic data sources to the subgraph + manifest.data_sources.extend(data_sources); + + (manifest, manifest_idx_and_name, static_data_sources) }; - let static_filters = self.static_filters - || (manifest.network_name() == "bsc" && manifest.templates.len() > 10000); + let dds_count = manifest + .data_sources + .len() + .abs_diff(static_data_sources.len()); + + let static_filters = + self.static_filters || (manifest.network_name() == "bsc" && dds_count >= 10000); let onchain_data_sources = manifest .data_sources @@ -248,9 +255,14 @@ impl SubgraphInstanceManager { .clone(); // Obtain filters from the manifest - let mut filter = C::TriggerFilter::from_data_sources(onchain_data_sources.iter()); + let filter = if static_filters { + let onchain_data_sources = static_data_sources + .iter() + .filter_map(|d| d.as_onchain().cloned()) + .collect::>(); + + let mut filter = C::TriggerFilter::from_data_sources(onchain_data_sources.iter()); - if static_filters { filter.extend_with_template( manifest .templates @@ -258,7 +270,10 @@ impl SubgraphInstanceManager { .filter_map(|ds| ds.as_onchain()) .cloned(), ); - } + filter + } else { + C::TriggerFilter::from_data_sources(onchain_data_sources.iter()) + }; let start_blocks = manifest.start_blocks();