Skip to content

Commit 5f5e7f6

Browse files
authored
Gusinacio/bump axum reqwest (#151)
* chore: bump axum to 0.7.0, reqwest to 0.12 and deps Signed-off-by: Gustavo Inacio <[email protected]> * chore: use crates.io for thegraph-graphql-http Signed-off-by: Gustavo Inacio <[email protected]> * chore: remove comment Signed-off-by: Gustavo Inacio <[email protected]> * fix: use expect to bind to ports Signed-off-by: Gustavo Inacio <[email protected]> --------- Signed-off-by: Gustavo Inacio <[email protected]>
1 parent 3f02ff4 commit 5f5e7f6

File tree

10 files changed

+526
-352
lines changed

10 files changed

+526
-352
lines changed

Cargo.lock

Lines changed: 462 additions & 280 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/Cargo.toml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,33 @@ lru = "0.11.1"
1818
once_cell = "1.17"
1919
prometheus = "0.13.3"
2020
regex = "1.7.1"
21-
reqwest = "0.11.20"
21+
reqwest = "0.12"
2222
secp256k1 = { version = "0.28.0", features = ["recovery"] }
2323
serde = { version = "1.0.188", features = ["derive"] }
2424
serde_json = { version = "1.0.107", features = ["arbitrary_precision"] }
2525
sqlx = { version = "0.7.1", features = [
26-
"postgres",
27-
"runtime-tokio",
28-
"bigdecimal",
29-
"rust_decimal",
30-
"time",
26+
"postgres",
27+
"runtime-tokio",
28+
"bigdecimal",
29+
"rust_decimal",
30+
"time",
3131
] }
3232
tokio = { version = "1.32.0", features = ["full", "macros", "rt"] }
3333
thegraph = { git = "https://github.com/edgeandnode/toolshed", tag = "thegraph-v0.5.0" }
34-
graphql-http = { git = "https://github.com/edgeandnode/toolshed", tag = "graphql-http-v0.2.1", features = [
35-
"http-reqwest",
34+
thegraph-graphql-http = { version = "0.2.0", features = [
35+
"http-client-reqwest",
3636
] }
3737
tap_core = "0.8.0"
38-
axum = { version = "0.6.20", default_features = true, features = ["headers"] }
38+
axum = { version = "0.7.5", default_features = true }
39+
axum-extra = { version = "0.9.3", features = ["typed-header"] }
3940
thiserror = "1.0.49"
4041
async-trait = "0.1.74"
41-
headers-derive = "0.1.1"
42-
headers = "0.3.9"
4342
build-info = "0.0.34"
44-
autometrics = { version = "0.6.0", features = ["prometheus-exporter"] }
43+
autometrics = { version = "1.0.1", features = ["prometheus-exporter"] }
4544
tracing = "0.1.40"
4645
tower = "0.4.13"
47-
tower_governor = "0.1.0"
48-
tower-http = { version = "0.4.4", features = ["trace"] }
46+
tower_governor = "0.3.2"
47+
tower-http = { version = "0.5.2", features = ["trace"] }
4948
tokio-util = "0.7.10"
5049
bigdecimal = "0.4.2"
5150

common/src/indexer_service/http/indexer_service.rs

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@ use anyhow;
1111
use autometrics::prometheus_exporter;
1212
use axum::extract::MatchedPath;
1313
use axum::http::Request;
14+
use axum::serve;
1415
use axum::{
1516
async_trait,
16-
body::Body,
17-
error_handling::HandleErrorLayer,
1817
response::{IntoResponse, Response},
1918
routing::{get, post},
20-
BoxError, Extension, Json, Router, Server,
19+
Extension, Json, Router,
2120
};
2221
use build_info::BuildInfo;
2322
use eventuals::Eventual;
@@ -28,9 +27,9 @@ use tap_core::{manager::Manager, receipt::checks::Checks};
2827
use thegraph::types::Address;
2928
use thegraph::types::{Attestation, DeploymentId};
3029
use thiserror::Error;
30+
use tokio::net::TcpListener;
3131
use tokio::signal;
32-
use tower::ServiceBuilder;
33-
use tower_governor::{errors::display_error, governor::GovernorConfigBuilder, GovernorLayer};
32+
use tower_governor::{governor::GovernorConfigBuilder, GovernorLayer};
3433
use tower_http::trace::TraceLayer;
3534
use tracing::{info, info_span};
3635

@@ -167,7 +166,7 @@ where
167166
pub release: IndexerServiceRelease,
168167
pub url_namespace: &'static str,
169168
pub metrics_prefix: &'static str,
170-
pub extra_routes: Router<Arc<IndexerServiceState<I>>, Body>,
169+
pub extra_routes: Router<Arc<IndexerServiceState<I>>>,
171170
}
172171

173172
pub struct IndexerServiceState<I>
@@ -329,13 +328,7 @@ impl IndexerService {
329328
.route("/", get("Service is up and running"))
330329
.route("/version", get(Json(options.release)))
331330
.route("/info", get(operator_address))
332-
.layer(
333-
ServiceBuilder::new()
334-
.layer(HandleErrorLayer::new(|e: BoxError| async move {
335-
display_error(e)
336-
}))
337-
.layer(misc_rate_limiter),
338-
);
331+
.layer(misc_rate_limiter);
339332

340333
// Rate limits by allowing bursts of 50 requests and requiring 20ms of
341334
// time between consecutive requests after that, effectively rate
@@ -360,13 +353,7 @@ impl IndexerService {
360353
.route_layer(Extension(
361354
options.config.network_subgraph.serve_auth_token.clone(),
362355
))
363-
.route_layer(
364-
ServiceBuilder::new()
365-
.layer(HandleErrorLayer::new(|e: BoxError| async move {
366-
display_error(e)
367-
}))
368-
.layer(static_subgraph_rate_limiter.clone()),
369-
),
356+
.route_layer(static_subgraph_rate_limiter.clone()),
370357
);
371358
}
372359

@@ -379,13 +366,7 @@ impl IndexerService {
379366
.route_layer(Extension(
380367
options.config.escrow_subgraph.serve_auth_token.clone(),
381368
))
382-
.route_layer(
383-
ServiceBuilder::new()
384-
.layer(HandleErrorLayer::new(|e: BoxError| async move {
385-
display_error(e)
386-
}))
387-
.layer(static_subgraph_rate_limiter),
388-
);
369+
.route_layer(static_subgraph_rate_limiter);
389370
}
390371

391372
misc_routes = misc_routes.with_state(state.clone());
@@ -435,11 +416,16 @@ impl IndexerService {
435416
address = %options.config.server.host_and_port,
436417
"Serving requests",
437418
);
419+
let listener = TcpListener::bind(&options.config.server.host_and_port)
420+
.await
421+
.expect("Failed to bind to indexer-service port");
438422

439-
Ok(Server::bind(&options.config.server.host_and_port)
440-
.serve(router.into_make_service_with_connect_info::<SocketAddr>())
441-
.with_graceful_shutdown(shutdown_signal())
442-
.await?)
423+
Ok(serve(
424+
listener,
425+
router.into_make_service_with_connect_info::<SocketAddr>(),
426+
)
427+
.with_graceful_shutdown(shutdown_signal())
428+
.await?)
443429
}
444430

445431
fn serve_metrics(host_and_port: SocketAddr) {
@@ -451,10 +437,14 @@ impl IndexerService {
451437
get(|| async { prometheus_exporter::encode_http_response() }),
452438
);
453439

454-
Server::bind(&host_and_port)
455-
.serve(router.into_make_service())
456-
.await
457-
.expect("Failed to serve metrics")
440+
serve(
441+
TcpListener::bind(host_and_port)
442+
.await
443+
.expect("Failed to bind to metrics port"),
444+
router.into_make_service(),
445+
)
446+
.await
447+
.expect("Failed to serve metrics")
458448
});
459449
}
460450
}

