Skip to content

Commit

Permalink
chore: use thegraph-headers graph-attestation http header (#1007)
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Delgado <[email protected]>
  • Loading branch information
LNSD authored Dec 9, 2024
1 parent b365977 commit 85ef06e
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 279 deletions.
14 changes: 14 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ thegraph-core = { version = "0.9.0", features = [
"serde",
] }
thegraph-graphql-http = { version = "0.3.2", features = ["reqwest"] }
thegraph-headers = { version = "0.1.0", features = ["attestation"] }
thiserror = "2.0.2"
tokio = { version = "1.38.0", features = [
"macros",
Expand Down
33 changes: 20 additions & 13 deletions src/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ use rand::{thread_rng, Rng as _};
use serde::Deserialize;
use serde_json::value::RawValue;
use thegraph_core::{alloy::primitives::BlockNumber, AllocationId, DeploymentId, IndexerId};
use thegraph_headers::{graph_attestation::GraphAttestation, HttpBuilderExt as _};
use tokio::sync::mpsc;
use tracing::{info_span, Instrument as _};
use url::Url;

use self::{attestation_header::GraphAttestation, context::Context, query_selector::QuerySelector};
use self::{context::Context, query_selector::QuerySelector};
use crate::{
auth::AuthSettings,
block_constraints::{resolve_block_requirements, rewrite_query, BlockRequirements},
budgets::USD,
errors::{Error, IndexerError, IndexerErrors, MissingBlockError, UnavailableReason},
http_ext::HttpBuilderExt as _,
indexer_client::{IndexerAuth, IndexerResponse},
indexing_performance,
metrics::{with_metric, METRICS},
Expand All @@ -40,7 +40,6 @@ use crate::{
reports,
};

mod attestation_header;
pub mod context;
mod query_selector;

Expand Down Expand Up @@ -104,12 +103,16 @@ pub async fn handle_query(
attestation,
..
}| {
Response::builder()
let mut builder = Response::builder()
.status(StatusCode::OK)
.header_typed(ContentType::json())
.header_typed(GraphAttestation(attestation))
.body(client_response)
.unwrap()
.header_typed(ContentType::json());

// Add attestation header if present
if let Some(attestation) = attestation {
builder = builder.header_typed(GraphAttestation(attestation));
}

builder.body(client_response).expect("valid response")
},
)
}
Expand Down Expand Up @@ -769,12 +772,16 @@ pub async fn handle_indexer_query(
attestation,
..
}| {
Response::builder()
let mut builder = Response::builder()
.status(StatusCode::OK)
.header_typed(ContentType::json())
.header_typed(GraphAttestation(attestation))
.body(client_response)
.unwrap()
.header_typed(ContentType::json());

// Add attestation header if present
if let Some(attestation) = attestation {
builder = builder.header_typed(GraphAttestation(attestation));
}

builder.body(client_response).expect("valid response")
},
)
}
Expand Down
238 changes: 0 additions & 238 deletions src/client_query/attestation_header.rs

This file was deleted.

3 changes: 1 addition & 2 deletions src/graphql.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use axum::http::{Response, StatusCode};
use headers::ContentType;
use thegraph_graphql_http::http::response::{IntoError as IntoGraphqlResponseError, ResponseBody};

use crate::http_ext::HttpBuilderExt as _;
use thegraph_headers::HttpBuilderExt as _;

/// Serialize an error into a GraphQL error response.
///
Expand Down
25 changes: 0 additions & 25 deletions src/http_ext.rs

This file was deleted.

1 change: 0 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ mod config;
mod errors;
mod exchange_rate;
mod graphql;
mod http_ext;
mod indexer_client;
mod indexing_performance;
mod metrics;
Expand Down

0 comments on commit 85ef06e

Please sign in to comment.