-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlib.rs
More file actions
61 lines (49 loc) · 1.74 KB
/
lib.rs
File metadata and controls
61 lines (49 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
mod attestation;
mod key_manager;
mod server;
mod snapshot;
mod summit;
pub mod utils;
const ENCLAVE_DEFAULT_ENDPOINT_IP: &str = "127.0.0.1";
const DEFAULT_RETH_RPC: &str = "127.0.0.1:8545";
pub const ENCLAVE_DEFAULT_ENDPOINT_PORT: u16 = 7878;
const DEFAULT_ENCLAVE_SUMMIT_SOCKET: &str = "/tmp/reth_enclave_socket.ipc";
use anyhow::Result;
use clap::Parser;
use seismic_enclave::mock::start_mock_server;
use std::net::SocketAddr;
/// Command line arguments for the enclave server
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
pub struct Args {
/// The ip to bind the server to
#[arg(long, default_value_t = ENCLAVE_DEFAULT_ENDPOINT_IP.to_string())]
pub ip: String,
/// The port to bind the server to
#[arg(long, default_value_t = ENCLAVE_DEFAULT_ENDPOINT_PORT)]
pub port: u16,
/// Flag if this is the genesis node that needs to generate the keys
#[arg(long, default_value_t = false)]
pub genesis_node: bool,
/// List of peer ips to fetch root key from. Must be {ip}:{port}
#[arg(long)]
pub peers: Vec<String>,
/// path to unix socket used to communicate with Summit
#[arg(long, default_value_t = DEFAULT_ENCLAVE_SUMMIT_SOCKET.to_string())]
pub summit_socket: String,
#[arg(long, default_value_t =DEFAULT_RETH_RPC.to_string())]
pub reth_rpc_url: String,
#[arg(long, default_value_t = false)]
pub mock: bool,
}
impl Args {
pub async fn start(self) -> Result<()> {
let addr: SocketAddr = format!("{}:{}", self.ip, self.port).parse()?;
println!("Starting TDX Quote JSON-RPC Server on {addr}...");
if self.mock {
start_mock_server(addr).await
} else {
server::start_server(addr, self).await
}
}
}