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
Next Next commit
graph: Remove unneeded methods from StatusStore trait
  • Loading branch information
lutter committed May 13, 2025
commit a383f5e440ffc122ae4978823798f66e5b58d8f5
20 changes: 0 additions & 20 deletions graph/src/components/store/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use super::*;
use crate::blockchain::block_stream::{EntitySourceOperation, FirehoseCursor};
use crate::blockchain::{BlockTime, ChainIdentifier, ExtendedBlockPtr};
use crate::components::metrics::stopwatch::StopwatchMetrics;
use crate::components::server::index_node::VersionInfo;
use crate::components::subgraph::SubgraphVersionSwitchingMode;
use crate::components::transaction_receipt;
use crate::components::versions::ApiVersion;
Expand Down Expand Up @@ -687,25 +686,6 @@ pub trait StatusStore: Send + Sync + 'static {

fn status(&self, filter: status::Filter) -> Result<Vec<status::Info>, StoreError>;

/// Support for the explorer-specific API
fn version_info(&self, version_id: &str) -> Result<VersionInfo, StoreError>;

/// Support for the explorer-specific API; note that `subgraph_id` must be
/// the id of an entry in `subgraphs.subgraph`, not that of a deployment.
/// The return values are the ids of the `subgraphs.subgraph_version` for
/// the current and pending versions of the subgraph
fn versions_for_subgraph_id(
&self,
subgraph_id: &str,
) -> Result<(Option<String>, Option<String>), StoreError>;

/// Support for the explorer-specific API. Returns a vector of (name, version) of all
/// subgraphs for a given deployment hash.
fn subgraphs_for_deployment_hash(
&self,
deployment_hash: &str,
) -> Result<Vec<(String, String)>, StoreError>;

/// A value of None indicates that the table is not available. Re-deploying
/// the subgraph fixes this. It is undesirable to force everything to
/// re-sync from scratch, so existing deployments will continue without a
Expand Down
57 changes: 2 additions & 55 deletions store/postgres/src/primary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ mod queries {
use diesel::dsl::{exists, sql};
use diesel::pg::PgConnection;
use diesel::prelude::{
BoolExpressionMethods, ExpressionMethods, JoinOnDsl, NullableExpressionMethods,
OptionalExtension, QueryDsl, RunQueryDsl,
ExpressionMethods, JoinOnDsl, NullableExpressionMethods, OptionalExtension, QueryDsl,
RunQueryDsl,
};
use diesel::sql_types::Text;
use graph::prelude::NodeId;
Expand Down Expand Up @@ -724,44 +724,6 @@ mod queries {
.first::<(String, String)>(conn)
.optional()?)
}

pub(super) fn versions_for_subgraph_id(
conn: &mut PgConnection,
subgraph_id: &str,
) -> Result<(Option<String>, Option<String>), StoreError> {
Ok(s::table
.select((s::current_version.nullable(), s::pending_version.nullable()))
.filter(s::id.eq(subgraph_id))
.first::<(Option<String>, Option<String>)>(conn)
.optional()?
.unwrap_or((None, None)))
}

/// Returns all (subgraph_name, version) pairs for a given deployment hash.
pub fn subgraphs_by_deployment_hash(
conn: &mut PgConnection,
deployment_hash: &str,
) -> Result<Vec<(String, String)>, StoreError> {
v::table
.inner_join(
s::table.on(v::id
.nullable()
.eq(s::current_version)
.or(v::id.nullable().eq(s::pending_version))),
)
.filter(v::deployment.eq(&deployment_hash))
.select((
s::name,
sql::<Text>(
"(case when subgraphs.subgraph.pending_version = subgraphs.subgraph_version.id then 'pending'
when subgraphs.subgraph.current_version = subgraphs.subgraph_version.id then 'current'
else 'unused'
end) as version",
),
))
.get_results(conn)
.map_err(Into::into)
}
}

/// A wrapper for a database connection that provides access to functionality
Expand Down Expand Up @@ -2117,21 +2079,6 @@ impl Mirror {
self.read(|conn| queries::version_info(conn, version))
}

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

/// Returns all (subgraph_name, version) pairs for a given deployment hash.
pub fn subgraphs_by_deployment_hash(
&self,
deployment_hash: &str,
) -> Result<Vec<(String, String)>, StoreError> {
self.read(|conn| queries::subgraphs_by_deployment_hash(conn, deployment_hash))
}

pub fn find_site_in_shard(
&self,
subgraph: &DeploymentHash,
Expand Down
31 changes: 8 additions & 23 deletions store/postgres/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ impl Store {
pub fn block_store(&self) -> Arc<BlockStore> {
self.block_store.cheap_clone()
}

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)?;

Ok(info)
}
}

impl StoreTrait for Store {
Expand Down Expand Up @@ -117,29 +125,6 @@ impl StatusStore for Store {
Ok(infos)
}

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)?;

Ok(info)
}

fn versions_for_subgraph_id(
&self,
subgraph_id: &str,
) -> Result<(Option<String>, Option<String>), StoreError> {
self.subgraph_store.versions_for_subgraph_id(subgraph_id)
}

fn subgraphs_for_deployment_hash(
&self,
deployment_hash: &str,
) -> Result<Vec<(String, String)>, StoreError> {
self.subgraph_store
.subgraphs_for_deployment_hash(deployment_hash)
}

async fn get_proof_of_indexing(
&self,
subgraph_id: &DeploymentHash,
Expand Down
14 changes: 0 additions & 14 deletions store/postgres/src/subgraph_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1017,20 +1017,6 @@ impl SubgraphStoreInner {
}
}

pub(crate) fn versions_for_subgraph_id(
&self,
subgraph_id: &str,
) -> Result<(Option<String>, Option<String>), StoreError> {
self.mirror.versions_for_subgraph_id(subgraph_id)
}

pub(crate) fn subgraphs_for_deployment_hash(
&self,
deployment_hash: &str,
) -> Result<Vec<(String, String)>, StoreError> {
self.mirror.subgraphs_by_deployment_hash(deployment_hash)
}

#[cfg(debug_assertions)]
pub fn error_count(&self, id: &DeploymentHash) -> Result<usize, StoreError> {
let (store, _) = self.store(id)?;
Expand Down