Skip to content

Commit

Permalink
wip with http server / gateway bug
Browse files Browse the repository at this point in the history
commit-id:09e6f11e
  • Loading branch information
Itay-Tsabary-Starkware committed Dec 24, 2024
1 parent 636b170 commit d049fae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
10 changes: 10 additions & 0 deletions crates/starknet_http_server/src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,29 @@ async fn add_tx(
record_added_transaction();
let gateway_input: GatewayInput = GatewayInput { rpc_tx: tx, message_metadata: None };

info!("Received tx: {:?}", gateway_input);

let add_tx_result = app_state.gateway_client.add_tx(gateway_input).await.map_err(|join_err| {
error!("Failed to process tx: {}", join_err);
GatewaySpecError::UnexpectedError { data: "Internal server error".to_owned() }
});

info!("Add tx result: {:?}", add_tx_result);

record_added_transaction_status(add_tx_result.is_ok());
info!("Updated the metrics");

add_tx_result_as_json(add_tx_result)
}

pub(crate) fn add_tx_result_as_json(
result: Result<TransactionHash, GatewaySpecError>,
) -> HttpServerResult<Json<TransactionHash>> {
info!("add_tx_result_as_json");

let tx_hash = result?;
info!("tx_hash: {:?}", tx_hash);

Ok(Json(tx_hash))
}

Expand Down
7 changes: 6 additions & 1 deletion crates/starknet_http_server/src/http_server_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use metrics_exporter_prometheus::PrometheusBuilder;
use starknet_api::transaction::TransactionHash;
use starknet_gateway_types::communication::{GatewayClientError, MockGatewayClient};
use starknet_sequencer_infra::component_client::ClientError;
use starknet_sequencer_infra::trace_util::configure_tracing;
use tokio::task;

use crate::config::HttpServerConfig;
Expand Down Expand Up @@ -40,6 +41,8 @@ async fn to_bytes(res: Response) -> Bytes {

#[tokio::test]
async fn get_metrics_test() {
configure_tracing().await;

let prometheus_handle = PrometheusBuilder::new()
.install_recorder()
.expect("should be able to build the recorder and install it globally");
Expand All @@ -61,7 +64,9 @@ async fn get_metrics_test() {
"mock response".to_string(),
))),
1 => Ok(TransactionHash::default()),
_ => Ok(TransactionHash::default()),
_ => Err(GatewayClientError::ClientError(ClientError::UnexpectedResponse(
"mock response".to_string(),
))),
}
});

Expand Down

0 comments on commit d049fae

Please sign in to comment.