Skip to content

Commit a8d62bb

Browse files
kodemartinmarc2332
andauthored
fix(core): Update async-graphql, axum and tonic (#6901) (#6969)
# Description of change This patch introduces the necessary changes to restore `graphiql` endpoints. - Updated `async-graphql` to `7.0.17` - Updated `axum` to `0.8` - Updated `tonic` to `0.13` - Updated `tonic-rustls` to `0.2` - Refactored accordingly the codebase ## Type of change - Bug fix (a non-breaking change which fixes an issue) ### Release Notes - [x] GraphQL: Fix graphiql web interface --------- Co-authored-by: Marc Espin <[email protected]>
1 parent 97a0b53 commit a8d62bb

File tree

24 files changed

+291
-152
lines changed

24 files changed

+291
-152
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ anemo-build = { git = "https://github.com/mystenlabs/anemo.git", rev = "c4e7e4cb
216216
anemo-tower = { git = "https://github.com/mystenlabs/anemo.git", rev = "c4e7e4cb4b624d7738c2016d7b7885c6774ff9c2" }
217217
anyhow = "1.0.71"
218218
arc-swap = { version = "1.5.1", features = ["serde"] }
219-
async-graphql = "=7.0.11"
219+
async-graphql = "7.0.17"
220220
async-recursion = "1.0.4"
221221
async-trait = "0.1.61"
222222
aws-config = "1.5.6"
223223
aws-sdk-dynamodb = "1.42"
224-
axum = { version = "0.7", default-features = false, features = ["tokio", "http1", "http2", "json", "matched-path", "original-uri", "form", "query", "ws"] }
225-
axum-extra = { version = "0.9", features = ["typed-header"] }
224+
axum = { version = "0.8", default-features = false, features = ["tokio", "http1", "http2", "json", "matched-path", "original-uri", "form", "query", "ws", "macros"] }
225+
axum-extra = { version = "0.10", features = ["typed-header"] }
226226
axum-server = { git = "https://github.com/bmwill/axum-server.git", rev = "f44323e271afdd1365fd0c8b0a4c0bbdf4956cb7", version = "0.6", default-features = false, features = ["tls-rustls"] }
227227
backoff = { version = "0.4.0", features = ["futures", "futures-core", "pin-project-lite", "tokio", "tokio_1"] }
228228
base64 = "0.21.2"
@@ -346,9 +346,9 @@ tokio-rustls = { version = "0.26", default-features = false, features = ["tls12"
346346
tokio-stream = { version = "0.1.14", features = ["sync", "net"] }
347347
tokio-util = "0.7.10"
348348
toml = { version = "0.7.4", features = ["preserve_order"] }
349-
tonic = { version = "0.12", features = ["zstd", "transport"] }
350-
tonic-build = { version = "0.12", features = ["prost", "transport"] }
351-
tonic-health = "0.12"
349+
tonic = { version = "0.13", features = ["zstd", "transport"] }
350+
tonic-build = { version = "0.13", features = ["prost", "transport"] }
351+
tonic-health = "0.13"
352352
tower = { version = "0.4.12", features = ["full", "util", "timeout", "load-shed", "limit"] }
353353
tower-http = { version = "0.5", features = ["cors", "full", "trace", "set-header", "propagate-header"] }
354354
tracing = "0.1.37"

consensus/core/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ tokio-rustls.workspace = true
4040
tokio-stream.workspace = true
4141
tokio-util.workspace = true
4242
tonic.workspace = true
43-
tonic-rustls = "0.1.0"
43+
tonic-rustls = "0.2.0"
4444
tower.workspace = true
4545
tower-http.workspace = true
4646
tracing.workspace = true

crates/iota-bridge/src/server/mod.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,21 @@ pub const PING_PATH: &str = "/ping";
4444

4545
// Important: for BridgeActions, the paths need to match the ones in
4646
// bridge_client.rs
47-
pub const ETH_TO_IOTA_TX_PATH: &str = "/sign/bridge_tx/eth/iota/:tx_hash/:event_index";
48-
pub const IOTA_TO_ETH_TX_PATH: &str = "/sign/bridge_tx/iota/eth/:tx_digest/:event_index";
47+
pub const ETH_TO_IOTA_TX_PATH: &str = "/sign/bridge_tx/eth/iota/{tx_hash}/{event_index}";
48+
pub const IOTA_TO_ETH_TX_PATH: &str = "/sign/bridge_tx/iota/eth/{tx_digest}/{event_index}";
4949
pub const COMMITTEE_BLOCKLIST_UPDATE_PATH: &str =
50-
"/sign/update_committee_blocklist/:chain_id/:nonce/:type/:keys";
51-
pub const EMERGENCY_BUTTON_PATH: &str = "/sign/emergency_button/:chain_id/:nonce/:type";
50+
"/sign/update_committee_blocklist/{chain_id}/{nonce}/{type}/{keys}";
51+
pub const EMERGENCY_BUTTON_PATH: &str = "/sign/emergency_button/{chain_id}/{nonce}/{type}";
5252
pub const LIMIT_UPDATE_PATH: &str =
53-
"/sign/update_limit/:chain_id/:nonce/:sending_chain_id/:new_usd_limit";
53+
"/sign/update_limit/{chain_id}/{nonce}/{sending_chain_id}/{new_usd_limit}";
5454
pub const ASSET_PRICE_UPDATE_PATH: &str =
55-
"/sign/update_asset_price/:chain_id/:nonce/:token_id/:new_usd_price";
55+
"/sign/update_asset_price/{chain_id}/{nonce}/{token_id}/{new_usd_price}";
5656
pub const EVM_CONTRACT_UPGRADE_PATH_WITH_CALLDATA: &str =
57-
"/sign/upgrade_evm_contract/:chain_id/:nonce/:proxy_address/:new_impl_address/:calldata";
57+
"/sign/upgrade_evm_contract/{chain_id}/{nonce}/{proxy_address}/{new_impl_address}/{calldata}";
5858
pub const EVM_CONTRACT_UPGRADE_PATH: &str =
59-
"/sign/upgrade_evm_contract/:chain_id/:nonce/:proxy_address/:new_impl_address";
60-
pub const ADD_TOKENS_ON_IOTA_PATH: &str =
61-
"/sign/add_tokens_on_iota/:chain_id/:nonce/:native/:token_ids/:token_type_names/:token_prices";
62-
pub const ADD_TOKENS_ON_EVM_PATH: &str = "/sign/add_tokens_on_evm/:chain_id/:nonce/:native/:token_ids/:token_addresses/:token_iota_decimals/:token_prices";
59+
"/sign/upgrade_evm_contract/{chain_id}/{nonce}/{proxy_address}/{new_impl_address}";
60+
pub const ADD_TOKENS_ON_IOTA_PATH: &str = "/sign/add_tokens_on_iota/{chain_id}/{nonce}/{native}/{token_ids}/{token_type_names}/{token_prices}";
61+
pub const ADD_TOKENS_ON_EVM_PATH: &str = "/sign/add_tokens_on_evm/{chain_id}/{nonce}/{native}/{token_ids}/{token_addresses}/{token_iota_decimals}/{token_prices}";
6362

6463
/// BridgeNode's public metadata that is acceesible via the `/ping` endpoint.
6564
// Be careful with what to put here, as it is public.

crates/iota-faucet/src/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub async fn start_faucet(
5757
.route("/", get(health))
5858
.route("/gas", post(request_gas))
5959
.route("/v1/gas", post(batch_request_gas))
60-
.route("/v1/status/:task_id", get(request_status))
60+
.route("/v1/status/{task_id}", get(request_status))
6161
.layer(
6262
ServiceBuilder::new()
6363
.layer(HandleErrorLayer::new(handle_error))

crates/iota-graphql-e2e-tests/tests/call/simple.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ Response: {
115115
task 15, lines 64-69:
116116
//# run-graphql --show-usage --show-headers --show-service-version
117117
Headers: {
118-
"content-type": "application/json",
119-
"content-length": "157",
118+
"content-type": "application/graphql-response+json",
120119
"x-iota-rpc-version": "1.2.0-testing-no-sha",
121120
"vary": "origin, access-control-request-method, access-control-request-headers",
122121
"access-control-allow-origin": "*",
122+
"content-length": "157",
123123
}
124124
Service version: 1.2.0-testing-no-sha
125125
Response: {

crates/iota-graphql-rpc/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ publish = false
1010
# external dependencies
1111
anyhow.workspace = true
1212
async-graphql = { workspace = true, features = ["dataloader", "apollo_tracing", "tracing", "opentelemetry"] }
13-
async-graphql-axum = "=7.0.11"
14-
async-graphql-value = "=7.0.11"
13+
async-graphql-axum = "7.0.17"
14+
async-graphql-value = "7.0.17"
1515
async-trait.workspace = true
1616
axum.workspace = true
1717
axum-extra.workspace = true

crates/iota-graphql-rpc/src/server/builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ impl ServerBuilder {
272272
if self.router.is_none() {
273273
let router: Router = Router::new()
274274
.route("/", post(graphql_handler))
275-
.route("/:version", post(graphql_handler))
275+
.route("/{version}", post(graphql_handler))
276276
.route("/graphql", post(graphql_handler))
277-
.route("/graphql/:version", post(graphql_handler))
277+
.route("/graphql/{version}", post(graphql_handler))
278278
.route("/health", get(health_check))
279279
.route("/graphql/health", get(health_check))
280-
.route("/graphql/:version/health", get(health_check))
280+
.route("/graphql/{version}/health", get(health_check))
281281
.with_state(self.state.clone())
282282
.route_layer(CallbackLayer::new(MetricsMakeCallbackHandler {
283283
metrics: self.state.metrics.clone(),
@@ -294,8 +294,8 @@ impl ServerBuilder {
294294

295295
pub fn layer<L>(mut self, layer: L) -> Self
296296
where
297-
L: Layer<Route> + Clone + Send + 'static,
298-
L::Service: Service<Request<Body>> + Clone + Send + 'static,
297+
L: Layer<Route> + Clone + Send + Sync + 'static,
298+
L::Service: Service<Request<Body>> + Clone + Send + Sync + 'static,
299299
<L::Service as Service<Request<Body>>>::Response: IntoResponse + 'static,
300300
<L::Service as Service<Request<Body>>>::Error: Into<Infallible> + 'static,
301301
<L::Service as Service<Request<Body>>>::Future: Send + 'static,

crates/iota-graphql-rpc/src/server/graphiql_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ async fn start_graphiql_server_impl(
5252
// Add GraphiQL IDE handler on GET request to `/`` endpoint
5353
let server = server_builder
5454
.route("/", axum::routing::get(graphiql))
55-
.route("/:version", axum::routing::get(graphiql))
55+
.route("/{version}", axum::routing::get(graphiql))
5656
.route("/graphql", axum::routing::get(graphiql))
57-
.route("/graphql/:version", axum::routing::get(graphiql))
57+
.route("/graphql/{version}", axum::routing::get(graphiql))
5858
.layer(axum::extract::Extension(Some(ide_title)))
5959
.build()?;
6060

crates/iota-graphql-rpc/src/server/version.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ mod tests {
166166

167167
Router::new()
168168
.route("/", get(|| async { "Hello, Versioning!" }))
169-
.route("/:version", get(|| async { "Hello, Versioning!" }))
169+
.route("/{version}", get(|| async { "Hello, Versioning!" }))
170170
.route("/graphql", get(|| async { "Hello, Versioning!" }))
171-
.route("/graphql/:version", get(|| async { "Hello, Versioning!" }))
171+
.route("/graphql/{version}", get(|| async { "Hello, Versioning!" }))
172172
.layer(middleware::from_fn_with_state(
173173
state.version,
174174
check_version_middleware,

0 commit comments

Comments
 (0)