Skip to content

Commit

Permalink
Merge branch 'master' of github.com:solana-labs/solana into ecrecover
Browse files Browse the repository at this point in the history
  • Loading branch information
anton-lisanin committed Jul 7, 2021
2 parents 7640a1c + 6fb194f commit 63f4607
Show file tree
Hide file tree
Showing 195 changed files with 6,854 additions and 3,297 deletions.
406 changes: 205 additions & 201 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion account-decoder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ solana-sdk = { path = "../sdk", version = "=1.8.0" }
solana-vote-program = { path = "../programs/vote", version = "=1.8.0" }
spl-token-v2-0 = { package = "spl-token", version = "=3.1.1", features = ["no-entrypoint"] }
thiserror = "1.0"
zstd = "0.5.1"
zstd = "0.9.0"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
2 changes: 1 addition & 1 deletion accounts-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ homepage = "https://solana.com/"
publish = false

[dependencies]
log = "0.4.11"
log = "0.4.14"
rayon = "1.5.1"
solana-logger = { path = "../logger", version = "=1.8.0" }
solana-runtime = { path = "../runtime", version = "=1.8.0" }
Expand Down
2 changes: 1 addition & 1 deletion accounts-cluster-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false

[dependencies]
clap = "2.33.1"
log = "0.4.11"
log = "0.4.14"
rand = "0.7.0"
rayon = "1.5.1"
solana-account-decoder = { path = "../account-decoder", version = "=1.8.0" }
Expand Down
2 changes: 1 addition & 1 deletion banking-bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ publish = false
[dependencies]
clap = "2.33.1"
crossbeam-channel = "0.5"
log = "0.4.11"
log = "0.4.14"
rand = "0.7.0"
rayon = "1.5.1"
solana-core = { path = "../core", version = "=1.8.0" }
Expand Down
6 changes: 4 additions & 2 deletions banking-bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crossbeam_channel::unbounded;
use log::*;
use rand::{thread_rng, Rng};
use rayon::prelude::*;
use solana_core::{banking_stage::BankingStage, cost_model::CostModel};
use solana_core::{banking_stage::BankingStage, cost_model::CostModel, cost_tracker::CostTracker};
use solana_gossip::{cluster_info::ClusterInfo, cluster_info::Node};
use solana_ledger::{
blockstore::Blockstore,
Expand Down Expand Up @@ -224,7 +224,9 @@ fn main() {
vote_receiver,
None,
replay_vote_sender,
&Arc::new(RwLock::new(CostModel::default())),
Arc::new(RwLock::new(CostTracker::new(Arc::new(RwLock::new(
CostModel::default(),
))))),
);
poh_recorder.lock().unwrap().set_bank(&bank);

Expand Down
2 changes: 1 addition & 1 deletion banks-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ edition = "2018"
[dependencies]
bincode = "1.3.3"
futures = "0.3"
log = "0.4.11"
log = "0.4.14"
mio = "0.7.13"
solana-banks-interface = { path = "../banks-interface", version = "=1.8.0" }
solana-runtime = { path = "../runtime", version = "=1.8.0" }
Expand Down
2 changes: 1 addition & 1 deletion bench-exchange/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ publish = false
[dependencies]
clap = "2.33.1"
itertools = "0.10.1"
log = "0.4.11"
log = "0.4.14"
num-derive = "0.3"
num-traits = "0.2"
rand = "0.7.0"
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ publish = false
[dependencies]
bincode = "1.3.3"
clap = "2.33.1"
log = "0.4.11"
log = "0.4.14"
rayon = "1.5.1"
serde_json = "1.0.64"
serde_yaml = "0.8.17"
Expand Down
2 changes: 1 addition & 1 deletion clap-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ clap = "2.33.0"
rpassword = "5.0"
solana-remote-wallet = { path = "../remote-wallet", version = "=1.8.0" }
solana-sdk = { path = "../sdk", version = "=1.8.0" }
thiserror = "1.0.25"
thiserror = "1.0.26"
tiny-bip39 = "0.8.0"
uriparse = "0.6.3"
url = "2.2.2"
Expand Down
70 changes: 58 additions & 12 deletions cli-output/src/cli_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ pub struct CliEpochInfo {
pub epoch_info: EpochInfo,
#[serde(skip)]
pub average_slot_time_ms: u64,
#[serde(skip)]
pub start_block_time: Option<UnixTimestamp>,
#[serde(skip)]
pub current_block_time: Option<UnixTimestamp>,
}

impl QuietDisplay for CliEpochInfo {}
Expand Down Expand Up @@ -277,21 +281,41 @@ impl fmt::Display for CliEpochInfo {
remaining_slots_in_epoch
),
)?;
let (time_elapsed, annotation) = if let (Some(start_block_time), Some(current_block_time)) =
(self.start_block_time, self.current_block_time)
{
(
Duration::from_secs((current_block_time - start_block_time) as u64),
None,
)
} else {
(
slot_to_duration(self.epoch_info.slot_index, self.average_slot_time_ms),
Some("* estimated based on current slot durations"),
)
};
let time_remaining = slot_to_duration(remaining_slots_in_epoch, self.average_slot_time_ms);
writeln_name_value(
f,
"Epoch Completed Time:",
&format!(
"{}/{} ({} remaining)",
slot_to_human_time(self.epoch_info.slot_index, self.average_slot_time_ms),
slot_to_human_time(self.epoch_info.slots_in_epoch, self.average_slot_time_ms),
slot_to_human_time(remaining_slots_in_epoch, self.average_slot_time_ms)
"{}{}/{} ({} remaining)",
humantime::format_duration(time_elapsed).to_string(),
if annotation.is_some() { "*" } else { "" },
humantime::format_duration(time_elapsed + time_remaining).to_string(),
humantime::format_duration(time_remaining).to_string(),
),
)
)?;
if let Some(annotation) = annotation {
writeln!(f)?;
writeln!(f, "{}", annotation)?;
}
Ok(())
}
}

