Skip to content

Commit

Permalink
graph: new specVersion validation for indexerHints
Browse files Browse the repository at this point in the history
  • Loading branch information
incrypto32 committed Dec 8, 2023
1 parent 5aabecd commit 5c97594
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions graph/src/data/subgraph/api_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ pub const SPEC_VERSION_0_0_8: Version = Version::new(0, 0, 8);
// Enables `endBlock` feature.
pub const SPEC_VERSION_0_0_9: Version = Version::new(0, 0, 9);

// Enables `indexerHints` feature.
pub const SPEC_VERSION_0_1_0: Version = Version::new(0, 1, 0);

pub const MIN_SPEC_VERSION: Version = Version::new(0, 0, 2);

#[derive(Clone, PartialEq, Debug)]
Expand Down
7 changes: 7 additions & 0 deletions graph/src/data/subgraph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,13 @@ impl<C: Blockchain> UnresolvedSubgraphManifest<C> {
);
}

if spec_version < SPEC_VERSION_0_1_0 && indexer_hints.is_some() {
bail!(
"`indexerHints` are not supported prior to {}",
SPEC_VERSION_0_1_0
);
}

// Check the min_spec_version of each data source against the spec version of the subgraph
let min_spec_version_mismatch = data_sources
.iter()
Expand Down
5 changes: 3 additions & 2 deletions store/test-store/tests/chain/ethereum/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use graph::data::store::Value;
use graph::data::subgraph::schema::SubgraphError;
use graph::data::subgraph::{
SPEC_VERSION_0_0_4, SPEC_VERSION_0_0_7, SPEC_VERSION_0_0_8, SPEC_VERSION_0_0_9,
SPEC_VERSION_0_1_0,
};
use graph::data_source::offchain::OffchainDataSourceKind;
use graph::data_source::DataSourceTemplate;
Expand Down Expand Up @@ -197,12 +198,12 @@ schema:
graft:
base: Qmbase
block: 12345
specVersion: 0.0.2
specVersion: 0.1.0
indexerHints:
historyBlocks: 100
";

let manifest = resolve_manifest(YAML, SPEC_VERSION_0_0_4).await;
let manifest = resolve_manifest(YAML, SPEC_VERSION_0_1_0).await;

assert_eq!(manifest.history_blocks().unwrap(), 100);
}
Expand Down

0 comments on commit 5c97594

Please sign in to comment.