common/src/indexer_service/http/request_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use axum::{
88
extract::{Path, State},
99
http::HeaderMap,
1010
response::IntoResponse,
11-
TypedHeader,
1211
};
12+
use axum_extra::TypedHeader;
1313
use reqwest::StatusCode;
1414
use thegraph::types::DeploymentId;
1515
use tracing::trace;

common/src/indexer_service/http/scalar_receipt_header.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use std::ops::Deref;
55

6-
use headers::{Header, HeaderName, HeaderValue};
6+
use axum_extra::headers::{self, Header, HeaderName, HeaderValue};
77
use lazy_static::lazy_static;
88
use tap_core::receipt::SignedReceipt;
99

@@ -61,7 +61,8 @@ impl Header for ScalarReceipt {
6161
mod test {
6262
use std::str::FromStr;
6363

64-
use axum::{headers::Header, http::HeaderValue};
64+
use axum::http::HeaderValue;
65+
use axum_extra::headers::Header;
6566
use thegraph::types::Address;
6667

6768
use crate::test_vectors::create_signed_receipt;

common/src/subgraph_client/client.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
use anyhow::anyhow;
55
use axum::body::Bytes;
66
use eventuals::Eventual;
7-
use graphql_http::{
8-
graphql::{Document, IntoDocument},
9-
http::request::{IntoRequestParameters, RequestParameters},
10-
http_client::{ReqwestExt, ResponseResult},
11-
};
127
use reqwest::{header, Url};
138
use serde::de::Deserialize;
149
use serde_json::{Map, Value};
1510
use thegraph::types::DeploymentId;
11+
use thegraph_graphql_http::{
12+
graphql::{Document, IntoDocument},
13+
http::request::{IntoRequestParameters, RequestParameters},
14+
http_client::{ReqwestExt, ResponseResult},
15+
};
1616
use tracing::warn;
1717

1818
use super::monitor::{monitor_deployment_status, DeploymentStatus};

common/src/subgraph_client/monitor.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
use std::time::Duration;
55

66
use eventuals::{timer, Eventual, EventualExt};
7-
use graphql_http::{
8-
http::request::IntoRequestParameters,
9-
http_client::{ReqwestExt, ResponseResult},
10-
};
117
use reqwest::Url;
128
use serde::Deserialize;
139
use serde_json::json;
1410
use thegraph::types::DeploymentId;
11+
use thegraph_graphql_http::{
12+
http::request::IntoRequestParameters,
13+
http_client::{ReqwestExt, ResponseResult},
14+
};
1515
use tokio::time::sleep;
1616
use tracing::warn;
1717

service/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ eventuals = "0.6.7"
1515
dotenvy = "0.15"
1616
log = "0.4.17"
1717
anyhow = "1.0.57"
18-
reqwest = "0.11.10"
18+
reqwest = { version = "0.12", features = ["json"] }
1919
tokio = { version = "1", features = ["rt", "macros", "sync", "full"] }
2020
tracing = "0.1.34"
2121
thiserror = "1.0.49"
2222
serde = { version = "1.0", features = ["rc", "derive"] }
2323
serde_json = "1"
24-
axum = "0.6.20"
24+
axum = "0.7.5"
2525
hyper = "0.14.27"
2626
tower = { version = "0.4", features = ["util", "timeout", "limit"] }
2727
tower-http = { version = "0.4.0", features = [
@@ -30,8 +30,8 @@ tower-http = { version = "0.4.0", features = [
3030
"cors",
3131
] }
3232
once_cell = "1.17"
33-
async-graphql = "6.0.11"
34-
async-graphql-axum = "6.0.11"
33+
async-graphql = "7.0.3"
34+
async-graphql-axum = "7.0.3"
3535
sha3 = "0.10.6"
3636
tracing-subscriber = { version = "0.3", features = [
3737
"env-filter",
@@ -58,8 +58,8 @@ alloy-sol-types = "0.6"
5858
lazy_static = "1.4.0"
5959
thegraph = { git = "https://github.com/edgeandnode/toolshed", tag = "thegraph-v0.5.0" }
6060
graphql = { git = "https://github.com/edgeandnode/toolshed", tag = "graphql-v0.3.0" }
61-
graphql-http = { git = "https://github.com/edgeandnode/toolshed", tag = "graphql-http-v0.2.1", features = [
62-
"http-reqwest",
61+
thegraph-graphql-http = { version = "0.2.0", features = [
62+
"http-client-reqwest",
6363
] }
6464
build-info = "0.0.34"
6565
figment = { version = "0.10", features = ["toml", "env"] }

service/src/routes/status.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ use std::sync::Arc;
77
use async_graphql_axum::GraphQLRequest;
88
use axum::{extract::State, response::IntoResponse, Json};
99
use graphql::graphql_parser::query as q;
10-
use graphql_http::{
10+
use serde_json::{json, Map, Value};
11+
use thegraph_graphql_http::{
1112
http::request::{IntoRequestParameters, RequestParameters},
1213
http_client::{ReqwestExt, ResponseError},
1314
};
14-
use serde_json::{json, Map, Value};
1515

1616
use crate::{SubgraphServiceError, SubgraphServiceState};
1717

tap-agent/Cargo.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ eventuals = "0.6.7"
2222
indexer-common = { version = "0.1.0", path = "../common" }
2323
jsonrpsee = { version = "0.20.2", features = ["http-client", "macros"] }
2424
lazy_static = "1.4.0"
25-
reqwest = "0.11.20"
25+
reqwest = "0.12"
2626
serde = "1.0.188"
2727
serde_json = "1.0.104"
2828
serde_yaml = "0.9.25"
@@ -38,7 +38,9 @@ tap_core = "0.8.0"
3838
thiserror = "1.0.44"
3939
tokio = { version = "1.33.0" }
4040
thegraph = { git = "https://github.com/edgeandnode/toolshed", tag = "thegraph-v0.5.0" }
41-
graphql-http = { git = "https://github.com/edgeandnode/toolshed", tag = "graphql-http-v0.2.1" }
41+
thegraph-graphql-http = { version = "0.2.0", features = [
42+
"http-client-reqwest",
43+
] }
4244
tracing = "0.1.37"
4345
tracing-subscriber = { version = "0.3", features = [
4446
"env-filter",
@@ -48,7 +50,7 @@ tracing-subscriber = { version = "0.3", features = [
4850
"json",
4951
] }
5052
enum-as-inner = "0.6.0"
51-
ethers = "2.0.13"
53+
ethers = "2.0.14"
5254
typetag = "0.2.14"
5355
ractor = "0.9.7"
5456

0 commit comments

Comments
 (0)