2024-07-10 21:59:26 +00:00
|
|
|
use std::{env, net::SocketAddr};
|
2024-02-22 20:48:13 +00:00
|
|
|
|
|
|
|
use clap::Parser;
|
|
|
|
use color_eyre::eyre::{eyre, Result};
|
2024-09-18 20:04:33 +00:00
|
|
|
use cosmrs::AccountId;
|
2024-09-25 19:14:06 +00:00
|
|
|
use quartz_common::enclave::types::Fmspc;
|
2024-09-18 20:04:33 +00:00
|
|
|
use tendermint::Hash;
|
2024-02-22 20:48:13 +00:00
|
|
|
use tendermint_light_client::types::{Height, TrustThreshold};
|
|
|
|
|
|
|
|
fn parse_trust_threshold(s: &str) -> Result<TrustThreshold> {
|
|
|
|
if let Some((l, r)) = s.split_once('/') {
|
|
|
|
TrustThreshold::new(l.parse()?, r.parse()?).map_err(Into::into)
|
|
|
|
} else {
|
|
|
|
Err(eyre!(
|
|
|
|
"invalid trust threshold: {s}, format must be X/Y where X and Y are integers"
|
|
|
|
))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Parser)]
|
|
|
|
#[command(author, version, about, long_about = None)]
|
|
|
|
pub struct Cli {
|
|
|
|
/// RPC server address
|
2024-07-10 21:59:26 +00:00
|
|
|
#[clap(long, default_value_t = default_rpc_addr())]
|
2024-02-22 20:48:13 +00:00
|
|
|
pub rpc_addr: SocketAddr,
|
|
|
|
|
|
|
|
/// Identifier of the chain
|
|
|
|
#[clap(long)]
|
|
|
|
pub chain_id: String,
|
|
|
|
|
2024-09-25 19:14:06 +00:00
|
|
|
/// FMSPC (Family-Model-Stepping-Platform-Custom SKU)
|
|
|
|
#[clap(long)]
|
|
|
|
pub fmspc: Option<Fmspc>,
|
|
|
|
|
2024-09-05 10:07:35 +00:00
|
|
|
/// TcbInfo contract address
|
|
|
|
#[clap(long)]
|
2024-09-12 09:10:24 +00:00
|
|
|
pub tcbinfo_contract: Option<AccountId>,
|
2024-09-05 10:07:35 +00:00
|
|
|
|
2024-09-25 19:14:06 +00:00
|
|
|
/// DCAP verifier contract address
|
|
|
|
#[clap(long)]
|
|
|
|
pub dcap_verifier_contract: Option<AccountId>,
|
|
|
|
|
2024-02-22 20:48:13 +00:00
|
|
|
/// Height of the trusted header (AKA root-of-trust)
|
|
|
|
#[clap(long)]
|
|
|
|
pub trusted_height: Height,
|
|
|
|
|
|
|
|
/// Hash of the trusted header (AKA root-of-trust)
|
|
|
|
#[clap(long)]
|
|
|
|
pub trusted_hash: Hash,
|
|
|
|
|
|
|
|
/// Trust threshold
|
|
|
|
#[clap(long, value_parser = parse_trust_threshold, default_value_t = TrustThreshold::TWO_THIRDS)]
|
|
|
|
pub trust_threshold: TrustThreshold,
|
|
|
|
|
|
|
|
/// Trusting period, in seconds (default: two weeks)
|
|
|
|
#[clap(long, default_value = "1209600")]
|
|
|
|
pub trusting_period: u64,
|
|
|
|
|
|
|
|
/// Maximum clock drift, in seconds
|
|
|
|
#[clap(long, default_value = "5")]
|
|
|
|
pub max_clock_drift: u64,
|
|
|
|
|
|
|
|
/// Maximum block lag, in seconds
|
|
|
|
#[clap(long, default_value = "5")]
|
|
|
|
pub max_block_lag: u64,
|
2024-09-18 20:04:33 +00:00
|
|
|
|
|
|
|
#[clap(long, default_value = "127.0.0.1:11090")]
|
|
|
|
pub node_url: String,
|
|
|
|
|
|
|
|
#[clap(long, default_value = "admin")]
|
|
|
|
pub tx_sender: String,
|
2024-02-22 20:48:13 +00:00
|
|
|
}
|
2024-07-10 21:59:26 +00:00
|
|
|
|
|
|
|
fn default_rpc_addr() -> SocketAddr {
|
2024-09-18 20:04:33 +00:00
|
|
|
let port = env::var("QUARTZ_ENCLAVE_RPC_PORT").unwrap_or_else(|_| "11090".to_string());
|
2024-07-18 23:34:31 +00:00
|
|
|
format!("127.0.0.1:{}", port)
|
|
|
|
.parse()
|
|
|
|
.expect("Invalid socket address")
|
2024-07-10 21:59:26 +00:00
|
|
|
}
|