main.rs

Overview

This file implements the command-line interface (CLI) entry point for managing and configuring an AckiNacki node. It provides subcommands for setting up node configurations, generating BLS (Boneh–Lynn–Shacham) key pairs, and producing cryptographic keys compatible with the TVM client. The CLI parses arguments, loads or creates node configurations, manages cryptographic keys, and persists configurations or keys to files. The file extensively interacts with the node's configuration system, cryptographic libraries, and networking utilities.


Command-Line Argument Parsing

The CLI uses the clap crate to define argument parsing structures:

Args Struct

Commands Enum

Config Struct

Bls Struct

GenKeys Struct


Functions and Methods

fn main() -> anyhow::Result<()>


fn save_keys_map_to_file(path: PathBuf, keys_map: HashMap<PubKey, (Secret, RndSeed)>) -> anyhow::Result<()>


fn parse_node_addr(s: &str) -> Result<SocketAddr, String>

fn parse_gossip_addr(s: &str) -> Result<SocketAddr, String>


Important Implementation Details


Interactions with other System Components


Usage Examples

Generate BLS Key Pair with File Output and Remove Old Keys

ackinacki bls --path ./bls_keys.json --remove_old

This generates a new BLS key pair, removes the old key file if it exists, and appends the new key pair to the file.

Create or Update Node Configuration

ackinacki config --config-file-path ./node_config.json --default --node-id <64-char-hex> --chitchat-cluster-id mycluster --node-advertise-addr 192.168.1.2:8500 --api-addr 127.0.0.1:5000 --api-advertise-addr http://localhost:5000

Creates a default configuration if none exists, setting the required fields for node ID and network addresses.

Generate TVM Signing Keys and Print to Stdout

ackinacki genkeys

Generates a random TVM signing key pair and prints the JSON representation to the console.


Visual Diagram

flowchart TD
A["main()"] --> B{Commands}
B --> C[Config]
B --> D[Bls]
B --> E[GenKeys]
C --> F[Load config file]
F --> G{File valid?}
G -- Yes --> H[Update config with CLI params]
G -- No & default flag --> I[Create default config]
I --> H
H --> J[Save config to file]
D --> K[Generate BLS key pair]
K --> L{Has path?}
L -- Yes --> M{Remove old file?}
M -- Yes --> N[Delete old file]
M -- No --> O[Load existing keys]
O --> P[Insert new key]
N --> P
P --> Q[Save keys map to file]
L -- No --> R[Print key pair]
E --> S[Create TVM Client]
S --> T[Generate random signing keys]
T --> U{Has path?}
U -- Yes --> V[Write keys to file]
U -- No --> W[Print keys JSON]

References