Reduce slot duration and consecutive leader slots (#4838)

* change consecutive leader slots to 4

* reduce polling frequency for transaction signature confirmation

* adjust wait time for transaction signature confirmation

* fix nominal test

* fix flakiness in wallet pay test
This commit is contained in:
Pankaj Garg 2019-07-01 13:21:00 -07:00 committed by GitHub
parent c1953dca8f
commit 38b44f2496
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 17 deletions

View File

@ -446,17 +446,27 @@ impl RpcClient {
) -> io::Result<()> {
let mut now = Instant::now();
let mut confirmed_blocks = 0;
let mut wait_time = 15;
loop {
let response = self.get_num_blocks_since_signature_confirmation(signature);
match response {
Ok(count) => {
if confirmed_blocks != count {
info!(
"signature {} confirmed {} out of {}",
signature, count, min_confirmed_blocks
"signature {} confirmed {} out of {} after {} ms",
signature,
count,
min_confirmed_blocks,
now.elapsed().as_millis()
);
now = Instant::now();
confirmed_blocks = count;
// If the signature has been confirmed once, wait extra while reconfirming it
// One confirmation means the transaction has been seen by the network, so
// next confirmation (for a higher block count) should come through.
// Returning an error prematurely will cause a valid transaction to be deemed
// as failure.
wait_time = 30;
}
if count >= min_confirmed_blocks {
break;
@ -466,11 +476,18 @@ impl RpcClient {
debug!("check_confirmations request failed: {:?}", err);
}
};
if now.elapsed().as_secs() > 15 {
if now.elapsed().as_secs() > wait_time {
info!(
"signature {} confirmed {} out of {} failed after {} ms",
signature,
confirmed_blocks,
min_confirmed_blocks,
now.elapsed().as_millis()
);
// TODO: Return a better error.
return Err(io::Error::new(io::ErrorKind::Other, "signature not found"));
}
sleep(Duration::from_millis(250));
sleep(Duration::from_secs(1));
}
Ok(())
}

View File

@ -4,6 +4,7 @@ extern crate solana;
use assert_cmd::prelude::*;
use solana::blocktree::create_new_tmp_ledger;
use solana::genesis_utils::create_genesis_block;
use std::cmp;
use std::process::Command;
use std::process::Output;
@ -47,10 +48,12 @@ fn nominal() {
assert!(output.status.success());
assert_eq!(count_newlines(&output.stdout), ticks);
// Only print the first 5 items
let output = run_ledger_tool(&["-l", &ledger_path, "-n", "5", "print"]);
// Only print the first N items
let count = cmp::min(genesis_block.ticks_per_slot, 5);
let output = run_ledger_tool(&["-l", &ledger_path, "-n", &count.to_string(), "print"]);
println!("{:?}", output);
assert!(output.status.success());
assert_eq!(count_newlines(&output.stdout), 5);
assert_eq!(count_newlines(&output.stdout), count as usize);
// Skip entries with no hashes
let output = run_ledger_tool(&["-l", &ledger_path, "-h", "1", "print"]);

View File

@ -6,14 +6,14 @@ use std::time::{SystemTime, UNIX_EPOCH};
// rate at any given time should be expected to drift
pub const DEFAULT_NUM_TICKS_PER_SECOND: u64 = 10;
// At 10 ticks/s, 8 ticks per slot implies that leader rotation and voting will happen
// every 800 ms. A fast voting cadence ensures faster finality and convergence
pub const DEFAULT_TICKS_PER_SLOT: u64 = 8;
// At 10 ticks/s, 4 ticks per slot implies that leader rotation and voting will happen
// every 400 ms. A fast voting cadence ensures faster finality and convergence
pub const DEFAULT_TICKS_PER_SLOT: u64 = 4;
// 1 Epoch = 800 * 4096 ms ~= 55 minutes
pub const DEFAULT_SLOTS_PER_EPOCH: u64 = 4096;
// 1 Epoch = 400 * 8192 ms ~= 55 minutes
pub const DEFAULT_SLOTS_PER_EPOCH: u64 = 8192;
pub const NUM_CONSECUTIVE_LEADER_SLOTS: u64 = 8;
pub const NUM_CONSECUTIVE_LEADER_SLOTS: u64 = 4;
/// The time window of recent block hash values that the bank will track the signatures
/// of over. Once the bank discards a block hash, it will reject any transactions that use
@ -32,11 +32,11 @@ pub const MAX_PROCESSING_AGE: usize = MAX_RECENT_BLOCKHASHES / 2;
/// This is maximum time consumed in forwarding a transaction from one node to next, before
/// it can be processed in the target node
#[cfg(feature = "cuda")]
pub const MAX_TRANSACTION_FORWARDING_DELAY: usize = 4;
pub const MAX_TRANSACTION_FORWARDING_DELAY: usize = 2;
/// More delay is expected if CUDA is not enabled (as signature verification takes longer)
#[cfg(not(feature = "cuda"))]
pub const MAX_TRANSACTION_FORWARDING_DELAY: usize = 12;
pub const MAX_TRANSACTION_FORWARDING_DELAY: usize = 6;
pub fn duration_as_ns(d: &Duration) -> u64 {
d.as_secs() * 1_000_000_000 + u64::from(d.subsec_nanos())

View File

@ -12,10 +12,20 @@ use std::sync::mpsc::channel;
#[cfg(test)]
use solana::validator::new_validator_for_tests;
use std::thread::sleep;
use std::time::Duration;
fn check_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
let balance = client.retry_get_balance(pubkey, 1).unwrap().unwrap();
assert_eq!(balance, expected_balance);
(0..5).for_each(|tries| {
let balance = client.retry_get_balance(pubkey, 1).unwrap().unwrap();
if balance == expected_balance {
return;
}
if tries == 4 {
assert_eq!(balance, expected_balance);
}
sleep(Duration::from_millis(500));
});
}
#[test]