diff --git a/Cargo.lock b/Cargo.lock index 6ab9d44fa9..84975f016a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10260,7 +10260,6 @@ dependencies = [ "blockifier", "cairo-lang-sierra-to-casm", "cairo-lang-starknet-classes", - "hyper 0.14.30", "mempool_test_utils", "mockall", "mockito 1.5.0", @@ -10311,13 +10310,14 @@ name = "starknet_http_server" version = "0.0.0" dependencies = [ "axum", + "hyper 0.14.30", "papyrus_config", "serde", "serde_json", "starknet_api", - "starknet_gateway", "starknet_gateway_types", "starknet_mempool_infra", + "thiserror", "tokio", "tracing", "validator", diff --git a/crates/gateway/Cargo.toml b/crates/gateway/Cargo.toml index e6e1818457..b8006e96c9 100644 --- a/crates/gateway/Cargo.toml +++ b/crates/gateway/Cargo.toml @@ -16,7 +16,6 @@ async-trait.workspace = true axum.workspace = true blockifier = { workspace = true, features = ["testing"] } cairo-lang-starknet-classes.workspace = true -hyper.workspace = true mempool_test_utils.workspace = true papyrus_config.workspace = true papyrus_network_types.workspace = true diff --git a/crates/gateway/src/errors.rs b/crates/gateway/src/errors.rs index 2374b93706..5ffc49f2ce 100644 --- a/crates/gateway/src/errors.rs +++ b/crates/gateway/src/errors.rs @@ -68,13 +68,6 @@ pub type StatelessTransactionValidatorResult = Result = Result; -/// Errors originating from `[`Gateway::run`]` command, to be handled by infrastructure code. -#[derive(Debug, Error)] -pub enum GatewayRunError { - #[error(transparent)] - ServerStartupError(#[from] hyper::Error), -} - #[derive(Debug, Error)] pub enum RPCStateReaderError { #[error("Block not found for request {0}")] diff --git a/crates/http_server/Cargo.toml b/crates/http_server/Cargo.toml index ce122531d2..a94d018f7f 100644 --- a/crates/http_server/Cargo.toml +++ b/crates/http_server/Cargo.toml @@ -10,12 +10,13 @@ workspace = true [dependencies] axum.workspace = true +hyper.workspace = true papyrus_config.workspace = true serde.workspace = true starknet_api.workspace = true -starknet_gateway.workspace = true starknet_gateway_types.workspace = true starknet_mempool_infra.workspace = true +thiserror.workspace = true tracing.workspace = true validator.workspace = true diff --git a/crates/http_server/src/errors.rs b/crates/http_server/src/errors.rs index 8b13789179..4a0a5122bc 100644 --- a/crates/http_server/src/errors.rs +++ b/crates/http_server/src/errors.rs @@ -1 +1,8 @@ +use thiserror::Error; +/// Errors originating from `[`HttpServer::run`]` command. +#[derive(Debug, Error)] +pub enum HttpServerRunError { + #[error(transparent)] + ServerStartupError(#[from] hyper::Error), +} diff --git a/crates/http_server/src/http_server.rs b/crates/http_server/src/http_server.rs index c216f8cf29..013ea6a590 100644 --- a/crates/http_server/src/http_server.rs +++ b/crates/http_server/src/http_server.rs @@ -3,11 +3,10 @@ use std::clone::Clone; use std::net::SocketAddr; use axum::extract::State; -use axum::routing::{get, post}; +use axum::routing::post; use axum::{async_trait, Json, Router}; use starknet_api::rpc_transaction::RpcTransaction; use starknet_api::transaction::TransactionHash; -use starknet_gateway::errors::GatewayRunError; use starknet_gateway_types::communication::SharedGatewayClient; use starknet_gateway_types::errors::GatewaySpecError; use starknet_gateway_types::gateway_types::GatewayInput; @@ -16,6 +15,7 @@ use starknet_mempool_infra::errors::ComponentError; use tracing::{error, info, instrument}; use crate::config::HttpServerConfig; +use crate::errors::HttpServerRunError; #[cfg(test)] #[path = "http_server_test.rs"] @@ -39,8 +39,7 @@ impl HttpServer { HttpServer { config, app_state } } - // TODO(Tsabary/Lev): Rename "GatewayRunError" to "HttpServerRunError". - pub async fn run(&mut self) -> Result<(), GatewayRunError> { + pub async fn run(&mut self) -> Result<(), HttpServerRunError> { // Parses the bind address from HttpServerConfig, returning an error for invalid addresses. let HttpServerConfig { ip, port } = self.config; let addr = SocketAddr::new(ip, port); @@ -52,20 +51,12 @@ impl HttpServer { } pub fn app(&self) -> Router { - Router::new() - .route("/is_alive", get(is_alive)) - .route("/add_tx", post(add_tx)) - .with_state(self.app_state.clone()) + Router::new().route("/add_tx", post(add_tx)).with_state(self.app_state.clone()) } } // HttpServer handlers. -#[instrument] -async fn is_alive() -> HttpServerResult { - unimplemented!("Future handling should be implemented here."); -} - #[instrument(skip(app_state))] async fn add_tx( State(app_state): State,