Skip to content

Commit

Permalink
chore(deps): use thegraph dependency types and subgraph client (#439)
Browse files Browse the repository at this point in the history
This PR moves the gateway from using the `thegraph` types instead of the
`toolshed::thegraph`.
  • Loading branch information
LNSD authored Nov 28, 2023
1 parent 24c7d92 commit 7afe189
Show file tree
Hide file tree
Showing 36 changed files with 68 additions and 683 deletions.
32 changes: 28 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ tokio = { version = "1.24", features = [
"sync",
"time",
] }
toolshed = { git = "https://github.com/edgeandnode/toolshed", tag = "v0.3.0" }
toolshed = { git = "https://github.com/edgeandnode/toolshed", tag = "v0.4.0" }
thegraph = { git = "https://github.com/edgeandnode/toolshed", tag = "thegraph-v0.1.1" }
tracing = { version = "0.1", default-features = false }
1 change: 1 addition & 0 deletions graph-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ serde_with = "3.1"
serde_yaml = "0.9"
simple-rate-limiter = "1.0"
tap_core = { git = "https://github.com/semiotic-ai/timeline-aggregation-protocol", rev = "e55ea03" }
thegraph = { workspace = true, features = ["subgraph-client"] }
thiserror = "1.0.40"
tokio.workspace = true
toolshed.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use anyhow::{anyhow, bail, ensure, Result};
use eventuals::{Eventual, EventualExt, Ptr};
use graph_subscriptions::TicketPayload;
use prelude::USD;
use thegraph::types::{DeploymentId, SubgraphId};
use tokio::sync::RwLock;
use toolshed::thegraph::{DeploymentId, SubgraphId};

use crate::subgraph_studio::{APIKey, QueryStatus};
use crate::subscriptions::Subscription;
Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/block_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use graphql::{IntoStaticValue as _, StaticValue};
use indexer_selection::UnresolvedBlock;
use itertools::Itertools as _;
use serde_json::{self, json};
use toolshed::thegraph::BlockPointer;
use thegraph::types::BlockPointer;

#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub enum BlockConstraint {
Expand Down
3 changes: 2 additions & 1 deletion graph-gateway/src/chains/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use alloy_primitives::BlockHash;
use indexer_selection::UnresolvedBlock;
use serde::{de::Error, Deserialize, Deserializer};
use serde_json::{json, Value as JSON};
use thegraph::types::BlockPointer;
use tokio::sync::mpsc;
use tokio::time::interval;
use toolshed::{thegraph::BlockPointer, url::Url};
use toolshed::url::Url;
use tracing::Instrument;

use super::{BlockHead, ClientMsg};
Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/chains/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use alloy_primitives::{BlockHash, BlockNumber};
use eventuals::{Eventual, EventualWriter};
use indexer_selection::UnresolvedBlock;
use prelude::epoch_cache::EpochCache;
use thegraph::types::BlockPointer;
use tokio::sync::{mpsc, oneshot};
use tokio::time::interval;
use toolshed::thegraph::BlockPointer;
use tracing::Instrument;

use crate::{block_constraints::*, metrics::*};
Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/chains/test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::time::Duration;

use indexer_selection::UnresolvedBlock;
use thegraph::types::BlockPointer;
use tokio::sync::mpsc;
use toolshed::thegraph::BlockPointer;

use crate::chains::BlockHead;

Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ use rand::{rngs::SmallRng, SeedableRng as _};
use serde::Deserialize;
use serde_json::json;
use serde_json::value::RawValue;
use thegraph::types::{attestation, BlockPointer, DeploymentId, SubgraphId};
use tokio::sync::mpsc;
use toolshed::thegraph::{attestation, BlockPointer, DeploymentId, SubgraphId};
use toolshed::url::Url;
use tracing::Instrument;
use uuid::Uuid;
Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/indexer_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloy_primitives::BlockNumber;
use axum::http::StatusCode;
use indexer_selection::Selection;
use serde::Deserialize;
use toolshed::thegraph::attestation::Attestation;
use thegraph::types::attestation::Attestation;

use crate::receipts::{ReceiptSigner, ReceiptStatus, ScalarReceipt};

Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/indexers_status/cost_models/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use graphql_http::graphql::{Document, IntoDocument, IntoDocumentWithVariables};
use indoc::indoc;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
use toolshed::thegraph::DeploymentId;
use thegraph::types::DeploymentId;

pub(super) const COST_MODEL_QUERY_DOCUMENT: &str = indoc! {
r#"query ($deployments: [String!]!) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::borrow::Cow;
use alloy_primitives::BlockHash;
use indoc::indoc;
use serde::{Deserialize, Deserializer};
use toolshed::thegraph::DeploymentId;
use thegraph::types::DeploymentId;

pub(super) const INDEXING_STATUSES_QUERY_DOCUMENT: &str = indoc! {
r#"{
Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/indexers_status/public_poi/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::HashMap;
use alloy_primitives::BlockNumber;
use graphql_http::http_client::ReqwestExt;
use itertools::Itertools;
use toolshed::thegraph::DeploymentId;
use thegraph::types::DeploymentId;
use toolshed::url::Url;

use crate::indexers_status::public_poi::query;
Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/indexers_status/public_poi/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use graphql_http::graphql::{Document, IntoDocument, IntoDocumentWithVariables};
use indoc::indoc;
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
use toolshed::thegraph::DeploymentId;
use thegraph::types::DeploymentId;

pub const MAX_REQUESTS_PER_QUERY: usize = 10;

Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use futures::future::join_all;
use indexer_selection::Indexing;
use prelude::epoch_cache::EpochCache;
use semver::Version;
use thegraph::types::{BlockPointer, DeploymentId};
use tokio::sync::Mutex;
use toolshed::thegraph::{BlockPointer, DeploymentId};
use toolshed::url::{url::Host, Url};
use trust_dns_resolver::TokioAsyncResolver as DNSResolver;

Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/indexings_blocklist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::time::Duration;

use alloy_primitives::Address;
use itertools::Itertools;
use thegraph::types::DeploymentId;
use tokio::sync::Mutex;
use toolshed::thegraph::DeploymentId;
use toolshed::url::Url;

use indexer_selection::Indexing;
Expand Down
1 change: 0 additions & 1 deletion graph-gateway/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub mod network_subgraph;
pub mod poi;
pub mod receipts;
pub mod reports;
pub mod subgraph_client;
pub mod subgraph_studio;
pub mod subscriptions;
pub mod subscriptions_subgraph;
Expand Down
9 changes: 5 additions & 4 deletions graph-gateway/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ use axum::{
routing, Router, Server,
};
use eventuals::{Eventual, EventualExt as _, Ptr};
use graph_gateway::budgets::Budgeter;
use graph_subscriptions::subscription_tier::SubscriptionTiers;
use prometheus::{self, Encoder as _};
use secp256k1::SecretKey;
use serde_json::json;
use simple_rate_limiter::RateLimiter;
use thegraph::client as subgraph_client;
use thegraph::types::{attestation, DeploymentId};
use tokio::spawn;
use toolshed::thegraph::{attestation, DeploymentId};
use tower_http::cors::{self, CorsLayer};

use graph_gateway::indexings_blocklist::indexings_blocklist;
use graph_gateway::{
auth::AuthHandler,
budgets::Budgeter,
chains::{ethereum, BlockCache},
client_query,
config::{Config, ExchangeRateProvider},
Expand All @@ -40,13 +42,12 @@ use graph_gateway::{
receipts::ReceiptSigner,
reports,
reports::KafkaClient,
subgraph_client, subgraph_studio, subscriptions_subgraph,
subgraph_studio, subscriptions_subgraph,
topology::{Deployment, GraphNetwork},
vouchers, JsonResponse,
};
use indexer_selection::{actor::Update, BlockStatus, Indexing};
use prelude::{buffer_queue::QueueWriter, *};
use secp256k1::SecretKey;

// Moving the `exchange_rate` module to `lib.rs` makes the doctests to fail during the compilation
// step. This module is only used here, so let's keep it here for now.
Expand Down
5 changes: 2 additions & 3 deletions graph-gateway/src/network_subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use anyhow::anyhow;
use eventuals::{self, Eventual, EventualExt as _, EventualWriter, Ptr};
use prelude::*;
use serde::Deserialize;
use thegraph::client as subgraph_client;
use thegraph::types::{DeploymentId, SubgraphId};
use tokio::sync::Mutex;
use toolshed::thegraph::{DeploymentId, SubgraphId};

use crate::subgraph_client;

pub struct Data {
pub network_params: NetworkParams,
Expand Down
2 changes: 1 addition & 1 deletion graph-gateway/src/poi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use alloy_primitives::{BlockNumber, B256};
use toolshed::thegraph::DeploymentId;
use thegraph::types::DeploymentId;

pub type ProofOfIndexing = B256;

Expand Down
3 changes: 2 additions & 1 deletion graph-gateway/src/reports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use prost::Message as _;
use rdkafka::error::KafkaResult;
use serde::Deserialize;
use serde_json::{json, Map};
use toolshed::{concat_bytes, thegraph::attestation::Attestation};
use thegraph::types::attestation::Attestation;
use toolshed::concat_bytes;
use tracing::span;
use tracing_subscriber::{filter::FilterFn, layer, prelude::*, registry, EnvFilter, Layer};

Expand Down
4 changes: 0 additions & 4 deletions graph-gateway/src/subgraph_client.rs

This file was deleted.

Loading

0 comments on commit 7afe189

Please sign in to comment.