Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"batcher_config.storage.mmap_file_config.max_object_size": 1073741824,
"batcher_config.storage.mmap_file_config.max_size": 1099511627776,
"batcher_config.storage.scope": "StateOnly",
"batcher_config.storage_reader_server_config.socket": "0.0.0.0:8080",
"batcher_config.storage_reader_server_config.ip": "0.0.0.0",
"batcher_config.storage_reader_server_config.port": 8080,
"batcher_config.storage_reader_server_config.enable": false,
"batcher_config.propose_l1_txs_every": 10
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"batcher_config.storage.mmap_file_config.max_object_size": 1073741824,
"batcher_config.storage.mmap_file_config.max_size": 1099511627776,
"batcher_config.storage.scope": "StateOnly",
"batcher_config.storage_reader_server_config.socket": "0.0.0.0:8080",
"batcher_config.storage_reader_server_config.enable": false
"batcher_config.storage_reader_server_config.enable": false,
"batcher_config.storage_reader_server_config.ip": "0.0.0.0",
"batcher_config.storage_reader_server_config.port": "$$$_BATCHER_CONFIG-STORAGE_READER_SERVER_CONFIG-PORT_$$$"
}
11 changes: 8 additions & 3 deletions crates/apollo_node/resources/config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,15 @@
"privacy": "Public",
"value": false
},
"batcher_config.storage_reader_server_config.socket": {
"description": "The socket address for the storage reader HTTP server.",
"batcher_config.storage_reader_server_config.ip": {
"description": "The IP address for the storage reader HTTP server.",
"privacy": "Public",
"value": "0.0.0.0:8080"
"value": "0.0.0.0"
},
"batcher_config.storage_reader_server_config.port": {
"description": "The port for the storage reader HTTP server.",
"privacy": "Public",
"value": 8080
},
"chain_id": {
"description": "The chain to follow. For more details see https://docs.starknet.io/documentation/architecture_and_concepts/Blocks/transactions/#chain-id.",
Expand Down
33 changes: 21 additions & 12 deletions crates/apollo_storage/src/storage_reader_server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeMap;
use std::io;
use std::marker::PhantomData;
use std::net::{Ipv4Addr, SocketAddr};
use std::net::{IpAddr, Ipv4Addr, SocketAddr};

use apollo_config::dumping::{ser_param, SerializeConfig};
use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam};
Expand All @@ -24,32 +24,40 @@ mod storage_reader_server_test;
/// Configuration for the storage reader server.
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct ServerConfig {
/// The socket address to bind the server to.
pub socket: SocketAddr,
/// The socket address for the server.
pub ip: IpAddr,
/// The port for the server.
pub port: u16,
/// Whether the server is enabled.
pub enable: bool,
}

impl ServerConfig {
/// Creates a new server configuration.
pub fn new(socket: SocketAddr, enable: bool) -> Self {
Self { socket, enable }
pub fn new(ip: IpAddr, port: u16, enable: bool) -> Self {
Self { ip, port, enable }
}
}

impl Default for ServerConfig {
fn default() -> Self {
Self { socket: (Ipv4Addr::UNSPECIFIED, 8080).into(), enable: false }
Self { ip: Ipv4Addr::UNSPECIFIED.into(), port: 8080, enable: false }
}
}

impl SerializeConfig for ServerConfig {
fn dump(&self) -> BTreeMap<ParamPath, SerializedParam> {
BTreeMap::from_iter([
ser_param(
"socket",
&self.socket.to_string(),
"The socket address for the storage reader HTTP server.",
"ip",
&self.ip.to_string(),
"The IP address for the storage reader HTTP server.",
ParamPrivacyInput::Public,
),
ser_param(
"port",
&self.port,
"The port for the storage reader HTTP server.",
ParamPrivacyInput::Public,
),
ser_param(
Expand Down Expand Up @@ -140,12 +148,13 @@ where
info!("Storage reader server is disabled, not starting");
return Ok(());
}
info!("Starting storage reader server on {}", self.config.socket);
let socket = SocketAddr::from((self.config.ip, self.config.port));
info!("Starting storage reader server on {}", socket);
let app = self.app();
info!("Storage reader server listening on {}", self.config.socket);
info!("Storage reader server listening on {}", socket);

// Start the server
axum::Server::bind(&self.config.socket).serve(app.into_make_service()).await.map_err(|e| {
axum::Server::bind(&socket).serve(app.into_make_service()).await.map_err(|e| {
error!("Storage reader server error: {}", e);
StorageError::IOError(io::Error::other(e))
})
Expand Down
14 changes: 5 additions & 9 deletions crates/apollo_storage/src/storage_reader_server_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::net::{Ipv4Addr, SocketAddr};
use std::net::{IpAddr, Ipv4Addr};

use async_trait::async_trait;
use axum::body::{Body, Bytes, HttpBody};
Expand Down Expand Up @@ -69,8 +69,7 @@ async fn test_endpoint_successful_query() {
.commit()
.unwrap();

let socket = SocketAddr::from((Ipv4Addr::LOCALHOST, 8081));
let config = ServerConfig::new(socket, true);
let config = ServerConfig::new(IpAddr::from(Ipv4Addr::LOCALHOST), 8081, true);

let server =
StorageReaderServer::<TestHandler, TestRequest, TestResponse>::new(reader.clone(), config);
Expand All @@ -92,8 +91,7 @@ async fn test_endpoint_successful_query() {
async fn test_endpoint_query_nonexistent_block() {
let ((reader, _writer), _temp_dir) = get_test_storage();

let socket = SocketAddr::from((Ipv4Addr::LOCALHOST, 8082));
let config = ServerConfig::new(socket, true);
let config = ServerConfig::new(IpAddr::from(Ipv4Addr::LOCALHOST), 8082, true);

let server =
StorageReaderServer::<TestHandler, TestRequest, TestResponse>::new(reader.clone(), config);
Expand Down Expand Up @@ -128,8 +126,7 @@ async fn send_storage_query<T: Serialize>(app: Router, request: &T) -> Response
async fn test_endpoint_handler_error() {
let ((reader, _writer), _temp_dir) = get_test_storage();

let socket = SocketAddr::from((Ipv4Addr::LOCALHOST, 8083));
let config = ServerConfig::new(socket, true);
let config = ServerConfig::new(IpAddr::from(Ipv4Addr::LOCALHOST), 8083, true);

let server =
StorageReaderServer::<ErrorHandler, TestRequest, TestResponse>::new(reader.clone(), config);
Expand All @@ -150,8 +147,7 @@ async fn test_endpoint_handler_error() {
async fn test_endpoint_invalid_json() {
let ((reader, _writer), _temp_dir) = get_test_storage();

let socket = SocketAddr::from((Ipv4Addr::LOCALHOST, 8084));
let config = ServerConfig::new(socket, true);
let config = ServerConfig::new(IpAddr::from(Ipv4Addr::LOCALHOST), 8084, true);

let server =
StorageReaderServer::<TestHandler, TestRequest, TestResponse>::new(reader.clone(), config);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ config:
# mountPath: "/config/sequencer/presets" # Override default mount path

sequencerConfig:
batcher_config_storage_reader_server_config_port: 55011
components_batcher_port: 55000
components_batcher_url: "sequencer-core-service"
components_class_manager_port: 55001
Expand Down Expand Up @@ -96,6 +97,10 @@ service:
port: 55010
targetPort: 55010
protocol: TCP
- name: batcher-storage-reader
port: 55011
targetPort: 55011
protocol: TCP
- name: consensus-p2p
port: 53080
targetPort: 53080
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ config:
batcher_config_block_builder_config_proposer_idle_detection_delay_millis: 2000
batcher_config_contract_class_manager_config_cairo_native_run_config_native_classes_whitelist: "All"
batcher_config_contract_class_manager_config_native_compiler_config_max_cpu_time: 600
batcher_config_storage_reader_server_config_port: 55011
class_manager_config_class_manager_config_max_compiled_contract_class_object_size: 4089446
components_batcher_port: 55000
components_batcher_url: sequencer-core-service
Expand Down Expand Up @@ -79,6 +80,10 @@ service:
port: 55009
targetPort: 55009
protocol: TCP
- name: batcher-storage-reader
port: 55011
targetPort: 55011
protocol: TCP

statefulSet:
enabled: true
Expand Down
Loading