fn slot_to_human_time(slot: Slot, slot_time_ms: u64) -> String {
humantime::format_duration(Duration::from_secs((slot * slot_time_ms) / 1000)).to_string()
fn slot_to_duration(slot: Slot, slot_time_ms: u64) -> Duration {
Duration::from_secs((slot * slot_time_ms) / 1000)
}

#[derive(Serialize, Deserialize, Default)]
Expand Down Expand Up @@ -323,6 +347,8 @@ pub struct CliValidators {
pub total_current_stake: u64,
pub total_delinquent_stake: u64,
pub validators: Vec<CliValidator>,
pub average_skip_rate: f64,
pub average_stake_weighted_skip_rate: f64,
#[serde(skip_serializing)]
pub validators_sort_order: CliValidatorsSortOrder,
#[serde(skip_serializing)]
Expand Down Expand Up @@ -486,6 +512,18 @@ impl fmt::Display for CliValidators {
writeln!(f, "{}", header)?;
}

writeln!(f)?;
writeln_name_value(
f,
"Average Stake-Weighted Skip Rate:",
&format!("{:.2}%", self.average_stake_weighted_skip_rate,),
)?;
writeln_name_value(
f,
"Average Unweighted Skip Rate: ",
&format!("{:.2}%", self.average_skip_rate),
)?;

writeln!(f)?;
writeln_name_value(
f,
Expand Down Expand Up @@ -1513,11 +1551,15 @@ impl fmt::Display for CliInflation {
"Staking rate: {:>5.2}%",
self.current_rate.validator * 100.
)?;
writeln!(
f,
"Foundation rate: {:>5.2}%",
self.current_rate.foundation * 100.
)

if self.current_rate.foundation > 0. {
writeln!(
f,
"Foundation rate: {:>5.2}%",
self.current_rate.foundation * 100.
)?;
}
Ok(())
}
}

Expand Down Expand Up @@ -2408,6 +2450,10 @@ mod tests {
fn try_sign_message(&self, _message: &[u8]) -> Result<Signature, SignerError> {
Ok(Signature::new(&[1u8; 64]))
}

fn is_interactive(&self) -> bool {
false
}
}

let present: Box<dyn Signer> = Box::new(keypair_from_seed(&[2u8; 32]).unwrap());
Expand Down
2 changes: 1 addition & 1 deletion cli-output/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn format_account_mode(message: &Message, index: usize) -> String {
} else {
"-"
},
if message.is_writable(index, /*demote_sysvar_write_locks=*/ true) {
if message.is_writable(index) {
"w" // comment for consistent rust fmt (no joking; lol)
} else {
"-"
Expand Down
8 changes: 4 additions & 4 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ criterion-stats = "0.3.0"
ctrlc = { version = "3.1.9", features = ["termination"] }
console = "0.14.1"
dirs-next = "2.0.0"
log = "0.4.11"
log = "0.4.14"
Inflector = "0.11.4"
indicatif = "0.16.2"
humantime = "2.0.1"
num-traits = "0.2"
pretty-hex = "0.2.1"
reqwest = { version = "0.11.2", default-features = false, features = ["blocking", "rustls-tls", "json"] }
reqwest = { version = "0.11.4", default-features = false, features = ["blocking", "rustls-tls", "json"] }
serde = "1.0.126"
serde_derive = "1.0.103"
serde_json = "1.0.64"
Expand All @@ -38,14 +38,14 @@ solana-config-program = { path = "../programs/config", version = "=1.8.0" }
solana-faucet = { path = "../faucet", version = "=1.8.0" }
solana-logger = { path = "../logger", version = "=1.8.0" }
solana-net-utils = { path = "../net-utils", version = "=1.8.0" }
solana_rbpf = "=0.2.12"
solana_rbpf = "=0.2.13"
solana-remote-wallet = { path = "../remote-wallet", version = "=1.8.0" }
solana-sdk = { path = "../sdk", version = "=1.8.0" }
solana-transaction-status = { path = "../transaction-status", version = "=1.8.0" }
solana-version = { path = "../version", version = "=1.8.0" }
solana-vote-program = { path = "../programs/vote", version = "=1.8.0" }
spl-memo = { version = "=3.0.1", features = ["no-entrypoint"] }
thiserror = "1.0.25"
thiserror = "1.0.26"
tiny-bip39 = "0.7.0"
url = "2.2.2"

Expand Down
10 changes: 8 additions & 2 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ use std::{
use thiserror::Error;

pub const DEFAULT_RPC_TIMEOUT_SECONDS: &str = "30";
pub const DEFAULT_CONFIRM_TX_TIMEOUT_SECONDS: &str = "5";

#[derive(Debug, PartialEq)]
#[allow(clippy::large_enum_variant)]
Expand Down Expand Up @@ -453,6 +454,7 @@ pub struct CliConfig<'a> {
pub output_format: OutputFormat,
pub commitment: CommitmentConfig,
pub send_transaction_config: RpcSendTransactionConfig,
pub confirm_transaction_initial_timeout: Duration,
pub address_labels: HashMap<String, String>,
}

Expand Down Expand Up @@ -597,6 +599,9 @@ impl Default for CliConfig<'_> {
output_format: OutputFormat::Display,
commitment: CommitmentConfig::confirmed(),
send_transaction_config: RpcSendTransactionConfig::default(),
confirm_transaction_initial_timeout: Duration::from_secs(
u64::from_str(DEFAULT_CONFIRM_TX_TIMEOUT_SECONDS).unwrap(),
),
address_labels: HashMap::new(),
}
}
Expand Down Expand Up @@ -1288,10 +1293,11 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
}

