Always use bootstrap vote account for leader

This commit is contained in:
Sagar Dhawan
2019-04-10 12:51:25 -07:00
committed by Grimes
parent e6f02d1a10
commit d2ea782372
5 changed files with 21 additions and 15 deletions

View File

@ -3,15 +3,15 @@
use clap::{crate_description, crate_name, crate_version, value_t_or_exit, App, Arg};
use solana::blocktree::create_new_ledger;
use solana_sdk::genesis_block::GenesisBlock;
use solana_sdk::signature::{read_keypair, Keypair, KeypairUtil};
use solana_sdk::signature::{read_keypair, KeypairUtil};
use std::error;
/**
* Bootstrap leader gets two lamports:
* - one lamport to use as stake
* - one lamport to keep the node identity public key valid
* - 42 lamports to use as stake
* - One lamport to keep the node identity public key valid
*/
pub const BOOTSTRAP_LEADER_LAMPORTS: u64 = 2;
pub const BOOTSTRAP_LEADER_LAMPORTS: u64 = 43;
fn main() -> Result<(), Box<dyn error::Error>> {
let matches = App::new(crate_name!())
@ -53,24 +53,34 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.required(true)
.help("Path to file containing keys of the mint"),
)
.arg(
Arg::with_name("bootstrap_stake_keypair_file")
.short("s")
.long("bootstrap-stake-keypair")
.value_name("BOOTSTRAP STAKE KEYPAIR")
.takes_value(true)
.required(true)
.help("Path to file containing the bootstrap leader's staking keypair"),
)
.get_matches();
let bootstrap_leader_keypair_file = matches.value_of("bootstrap_leader_keypair_file").unwrap();
let bootstrap_stake_keypair_file = matches.value_of("bootstrap_stake_keypair_file").unwrap();
let ledger_path = matches.value_of("ledger_path").unwrap();
let mint_keypair_file = matches.value_of("mint_keypair_file").unwrap();
let lamports = value_t_or_exit!(matches, "lamports", u64);
let bootstrap_leader_keypair = read_keypair(bootstrap_leader_keypair_file)?;
let bootstrap_stake_keypair = read_keypair(bootstrap_stake_keypair_file)?;
let mint_keypair = read_keypair(mint_keypair_file)?;
let bootstrap_leader_vote_account_keypair = Keypair::new();
let (mut genesis_block, _mint_keypair) = GenesisBlock::new_with_leader(
lamports,
&bootstrap_leader_keypair.pubkey(),
BOOTSTRAP_LEADER_LAMPORTS,
);
genesis_block.mint_id = mint_keypair.pubkey();
genesis_block.bootstrap_leader_vote_account_id = bootstrap_leader_vote_account_keypair.pubkey();
genesis_block.bootstrap_leader_vote_account_id = bootstrap_stake_keypair.pubkey();
genesis_block
.native_instruction_processors
.extend_from_slice(&[