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

Jstzd: serialize rollup config #705

Merged
merged 1 commit into from
Dec 6, 2024
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
2 changes: 1 addition & 1 deletion crates/jstzd/src/task/jstzd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct JstzdConfig {
baker_config: OctezBakerConfig,
#[serde(rename(serialize = "octez-client"))]
octez_client_config: OctezClientConfig,
#[serde(skip_serializing)]
#[serde(rename(serialize = "octez-rollup"))]
octez_rollup_config: OctezRollupConfig,
#[serde(skip_serializing)]
jstz_node_config: JstzNodeConfig,
Expand Down
4 changes: 4 additions & 0 deletions crates/jstzd/tests/jstzd_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ async fn fetch_config_test(jstzd_config: JstzdConfig, jstzd_port: u16) {
"octez-baker",
serde_json::to_value(jstzd_config.baker_config()).unwrap(),
),
(
"octez-rollup",
serde_json::to_value(jstzd_config.octez_rollup_config()).unwrap(),
),
] {
let res =
reqwest::get(&format!("http://localhost:{}/config/{}", jstzd_port, key))
Expand Down
39 changes: 37 additions & 2 deletions crates/octez/src/async/rollup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::unused_port;
use super::{bootstrap::SmartRollupPvmKind, endpoint::Endpoint};
use anyhow::Result;
use http::Uri;
use serde::Deserialize;
use serde::{Deserialize, Serialize};
use std::{
path::{Path, PathBuf},
str::FromStr,
Expand Down Expand Up @@ -119,11 +119,13 @@ impl OctezRollupConfigBuilder {
}
}

#[derive(Clone)]
#[derive(Clone, Serialize)]
pub struct OctezRollupConfig {
pub binary_path: PathBuf,
pub octez_client_base_dir: PathBuf,
pub octez_node_endpoint: Endpoint,
// TODO: https://linear.app/tezos/issue/JSTZ-243/include-rollup-data-dir-in-config
#[serde(skip_serializing)]
pub data_dir: RollupDataDir,
pub address: SmartRollupHash,
pub operator: String,
Expand Down Expand Up @@ -257,4 +259,37 @@ mod test {
Some(PathBuf::from("/tmp/kernel_debug.log"))
);
}

#[test]
fn serialize_config() {
let config = OctezRollupConfigBuilder::new(
Endpoint::localhost(1234),
PathBuf::from("/base_dir"),
SmartRollupHash::from_str("sr1PuFMgaRUN12rKQ3J2ae5psNtwCxPNmGNK").unwrap(),
"operator".to_owned(),
PathBuf::from("/tmp/boot_sector.hex"),
)
.set_kernel_debug_file(Path::new("/tmp/kernel_debug.log"))
.set_data_dir(RollupDataDir::TempWithPreImages {
preimages_dir: PathBuf::from("/tmp/pre_images"),
})
.build()
.unwrap();

let json = serde_json::to_value(config.clone()).unwrap();
assert_eq!(
json,
serde_json::json!({
"binary_path": "octez-smart-rollup-node",
"octez_client_base_dir": "/base_dir",
"octez_node_endpoint": "http://localhost:1234",
"pvm_kind": "wasm_2_0_0",
"address": "sr1PuFMgaRUN12rKQ3J2ae5psNtwCxPNmGNK",
"operator": "operator",
"boot_sector_file": "/tmp/boot_sector.hex",
"rpc_endpoint": format!("http://127.0.0.1:{}", config.rpc_endpoint.port()),
"kernel_debug_file": "/tmp/kernel_debug.log"
})
);
}
}
Loading