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

@ -116,6 +116,7 @@ impl LocalCluster {
slots_per_epoch: u64,
native_instruction_processors: &[(String, Pubkey)],
) -> Self {
let voting_keypair = Keypair::new();
let leader_keypair = Arc::new(Keypair::new());
let leader_pubkey = leader_keypair.pubkey();
let leader_node = Node::new_localhost_with_pubkey(&leader_keypair.pubkey());
@ -126,9 +127,9 @@ impl LocalCluster {
genesis_block
.native_instruction_processors
.extend_from_slice(native_instruction_processors);
genesis_block.bootstrap_leader_vote_account_id = voting_keypair.pubkey();
let (genesis_ledger_path, _blockhash) = create_new_tmp_ledger!(&genesis_block);
let leader_ledger_path = tmp_copy_blocktree!(&genesis_ledger_path);
let voting_keypair = Keypair::new();
let leader_contact_info = leader_node.info.clone();
let leader_server = Fullnode::new(
@ -457,4 +458,5 @@ mod test {
assert_eq!(cluster.fullnodes.len(), NUM_NODES);
assert_eq!(cluster.replicators.len(), num_replicators);
}
}

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(&[

View File

@ -15,7 +15,6 @@ if [[ $1 = -h ]]; then
fi
extra_fullnode_args=()
setup_stakes=true
while [[ ${1:0:1} = - ]]; do
if [[ $1 = --blockstream ]]; then
@ -27,9 +26,6 @@ while [[ ${1:0:1} = - ]]; do
elif [[ $1 = --init-complete-file ]]; then
extra_fullnode_args+=("$1" "$2")
shift 2
elif [[ $1 = --only-bootstrap-stake ]]; then
setup_stakes=false
shift
elif [[ $1 = --public-address ]]; then
extra_fullnode_args+=("$1")
shift
@ -85,8 +81,4 @@ $program \
pid=$!
oom_score_adj "$pid" 1000
if [[ $setup_stakes = true ]] ; then
setup_fullnode_staking 127.0.0.1 "$bootstrap_leader_id_path" "$bootstrap_leader_staker_id_path"
fi
wait "$pid"

View File

@ -79,6 +79,7 @@ if $bootstrap_leader; then
$solana_keygen -o "$SOLANA_CONFIG_DIR"/bootstrap-leader-staker-id.json
$solana_genesis \
--bootstrap-leader-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json \
--bootstrap-stake-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-staker-id.json \
--ledger "$SOLANA_RSYNC_CONFIG_DIR"/ledger \
--mint "$SOLANA_CONFIG_DIR"/mint-id.json \
--lamports "$lamports"

1
run.sh
View File

@ -58,6 +58,7 @@ solana-genesis \
--lamports 1000000000 \
--mint "$dataDir"/config/drone-keypair.json \
--bootstrap-leader-keypair "$dataDir"/config/leader-keypair.json \
--bootstrap-stake-keypair "$dataDir"/config/leader-staking-account-keypair.json \
--ledger "$dataDir"/ledger
solana-drone --keypair "$dataDir"/config/drone-keypair.json &