Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip with http server / gateway bug #2888

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions crates/starknet_http_server/src/http_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,30 @@ async fn add_tx(
) -> HttpServerResult<Json<TransactionHash>> {
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(|e| {
debug!("Error while adding transaction: {}", e);
HttpServerError::from(e)
});

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: HttpServerResult<TransactionHash>,
) -> 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
Loading