From 29f73ae28996e103c3ea258f5222181d2f8ed73d Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Thu, 28 Mar 2024 04:30:27 +0100 Subject: [PATCH] chore(deps): update to hyper 1.0 --- Cargo.lock | 155 ++++++++++++++--------------- Cargo.toml | 12 +-- crates/anvil/server/Cargo.toml | 1 - crates/anvil/server/src/ipc.rs | 4 +- crates/anvil/server/src/lib.rs | 93 +++++++---------- crates/anvil/src/cmd.rs | 2 +- crates/anvil/src/lib.rs | 67 +++++++++---- crates/anvil/src/server/mod.rs | 57 +++++++---- crates/chisel/Cargo.toml | 2 +- crates/common/Cargo.toml | 2 +- crates/config/Cargo.toml | 2 +- crates/forge/Cargo.toml | 4 +- crates/forge/bin/cmd/doc/server.rs | 13 ++- crates/verify/Cargo.toml | 2 +- 14 files changed, 219 insertions(+), 197 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7dcd51e0673..d67f744c81a2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -558,7 +558,7 @@ dependencies = [ "http 0.2.12", "serde_json", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.20.1", "tracing", "ws_stream_wasm", ] @@ -708,7 +708,7 @@ dependencies = [ "foundry-evm", "foundry-test-utils", "futures", - "hyper 0.14.28", + "hyper 1.2.0", "itertools 0.12.1", "k256", "parking_lot", @@ -771,7 +771,6 @@ dependencies = [ "bytes", "clap", "futures", - "hyper 0.14.28", "parity-tokio-ipc", "parking_lot", "pin-project", @@ -1409,19 +1408,20 @@ dependencies = [ [[package]] name = "axum" -version = "0.6.20" +version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "3a6c9af12842a67734c9a2e355436e5d03b22383ed60cf13cd0c18fbfe3dcbcf" dependencies = [ "async-trait", "axum-core", "base64 0.21.7", - "bitflags 1.3.2", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.28", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", + "hyper 1.2.0", + "hyper-util", "itoa", "matchit", "memchr", @@ -1434,29 +1434,34 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper", + "sync_wrapper 1.0.1", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.21.0", "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "a15c63fd72d41492dc4f497196f5da1fb04fb7529e631d73630d1b491e47a2e3" dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper 0.1.2", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -1877,7 +1882,7 @@ dependencies = [ "foundry-evm", "once_cell", "regex", - "reqwest 0.11.27", + "reqwest 0.12.3", "revm", "rustyline", "semver 1.0.22", @@ -3158,7 +3163,7 @@ dependencies = [ "serde_json", "thiserror", "tokio", - "tokio-tungstenite", + "tokio-tungstenite 0.20.1", "tracing", "tracing-futures", "url", @@ -3494,7 +3499,7 @@ dependencies = [ "foundry-wallets", "futures", "globset", - "hyper 0.14.28", + "hyper 1.2.0", "indicatif", "itertools 0.12.1", "mockall", @@ -3507,7 +3512,7 @@ dependencies = [ "proptest", "rayon", "regex", - "reqwest 0.11.27", + "reqwest 0.12.3", "revm-inspectors", "rustc-hash", "semver 1.0.22", @@ -3516,7 +3521,7 @@ dependencies = [ "similar", "solang-parser", "strum", - "svm-rs 0.4.1", + "svm-rs 0.5.1", "tempfile", "thiserror", "tikv-jemallocator", @@ -3637,7 +3642,7 @@ dependencies = [ "futures", "once_cell", "regex", - "reqwest 0.11.27", + "reqwest 0.12.3", "revm-primitives", "semver 1.0.22", "serde", @@ -4128,16 +4133,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "fs4" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29f9df8a11882c4e3335eb2d18a0137c505d9ca927470b0cac9c6f0ae07d28f7" -dependencies = [ - "rustix", - "windows-sys 0.48.0", -] - [[package]] name = "fs4" version = "0.8.2" @@ -4812,9 +4807,9 @@ dependencies = [ [[package]] name = "http-range-header" -version = "0.3.1" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "add0ab9360ddbd88cfeb3bd9574a1d85cfdfa14db10b3e21d3700dbc4328758f" +checksum = "3ce4ef31cda248bbdb6e6820603b82dfcd9e833db65a43e997a0ccec777d11fe" [[package]] name = "httparse" @@ -4870,6 +4865,7 @@ dependencies = [ "http 1.1.0", "http-body 1.0.0", "httparse", + "httpdate", "itoa", "pin-project-lite", "smallvec", @@ -4910,19 +4906,6 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper 0.14.28", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "hyper-tls" version = "0.6.0" @@ -6927,12 +6910,10 @@ dependencies = [ "http-body 0.4.6", "hyper 0.14.28", "hyper-rustls 0.24.2", - "hyper-tls 0.5.0", "ipnet", "js-sys", "log", "mime", - "native-tls", "once_cell", "percent-encoding", "pin-project-lite", @@ -6942,10 +6923,9 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "system-configuration", "tokio", - "tokio-native-tls", "tokio-rustls 0.24.1", "tower-service", "url", @@ -6972,7 +6952,7 @@ dependencies = [ "http-body-util", "hyper 1.2.0", "hyper-rustls 0.26.0", - "hyper-tls 0.6.0", + "hyper-tls", "hyper-util", "ipnet", "js-sys", @@ -6989,7 +6969,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", + "sync_wrapper 0.1.2", "tokio", "tokio-native-tls", "tokio-rustls 0.25.0", @@ -8054,26 +8034,6 @@ dependencies = [ "zip", ] -[[package]] -name = "svm-rs" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd5e919f01c9280dce59ab66296449d0e9144b8472b8892fbacf9612998b653" -dependencies = [ - "const-hex", - "dirs 5.0.1", - "fs4 0.7.0", - "once_cell", - "reqwest 0.11.27", - "semver 1.0.22", - "serde", - "serde_json", - "sha2", - "thiserror", - "url", - "zip", -] - [[package]] name = "svm-rs" version = "0.5.1" @@ -8082,7 +8042,7 @@ checksum = "c912d2f0dfbf9d8ba683b3181c4bd6d042bac9279d5c062346c253c1eadf46e2" dependencies = [ "const-hex", "dirs 5.0.1", - "fs4 0.8.2", + "fs4", "once_cell", "reqwest 0.12.3", "semver 1.0.22", @@ -8147,6 +8107,12 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" + [[package]] name = "system-configuration" version = "0.5.1" @@ -8453,10 +8419,22 @@ dependencies = [ "rustls 0.21.10", "tokio", "tokio-rustls 0.24.1", - "tungstenite", + "tungstenite 0.20.1", "webpki-roots 0.25.4", ] +[[package]] +name = "tokio-tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c83b561d025642014097b66e6c1bb422783339e0909e4429cde4749d1990bc38" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite 0.21.0", +] + [[package]] name = "tokio-util" version = "0.7.10" @@ -8573,16 +8551,16 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.4.4" +version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61c5bb1d698276a2443e5ecfabc1008bf15a36c12e6a7176e7bf089ea9131140" +checksum = "1e9cd434a998747dd2c4276bc96ee2e0c7a2eadf3cae88e52be55a05fa9053f5" dependencies = [ "bitflags 2.5.0", "bytes", - "futures-core", "futures-util", - "http 0.2.12", - "http-body 0.4.6", + "http 1.1.0", + "http-body 1.0.0", + "http-body-util", "http-range-header", "httpdate", "mime", @@ -8730,6 +8708,25 @@ dependencies = [ "utf-8", ] +[[package]] +name = "tungstenite" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ef1a641ea34f399a848dea702823bbecfb4c486f911735368f1f137cb8257e1" +dependencies = [ + "byteorder", + "bytes", + "data-encoding", + "http 1.1.0", + "httparse", + "log", + "rand 0.8.5", + "sha1", + "thiserror", + "url", + "utf-8", +] + [[package]] name = "typed-arena" version = "2.0.2" diff --git a/Cargo.toml b/Cargo.toml index 622b2cf3f634..2859b9349afe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -192,10 +192,7 @@ solang-parser = "=0.3.3" ## misc arrayvec = "0.7" base64 = "0.22" -chrono = { version = "0.4", default-features = false, features = [ - "clock", - "std", -] } +chrono = { version = "0.4", default-features = false, features = ["clock", "std"] } color-eyre = "0.6" derive_more = "0.99" evm-disassembler = "0.5" @@ -218,7 +215,8 @@ indexmap = "2.2" tikv-jemallocator = "0.5.4" num-format = "0.4.4" -axum = "0.6" -hyper = "0.14" +axum = "0.7" +hyper = "1.0" +reqwest = { version = "0.12", default-features = false } tower = "0.4" -tower-http = "0.4" +tower-http = "0.5" diff --git a/crates/anvil/server/Cargo.toml b/crates/anvil/server/Cargo.toml index fb880a422de9..a9d87051050d 100644 --- a/crates/anvil/server/Cargo.toml +++ b/crates/anvil/server/Cargo.toml @@ -15,7 +15,6 @@ anvil-rpc = { path = "../rpc" } # axum related axum = { workspace = true, features = ["ws"] } -hyper.workspace = true tower-http = { workspace = true, features = ["trace", "cors"] } # tracing diff --git a/crates/anvil/server/src/ipc.rs b/crates/anvil/server/src/ipc.rs index 97ec0709887d..152b41873f95 100644 --- a/crates/anvil/server/src/ipc.rs +++ b/crates/anvil/server/src/ipc.rs @@ -24,8 +24,8 @@ pub struct IpcEndpoint { impl IpcEndpoint { /// Creates a new endpoint with the given handler - pub fn new(handler: Handler, endpoint: impl Into) -> Self { - Self { handler, endpoint: Endpoint::new(endpoint.into()) } + pub fn new(handler: Handler, endpoint: String) -> Self { + Self { handler, endpoint: Endpoint::new(endpoint) } } /// Returns a stream of incoming connection handlers diff --git a/crates/anvil/server/src/lib.rs b/crates/anvil/server/src/lib.rs index 5ff287c96b3c..5bd81b043e8e 100644 --- a/crates/anvil/server/src/lib.rs +++ b/crates/anvil/server/src/lib.rs @@ -1,4 +1,4 @@ -//! Bootstrap [axum] RPC servers +//! Bootstrap [axum] RPC servers. #![warn(missing_docs, unused_crate_dependencies)] @@ -12,91 +12,66 @@ use anvil_rpc::{ }; use axum::{ http::{header, HeaderValue, Method}, - routing::{post, IntoMakeService}, - Router, Server, + routing::{post, MethodRouter}, + Router, }; -use hyper::server::conn::AddrIncoming; use serde::de::DeserializeOwned; -use std::{fmt, net::SocketAddr}; +use std::fmt; use tower_http::{cors::CorsLayer, trace::TraceLayer}; mod config; +pub use config::ServerConfig; mod error; -/// handlers for axum server mod handler; -#[cfg(feature = "ipc")] -pub mod ipc; + mod pubsub; -mod ws; +pub use pubsub::{PubSubContext, PubSubRpcHandler}; -pub use crate::pubsub::{PubSubContext, PubSubRpcHandler}; -pub use config::ServerConfig; +mod ws; -/// Type alias for the configured axum server -pub type AnvilServer = Server>; +#[cfg(feature = "ipc")] +pub mod ipc; -/// Configures an [axum::Server] that handles RPC-Calls, both HTTP requests and requests via -/// websocket -pub fn serve_http_ws( - addr: SocketAddr, - config: ServerConfig, - http: Http, - ws: Ws, -) -> AnvilServer +/// Configures an [`axum::Router`] that handles JSON-RPC calls via both HTTP and WS. +pub fn http_ws_router(config: ServerConfig, http: Http, ws: Ws) -> Router where Http: RpcHandler, Ws: PubSubRpcHandler, { - let ServerConfig { allow_origin, no_cors } = config; - - let svc = Router::new() - .route("/", post(handler::handle).get(ws::handle_ws)) - .with_state((http, ws)) - .layer(TraceLayer::new_for_http()); - - let svc = if no_cors { - svc - } else { - svc.layer( - // see https://docs.rs/tower-http/latest/tower_http/cors/index.html - // for more details - CorsLayer::new() - .allow_origin(allow_origin.0) - .allow_headers(vec![header::CONTENT_TYPE]) - .allow_methods(vec![Method::GET, Method::POST]), - ) - } - .into_make_service(); - Server::bind(&addr).serve(svc) + router_inner(config, post(handler::handle).get(ws::handle_ws), (http, ws)) } -/// Configures an [axum::Server] that handles RPC-Calls listing for POST on `/` -pub fn serve_http(addr: SocketAddr, config: ServerConfig, http: Http) -> AnvilServer +/// Configures an [`axum::Router`] that handles JSON-RPC calls via HTTP. +pub fn http_router(config: ServerConfig, http: Http) -> Router where Http: RpcHandler, { + router_inner(config, post(handler::handle), (http, ())) +} + +fn router_inner( + config: ServerConfig, + root_method_router: MethodRouter, + state: S, +) -> Router { let ServerConfig { allow_origin, no_cors } = config; - let svc = Router::new() - .route("/", post(handler::handle)) - .with_state((http, ())) + let mut router = Router::new() + .route("/", root_method_router) + .with_state(state) .layer(TraceLayer::new_for_http()); - let svc = if no_cors { - svc - } else { - svc.layer( - // see https://docs.rs/tower-http/latest/tower_http/cors/index.html - // for more details + if !no_cors { + // See [`tower_http::cors`](https://docs.rs/tower-http/latest/tower_http/cors/index.html) + // for more details. + router = router.layer( CorsLayer::new() .allow_origin(allow_origin.0) - .allow_headers(vec![header::CONTENT_TYPE]) - .allow_methods(vec![Method::GET, Method::POST]), - ) + .allow_headers([header::CONTENT_TYPE]) + .allow_methods([Method::GET, Method::POST]), + ); } - .into_make_service(); - - Server::bind(&addr).serve(svc) + router } /// Helper trait that is used to execute ethereum rpc calls diff --git a/crates/anvil/src/cmd.rs b/crates/anvil/src/cmd.rs index 8e29152410ee..c64d9471fd81 100644 --- a/crates/anvil/src/cmd.rs +++ b/crates/anvil/src/cmd.rs @@ -275,7 +275,7 @@ impl NodeArgs { let dump_interval = self.state_interval.map(Duration::from_secs).unwrap_or(DEFAULT_DUMP_INTERVAL); - let (api, mut handle) = crate::spawn(self.into_node_config()).await; + let (api, mut handle) = crate::try_spawn(self.into_node_config()).await?; // sets the signal handler to gracefully shutdown. let mut fork = api.get_fork(); diff --git a/crates/anvil/src/lib.rs b/crates/anvil/src/lib.rs index 31c635990b11..b08fd7e9c665 100644 --- a/crates/anvil/src/lib.rs +++ b/crates/anvil/src/lib.rs @@ -70,26 +70,56 @@ mod tasks; #[cfg(feature = "cmd")] pub mod cmd; -/// Creates the node and runs the server +/// Creates the node and runs the server. /// /// Returns the [EthApi] that can be used to interact with the node and the [JoinHandle] of the /// task. /// -/// # Example +/// # Panics +/// +/// Panics if any error occurs. For a non-panicking version, use [`try_spawn`]. +/// /// -/// ```rust +/// # Examples +/// +/// ```no_run /// # use anvil::NodeConfig; -/// # async fn spawn() { +/// # async fn spawn() -> eyre::Result<()> { /// let config = NodeConfig::default(); /// let (api, handle) = anvil::spawn(config).await; /// /// // use api /// /// // wait forever -/// handle.await.unwrap(); +/// handle.await.unwrap().unwrap(); +/// # Ok(()) +/// # } +/// ``` +pub async fn spawn(config: NodeConfig) -> (EthApi, NodeHandle) { + try_spawn(config).await.expect("failed to spawn node") +} + +/// Creates the node and runs the server +/// +/// Returns the [EthApi] that can be used to interact with the node and the [JoinHandle] of the +/// task. +/// +/// # Examples +/// +/// ```no_run +/// # use anvil::NodeConfig; +/// # async fn spawn() -> eyre::Result<()> { +/// let config = NodeConfig::default(); +/// let (api, handle) = anvil::try_spawn(config).await?; +/// +/// // use api +/// +/// // wait forever +/// handle.await??; +/// # Ok(()) /// # } /// ``` -pub async fn spawn(mut config: NodeConfig) -> (EthApi, NodeHandle) { +pub async fn try_spawn(mut config: NodeConfig) -> io::Result<(EthApi, NodeHandle)> { let logger = if config.enable_tracing { init_tracing() } else { Default::default() }; logger.set_enabled(!config.silent); @@ -174,18 +204,19 @@ pub async fn spawn(mut config: NodeConfig) -> (EthApi, NodeHandle) { let node_service = tokio::task::spawn(NodeService::new(pool, backend, miner, fee_history_service, filters)); - let mut servers = Vec::new(); - let mut addresses = Vec::new(); + let mut servers = Vec::with_capacity(config.host.len()); + let mut addresses = Vec::with_capacity(config.host.len()); - for addr in config.host.iter() { - let sock_addr = SocketAddr::new(addr.to_owned(), port); - let srv = server::serve(sock_addr, api.clone(), server_config.clone()); + for addr in &config.host { + let sock_addr = SocketAddr::new(*addr, port); - addresses.push(srv.local_addr()); + // Create a TCP listener. + let tcp_listener = tokio::net::TcpListener::bind(sock_addr).await?; + addresses.push(tcp_listener.local_addr()?); - // spawn the server on a new task - let srv = tokio::task::spawn(srv.map_err(NodeError::from)); - servers.push(srv); + // Spawn the server future on a new task. + let srv = server::serve_on(tcp_listener, api.clone(), server_config.clone()); + servers.push(tokio::task::spawn(srv.map_err(Into::into))); } let tokio_handle = Handle::current(); @@ -206,10 +237,10 @@ pub async fn spawn(mut config: NodeConfig) -> (EthApi, NodeHandle) { handle.print(fork.as_ref()); - (api, handle) + Ok((api, handle)) } -type IpcTask = JoinHandle>; +type IpcTask = JoinHandle<()>; /// A handle to the spawned node and server tasks /// @@ -359,7 +390,7 @@ impl Future for NodeHandle { // poll the ipc task if let Some(mut ipc) = pin.ipc_task.take() { if let Poll::Ready(res) = ipc.poll_unpin(cx) { - return Poll::Ready(res.map(|res| res.map_err(NodeError::from))); + return Poll::Ready(res.map(|()| Ok(()))); } else { pin.ipc_task = Some(ipc); } diff --git a/crates/anvil/src/server/mod.rs b/crates/anvil/src/server/mod.rs index 10d86f6713d5..c488bcdc15ca 100644 --- a/crates/anvil/src/server/mod.rs +++ b/crates/anvil/src/server/mod.rs @@ -1,48 +1,67 @@ -//! Contains the code to launch an ethereum RPC-Server -use crate::EthApi; -use anvil_server::{ipc::IpcEndpoint, AnvilServer, ServerConfig}; +//! Contains the code to launch an Ethereum RPC server. + +use crate::{EthApi, IpcTask}; +use anvil_server::{ipc::IpcEndpoint, ServerConfig}; +use axum::Router; use futures::StreamExt; use handler::{HttpEthRpcHandler, PubSubEthRpcHandler}; -use std::net::SocketAddr; -use tokio::{io, task::JoinHandle}; +use std::{future::Future, io, net::SocketAddr, pin::pin}; +use tokio::net::TcpListener; +pub mod error; mod handler; -pub mod error; +/// Configures a server that handles [`EthApi`] related JSON-RPC calls via HTTP and WS. +/// +/// The returned future creates a new server, binding it to the given address, which returns another +/// future that runs it. +pub async fn serve( + addr: SocketAddr, + api: EthApi, + config: ServerConfig, +) -> io::Result>> { + let tcp_listener = TcpListener::bind(addr).await?; + Ok(serve_on(tcp_listener, api, config)) +} -/// Configures an [axum::Server] that handles [EthApi] related JSON-RPC calls via HTTP and WS -pub fn serve(addr: SocketAddr, api: EthApi, config: ServerConfig) -> AnvilServer { +/// Configures a server that handles [`EthApi`] related JSON-RPC calls via HTTP and WS. +pub async fn serve_on( + tcp_listener: TcpListener, + api: EthApi, + config: ServerConfig, +) -> io::Result<()> { + axum::serve(tcp_listener, router(api, config).into_make_service()).await +} + +/// Configures an [`axum::Router`] that handles [`EthApi`] related JSON-RPC calls via HTTP and WS. +pub fn router(api: EthApi, config: ServerConfig) -> Router { let http = HttpEthRpcHandler::new(api.clone()); let ws = PubSubEthRpcHandler::new(api); - anvil_server::serve_http_ws(addr, config, http, ws) + anvil_server::http_ws_router(config, http, ws) } /// Launches an ipc server at the given path in a new task /// /// # Panics /// -/// if setting up the ipc connection was unsuccessful -pub fn spawn_ipc(api: EthApi, path: impl Into) -> JoinHandle> { +/// Panics if setting up the IPC connection was unsuccessful. +#[track_caller] +pub fn spawn_ipc(api: EthApi, path: String) -> IpcTask { try_spawn_ipc(api, path).expect("failed to establish ipc connection") } -/// Launches an ipc server at the given path in a new task -pub fn try_spawn_ipc( - api: EthApi, - path: impl Into, -) -> io::Result>> { - let path = path.into(); +/// Launches an ipc server at the given path in a new task. +pub fn try_spawn_ipc(api: EthApi, path: String) -> io::Result { let handler = PubSubEthRpcHandler::new(api); let ipc = IpcEndpoint::new(handler, path); let incoming = ipc.incoming()?; let task = tokio::task::spawn(async move { - tokio::pin!(incoming); + let mut incoming = pin!(incoming); while let Some(stream) = incoming.next().await { trace!(target: "ipc", "new ipc connection"); tokio::task::spawn(stream); } - Ok(()) }); Ok(task) diff --git a/crates/chisel/Cargo.toml b/crates/chisel/Cargo.toml index 9829abb7c475..9d07ae80019a 100644 --- a/crates/chisel/Cargo.toml +++ b/crates/chisel/Cargo.toml @@ -37,7 +37,7 @@ dirs = "5" eyre.workspace = true once_cell = "1.18.0" regex = "1" -reqwest = { version = "0.11", default-features = false } +reqwest.workspace = true revm.workspace = true rustyline = "12" semver = "1" diff --git a/crates/common/Cargo.toml b/crates/common/Cargo.toml index cafa1938a5ec..07f8837cabb8 100644 --- a/crates/common/Cargo.toml +++ b/crates/common/Cargo.toml @@ -50,7 +50,7 @@ glob = "0.3" globset = "0.4" hex.workspace = true once_cell = "1" -reqwest = { version = "0.12", default-features = false } +reqwest.workspace = true semver = "1" serde_json.workspace = true serde.workspace = true diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index da1371c75bd4..1b639ee55ae1 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -29,7 +29,7 @@ Inflector = "0.11" number_prefix = "0.4" once_cell = "1" regex = "1" -reqwest = { version = "0.12", default-features = false } +reqwest.workspace = true semver = { version = "1", features = ["serde"] } serde_json.workspace = true serde_regex = "1" diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 30b5975768c7..9ccec21508fc 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -71,7 +71,7 @@ itertools.workspace = true once_cell = "1" parking_lot = "0.12" regex = { version = "1", default-features = false } -reqwest = { version = "0.11", default-features = false, features = ["json"] } +reqwest = { workspace = true, features = ["json"] } semver = "1" serde_json.workspace = true similar = { version = "2", features = ["inline"] } @@ -104,7 +104,7 @@ globset = "0.4" paste = "1.0" path-slash = "0.2" pretty_assertions.workspace = true -svm = { package = "svm-rs", version = "0.4", default-features = false, features = ["rustls"] } +svm = { package = "svm-rs", version = "0.5", default-features = false, features = ["rustls"] } tempfile = "3" tracing-subscriber = { workspace = true, features = ["env-filter", "fmt"] } diff --git a/crates/forge/bin/cmd/doc/server.rs b/crates/forge/bin/cmd/doc/server.rs index 7c092713615d..f5991ba43837 100644 --- a/crates/forge/bin/cmd/doc/server.rs +++ b/crates/forge/bin/cmd/doc/server.rs @@ -1,6 +1,7 @@ use axum::{routing::get_service, Router}; use forge_doc::mdbook::{utils::fs::get_404_output_file, MDBook}; use std::{ + io, net::{SocketAddr, ToSocketAddrs}, path::PathBuf, }; @@ -82,18 +83,20 @@ impl Server { open(serving_url); } - let _ = thread_handle.join(); - - Ok(()) + match thread_handle.join() { + Ok(r) => r.map_err(Into::into), + Err(e) => std::panic::resume_unwind(e), + } } } #[tokio::main] -async fn serve(build_dir: PathBuf, address: SocketAddr, file_404: &str) { +async fn serve(build_dir: PathBuf, address: SocketAddr, file_404: &str) -> io::Result<()> { let file_404 = build_dir.join(file_404); let svc = ServeDir::new(build_dir).not_found_service(ServeFile::new(file_404)); let app = Router::new().nest_service("/", get_service(svc)); - hyper::Server::bind(&address).serve(app.into_make_service()).await.unwrap(); + let tcp_listener = tokio::net::TcpListener::bind(address).await?; + axum::serve(tcp_listener, app.into_make_service()).await } fn open>(path: P) { diff --git a/crates/verify/Cargo.toml b/crates/verify/Cargo.toml index 16efe68881d7..d365388d09f7 100644 --- a/crates/verify/Cargo.toml +++ b/crates/verify/Cargo.toml @@ -29,7 +29,7 @@ foundry-compilers = { workspace = true, features = ["full"] } foundry-block-explorers = { workspace = true, features = ["foundry-compilers"] } clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] } -reqwest = { version = "0.11", default-features = false, features = ["json"] } +reqwest = { workspace = true, features = ["json"] } async-trait = "0.1" futures = "0.3" semver = "1"