Misc token to lamport renaming

This commit is contained in:
Michael Vines
2019-03-05 17:18:25 -08:00
parent 3794048c91
commit 545feab6db
5 changed files with 40 additions and 40 deletions

View File

@ -34,12 +34,12 @@ pub const MAX_SPENDS_PER_TX: usize = 4;
pub type SharedTransactions = Arc<RwLock<VecDeque<Vec<(Transaction, u64)>>>>; pub type SharedTransactions = Arc<RwLock<VecDeque<Vec<(Transaction, u64)>>>>;
pub fn metrics_submit_token_balance(token_balance: u64) { pub fn metrics_submit_lamport_balance(lamport_balance: u64) {
println!("Token balance: {}", token_balance); println!("Token balance: {}", lamport_balance);
solana_metrics::submit( solana_metrics::submit(
influxdb::Point::new("bench-tps") influxdb::Point::new("bench-tps")
.add_tag("op", influxdb::Value::String("token_balance".to_string())) .add_tag("op", influxdb::Value::String("lamport_balance".to_string()))
.add_field("balance", influxdb::Value::Integer(token_balance as i64)) .add_field("balance", influxdb::Value::Integer(lamport_balance as i64))
.to_owned(), .to_owned(),
); );
} }
@ -100,7 +100,7 @@ pub fn sample_tx_count(
} }
} }
/// Send loopback payment of 0 tokens and confirm the network processed it /// Send loopback payment of 0 lamports and confirm the network processed it
pub fn send_barrier_transaction( pub fn send_barrier_transaction(
barrier_client: &mut ThinClient, barrier_client: &mut ThinClient,
blockhash: &mut Hash, blockhash: &mut Hash,
@ -304,8 +304,8 @@ pub fn verify_funding_transfer(client: &mut ThinClient, tx: &Transaction, amount
/// fund the dests keys by spending all of the source keys into MAX_SPENDS_PER_TX /// fund the dests keys by spending all of the source keys into MAX_SPENDS_PER_TX
/// on every iteration. This allows us to replay the transfers because the source is either empty, /// on every iteration. This allows us to replay the transfers because the source is either empty,
/// or full /// or full
pub fn fund_keys(client: &mut ThinClient, source: &Keypair, dests: &[Keypair], tokens: u64) { pub fn fund_keys(client: &mut ThinClient, source: &Keypair, dests: &[Keypair], lamports: u64) {
let total = tokens * dests.len() as u64; let total = lamports * dests.len() as u64;
let mut funded: Vec<(&Keypair, u64)> = vec![(source, total)]; let mut funded: Vec<(&Keypair, u64)> = vec![(source, total)];
let mut notfunded: Vec<&Keypair> = dests.iter().collect(); let mut notfunded: Vec<&Keypair> = dests.iter().collect();
@ -397,20 +397,20 @@ pub fn fund_keys(client: &mut ThinClient, source: &Keypair, dests: &[Keypair], t
} }
} }
pub fn airdrop_tokens( pub fn airdrop_lamports(
client: &mut ThinClient, client: &mut ThinClient,
drone_addr: &SocketAddr, drone_addr: &SocketAddr,
id: &Keypair, id: &Keypair,
tx_count: u64, tx_count: u64,
) { ) {
let starting_balance = client.poll_get_balance(&id.pubkey()).unwrap_or(0); let starting_balance = client.poll_get_balance(&id.pubkey()).unwrap_or(0);
metrics_submit_token_balance(starting_balance); metrics_submit_lamport_balance(starting_balance);
println!("starting balance {}", starting_balance); println!("starting balance {}", starting_balance);
if starting_balance < tx_count { if starting_balance < tx_count {
let airdrop_amount = tx_count - starting_balance; let airdrop_amount = tx_count - starting_balance;
println!( println!(
"Airdropping {:?} tokens from {} for {}", "Airdropping {:?} lamports from {} for {}",
airdrop_amount, airdrop_amount,
drone_addr, drone_addr,
id.pubkey(), id.pubkey(),
@ -436,7 +436,7 @@ pub fn airdrop_tokens(
}); });
println!("current balance {}...", current_balance); println!("current balance {}...", current_balance);
metrics_submit_token_balance(current_balance); metrics_submit_lamport_balance(current_balance);
if current_balance - starting_balance != airdrop_amount { if current_balance - starting_balance != airdrop_amount {
println!( println!(
"Airdrop failed! {} {} {}", "Airdrop failed! {} {} {}",
@ -513,11 +513,11 @@ pub fn compute_and_report_stats(
); );
} }
// First transfer 3/4 of the tokens to the dest accounts // First transfer 3/4 of the lamports to the dest accounts
// then ping-pong 1/4 of the tokens back to the other account // then ping-pong 1/4 of the lamports back to the other account
// this leaves 1/4 token buffer in each account // this leaves 1/4 lamport buffer in each account
pub fn should_switch_directions(num_tokens_per_account: u64, i: u64) -> bool { pub fn should_switch_directions(num_lamports_per_account: u64, i: u64) -> bool {
i % (num_tokens_per_account / 4) == 0 && (i >= (3 * num_tokens_per_account) / 4) i % (num_lamports_per_account / 4) == 0 && (i >= (3 * num_lamports_per_account) / 4)
} }
#[cfg(test)] #[cfg(test)]

View File

@ -149,25 +149,25 @@ fn main() {
let barrier_source_keypair = Keypair::new(); let barrier_source_keypair = Keypair::new();
let barrier_dest_id = Keypair::new().pubkey(); let barrier_dest_id = Keypair::new().pubkey();
println!("Get tokens..."); println!("Get lamports...");
let num_tokens_per_account = 20; let num_lamports_per_account = 20;
// Sample the first keypair, see if it has tokens, if so then resume // Sample the first keypair, see if it has lamports, if so then resume
// to avoid token loss // to avoid lamport loss
let keypair0_balance = client let keypair0_balance = client
.poll_get_balance(&gen_keypairs.last().unwrap().pubkey()) .poll_get_balance(&gen_keypairs.last().unwrap().pubkey())
.unwrap_or(0); .unwrap_or(0);
if num_tokens_per_account > keypair0_balance { if num_lamports_per_account > keypair0_balance {
let extra = num_tokens_per_account - keypair0_balance; let extra = num_lamports_per_account - keypair0_balance;
let total = extra * (gen_keypairs.len() as u64); let total = extra * (gen_keypairs.len() as u64);
airdrop_tokens(&mut client, &drone_addr, &id, total); airdrop_lamports(&mut client, &drone_addr, &id, total);
println!("adding more tokens {}", extra); println!("adding more lamports {}", extra);
fund_keys(&mut client, &id, &gen_keypairs, extra); fund_keys(&mut client, &id, &gen_keypairs, extra);
} }
let start = gen_keypairs.len() - (tx_count * 2) as usize; let start = gen_keypairs.len() - (tx_count * 2) as usize;
let keypairs = &gen_keypairs[start..]; let keypairs = &gen_keypairs[start..];
airdrop_tokens(&mut barrier_client, &drone_addr, &barrier_source_keypair, 1); airdrop_lamports(&mut barrier_client, &drone_addr, &barrier_source_keypair, 1);
println!("Get last ID..."); println!("Get last ID...");
let mut blockhash = client.get_recent_blockhash(); let mut blockhash = client.get_recent_blockhash();
@ -225,11 +225,11 @@ fn main() {
// generate and send transactions for the specified duration // generate and send transactions for the specified duration
let start = Instant::now(); let start = Instant::now();
let mut reclaim_tokens_back_to_source_account = false; let mut reclaim_lamports_back_to_source_account = false;
let mut i = keypair0_balance; let mut i = keypair0_balance;
while start.elapsed() < duration { while start.elapsed() < duration {
let balance = client.poll_get_balance(&id.pubkey()).unwrap_or(0); let balance = client.poll_get_balance(&id.pubkey()).unwrap_or(0);
metrics_submit_token_balance(balance); metrics_submit_lamport_balance(balance);
// ping-pong between source and destination accounts for each loop iteration // ping-pong between source and destination accounts for each loop iteration
// this seems to be faster than trying to determine the balance of individual // this seems to be faster than trying to determine the balance of individual
@ -240,7 +240,7 @@ fn main() {
&keypairs[..len], &keypairs[..len],
&keypairs[len..], &keypairs[len..],
threads, threads,
reclaim_tokens_back_to_source_account, reclaim_lamports_back_to_source_account,
&leader, &leader,
); );
// In sustained mode overlap the transfers with generation // In sustained mode overlap the transfers with generation
@ -262,8 +262,8 @@ fn main() {
); );
i += 1; i += 1;
if should_switch_directions(num_tokens_per_account, i) { if should_switch_directions(num_lamports_per_account, i) {
reclaim_tokens_back_to_source_account = !reclaim_tokens_back_to_source_account; reclaim_lamports_back_to_source_account = !reclaim_lamports_back_to_source_account;
} }
} }
@ -286,7 +286,7 @@ fn main() {
} }
let balance = client.poll_get_balance(&id.pubkey()).unwrap_or(0); let balance = client.poll_get_balance(&id.pubkey()).unwrap_or(0);
metrics_submit_token_balance(balance); metrics_submit_lamport_balance(balance);
compute_and_report_stats( compute_and_report_stats(
&maxes, &maxes,

View File

@ -29,18 +29,18 @@ fn create_and_fund_vote_account(
if node_balance < 1 { if node_balance < 1 {
return Err(Error::new( return Err(Error::new(
ErrorKind::Other, ErrorKind::Other,
"insufficient tokens, one token required", "insufficient lamports, one lamport required",
)); ));
} }
// Create the vote account if necessary // Create the vote account if necessary
if client.poll_get_balance(&vote_account).unwrap_or(0) == 0 { if client.poll_get_balance(&vote_account).unwrap_or(0) == 0 {
// Need at least two tokens as one token will be spent on a vote_account_new() transaction // Need at least two lamports as one lamport will be spent on a vote_account_new() transaction
if node_balance < 2 { if node_balance < 2 {
error!("insufficient tokens, two tokens required"); error!("insufficient lamports, two lamports required");
return Err(Error::new( return Err(Error::new(
ErrorKind::Other, ErrorKind::Other,
"insufficient tokens, two tokens required", "insufficient lamports, two lamports required",
)); ));
} }
loop { loop {

View File

@ -192,9 +192,9 @@ if [[ ! -d "$ledger_config_dir" ]]; then
$solana_wallet --keypair "$fullnode_id_path" address $solana_wallet --keypair "$fullnode_id_path" address
# A fullnode requires 3 lamports to function: # A fullnode requires 3 lamports to function:
# - 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 token to keep the node identity public key valid. # - one lamport 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

View File

@ -111,10 +111,10 @@ fn test_replicator_startup_basic() {
let replicator_keypair = Keypair::new(); let replicator_keypair = Keypair::new();
info!("giving replicator tokens.."); info!("giving replicator lamports..");
let blockhash = leader_client.get_recent_blockhash(); let blockhash = leader_client.get_recent_blockhash();
// Give the replicator some tokens // Give the replicator some lamports
let mut tx = SystemTransaction::new_account( let mut tx = SystemTransaction::new_account(
&mint_keypair, &mint_keypair,
replicator_keypair.pubkey(), replicator_keypair.pubkey(),