No longer spin up accounts for client-demo
Now that the Bank is single-threaded again, we can spin up new accounts on the fly without concern of thread contention. Likewise, we can send all transactions from a single account, which was also problematic in the multi-threaded bank. Sending from one account will also make client-demo straightforward to port to solana-drone.
This commit is contained in:
parent
6dac87f2a7
commit
ed10841e3d
|
@ -33,18 +33,10 @@ path = "src/bin/fullnode-config.rs"
|
|||
name = "solana-genesis"
|
||||
path = "src/bin/genesis.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "solana-genesis-demo"
|
||||
path = "src/bin/genesis-demo.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "solana-mint"
|
||||
path = "src/bin/mint.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "solana-mint-demo"
|
||||
path = "src/bin/mint-demo.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "solana-drone"
|
||||
path = "src/bin/drone.rs"
|
||||
|
|
|
@ -16,9 +16,9 @@ rsync_leader_url=$(rsync_url "$leader")
|
|||
set -ex
|
||||
mkdir -p $SOLANA_CONFIG_DIR
|
||||
rsync -vPz "$rsync_leader_url"/config/leader.json $SOLANA_CONFIG_DIR/
|
||||
rsync -vPz "$rsync_leader_url"/config/mint-demo.json $SOLANA_CONFIG_DIR/
|
||||
rsync -vPz "$rsync_leader_url"/config/mint.json $SOLANA_CONFIG_DIR/
|
||||
|
||||
# shellcheck disable=SC2086 # $solana_client_demo should not be quoted
|
||||
exec $solana_client_demo \
|
||||
-n "$count" -l $SOLANA_CONFIG_DIR/leader.json -d \
|
||||
< $SOLANA_CONFIG_DIR/mint-demo.json
|
||||
< $SOLANA_CONFIG_DIR/mint.json
|
||||
|
|
|
@ -40,8 +40,8 @@ solana_drone=$(solana_program drone)
|
|||
solana_fullnode=$(solana_program fullnode)
|
||||
solana_fullnode_config=$(solana_program fullnode-config)
|
||||
solana_fullnode_cuda=$(solana_program fullnode-cuda)
|
||||
solana_genesis_demo=$(solana_program genesis-demo)
|
||||
solana_mint_demo=$(solana_program mint-demo)
|
||||
solana_genesis=$(solana_program genesis)
|
||||
solana_mint=$(solana_program mint)
|
||||
|
||||
export RUST_LOG=${RUST_LOG:-solana=info} # if RUST_LOG is unset, default to info
|
||||
export RUST_BACKTRACE=1
|
||||
|
|
|
@ -12,11 +12,11 @@ echo "Cleaning $SOLANA_CONFIG_DIR"
|
|||
rm -rvf "$SOLANA_CONFIG_DIR"
|
||||
mkdir -p "$SOLANA_CONFIG_DIR"
|
||||
|
||||
echo "Creating $SOLANA_CONFIG_DIR/mint-demo.json with $num_tokens tokens"
|
||||
$solana_mint_demo <<<"$num_tokens" > "$SOLANA_CONFIG_DIR"/mint-demo.json
|
||||
echo "Creating $SOLANA_CONFIG_DIR/mint.json with $num_tokens tokens"
|
||||
$solana_mint <<<"$num_tokens" > "$SOLANA_CONFIG_DIR"/mint.json
|
||||
|
||||
echo "Creating $SOLANA_CONFIG_DIR/genesis.log"
|
||||
$solana_genesis_demo < "$SOLANA_CONFIG_DIR"/mint-demo.json > "$SOLANA_CONFIG_DIR"/genesis.log
|
||||
$solana_genesis < "$SOLANA_CONFIG_DIR"/mint.json > "$SOLANA_CONFIG_DIR"/genesis.log
|
||||
|
||||
echo "Creating $SOLANA_CONFIG_DIR/leader.json"
|
||||
$solana_fullnode_config -d > "$SOLANA_CONFIG_DIR"/leader.json
|
||||
|
|
|
@ -39,12 +39,8 @@ apps:
|
|||
- network-bind
|
||||
genesis:
|
||||
command: solana-genesis
|
||||
genesis-demo:
|
||||
command: solana-genesis-demo
|
||||
mint:
|
||||
command: solana-mint
|
||||
mint-demo:
|
||||
command: solana-mint-demo
|
||||
client-demo:
|
||||
command: solana-client-demo
|
||||
simple-client-demo:
|
||||
|
|
|
@ -10,7 +10,7 @@ use getopts::Options;
|
|||
use rayon::prelude::*;
|
||||
use solana::crdt::{get_ip_addr, Crdt, ReplicatedData};
|
||||
use solana::hash::Hash;
|
||||
use solana::mint::MintDemo;
|
||||
use solana::mint::Mint;
|
||||
use solana::ncp::Ncp;
|
||||
use solana::signature::{GenKeys, KeyPair, KeyPairUtil};
|
||||
use solana::streamer::default_window;
|
||||
|
@ -83,21 +83,18 @@ fn sample_tx_count(
|
|||
fn generate_and_send_txs(
|
||||
client: &mut ThinClient,
|
||||
tx_clients: &Vec<ThinClient>,
|
||||
keypair_pairs: &Vec<&[KeyPair]>,
|
||||
mint: &Mint,
|
||||
keypairs: &Vec<KeyPair>,
|
||||
leader: &ReplicatedData,
|
||||
txs: i64,
|
||||
last_id: &mut Hash,
|
||||
threads: usize,
|
||||
) {
|
||||
println!(
|
||||
"Signing transactions... {} {}",
|
||||
keypair_pairs.len(),
|
||||
keypair_pairs[0].len()
|
||||
);
|
||||
println!("Signing transactions... {}", keypairs.len(),);
|
||||
let signing_start = Instant::now();
|
||||
let transactions: Vec<_> = keypair_pairs
|
||||
let transactions: Vec<_> = keypairs
|
||||
.par_iter()
|
||||
.map(|chunk| Transaction::new(&chunk[0], chunk[1].pubkey(), 1, *last_id))
|
||||
.map(|keypair| Transaction::new(&mint.keypair(), keypair.pubkey(), 1, *last_id))
|
||||
.collect();
|
||||
|
||||
let duration = signing_start.elapsed();
|
||||
|
@ -232,7 +229,7 @@ fn main() {
|
|||
}
|
||||
|
||||
println!("Parsing stdin...");
|
||||
let demo: MintDemo = serde_json::from_str(&buffer).unwrap_or_else(|e| {
|
||||
let mint: Mint = serde_json::from_str(&buffer).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse json: {}", e);
|
||||
exit(1);
|
||||
});
|
||||
|
@ -243,13 +240,13 @@ fn main() {
|
|||
println!("Got last ID {:?}", last_id);
|
||||
|
||||
let mut seed = [0u8; 32];
|
||||
seed.copy_from_slice(&demo.mint.keypair().public_key_bytes()[..32]);
|
||||
seed.copy_from_slice(&mint.keypair().public_key_bytes()[..32]);
|
||||
let rnd = GenKeys::new(seed);
|
||||
|
||||
println!("Creating keypairs...");
|
||||
let txs = demo.num_accounts / 2;
|
||||
let keypairs = rnd.gen_n_keypairs(demo.num_accounts);
|
||||
let keypair_pairs: Vec<_> = keypairs.chunks(2).collect();
|
||||
let num_accounts = 500_000;
|
||||
let txs = num_accounts / 2;
|
||||
let keypairs = rnd.gen_n_keypairs(num_accounts);
|
||||
|
||||
let first_count = client.transaction_count();
|
||||
println!("initial count {}", first_count);
|
||||
|
@ -286,7 +283,8 @@ fn main() {
|
|||
generate_and_send_txs(
|
||||
&mut client,
|
||||
&clients,
|
||||
&keypair_pairs,
|
||||
&mint,
|
||||
&keypairs,
|
||||
&leader,
|
||||
txs,
|
||||
&mut last_id,
|
||||
|
|
|
@ -13,7 +13,7 @@ use bincode::deserialize;
|
|||
use getopts::Options;
|
||||
use solana::crdt::{get_ip_addr, ReplicatedData};
|
||||
use solana::drone::{Drone, DroneRequest};
|
||||
use solana::mint::MintDemo;
|
||||
use solana::mint::Mint;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{stdin, Read};
|
||||
|
@ -26,7 +26,7 @@ use tokio::prelude::*;
|
|||
use tokio_codec::{BytesCodec, Decoder};
|
||||
|
||||
fn print_usage(program: &str, opts: Options) {
|
||||
let mut brief = format!("Usage: cat <mint-demo.json> | {} [options]\n\n", program);
|
||||
let mut brief = format!("Usage: cat <mint.json> | {} [options]\n\n", program);
|
||||
brief += " Run a Solana Drone to act as the custodian of the mint's remaining tokens\n";
|
||||
|
||||
print!("{}", opts.usage(&brief));
|
||||
|
@ -96,12 +96,12 @@ fn main() {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
let demo: MintDemo = serde_json::from_str(&buffer).unwrap_or_else(|e| {
|
||||
let mint: Mint = serde_json::from_str(&buffer).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse json: {}", e);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let mint_keypair = demo.mint.keypair();
|
||||
let mint_keypair = mint.keypair();
|
||||
|
||||
let mut drone_addr: SocketAddr = "0.0.0.0:9900".parse().unwrap();
|
||||
drone_addr.set_ip(get_ip_addr().unwrap());
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
extern crate atty;
|
||||
extern crate rayon;
|
||||
extern crate serde_json;
|
||||
extern crate solana;
|
||||
|
||||
use atty::{is, Stream};
|
||||
use rayon::prelude::*;
|
||||
use solana::bank::MAX_ENTRY_IDS;
|
||||
use solana::entry::next_entry;
|
||||
use solana::ledger::next_entries;
|
||||
use solana::mint::MintDemo;
|
||||
use solana::signature::{GenKeys, KeyPairUtil};
|
||||
use solana::transaction::Transaction;
|
||||
use std::io::{stdin, Read};
|
||||
use std::process::exit;
|
||||
|
||||
// Generate a ledger with lots and lots of accounts.
|
||||
fn main() {
|
||||
if is(Stream::Stdin) {
|
||||
eprintln!("nothing found on stdin, expected a json file");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let mut buffer = String::new();
|
||||
let num_bytes = stdin().read_to_string(&mut buffer).unwrap();
|
||||
if num_bytes == 0 {
|
||||
eprintln!("empty file on stdin, expected a json file");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
let demo: MintDemo = serde_json::from_str(&buffer).unwrap_or_else(|e| {
|
||||
eprintln!("failed to parse json: {}", e);
|
||||
exit(1);
|
||||
});
|
||||
|
||||
let mut seed = [0u8; 32];
|
||||
seed.copy_from_slice(&demo.mint.keypair().public_key_bytes()[..32]);
|
||||
let rnd = GenKeys::new(seed);
|
||||
let num_accounts = demo.num_accounts;
|
||||
let tokens_per_user = 500;
|
||||
|
||||
let keypairs = rnd.gen_n_keypairs(num_accounts);
|
||||
|
||||
let mint_keypair = demo.mint.keypair();
|
||||
let last_id = demo.mint.last_id();
|
||||
|
||||
for entry in demo.mint.create_entries() {
|
||||
println!("{}", serde_json::to_string(&entry).unwrap());
|
||||
}
|
||||
|
||||
eprintln!("Creating {} empty entries...", MAX_ENTRY_IDS);
|
||||
|
||||
// Offer client lots of entry IDs to use for each transaction's last_id.
|
||||
let mut last_id = last_id;
|
||||
let mut last_ids = vec![];
|
||||
for _ in 0..MAX_ENTRY_IDS {
|
||||
let entry = next_entry(&last_id, 1, vec![]);
|
||||
last_id = entry.id;
|
||||
last_ids.push(last_id);
|
||||
let serialized = serde_json::to_string(&entry).unwrap_or_else(|e| {
|
||||
eprintln!("failed to serialize: {}", e);
|
||||
exit(1);
|
||||
});
|
||||
println!("{}", serialized);
|
||||
}
|
||||
|
||||
eprintln!("Creating {} transactions...", num_accounts);
|
||||
let transactions: Vec<_> = keypairs
|
||||
.into_par_iter()
|
||||
.enumerate()
|
||||
.map(|(i, rando)| {
|
||||
let last_id = last_ids[i % MAX_ENTRY_IDS];
|
||||
Transaction::new(&mint_keypair, rando.pubkey(), tokens_per_user, last_id)
|
||||
})
|
||||
.collect();
|
||||
|
||||
eprintln!("Logging the creation of {} accounts...", num_accounts);
|
||||
let entries = next_entries(&last_id, 0, transactions);
|
||||
for entry in entries {
|
||||
println!("{}", serde_json::to_string(&entry).unwrap());
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
extern crate atty;
|
||||
extern crate rayon;
|
||||
extern crate ring;
|
||||
extern crate serde_json;
|
||||
extern crate solana;
|
||||
|
||||
use atty::{is, Stream};
|
||||
use solana::mint::{Mint, MintDemo};
|
||||
use std::io;
|
||||
use std::process::exit;
|
||||
|
||||
fn main() {
|
||||
let mut input_text = String::new();
|
||||
if is(Stream::Stdin) {
|
||||
eprintln!("nothing found on stdin, expected a token number");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
io::stdin().read_line(&mut input_text).unwrap();
|
||||
let trimmed = input_text.trim();
|
||||
let tokens = trimmed.parse::<i64>().unwrap();
|
||||
|
||||
let mint = Mint::new(tokens);
|
||||
let tokens_per_user = 1_000;
|
||||
let num_accounts = tokens / tokens_per_user;
|
||||
|
||||
let demo = MintDemo { mint, num_accounts };
|
||||
println!("{}", serde_json::to_string(&demo).unwrap());
|
||||
}
|
|
@ -59,12 +59,6 @@ impl Mint {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct MintDemo {
|
||||
pub mint: Mint,
|
||||
pub num_accounts: i64,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
Loading…
Reference in New Issue