solana-genesis: rename tokens to lamports

This commit is contained in:
Michael Vines 2019-03-05 17:01:57 -08:00
parent f1d1852691
commit beb45f44ac
4 changed files with 20 additions and 20 deletions

View File

@ -7,14 +7,14 @@ use solana_sdk::signature::{read_keypair, Keypair, KeypairUtil};
use std::error; use std::error;
/** /**
* Bootstrap leader gets two tokens: * Bootstrap leader gets two lamports:
* - one token to create an instance of the vote_program with * - one lamport to create an instance of the vote_program with
* - one token for the transaction fee * - one lamport for the transaction fee
* - one second token to keep the node identity public key valid * - one second lamport to keep the node identity public key valid
*/ */
//pub const BOOTSTRAP_LEADER_LAMPORTS: u64 = 3; //pub const BOOTSTRAP_LEADER_LAMPORTS: u64 = 3;
// TODO: Until https://github.com/solana-labs/solana/issues/2355 is resolved the bootstrap leader // TODO: Until https://github.com/solana-labs/solana/issues/2355 is resolved the bootstrap leader
// needs N tokens as its vote account gets re-created on every node restart, costing it tokens // needs N lamports as its vote account gets re-created on every node restart, costing it lamports
pub const BOOTSTRAP_LEADER_LAMPORTS: u64 = 1_000_000; pub const BOOTSTRAP_LEADER_LAMPORTS: u64 = 1_000_000;
fn main() -> Result<(), Box<dyn error::Error>> { fn main() -> Result<(), Box<dyn error::Error>> {
@ -39,13 +39,13 @@ fn main() -> Result<(), Box<dyn error::Error>> {
.help("Use directory as persistent ledger location"), .help("Use directory as persistent ledger location"),
) )
.arg( .arg(
Arg::with_name("num_tokens") Arg::with_name("lamports")
.short("t") .short("t")
.long("num_tokens") .long("lamports")
.value_name("TOKENS") .value_name("LAMPORTS")
.takes_value(true) .takes_value(true)
.required(true) .required(true)
.help("Number of tokens to create in the mint"), .help("Number of lamports to create in the mint"),
) )
.arg( .arg(
Arg::with_name("mint_keypair_file") Arg::with_name("mint_keypair_file")
@ -61,14 +61,14 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let bootstrap_leader_keypair_file = matches.value_of("bootstrap_leader_keypair_file").unwrap(); let bootstrap_leader_keypair_file = matches.value_of("bootstrap_leader_keypair_file").unwrap();
let ledger_path = matches.value_of("ledger_path").unwrap(); let ledger_path = matches.value_of("ledger_path").unwrap();
let mint_keypair_file = matches.value_of("mint_keypair_file").unwrap(); let mint_keypair_file = matches.value_of("mint_keypair_file").unwrap();
let num_tokens = value_t_or_exit!(matches, "num_tokens", u64); let lamports = value_t_or_exit!(matches, "lamports", u64);
let bootstrap_leader_keypair = read_keypair(bootstrap_leader_keypair_file)?; let bootstrap_leader_keypair = read_keypair(bootstrap_leader_keypair_file)?;
let mint_keypair = read_keypair(mint_keypair_file)?; let mint_keypair = read_keypair(mint_keypair_file)?;
let bootstrap_leader_vote_account_keypair = Keypair::new(); let bootstrap_leader_vote_account_keypair = Keypair::new();
let (mut genesis_block, _mint_keypair) = GenesisBlock::new_with_leader( let (mut genesis_block, _mint_keypair) = GenesisBlock::new_with_leader(
num_tokens, lamports,
bootstrap_leader_keypair.pubkey(), bootstrap_leader_keypair.pubkey(),
BOOTSTRAP_LEADER_LAMPORTS, BOOTSTRAP_LEADER_LAMPORTS,
); );

View File

@ -191,15 +191,15 @@ if [[ ! -d "$ledger_config_dir" ]]; then
$solana_wallet --keypair "$fullnode_id_path" address $solana_wallet --keypair "$fullnode_id_path" address
# A fullnode requires 3 tokens to function: # A fullnode requires 3 lamports to function:
# - one token to create an instance of the vote_program with # - one token to create an instance of the vote_program with
# - one token for the transaction fee # - one token for the transaction fee
# - one token to keep the node identity public key valid. # - one token to keep the node identity public key valid.
retries=5 retries=5
while true; do while true; do
# TODO: Until https://github.com/solana-labs/solana/issues/2355 is resolved # TODO: Until https://github.com/solana-labs/solana/issues/2355 is resolved
# a fullnode needs N tokens as its vote account gets re-created on every # a fullnode needs N lamports as its vote account gets re-created on every
# node restart, costing it tokens # node restart, costing it lamports
if $solana_wallet --keypair "$fullnode_id_path" --host "${leader_address%:*}" airdrop 1000000; then if $solana_wallet --keypair "$fullnode_id_path" --host "${leader_address%:*}" airdrop 1000000; then
break break
fi fi

View File

@ -14,11 +14,11 @@ usage () {
echo "Error: $*" echo "Error: $*"
fi fi
cat <<EOF cat <<EOF
usage: $0 [-n num_tokens] [-l] [-p] [-t node_type] usage: $0 [-n lamports] [-l] [-p] [-t node_type]
Creates a fullnode configuration Creates a fullnode configuration
-n num_tokens - Number of tokens to create -n lamports - Number of lamports to create
-t node_type - Create configuration files only for this kind of node. Valid -t node_type - Create configuration files only for this kind of node. Valid
options are bootstrap-leader or fullnode. Creates configuration files options are bootstrap-leader or fullnode. Creates configuration files
for both by default for both by default
@ -27,7 +27,7 @@ EOF
exit $exitcode exit $exitcode
} }
num_tokens=1000000000 lamports=1000000000
bootstrap_leader=true bootstrap_leader=true
fullnode=true fullnode=true
while getopts "h?n:lpt:" opt; do while getopts "h?n:lpt:" opt; do
@ -37,7 +37,7 @@ while getopts "h?n:lpt:" opt; do
exit 0 exit 0
;; ;;
n) n)
num_tokens="$OPTARG" lamports="$OPTARG"
;; ;;
t) t)
node_type="$OPTARG" node_type="$OPTARG"
@ -80,7 +80,7 @@ if $bootstrap_leader; then
--bootstrap-leader-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json \ --bootstrap-leader-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json \
--ledger "$SOLANA_RSYNC_CONFIG_DIR"/ledger \ --ledger "$SOLANA_RSYNC_CONFIG_DIR"/ledger \
--mint "$SOLANA_CONFIG_DIR"/mint-id.json \ --mint "$SOLANA_CONFIG_DIR"/mint-id.json \
--num_tokens "$num_tokens" --lamports "$lamports"
cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger
) )
fi fi

2
run.sh
View File

@ -43,7 +43,7 @@ solana-keygen -o "$dataDir"/config/leader-keypair.json
solana-keygen -o "$dataDir"/config/drone-keypair.json solana-keygen -o "$dataDir"/config/drone-keypair.json
solana-genesis \ solana-genesis \
--num_tokens 1000000000 \ --lamports 1000000000 \
--mint "$dataDir"/config/drone-keypair.json \ --mint "$dataDir"/config/drone-keypair.json \
--bootstrap-leader-keypair "$dataDir"/config/leader-keypair.json \ --bootstrap-leader-keypair "$dataDir"/config/leader-keypair.json \
--ledger "$dataDir"/ledger --ledger "$dataDir"/ledger