Skip to content

Commit

Permalink
feat(starknet_mempool): add mempool config to sequencer node
Browse files Browse the repository at this point in the history
  • Loading branch information
dafnamatsry committed Feb 19, 2025
1 parent 91e4746 commit 258c759
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

17 changes: 16 additions & 1 deletion config/sequencer/default_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,21 @@
"privacy": "Public",
"value": 0
},
"mempool_config.enable_fee_escalation": {
"description": "If true, transactions can be replaced with higher fee transactions.",
"privacy": "Public",
"value": true
},
"mempool_config.fee_escalation_percentage": {
"description": "Percentage increase for tip and max gas price to enable transaction replacement.",
"privacy": "Public",
"value": 10
},
"mempool_config.transaction_ttl": {
"description": "Time-to-live for transactions in the mempool, in seconds.",
"privacy": "Public",
"value": 60
},
"mempool_p2p_config.network_buffer_size": {
"description": "Network buffer size.",
"privacy": "Public",
Expand Down Expand Up @@ -1449,4 +1464,4 @@
"privacy": "TemporaryValue",
"value": 1000000
}
}
}
1 change: 1 addition & 0 deletions crates/starknet_integration_tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ starknet_gateway = { workspace = true, features = ["testing"] }
starknet_gateway_types.workspace = true
starknet_http_server = { workspace = true, features = ["testing"] }
starknet_infra_utils = { workspace = true, features = ["testing"] }
starknet_mempool.workspace = true
starknet_mempool_p2p.workspace = true
starknet_monitoring_endpoint = { workspace = true, features = ["testing"] }
starknet_sequencer_infra = { workspace = true, features = ["testing"] }
Expand Down
7 changes: 7 additions & 0 deletions crates/starknet_integration_tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use starknet_gateway::config::{
};
use starknet_http_server::test_utils::create_http_server_config;
use starknet_infra_utils::test_utils::AvailablePorts;
use starknet_mempool::config::MempoolConfig;
use starknet_mempool_p2p::config::MempoolP2pConfig;
use starknet_monitoring_endpoint::config::MonitoringEndpointConfig;
use starknet_sequencer_node::config::component_config::ComponentConfig;
Expand Down Expand Up @@ -151,6 +152,7 @@ pub fn create_node_config(
let fee_token_addresses = chain_info.fee_token_addresses.clone();
let batcher_config = create_batcher_config(batcher_storage_config, chain_info.clone());
let gateway_config = create_gateway_config(chain_info.clone());
let mempool_config = create_mempool_config();
let http_server_config =
create_http_server_config(available_ports.get_next_local_host_socket());
let class_manager_config = create_class_manager_config(class_manager_storage_config);
Expand All @@ -163,6 +165,7 @@ pub fn create_node_config(
consensus_manager_config,
gateway_config,
http_server_config,
mempool_config,
mempool_p2p_config,
monitoring_endpoint_config,
state_sync_config,
Expand Down Expand Up @@ -458,6 +461,10 @@ pub fn create_batcher_config(
}
}

pub fn create_mempool_config() -> MempoolConfig {
MempoolConfig { transaction_ttl: Duration::from_secs(5 * 60), ..Default::default() }
}

pub fn create_class_manager_config(
class_storage_config: FsClassStorageConfig,
) -> FsClassManagerConfig {
Expand Down
3 changes: 2 additions & 1 deletion crates/starknet_mempool/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ pub type LocalMempoolServer =
pub type RemoteMempoolServer = RemoteComponentServer<MempoolRequest, MempoolResponse>;

pub fn create_mempool(
config: MempoolConfig,
mempool_p2p_propagator_client: SharedMempoolP2pPropagatorClient,
) -> MempoolCommunicationWrapper {
MempoolCommunicationWrapper::new(
Mempool::new(MempoolConfig::default(), Arc::new(InstantClock)),
Mempool::new(config, Arc::new(InstantClock)),
mempool_p2p_propagator_client,
)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet_mempool/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl SerializeConfig for MempoolConfig {
),
ser_param(
"transaction_ttl",
&self.transaction_ttl,
&self.transaction_ttl.as_secs(),
"Time-to-live for transactions in the mempool, in seconds.",
ParamPrivacyInput::Public,
),
Expand Down
3 changes: 2 additions & 1 deletion crates/starknet_sequencer_node/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ pub async fn create_node_components(
let mempool_p2p_propagator_client = clients
.get_mempool_p2p_propagator_shared_client()
.expect("Propagator Client should be available");
let mempool = create_mempool(mempool_p2p_propagator_client);
let mempool =
create_mempool(config.mempool_config.clone(), mempool_p2p_propagator_client);
Some(mempool)
}
ReactiveComponentExecutionMode::Disabled | ReactiveComponentExecutionMode::Remote => None,
Expand Down
4 changes: 4 additions & 0 deletions crates/starknet_sequencer_node/src/config/node_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use starknet_http_server::config::HttpServerConfig;
use starknet_infra_utils::path::resolve_project_relative_path;
use starknet_l1_provider::l1_scraper::L1ScraperConfig;
use starknet_l1_provider::L1ProviderConfig;
use starknet_mempool::config::MempoolConfig;
use starknet_mempool_p2p::config::MempoolP2pConfig;
use starknet_monitoring_endpoint::config::MonitoringEndpointConfig;
use starknet_sierra_multicompile::config::SierraCompilationConfig;
Expand Down Expand Up @@ -154,6 +155,8 @@ pub struct SequencerNodeConfig {
#[validate]
pub l1_scraper_config: L1ScraperConfig,
#[validate]
pub mempool_config: MempoolConfig,
#[validate]
pub mempool_p2p_config: MempoolP2pConfig,
#[validate]
pub monitoring_endpoint_config: MonitoringEndpointConfig,
Expand All @@ -175,6 +178,7 @@ impl SerializeConfig for SequencerNodeConfig {
append_sub_config_name(self.gateway_config.dump(), "gateway_config"),
append_sub_config_name(self.http_server_config.dump(), "http_server_config"),
append_sub_config_name(self.compiler_config.dump(), "compiler_config"),
append_sub_config_name(self.mempool_config.dump(), "mempool_config"),
append_sub_config_name(self.mempool_p2p_config.dump(), "mempool_p2p_config"),
append_sub_config_name(
self.monitoring_endpoint_config.dump(),
Expand Down

0 comments on commit 258c759

Please sign in to comment.