From f4b26247c06a449a9d5cd8ca2cf16161c5547f0b Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Thu, 6 Dec 2018 14:01:25 -0800 Subject: [PATCH] Genesis only needs a keypair, not the entire fullnode::Config --- multinode-demo/setup.sh | 2 +- src/bin/genesis.rs | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/multinode-demo/setup.sh b/multinode-demo/setup.sh index 04208f0117..02509abb1e 100755 --- a/multinode-demo/setup.sh +++ b/multinode-demo/setup.sh @@ -99,7 +99,7 @@ if $node_type_leader; then $solana_genesis \ --num_tokens "$num_tokens" \ --mint "$mint_id_path" \ - --bootstrap_leader "$SOLANA_CONFIG_DIR"/leader.json \ + --bootstrap-leader-keypair "$leader_id_path" \ --ledger "$SOLANA_CONFIG_DIR"/ledger \ ls -lhR "$SOLANA_CONFIG_DIR"/ diff --git a/src/bin/genesis.rs b/src/bin/genesis.rs index 10ad7eafe3..c58b199438 100644 --- a/src/bin/genesis.rs +++ b/src/bin/genesis.rs @@ -9,10 +9,9 @@ extern crate solana_sdk; extern crate untrusted; use clap::{App, Arg}; -use solana::fullnode::Config; use solana::ledger::LedgerWriter; use solana::mint::Mint; -use solana_sdk::signature::KeypairUtil; +use solana_sdk::signature::{read_keypair, KeypairUtil}; use std::error; use std::fs::File; use std::path::Path; @@ -44,13 +43,13 @@ fn main() -> Result<(), Box> { .required(true) .help("Path to file containing keys of the mint"), ).arg( - Arg::with_name("bootstrap_leader") + Arg::with_name("bootstrap-leader-keypair") .short("b") - .long("bootstrap_leader") - .value_name("BOOTSTRAP LEADER") + .long("bootstrap-leader-keypair") + .value_name("BOOTSTRAP LEADER KEYPAIR") .takes_value(true) .required(true) - .help("Path to file containing keys of the bootstrap leader"), + .help("Path to file containing the bootstrap leader's keypair"), ).arg( Arg::with_name("ledger") .short("l") @@ -61,10 +60,11 @@ fn main() -> Result<(), Box> { .help("Use directory as persistent ledger location"), ).get_matches(); - // Parse the input leader configuration - let file = File::open(Path::new(&matches.value_of("bootstrap_leader").unwrap())).unwrap(); - let leader_config: Config = serde_json::from_reader(file).unwrap(); - let leader_keypair = leader_config.keypair(); + // Load the bootstreap leader keypair + // TODO: Only the public key is really needed, genesis should not have access to the leader's + // secret key. + let leader_keypair = read_keypair(matches.value_of("bootstrap-leader-keypair").unwrap()) + .expect("failed to read bootstrap leader keypair"); // Parse the input mint configuration let num_tokens = value_t_or_exit!(matches, "num_tokens", u64);