From 4101eb37be02c9df912f19877940006ac2881fac Mon Sep 17 00:00:00 2001 From: driftluo Date: Wed, 23 Oct 2024 22:08:09 +0800 Subject: [PATCH] chore: upgrade axum --- Cargo.lock | 222 ++++++++++++++++++---------------------------- Cargo.toml | 2 +- rpc/Cargo.toml | 7 +- rpc/src/server.rs | 8 +- 4 files changed, 98 insertions(+), 141 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f1bfa18325..20245e39fc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -223,19 +223,20 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "504e3947307ac8326a5437504c517c4b56716c9d98fac0028c2acc7ca47d70ae" dependencies = [ "async-trait", "axum-core", - "base64 0.21.7", - "bitflags 1.3.2", + "base64 0.22.1", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.31", + "http 1.1.0", + "http-body", + "http-body-util", + "hyper", + "hyper-util", "itoa", "matchit", "memchr", @@ -248,29 +249,34 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper 0.1.2", + "sync_wrapper 1.0.1", "tokio", "tokio-tungstenite", - "tower", + "tower 0.5.1", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", + "http 1.1.0", + "http-body", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 1.0.1", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -1155,7 +1161,7 @@ dependencies = [ "ckb-stop-handler", "ckb-util", "http-body-util", - "hyper 1.5.0", + "hyper", "hyper-util", "prometheus", "tokio", @@ -1206,7 +1212,7 @@ dependencies = [ "eaglesong", "futures", "http-body-util", - "hyper 1.5.0", + "hyper", "hyper-tls", "hyper-util", "indicatif", @@ -1710,7 +1716,7 @@ dependencies = [ "ckb-util", "ckb-verification", "http-body-util", - "hyper 1.5.0", + "hyper", "hyper-util", "lru", "multi_index_map", @@ -1944,9 +1950,9 @@ dependencies = [ [[package]] name = "console-api" -version = "0.6.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd326812b3fd01da5bb1af7d340d0d555fd3d4b641e7f1dfcf5962a902952787" +checksum = "86ed14aa9c9f927213c6e4f3ef75faaad3406134efe84ba2cb7983431d5f0931" dependencies = [ "futures-core", "prost", @@ -1957,9 +1963,9 @@ dependencies = [ [[package]] name = "console-subscriber" -version = "0.2.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7481d4c57092cd1c19dd541b92bdce883de840df30aa5d03fd48a3935c01842e" +checksum = "e2e3a111a37f3333946ebf9da370ba5c5577b18eb342ec683eb488dd21980302" dependencies = [ "console-api", "crossbeam-channel", @@ -1967,6 +1973,8 @@ dependencies = [ "futures-task", "hdrhistogram", "humantime", + "hyper-util", + "prost", "prost-types", "serde", "serde_json", @@ -2874,25 +2882,6 @@ dependencies = [ "smallvec", ] -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.12", - "indexmap 2.6.0", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "h2" version = "0.4.6" @@ -3089,17 +3078,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.12", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.1" @@ -3119,16 +3097,10 @@ dependencies = [ "bytes", "futures-util", "http 1.1.0", - "http-body 1.0.1", + "http-body", "pin-project-lite", ] -[[package]] -name = "http-range-header" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" - [[package]] name = "httparse" version = "1.9.5" @@ -3156,30 +3128,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "hyper" -version = "0.14.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - [[package]] name = "hyper" version = "1.5.0" @@ -3189,9 +3137,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.6", + "h2", "http 1.1.0", - "http-body 1.0.1", + "http-body", "httparse", "httpdate", "itoa", @@ -3209,7 +3157,7 @@ checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" dependencies = [ "futures-util", "http 1.1.0", - "hyper 1.5.0", + "hyper", "hyper-util", "rustls", "rustls-pki-types", @@ -3220,14 +3168,15 @@ dependencies = [ [[package]] name = "hyper-timeout" -version = "0.4.1" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" +checksum = "3203a961e5c83b6f5498933e78b6b263e208c197b63e9c6c53cc82ffd3f63793" dependencies = [ - "hyper 0.14.31", + "hyper", + "hyper-util", "pin-project-lite", "tokio", - "tokio-io-timeout", + "tower-service", ] [[package]] @@ -3238,7 +3187,7 @@ checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", "http-body-util", - "hyper 1.5.0", + "hyper", "hyper-util", "native-tls", "tokio", @@ -3256,8 +3205,8 @@ dependencies = [ "futures-channel", "futures-util", "http 1.1.0", - "http-body 1.0.1", - "hyper 1.5.0", + "http-body", + "hyper", "pin-project-lite", "socket2", "tokio", @@ -3551,9 +3500,9 @@ dependencies = [ [[package]] name = "jsonrpc-utils" -version = "0.2.6" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfe6601e4eedf0730aebf2ad532cd22c05c67d3cb20105577dd12a5f004abd3b" +checksum = "b70b75b921afd705aef070f0eab39e566031b929433cffa9fc01ea44ce1339d0" dependencies = [ "anyhow", "axum", @@ -4579,9 +4528,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.6" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +checksum = "7b0487d90e047de87f984913713b85c601c05609aad5b0df4b4573fbf69aa13f" dependencies = [ "bytes", "prost-derive", @@ -4589,9 +4538,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.6" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +checksum = "e9552f850d5f0964a4e4d0bf306459ac29323ddfbae05e35a7c0d35cb0803cc5" dependencies = [ "anyhow", "itertools 0.12.1", @@ -4602,9 +4551,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.6" +version = "0.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +checksum = "4759aa0d3a6232fb8dbdb97b61de2c20047c68aca932c7ed76da9d788508d670" dependencies = [ "prost", ] @@ -4845,11 +4794,11 @@ dependencies = [ "futures-channel", "futures-core", "futures-util", - "h2 0.4.6", + "h2", "http 1.1.0", - "http-body 1.0.1", + "http-body", "http-body-util", - "hyper 1.5.0", + "hyper", "hyper-rustls", "hyper-tls", "hyper-util", @@ -6117,16 +6066,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-macros" version = "2.4.0" @@ -6172,9 +6111,9 @@ dependencies = [ [[package]] name = "tokio-tungstenite" -version = "0.20.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d5dcb2a1ce06d81107c3d0ffa3121fe974b73f068c8282cb1c32328113b6c" +checksum = "edc5f74e248dc973e0dbb7b74c7e0d6fcc301c694ff50049504004ef4d0cdcd9" dependencies = [ "futures-util", "log", @@ -6220,26 +6159,29 @@ dependencies = [ [[package]] name = "tonic" -version = "0.10.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.21.7", + "base64 0.22.1", "bytes", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.31", + "h2", + "http 1.1.0", + "http-body", + "http-body-util", + "hyper", "hyper-timeout", + "hyper-util", "percent-encoding", "pin-project", "prost", + "socket2", "tokio", "tokio-stream", - "tower", + "tower 0.4.13", "tower-layer", "tower-service", "tracing", @@ -6266,18 +6208,31 @@ dependencies = [ ] [[package]] -name = "tower-http" -version = "0.3.5" +name = "tower" +version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f873044bf02dd1e8239e9c1293ea39dad76dc594ec16185d0a1bf31d8dc8d858" +checksum = "2873938d487c3cfb9aed7546dc9f2711d867c9f90c46b889989a2cb84eba6b4f" dependencies = [ - "bitflags 1.3.2", - "bytes", "futures-core", "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "http-range-header", + "pin-project-lite", + "sync_wrapper 0.1.2", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8437150ab6bbc8c5f0f519e3d5ed4aa883a83dd4cdd3d1b21f9482936046cb97" +dependencies = [ + "bitflags 2.6.0", + "bytes", + "http 1.1.0", + "http-body", "pin-project-lite", "tokio", "tower-layer", @@ -6398,20 +6353,19 @@ checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" [[package]] name = "tungstenite" -version = "0.20.1" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dac10fd62eaf6617d3a904ae222845979aec67c615d1c842b4002c7666fb9" +checksum = "18e5b8366ee7a95b16d32197d0b2604b43a0be89dc5fac9f8e96ccafbaedda8a" dependencies = [ "byteorder", "bytes", "data-encoding", - "http 0.2.12", + "http 1.1.0", "httparse", "log", "rand 0.8.5", "sha1", "thiserror", - "url", "utf-8", ] diff --git a/Cargo.toml b/Cargo.toml index d0fd227a91..2dea28b5b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ ckb-build-info = { path = "util/build-info", version = "= 0.119.0-pre" } [dependencies] ckb-build-info = { path = "util/build-info", version = "= 0.119.0-pre" } ckb-bin = { path = "ckb-bin", version = "= 0.119.0-pre" } -console-subscriber = { version = "0.2.0", optional = true } +console-subscriber = { version = "0.4.0", optional = true } [dev-dependencies] diff --git a/rpc/Cargo.toml b/rpc/Cargo.toml index 7d1675b21e..d795af7bf6 100644 --- a/rpc/Cargo.toml +++ b/rpc/Cargo.toml @@ -24,7 +24,7 @@ ckb-app-config = { path = "../util/app-config", version = "= 0.119.0-pre" } ckb-constant = { path = "../util/constant", version = "= 0.119.0-pre" } jsonrpc-core = "18.0" serde_json = "1.0" -jsonrpc-utils = { version = "0.2.6", features = ["server", "macros", "axum"] } +jsonrpc-utils = { version = "0.3", features = ["server", "macros", "axum"] } ckb-jsonrpc-types = { path = "../util/jsonrpc-types", version = "= 0.119.0-pre" } ckb-verification = { path = "../verification", version = "= 0.119.0-pre" } ckb-verification-traits = { path = "../verification/traits", version = "= 0.119.0-pre" } @@ -44,14 +44,15 @@ ckb-stop-handler = { path = "../util/stop-handler", version = "= 0.119.0-pre" } itertools.workspace = true tokio = "1" async-trait = "0.1" -axum = "0.6.20" +axum = "0.7" tokio-util = { version = "0.7.3", features = ["codec"] } futures-util = { version = "0.3.21" } -tower-http = { version = "0.3.5", features = ["timeout", "cors"] } +tower-http = { version = "0.6", features = ["timeout", "cors"] } async-stream = "0.3.3" ckb-async-runtime = { path = "../util/runtime", version = "= 0.119.0-pre" } # issue tracking: https://github.com/GREsau/schemars/pull/251 schemars = { version = "0.8.19", package = "ckb_schemars" } + [dev-dependencies] reqwest = { version = "0.12", features = ["blocking", "json"] } serde = { version = "1.0", features = ["derive"] } diff --git a/rpc/src/server.rs b/rpc/src/server.rs index 9388acc091..e32a263a22 100644 --- a/rpc/src/server.rs +++ b/rpc/src/server.rs @@ -128,16 +128,18 @@ impl RpcServer { let (tx_addr, rx_addr) = tokio::sync::oneshot::channel::(); handler.spawn(async move { - let server = axum::Server::bind( + let listener = tokio::net::TcpListener::bind( &address .to_socket_addrs() .expect("config listen_address parsed") .next() .expect("config listen_address parsed"), ) - .serve(app.clone().into_make_service()); + .await + .unwrap(); + let server = axum::serve(listener, app.into_make_service()); - let _ = tx_addr.send(server.local_addr()); + let _ = tx_addr.send(server.local_addr().unwrap()); let graceful = server.with_graceful_shutdown(async move { new_tokio_exit_rx().cancelled().await; });