let rpc_client = if config.rpc_client.is_none() {
Arc::new(RpcClient::new_with_timeout_and_commitment(
Arc::new(RpcClient::new_with_timeouts_and_commitment(
config.json_rpc_url.to_string(),
config.rpc_timeout,
config.commitment,
config.confirm_transaction_initial_timeout,
))
} else {
// Primarily for testing
Expand Down Expand Up @@ -2244,7 +2250,7 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
)
.offline_args()
.nonce_args(false)
.arg(memo_arg())
.arg(memo_arg())
.arg(fee_payer_arg()),
)
.subcommand(
Expand Down
40 changes: 36 additions & 4 deletions cli/src/cluster_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,9 +1074,15 @@ pub fn process_get_epoch_info(rpc_client: &RpcClient, config: &CliConfig) -> Pro
(secs as u64).saturating_mul(1000).checked_div(slots)
})
.unwrap_or(clock::DEFAULT_MS_PER_SLOT);
let start_block_time = rpc_client
.get_block_time(epoch_info.absolute_slot - epoch_info.slot_index)
.ok();
let current_block_time = rpc_client.get_block_time(epoch_info.absolute_slot).ok();
let epoch_info = CliEpochInfo {
epoch_info,
average_slot_time_ms,
start_block_time,
current_block_time,
};
Ok(config.output_format.formatted_string(&epoch_info))
}
Expand Down Expand Up @@ -1886,14 +1892,40 @@ pub fn process_show_validators(
entry.delinquent_active_stake += validator.activated_stake;
}

let validators: Vec<_> = current_validators
.into_iter()
.chain(delinquent_validators.into_iter())
.collect();

let (average_skip_rate, average_stake_weighted_skip_rate) = {
let mut skip_rate_len = 0;
let mut skip_rate_sum = 0.;
let mut skip_rate_weighted_sum = 0.;
for validator in validators.iter() {
if let Some(skip_rate) = validator.skip_rate {
skip_rate_sum += skip_rate;
skip_rate_len += 1;
skip_rate_weighted_sum += skip_rate * validator.activated_stake as f64;
}
}

if skip_rate_len > 0 && total_active_stake > 0 {
(
skip_rate_sum / skip_rate_len as f64,
skip_rate_weighted_sum / total_active_stake as f64,
)
} else {
(100., 100.) // Impossible?
}
};

let cli_validators = CliValidators {
total_active_stake,
total_current_stake,
total_delinquent_stake,
validators: current_validators
.into_iter()
.chain(delinquent_validators.into_iter())
.collect(),
validators,
average_skip_rate,
average_stake_weighted_skip_rate,
validators_sort_order,
validators_reverse_sort,
number_validators,
Expand Down
Loading

0 comments on commit 63f4607

Please sign in to comment.