partner_chains_cli/
lib.rs1pub(crate) mod cardano_key;
5mod cmd_traits;
6pub mod config;
7pub mod create_chain_spec;
8pub(crate) mod data_source;
9mod deregister;
10pub mod generate_keys;
11pub mod io;
12pub mod keystore;
13pub(crate) mod ogmios;
14pub(crate) mod permissioned_candidates;
15mod prepare_configuration;
16pub mod register;
17pub mod runtime_bindings;
18pub(crate) mod select_utxo;
19mod setup_main_chain_state;
20pub mod start_node;
21
22#[cfg(test)]
23mod tests;
24
25use clap::Parser;
26use io::*;
27use partner_chains_cardano_offchain::await_tx::FixedDelayRetries;
28pub use runtime_bindings::{PartnerChainRuntime, PartnerChainRuntimeBindings, RuntimeTypeWrapper};
29use std::time::Duration;
30
31#[derive(Clone, Debug, clap::Parser)]
32#[command(author, version, about, long_about = None)]
33pub struct CommonArguments {
34 #[arg(default_value = "5", long)]
35 retry_delay_seconds: u64,
36 #[arg(default_value = "59", long)]
37 retry_count: usize,
38}
39
40impl CommonArguments {
41 pub fn retries(&self) -> FixedDelayRetries {
42 FixedDelayRetries::new(Duration::from_secs(self.retry_delay_seconds), self.retry_count)
43 }
44}
45
46#[derive(Clone, Debug, Parser)]
47#[command(
48 after_long_help = HELP_EXAMPLES,
49)]
50pub enum Command<T: PartnerChainRuntime + PartnerChainRuntimeBindings> {
51 GenerateKeys(generate_keys::GenerateKeysCmd),
53 PrepareConfiguration(prepare_configuration::PrepareConfigurationCmd),
55 CreateChainSpec(create_chain_spec::CreateChainSpecCmd<T>),
57 SetupMainChainState(setup_main_chain_state::SetupMainChainStateCmd),
60 StartNode(start_node::StartNodeCmd),
63 Register1(register::register1::Register1Cmd),
65 Register2(register::register2::Register2Cmd),
67 Register3(register::register3::Register3Cmd),
69 Deregister(deregister::DeregisterCmd),
71}
72
73impl<T: PartnerChainRuntime + PartnerChainRuntimeBindings> Command<T> {
74 pub fn run<C: IOContext>(&self, context: &C) -> anyhow::Result<()> {
75 match self {
76 Command::GenerateKeys(cmd) => cmd.run(context),
77 Command::PrepareConfiguration(cmd) => cmd.run(context),
78 Command::CreateChainSpec(cmd) => cmd.run(context),
79 Command::SetupMainChainState(cmd) => cmd.run(context),
80 Command::StartNode(cmd) => cmd.run(context),
81 Command::Register1(cmd) => cmd.run(context),
82 Command::Register2(cmd) => cmd.run(context),
83 Command::Register3(cmd) => cmd.run(context),
84 Command::Deregister(cmd) => cmd.run(context),
85 }
86 }
87}
88
89pub trait CmdRun {
90 fn run<C: IOContext>(&self, context: &C) -> anyhow::Result<()>;
91}
92
93const HELP_EXAMPLES: &str = r#"
94╔════════════════════════════════════════════════════════════════════════════════╗
95║ Command groups by role ║
96╠════════════════════════════════════════════════════════════════════════════════╣
97║ The following sections outline the typical sequence of commands for each role. ║
98║ The numbering indicates the recommended order of execution. Please note that ║
99║ this order may vary depending on specific deployment scenarios. ║
100╟────────────────────────────────────────────────────────────────────────────────╢
101║ Governance Authority: ║
102║ 1. generate-keys : generate necessary cryptographic keys ║
103║ 2. prepare-configuration : set up the partner chain configuration ║
104║ 3. create-chain-spec : create the chain specification file ║
105║ 4. setup-main-chain-state: configure the main chain parameters ║
106║ 5. start-node : start the validator node ║
107╟────────────────────────────────────────────────────────────────────────────────╢
108║ Registered Validator: ║
109║ 1. generate-keys : generate validator keys ║
110║ 2. register1 : initiate the registration process ║
111║ 3. register2 : complete registration with cold keys ║
112║ 4. register3 : finalize registration ║
113║ 5. start-node : start the validator node ║
114║ 6. deregister : cancel registration ║
115║ ║
116║ Note: This sequence assumes that the chain-spec.json and ║
117║ pc-chain-config.json files have been obtained from ║
118║ the Governance Authority and are present in the working directory. ║
119╟────────────────────────────────────────────────────────────────────────────────╢
120║ Permissioned Validator: ║
121║ 1. generate-keys : generate validator keys ║
122║ 2. start-node : start the validator node ║
123║ ║
124║ Note: After executing 'generate-keys', the generated keys must be shared ║
125║ with the Governance Authority. The 'start-node' command can only be ║
126║ executed after the Governance Authority has established the partner ║
127║ chain on the main network. This sequence assumes that the ║
128║ chain-spec.json and pc-chain-config.json files have ║
129║ been obtained from the Governance Authority and are present in the ║
130║ working directory. ║
131╚════════════════════════════════════════════════════════════════════════════════╝
132"#;