Skip to content

Remove the private API for the hosted explorer #5978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
graph, store: Simplify VersionInfo
Move hte struct to the store since it is only used for tests and remove any
fields that the tests don't need
  • Loading branch information
lutter committed May 13, 2025
commit 2d1867435052621f5a54ffeb4f811b0486b0abca
3 changes: 0 additions & 3 deletions graph/src/components/server/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/// Component for running GraphQL queries over HTTP.
pub mod query;

/// Component for the index node server.
pub mod index_node;

pub mod server;
18 changes: 2 additions & 16 deletions store/postgres/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,27 +318,15 @@ pub fn schema(conn: &mut PgConnection, site: &Site) -> Result<(InputSchema, bool
}

pub struct ManifestInfo {
pub description: Option<String>,
pub repository: Option<String>,
pub spec_version: String,
pub instrument: bool,
}

impl ManifestInfo {
pub fn load(conn: &mut PgConnection, site: &Site) -> Result<ManifestInfo, StoreError> {
use subgraph_manifest as sm;
let (description, repository, spec_version, features): (
Option<String>,
Option<String>,
String,
Vec<String>,
) = sm::table
.select((
sm::description,
sm::repository,
sm::spec_version,
sm::features,
))
let (spec_version, features): (String, Vec<String>) = sm::table
.select((sm::spec_version, sm::features))
.filter(sm::id.eq(site.id))
.first(conn)?;

Expand All @@ -348,8 +336,6 @@ impl ManifestInfo {
let instrument = features.iter().any(|s| s == "instrument");

Ok(ManifestInfo {
description,
repository,
spec_version,
instrument,
})
Expand Down
4 changes: 0 additions & 4 deletions store/postgres/src/deployment_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ pub(crate) struct SubgraphInfo {
/// The deployment hash of the remote subgraph whose store
/// will be GraphQL queried, for debugging purposes.
pub(crate) debug_fork: Option<DeploymentHash>,
pub(crate) description: Option<String>,
pub(crate) repository: Option<String>,
pub(crate) poi_version: ProofOfIndexingVersion,
pub(crate) instrument: bool,
}
Expand Down Expand Up @@ -499,8 +497,6 @@ impl DeploymentStore {
api,
graft_block,
debug_fork,
description: manifest_info.description,
repository: manifest_info.repository,
poi_version,
instrument: manifest_info.instrument,
};
Expand Down
1 change: 1 addition & 0 deletions store/postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pub mod layout_for_tests {
make_dummy_site, Connection, Mirror, Namespace, EVENT_TAP, EVENT_TAP_ENABLED,
};
pub use crate::relational::*;
pub use crate::store::VersionInfo;
pub mod writable {
pub use crate::writable::test_support::allow_steps;
}
Expand Down
15 changes: 7 additions & 8 deletions store/postgres/src/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,12 @@ pub fn make_dummy_site(deployment: DeploymentHash, namespace: Namespace, network
/// read-only
mod queries {
use diesel::data_types::PgTimestamp;
use diesel::dsl::{exists, sql};
use diesel::dsl::exists;
use diesel::pg::PgConnection;
use diesel::prelude::{
ExpressionMethods, JoinOnDsl, NullableExpressionMethods, OptionalExtension, QueryDsl,
RunQueryDsl,
};
use diesel::sql_types::Text;
use graph::prelude::NodeId;
use graph::{
components::store::DeploymentId as GraphDeploymentId,
Expand Down Expand Up @@ -714,14 +713,14 @@ mod queries {
.transpose()
}

pub(super) fn version_info(
pub(super) fn deployment_for_version(
conn: &mut PgConnection,
version: &str,
) -> Result<Option<(String, String)>, StoreError> {
) -> Result<Option<String>, StoreError> {
Ok(v::table
.select((v::deployment, sql::<Text>("created_at::text")))
.select(v::deployment)
.filter(v::id.eq(version))
.first::<(String, String)>(conn)
.first::<String>(conn)
.optional()?)
}
}
Expand Down Expand Up @@ -2075,8 +2074,8 @@ impl Mirror {
self.read(|conn| queries::fill_assignments(conn, infos))
}

pub fn version_info(&self, version: &str) -> Result<Option<(String, String)>, StoreError> {
self.read(|conn| queries::version_info(conn, version))
pub fn deployment_for_version(&self, version: &str) -> Result<Option<String>, StoreError> {
self.read(|conn| queries::deployment_for_version(conn, version))
}

pub fn find_site_in_shard(
Expand Down
21 changes: 12 additions & 9 deletions store/postgres/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@ use async_trait::async_trait;
use std::sync::Arc;

use graph::{
components::{
server::index_node::VersionInfo,
store::{
BlockPtrForNumber, BlockStore as BlockStoreTrait, QueryPermit, QueryStoreManager,
StatusStore, Store as StoreTrait,
},
components::store::{
BlockPtrForNumber, BlockStore as BlockStoreTrait, QueryPermit, QueryStoreManager,
StatusStore, Store as StoreTrait,
},
data::subgraph::status,
internal_error,
Expand All @@ -19,6 +16,14 @@ use graph::{

use crate::{block_store::BlockStore, query_store::QueryStore, SubgraphStore};

/// This is only needed for some tests
#[derive(Debug)]
pub struct VersionInfo {
pub deployment_id: String,
pub latest_ethereum_block_number: Option<BlockNumber>,
pub failed: bool,
}

/// The overall store of the system, consisting of a [`SubgraphStore`] and a
/// [`BlockStore`], each of which multiplex across multiple database shards.
/// The `SubgraphStore` is responsible for storing all data and metadata related
Expand Down Expand Up @@ -52,9 +57,7 @@ impl Store {
}

pub fn version_info(&self, version_id: &str) -> Result<VersionInfo, StoreError> {
let mut info = self.subgraph_store.version_info(version_id)?;

info.total_ethereum_blocks_count = self.block_store.chain_head_block(&info.network)?;
let info = self.subgraph_store.version_info(version_id)?;

Ok(info)
}
Expand Down
22 changes: 5 additions & 17 deletions store/postgres/src/subgraph_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@ use std::{iter::FromIterator, time::Duration};
use graph::futures03::future::join_all;
use graph::{
cheap_clone::CheapClone,
components::{
server::index_node::VersionInfo,
store::{
self, BlockPtrForNumber, BlockStore, DeploymentLocator, EnsLookup as EnsLookupTrait,
PruneReporter, PruneRequest, SubgraphFork,
},
components::store::{
self, BlockPtrForNumber, BlockStore, DeploymentLocator, EnsLookup as EnsLookupTrait,
PruneReporter, PruneRequest, SubgraphFork,
},
data::query::QueryTarget,
data::subgraph::{schema::DeploymentCreate, status, DeploymentFeatures},
Expand All @@ -44,6 +41,7 @@ use crate::{
index::{IndexList, Method},
Layout,
},
store::VersionInfo,
writable::{SourceableStore, WritableStore},
ConnectionPool, NotificationSender,
};
Expand Down Expand Up @@ -981,7 +979,7 @@ impl SubgraphStoreInner {
}

pub(crate) fn version_info(&self, version: &str) -> Result<VersionInfo, StoreError> {
if let Some((deployment_id, created_at)) = self.mirror.version_info(version)? {
if let Some(deployment_id) = self.mirror.deployment_for_version(version)? {
let id = DeploymentHash::new(deployment_id.clone())
.map_err(|id| internal_error!("illegal deployment id {}", id))?;
let (store, site) = self.store(&id)?;
Expand All @@ -995,21 +993,11 @@ impl SubgraphStoreInner {
.ok_or_else(|| internal_error!("no chain info for {}", deployment_id))?;
let latest_ethereum_block_number =
chain.latest_block.as_ref().map(|block| block.number());
let subgraph_info = store.subgraph_info(site.cheap_clone())?;
let layout = store.find_layout(site.cheap_clone())?;
let network = site.network.clone();

let info = VersionInfo {
created_at,
deployment_id,
latest_ethereum_block_number,
total_ethereum_blocks_count: None,
synced: status.synced,
failed: status.health.is_failed(),
description: subgraph_info.description,
repository: subgraph_info.repository,
schema: layout.input_schema.cheap_clone(),
network,
};
Ok(info)
} else {
Expand Down
49 changes: 2 additions & 47 deletions store/test-store/tests/postgres/subgraph.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use graph::futures03;
use graph::{
components::{
server::index_node::VersionInfo,
store::{DeploymentId, DeploymentLocator, StatusStore},
},
components::store::{DeploymentId, DeploymentLocator, StatusStore},
data::query::QueryTarget,
data::subgraph::{schema::SubgraphHealth, SubgraphFeature},
data::subgraph::{
Expand All @@ -22,7 +19,7 @@ use graph::{
schema::InputSchema,
semver::Version,
};
use graph_store_postgres::layout_for_tests::Connection as Primary;
use graph_store_postgres::layout_for_tests::{Connection as Primary, VersionInfo};
use graph_store_postgres::SubgraphStore;
use std::{collections::HashSet, marker::PhantomData, sync::Arc};
use test_store::*;
Expand Down Expand Up @@ -473,48 +470,6 @@ fn status() {
})
}

#[test]
fn version_info() {
const NAME: &str = "versionInfoSubgraph";

async fn setup() -> DeploymentLocator {
let id = DeploymentHash::new(NAME).unwrap();
remove_subgraphs();
block_store::set_chain(vec![], NETWORK_NAME).await;
create_test_subgraph(&id, SUBGRAPH_GQL).await
}

run_test_sequentially(|store| async move {
let deployment = setup().await;
transact_and_wait(
&store.subgraph_store(),
&deployment,
BLOCK_ONE.clone(),
vec![],
)
.await
.unwrap();

let vi = get_version_info(&store, NAME);
assert_eq!(NAME, vi.deployment_id.as_str());
assert_eq!(false, vi.synced);
assert_eq!(false, vi.failed);
assert_eq!(
Some("manifest for versionInfoSubgraph"),
vi.description.as_deref()
);
assert_eq!(
Some("repo for versionInfoSubgraph"),
vi.repository.as_deref()
);
assert_eq!(NAME, vi.schema.id().as_str());
assert_eq!(Some(1), vi.latest_ethereum_block_number);
assert_eq!(NETWORK_NAME, vi.network.as_str());
// We set the head for the network to null in the test framework
assert_eq!(None, vi.total_ethereum_blocks_count);
})
}

#[test]
fn subgraph_features() {
run_test_sequentially(|_store| async move {
Expand Down
Loading