Skip to content
Open
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
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.

1 change: 1 addition & 0 deletions crates/jstz_node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ tokio-util.workspace = true
tokio.workspace = true
tower.workspace = true
tower-http.workspace = true
url.workspace = true
utoipa.workspace = true
utoipa-axum.workspace = true
utoipa-scalar.workspace = true
Expand Down
7 changes: 7 additions & 0 deletions crates/jstz_node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use serde::{Deserialize, Serialize};
use tempfile::NamedTempFile;
use tezos_crypto_rs::hash::SmartRollupHash;

use crate::simulation::config::SimulationConfig;

#[derive(Debug, Deserialize, Serialize, Clone, PartialEq)]
#[serde(rename_all = "lowercase")]
#[serde(tag = "type")]
Expand Down Expand Up @@ -187,6 +189,8 @@ pub struct JstzNodeConfig {
/// Path to the sqlite db file that keeps the runtime state.
#[serde(skip_serializing_if = "Option::is_none")]
pub runtime_db_path: Option<PathBuf>,
#[serde(skip_serializing_if = "Option::is_none")]
pub simulation: Option<SimulationConfig>,
}

impl JstzNodeConfig {
Expand All @@ -203,6 +207,7 @@ impl JstzNodeConfig {
injector: KeyPair,
mode: RunMode,
storage_sync: bool,
simulation: Option<SimulationConfig>,
) -> Self {
Self {
endpoint: endpoint.clone(),
Expand All @@ -213,6 +218,7 @@ impl JstzNodeConfig {
mode,
storage_sync,
runtime_db_path: None,
simulation,
}
}
}
Expand Down Expand Up @@ -244,6 +250,7 @@ mod tests {
),
RunMode::Default,
true,
None,
);

let json = serde_json::to_value(&config).unwrap();
Expand Down
9 changes: 8 additions & 1 deletion crates/jstz_node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use tower_http::cors::{Any, CorsLayer};

mod api_doc;
mod services;
pub mod simulation;
pub mod storage_sync;
use services::Service;
use utoipa::OpenApi;
Expand All @@ -34,7 +35,7 @@ pub mod config;
pub mod sequencer;
pub use config::RunMode;

use crate::config::RuntimeEnv;
use crate::{config::RuntimeEnv, simulation::config::SimulationConfig};

#[derive(Clone)]
pub struct AppState {
Expand Down Expand Up @@ -76,6 +77,7 @@ pub struct RunOptions {
pub mode: RunMode,
pub storage_sync: bool,
pub runtime_db_path: Option<PathBuf>,
pub simulation: Option<SimulationConfig>,
}

pub async fn run_with_config(config: JstzNodeConfig) -> Result<()> {
Expand All @@ -92,6 +94,7 @@ pub async fn run_with_config(config: JstzNodeConfig) -> Result<()> {
mode: config.mode,
storage_sync: config.storage_sync,
runtime_db_path: config.runtime_db_path,
simulation: config.simulation,
})
.await
}
Expand All @@ -107,6 +110,7 @@ pub async fn run(
mode,
storage_sync,
runtime_db_path,
..
}: RunOptions,
) -> Result<()> {
let rollup_client = OctezRollupClient::new(rollup_endpoint.to_string());
Expand Down Expand Up @@ -383,6 +387,7 @@ mod test {
mode: mode.clone(),
storage_sync: false,
runtime_db_path: None,
simulation: None,
}));

let res = jstz_utils::poll(10, 500, || async {
Expand Down Expand Up @@ -439,6 +444,7 @@ mod test {
mode,
storage_sync: false,
runtime_db_path: None,
simulation: None,
}));

sleep(Duration::from_secs(1)).await;
Expand Down Expand Up @@ -532,6 +538,7 @@ mod test {
mode,
storage_sync: true,
runtime_db_path: None,
simulation: None,
}))
}

Expand Down
14 changes: 14 additions & 0 deletions crates/jstz_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use jstz_node::{
};
use jstz_utils::key_pair::parse_key_file;
use tezos_crypto_rs::hash::SmartRollupHash;
use url::Url;

const DEFAULT_ROLLUP_NODE_RPC_ADDR: &str = "127.0.0.1";
const DEFAULT_ROLLUP_RPC_PORT: u16 = 8932;
Expand Down Expand Up @@ -81,6 +82,18 @@ struct Args {

#[arg(long)]
inbox_checkpoint_path: Option<PathBuf>,

// Enables simulation of operations
#[arg(long, action = ArgAction::SetFalse, requires_all = ["sequencer_endpoint", "simulation_kernel_path"])]
enable_simulation: bool,

// Sequencer endpoint to listen for included operations. Required when simulation is enabled
#[arg(long)]
sequencer_endpoint: Option<Url>,

// Path to RISC-V simulation kernel. Required when simulation is enabled
#[arg(long)]
simulation_kernel_path: Option<PathBuf>,
}

#[tokio::main]
Expand Down Expand Up @@ -119,6 +132,7 @@ async fn main() -> anyhow::Result<()> {
mode: run_mode_builder.build()?,
storage_sync: args.storage_sync,
runtime_db_path: args.runtime_db_path,
simulation: None,
})
.await
}
Expand Down
4 changes: 4 additions & 0 deletions crates/jstz_node/src/simulation/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
use serde::Serialize;

#[derive(Clone, Serialize)]
pub struct SimulationConfig;
1 change: 1 addition & 0 deletions crates/jstz_node/src/simulation/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod config;
1 change: 1 addition & 0 deletions crates/jstzd/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ fn build_jstz_node_config(
injector.clone(),
run_mode_builder.build()?,
config.storage_sync,
None,
))
}

Expand Down
1 change: 1 addition & 0 deletions crates/jstzd/src/task/jstzd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ mod tests {
inbox_checkpoint_path: PathBuf::from("/inbox/checkpoint"),
},
false,
None,
)),
ProtocolParameterBuilder::new()
.set_bootstrap_accounts([BootstrapAccount::new(
Expand Down
1 change: 1 addition & 0 deletions crates/jstzd/tests/jstz_node_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ async fn jstz_node_test() {
),
jstz_node::RunMode::Default,
false,
None,
);
let mut jstz_node = jstzd::task::jstz_node::JstzNode::spawn(jstz_node_config)
.await
Expand Down
1 change: 1 addition & 0 deletions crates/jstzd/tests/jstzd_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ async fn create_jstzd_server(
),
jstz_node::RunMode::Default,
false,
None,
);
let config = JstzdConfig::new(
octez_node_config,
Expand Down