diff --git a/Cargo.lock b/Cargo.lock index 11725ff2..e2a34388 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3737,7 +3737,6 @@ dependencies = [ "serde_json", "serde_yaml", "sha2", - "snarkos-aot", "snot-common", "tarpc", "tokio", diff --git a/crates/snot-agent/src/rpc.rs b/crates/snot-agent/src/rpc.rs index f3fb84de..b9b09a37 100644 --- a/crates/snot-agent/src/rpc.rs +++ b/crates/snot-agent/src/rpc.rs @@ -70,10 +70,6 @@ impl AgentService for AgentRpcServer { _: context::Context, target: AgentState, ) -> Result<(), ReconcileError> { - if matches!(target, AgentState::Cannon(_, _)) { - unimplemented!("tx cannons are unimplemented"); - } - // acquire the handle lock let mut handle_container = self.state.reconcilation_handle.lock().await; @@ -163,7 +159,7 @@ impl AgentService for AgentRpcServer { // use `tar` to decompress the storage let mut tar_child = Command::new("tar") - .current_dir(&base_path) + .current_dir(base_path) .arg("-xzf") .arg(LEDGER_STORAGE_FILE) .kill_on_drop(true) @@ -254,9 +250,6 @@ impl AgentService for AgentRpcServer { *child_lock = Some(child); } - - // TODO - AgentState::Cannon(_, _) => unimplemented!(), } Ok(()) diff --git a/crates/snot-common/src/state.rs b/crates/snot-common/src/state.rs index 016bfd88..32cdc2a3 100644 --- a/crates/snot-common/src/state.rs +++ b/crates/snot-common/src/state.rs @@ -10,14 +10,13 @@ use serde::{de::Error, Deserialize, Serialize}; type AgentId = usize; type StorageId = usize; -type CannonSourceId = usize; #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub enum AgentState { #[default] + // A node in the inventory can function as a transaction cannon Inventory, Node(StorageId, NodeState), - Cannon(StorageId, CannonState), } #[derive(Debug, Clone, Serialize, Deserialize)] @@ -31,43 +30,6 @@ pub struct NodeState { pub validators: Vec, } -/// Transaction cannon modes. -/// When a target node is specified, it MUST have REST ports available for -/// both broadcasting and for checking if a transaction has been confirmed for -/// private transactions (record must exist before transfer_private can be run) -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum CannonState { - /// Generate transactions and submit them to the control-plane - AheadOfTime { - mode: TxGenMode, - pks: Vec, - addrs: Vec, - }, - /// Generate transactions in realtime and submit them to a target node - Realtime { - target: AgentPeer, - mode: TxGenMode, - pks: Vec, - addrs: Vec, - }, - /// Playback transactions from a file to a target node - Playback { - target: AgentPeer, - // number of transactions per second to emit - rate: u16, - // total number of transactions to emit - total: u32, - source: CannonSourceId, - }, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub enum TxGenMode { - All, - OnlyPrivate, - OnlyPublic, -} - // // agent code // impl AgentState { // async fn reconcile(&self, target: AgentState) { @@ -267,7 +229,7 @@ impl Display for NodeKey { write!(f, "{}/{}", self.ty, self.id)?; if let Some(ns) = &self.ns { f.write_char('@')?; - f.write_str(&ns)?; + f.write_str(ns)?; } Ok(()) diff --git a/crates/snot/Cargo.toml b/crates/snot/Cargo.toml index e1971e9a..1826ab38 100644 --- a/crates/snot/Cargo.toml +++ b/crates/snot/Cargo.toml @@ -22,7 +22,6 @@ serde.workspace = true serde_json.workspace = true serde_yaml.workspace = true sha2 = "0.10.8" -snarkos-aot = { path = "../aot", default-features = false } snot-common = { path = "../snot-common" } tarpc.workspace = true tokio.workspace = true diff --git a/crates/snot/src/schema/storage.rs b/crates/snot/src/schema/storage.rs index 355025c2..acd4dbdb 100644 --- a/crates/snot/src/schema/storage.rs +++ b/crates/snot/src/schema/storage.rs @@ -1,6 +1,7 @@ use std::{ ops::Deref, path::PathBuf, + process::Stdio, sync::atomic::{AtomicUsize, Ordering}, }; @@ -29,7 +30,7 @@ pub struct StorageGeneration { pub path: PathBuf, // TODO: individually validate arguments, or just pass them like this? - pub genesis: snarkos_aot::genesis::Genesis, + pub genesis: GenesisGeneration, pub ledger: LedgerGeneration, #[serde(default)] @@ -46,11 +47,32 @@ pub struct Transaction { pub destinations: Vec, } +#[derive(Deserialize, Debug, Clone)] +pub struct GenesisGeneration { + pub output: PathBuf, +} + +impl Default for GenesisGeneration { + fn default() -> Self { + Self { + output: PathBuf::from("genesis.block"), + } + } +} + #[derive(Deserialize, Debug, Clone)] pub struct LedgerGeneration { pub output: PathBuf, } +impl Default for LedgerGeneration { + fn default() -> Self { + Self { + output: PathBuf::from("ledger"), + } + } +} + #[derive(Debug, Clone, Serialize)] pub struct FilenameString(String); @@ -129,15 +151,36 @@ impl Document { break 'generate; } - generation.genesis = snarkos_aot::genesis::Genesis { + generation.genesis = GenesisGeneration { output: base.join("genesis.block"), - ledger: None, - additional_accounts_output: Some(base.join("accounts.json")), - committee_output: Some(base.join("committee.json")), - ..generation.genesis }; - - tokio::task::spawn_blocking(move || generation.genesis.parse()).await??; + // generation.genesis = snarkos_aot::genesis::Genesis { + // output: base.join("genesis.block"), + // ledger: None, + // additional_accounts_output: Some(base.join("accounts.json")), + // committee_output: Some(base.join("committee.json")), + // ..generation.genesis + // }; + + // generate the genesis block using the aot cli + Command::new("./target/release/snarkos-aot") + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .current_dir(&base) + .arg("genesis") + .arg("--output") + .arg(&generation.genesis.output) + .arg("--committee-size") + .arg("5") + .arg("--committee-output") + .arg(base.join("committee.json")) + .arg("--additional-accounts") + .arg("5") + .arg("--additional-accounts-output") + .arg(base.join("accounts.json")) + .spawn()? + .wait() + .await?; // TODO: transactions }