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

feat: add functionality to create all components #265

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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion crates/gateway/src/gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ use starknet_mempool_types::mempool_types::{Account, MempoolInput};
use starknet_sierra_compile::compile::{compile_sierra_to_casm, CompilationUtilError};
use starknet_sierra_compile::utils::into_contract_class_for_compilation;

use crate::config::{GatewayConfig, GatewayNetworkConfig};
use crate::config::{GatewayConfig, GatewayNetworkConfig, RpcStateReaderConfig};
use crate::errors::{GatewayError, GatewayRunError};
use crate::rpc_state_reader::RpcStateReaderFactory;
use crate::starknet_api_test_utils::get_sender_address;
use crate::state_reader::StateReaderFactory;
use crate::stateful_transaction_validator::StatefulTransactionValidator;
Expand Down Expand Up @@ -167,3 +168,12 @@ fn compile_contract_class(declare_tx: &RPCDeclareTransaction) -> GatewayResult<C
)?;
Ok(class_info)
}

pub fn create_gateway(
config: GatewayConfig,
rpc_state_reader_config: RpcStateReaderConfig,
client: SharedMempoolClient,
) -> Gateway {
let state_reader_factory = Arc::new(RpcStateReaderFactory { config: rpc_state_reader_config });
Gateway::new(config, state_reader_factory, client)
}
2 changes: 2 additions & 0 deletions crates/mempool_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ workspace = true
clap.workspace = true
const_format.workspace = true
starknet_gateway = { path = "../gateway", version = "0.0" }
starknet_mempool = { path = "../mempool", version = "0.0" }
starknet_mempool_types = { path = "../mempool_types", version = "0.0" }
serde.workspace = true
papyrus_config.workspace = true
tokio.workspace = true
Expand Down
30 changes: 30 additions & 0 deletions crates/mempool_node/src/components.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use starknet_gateway::gateway::{create_gateway, Gateway};
use starknet_mempool::mempool::Mempool;

use crate::communication::MempoolNodeClients;
use crate::config::MempoolNodeConfig;

pub struct Components {
pub gateway: Option<Gateway>,
pub mempool: Option<Mempool>,
}

pub fn create_components(config: &MempoolNodeConfig, clients: &MempoolNodeClients) -> Components {
let gateway_component = if config.components.gateway_component.execute {
let mempool_clent =
clients.get_mempool_client().expect("Mempool Client should be available");

Some(create_gateway(
config.gateway_config.clone(),
config.rpc_state_reader_config.clone(),
mempool_clent,
))
} else {
None
};

let mempool_component =
if config.components.mempool_component.execute { Some(Mempool::empty()) } else { None };

Components { gateway: gateway_component, mempool: mempool_component }
}
2 changes: 2 additions & 0 deletions crates/mempool_node/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
pub mod communication;
pub mod components;
pub mod config;
pub mod version;
Loading