From 545feab6db0c97d50ef195bd508ad1d942053dc1 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 5 Mar 2019 17:18:25 -0800 Subject: [PATCH] Misc token to lamport renaming --- bench-tps/src/bench.rs | 32 ++++++++++++++++---------------- bench-tps/src/main.rs | 30 +++++++++++++++--------------- fullnode/src/main.rs | 8 ++++---- multinode-demo/fullnode.sh | 6 +++--- tests/replicator.rs | 4 ++-- 5 files changed, 40 insertions(+), 40 deletions(-) diff --git a/bench-tps/src/bench.rs b/bench-tps/src/bench.rs index 5bc650594..22fa23876 100644 --- a/bench-tps/src/bench.rs +++ b/bench-tps/src/bench.rs @@ -34,12 +34,12 @@ pub const MAX_SPENDS_PER_TX: usize = 4; pub type SharedTransactions = Arc>>>; -pub fn metrics_submit_token_balance(token_balance: u64) { - println!("Token balance: {}", token_balance); +pub fn metrics_submit_lamport_balance(lamport_balance: u64) { + println!("Token balance: {}", lamport_balance); solana_metrics::submit( influxdb::Point::new("bench-tps") - .add_tag("op", influxdb::Value::String("token_balance".to_string())) - .add_field("balance", influxdb::Value::Integer(token_balance as i64)) + .add_tag("op", influxdb::Value::String("lamport_balance".to_string())) + .add_field("balance", influxdb::Value::Integer(lamport_balance as i64)) .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( barrier_client: &mut ThinClient, 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 /// on every iteration. This allows us to replay the transfers because the source is either empty, /// or full -pub fn fund_keys(client: &mut ThinClient, source: &Keypair, dests: &[Keypair], tokens: u64) { - let total = tokens * dests.len() as u64; +pub fn fund_keys(client: &mut ThinClient, source: &Keypair, dests: &[Keypair], lamports: u64) { + let total = lamports * dests.len() as u64; let mut funded: Vec<(&Keypair, u64)> = vec![(source, total)]; 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, drone_addr: &SocketAddr, id: &Keypair, tx_count: u64, ) { 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); if starting_balance < tx_count { let airdrop_amount = tx_count - starting_balance; println!( - "Airdropping {:?} tokens from {} for {}", + "Airdropping {:?} lamports from {} for {}", airdrop_amount, drone_addr, id.pubkey(), @@ -436,7 +436,7 @@ pub fn airdrop_tokens( }); println!("current balance {}...", current_balance); - metrics_submit_token_balance(current_balance); + metrics_submit_lamport_balance(current_balance); if current_balance - starting_balance != airdrop_amount { println!( "Airdrop failed! {} {} {}", @@ -513,11 +513,11 @@ pub fn compute_and_report_stats( ); } -// First transfer 3/4 of the tokens to the dest accounts -// then ping-pong 1/4 of the tokens back to the other account -// this leaves 1/4 token buffer in each account -pub fn should_switch_directions(num_tokens_per_account: u64, i: u64) -> bool { - i % (num_tokens_per_account / 4) == 0 && (i >= (3 * num_tokens_per_account) / 4) +// First transfer 3/4 of the lamports to the dest accounts +// then ping-pong 1/4 of the lamports back to the other account +// this leaves 1/4 lamport buffer in each account +pub fn should_switch_directions(num_lamports_per_account: u64, i: u64) -> bool { + i % (num_lamports_per_account / 4) == 0 && (i >= (3 * num_lamports_per_account) / 4) } #[cfg(test)] diff --git a/bench-tps/src/main.rs b/bench-tps/src/main.rs index c306083ea..d6e5e4658 100644 --- a/bench-tps/src/main.rs +++ b/bench-tps/src/main.rs @@ -149,25 +149,25 @@ fn main() { let barrier_source_keypair = Keypair::new(); let barrier_dest_id = Keypair::new().pubkey(); - println!("Get tokens..."); - let num_tokens_per_account = 20; + println!("Get lamports..."); + let num_lamports_per_account = 20; - // Sample the first keypair, see if it has tokens, if so then resume - // to avoid token loss + // Sample the first keypair, see if it has lamports, if so then resume + // to avoid lamport loss let keypair0_balance = client .poll_get_balance(&gen_keypairs.last().unwrap().pubkey()) .unwrap_or(0); - if num_tokens_per_account > keypair0_balance { - let extra = num_tokens_per_account - keypair0_balance; + if num_lamports_per_account > keypair0_balance { + let extra = num_lamports_per_account - keypair0_balance; let total = extra * (gen_keypairs.len() as u64); - airdrop_tokens(&mut client, &drone_addr, &id, total); - println!("adding more tokens {}", extra); + airdrop_lamports(&mut client, &drone_addr, &id, total); + println!("adding more lamports {}", extra); fund_keys(&mut client, &id, &gen_keypairs, extra); } let start = gen_keypairs.len() - (tx_count * 2) as usize; 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..."); let mut blockhash = client.get_recent_blockhash(); @@ -225,11 +225,11 @@ fn main() { // generate and send transactions for the specified duration 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; while start.elapsed() < duration { 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 // this seems to be faster than trying to determine the balance of individual @@ -240,7 +240,7 @@ fn main() { &keypairs[..len], &keypairs[len..], threads, - reclaim_tokens_back_to_source_account, + reclaim_lamports_back_to_source_account, &leader, ); // In sustained mode overlap the transfers with generation @@ -262,8 +262,8 @@ fn main() { ); i += 1; - if should_switch_directions(num_tokens_per_account, i) { - reclaim_tokens_back_to_source_account = !reclaim_tokens_back_to_source_account; + if should_switch_directions(num_lamports_per_account, i) { + 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); - metrics_submit_token_balance(balance); + metrics_submit_lamport_balance(balance); compute_and_report_stats( &maxes, diff --git a/fullnode/src/main.rs b/fullnode/src/main.rs index d0960351f..533505f51 100644 --- a/fullnode/src/main.rs +++ b/fullnode/src/main.rs @@ -29,18 +29,18 @@ fn create_and_fund_vote_account( if node_balance < 1 { return Err(Error::new( ErrorKind::Other, - "insufficient tokens, one token required", + "insufficient lamports, one lamport required", )); } // Create the vote account if necessary 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 { - error!("insufficient tokens, two tokens required"); + error!("insufficient lamports, two lamports required"); return Err(Error::new( ErrorKind::Other, - "insufficient tokens, two tokens required", + "insufficient lamports, two lamports required", )); } loop { diff --git a/multinode-demo/fullnode.sh b/multinode-demo/fullnode.sh index ac55a66a4..761865a1c 100755 --- a/multinode-demo/fullnode.sh +++ b/multinode-demo/fullnode.sh @@ -192,9 +192,9 @@ if [[ ! -d "$ledger_config_dir" ]]; then $solana_wallet --keypair "$fullnode_id_path" address # A fullnode requires 3 lamports to function: - # - one token to create an instance of the vote_program with - # - one token for the transaction fee - # - one token to keep the node identity public key valid. + # - one lamport to create an instance of the vote_program with + # - one lamport for the transaction fee + # - one lamport to keep the node identity public key valid. retries=5 while true; do # TODO: Until https://github.com/solana-labs/solana/issues/2355 is resolved diff --git a/tests/replicator.rs b/tests/replicator.rs index c390583c4..33dea9090 100644 --- a/tests/replicator.rs +++ b/tests/replicator.rs @@ -111,10 +111,10 @@ fn test_replicator_startup_basic() { let replicator_keypair = Keypair::new(); - info!("giving replicator tokens.."); + info!("giving replicator lamports.."); let blockhash = leader_client.get_recent_blockhash(); - // Give the replicator some tokens + // Give the replicator some lamports let mut tx = SystemTransaction::new_account( &mint_keypair, replicator_keypair.pubkey(),