Revert "Reformat imports to a consistent style for imports"

This reverts commit 139d15cd84.
This commit is contained in:
Trent Nelson
2021-12-13 08:48:39 -07:00
committed by Tao Zhu
parent d1e0941289
commit d7377d4794
380 changed files with 5320 additions and 6094 deletions

View File

@@ -17,10 +17,8 @@ pub mod validator_info;
use { use {
crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount}, crate::parse_account_data::{parse_account_data, AccountAdditionalData, ParsedAccount},
solana_sdk::{ solana_sdk::{
account::{ReadableAccount, WritableAccount}, account::ReadableAccount, account::WritableAccount, clock::Epoch,
clock::Epoch, fee_calculator::FeeCalculator, pubkey::Pubkey,
fee_calculator::FeeCalculator,
pubkey::Pubkey,
}, },
std::{ std::{
io::{Read, Write}, io::{Read, Write},
@@ -204,10 +202,8 @@ fn slice_data(data: &[u8], data_slice_config: Option<UiDataSliceConfig>) -> &[u8
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use solana_sdk::account::{Account, AccountSharedData};
solana_sdk::account::{Account, AccountSharedData},
};
#[test] #[test]
fn test_slice_data() { fn test_slice_data() {

View File

@@ -1,19 +1,17 @@
use { use crate::{
crate::{ parse_bpf_loader::parse_bpf_upgradeable_loader,
parse_bpf_loader::parse_bpf_upgradeable_loader, parse_config::parse_config,
parse_config::parse_config, parse_nonce::parse_nonce,
parse_nonce::parse_nonce, parse_stake::parse_stake,
parse_stake::parse_stake, parse_sysvar::parse_sysvar,
parse_sysvar::parse_sysvar, parse_token::{parse_token, spl_token_id},
parse_token::{parse_token, spl_token_id}, parse_vote::parse_vote,
parse_vote::parse_vote,
},
inflector::Inflector,
serde_json::Value,
solana_sdk::{instruction::InstructionError, pubkey::Pubkey, stake, system_program, sysvar},
std::collections::HashMap,
thiserror::Error,
}; };
use inflector::Inflector;
use serde_json::Value;
use solana_sdk::{instruction::InstructionError, pubkey::Pubkey, stake, system_program, sysvar};
use std::collections::HashMap;
use thiserror::Error;
lazy_static! { lazy_static! {
static ref BPF_UPGRADEABLE_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader_upgradeable::id(); static ref BPF_UPGRADEABLE_LOADER_PROGRAM_ID: Pubkey = solana_sdk::bpf_loader_upgradeable::id();
@@ -114,14 +112,12 @@ pub fn parse_account_data(
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use solana_sdk::nonce::{
solana_sdk::nonce::{ state::{Data, Versions},
state::{Data, Versions}, State,
State,
},
solana_vote_program::vote_state::{VoteState, VoteStateVersions},
}; };
use solana_vote_program::vote_state::{VoteState, VoteStateVersions};
#[test] #[test]
fn test_parse_account_data() { fn test_parse_account_data() {

View File

@@ -1,11 +1,9 @@
use { use crate::{
crate::{ parse_account_data::{ParsableAccount, ParseAccountError},
parse_account_data::{ParsableAccount, ParseAccountError}, UiAccountData, UiAccountEncoding,
UiAccountData, UiAccountEncoding,
},
bincode::{deserialize, serialized_size},
solana_sdk::{bpf_loader_upgradeable::UpgradeableLoaderState, pubkey::Pubkey},
}; };
use bincode::{deserialize, serialized_size};
use solana_sdk::{bpf_loader_upgradeable::UpgradeableLoaderState, pubkey::Pubkey};
pub fn parse_bpf_upgradeable_loader( pub fn parse_bpf_upgradeable_loader(
data: &[u8], data: &[u8],
@@ -92,7 +90,9 @@ pub struct UiProgramData {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use {super::*, bincode::serialize, solana_sdk::pubkey::Pubkey}; use super::*;
use bincode::serialize;
use solana_sdk::pubkey::Pubkey;
#[test] #[test]
fn test_parse_bpf_upgradeable_loader_accounts() { fn test_parse_bpf_upgradeable_loader_accounts() {

View File

@@ -1,16 +1,12 @@
use { use crate::{
crate::{ parse_account_data::{ParsableAccount, ParseAccountError},
parse_account_data::{ParsableAccount, ParseAccountError}, validator_info,
validator_info,
},
bincode::deserialize,
serde_json::Value,
solana_config_program::{get_config_data, ConfigKeys},
solana_sdk::{
pubkey::Pubkey,
stake::config::{self as stake_config, Config as StakeConfig},
},
}; };
use bincode::deserialize;
use serde_json::Value;
use solana_config_program::{get_config_data, ConfigKeys};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::stake::config::{self as stake_config, Config as StakeConfig};
pub fn parse_config(data: &[u8], pubkey: &Pubkey) -> Result<ConfigAccountType, ParseAccountError> { pub fn parse_config(data: &[u8], pubkey: &Pubkey) -> Result<ConfigAccountType, ParseAccountError> {
let parsed_account = if pubkey == &stake_config::id() { let parsed_account = if pubkey == &stake_config::id() {
@@ -91,10 +87,11 @@ pub struct UiConfig<T> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, crate::validator_info::ValidatorInfo, serde_json::json, use crate::validator_info::ValidatorInfo;
solana_config_program::create_config_account, solana_sdk::account::ReadableAccount, use serde_json::json;
}; use solana_config_program::create_config_account;
use solana_sdk::account::ReadableAccount;
#[test] #[test]
fn test_parse_config() { fn test_parse_config() {

View File

@@ -1,9 +1,7 @@
use { use crate::{parse_account_data::ParseAccountError, UiFeeCalculator};
crate::{parse_account_data::ParseAccountError, UiFeeCalculator}, use solana_sdk::{
solana_sdk::{ instruction::InstructionError,
instruction::InstructionError, nonce::{state::Versions, State},
nonce::{state::Versions, State},
},
}; };
pub fn parse_nonce(data: &[u8]) -> Result<UiNonceState, ParseAccountError> { pub fn parse_nonce(data: &[u8]) -> Result<UiNonceState, ParseAccountError> {
@@ -44,16 +42,14 @@ pub struct UiNonceData {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use solana_sdk::{
solana_sdk::{ hash::Hash,
hash::Hash, nonce::{
nonce::{ state::{Data, Versions},
state::{Data, Versions}, State,
State,
},
pubkey::Pubkey,
}, },
pubkey::Pubkey,
}; };
#[test] #[test]

View File

@@ -1,14 +1,10 @@
use { use crate::{
crate::{ parse_account_data::{ParsableAccount, ParseAccountError},
parse_account_data::{ParsableAccount, ParseAccountError}, StringAmount,
StringAmount,
},
bincode::deserialize,
solana_sdk::{
clock::{Epoch, UnixTimestamp},
stake::state::{Authorized, Delegation, Lockup, Meta, Stake, StakeState},
},
}; };
use bincode::deserialize;
use solana_sdk::clock::{Epoch, UnixTimestamp};
use solana_sdk::stake::state::{Authorized, Delegation, Lockup, Meta, Stake, StakeState};
pub fn parse_stake(data: &[u8]) -> Result<StakeAccountType, ParseAccountError> { pub fn parse_stake(data: &[u8]) -> Result<StakeAccountType, ParseAccountError> {
let stake_state: StakeState = deserialize(data) let stake_state: StakeState = deserialize(data)
@@ -136,7 +132,8 @@ impl From<Delegation> for UiDelegation {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use {super::*, bincode::serialize}; use super::*;
use bincode::serialize;
#[test] #[test]
fn test_parse_stake() { fn test_parse_stake() {

View File

@@ -1,20 +1,18 @@
use { use crate::{
crate::{ parse_account_data::{ParsableAccount, ParseAccountError},
parse_account_data::{ParsableAccount, ParseAccountError}, StringAmount, UiFeeCalculator,
StringAmount, UiFeeCalculator, };
}, use bincode::deserialize;
bincode::deserialize, use bv::BitVec;
bv::BitVec, use solana_sdk::{
solana_sdk::{ clock::{Clock, Epoch, Slot, UnixTimestamp},
clock::{Clock, Epoch, Slot, UnixTimestamp}, epoch_schedule::EpochSchedule,
epoch_schedule::EpochSchedule, pubkey::Pubkey,
pubkey::Pubkey, rent::Rent,
rent::Rent, slot_hashes::SlotHashes,
slot_hashes::SlotHashes, slot_history::{self, SlotHistory},
slot_history::{self, SlotHistory}, stake_history::{StakeHistory, StakeHistoryEntry},
stake_history::{StakeHistory, StakeHistoryEntry}, sysvar::{self, fees::Fees, recent_blockhashes::RecentBlockhashes, rewards::Rewards},
sysvar::{self, fees::Fees, recent_blockhashes::RecentBlockhashes, rewards::Rewards},
},
}; };
pub fn parse_sysvar(data: &[u8], pubkey: &Pubkey) -> Result<SysvarAccountType, ParseAccountError> { pub fn parse_sysvar(data: &[u8], pubkey: &Pubkey) -> Result<SysvarAccountType, ParseAccountError> {
@@ -214,12 +212,10 @@ pub struct UiStakeHistoryEntry {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use solana_sdk::{
solana_sdk::{ account::create_account_for_test, fee_calculator::FeeCalculator, hash::Hash,
account::create_account_for_test, fee_calculator::FeeCalculator, hash::Hash, sysvar::recent_blockhashes::IterItem,
sysvar::recent_blockhashes::IterItem,
},
}; };
#[test] #[test]

View File

@@ -1,17 +1,15 @@
use { use crate::{
crate::{ parse_account_data::{ParsableAccount, ParseAccountError},
parse_account_data::{ParsableAccount, ParseAccountError}, StringAmount, StringDecimals,
StringAmount, StringDecimals,
},
solana_sdk::pubkey::Pubkey,
spl_token::{
solana_program::{
program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey,
},
state::{Account, AccountState, Mint, Multisig},
},
std::str::FromStr,
}; };
use solana_sdk::pubkey::Pubkey;
use spl_token::{
solana_program::{
program_option::COption, program_pack::Pack, pubkey::Pubkey as SplTokenPubkey,
},
state::{Account, AccountState, Mint, Multisig},
};
use std::str::FromStr;
// A helper function to convert spl_token::id() as spl_sdk::pubkey::Pubkey to // A helper function to convert spl_token::id() as spl_sdk::pubkey::Pubkey to
// solana_sdk::pubkey::Pubkey // solana_sdk::pubkey::Pubkey

View File

@@ -1,11 +1,9 @@
use { use crate::{parse_account_data::ParseAccountError, StringAmount};
crate::{parse_account_data::ParseAccountError, StringAmount}, use solana_sdk::{
solana_sdk::{ clock::{Epoch, Slot},
clock::{Epoch, Slot}, pubkey::Pubkey,
pubkey::Pubkey,
},
solana_vote_program::vote_state::{BlockTimestamp, Lockout, VoteState},
}; };
use solana_vote_program::vote_state::{BlockTimestamp, Lockout, VoteState};
pub fn parse_vote(data: &[u8]) -> Result<VoteAccountType, ParseAccountError> { pub fn parse_vote(data: &[u8]) -> Result<VoteAccountType, ParseAccountError> {
let mut vote_state = VoteState::deserialize(data).map_err(ParseAccountError::from)?; let mut vote_state = VoteState::deserialize(data).map_err(ParseAccountError::from)?;
@@ -123,7 +121,8 @@ struct UiEpochCredits {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use {super::*, solana_vote_program::vote_state::VoteStateVersions}; use super::*;
use solana_vote_program::vote_state::VoteStateVersions;
#[test] #[test]
fn test_parse_vote() { fn test_parse_vote() {

View File

@@ -1,19 +1,17 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
#[macro_use] #[macro_use]
extern crate log; extern crate log;
use { use clap::{crate_description, crate_name, value_t, App, Arg};
clap::{crate_description, crate_name, value_t, App, Arg}, use rayon::prelude::*;
rayon::prelude::*, use solana_measure::measure::Measure;
solana_measure::measure::Measure, use solana_runtime::{
solana_runtime::{ accounts::{create_test_accounts, update_accounts_bench, Accounts},
accounts::{create_test_accounts, update_accounts_bench, Accounts}, accounts_db::AccountShrinkThreshold,
accounts_db::AccountShrinkThreshold, accounts_index::AccountSecondaryIndexes,
accounts_index::AccountSecondaryIndexes, ancestors::Ancestors,
ancestors::Ancestors,
},
solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey},
std::{env, fs, path::PathBuf},
}; };
use solana_sdk::{genesis_config::ClusterType, pubkey::Pubkey};
use std::{env, fs, path::PathBuf};
fn main() { fn main() {
solana_logger::setup(); solana_logger::setup();

View File

@@ -1,38 +1,36 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use { use clap::{crate_description, crate_name, value_t, values_t_or_exit, App, Arg};
clap::{crate_description, crate_name, value_t, values_t_or_exit, App, Arg}, use log::*;
log::*, use rand::{thread_rng, Rng};
rand::{thread_rng, Rng}, use rayon::prelude::*;
rayon::prelude::*, use solana_account_decoder::parse_token::spl_token_pubkey;
solana_account_decoder::parse_token::spl_token_pubkey, use solana_clap_utils::input_parsers::pubkey_of;
solana_clap_utils::input_parsers::pubkey_of, use solana_client::rpc_client::RpcClient;
solana_client::rpc_client::RpcClient, use solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT};
solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT}, use solana_gossip::gossip_service::discover;
solana_gossip::gossip_service::discover, use solana_measure::measure::Measure;
solana_measure::measure::Measure, use solana_runtime::inline_spl_token;
solana_runtime::inline_spl_token, use solana_sdk::{
solana_sdk::{ commitment_config::CommitmentConfig,
commitment_config::CommitmentConfig, message::Message,
message::Message, pubkey::Pubkey,
pubkey::Pubkey, rpc_port::DEFAULT_RPC_PORT,
rpc_port::DEFAULT_RPC_PORT, signature::{read_keypair_file, Keypair, Signature, Signer},
signature::{read_keypair_file, Keypair, Signature, Signer}, system_instruction, system_program,
system_instruction, system_program, timing::timestamp,
timing::timestamp, transaction::Transaction,
transaction::Transaction, };
}, use solana_streamer::socket::SocketAddrSpace;
solana_streamer::socket::SocketAddrSpace, use solana_transaction_status::parse_token::spl_token_instruction;
solana_transaction_status::parse_token::spl_token_instruction, use std::{
std::{ net::SocketAddr,
net::SocketAddr, process::exit,
process::exit, sync::{
sync::{ atomic::{AtomicBool, AtomicU64, Ordering},
atomic::{AtomicBool, AtomicU64, Ordering}, Arc, RwLock,
Arc, RwLock,
},
thread::{sleep, Builder, JoinHandle},
time::{Duration, Instant},
}, },
thread::{sleep, Builder, JoinHandle},
time::{Duration, Instant},
}; };
// Create and close messages both require 2 signatures; if transaction construction changes, update // Create and close messages both require 2 signatures; if transaction construction changes, update
@@ -703,15 +701,13 @@ fn main() {
#[cfg(test)] #[cfg(test)]
pub mod test { pub mod test {
use { use super::*;
super::*, use solana_core::validator::ValidatorConfig;
solana_core::validator::ValidatorConfig, use solana_local_cluster::{
solana_local_cluster::{ local_cluster::{ClusterConfig, LocalCluster},
local_cluster::{ClusterConfig, LocalCluster}, validator_configs::make_identical_validator_configs,
validator_configs::make_identical_validator_configs,
},
solana_sdk::poh_config::PohConfig,
}; };
use solana_sdk::poh_config::PohConfig;
#[test] #[test]
fn test_accounts_cluster_bench() { fn test_accounts_cluster_bench() {

View File

@@ -1,4 +1,5 @@
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
/// Main entry for the PostgreSQL plugin /// Main entry for the PostgreSQL plugin
use { use {
crate::{ crate::{

View File

@@ -1,37 +1,36 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use { use clap::{crate_description, crate_name, value_t, App, Arg};
clap::{crate_description, crate_name, value_t, App, Arg}, use crossbeam_channel::unbounded;
crossbeam_channel::unbounded, use log::*;
log::*, use rand::{thread_rng, Rng};
rand::{thread_rng, Rng}, use rayon::prelude::*;
rayon::prelude::*, use solana_core::banking_stage::BankingStage;
solana_core::banking_stage::BankingStage, use solana_gossip::{cluster_info::ClusterInfo, cluster_info::Node};
solana_gossip::cluster_info::{ClusterInfo, Node}, use solana_ledger::{
solana_ledger::{ blockstore::Blockstore,
blockstore::Blockstore, genesis_utils::{create_genesis_config, GenesisConfigInfo},
genesis_utils::{create_genesis_config, GenesisConfigInfo}, get_tmp_ledger_path,
get_tmp_ledger_path, };
}, use solana_measure::measure::Measure;
solana_measure::measure::Measure, use solana_perf::packet::to_packets_chunked;
solana_perf::packet::to_packets_chunked, use solana_poh::poh_recorder::{create_test_recorder, PohRecorder, WorkingBankEntry};
solana_poh::poh_recorder::{create_test_recorder, PohRecorder, WorkingBankEntry}, use solana_runtime::{
solana_runtime::{ accounts_background_service::AbsRequestSender, bank::Bank, bank_forks::BankForks,
accounts_background_service::AbsRequestSender, bank::Bank, bank_forks::BankForks, cost_model::CostModel,
cost_model::CostModel, };
}, use solana_sdk::{
solana_sdk::{ hash::Hash,
hash::Hash, signature::Keypair,
signature::{Keypair, Signature}, signature::Signature,
system_transaction, system_transaction,
timing::{duration_as_us, timestamp}, timing::{duration_as_us, timestamp},
transaction::Transaction, transaction::Transaction,
}, };
solana_streamer::socket::SocketAddrSpace, use solana_streamer::socket::SocketAddrSpace;
std::{ use std::{
sync::{atomic::Ordering, mpsc::Receiver, Arc, Mutex, RwLock}, sync::{atomic::Ordering, mpsc::Receiver, Arc, Mutex, RwLock},
thread::sleep, thread::sleep,
time::{Duration, Instant}, time::{Duration, Instant},
},
}; };
fn check_txs( fn check_txs(

View File

@@ -5,38 +5,37 @@
//! but they are undocumented, may change over time, and are generally more //! but they are undocumented, may change over time, and are generally more
//! cumbersome to use. //! cumbersome to use.
use borsh::BorshDeserialize;
use futures::{future::join_all, Future, FutureExt};
pub use solana_banks_interface::{BanksClient as TarpcClient, TransactionStatus}; pub use solana_banks_interface::{BanksClient as TarpcClient, TransactionStatus};
use { use solana_banks_interface::{BanksRequest, BanksResponse};
borsh::BorshDeserialize, use solana_program::{
futures::{future::join_all, Future, FutureExt}, clock::Clock,
solana_banks_interface::{BanksRequest, BanksResponse}, clock::Slot,
solana_program::{ fee_calculator::FeeCalculator,
clock::{Clock, Slot}, hash::Hash,
fee_calculator::FeeCalculator, program_pack::Pack,
hash::Hash, pubkey::Pubkey,
program_pack::Pack, rent::Rent,
pubkey::Pubkey, sysvar::{self, Sysvar},
rent::Rent,
sysvar::{self, Sysvar},
},
solana_sdk::{
account::{from_account, Account},
commitment_config::CommitmentLevel,
signature::Signature,
transaction::{self, Transaction},
transport,
},
std::io::{self, Error, ErrorKind},
tarpc::{
client::{self, channel::RequestDispatch, NewClient},
context::{self, Context},
rpc::{ClientMessage, Response},
serde_transport::tcp,
Transport,
},
tokio::{net::ToSocketAddrs, time::Duration},
tokio_serde::formats::Bincode,
}; };
use solana_sdk::{
account::{from_account, Account},
commitment_config::CommitmentLevel,
signature::Signature,
transaction::{self, Transaction},
transport,
};
use std::io::{self, Error, ErrorKind};
use tarpc::{
client::{self, channel::RequestDispatch, NewClient},
context::{self, Context},
rpc::{ClientMessage, Response},
serde_transport::tcp,
Transport,
};
use tokio::{net::ToSocketAddrs, time::Duration};
use tokio_serde::formats::Bincode;
// This exists only for backward compatibility // This exists only for backward compatibility
pub trait BanksClientExt {} pub trait BanksClientExt {}
@@ -349,18 +348,16 @@ pub async fn start_tcp_client<T: ToSocketAddrs>(addr: T) -> io::Result<BanksClie
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use solana_banks_server::banks_server::start_local_server;
solana_banks_server::banks_server::start_local_server, use solana_runtime::{
solana_runtime::{ bank::Bank, bank_forks::BankForks, commitment::BlockCommitmentCache,
bank::Bank, bank_forks::BankForks, commitment::BlockCommitmentCache, genesis_utils::create_genesis_config,
genesis_utils::create_genesis_config,
},
solana_sdk::{message::Message, signature::Signer, system_instruction},
std::sync::{Arc, RwLock},
tarpc::transport,
tokio::{runtime::Runtime, time::sleep},
}; };
use solana_sdk::{message::Message, signature::Signer, system_instruction};
use std::sync::{Arc, RwLock};
use tarpc::transport;
use tokio::{runtime::Runtime, time::sleep};
#[test] #[test]
fn test_banks_client_new() { fn test_banks_client_new() {

View File

@@ -1,15 +1,13 @@
use { use serde::{Deserialize, Serialize};
serde::{Deserialize, Serialize}, use solana_sdk::{
solana_sdk::{ account::Account,
account::Account, clock::Slot,
clock::Slot, commitment_config::CommitmentLevel,
commitment_config::CommitmentLevel, fee_calculator::FeeCalculator,
fee_calculator::FeeCalculator, hash::Hash,
hash::Hash, pubkey::Pubkey,
pubkey::Pubkey, signature::Signature,
signature::Signature, transaction::{self, Transaction, TransactionError},
transaction::{self, Transaction, TransactionError},
},
}; };
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
@@ -49,10 +47,8 @@ pub trait Banks {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use tarpc::{client, transport};
tarpc::{client, transport},
};
#[test] #[test]
fn test_banks_client_new() { fn test_banks_client_new() {

View File

@@ -1,45 +1,43 @@
use { use crate::send_transaction_service::{SendTransactionService, TransactionInfo};
crate::send_transaction_service::{SendTransactionService, TransactionInfo}, use bincode::{deserialize, serialize};
bincode::{deserialize, serialize}, use futures::{
futures::{ future,
future, prelude::stream::{self, StreamExt},
prelude::stream::{self, StreamExt},
},
solana_banks_interface::{
Banks, BanksRequest, BanksResponse, TransactionConfirmationStatus, TransactionStatus,
},
solana_runtime::{bank::Bank, bank_forks::BankForks, commitment::BlockCommitmentCache},
solana_sdk::{
account::Account,
clock::Slot,
commitment_config::CommitmentLevel,
feature_set::FeatureSet,
fee_calculator::FeeCalculator,
hash::Hash,
pubkey::Pubkey,
signature::Signature,
transaction::{self, Transaction},
},
std::{
io,
net::{Ipv4Addr, SocketAddr},
sync::{
mpsc::{channel, Receiver, Sender},
Arc, RwLock,
},
thread::Builder,
time::Duration,
},
tarpc::{
context::Context,
rpc::{transport::channel::UnboundedChannel, ClientMessage, Response},
serde_transport::tcp,
server::{self, Channel, Handler},
transport,
},
tokio::time::sleep,
tokio_serde::formats::Bincode,
}; };
use solana_banks_interface::{
Banks, BanksRequest, BanksResponse, TransactionConfirmationStatus, TransactionStatus,
};
use solana_runtime::{bank::Bank, bank_forks::BankForks, commitment::BlockCommitmentCache};
use solana_sdk::{
account::Account,
clock::Slot,
commitment_config::CommitmentLevel,
feature_set::FeatureSet,
fee_calculator::FeeCalculator,
hash::Hash,
pubkey::Pubkey,
signature::Signature,
transaction::{self, Transaction},
};
use std::{
io,
net::{Ipv4Addr, SocketAddr},
sync::{
mpsc::{channel, Receiver, Sender},
Arc, RwLock,
},
thread::Builder,
time::Duration,
};
use tarpc::{
context::Context,
rpc::{transport::channel::UnboundedChannel, ClientMessage, Response},
serde_transport::tcp,
server::{self, Channel, Handler},
transport,
};
use tokio::time::sleep;
use tokio_serde::formats::Bincode;
#[derive(Clone)] #[derive(Clone)]
struct BanksServer { struct BanksServer {

View File

@@ -1,23 +1,21 @@
//! The `rpc_banks_service` module implements the Solana Banks RPC API. //! The `rpc_banks_service` module implements the Solana Banks RPC API.
use { use crate::banks_server::start_tcp_server;
crate::banks_server::start_tcp_server, use futures::{future::FutureExt, pin_mut, prelude::stream::StreamExt, select};
futures::{future::FutureExt, pin_mut, prelude::stream::StreamExt, select}, use solana_runtime::{bank_forks::BankForks, commitment::BlockCommitmentCache};
solana_runtime::{bank_forks::BankForks, commitment::BlockCommitmentCache}, use std::{
std::{ net::SocketAddr,
net::SocketAddr, sync::{
sync::{ atomic::{AtomicBool, Ordering},
atomic::{AtomicBool, Ordering}, Arc, RwLock,
Arc, RwLock,
},
thread::{self, Builder, JoinHandle},
}, },
tokio::{ thread::{self, Builder, JoinHandle},
runtime::Runtime,
time::{self, Duration},
},
tokio_stream::wrappers::IntervalStream,
}; };
use tokio::{
runtime::Runtime,
time::{self, Duration},
};
use tokio_stream::wrappers::IntervalStream;
pub struct RpcBanksService { pub struct RpcBanksService {
thread_hdl: JoinHandle<()>, thread_hdl: JoinHandle<()>,
@@ -103,7 +101,8 @@ impl RpcBanksService {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use {super::*, solana_runtime::bank::Bank}; use super::*;
use solana_runtime::bank::Bank;
#[test] #[test]
fn test_rpc_banks_server_exit() { fn test_rpc_banks_server_exit() {

View File

@@ -1,19 +1,17 @@
// TODO: Merge this implementation with the one at `core/src/send_transaction_service.rs` // TODO: Merge this implementation with the one at `core/src/send_transaction_service.rs`
use { use log::*;
log::*, use solana_metrics::{datapoint_warn, inc_new_counter_info};
solana_metrics::{datapoint_warn, inc_new_counter_info}, use solana_runtime::{bank::Bank, bank_forks::BankForks};
solana_runtime::{bank::Bank, bank_forks::BankForks}, use solana_sdk::signature::Signature;
solana_sdk::signature::Signature, use std::{
std::{ collections::HashMap,
collections::HashMap, net::{SocketAddr, UdpSocket},
net::{SocketAddr, UdpSocket}, sync::{
sync::{ mpsc::{Receiver, RecvTimeoutError},
mpsc::{Receiver, RecvTimeoutError}, Arc, RwLock,
Arc, RwLock,
},
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
}, },
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
}; };
/// Maximum size of the transaction queue /// Maximum size of the transaction queue
@@ -185,14 +183,12 @@ impl SendTransactionService {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use solana_sdk::{
solana_sdk::{ genesis_config::create_genesis_config, pubkey::Pubkey, signature::Signer,
genesis_config::create_genesis_config, pubkey::Pubkey, signature::Signer, system_transaction,
system_transaction,
},
std::sync::mpsc::channel,
}; };
use std::sync::mpsc::channel;
#[test] #[test]
fn service_exit() { fn service_exit() {

View File

@@ -1,45 +1,43 @@
#![allow(clippy::useless_attribute)] #![allow(clippy::useless_attribute)]
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use { use crate::order_book::*;
crate::order_book::*, use itertools::izip;
itertools::izip, use log::*;
log::*, use rand::{thread_rng, Rng};
rand::{thread_rng, Rng}, use rayon::prelude::*;
rayon::prelude::*, use solana_client::perf_utils::{sample_txs, SampleStats};
solana_client::perf_utils::{sample_txs, SampleStats}, use solana_core::gen_keys::GenKeys;
solana_core::gen_keys::GenKeys, use solana_exchange_program::{exchange_instruction, exchange_state::*, id};
solana_exchange_program::{exchange_instruction, exchange_state::*, id}, use solana_faucet::faucet::request_airdrop_transaction;
solana_faucet::faucet::request_airdrop_transaction, use solana_genesis::Base64Account;
solana_genesis::Base64Account, use solana_metrics::datapoint_info;
solana_metrics::datapoint_info, use solana_sdk::{
solana_sdk::{ client::{Client, SyncClient},
client::{Client, SyncClient}, commitment_config::CommitmentConfig,
commitment_config::CommitmentConfig, message::Message,
message::Message, pubkey::Pubkey,
pubkey::Pubkey, signature::{Keypair, Signer},
signature::{Keypair, Signer}, timing::{duration_as_ms, duration_as_s},
system_instruction, system_program, transaction::Transaction,
timing::{duration_as_ms, duration_as_s}, {system_instruction, system_program},
transaction::Transaction, };
}, use std::{
std::{ cmp,
cmp, collections::{HashMap, VecDeque},
collections::{HashMap, VecDeque}, fs::File,
fs::File, io::prelude::*,
io::prelude::*, mem,
mem, net::SocketAddr,
net::SocketAddr, path::Path,
path::Path, process::exit,
process::exit, sync::{
sync::{ atomic::{AtomicBool, AtomicUsize, Ordering},
atomic::{AtomicBool, AtomicUsize, Ordering}, mpsc::{channel, Receiver, Sender},
mpsc::{channel, Receiver, Sender}, Arc, RwLock,
Arc, RwLock,
},
thread::{sleep, Builder},
time::{Duration, Instant},
}, },
thread::{sleep, Builder},
time::{Duration, Instant},
}; };
// TODO Chunk length as specified results in a bunch of failures, divide by 10 helps... // TODO Chunk length as specified results in a bunch of failures, divide by 10 helps...

View File

@@ -1,10 +1,10 @@
use { use clap::{crate_description, crate_name, value_t, App, Arg, ArgMatches};
clap::{crate_description, crate_name, value_t, App, Arg, ArgMatches}, use solana_core::gen_keys::GenKeys;
solana_core::gen_keys::GenKeys, use solana_faucet::faucet::FAUCET_PORT;
solana_faucet::faucet::FAUCET_PORT, use solana_sdk::signature::{read_keypair_file, Keypair};
solana_sdk::signature::{read_keypair_file, Keypair}, use std::net::SocketAddr;
std::{net::SocketAddr, process::exit, time::Duration}, use std::process::exit;
}; use std::time::Duration;
pub struct Config { pub struct Config {
pub entrypoint_addr: SocketAddr, pub entrypoint_addr: SocketAddr,

View File

@@ -3,13 +3,11 @@ pub mod bench;
mod cli; mod cli;
pub mod order_book; pub mod order_book;
use { use crate::bench::{airdrop_lamports, create_client_accounts_file, do_bench_exchange, Config};
crate::bench::{airdrop_lamports, create_client_accounts_file, do_bench_exchange, Config}, use log::*;
log::*, use solana_gossip::gossip_service::{discover_cluster, get_multi_client};
solana_gossip::gossip_service::{discover_cluster, get_multi_client}, use solana_sdk::signature::Signer;
solana_sdk::signature::Signer, use solana_streamer::socket::SocketAddrSpace;
solana_streamer::socket::SocketAddrSpace,
};
fn main() { fn main() {
solana_logger::setup(); solana_logger::setup();

View File

@@ -1,13 +1,11 @@
use { use itertools::EitherOrBoth::{Both, Left, Right};
itertools::{ use itertools::Itertools;
EitherOrBoth::{Both, Left, Right}, use log::*;
Itertools, use solana_exchange_program::exchange_state::*;
}, use solana_sdk::pubkey::Pubkey;
log::*, use std::cmp::Ordering;
solana_exchange_program::exchange_state::*, use std::collections::BinaryHeap;
solana_sdk::pubkey::Pubkey, use std::{error, fmt};
std::{cmp::Ordering, collections::BinaryHeap, error, fmt},
};
#[derive(Clone, Debug, Eq, PartialEq)] #[derive(Clone, Debug, Eq, PartialEq)]
pub struct ToOrder { pub struct ToOrder {

View File

@@ -1,24 +1,22 @@
use { use log::*;
log::*, use solana_bench_exchange::bench::{airdrop_lamports, do_bench_exchange, Config};
solana_bench_exchange::bench::{airdrop_lamports, do_bench_exchange, Config}, use solana_core::validator::ValidatorConfig;
solana_core::validator::ValidatorConfig, use solana_exchange_program::{
solana_exchange_program::{ exchange_processor::process_instruction, id, solana_exchange_program,
exchange_processor::process_instruction, id, solana_exchange_program,
},
solana_faucet::faucet::run_local_faucet_with_port,
solana_gossip::gossip_service::{discover_cluster, get_multi_client},
solana_local_cluster::{
local_cluster::{ClusterConfig, LocalCluster},
validator_configs::make_identical_validator_configs,
},
solana_runtime::{bank::Bank, bank_client::BankClient},
solana_sdk::{
genesis_config::create_genesis_config,
signature::{Keypair, Signer},
},
solana_streamer::socket::SocketAddrSpace,
std::{process::exit, sync::mpsc::channel, time::Duration},
}; };
use solana_faucet::faucet::run_local_faucet_with_port;
use solana_gossip::gossip_service::{discover_cluster, get_multi_client};
use solana_local_cluster::{
local_cluster::{ClusterConfig, LocalCluster},
validator_configs::make_identical_validator_configs,
};
use solana_runtime::{bank::Bank, bank_client::BankClient};
use solana_sdk::{
genesis_config::create_genesis_config,
signature::{Keypair, Signer},
};
use solana_streamer::socket::SocketAddrSpace;
use std::{process::exit, sync::mpsc::channel, time::Duration};
#[test] #[test]
#[ignore] #[ignore]

View File

@@ -1,22 +1,16 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use { use clap::{crate_description, crate_name, App, Arg};
clap::{crate_description, crate_name, App, Arg}, use solana_streamer::packet::{Packet, Packets, PacketsRecycler, PACKET_DATA_SIZE};
solana_streamer::{ use solana_streamer::streamer::{receiver, PacketReceiver};
packet::{Packet, Packets, PacketsRecycler, PACKET_DATA_SIZE}, use std::cmp::max;
streamer::{receiver, PacketReceiver}, use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket};
}, use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
std::{ use std::sync::mpsc::channel;
cmp::max, use std::sync::Arc;
net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket}, use std::thread::sleep;
sync::{ use std::thread::{spawn, JoinHandle, Result};
atomic::{AtomicBool, AtomicUsize, Ordering}, use std::time::Duration;
mpsc::channel, use std::time::SystemTime;
Arc,
},
thread::{sleep, spawn, JoinHandle, Result},
time::{Duration, SystemTime},
},
};
fn producer(addr: &SocketAddr, exit: Arc<AtomicBool>) -> JoinHandle<()> { fn producer(addr: &SocketAddr, exit: Arc<AtomicBool>) -> JoinHandle<()> {
let send = UdpSocket::bind("0.0.0.0:0").unwrap(); let send = UdpSocket::bind("0.0.0.0:0").unwrap();

View File

@@ -1,36 +1,34 @@
use { use crate::cli::Config;
crate::cli::Config, use log::*;
log::*, use rayon::prelude::*;
rayon::prelude::*, use solana_client::perf_utils::{sample_txs, SampleStats};
solana_client::perf_utils::{sample_txs, SampleStats}, use solana_core::gen_keys::GenKeys;
solana_core::gen_keys::GenKeys, use solana_faucet::faucet::request_airdrop_transaction;
solana_faucet::faucet::request_airdrop_transaction, use solana_measure::measure::Measure;
solana_measure::measure::Measure, use solana_metrics::{self, datapoint_info};
solana_metrics::{self, datapoint_info}, use solana_sdk::{
solana_sdk::{ client::Client,
client::Client, clock::{DEFAULT_S_PER_SLOT, MAX_PROCESSING_AGE},
clock::{DEFAULT_S_PER_SLOT, MAX_PROCESSING_AGE}, commitment_config::CommitmentConfig,
commitment_config::CommitmentConfig, fee_calculator::FeeCalculator,
fee_calculator::FeeCalculator, hash::Hash,
hash::Hash, message::Message,
message::Message, pubkey::Pubkey,
pubkey::Pubkey, signature::{Keypair, Signer},
signature::{Keypair, Signer}, system_instruction, system_transaction,
system_instruction, system_transaction, timing::{duration_as_ms, duration_as_s, duration_as_us, timestamp},
timing::{duration_as_ms, duration_as_s, duration_as_us, timestamp}, transaction::Transaction,
transaction::Transaction, };
}, use std::{
std::{ collections::{HashSet, VecDeque},
collections::{HashSet, VecDeque}, net::SocketAddr,
net::SocketAddr, process::exit,
process::exit, sync::{
sync::{ atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering},
atomic::{AtomicBool, AtomicIsize, AtomicUsize, Ordering}, Arc, Mutex, RwLock,
Arc, Mutex, RwLock,
},
thread::{sleep, Builder, JoinHandle},
time::{Duration, Instant},
}, },
thread::{sleep, Builder, JoinHandle},
time::{Duration, Instant},
}; };
// The point at which transactions become "too old", in seconds. // The point at which transactions become "too old", in seconds.
@@ -926,14 +924,12 @@ pub fn generate_and_fund_keypairs<T: 'static + Client + Send + Sync>(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use solana_runtime::bank::Bank;
solana_runtime::{bank::Bank, bank_client::BankClient}, use solana_runtime::bank_client::BankClient;
solana_sdk::{ use solana_sdk::client::SyncClient;
client::SyncClient, fee_calculator::FeeRateGovernor, use solana_sdk::fee_calculator::FeeRateGovernor;
genesis_config::create_genesis_config, use solana_sdk::genesis_config::create_genesis_config;
},
};
#[test] #[test]
fn test_bench_tps_bank_client() { fn test_bench_tps_bank_client() {

View File

@@ -1,13 +1,11 @@
use { use clap::{crate_description, crate_name, App, Arg, ArgMatches};
clap::{crate_description, crate_name, App, Arg, ArgMatches}, use solana_faucet::faucet::FAUCET_PORT;
solana_faucet::faucet::FAUCET_PORT, use solana_sdk::fee_calculator::FeeRateGovernor;
solana_sdk::{ use solana_sdk::{
fee_calculator::FeeRateGovernor, pubkey::Pubkey,
pubkey::Pubkey, signature::{read_keypair_file, Keypair},
signature::{read_keypair_file, Keypair},
},
std::{net::SocketAddr, process::exit, time::Duration},
}; };
use std::{net::SocketAddr, process::exit, time::Duration};
const NUM_LAMPORTS_PER_ACCOUNT_DEFAULT: u64 = solana_sdk::native_token::LAMPORTS_PER_SOL; const NUM_LAMPORTS_PER_ACCOUNT_DEFAULT: u64 = solana_sdk::native_token::LAMPORTS_PER_SOL;

View File

@@ -1,20 +1,14 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use { use log::*;
log::*, use solana_bench_tps::bench::{do_bench_tps, generate_and_fund_keypairs, generate_keypairs};
solana_bench_tps::{ use solana_bench_tps::cli;
bench::{do_bench_tps, generate_and_fund_keypairs, generate_keypairs}, use solana_genesis::Base64Account;
cli, use solana_gossip::gossip_service::{discover_cluster, get_client, get_multi_client};
}, use solana_sdk::fee_calculator::FeeRateGovernor;
solana_genesis::Base64Account, use solana_sdk::signature::{Keypair, Signer};
solana_gossip::gossip_service::{discover_cluster, get_client, get_multi_client}, use solana_sdk::system_program;
solana_sdk::{ use solana_streamer::socket::SocketAddrSpace;
fee_calculator::FeeRateGovernor, use std::{collections::HashMap, fs::File, io::prelude::*, path::Path, process::exit, sync::Arc};
signature::{Keypair, Signer},
system_program,
},
solana_streamer::socket::SocketAddrSpace,
std::{collections::HashMap, fs::File, io::prelude::*, path::Path, process::exit, sync::Arc},
};
/// Number of signatures for all transactions in ~1 week at ~100K TPS /// Number of signatures for all transactions in ~1 week at ~100K TPS
pub const NUM_SIGNATURES_FOR_TXS: u64 = 100_000 * 60 * 60 * 24 * 7; pub const NUM_SIGNATURES_FOR_TXS: u64 = 100_000 * 60 * 60 * 24 * 7;

View File

@@ -1,24 +1,22 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use { use serial_test::serial;
serial_test::serial, use solana_bench_tps::{
solana_bench_tps::{ bench::{do_bench_tps, generate_and_fund_keypairs},
bench::{do_bench_tps, generate_and_fund_keypairs}, cli::Config,
cli::Config, };
}, use solana_client::thin_client::create_client;
solana_client::thin_client::create_client, use solana_core::validator::ValidatorConfig;
solana_core::validator::ValidatorConfig, use solana_faucet::faucet::run_local_faucet_with_port;
solana_faucet::faucet::run_local_faucet_with_port, use solana_gossip::cluster_info::VALIDATOR_PORT_RANGE;
solana_gossip::cluster_info::VALIDATOR_PORT_RANGE, use solana_local_cluster::{
solana_local_cluster::{ local_cluster::{ClusterConfig, LocalCluster},
local_cluster::{ClusterConfig, LocalCluster}, validator_configs::make_identical_validator_configs,
validator_configs::make_identical_validator_configs, };
}, use solana_sdk::signature::{Keypair, Signer};
solana_sdk::signature::{Keypair, Signer}, use solana_streamer::socket::SocketAddrSpace;
solana_streamer::socket::SocketAddrSpace, use std::{
std::{ sync::{mpsc::channel, Arc},
sync::{mpsc::channel, Arc}, time::Duration,
time::Duration,
},
}; };
fn test_bench_tps_local_cluster(config: Config) { fn test_bench_tps_local_cluster(config: Config) {

View File

@@ -196,12 +196,10 @@ pub fn commitment_of(matches: &ArgMatches<'_>, name: &str) -> Option<CommitmentC
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use clap::{App, Arg};
clap::{App, Arg}, use solana_sdk::signature::write_keypair_file;
solana_sdk::signature::write_keypair_file, use std::fs;
std::fs,
};
fn app<'ab, 'v>() -> App<'ab, 'v> { fn app<'ab, 'v>() -> App<'ab, 'v> {
App::new("test") App::new("test")

View File

@@ -7,7 +7,8 @@ use {
pubkey::{Pubkey, MAX_SEED_LEN}, pubkey::{Pubkey, MAX_SEED_LEN},
signature::{read_keypair_file, Signature}, signature::{read_keypair_file, Signature},
}, },
std::{fmt::Display, str::FromStr}, std::fmt::Display,
std::str::FromStr,
}; };
fn is_parsable_generic<U, T>(string: T) -> Result<(), String> fn is_parsable_generic<U, T>(string: T) -> Result<(), String>

View File

@@ -1123,14 +1123,14 @@ fn sanitize_seed_phrase(seed_phrase: &str) -> String {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::offline::OfflineArgs;
crate::offline::OfflineArgs, use clap::{value_t_or_exit, App, Arg};
clap::{value_t_or_exit, App, Arg}, use solana_remote_wallet::locator::Manufacturer;
solana_remote_wallet::{locator::Manufacturer, remote_wallet::initialize_wallet_manager}, use solana_remote_wallet::remote_wallet::initialize_wallet_manager;
solana_sdk::{signer::keypair::write_keypair_file, system_instruction}, use solana_sdk::signer::keypair::write_keypair_file;
tempfile::{NamedTempFile, TempDir}, use solana_sdk::system_instruction;
}; use tempfile::{NamedTempFile, TempDir};
#[test] #[test]
fn test_sanitize_seed_phrase() { fn test_sanitize_seed_phrase() {

View File

@@ -1,9 +1,7 @@
// Wallet settings that can be configured for long-term use // Wallet settings that can be configured for long-term use
use { use serde_derive::{Deserialize, Serialize};
serde_derive::{Deserialize, Serialize}, use std::{collections::HashMap, io, path::Path};
std::{collections::HashMap, io, path::Path}, use url::Url;
url::Url,
};
lazy_static! { lazy_static! {
pub static ref CONFIG_FILE: Option<String> = { pub static ref CONFIG_FILE: Option<String> = {

View File

@@ -3,6 +3,7 @@ extern crate lazy_static;
mod config; mod config;
pub use config::{Config, CONFIG_FILE}; pub use config::{Config, CONFIG_FILE};
use std::{ use std::{
fs::{create_dir_all, File}, fs::{create_dir_all, File},
io::{self, Write}, io::{self, Write},

View File

@@ -2525,16 +2525,14 @@ impl VerboseDisplay for CliGossipNodes {}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use clap::{App, Arg};
clap::{App, Arg}, use solana_sdk::{
solana_sdk::{ message::Message,
message::Message, pubkey::Pubkey,
pubkey::Pubkey, signature::{keypair_from_seed, NullSigner, Signature, Signer, SignerError},
signature::{keypair_from_seed, NullSigner, Signature, Signer, SignerError}, system_instruction,
system_instruction, transaction::Transaction,
transaction::Transaction,
},
}; };
#[test] #[test]

View File

@@ -8,7 +8,8 @@ use {
program_utils::limited_deserialize, pubkey::Pubkey, stake, transaction::Transaction, program_utils::limited_deserialize, pubkey::Pubkey, stake, transaction::Transaction,
}, },
solana_transaction_status::UiTransactionStatusMeta, solana_transaction_status::UiTransactionStatusMeta,
spl_memo::{id as spl_memo_id, v1::id as spl_memo_v1_id}, spl_memo::id as spl_memo_id,
spl_memo::v1::id as spl_memo_v1_id,
std::{collections::HashMap, fmt, io}, std::{collections::HashMap, fmt, io},
}; };
@@ -430,7 +431,8 @@ pub fn unix_timestamp_to_string(unix_timestamp: UnixTimestamp) -> String {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use {super::*, solana_sdk::pubkey::Pubkey}; use super::*;
use solana_sdk::pubkey::Pubkey;
#[test] #[test]
fn test_format_labeled_address() { fn test_format_labeled_address() {

View File

@@ -1,13 +1,11 @@
use { use crate::cli::CliError;
crate::cli::CliError, use solana_client::{
solana_client::{ client_error::{ClientError, Result as ClientResult},
client_error::{ClientError, Result as ClientResult}, rpc_client::RpcClient,
rpc_client::RpcClient, };
}, use solana_sdk::{
solana_sdk::{ commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, message::Message,
commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, message::Message, native_token::lamports_to_sol, pubkey::Pubkey,
native_token::lamports_to_sol, pubkey::Pubkey,
},
}; };
pub fn check_account_for_fee( pub fn check_account_for_fee(
@@ -151,16 +149,14 @@ pub fn check_unique_pubkeys(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use serde_json::json;
serde_json::json, use solana_client::{
solana_client::{ rpc_request::RpcRequest,
rpc_request::RpcRequest, rpc_response::{Response, RpcResponseContext},
rpc_response::{Response, RpcResponseContext},
},
solana_sdk::system_instruction,
std::collections::HashMap,
}; };
use solana_sdk::system_instruction;
use std::collections::HashMap;
#[test] #[test]
fn test_check_account_for_fees() { fn test_check_account_for_fees() {

View File

@@ -1,12 +1,10 @@
use { use crate::{
crate::{ cli::*, cluster_query::*, feature::*, inflation::*, nonce::*, program::*, stake::*,
cli::*, cluster_query::*, feature::*, inflation::*, nonce::*, program::*, stake::*, validator_info::*, vote::*, wallet::*,
validator_info::*, vote::*, wallet::*,
},
clap::{App, AppSettings, Arg, ArgGroup, SubCommand},
solana_clap_utils::{self, input_validators::*, keypair::*},
solana_cli_config::CONFIG_FILE,
}; };
use clap::{App, AppSettings, Arg, ArgGroup, SubCommand};
use solana_clap_utils::{self, input_validators::*, keypair::*};
use solana_cli_config::CONFIG_FILE;
pub fn get_clap_app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, 'v> { pub fn get_clap_app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, 'v> {
App::new(name) App::new(name)

View File

@@ -1,41 +1,37 @@
use { use crate::{
crate::{ clap_app::*, cluster_query::*, feature::*, inflation::*, nonce::*, program::*, spend_utils::*,
clap_app::*, cluster_query::*, feature::*, inflation::*, nonce::*, program::*, stake::*, validator_info::*, vote::*, wallet::*,
spend_utils::*, stake::*, validator_info::*, vote::*, wallet::*,
},
clap::{crate_description, crate_name, value_t_or_exit, ArgMatches, Shell},
log::*,
num_traits::FromPrimitive,
serde_json::{self, Value},
solana_clap_utils::{self, input_parsers::*, input_validators::*, keypair::*},
solana_cli_output::{
display::println_name_value, CliSignature, CliValidatorsSortOrder, OutputFormat,
},
solana_client::{
blockhash_query::BlockhashQuery,
client_error::{ClientError, Result as ClientResult},
nonce_utils,
rpc_client::RpcClient,
rpc_config::{
RpcLargestAccountsFilter, RpcSendTransactionConfig, RpcTransactionLogsFilter,
},
},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{
clock::{Epoch, Slot},
commitment_config::CommitmentConfig,
decode_error::DecodeError,
hash::Hash,
instruction::InstructionError,
pubkey::Pubkey,
signature::{Signature, Signer, SignerError},
stake::{instruction::LockupArgs, state::Lockup},
transaction::{Transaction, TransactionError},
},
solana_vote_program::vote_state::VoteAuthorize,
std::{collections::HashMap, error, io::stdout, str::FromStr, sync::Arc, time::Duration},
thiserror::Error,
}; };
use clap::{crate_description, crate_name, value_t_or_exit, ArgMatches, Shell};
use log::*;
use num_traits::FromPrimitive;
use serde_json::{self, Value};
use solana_clap_utils::{self, input_parsers::*, input_validators::*, keypair::*};
use solana_cli_output::{
display::println_name_value, CliSignature, CliValidatorsSortOrder, OutputFormat,
};
use solana_client::{
blockhash_query::BlockhashQuery,
client_error::{ClientError, Result as ClientResult},
nonce_utils,
rpc_client::RpcClient,
rpc_config::{RpcLargestAccountsFilter, RpcSendTransactionConfig, RpcTransactionLogsFilter},
};
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
clock::{Epoch, Slot},
commitment_config::CommitmentConfig,
decode_error::DecodeError,
hash::Hash,
instruction::InstructionError,
pubkey::Pubkey,
signature::{Signature, Signer, SignerError},
stake::{instruction::LockupArgs, state::Lockup},
transaction::{Transaction, TransactionError},
};
use solana_vote_program::vote_state::VoteAuthorize;
use std::{collections::HashMap, error, io::stdout, str::FromStr, sync::Arc, time::Duration};
use thiserror::Error;
pub const DEFAULT_RPC_TIMEOUT_SECONDS: &str = "30"; pub const DEFAULT_RPC_TIMEOUT_SECONDS: &str = "30";
pub const DEFAULT_CONFIRM_TX_TIMEOUT_SECONDS: &str = "5"; pub const DEFAULT_CONFIRM_TX_TIMEOUT_SECONDS: &str = "5";
@@ -1589,26 +1585,22 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use serde_json::{json, Value};
serde_json::{json, Value}, use solana_client::{
solana_client::{ blockhash_query,
blockhash_query, mock_sender::SIGNATURE,
mock_sender::SIGNATURE, rpc_request::RpcRequest,
rpc_request::RpcRequest, rpc_response::{Response, RpcResponseContext},
rpc_response::{Response, RpcResponseContext},
},
solana_sdk::{
pubkey::Pubkey,
signature::{
keypair_from_seed, read_keypair_file, write_keypair_file, Keypair, Presigner,
},
stake, system_program,
transaction::TransactionError,
},
solana_transaction_status::TransactionConfirmationStatus,
std::path::PathBuf,
}; };
use solana_sdk::{
pubkey::Pubkey,
signature::{keypair_from_seed, read_keypair_file, write_keypair_file, Keypair, Presigner},
stake, system_program,
transaction::TransactionError,
};
use solana_transaction_status::TransactionConfirmationStatus;
use std::path::PathBuf;
fn make_tmp_path(name: &str) -> String { fn make_tmp_path(name: &str) -> String {
let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()); let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string());

View File

@@ -1,78 +1,76 @@
use { use crate::{
crate::{ cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
},
clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand},
console::{style, Emoji},
serde::{Deserialize, Serialize},
solana_clap_utils::{
input_parsers::*,
input_validators::*,
keypair::DefaultSigner,
offline::{blockhash_arg, BLOCKHASH_ARG},
},
solana_cli_output::{
display::{
build_balance_message, format_labeled_address, new_spinner_progress_bar,
println_name_value, println_transaction, unix_timestamp_to_string, writeln_name_value,
},
*,
},
solana_client::{
client_error::ClientErrorKind,
pubsub_client::PubsubClient,
rpc_client::{GetConfirmedSignaturesForAddress2Config, RpcClient},
rpc_config::{
RpcAccountInfoConfig, RpcBlockConfig, RpcGetVoteAccountsConfig,
RpcLargestAccountsConfig, RpcLargestAccountsFilter, RpcProgramAccountsConfig,
RpcTransactionConfig, RpcTransactionLogsConfig, RpcTransactionLogsFilter,
},
rpc_filter,
rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE,
rpc_response::SlotInfo,
},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{
account::from_account,
account_utils::StateMut,
clock::{self, Clock, Slot},
commitment_config::CommitmentConfig,
epoch_schedule::Epoch,
hash::Hash,
message::Message,
native_token::lamports_to_sol,
nonce::State as NonceState,
pubkey::{self, Pubkey},
rent::Rent,
rpc_port::DEFAULT_RPC_PORT_STR,
signature::Signature,
slot_history,
stake::{self, state::StakeState},
system_instruction, system_program,
sysvar::{
self,
slot_history::SlotHistory,
stake_history::{self},
},
timing,
transaction::Transaction,
},
solana_transaction_status::UiTransactionEncoding,
solana_vote_program::vote_state::VoteState,
std::{
collections::{BTreeMap, HashMap, VecDeque},
fmt,
str::FromStr,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread::sleep,
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
},
thiserror::Error,
}; };
use clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand};
use console::{style, Emoji};
use serde::{Deserialize, Serialize};
use solana_clap_utils::{
input_parsers::*,
input_validators::*,
keypair::DefaultSigner,
offline::{blockhash_arg, BLOCKHASH_ARG},
};
use solana_cli_output::{
display::{
build_balance_message, format_labeled_address, new_spinner_progress_bar,
println_name_value, println_transaction, unix_timestamp_to_string, writeln_name_value,
},
*,
};
use solana_client::{
client_error::ClientErrorKind,
pubsub_client::PubsubClient,
rpc_client::{GetConfirmedSignaturesForAddress2Config, RpcClient},
rpc_config::{
RpcAccountInfoConfig, RpcBlockConfig, RpcGetVoteAccountsConfig, RpcLargestAccountsConfig,
RpcLargestAccountsFilter, RpcProgramAccountsConfig, RpcTransactionConfig,
RpcTransactionLogsConfig, RpcTransactionLogsFilter,
},
rpc_filter,
rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE,
rpc_response::SlotInfo,
};
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
account::from_account,
account_utils::StateMut,
clock::{self, Clock, Slot},
commitment_config::CommitmentConfig,
epoch_schedule::Epoch,
hash::Hash,
message::Message,
native_token::lamports_to_sol,
nonce::State as NonceState,
pubkey::{self, Pubkey},
rent::Rent,
rpc_port::DEFAULT_RPC_PORT_STR,
signature::Signature,
slot_history,
stake::{self, state::StakeState},
system_instruction, system_program,
sysvar::{
self,
slot_history::SlotHistory,
stake_history::{self},
},
timing,
transaction::Transaction,
};
use solana_transaction_status::UiTransactionEncoding;
use solana_vote_program::vote_state::VoteState;
use std::{
collections::{BTreeMap, HashMap, VecDeque},
fmt,
str::FromStr,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread::sleep,
time::{Duration, Instant, SystemTime, UNIX_EPOCH},
};
use thiserror::Error;
static CHECK_MARK: Emoji = Emoji("", ""); static CHECK_MARK: Emoji = Emoji("", "");
static CROSS_MARK: Emoji = Emoji("", ""); static CROSS_MARK: Emoji = Emoji("", "");
@@ -2142,13 +2140,11 @@ pub fn process_calculate_rent(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::{clap_app::get_clap_app, cli::parse_command};
crate::{clap_app::get_clap_app, cli::parse_command}, use solana_sdk::signature::{write_keypair, Keypair};
solana_sdk::signature::{write_keypair, Keypair}, use std::str::FromStr;
std::str::FromStr, use tempfile::NamedTempFile;
tempfile::NamedTempFile,
};
fn make_tmp_file() -> (String, NamedTempFile) { fn make_tmp_file() -> (String, NamedTempFile) {
let tmp_file = NamedTempFile::new().unwrap(); let tmp_file = NamedTempFile::new().unwrap();

View File

@@ -1,30 +1,28 @@
use { use crate::{
crate::{ cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, };
}, use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
clap::{App, AppSettings, Arg, ArgMatches, SubCommand}, use console::style;
console::style, use serde::{Deserialize, Serialize};
serde::{Deserialize, Serialize}, use solana_clap_utils::{input_parsers::*, input_validators::*, keypair::*};
solana_clap_utils::{input_parsers::*, input_validators::*, keypair::*}, use solana_cli_output::{QuietDisplay, VerboseDisplay};
solana_cli_output::{QuietDisplay, VerboseDisplay}, use solana_client::{client_error::ClientError, rpc_client::RpcClient};
solana_client::{client_error::ClientError, rpc_client::RpcClient}, use solana_remote_wallet::remote_wallet::RemoteWalletManager;
solana_remote_wallet::remote_wallet::RemoteWalletManager, use solana_sdk::{
solana_sdk::{ account::Account,
account::Account, clock::Slot,
clock::Slot, feature::{self, Feature},
feature::{self, Feature}, feature_set::FEATURE_NAMES,
feature_set::FEATURE_NAMES, message::Message,
message::Message, pubkey::Pubkey,
pubkey::Pubkey, transaction::Transaction,
transaction::Transaction, };
}, use std::{
std::{ cmp::Ordering,
cmp::Ordering, collections::{HashMap, HashSet},
collections::{HashMap, HashSet}, fmt,
fmt, sync::Arc,
sync::Arc,
},
}; };
#[derive(Copy, Clone, Debug, PartialEq)] #[derive(Copy, Clone, Debug, PartialEq)]

View File

@@ -1,19 +1,17 @@
use { use crate::cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult};
crate::cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, use clap::{App, Arg, ArgMatches, SubCommand};
clap::{App, Arg, ArgMatches, SubCommand}, use solana_clap_utils::{
solana_clap_utils::{ input_parsers::{pubkeys_of, value_of},
input_parsers::{pubkeys_of, value_of}, input_validators::is_valid_pubkey,
input_validators::is_valid_pubkey, keypair::*,
keypair::*,
},
solana_cli_output::{
CliEpochRewardshMetadata, CliInflation, CliKeyedEpochReward, CliKeyedEpochRewards,
},
solana_client::rpc_client::RpcClient,
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{clock::Epoch, pubkey::Pubkey},
std::sync::Arc,
}; };
use solana_cli_output::{
CliEpochRewardshMetadata, CliInflation, CliKeyedEpochReward, CliKeyedEpochRewards,
};
use solana_client::rpc_client::RpcClient;
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{clock::Epoch, pubkey::Pubkey};
use std::sync::Arc;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum InflationCliCommand { pub enum InflationCliCommand {

View File

@@ -1,21 +1,19 @@
use { use clap::{crate_description, crate_name, value_t_or_exit, ArgMatches};
clap::{crate_description, crate_name, value_t_or_exit, ArgMatches}, use console::style;
console::style, use solana_clap_utils::{
solana_clap_utils::{ input_validators::normalize_to_url_if_moniker,
input_validators::normalize_to_url_if_moniker, keypair::{CliSigners, DefaultSigner},
keypair::{CliSigners, DefaultSigner}, DisplayError,
DisplayError,
},
solana_cli::{
clap_app::get_clap_app,
cli::{parse_command, process_command, CliCommandInfo, CliConfig, SettingType},
},
solana_cli_config::Config,
solana_cli_output::{display::println_name_value, OutputFormat},
solana_client::rpc_config::RpcSendTransactionConfig,
solana_remote_wallet::remote_wallet::RemoteWalletManager,
std::{collections::HashMap, error, path::PathBuf, sync::Arc, time::Duration},
}; };
use solana_cli::{
clap_app::get_clap_app,
cli::{parse_command, process_command, CliCommandInfo, CliConfig, SettingType},
};
use solana_cli_config::Config;
use solana_cli_output::{display::println_name_value, OutputFormat};
use solana_client::rpc_config::RpcSendTransactionConfig;
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use std::{collections::HashMap, error, path::PathBuf, sync::Arc, time::Duration};
pub fn println_name_value_or(name: &str, value: &str, setting_type: SettingType) { pub fn println_name_value_or(name: &str, value: &str, setting_type: SettingType) {
let description = match setting_type { let description = match setting_type {

View File

@@ -1,7 +1,6 @@
use { use solana_sdk::instruction::Instruction;
solana_sdk::{instruction::Instruction, pubkey::Pubkey}, use solana_sdk::pubkey::Pubkey;
spl_memo::id, use spl_memo::id;
};
pub trait WithMemo { pub trait WithMemo {
fn with_memo<T: AsRef<str>>(self, memo: Option<T>) -> Self; fn with_memo<T: AsRef<str>>(self, memo: Option<T>) -> Self;

View File

@@ -1,43 +1,41 @@
use { use crate::{
crate::{ checks::{check_account_for_fee_with_commitment, check_unique_pubkeys},
checks::{check_account_for_fee_with_commitment, check_unique_pubkeys}, cli::{
cli::{ log_instruction_custom_error, log_instruction_custom_error_ex, CliCommand, CliCommandInfo,
log_instruction_custom_error, log_instruction_custom_error_ex, CliCommand, CliConfig, CliError, ProcessResult,
CliCommandInfo, CliConfig, CliError, ProcessResult,
},
feature::get_feature_is_active,
memo::WithMemo,
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
}, },
clap::{App, Arg, ArgMatches, SubCommand}, feature::get_feature_is_active,
solana_clap_utils::{ memo::WithMemo,
input_parsers::*, spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
input_validators::*,
keypair::{DefaultSigner, SignerIndex},
memo::{memo_arg, MEMO_ARG},
nonce::*,
},
solana_cli_output::CliNonceAccount,
solana_client::{nonce_utils::*, rpc_client::RpcClient},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{
account::Account,
feature_set::merge_nonce_error_into_system_error,
hash::Hash,
instruction::InstructionError,
message::Message,
nonce::{self, State},
pubkey::Pubkey,
system_instruction::{
advance_nonce_account, authorize_nonce_account, create_nonce_account,
create_nonce_account_with_seed, instruction_to_nonce_error, withdraw_nonce_account,
NonceError, SystemError,
},
system_program,
transaction::{Transaction, TransactionError},
},
std::sync::Arc,
}; };
use clap::{App, Arg, ArgMatches, SubCommand};
use solana_clap_utils::{
input_parsers::*,
input_validators::*,
keypair::{DefaultSigner, SignerIndex},
memo::{memo_arg, MEMO_ARG},
nonce::*,
};
use solana_cli_output::CliNonceAccount;
use solana_client::{nonce_utils::*, rpc_client::RpcClient};
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
account::Account,
feature_set::merge_nonce_error_into_system_error,
hash::Hash,
instruction::InstructionError,
message::Message,
nonce::{self, State},
pubkey::Pubkey,
system_instruction::{
advance_nonce_account, authorize_nonce_account, create_nonce_account,
create_nonce_account_with_seed, instruction_to_nonce_error, withdraw_nonce_account,
NonceError, SystemError,
},
system_program,
transaction::{Transaction, TransactionError},
};
use std::sync::Arc;
pub trait NonceSubCommands { pub trait NonceSubCommands {
fn nonce_subcommands(self) -> Self; fn nonce_subcommands(self) -> Self;
@@ -652,21 +650,19 @@ pub fn process_withdraw_from_nonce_account(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::{clap_app::get_clap_app, cli::parse_command};
crate::{clap_app::get_clap_app, cli::parse_command}, use solana_sdk::{
solana_sdk::{ account::Account,
account::Account, account_utils::StateMut,
account_utils::StateMut, fee_calculator::FeeCalculator,
fee_calculator::FeeCalculator, hash::hash,
hash::hash, nonce::{self, state::Versions, State},
nonce::{self, state::Versions, State}, nonce_account,
nonce_account, signature::{read_keypair_file, write_keypair, Keypair, Signer},
signature::{read_keypair_file, write_keypair, Keypair, Signer}, system_program,
system_program,
},
tempfile::NamedTempFile,
}; };
use tempfile::NamedTempFile;
fn make_tmp_file() -> (String, NamedTempFile) { fn make_tmp_file() -> (String, NamedTempFile) {
let tmp_file = NamedTempFile::new().unwrap(); let tmp_file = NamedTempFile::new().unwrap();

View File

@@ -1,56 +1,57 @@
use { use crate::{
crate::{ checks::*,
checks::*, cli::{
cli::{ log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult,
ProcessResult,
},
},
bip39::{Language, Mnemonic, MnemonicType, Seed},
clap::{App, AppSettings, Arg, ArgMatches, SubCommand},
log::*,
solana_account_decoder::{UiAccountEncoding, UiDataSliceConfig},
solana_bpf_loader_program::{bpf_verifier, BpfError, ThisInstructionMeter},
solana_clap_utils::{self, input_parsers::*, input_validators::*, keypair::*},
solana_cli_output::{
CliProgram, CliProgramAccountType, CliProgramAuthority, CliProgramBuffer, CliProgramId,
CliUpgradeableBuffer, CliUpgradeableBuffers, CliUpgradeableProgram,
CliUpgradeableProgramClosed, CliUpgradeablePrograms,
},
solana_client::{
client_error::ClientErrorKind,
rpc_client::RpcClient,
rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, RpcSendTransactionConfig},
rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType},
tpu_client::{TpuClient, TpuClientConfig},
},
solana_rbpf::vm::{Config, Executable},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{
account::Account,
account_utils::StateMut,
bpf_loader, bpf_loader_deprecated,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
instruction::{Instruction, InstructionError},
loader_instruction,
message::Message,
native_token::Sol,
packet::PACKET_DATA_SIZE,
pubkey::Pubkey,
signature::{keypair_from_seed, read_keypair_file, Keypair, Signature, Signer},
system_instruction::{self, SystemError},
system_program,
transaction::{Transaction, TransactionError},
},
std::{
fs::File,
io::{Read, Write},
mem::size_of,
path::PathBuf,
str::FromStr,
sync::Arc,
}, },
}; };
use bip39::{Language, Mnemonic, MnemonicType, Seed};
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use log::*;
use solana_account_decoder::{UiAccountEncoding, UiDataSliceConfig};
use solana_bpf_loader_program::{bpf_verifier, BpfError, ThisInstructionMeter};
use solana_clap_utils::{self, input_parsers::*, input_validators::*, keypair::*};
use solana_cli_output::{
CliProgram, CliProgramAccountType, CliProgramAuthority, CliProgramBuffer, CliProgramId,
CliUpgradeableBuffer, CliUpgradeableBuffers, CliUpgradeableProgram,
CliUpgradeableProgramClosed, CliUpgradeablePrograms,
};
use solana_client::{
client_error::ClientErrorKind,
rpc_client::RpcClient,
rpc_config::RpcSendTransactionConfig,
rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig},
rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType},
tpu_client::{TpuClient, TpuClientConfig},
};
use solana_rbpf::vm::{Config, Executable};
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
account::Account,
account_utils::StateMut,
bpf_loader, bpf_loader_deprecated,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
instruction::Instruction,
instruction::InstructionError,
loader_instruction,
message::Message,
native_token::Sol,
packet::PACKET_DATA_SIZE,
pubkey::Pubkey,
signature::{keypair_from_seed, read_keypair_file, Keypair, Signature, Signer},
system_instruction::{self, SystemError},
system_program,
transaction::Transaction,
transaction::TransactionError,
};
use std::{
fs::File,
io::{Read, Write},
mem::size_of,
path::PathBuf,
str::FromStr,
sync::Arc,
};
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub enum ProgramCliCommand { pub enum ProgramCliCommand {
@@ -2191,16 +2192,14 @@ fn report_ephemeral_mnemonic(words: usize, mnemonic: bip39::Mnemonic) {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::{
crate::{ clap_app::get_clap_app,
clap_app::get_clap_app, cli::{parse_command, process_command},
cli::{parse_command, process_command},
},
serde_json::Value,
solana_cli_output::OutputFormat,
solana_sdk::signature::write_keypair_file,
}; };
use serde_json::Value;
use solana_cli_output::OutputFormat;
use solana_sdk::signature::write_keypair_file;
fn make_tmp_path(name: &str) -> String { fn make_tmp_path(name: &str) -> String {
let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string()); let out_dir = std::env::var("FARF_DIR").unwrap_or_else(|_| "farf".to_string());

View File

@@ -1,15 +1,13 @@
use { use crate::{
crate::{ checks::{calculate_fee, check_account_for_balance_with_commitment},
checks::{calculate_fee, check_account_for_balance_with_commitment}, cli::CliError,
cli::CliError, };
}, use clap::ArgMatches;
clap::ArgMatches, use solana_clap_utils::{input_parsers::lamports_of_sol, offline::SIGN_ONLY_ARG};
solana_clap_utils::{input_parsers::lamports_of_sol, offline::SIGN_ONLY_ARG}, use solana_client::rpc_client::RpcClient;
solana_client::rpc_client::RpcClient, use solana_sdk::{
solana_sdk::{ commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, message::Message,
commitment_config::CommitmentConfig, fee_calculator::FeeCalculator, message::Message, native_token::lamports_to_sol, pubkey::Pubkey,
native_token::lamports_to_sol, pubkey::Pubkey,
},
}; };
#[derive(Debug, PartialEq, Clone, Copy)] #[derive(Debug, PartialEq, Clone, Copy)]

View File

@@ -1,55 +1,53 @@
use { use crate::{
crate::{ checks::{check_account_for_fee_with_commitment, check_unique_pubkeys},
checks::{check_account_for_fee_with_commitment, check_unique_pubkeys}, cli::{
cli::{ log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult,
ProcessResult,
},
memo::WithMemo,
nonce::check_nonce_account,
spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
}, },
clap::{value_t, App, Arg, ArgGroup, ArgMatches, SubCommand}, memo::WithMemo,
solana_clap_utils::{ nonce::check_nonce_account,
fee_payer::{fee_payer_arg, FEE_PAYER_ARG}, spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
input_parsers::*,
input_validators::*,
keypair::{DefaultSigner, SignerIndex},
memo::{memo_arg, MEMO_ARG},
nonce::*,
offline::*,
ArgConstant,
},
solana_cli_output::{
return_signers_with_config, CliEpochReward, CliStakeHistory, CliStakeHistoryEntry,
CliStakeState, CliStakeType, OutputFormat, ReturnSignersConfig,
},
solana_client::{
blockhash_query::BlockhashQuery, nonce_utils, rpc_client::RpcClient,
rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE, rpc_response::RpcInflationReward,
},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{
account::from_account,
account_utils::StateMut,
clock::{Clock, UnixTimestamp, SECONDS_PER_DAY},
commitment_config::CommitmentConfig,
epoch_schedule::EpochSchedule,
message::Message,
pubkey::Pubkey,
stake::{
self,
instruction::{self as stake_instruction, LockupArgs, StakeError},
state::{Authorized, Lockup, Meta, StakeActivationStatus, StakeAuthorize, StakeState},
},
stake_history::StakeHistory,
system_instruction::SystemError,
sysvar::{clock, stake_history},
transaction::Transaction,
},
solana_vote_program::vote_state::VoteState,
std::{ops::Deref, sync::Arc},
}; };
use clap::{value_t, App, Arg, ArgGroup, ArgMatches, SubCommand};
use solana_clap_utils::{
fee_payer::{fee_payer_arg, FEE_PAYER_ARG},
input_parsers::*,
input_validators::*,
keypair::{DefaultSigner, SignerIndex},
memo::{memo_arg, MEMO_ARG},
nonce::*,
offline::*,
ArgConstant,
};
use solana_cli_output::{
return_signers_with_config, CliEpochReward, CliStakeHistory, CliStakeHistoryEntry,
CliStakeState, CliStakeType, OutputFormat, ReturnSignersConfig,
};
use solana_client::{
blockhash_query::BlockhashQuery, nonce_utils, rpc_client::RpcClient,
rpc_request::DELINQUENT_VALIDATOR_SLOT_DISTANCE, rpc_response::RpcInflationReward,
};
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
account::from_account,
account_utils::StateMut,
clock::{Clock, UnixTimestamp, SECONDS_PER_DAY},
commitment_config::CommitmentConfig,
epoch_schedule::EpochSchedule,
message::Message,
pubkey::Pubkey,
stake::{
self,
instruction::{self as stake_instruction, LockupArgs, StakeError},
state::{Authorized, Lockup, Meta, StakeActivationStatus, StakeAuthorize, StakeState},
},
stake_history::StakeHistory,
system_instruction::SystemError,
sysvar::{clock, stake_history},
transaction::Transaction,
};
use solana_vote_program::vote_state::VoteState;
use std::{ops::Deref, sync::Arc};
pub const STAKE_AUTHORITY_ARG: ArgConstant<'static> = ArgConstant { pub const STAKE_AUTHORITY_ARG: ArgConstant<'static> = ArgConstant {
name: "stake_authority", name: "stake_authority",
@@ -2440,18 +2438,16 @@ pub fn process_delegate_stake(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::{clap_app::get_clap_app, cli::parse_command};
crate::{clap_app::get_clap_app, cli::parse_command}, use solana_client::blockhash_query;
solana_client::blockhash_query, use solana_sdk::{
solana_sdk::{ hash::Hash,
hash::Hash, signature::{
signature::{ keypair_from_seed, read_keypair_file, write_keypair, Keypair, Presigner, Signer,
keypair_from_seed, read_keypair_file, write_keypair, Keypair, Presigner, Signer,
},
}, },
tempfile::NamedTempFile,
}; };
use tempfile::NamedTempFile;
fn make_tmp_file() -> (String, NamedTempFile) { fn make_tmp_file() -> (String, NamedTempFile) {
let tmp_file = NamedTempFile::new().unwrap(); let tmp_file = NamedTempFile::new().unwrap();

View File

@@ -1,8 +1,6 @@
use { use solana_client::rpc_client::RpcClient;
solana_client::rpc_client::RpcClient, use solana_sdk::{clock::DEFAULT_MS_PER_SLOT, commitment_config::CommitmentConfig, pubkey::Pubkey};
solana_sdk::{clock::DEFAULT_MS_PER_SLOT, commitment_config::CommitmentConfig, pubkey::Pubkey}, use std::{thread::sleep, time::Duration};
std::{thread::sleep, time::Duration},
};
pub fn check_recent_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) { pub fn check_recent_balance(expected_balance: u64, client: &RpcClient, pubkey: &Pubkey) {
(0..5).for_each(|tries| { (0..5).for_each(|tries| {

View File

@@ -1,33 +1,31 @@
use { use crate::{
crate::{ cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
},
bincode::deserialize,
clap::{App, AppSettings, Arg, ArgMatches, SubCommand},
reqwest::blocking::Client,
serde_json::{Map, Value},
solana_account_decoder::validator_info::{
self, ValidatorInfo, MAX_LONG_FIELD_LENGTH, MAX_SHORT_FIELD_LENGTH,
},
solana_clap_utils::{
input_parsers::pubkey_of,
input_validators::{is_pubkey, is_url},
keypair::DefaultSigner,
},
solana_cli_output::{CliValidatorInfo, CliValidatorInfoVec},
solana_client::rpc_client::RpcClient,
solana_config_program::{config_instruction, get_config_data, ConfigKeys, ConfigState},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{
account::Account,
message::Message,
pubkey::Pubkey,
signature::{Keypair, Signer},
transaction::Transaction,
},
std::{error, sync::Arc},
}; };
use bincode::deserialize;
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use reqwest::blocking::Client;
use serde_json::{Map, Value};
use solana_account_decoder::validator_info::{
self, ValidatorInfo, MAX_LONG_FIELD_LENGTH, MAX_SHORT_FIELD_LENGTH,
};
use solana_clap_utils::{
input_parsers::pubkey_of,
input_validators::{is_pubkey, is_url},
keypair::DefaultSigner,
};
use solana_cli_output::{CliValidatorInfo, CliValidatorInfoVec};
use solana_client::rpc_client::RpcClient;
use solana_config_program::{config_instruction, get_config_data, ConfigKeys, ConfigState};
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
account::Account,
message::Message,
pubkey::Pubkey,
signature::{Keypair, Signer},
transaction::Transaction,
};
use std::{error, sync::Arc};
// Return an error if a validator details are longer than the max length. // Return an error if a validator details are longer than the max length.
pub fn check_details_length(string: String) -> Result<(), String> { pub fn check_details_length(string: String) -> Result<(), String> {
@@ -409,12 +407,10 @@ pub fn process_get_validator_info(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::clap_app::get_clap_app;
crate::clap_app::get_clap_app, use bincode::{serialize, serialized_size};
bincode::{serialize, serialized_size}, use serde_json::json;
serde_json::json,
};
#[test] #[test]
fn test_check_url() { fn test_check_url() {

View File

@@ -1,35 +1,33 @@
use { use crate::{
crate::{ checks::{check_account_for_fee_with_commitment, check_unique_pubkeys},
checks::{check_account_for_fee_with_commitment, check_unique_pubkeys}, cli::{
cli::{ log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError,
log_instruction_custom_error, CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult,
ProcessResult,
},
memo::WithMemo,
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
stake::check_current_authority,
}, },
clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand}, memo::WithMemo,
solana_clap_utils::{ spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
input_parsers::*, stake::check_current_authority,
input_validators::*,
keypair::{DefaultSigner, SignerIndex},
memo::{memo_arg, MEMO_ARG},
},
solana_cli_output::{CliEpochVotingHistory, CliLockout, CliVoteAccount},
solana_client::rpc_client::RpcClient,
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{
account::Account, commitment_config::CommitmentConfig, message::Message,
native_token::lamports_to_sol, pubkey::Pubkey, system_instruction::SystemError,
transaction::Transaction,
},
solana_vote_program::{
vote_instruction::{self, withdraw, VoteError},
vote_state::{VoteAuthorize, VoteInit, VoteState},
},
std::sync::Arc,
}; };
use clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand};
use solana_clap_utils::{
input_parsers::*,
input_validators::*,
keypair::{DefaultSigner, SignerIndex},
memo::{memo_arg, MEMO_ARG},
};
use solana_cli_output::{CliEpochVotingHistory, CliLockout, CliVoteAccount};
use solana_client::rpc_client::RpcClient;
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
account::Account, commitment_config::CommitmentConfig, message::Message,
native_token::lamports_to_sol, pubkey::Pubkey, system_instruction::SystemError,
transaction::Transaction,
};
use solana_vote_program::{
vote_instruction::{self, withdraw, VoteError},
vote_state::{VoteAuthorize, VoteInit, VoteState},
};
use std::sync::Arc;
pub trait VoteSubCommands { pub trait VoteSubCommands {
fn vote_subcommands(self) -> Self; fn vote_subcommands(self) -> Self;
@@ -939,12 +937,10 @@ pub fn process_withdraw_from_vote_account(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::{clap_app::get_clap_app, cli::parse_command};
crate::{clap_app::get_clap_app, cli::parse_command}, use solana_sdk::signature::{read_keypair_file, write_keypair, Keypair, Signer};
solana_sdk::signature::{read_keypair_file, write_keypair, Keypair, Signer}, use tempfile::NamedTempFile;
tempfile::NamedTempFile,
};
fn make_tmp_file() -> (String, NamedTempFile) { fn make_tmp_file() -> (String, NamedTempFile) {
let tmp_file = NamedTempFile::new().unwrap(); let tmp_file = NamedTempFile::new().unwrap();

View File

@@ -1,47 +1,45 @@
use { use crate::{
crate::{ cli::{
cli::{ log_instruction_custom_error, request_and_confirm_airdrop, CliCommand, CliCommandInfo,
log_instruction_custom_error, request_and_confirm_airdrop, CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult,
CliConfig, CliError, ProcessResult,
},
memo::WithMemo,
nonce::check_nonce_account,
spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
}, },
clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand}, memo::WithMemo,
solana_account_decoder::{UiAccount, UiAccountEncoding}, nonce::check_nonce_account,
solana_clap_utils::{ spend_utils::{resolve_spend_tx_and_check_account_balances, SpendAmount},
fee_payer::*,
input_parsers::*,
input_validators::*,
keypair::{DefaultSigner, SignerIndex},
memo::*,
nonce::*,
offline::*,
},
solana_cli_output::{
display::build_balance_message, return_signers_with_config, CliAccount,
CliSignatureVerificationStatus, CliTransaction, CliTransactionConfirmation, OutputFormat,
ReturnSignersConfig,
},
solana_client::{
blockhash_query::BlockhashQuery, nonce_utils, rpc_client::RpcClient,
rpc_config::RpcTransactionConfig, rpc_response::RpcKeyedAccount,
},
solana_remote_wallet::remote_wallet::RemoteWalletManager,
solana_sdk::{
commitment_config::CommitmentConfig,
message::Message,
pubkey::Pubkey,
signature::Signature,
stake,
system_instruction::{self, SystemError},
system_program,
transaction::Transaction,
},
solana_transaction_status::{EncodedTransaction, UiTransactionEncoding},
std::{fmt::Write as FmtWrite, fs::File, io::Write, sync::Arc},
}; };
use clap::{value_t_or_exit, App, Arg, ArgMatches, SubCommand};
use solana_account_decoder::{UiAccount, UiAccountEncoding};
use solana_clap_utils::{
fee_payer::*,
input_parsers::*,
input_validators::*,
keypair::{DefaultSigner, SignerIndex},
memo::*,
nonce::*,
offline::*,
};
use solana_cli_output::{
display::build_balance_message, return_signers_with_config, CliAccount,
CliSignatureVerificationStatus, CliTransaction, CliTransactionConfirmation, OutputFormat,
ReturnSignersConfig,
};
use solana_client::{
blockhash_query::BlockhashQuery, nonce_utils, rpc_client::RpcClient,
rpc_config::RpcTransactionConfig, rpc_response::RpcKeyedAccount,
};
use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{
commitment_config::CommitmentConfig,
message::Message,
pubkey::Pubkey,
signature::Signature,
stake,
system_instruction::{self, SystemError},
system_program,
transaction::Transaction,
};
use solana_transaction_status::{EncodedTransaction, UiTransactionEncoding};
use std::{fmt::Write as FmtWrite, fs::File, io::Write, sync::Arc};
pub trait WalletSubCommands { pub trait WalletSubCommands {
fn wallet_subcommands(self) -> Self; fn wallet_subcommands(self) -> Self;

View File

@@ -1,26 +1,24 @@
use { use solana_cli::{
solana_cli::{ cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, spend_utils::SpendAmount,
spend_utils::SpendAmount, test_utils::{check_ready, check_recent_balance},
test_utils::{check_ready, check_recent_balance},
},
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
solana_client::{
blockhash_query::{self, BlockhashQuery},
nonce_utils,
rpc_client::RpcClient,
},
solana_core::test_validator::TestValidator,
solana_faucet::faucet::run_local_faucet,
solana_sdk::{
commitment_config::CommitmentConfig,
hash::Hash,
pubkey::Pubkey,
signature::{keypair_from_seed, Keypair, Signer},
system_program,
},
solana_streamer::socket::SocketAddrSpace,
}; };
use solana_cli_output::{parse_sign_only_reply_string, OutputFormat};
use solana_client::{
blockhash_query::{self, BlockhashQuery},
nonce_utils,
rpc_client::RpcClient,
};
use solana_core::test_validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
commitment_config::CommitmentConfig,
hash::Hash,
pubkey::Pubkey,
signature::{keypair_from_seed, Keypair, Signer},
system_program,
};
use solana_streamer::socket::SocketAddrSpace;
#[test] #[test]
fn test_nonce() { fn test_nonce() {

View File

@@ -1,24 +1,22 @@
use { use serde_json::Value;
serde_json::Value, use solana_cli::{
solana_cli::{ cli::{process_command, CliCommand, CliConfig},
cli::{process_command, CliCommand, CliConfig}, program::ProgramCliCommand,
program::ProgramCliCommand,
},
solana_cli_output::OutputFormat,
solana_client::rpc_client::RpcClient,
solana_core::test_validator::TestValidator,
solana_faucet::faucet::run_local_faucet,
solana_sdk::{
account_utils::StateMut,
bpf_loader,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
commitment_config::CommitmentConfig,
pubkey::Pubkey,
signature::{Keypair, Signer},
},
solana_streamer::socket::SocketAddrSpace,
std::{env, fs::File, io::Read, path::PathBuf, str::FromStr},
}; };
use solana_cli_output::OutputFormat;
use solana_client::rpc_client::RpcClient;
use solana_core::test_validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
account_utils::StateMut,
bpf_loader,
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
commitment_config::CommitmentConfig,
pubkey::Pubkey,
signature::{Keypair, Signer},
};
use solana_streamer::socket::SocketAddrSpace;
use std::{env, fs::File, io::Read, path::PathBuf, str::FromStr};
#[test] #[test]
fn test_cli_program_deploy_non_upgradeable() { fn test_cli_program_deploy_non_upgradeable() {

View File

@@ -1,14 +1,12 @@
use { use solana_cli::cli::{process_command, CliCommand, CliConfig};
solana_cli::cli::{process_command, CliCommand, CliConfig}, use solana_client::rpc_client::RpcClient;
solana_client::rpc_client::RpcClient, use solana_core::test_validator::TestValidator;
solana_core::test_validator::TestValidator, use solana_faucet::faucet::run_local_faucet;
solana_faucet::faucet::run_local_faucet, use solana_sdk::{
solana_sdk::{ commitment_config::CommitmentConfig,
commitment_config::CommitmentConfig, signature::{Keypair, Signer},
signature::{Keypair, Signer},
},
solana_streamer::socket::SocketAddrSpace,
}; };
use solana_streamer::socket::SocketAddrSpace;
#[test] #[test]
fn test_cli_request_airdrop() { fn test_cli_request_airdrop() {

View File

@@ -1,32 +1,30 @@
use { use solana_cli::{
solana_cli::{ cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, spend_utils::SpendAmount,
spend_utils::SpendAmount, stake::StakeAuthorizationIndexed,
stake::StakeAuthorizationIndexed, test_utils::{check_ready, check_recent_balance},
test_utils::{check_ready, check_recent_balance},
},
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
solana_client::{
blockhash_query::{self, BlockhashQuery},
nonce_utils,
rpc_client::RpcClient,
},
solana_core::test_validator::TestValidator,
solana_faucet::faucet::run_local_faucet,
solana_sdk::{
account_utils::StateMut,
commitment_config::CommitmentConfig,
nonce::State as NonceState,
pubkey::Pubkey,
signature::{keypair_from_seed, Keypair, Signer},
stake::{
self,
instruction::LockupArgs,
state::{Lockup, StakeAuthorize, StakeState},
},
},
solana_streamer::socket::SocketAddrSpace,
}; };
use solana_cli_output::{parse_sign_only_reply_string, OutputFormat};
use solana_client::{
blockhash_query::{self, BlockhashQuery},
nonce_utils,
rpc_client::RpcClient,
};
use solana_core::test_validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
account_utils::StateMut,
commitment_config::CommitmentConfig,
nonce::State as NonceState,
pubkey::Pubkey,
signature::{keypair_from_seed, Keypair, Signer},
stake::{
self,
instruction::LockupArgs,
state::{Lockup, StakeAuthorize, StakeState},
},
};
use solana_streamer::socket::SocketAddrSpace;
#[test] #[test]
fn test_stake_delegation_force() { fn test_stake_delegation_force() {

View File

@@ -1,26 +1,24 @@
use { use solana_cli::{
solana_cli::{ cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, spend_utils::SpendAmount,
spend_utils::SpendAmount, test_utils::{check_ready, check_recent_balance},
test_utils::{check_ready, check_recent_balance},
},
solana_cli_output::{parse_sign_only_reply_string, OutputFormat},
solana_client::{
blockhash_query::{self, BlockhashQuery},
nonce_utils,
rpc_client::RpcClient,
},
solana_core::test_validator::TestValidator,
solana_faucet::faucet::run_local_faucet,
solana_sdk::{
commitment_config::CommitmentConfig,
nonce::State as NonceState,
pubkey::Pubkey,
signature::{keypair_from_seed, Keypair, NullSigner, Signer},
stake,
},
solana_streamer::socket::SocketAddrSpace,
}; };
use solana_cli_output::{parse_sign_only_reply_string, OutputFormat};
use solana_client::{
blockhash_query::{self, BlockhashQuery},
nonce_utils,
rpc_client::RpcClient,
};
use solana_core::test_validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
commitment_config::CommitmentConfig,
nonce::State as NonceState,
pubkey::Pubkey,
signature::{keypair_from_seed, Keypair, NullSigner, Signer},
stake,
};
use solana_streamer::socket::SocketAddrSpace;
#[test] #[test]
fn test_transfer() { fn test_transfer() {

View File

@@ -1,23 +1,21 @@
use { use solana_cli::{
solana_cli::{ cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig},
cli::{process_command, request_and_confirm_airdrop, CliCommand, CliConfig}, spend_utils::SpendAmount,
spend_utils::SpendAmount, test_utils::check_recent_balance,
test_utils::check_recent_balance,
},
solana_client::{
blockhash_query::{self, BlockhashQuery},
rpc_client::RpcClient,
},
solana_core::test_validator::TestValidator,
solana_faucet::faucet::run_local_faucet,
solana_sdk::{
account_utils::StateMut,
commitment_config::CommitmentConfig,
signature::{Keypair, Signer},
},
solana_streamer::socket::SocketAddrSpace,
solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions},
}; };
use solana_client::{
blockhash_query::{self, BlockhashQuery},
rpc_client::RpcClient,
};
use solana_core::test_validator::TestValidator;
use solana_faucet::faucet::run_local_faucet;
use solana_sdk::{
account_utils::StateMut,
commitment_config::CommitmentConfig,
signature::{Keypair, Signer},
};
use solana_streamer::socket::SocketAddrSpace;
use solana_vote_program::vote_state::{VoteAuthorize, VoteState, VoteStateVersions};
#[test] #[test]
fn test_vote_authorize_and_withdraw() { fn test_vote_authorize_and_withdraw() {

View File

@@ -118,19 +118,17 @@ impl Default for BlockhashQuery {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::{
crate::{ blockhash_query,
blockhash_query, rpc_request::RpcRequest,
rpc_request::RpcRequest, rpc_response::{Response, RpcFeeCalculator, RpcFees, RpcResponseContext},
rpc_response::{Response, RpcFeeCalculator, RpcFees, RpcResponseContext},
},
clap::App,
serde_json::{self, json},
solana_account_decoder::{UiAccount, UiAccountEncoding},
solana_sdk::{account::Account, hash::hash, nonce, system_program},
std::collections::HashMap,
}; };
use clap::App;
use serde_json::{self, json};
use solana_account_decoder::{UiAccount, UiAccountEncoding};
use solana_sdk::{account::Account, hash::hash, nonce, system_program};
use std::collections::HashMap;
#[test] #[test]
fn test_blockhash_query_new_ok() { fn test_blockhash_query_new_ok() {

View File

@@ -1,4 +1,3 @@
pub use reqwest;
use { use {
crate::{rpc_request, rpc_response}, crate::{rpc_request, rpc_response},
solana_faucet::faucet::FaucetError, solana_faucet::faucet::FaucetError,
@@ -7,7 +6,9 @@ use {
}, },
std::io, std::io,
thiserror::Error, thiserror::Error,
}; // export `reqwest` for clients };
pub use reqwest; // export `reqwest` for clients
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum ClientErrorKind { pub enum ClientErrorKind {

View File

@@ -16,7 +16,8 @@ use {
client_error::{ClientError, ClientErrorKind, Result as ClientResult}, client_error::{ClientError, ClientErrorKind, Result as ClientResult},
http_sender::HttpSender, http_sender::HttpSender,
mock_sender::{MockSender, Mocks}, mock_sender::{MockSender, Mocks},
rpc_config::{RpcAccountInfoConfig, *}, rpc_config::RpcAccountInfoConfig,
rpc_config::*,
rpc_request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter}, rpc_request::{RpcError, RpcRequest, RpcResponseErrorData, TokenAccountsFilter},
rpc_response::*, rpc_response::*,
rpc_sender::*, rpc_sender::*,
@@ -4783,21 +4784,19 @@ pub fn create_rpc_client_mocks() -> crate::mock_sender::Mocks {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::{client_error::ClientErrorKind, mock_sender::PUBKEY};
crate::{client_error::ClientErrorKind, mock_sender::PUBKEY}, use assert_matches::assert_matches;
assert_matches::assert_matches, use jsonrpc_core::{futures::prelude::*, Error, IoHandler, Params};
jsonrpc_core::{futures::prelude::*, Error, IoHandler, Params}, use jsonrpc_http_server::{AccessControlAllowOrigin, DomainsValidation, ServerBuilder};
jsonrpc_http_server::{AccessControlAllowOrigin, DomainsValidation, ServerBuilder}, use serde_json::Number;
serde_json::Number, use solana_sdk::{
solana_sdk::{ instruction::InstructionError,
instruction::InstructionError, signature::{Keypair, Signer},
signature::{Keypair, Signer}, system_transaction,
system_transaction, transaction::TransactionError,
transaction::TransactionError,
},
std::{io, sync::mpsc::channel, thread},
}; };
use std::{io, sync::mpsc::channel, thread};
#[test] #[test]
fn test_send() { fn test_send() {

View File

@@ -1,9 +1,9 @@
//! Implementation defined RPC server errors //! Implementation defined RPC server errors
use thiserror::Error;
use { use {
crate::rpc_response::RpcSimulateTransactionResult, crate::rpc_response::RpcSimulateTransactionResult,
jsonrpc_core::{Error, ErrorCode}, jsonrpc_core::{Error, ErrorCode},
solana_sdk::clock::Slot, solana_sdk::clock::Slot,
thiserror::Error,
}; };
pub const JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: i64 = -32001; pub const JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: i64 = -32001;

View File

@@ -241,11 +241,9 @@ pub enum TokenAccountsFilter {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::rpc_config::RpcTokenAccountsFilter;
crate::rpc_config::RpcTokenAccountsFilter, use solana_sdk::commitment_config::{CommitmentConfig, CommitmentLevel};
solana_sdk::commitment_config::{CommitmentConfig, CommitmentLevel},
};
#[test] #[test]
fn test_build_request_json() { fn test_build_request_json() {

View File

@@ -622,7 +622,8 @@ pub fn create_client_with_timeout(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use {super::*, rayon::prelude::*}; use super::*;
use rayon::prelude::*;
#[test] #[test]
fn test_client_optimizer() { fn test_client_optimizer() {

View File

@@ -1,36 +1,34 @@
use { use crate::{
crate::{ client_error::ClientError,
client_error::ClientError, pubsub_client::{PubsubClient, PubsubClientError, PubsubClientSubscription},
pubsub_client::{PubsubClient, PubsubClientError, PubsubClientSubscription}, rpc_client::RpcClient,
rpc_client::RpcClient, rpc_request::MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS,
rpc_request::MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, rpc_response::{Fees, SlotUpdate},
rpc_response::{Fees, SlotUpdate}, spinner,
spinner,
},
bincode::serialize,
log::*,
solana_sdk::{
clock::Slot,
commitment_config::CommitmentConfig,
message::Message,
pubkey::Pubkey,
signature::SignerError,
signers::Signers,
transaction::{Transaction, TransactionError},
},
std::{
collections::{HashMap, HashSet, VecDeque},
net::{SocketAddr, UdpSocket},
str::FromStr,
sync::{
atomic::{AtomicBool, Ordering},
Arc, RwLock,
},
thread::{sleep, JoinHandle},
time::{Duration, Instant},
},
thiserror::Error,
}; };
use bincode::serialize;
use log::*;
use solana_sdk::{
clock::Slot,
commitment_config::CommitmentConfig,
message::Message,
pubkey::Pubkey,
signature::SignerError,
signers::Signers,
transaction::{Transaction, TransactionError},
};
use std::{
collections::{HashMap, HashSet, VecDeque},
net::{SocketAddr, UdpSocket},
str::FromStr,
sync::{
atomic::{AtomicBool, Ordering},
Arc, RwLock,
},
thread::{sleep, JoinHandle},
time::{Duration, Instant},
};
use thiserror::Error;
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum TpuSenderError { pub enum TpuSenderError {

View File

@@ -3,41 +3,40 @@
extern crate test; extern crate test;
use { use crossbeam_channel::unbounded;
crossbeam_channel::unbounded, use log::*;
log::*, use rand::{thread_rng, Rng};
rand::{thread_rng, Rng}, use rayon::prelude::*;
rayon::prelude::*, use solana_core::banking_stage::{BankingStage, BankingStageStats};
solana_core::banking_stage::{BankingStage, BankingStageStats}, use solana_gossip::cluster_info::ClusterInfo;
solana_gossip::cluster_info::{ClusterInfo, Node}, use solana_gossip::cluster_info::Node;
solana_ledger::{ use solana_ledger::blockstore_processor::process_entries;
blockstore::Blockstore, use solana_ledger::entry::{next_hash, Entry};
blockstore_processor::process_entries, use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
entry::{next_hash, Entry}, use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path};
genesis_utils::{create_genesis_config, GenesisConfigInfo}, use solana_perf::packet::to_packets_chunked;
get_tmp_ledger_path, use solana_perf::test_tx::test_tx;
}, use solana_poh::poh_recorder::{create_test_recorder, WorkingBankEntry};
solana_perf::{packet::to_packets_chunked, test_tx::test_tx}, use solana_runtime::bank::Bank;
solana_poh::poh_recorder::{create_test_recorder, WorkingBankEntry}, use solana_runtime::cost_model::CostModel;
solana_runtime::{bank::Bank, cost_model::CostModel}, use solana_sdk::genesis_config::GenesisConfig;
solana_sdk::{ use solana_sdk::hash::Hash;
genesis_config::GenesisConfig, use solana_sdk::message::Message;
hash::Hash, use solana_sdk::pubkey;
message::Message, use solana_sdk::signature::Keypair;
pubkey, use solana_sdk::signature::Signature;
signature::{Keypair, Signature, Signer}, use solana_sdk::signature::Signer;
system_instruction, system_transaction, use solana_sdk::system_instruction;
timing::{duration_as_us, timestamp}, use solana_sdk::system_transaction;
transaction::Transaction, use solana_sdk::timing::{duration_as_us, timestamp};
}, use solana_sdk::transaction::Transaction;
solana_streamer::socket::SocketAddrSpace, use solana_streamer::socket::SocketAddrSpace;
std::{ use std::collections::VecDeque;
collections::VecDeque, use std::sync::atomic::Ordering;
sync::{atomic::Ordering, mpsc::Receiver, Arc, RwLock}, use std::sync::mpsc::Receiver;
time::{Duration, Instant}, use std::sync::{Arc, RwLock};
}, use std::time::{Duration, Instant};
test::Bencher, use test::Bencher;
};
fn check_txs(receiver: &Arc<Receiver<WorkingBankEntry>>, ref_tx_count: usize) { fn check_txs(receiver: &Arc<Receiver<WorkingBankEntry>>, ref_tx_count: usize) {
let mut total = 0; let mut total = 0;

View File

@@ -3,17 +3,15 @@
extern crate solana_ledger; extern crate solana_ledger;
extern crate test; extern crate test;
use { use rand::Rng;
rand::Rng, use solana_ledger::{
solana_ledger::{ blockstore::{entries_to_test_shreds, Blockstore},
blockstore::{entries_to_test_shreds, Blockstore}, entry::{create_ticks, Entry},
entry::{create_ticks, Entry}, get_tmp_ledger_path,
get_tmp_ledger_path,
},
solana_sdk::{clock::Slot, hash::Hash},
std::path::Path,
test::Bencher,
}; };
use solana_sdk::{clock::Slot, hash::Hash};
use std::path::Path;
use test::Bencher;
// Given some shreds and a ledger at ledger_path, benchmark writing the shreds to the ledger // Given some shreds and a ledger at ledger_path, benchmark writing the shreds to the ledger
fn bench_write_shreds(bench: &mut Bencher, entries: Vec<Entry>, ledger_path: &Path) { fn bench_write_shreds(bench: &mut Bencher, entries: Vec<Entry>, ledger_path: &Path) {

View File

@@ -3,17 +3,16 @@
extern crate solana_core; extern crate solana_core;
extern crate test; extern crate test;
use { use solana_core::consensus::Tower;
solana_core::consensus::Tower, use solana_runtime::bank::Bank;
solana_runtime::{bank::Bank, bank_forks::BankForks}, use solana_runtime::bank_forks::BankForks;
solana_sdk::{ use solana_sdk::{
pubkey::Pubkey, pubkey::Pubkey,
signature::{Keypair, Signer}, signature::{Keypair, Signer},
},
std::sync::Arc,
tempfile::TempDir,
test::Bencher,
}; };
use std::sync::Arc;
use tempfile::TempDir;
use test::Bencher;
#[bench] #[bench]
fn bench_save_tower(bench: &mut Bencher) { fn bench_save_tower(bench: &mut Bencher) {

View File

@@ -2,7 +2,8 @@
extern crate test; extern crate test;
use {solana_core::gen_keys::GenKeys, test::Bencher}; use solana_core::gen_keys::GenKeys;
use test::Bencher;
#[bench] #[bench]
fn bench_gen_keys(b: &mut Bencher) { fn bench_gen_keys(b: &mut Bencher) {

View File

@@ -3,22 +3,19 @@
extern crate test; extern crate test;
use { use rand::seq::SliceRandom;
rand::seq::SliceRandom, use raptorq::{Decoder, Encoder};
raptorq::{Decoder, Encoder}, use solana_ledger::entry::{create_ticks, Entry};
solana_ledger::{ use solana_ledger::shred::{
entry::{create_ticks, Entry}, max_entries_per_n_shred, max_ticks_per_n_shreds, ProcessShredsStats, Shred, Shredder,
shred::{ MAX_DATA_SHREDS_PER_FEC_BLOCK, SHRED_PAYLOAD_SIZE, SIZE_OF_CODING_SHRED_HEADERS,
max_entries_per_n_shred, max_ticks_per_n_shreds, ProcessShredsStats, Shred, Shredder, SIZE_OF_DATA_SHRED_PAYLOAD,
MAX_DATA_SHREDS_PER_FEC_BLOCK, SHRED_PAYLOAD_SIZE, SIZE_OF_CODING_SHRED_HEADERS,
SIZE_OF_DATA_SHRED_PAYLOAD,
},
},
solana_perf::test_tx,
solana_sdk::{hash::Hash, signature::Keypair},
std::sync::Arc,
test::Bencher,
}; };
use solana_perf::test_tx;
use solana_sdk::hash::Hash;
use solana_sdk::signature::Keypair;
use std::sync::Arc;
use test::Bencher;
fn make_test_entry(txs_per_entry: u64) -> Entry { fn make_test_entry(txs_per_entry: u64) -> Entry {
Entry { Entry {

View File

@@ -3,24 +3,20 @@
extern crate solana_core; extern crate solana_core;
extern crate test; extern crate test;
use { use crossbeam_channel::unbounded;
crossbeam_channel::unbounded, use log::*;
log::*, use rand::{thread_rng, Rng};
rand::{thread_rng, Rng}, use solana_core::sigverify::TransactionSigVerifier;
solana_core::{sigverify::TransactionSigVerifier, sigverify_stage::SigVerifyStage}, use solana_core::sigverify_stage::SigVerifyStage;
solana_perf::{packet::to_packets_chunked, test_tx::test_tx}, use solana_perf::packet::to_packets_chunked;
solana_sdk::{ use solana_perf::test_tx::test_tx;
hash::Hash, use solana_sdk::hash::Hash;
signature::{Keypair, Signer}, use solana_sdk::signature::{Keypair, Signer};
system_transaction, use solana_sdk::system_transaction;
timing::duration_as_ms, use solana_sdk::timing::duration_as_ms;
}, use std::sync::mpsc::channel;
std::{ use std::time::{Duration, Instant};
sync::mpsc::channel, use test::Bencher;
time::{Duration, Instant},
},
test::Bencher,
};
#[bench] #[bench]
fn bench_packet_discard(bencher: &mut Bencher) { fn bench_packet_discard(bencher: &mut Bencher) {

View File

@@ -4,25 +4,23 @@
// hash on gossip. Monitor gossip for messages from validators in the `--known-validator`s // hash on gossip. Monitor gossip for messages from validators in the `--known-validator`s
// set and halt the node if a mismatch is detected. // set and halt the node if a mismatch is detected.
use { use crate::snapshot_packager_service::PendingSnapshotPackage;
crate::snapshot_packager_service::PendingSnapshotPackage, use rayon::ThreadPool;
rayon::ThreadPool, use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES};
solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES}, use solana_runtime::{
solana_runtime::{ accounts_db,
accounts_db, snapshot_package::{AccountsPackage, AccountsPackagePre, AccountsPackageReceiver},
snapshot_package::{AccountsPackage, AccountsPackagePre, AccountsPackageReceiver}, };
}, use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey};
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}, use std::collections::{HashMap, HashSet};
std::{ use std::{
collections::{HashMap, HashSet}, sync::{
sync::{ atomic::{AtomicBool, Ordering},
atomic::{AtomicBool, Ordering}, mpsc::RecvTimeoutError,
mpsc::RecvTimeoutError, Arc,
Arc,
},
thread::{self, Builder, JoinHandle},
time::Duration,
}, },
thread::{self, Builder, JoinHandle},
time::Duration,
}; };
pub struct AccountsHashVerifier { pub struct AccountsHashVerifier {
@@ -131,10 +129,8 @@ impl AccountsHashVerifier {
&& accounts_package.slot % fault_injection_rate_slots == 0 && accounts_package.slot % fault_injection_rate_slots == 0
{ {
// For testing, publish an invalid hash to gossip. // For testing, publish an invalid hash to gossip.
use { use rand::{thread_rng, Rng};
rand::{thread_rng, Rng}, use solana_sdk::hash::extend_and_hash;
solana_sdk::hash::extend_and_hash,
};
warn!("inserting fault at slot: {}", accounts_package.slot); warn!("inserting fault at slot: {}", accounts_package.slot);
let rand = thread_rng().gen_range(0, 10); let rand = thread_rng().gen_range(0, 10);
let hash = extend_and_hash(&hash, &[rand]); let hash = extend_and_hash(&hash, &[rand]);
@@ -219,16 +215,15 @@ impl AccountsHashVerifier {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo};
solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo}, use solana_runtime::bank_forks::ArchiveFormat;
solana_runtime::{bank_forks::ArchiveFormat, snapshot_utils::SnapshotVersion}, use solana_runtime::snapshot_utils::SnapshotVersion;
solana_sdk::{ use solana_sdk::{
hash::hash, hash::hash,
signature::{Keypair, Signer}, signature::{Keypair, Signer},
},
solana_streamer::socket::SocketAddrSpace,
}; };
use solana_streamer::socket::SocketAddrSpace;
fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo { fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo {
ClusterInfo::new( ClusterInfo::new(
@@ -274,7 +269,8 @@ mod tests {
#[test] #[test]
fn test_max_hashes() { fn test_max_hashes() {
solana_logger::setup(); solana_logger::setup();
use {std::path::PathBuf, tempfile::TempDir}; use std::path::PathBuf;
use tempfile::TempDir;
let keypair = Keypair::new(); let keypair = Keypair::new();
let contact_info = ContactInfo::new_localhost(&keypair.pubkey(), 0); let contact_info = ContactInfo::new_localhost(&keypair.pubkey(), 0);

View File

@@ -1,67 +1,64 @@
//! The `banking_stage` processes Transaction messages. It is intended to be used //! The `banking_stage` processes Transaction messages. It is intended to be used
//! to contruct a software pipeline. The stage uses all available CPU cores and //! to contruct a software pipeline. The stage uses all available CPU cores and
//! can do its processing in parallel with signature verification on the GPU. //! can do its processing in parallel with signature verification on the GPU.
use { use crate::packet_hasher::PacketHasher;
crate::packet_hasher::PacketHasher, use crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError};
crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError}, use itertools::Itertools;
itertools::Itertools, use lru::LruCache;
lru::LruCache, use retain_mut::RetainMut;
retain_mut::RetainMut, use solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo};
solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo}, use solana_ledger::{blockstore_processor::TransactionStatusSender, entry::hash_transactions};
solana_ledger::{blockstore_processor::TransactionStatusSender, entry::hash_transactions}, use solana_measure::measure::Measure;
solana_measure::measure::Measure, use solana_metrics::{inc_new_counter_debug, inc_new_counter_info};
solana_metrics::{inc_new_counter_debug, inc_new_counter_info}, use solana_perf::{
solana_perf::{ cuda_runtime::PinnedVec,
cuda_runtime::PinnedVec, data_budget::DataBudget,
data_budget::DataBudget, packet::{limited_deserialize, Packet, Packets, PACKETS_PER_BATCH},
packet::{limited_deserialize, Packet, Packets, PACKETS_PER_BATCH}, perf_libs,
perf_libs, };
use solana_poh::poh_recorder::{PohRecorder, PohRecorderError, TransactionRecorder};
use solana_runtime::{
accounts_db::ErrorCounters,
bank::{
Bank, ExecuteTimings, TransactionBalancesSet, TransactionCheckResult,
TransactionExecutionResult,
}, },
solana_poh::poh_recorder::{PohRecorder, PohRecorderError, TransactionRecorder}, bank_utils,
solana_runtime::{ cost_model::CostModel,
accounts_db::ErrorCounters, cost_tracker::CostTracker,
bank::{ hashed_transaction::HashedTransaction,
Bank, ExecuteTimings, TransactionBalancesSet, TransactionCheckResult, transaction_batch::TransactionBatch,
TransactionExecutionResult, vote_sender_types::ReplayVoteSender,
}, };
bank_utils, use solana_sdk::{
cost_model::CostModel, clock::{
cost_tracker::CostTracker, Slot, DEFAULT_TICKS_PER_SLOT, MAX_PROCESSING_AGE, MAX_TRANSACTION_FORWARDING_DELAY,
hashed_transaction::HashedTransaction, MAX_TRANSACTION_FORWARDING_DELAY_GPU,
transaction_batch::TransactionBatch,
vote_sender_types::ReplayVoteSender,
},
solana_sdk::{
clock::{
Slot, DEFAULT_TICKS_PER_SLOT, MAX_PROCESSING_AGE, MAX_TRANSACTION_FORWARDING_DELAY,
MAX_TRANSACTION_FORWARDING_DELAY_GPU,
},
feature_set,
message::Message,
pubkey::Pubkey,
short_vec::decode_shortu16_len,
signature::Signature,
timing::{duration_as_ms, timestamp, AtomicInterval},
transaction::{self, Transaction, TransactionError},
},
solana_transaction_status::token_balances::{
collect_token_balances, TransactionTokenBalancesSet,
},
std::{
borrow::Cow,
cmp,
collections::{HashMap, VecDeque},
env,
mem::size_of,
net::{SocketAddr, UdpSocket},
ops::DerefMut,
sync::{
atomic::{AtomicU64, AtomicUsize, Ordering},
Arc, Mutex, RwLock, RwLockReadGuard,
},
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
}, },
feature_set,
message::Message,
pubkey::Pubkey,
short_vec::decode_shortu16_len,
signature::Signature,
timing::{duration_as_ms, timestamp, AtomicInterval},
transaction::{self, Transaction, TransactionError},
};
use solana_transaction_status::token_balances::{
collect_token_balances, TransactionTokenBalancesSet,
};
use std::{
borrow::Cow,
cmp,
collections::{HashMap, VecDeque},
env,
mem::size_of,
net::{SocketAddr, UdpSocket},
ops::DerefMut,
sync::atomic::{AtomicU64, AtomicUsize, Ordering},
sync::{Arc, Mutex, RwLock, RwLockReadGuard},
thread::{self, Builder, JoinHandle},
time::Duration,
time::Instant,
}; };
/// (packets, valid_indexes, forwarded) /// (packets, valid_indexes, forwarded)
@@ -1663,46 +1660,44 @@ where
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crossbeam_channel::unbounded;
crossbeam_channel::unbounded, use itertools::Itertools;
itertools::Itertools, use solana_gossip::{cluster_info::Node, contact_info::ContactInfo};
solana_gossip::{cluster_info::Node, contact_info::ContactInfo}, use solana_ledger::{
solana_ledger::{ blockstore::{entries_to_test_shreds, Blockstore},
blockstore::{entries_to_test_shreds, Blockstore}, entry::{next_entry, Entry, EntrySlice},
entry::{next_entry, Entry, EntrySlice}, genesis_utils::{create_genesis_config, GenesisConfigInfo},
genesis_utils::{create_genesis_config, GenesisConfigInfo}, get_tmp_ledger_path,
get_tmp_ledger_path, leader_schedule_cache::LeaderScheduleCache,
leader_schedule_cache::LeaderScheduleCache, };
}, use solana_perf::packet::to_packets_chunked;
solana_perf::packet::to_packets_chunked, use solana_poh::{
solana_poh::{ poh_recorder::{create_test_recorder, Record, WorkingBank, WorkingBankEntry},
poh_recorder::{create_test_recorder, Record, WorkingBank, WorkingBankEntry}, poh_service::PohService,
poh_service::PohService, };
}, use solana_rpc::transaction_status_service::TransactionStatusService;
solana_rpc::transaction_status_service::TransactionStatusService, use solana_runtime::cost_model::CostModel;
solana_runtime::cost_model::CostModel, use solana_sdk::{
solana_sdk::{ hash::Hash,
hash::Hash, instruction::InstructionError,
instruction::InstructionError, poh_config::PohConfig,
poh_config::PohConfig, signature::{Keypair, Signer},
signature::{Keypair, Signer}, system_instruction::SystemError,
system_instruction::SystemError, system_transaction,
system_transaction, transaction::TransactionError,
transaction::TransactionError, };
}, use solana_streamer::socket::SocketAddrSpace;
solana_streamer::socket::SocketAddrSpace, use solana_transaction_status::TransactionWithStatusMeta;
solana_transaction_status::TransactionWithStatusMeta, use solana_vote_program::vote_transaction;
solana_vote_program::vote_transaction, use std::{
std::{ net::SocketAddr,
net::SocketAddr, path::Path,
path::Path, sync::{
sync::{ atomic::{AtomicBool, Ordering},
atomic::{AtomicBool, Ordering}, mpsc::Receiver,
mpsc::Receiver,
},
thread::sleep,
}, },
thread::sleep,
}; };
fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo { fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo {

View File

@@ -23,9 +23,8 @@ use {
solana_poh::poh_recorder::WorkingBankEntry, solana_poh::poh_recorder::WorkingBankEntry,
solana_runtime::{bank::Bank, bank_forks::BankForks}, solana_runtime::{bank::Bank, bank_forks::BankForks},
solana_sdk::{ solana_sdk::{
clock::Slot,
pubkey::Pubkey,
timing::{timestamp, AtomicInterval}, timing::{timestamp, AtomicInterval},
{clock::Slot, pubkey::Pubkey},
}, },
solana_streamer::{ solana_streamer::{
sendmmsg::{batch_send, SendPktsError}, sendmmsg::{batch_send, SendPktsError},
@@ -450,28 +449,24 @@ pub fn broadcast_shreds(
#[cfg(test)] #[cfg(test)]
pub mod test { pub mod test {
use { use super::*;
super::*, use crossbeam_channel::unbounded;
crossbeam_channel::unbounded, use solana_gossip::cluster_info::{ClusterInfo, Node};
solana_gossip::cluster_info::{ClusterInfo, Node}, use solana_ledger::{
solana_ledger::{ blockstore::{make_slot_entries, Blockstore},
blockstore::{make_slot_entries, Blockstore}, entry::create_ticks,
entry::create_ticks, genesis_utils::{create_genesis_config, GenesisConfigInfo},
genesis_utils::{create_genesis_config, GenesisConfigInfo}, get_tmp_ledger_path,
get_tmp_ledger_path, shred::{max_ticks_per_n_shreds, ProcessShredsStats, Shredder},
shred::{max_ticks_per_n_shreds, ProcessShredsStats, Shredder}, };
}, use solana_runtime::bank::Bank;
solana_runtime::bank::Bank, use solana_sdk::{
solana_sdk::{ hash::Hash,
hash::Hash, pubkey::Pubkey,
pubkey::Pubkey, signature::{Keypair, Signer},
signature::{Keypair, Signer}, };
}, use std::{
std::{ path::Path, sync::atomic::AtomicBool, sync::mpsc::channel, sync::Arc, thread::sleep,
path::Path,
sync::{atomic::AtomicBool, mpsc::channel, Arc},
thread::sleep,
},
}; };
#[allow(clippy::implicit_hasher)] #[allow(clippy::implicit_hasher)]

View File

@@ -1,8 +1,8 @@
use { use super::*;
super::*, use solana_ledger::entry::Entry;
solana_ledger::{entry::Entry, shred::Shredder}, use solana_ledger::shred::Shredder;
solana_sdk::{hash::Hash, signature::Keypair}, use solana_sdk::hash::Hash;
}; use solana_sdk::signature::Keypair;
#[derive(Clone)] #[derive(Clone)]
pub(super) struct BroadcastFakeShredsRun { pub(super) struct BroadcastFakeShredsRun {
@@ -139,12 +139,10 @@ impl BroadcastRun for BroadcastFakeShredsRun {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use solana_gossip::contact_info::ContactInfo;
solana_gossip::contact_info::ContactInfo, use solana_streamer::socket::SocketAddrSpace;
solana_streamer::socket::SocketAddrSpace, use std::net::{IpAddr, Ipv4Addr, SocketAddr};
std::net::{IpAddr, Ipv4Addr, SocketAddr},
};
#[test] #[test]
fn test_tvu_peers_ordering() { fn test_tvu_peers_ordering() {

View File

@@ -1,13 +1,12 @@
use { use crate::result::Result;
crate::result::Result, use solana_ledger::{entry::Entry, shred::Shred};
solana_ledger::{entry::Entry, shred::Shred}, use solana_poh::poh_recorder::WorkingBankEntry;
solana_poh::poh_recorder::WorkingBankEntry, use solana_runtime::bank::Bank;
solana_runtime::bank::Bank, use solana_sdk::clock::Slot;
solana_sdk::clock::Slot, use std::{
std::{ sync::mpsc::Receiver,
sync::{mpsc::Receiver, Arc}, sync::Arc,
time::{Duration, Instant}, time::{Duration, Instant},
},
}; };
pub(super) struct ReceiveResults { pub(super) struct ReceiveResults {
@@ -80,15 +79,13 @@ pub(super) fn recv_slot_entries(receiver: &Receiver<WorkingBankEntry>) -> Result
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}, use solana_sdk::genesis_config::GenesisConfig;
solana_sdk::{ use solana_sdk::pubkey::Pubkey;
genesis_config::GenesisConfig, pubkey::Pubkey, system_transaction, use solana_sdk::system_transaction;
transaction::Transaction, use solana_sdk::transaction::Transaction;
}, use std::sync::mpsc::channel;
std::sync::mpsc::channel,
};
fn setup_test() -> (GenesisConfig, Arc<Bank>, Transaction) { fn setup_test() -> (GenesisConfig, Arc<Bank>, Transaction) {
let GenesisConfigInfo { let GenesisConfigInfo {

View File

@@ -511,21 +511,21 @@ impl BroadcastRun for StandardBroadcastRun {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use solana_gossip::cluster_info::{ClusterInfo, Node};
solana_gossip::cluster_info::{ClusterInfo, Node}, use solana_ledger::genesis_utils::create_genesis_config;
solana_ledger::{ use solana_ledger::{
blockstore::Blockstore, entry::create_ticks, genesis_utils::create_genesis_config, blockstore::Blockstore, entry::create_ticks, get_tmp_ledger_path,
get_tmp_ledger_path, shred::max_ticks_per_n_shreds, shred::max_ticks_per_n_shreds,
},
solana_runtime::bank::Bank,
solana_sdk::{
genesis_config::GenesisConfig,
signature::{Keypair, Signer},
},
solana_streamer::socket::SocketAddrSpace,
std::{sync::Arc, time::Duration},
}; };
use solana_runtime::bank::Bank;
use solana_sdk::{
genesis_config::GenesisConfig,
signature::{Keypair, Signer},
};
use solana_streamer::socket::SocketAddrSpace;
use std::sync::Arc;
use std::time::Duration;
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
fn setup( fn setup(

View File

@@ -1,56 +1,53 @@
use { use crate::{
crate::{ optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
optimistic_confirmation_verifier::OptimisticConfirmationVerifier, replay_stage::DUPLICATE_THRESHOLD,
replay_stage::DUPLICATE_THRESHOLD, result::{Error, Result},
result::{Error, Result}, sigverify,
sigverify, verified_vote_packets::VerifiedVotePackets,
verified_vote_packets::VerifiedVotePackets, vote_stake_tracker::VoteStakeTracker,
vote_stake_tracker::VoteStakeTracker, };
}, use crossbeam_channel::{
crossbeam_channel::{ unbounded, Receiver as CrossbeamReceiver, RecvTimeoutError, Select, Sender as CrossbeamSender,
unbounded, Receiver as CrossbeamReceiver, RecvTimeoutError, Select, };
Sender as CrossbeamSender, use itertools::izip;
}, use log::*;
itertools::izip, use solana_gossip::{
log::*, cluster_info::{ClusterInfo, GOSSIP_SLEEP_MILLIS},
solana_gossip::{ crds::Cursor,
cluster_info::{ClusterInfo, GOSSIP_SLEEP_MILLIS}, crds_value::CrdsValueLabel,
crds::Cursor, };
crds_value::CrdsValueLabel, use solana_ledger::blockstore::Blockstore;
}, use solana_metrics::inc_new_counter_debug;
solana_ledger::blockstore::Blockstore, use solana_perf::packet::{self, Packets};
solana_metrics::inc_new_counter_debug, use solana_poh::poh_recorder::PohRecorder;
solana_perf::packet::{self, Packets}, use solana_rpc::{
solana_poh::poh_recorder::PohRecorder, optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender},
solana_rpc::{ rpc_subscriptions::RpcSubscriptions,
optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender}, };
rpc_subscriptions::RpcSubscriptions, use solana_runtime::{
}, bank::Bank,
solana_runtime::{ bank_forks::BankForks,
bank::Bank, commitment::VOTE_THRESHOLD_SIZE,
bank_forks::BankForks, epoch_stakes::{EpochAuthorizedVoters, EpochStakes},
commitment::VOTE_THRESHOLD_SIZE, stakes::Stakes,
epoch_stakes::{EpochAuthorizedVoters, EpochStakes}, vote_sender_types::{ReplayVoteReceiver, ReplayedVote},
stakes::Stakes, };
vote_sender_types::{ReplayVoteReceiver, ReplayedVote}, use solana_sdk::{
}, clock::{Epoch, Slot, DEFAULT_MS_PER_SLOT, DEFAULT_TICKS_PER_SLOT},
solana_sdk::{ epoch_schedule::EpochSchedule,
clock::{Epoch, Slot, DEFAULT_MS_PER_SLOT, DEFAULT_TICKS_PER_SLOT}, hash::Hash,
epoch_schedule::EpochSchedule, pubkey::Pubkey,
hash::Hash, transaction::Transaction,
pubkey::Pubkey, };
transaction::Transaction, use solana_vote_program::{self, vote_state::Vote, vote_transaction};
}, use std::{
solana_vote_program::{self, vote_state::Vote, vote_transaction}, collections::HashMap,
std::{ sync::{
collections::HashMap, atomic::{AtomicBool, Ordering},
sync::{ {Arc, Mutex, RwLock},
atomic::{AtomicBool, Ordering},
Arc, Mutex, RwLock,
},
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
}, },
thread::{self, sleep, Builder, JoinHandle},
time::{Duration, Instant},
}; };
// Map from a vote account to the authorized voter for an epoch // Map from a vote account to the authorized voter for an epoch
@@ -838,23 +835,21 @@ impl ClusterInfoVoteListener {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use solana_perf::packet;
solana_perf::packet, use solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank;
solana_rpc::optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, use solana_runtime::{
solana_runtime::{ bank::Bank,
bank::Bank, commitment::BlockCommitmentCache,
commitment::BlockCommitmentCache, genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs},
genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs}, vote_sender_types::ReplayVoteSender,
vote_sender_types::ReplayVoteSender,
},
solana_sdk::{
hash::Hash,
signature::{Keypair, Signature, Signer},
},
solana_vote_program::vote_state::Vote,
std::collections::BTreeSet,
}; };
use solana_sdk::{
hash::Hash,
signature::{Keypair, Signature, Signer},
};
use solana_vote_program::vote_state::Vote;
use std::collections::BTreeSet;
#[test] #[test]
fn test_max_vote_tx_fits() { fn test_max_vote_tx_fits() {

View File

@@ -1,11 +1,9 @@
use { use crate::{
crate::{ fork_choice::ForkChoice, heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
fork_choice::ForkChoice, heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, progress_map::ProgressMap,
progress_map::ProgressMap,
},
solana_sdk::{clock::Slot, hash::Hash},
std::collections::{BTreeMap, BTreeSet},
}; };
use solana_sdk::{clock::Slot, hash::Hash};
use std::collections::{BTreeMap, BTreeSet};
pub(crate) type DuplicateSlotsTracker = BTreeSet<Slot>; pub(crate) type DuplicateSlotsTracker = BTreeSet<Slot>;
pub(crate) type GossipDuplicateConfirmedSlots = BTreeMap<Slot, Hash>; pub(crate) type GossipDuplicateConfirmedSlots = BTreeMap<Slot, Hash>;
@@ -307,16 +305,14 @@ pub(crate) fn check_slot_agrees_with_cluster(
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use crate::consensus::test::VoteSimulator;
crate::consensus::test::VoteSimulator, use solana_runtime::bank_forks::BankForks;
solana_runtime::bank_forks::BankForks, use std::{
std::{ collections::{HashMap, HashSet},
collections::{HashMap, HashSet}, sync::RwLock,
sync::RwLock,
},
trees::tr,
}; };
use trees::tr;
struct InitialState { struct InitialState {
heaviest_subtree_fork_choice: HeaviestSubtreeForkChoice, heaviest_subtree_fork_choice: HeaviestSubtreeForkChoice,

View File

@@ -186,7 +186,8 @@ impl ClusterSlots {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use {super::*, solana_runtime::epoch_stakes::NodeVoteAccounts}; use super::*;
use solana_runtime::epoch_stakes::NodeVoteAccounts;
#[test] #[test]
fn test_default() { fn test_default() {

View File

@@ -1,19 +1,17 @@
use { use crate::cluster_slots::ClusterSlots;
crate::cluster_slots::ClusterSlots, use crossbeam_channel::{Receiver, RecvTimeoutError, Sender};
crossbeam_channel::{Receiver, RecvTimeoutError, Sender}, use solana_gossip::cluster_info::ClusterInfo;
solana_gossip::cluster_info::ClusterInfo, use solana_ledger::blockstore::Blockstore;
solana_ledger::blockstore::Blockstore, use solana_measure::measure::Measure;
solana_measure::measure::Measure, use solana_runtime::bank_forks::BankForks;
solana_runtime::bank_forks::BankForks, use solana_sdk::clock::Slot;
solana_sdk::clock::Slot, use std::{
std::{ sync::{
sync::{ atomic::{AtomicBool, Ordering},
atomic::{AtomicBool, Ordering}, {Arc, RwLock},
Arc, RwLock,
},
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
}, },
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
}; };
pub type ClusterSlotsUpdateReceiver = Receiver<Vec<Slot>>; pub type ClusterSlotsUpdateReceiver = Receiver<Vec<Slot>>;

View File

@@ -1,25 +1,21 @@
use { use crate::consensus::Stake;
crate::consensus::Stake, use solana_measure::measure::Measure;
solana_measure::measure::Measure, use solana_metrics::datapoint_info;
solana_metrics::datapoint_info, use solana_rpc::rpc_subscriptions::RpcSubscriptions;
solana_rpc::rpc_subscriptions::RpcSubscriptions, use solana_runtime::{
solana_runtime::{ bank::Bank,
bank::Bank, commitment::{BlockCommitment, BlockCommitmentCache, CommitmentSlots, VOTE_THRESHOLD_SIZE},
commitment::{BlockCommitment, BlockCommitmentCache, CommitmentSlots, VOTE_THRESHOLD_SIZE}, };
}, use solana_sdk::clock::Slot;
solana_sdk::clock::Slot, use solana_vote_program::vote_state::VoteState;
solana_vote_program::vote_state::VoteState, use std::{
std::{ cmp::max,
cmp::max, collections::HashMap,
collections::HashMap, sync::atomic::{AtomicBool, Ordering},
sync::{ sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender},
atomic::{AtomicBool, Ordering}, sync::{Arc, RwLock},
mpsc::{channel, Receiver, RecvTimeoutError, Sender}, thread::{self, Builder, JoinHandle},
Arc, RwLock, time::Duration,
},
thread::{self, Builder, JoinHandle},
time::Duration,
},
}; };
pub struct CommitmentAggregationData { pub struct CommitmentAggregationData {
@@ -251,20 +247,18 @@ impl AggregateCommitmentService {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}, use solana_runtime::{
solana_runtime::{ accounts_background_service::AbsRequestSender,
accounts_background_service::AbsRequestSender, bank_forks::BankForks,
bank_forks::BankForks, genesis_utils::{create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs},
genesis_utils::{create_genesis_config_with_vote_accounts, ValidatorVoteKeypairs}, };
}, use solana_sdk::{account::Account, pubkey::Pubkey, signature::Signer};
solana_sdk::{account::Account, pubkey::Pubkey, signature::Signer}, use solana_stake_program::stake_state;
solana_stake_program::stake_state, use solana_vote_program::{
solana_vote_program::{ vote_state::{self, VoteStateVersions},
vote_state::{self, VoteStateVersions}, vote_transaction,
vote_transaction,
},
}; };
#[test] #[test]

View File

@@ -1,19 +1,15 @@
use { use crossbeam_channel::{Receiver, RecvTimeoutError, Sender};
crossbeam_channel::{Receiver, RecvTimeoutError, Sender}, use solana_ledger::blockstore::{Blockstore, CompletedDataSetInfo};
solana_ledger::{ use solana_ledger::entry::Entry;
blockstore::{Blockstore, CompletedDataSetInfo}, use solana_rpc::{max_slots::MaxSlots, rpc_subscriptions::RpcSubscriptions};
entry::Entry, use solana_sdk::signature::Signature;
}, use std::{
solana_rpc::{max_slots::MaxSlots, rpc_subscriptions::RpcSubscriptions}, sync::{
solana_sdk::signature::Signature, atomic::{AtomicBool, Ordering},
std::{ Arc,
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread::{self, Builder, JoinHandle},
time::Duration,
}, },
thread::{self, Builder, JoinHandle},
time::Duration,
}; };
pub type CompletedDataSetsReceiver = Receiver<Vec<CompletedDataSetInfo>>; pub type CompletedDataSetsReceiver = Receiver<Vec<CompletedDataSetInfo>>;
@@ -104,14 +100,10 @@ impl CompletedDataSetsService {
#[cfg(test)] #[cfg(test)]
pub mod test { pub mod test {
use { use super::*;
super::*, use solana_sdk::hash::Hash;
solana_sdk::{ use solana_sdk::signature::{Keypair, Signer};
hash::Hash, use solana_sdk::transaction::Transaction;
signature::{Keypair, Signer},
transaction::Transaction,
},
};
#[test] #[test]
fn test_zero_signatures() { fn test_zero_signatures() {

View File

@@ -1,42 +1,40 @@
use { use crate::{
crate::{ heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, progress_map::{LockoutIntervals, ProgressMap},
progress_map::{LockoutIntervals, ProgressMap},
},
chrono::prelude::*,
solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore, blockstore_db},
solana_measure::measure::Measure,
solana_runtime::{
bank::Bank, bank_forks::BankForks, commitment::VOTE_THRESHOLD_SIZE,
vote_account::ArcVoteAccount,
},
solana_sdk::{
clock::{Slot, UnixTimestamp},
hash::Hash,
instruction::Instruction,
pubkey::Pubkey,
signature::{Keypair, Signature, Signer},
slot_history::{Check, SlotHistory},
},
solana_vote_program::{
vote_instruction,
vote_state::{BlockTimestamp, Lockout, Vote, VoteState, MAX_LOCKOUT_HISTORY},
},
std::{
cmp::Ordering,
collections::{HashMap, HashSet},
fs::{self, File},
io::BufReader,
ops::{
Bound::{Included, Unbounded},
Deref,
},
path::{Path, PathBuf},
sync::Arc,
},
thiserror::Error,
}; };
use chrono::prelude::*;
use solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore, blockstore_db};
use solana_measure::measure::Measure;
use solana_runtime::{
bank::Bank, bank_forks::BankForks, commitment::VOTE_THRESHOLD_SIZE,
vote_account::ArcVoteAccount,
};
use solana_sdk::{
clock::{Slot, UnixTimestamp},
hash::Hash,
instruction::Instruction,
pubkey::Pubkey,
signature::{Keypair, Signature, Signer},
slot_history::{Check, SlotHistory},
};
use solana_vote_program::{
vote_instruction,
vote_state::{BlockTimestamp, Lockout, Vote, VoteState, MAX_LOCKOUT_HISTORY},
};
use std::{
cmp::Ordering,
collections::{HashMap, HashSet},
fs::{self, File},
io::BufReader,
ops::{
Bound::{Included, Unbounded},
Deref,
},
path::{Path, PathBuf},
sync::Arc,
};
use thiserror::Error;
#[derive(PartialEq, Clone, Debug, AbiExample)] #[derive(PartialEq, Clone, Debug, AbiExample)]
pub enum SwitchForkDecision { pub enum SwitchForkDecision {
@@ -1357,48 +1355,46 @@ pub fn reconcile_blockstore_roots_with_tower(
#[cfg(test)] #[cfg(test)]
pub mod test { pub mod test {
use { use super::*;
super::*, use crate::{
crate::{ cluster_info_vote_listener::VoteTracker,
cluster_info_vote_listener::VoteTracker, cluster_slot_state_verifier::{DuplicateSlotsTracker, GossipDuplicateConfirmedSlots},
cluster_slot_state_verifier::{DuplicateSlotsTracker, GossipDuplicateConfirmedSlots}, cluster_slots::ClusterSlots,
cluster_slots::ClusterSlots, fork_choice::{ForkChoice, SelectVoteAndResetForkResult},
fork_choice::{ForkChoice, SelectVoteAndResetForkResult}, heaviest_subtree_fork_choice::SlotHashKey,
heaviest_subtree_fork_choice::SlotHashKey, progress_map::ForkProgress,
progress_map::ForkProgress, replay_stage::{HeaviestForkFailures, ReplayStage},
replay_stage::{HeaviestForkFailures, ReplayStage}, unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes,
unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes,
},
solana_ledger::{blockstore::make_slot_entries, get_tmp_ledger_path},
solana_runtime::{
accounts_background_service::AbsRequestSender,
bank::Bank,
bank_forks::BankForks,
genesis_utils::{
create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs,
},
},
solana_sdk::{
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
clock::Slot,
hash::Hash,
pubkey::Pubkey,
signature::Signer,
slot_history::SlotHistory,
},
solana_vote_program::{
vote_state::{Vote, VoteStateVersions, MAX_LOCKOUT_HISTORY},
vote_transaction,
},
std::{
collections::HashMap,
fs::{remove_file, OpenOptions},
io::{Read, Seek, SeekFrom, Write},
sync::RwLock,
},
tempfile::TempDir,
trees::{tr, Tree, TreeWalk},
}; };
use solana_ledger::{blockstore::make_slot_entries, get_tmp_ledger_path};
use solana_runtime::{
accounts_background_service::AbsRequestSender,
bank::Bank,
bank_forks::BankForks,
genesis_utils::{
create_genesis_config_with_vote_accounts, GenesisConfigInfo, ValidatorVoteKeypairs,
},
};
use solana_sdk::{
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
clock::Slot,
hash::Hash,
pubkey::Pubkey,
signature::Signer,
slot_history::SlotHistory,
};
use solana_vote_program::{
vote_state::{Vote, VoteStateVersions, MAX_LOCKOUT_HISTORY},
vote_transaction,
};
use std::{
collections::HashMap,
fs::{remove_file, OpenOptions},
io::{Read, Seek, SeekFrom, Write},
sync::RwLock,
};
use tempfile::TempDir;
use trees::{tr, Tree, TreeWalk};
pub(crate) struct VoteSimulator { pub(crate) struct VoteSimulator {
pub validator_keypairs: HashMap<Pubkey, ValidatorVoteKeypairs>, pub validator_keypairs: HashMap<Pubkey, ValidatorVoteKeypairs>,

View File

@@ -3,23 +3,18 @@
//! packing transactions into block; it also triggers persisting cost //! packing transactions into block; it also triggers persisting cost
//! table to blockstore. //! table to blockstore.
use { use solana_ledger::blockstore::Blockstore;
solana_ledger::blockstore::Blockstore, use solana_measure::measure::Measure;
solana_measure::measure::Measure, use solana_runtime::{bank::Bank, bank::ExecuteTimings, cost_model::CostModel};
solana_runtime::{ use solana_sdk::timing::timestamp;
bank::{Bank, ExecuteTimings}, use std::{
cost_model::CostModel, sync::{
}, atomic::{AtomicBool, Ordering},
solana_sdk::timing::timestamp, mpsc::Receiver,
std::{ Arc, RwLock,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::Receiver,
Arc, RwLock,
},
thread::{self, Builder, JoinHandle},
time::Duration,
}, },
thread::{self, Builder, JoinHandle},
time::Duration,
}; };
#[derive(Default)] #[derive(Default)]
@@ -208,7 +203,9 @@ impl CostUpdateService {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use {super::*, solana_runtime::message_processor::ProgramTiming, solana_sdk::pubkey::Pubkey}; use super::*;
use solana_runtime::message_processor::ProgramTiming;
use solana_sdk::pubkey::Pubkey;
#[test] #[test]
fn test_update_cost_model_with_empty_execute_timings() { fn test_update_cost_model_with_empty_execute_timings() {

View File

@@ -1,10 +1,8 @@
use { use solana_measure::measure::Measure;
solana_measure::measure::Measure, use solana_runtime::bank::Bank;
solana_runtime::bank::Bank, use std::{
std::{ sync::{mpsc::Receiver, Arc},
sync::{mpsc::Receiver, Arc}, thread::{self, Builder, JoinHandle},
thread::{self, Builder, JoinHandle},
},
}; };
pub struct DropBankService { pub struct DropBankService {

View File

@@ -1,25 +1,18 @@
//! The `fetch_stage` batches input from a UDP socket and sends it to a channel. //! The `fetch_stage` batches input from a UDP socket and sends it to a channel.
use { use crate::banking_stage::HOLD_TRANSACTIONS_SLOT_OFFSET;
crate::{ use crate::result::{Error, Result};
banking_stage::HOLD_TRANSACTIONS_SLOT_OFFSET, use solana_metrics::{inc_new_counter_debug, inc_new_counter_info};
result::{Error, Result}, use solana_perf::packet::PacketsRecycler;
}, use solana_perf::recycler::Recycler;
solana_metrics::{inc_new_counter_debug, inc_new_counter_info}, use solana_poh::poh_recorder::PohRecorder;
solana_perf::{packet::PacketsRecycler, recycler::Recycler}, use solana_sdk::clock::DEFAULT_TICKS_PER_SLOT;
solana_poh::poh_recorder::PohRecorder, use solana_streamer::streamer::{self, PacketReceiver, PacketSender};
solana_sdk::clock::DEFAULT_TICKS_PER_SLOT, use std::net::UdpSocket;
solana_streamer::streamer::{self, PacketReceiver, PacketSender}, use std::sync::atomic::AtomicBool;
std::{ use std::sync::mpsc::{channel, RecvTimeoutError};
net::UdpSocket, use std::sync::{Arc, Mutex};
sync::{ use std::thread::{self, Builder, JoinHandle};
atomic::AtomicBool,
mpsc::{channel, RecvTimeoutError},
Arc, Mutex,
},
thread::{self, Builder, JoinHandle},
},
};
pub struct FetchStage { pub struct FetchStage {
thread_hdls: Vec<JoinHandle<()>>, thread_hdls: Vec<JoinHandle<()>>,

View File

@@ -1,15 +1,13 @@
use { use crate::{
crate::{ consensus::{SwitchForkDecision, Tower},
consensus::{SwitchForkDecision, Tower}, latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks, progress_map::ProgressMap,
progress_map::ProgressMap, replay_stage::HeaviestForkFailures,
replay_stage::HeaviestForkFailures, };
}, use solana_runtime::{bank::Bank, bank_forks::BankForks};
solana_runtime::{bank::Bank, bank_forks::BankForks}, use std::{
std::{ collections::{HashMap, HashSet},
collections::{HashMap, HashSet}, sync::{Arc, RwLock},
sync::{Arc, RwLock},
},
}; };
pub(crate) struct SelectVoteAndResetForkResult { pub(crate) struct SelectVoteAndResetForkResult {

View File

@@ -1,11 +1,9 @@
//! The `gen_keys` module makes lots of keypairs //! The `gen_keys` module makes lots of keypairs
use { use rand::{Rng, SeedableRng};
rand::{Rng, SeedableRng}, use rand_chacha::ChaChaRng;
rand_chacha::ChaChaRng, use rayon::prelude::*;
rayon::prelude::*, use solana_sdk::signature::Keypair;
solana_sdk::signature::Keypair,
};
pub struct GenKeys { pub struct GenKeys {
generator: ChaChaRng, generator: ChaChaRng,
@@ -41,8 +39,10 @@ impl GenKeys {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*;
pub use solana_sdk::pubkey::Pubkey; pub use solana_sdk::pubkey::Pubkey;
use {super::*, solana_sdk::signature::Signer, std::collections::HashSet}; use solana_sdk::signature::Signer;
use std::collections::HashSet;
#[test] #[test]
fn test_new_key_is_deterministic() { fn test_new_key_is_deterministic() {

View File

@@ -1,26 +1,24 @@
use crate::{
consensus::Tower, fork_choice::ForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::ProgressMap, tree_diff::TreeDiff,
};
use solana_measure::measure::Measure;
use solana_runtime::{bank::Bank, bank_forks::BankForks, epoch_stakes::EpochStakes};
use solana_sdk::{
clock::{Epoch, Slot},
epoch_schedule::EpochSchedule,
hash::Hash,
pubkey::Pubkey,
};
use std::{
borrow::Borrow,
collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque},
sync::{Arc, RwLock},
time::Instant,
};
#[cfg(test)] #[cfg(test)]
use trees::{Tree, TreeWalk}; use trees::{Tree, TreeWalk};
use {
crate::{
consensus::Tower, fork_choice::ForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::ProgressMap, tree_diff::TreeDiff,
},
solana_measure::measure::Measure,
solana_runtime::{bank::Bank, bank_forks::BankForks, epoch_stakes::EpochStakes},
solana_sdk::{
clock::{Epoch, Slot},
epoch_schedule::EpochSchedule,
hash::Hash,
pubkey::Pubkey,
},
std::{
borrow::Borrow,
collections::{hash_map::Entry, BTreeMap, HashMap, HashSet, VecDeque},
sync::{Arc, RwLock},
time::Instant,
},
};
pub type ForkWeight = u64; pub type ForkWeight = u64;
pub type SlotHashKey = (Slot, Hash); pub type SlotHashKey = (Slot, Hash);
@@ -1046,14 +1044,12 @@ impl<'a> Iterator for AncestorIterator<'a> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use crate::consensus::test::VoteSimulator;
crate::consensus::test::VoteSimulator, use solana_runtime::{bank::Bank, bank_utils};
solana_runtime::{bank::Bank, bank_utils}, use solana_sdk::{hash::Hash, slot_history::SlotHistory};
solana_sdk::{hash::Hash, slot_history::SlotHistory}, use std::{collections::HashSet, ops::Range};
std::{collections::HashSet, ops::Range}, use trees::tr;
trees::tr,
};
#[test] #[test]
fn test_max_by_weight() { fn test_max_by_weight() {

View File

@@ -1,8 +1,6 @@
use { use crate::heaviest_subtree_fork_choice::SlotHashKey;
crate::heaviest_subtree_fork_choice::SlotHashKey, use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey};
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}, use std::collections::{hash_map::Entry, HashMap};
std::collections::{hash_map::Entry, HashMap},
};
#[derive(Default)] #[derive(Default)]
pub(crate) struct LatestValidatorVotesForFrozenBanks { pub(crate) struct LatestValidatorVotesForFrozenBanks {

View File

@@ -1,24 +1,17 @@
//! The `ledger_cleanup_service` drops older ledger data to limit disk space usage //! The `ledger_cleanup_service` drops older ledger data to limit disk space usage
use { use rand::{thread_rng, Rng};
rand::{thread_rng, Rng}, use solana_ledger::blockstore::{Blockstore, PurgeType};
solana_ledger::{ use solana_ledger::blockstore_db::Result as BlockstoreResult;
blockstore::{Blockstore, PurgeType}, use solana_measure::measure::Measure;
blockstore_db::Result as BlockstoreResult, use solana_sdk::clock::{Slot, DEFAULT_TICKS_PER_SLOT, TICKS_PER_DAY};
}, use std::string::ToString;
solana_measure::measure::Measure, use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
solana_sdk::clock::{Slot, DEFAULT_TICKS_PER_SLOT, TICKS_PER_DAY}, use std::sync::mpsc::{Receiver, RecvTimeoutError};
std::{ use std::sync::Arc;
string::ToString, use std::thread;
sync::{ use std::thread::{sleep, Builder, JoinHandle};
atomic::{AtomicBool, AtomicU64, Ordering}, use std::time::Duration;
mpsc::{Receiver, RecvTimeoutError},
Arc,
},
thread::{self, sleep, Builder, JoinHandle},
time::Duration,
},
};
// - To try and keep the RocksDB size under 400GB: // - To try and keep the RocksDB size under 400GB:
// Seeing about 1600b/shred, using 2000b/shred for margin, so 200m shreds can be stored in 400gb. // Seeing about 1600b/shred, using 2000b/shred for margin, so 200m shreds can be stored in 400gb.
@@ -313,11 +306,10 @@ impl LedgerCleanupService {
} }
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use solana_ledger::blockstore::make_many_slot_entries;
solana_ledger::{blockstore::make_many_slot_entries, get_tmp_ledger_path}, use solana_ledger::get_tmp_ledger_path;
std::sync::mpsc::channel, use std::sync::mpsc::channel;
};
#[test] #[test]
fn test_cleanup1() { fn test_cleanup1() {

View File

@@ -1,10 +1,8 @@
use { use crate::cluster_info_vote_listener::VoteTracker;
crate::cluster_info_vote_listener::VoteTracker, use solana_ledger::blockstore::Blockstore;
solana_ledger::blockstore::Blockstore, use solana_runtime::bank::Bank;
solana_runtime::bank::Bank, use solana_sdk::{clock::Slot, hash::Hash};
solana_sdk::{clock::Slot, hash::Hash}, use std::{collections::BTreeSet, time::Instant};
std::{collections::BTreeSet, time::Instant},
};
pub struct OptimisticConfirmationVerifier { pub struct OptimisticConfirmationVerifier {
snapshot_start_slot: Slot, snapshot_start_slot: Slot,
@@ -141,11 +139,13 @@ impl OptimisticConfirmationVerifier {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, crate::consensus::test::VoteSimulator, solana_ledger::get_tmp_ledger_path, use crate::consensus::test::VoteSimulator;
solana_runtime::bank::Bank, solana_sdk::pubkey::Pubkey, std::collections::HashMap, use solana_ledger::get_tmp_ledger_path;
trees::tr, use solana_runtime::bank::Bank;
}; use solana_sdk::pubkey::Pubkey;
use std::collections::HashMap;
use trees::tr;
#[test] #[test]
fn test_add_new_optimistic_confirmed_slots() { fn test_add_new_optimistic_confirmed_slots() {

View File

@@ -1,9 +1,7 @@
use { use crate::request_response::RequestResponse;
crate::request_response::RequestResponse, use lru::LruCache;
lru::LruCache, use rand::{thread_rng, Rng};
rand::{thread_rng, Rng}, use solana_ledger::shred::Nonce;
solana_ledger::shred::Nonce,
};
pub const DEFAULT_REQUEST_EXPIRATION_MS: u64 = 60_000; pub const DEFAULT_REQUEST_EXPIRATION_MS: u64 = 60_000;
@@ -74,10 +72,10 @@ pub struct RequestStatus<T> {
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use { use super::*;
super::*, crate::serve_repair::RepairType, solana_ledger::shred::Shred, use crate::serve_repair::RepairType;
solana_sdk::timing::timestamp, use solana_ledger::shred::Shred;
}; use solana_sdk::timing::timestamp;
#[test] #[test]
fn test_add_request() { fn test_add_request() {

View File

@@ -1,17 +1,15 @@
use { use crate::{
crate::{ cluster_info_vote_listener::SlotVoteTracker,
cluster_info_vote_listener::SlotVoteTracker, cluster_slots::SlotPubkeys,
cluster_slots::SlotPubkeys, replay_stage::SUPERMINORITY_THRESHOLD,
consensus::{Stake, VotedStakes}, {consensus::Stake, consensus::VotedStakes},
replay_stage::SUPERMINORITY_THRESHOLD, };
}, use solana_ledger::blockstore_processor::{ConfirmationProgress, ConfirmationTiming};
solana_ledger::blockstore_processor::{ConfirmationProgress, ConfirmationTiming}, use solana_runtime::{bank::Bank, bank_forks::BankForks, vote_account::ArcVoteAccount};
solana_runtime::{bank::Bank, bank_forks::BankForks, vote_account::ArcVoteAccount}, use solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey};
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey}, use std::{
std::{ collections::{BTreeMap, HashMap, HashSet},
collections::{BTreeMap, HashMap, HashSet}, sync::{Arc, RwLock},
sync::{Arc, RwLock},
},
}; };
type VotedSlot = Slot; type VotedSlot = Slot;

View File

@@ -1,12 +1,10 @@
use { use solana_ledger::{
solana_ledger::{ blockstore::Blockstore,
blockstore::Blockstore, shred::{Nonce, SIZE_OF_NONCE},
shred::{Nonce, SIZE_OF_NONCE},
},
solana_perf::packet::limited_deserialize,
solana_sdk::{clock::Slot, packet::Packet},
std::{io, net::SocketAddr},
}; };
use solana_perf::packet::limited_deserialize;
use solana_sdk::{clock::Slot, packet::Packet};
use std::{io, net::SocketAddr};
pub fn repair_response_packet( pub fn repair_response_packet(
blockstore: &Blockstore, blockstore: &Blockstore,
@@ -50,17 +48,15 @@ pub fn nonce(buf: &[u8]) -> Option<Nonce> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use solana_ledger::{
solana_ledger::{ shred::{Shred, Shredder},
shred::{Shred, Shredder}, sigverify_shreds::verify_shred_cpu,
sigverify_shreds::verify_shred_cpu, };
}, use solana_sdk::signature::{Keypair, Signer};
solana_sdk::signature::{Keypair, Signer}, use std::{
std::{ collections::HashMap,
collections::HashMap, net::{IpAddr, Ipv4Addr},
net::{IpAddr, Ipv4Addr},
},
}; };
fn run_test_sigverify_shred_cpu_repair(slot: Slot) { fn run_test_sigverify_shred_cpu_repair(slot: Slot) {

View File

@@ -1,42 +1,40 @@
//! The `repair_service` module implements the tools necessary to generate a thread which //! The `repair_service` module implements the tools necessary to generate a thread which
//! regularly finds missing shreds in the ledger and sends repair requests for those shreds //! regularly finds missing shreds in the ledger and sends repair requests for those shreds
use { use crate::{
crate::{ cluster_info_vote_listener::VerifiedVoteReceiver,
cluster_info_vote_listener::VerifiedVoteReceiver, cluster_slots::ClusterSlots,
cluster_slots::ClusterSlots, outstanding_requests::OutstandingRequests,
outstanding_requests::OutstandingRequests, repair_weight::RepairWeight,
repair_weight::RepairWeight, replay_stage::DUPLICATE_THRESHOLD,
replay_stage::DUPLICATE_THRESHOLD, result::Result,
result::Result, serve_repair::{RepairType, ServeRepair, REPAIR_PEERS_CACHE_CAPACITY},
serve_repair::{RepairType, ServeRepair, REPAIR_PEERS_CACHE_CAPACITY}, };
}, use crossbeam_channel::{Receiver as CrossbeamReceiver, Sender as CrossbeamSender};
crossbeam_channel::{Receiver as CrossbeamReceiver, Sender as CrossbeamSender}, use lru::LruCache;
lru::LruCache, use solana_gossip::cluster_info::ClusterInfo;
solana_gossip::cluster_info::ClusterInfo, use solana_ledger::{
solana_ledger::{ blockstore::{Blockstore, SlotMeta},
blockstore::{Blockstore, SlotMeta}, shred::Nonce,
shred::Nonce, };
}, use solana_measure::measure::Measure;
solana_measure::measure::Measure, use solana_runtime::{bank::Bank, bank_forks::BankForks, contains::Contains};
solana_runtime::{bank::Bank, bank_forks::BankForks, contains::Contains}, use solana_sdk::{
solana_sdk::{ clock::{BankId, Slot},
clock::{BankId, Slot}, epoch_schedule::EpochSchedule,
epoch_schedule::EpochSchedule, pubkey::Pubkey,
pubkey::Pubkey, timing::timestamp,
timing::timestamp, };
}, use solana_streamer::sendmmsg::{batch_send, SendPktsError};
solana_streamer::sendmmsg::{batch_send, SendPktsError}, use std::{
std::{ collections::{HashMap, HashSet},
collections::{HashMap, HashSet}, iter::Iterator,
iter::Iterator, net::SocketAddr,
net::{SocketAddr, UdpSocket}, net::UdpSocket,
sync::{ sync::atomic::{AtomicBool, Ordering},
atomic::{AtomicBool, Ordering}, sync::{Arc, RwLock},
Arc, RwLock, thread::sleep,
}, thread::{self, Builder, JoinHandle},
thread::{self, sleep, Builder, JoinHandle}, time::{Duration, Instant},
time::{Duration, Instant},
},
}; };
pub type DuplicateSlotsResetSender = CrossbeamSender<Slot>; pub type DuplicateSlotsResetSender = CrossbeamSender<Slot>;
@@ -713,23 +711,20 @@ impl RepairService {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use crossbeam_channel::unbounded;
crossbeam_channel::unbounded, use solana_gossip::{cluster_info::Node, contact_info::ContactInfo};
solana_gossip::{cluster_info::Node, contact_info::ContactInfo}, use solana_ledger::blockstore::{
solana_ledger::{ make_chaining_slot_entries, make_many_slot_entries, make_slot_entries,
blockstore::{
make_chaining_slot_entries, make_many_slot_entries, make_slot_entries, Blockstore,
},
get_tmp_ledger_path,
shred::max_ticks_per_n_shreds,
},
solana_runtime::genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs},
solana_sdk::signature::{Keypair, Signer},
solana_streamer::socket::SocketAddrSpace,
solana_vote_program::vote_transaction,
std::collections::HashSet,
}; };
use solana_ledger::shred::max_ticks_per_n_shreds;
use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path};
use solana_runtime::genesis_utils::{self, GenesisConfigInfo, ValidatorVoteKeypairs};
use solana_sdk::signature::Keypair;
use solana_sdk::signature::Signer;
use solana_streamer::socket::SocketAddrSpace;
use solana_vote_program::vote_transaction;
use std::collections::HashSet;
fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo { fn new_test_cluster_info(contact_info: ContactInfo) -> ClusterInfo {
ClusterInfo::new( ClusterInfo::new(

View File

@@ -1,19 +1,17 @@
use { use crate::{
crate::{ heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairTiming,
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairTiming, repair_weighted_traversal, serve_repair::RepairType, tree_diff::TreeDiff,
repair_weighted_traversal, serve_repair::RepairType, tree_diff::TreeDiff,
},
solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore},
solana_measure::measure::Measure,
solana_runtime::{contains::Contains, epoch_stakes::EpochStakes},
solana_sdk::{
clock::Slot,
epoch_schedule::{Epoch, EpochSchedule},
hash::Hash,
pubkey::Pubkey,
},
std::collections::{BTreeSet, HashMap, HashSet, VecDeque},
}; };
use solana_ledger::{ancestor_iterator::AncestorIterator, blockstore::Blockstore};
use solana_measure::measure::Measure;
use solana_runtime::{contains::Contains, epoch_stakes::EpochStakes};
use solana_sdk::{
clock::Slot,
epoch_schedule::{Epoch, EpochSchedule},
hash::Hash,
pubkey::Pubkey,
};
use std::collections::{BTreeSet, HashMap, HashSet, VecDeque};
pub struct RepairWeight { pub struct RepairWeight {
// Map from root -> a subtree rooted at that `root` // Map from root -> a subtree rooted at that `root`
@@ -533,13 +531,11 @@ impl RepairWeight {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use { use super::*;
super::*, use solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path};
solana_ledger::{blockstore::Blockstore, get_tmp_ledger_path}, use solana_runtime::{bank::Bank, bank_utils};
solana_runtime::{bank::Bank, bank_utils}, use solana_sdk::hash::Hash;
solana_sdk::hash::Hash, use trees::tr;
trees::tr,
};
#[test] #[test]
fn test_sort_by_stake_weight_slot() { fn test_sort_by_stake_weight_slot() {

View File

@@ -1,13 +1,11 @@
use { use crate::{
crate::{ heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairService,
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice, repair_service::RepairService, serve_repair::RepairType, tree_diff::TreeDiff,
serve_repair::RepairType, tree_diff::TreeDiff,
},
solana_ledger::blockstore::Blockstore,
solana_runtime::contains::Contains,
solana_sdk::{clock::Slot, hash::Hash},
std::collections::{HashMap, HashSet},
}; };
use solana_ledger::blockstore::Blockstore;
use solana_runtime::contains::Contains;
use solana_sdk::{clock::Slot, hash::Hash};
use std::collections::{HashMap, HashSet};
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
enum Visit { enum Visit {
@@ -138,13 +136,11 @@ pub fn get_best_repair_shreds<'a>(
#[cfg(test)] #[cfg(test)]
pub mod test { pub mod test {
use { use super::*;
super::*, use solana_ledger::{get_tmp_ledger_path, shred::Shred};
solana_ledger::{get_tmp_ledger_path, shred::Shred}, use solana_runtime::bank_utils;
solana_runtime::bank_utils, use solana_sdk::hash::Hash;
solana_sdk::hash::Hash, use trees::tr;
trees::tr,
};
#[test] #[test]
fn test_weighted_repair_traversal_single() { fn test_weighted_repair_traversal_single() {

View File

@@ -1,74 +1,73 @@
//! The `replay_stage` replays transactions broadcast by the leader. //! The `replay_stage` replays transactions broadcast by the leader.
use { use crate::{
crate::{ broadcast_stage::RetransmitSlotsSender,
broadcast_stage::RetransmitSlotsSender, cache_block_meta_service::CacheBlockMetaSender,
cache_block_meta_service::CacheBlockMetaSender, cluster_info_vote_listener::{
cluster_info_vote_listener::{ GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, VoteTracker,
GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, VoteTracker,
},
cluster_slot_state_verifier::*,
cluster_slots::ClusterSlots,
cluster_slots_service::ClusterSlotsUpdateSender,
commitment_service::{AggregateCommitmentService, CommitmentAggregationData},
consensus::{
ComputedBankState, Stake, SwitchForkDecision, Tower, VotedStakes, SWITCH_FORK_THRESHOLD,
},
cost_update_service::CostUpdate,
fork_choice::{ForkChoice, SelectVoteAndResetForkResult},
heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
progress_map::{ForkProgress, ProgressMap, PropagatedStats},
repair_service::DuplicateSlotsResetReceiver,
rewards_recorder_service::RewardsRecorderSender,
unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes,
voting_service::VoteOp,
window_service::DuplicateSlotReceiver,
}, },
solana_client::rpc_response::SlotUpdate, cluster_slot_state_verifier::*,
solana_gossip::cluster_info::ClusterInfo, cluster_slots::ClusterSlots,
solana_ledger::{ cluster_slots_service::ClusterSlotsUpdateSender,
block_error::BlockError, commitment_service::{AggregateCommitmentService, CommitmentAggregationData},
blockstore::Blockstore, consensus::{
blockstore_processor::{self, BlockstoreProcessorError, TransactionStatusSender}, ComputedBankState, Stake, SwitchForkDecision, Tower, VotedStakes, SWITCH_FORK_THRESHOLD,
entry::VerifyRecyclers,
leader_schedule_cache::LeaderScheduleCache,
}, },
solana_measure::measure::Measure, cost_update_service::CostUpdate,
solana_metrics::inc_new_counter_info, fork_choice::{ForkChoice, SelectVoteAndResetForkResult},
solana_poh::poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS}, heaviest_subtree_fork_choice::HeaviestSubtreeForkChoice,
solana_rpc::{ latest_validator_votes_for_frozen_banks::LatestValidatorVotesForFrozenBanks,
optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender}, progress_map::{ForkProgress, ProgressMap, PropagatedStats},
rpc_subscriptions::RpcSubscriptions, repair_service::DuplicateSlotsResetReceiver,
}, rewards_recorder_service::RewardsRecorderSender,
solana_runtime::{ unfrozen_gossip_verified_vote_hashes::UnfrozenGossipVerifiedVoteHashes,
accounts_background_service::AbsRequestSender, voting_service::VoteOp,
bank::{Bank, ExecuteTimings, NewBankOptions}, window_service::DuplicateSlotReceiver,
bank_forks::BankForks, };
commitment::BlockCommitmentCache, use solana_client::rpc_response::SlotUpdate;
vote_sender_types::ReplayVoteSender, use solana_gossip::cluster_info::ClusterInfo;
}, use solana_ledger::{
solana_sdk::{ block_error::BlockError,
clock::{Slot, MAX_PROCESSING_AGE, NUM_CONSECUTIVE_LEADER_SLOTS}, blockstore::Blockstore,
genesis_config::ClusterType, blockstore_processor::{self, BlockstoreProcessorError, TransactionStatusSender},
hash::Hash, entry::VerifyRecyclers,
pubkey::Pubkey, leader_schedule_cache::LeaderScheduleCache,
signature::{Keypair, Signature, Signer}, };
timing::timestamp, use solana_measure::measure::Measure;
transaction::Transaction, use solana_metrics::inc_new_counter_info;
}, use solana_poh::poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS};
solana_vote_program::vote_state::Vote, use solana_rpc::{
std::{ optimistically_confirmed_bank_tracker::{BankNotification, BankNotificationSender},
collections::{BTreeMap, HashMap, HashSet}, rpc_subscriptions::RpcSubscriptions,
result, };
sync::{ use solana_runtime::{
atomic::{AtomicBool, Ordering}, accounts_background_service::AbsRequestSender,
mpsc::{Receiver, RecvTimeoutError, Sender}, bank::{Bank, ExecuteTimings, NewBankOptions},
Arc, Mutex, RwLock, bank_forks::BankForks,
}, commitment::BlockCommitmentCache,
thread::{self, Builder, JoinHandle}, vote_sender_types::ReplayVoteSender,
time::{Duration, Instant}, };
use solana_sdk::{
clock::{Slot, MAX_PROCESSING_AGE, NUM_CONSECUTIVE_LEADER_SLOTS},
genesis_config::ClusterType,
hash::Hash,
pubkey::Pubkey,
signature::Signature,
signature::{Keypair, Signer},
timing::timestamp,
transaction::Transaction,
};
use solana_vote_program::vote_state::Vote;
use std::{
collections::{BTreeMap, HashMap, HashSet},
result,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::{Receiver, RecvTimeoutError, Sender},
Arc, Mutex, RwLock,
}, },
thread::{self, Builder, JoinHandle},
time::{Duration, Instant},
}; };
pub const MAX_ENTRY_RECV_PER_ITER: usize = 512; pub const MAX_ENTRY_RECV_PER_ITER: usize = 512;
@@ -2562,62 +2561,60 @@ impl ReplayStage {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use super::*;
super::*, use crate::{
crate::{ consensus::test::{initialize_state, VoteSimulator},
consensus::{ consensus::Tower,
test::{initialize_state, VoteSimulator}, progress_map::ValidatorStakeInfo,
Tower, replay_stage::ReplayStage,
},
progress_map::ValidatorStakeInfo,
replay_stage::ReplayStage,
},
crossbeam_channel::unbounded,
solana_gossip::{cluster_info::Node, crds::Cursor},
solana_ledger::{
blockstore::{entries_to_test_shreds, make_slot_entries, BlockstoreError},
create_new_tmp_ledger,
entry::{self, Entry},
genesis_utils::{create_genesis_config, create_genesis_config_with_leader},
get_tmp_ledger_path,
shred::{
CodingShredHeader, DataShredHeader, Shred, ShredCommonHeader, DATA_COMPLETE_SHRED,
SIZE_OF_COMMON_SHRED_HEADER, SIZE_OF_DATA_SHRED_HEADER, SIZE_OF_DATA_SHRED_PAYLOAD,
},
},
solana_rpc::{
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
rpc::create_test_transactions_and_populate_blockstore,
},
solana_runtime::{
accounts_background_service::AbsRequestSender,
commitment::BlockCommitment,
genesis_utils::{GenesisConfigInfo, ValidatorVoteKeypairs},
},
solana_sdk::{
clock::NUM_CONSECUTIVE_LEADER_SLOTS,
genesis_config,
hash::{hash, Hash},
instruction::InstructionError,
packet::PACKET_DATA_SIZE,
poh_config::PohConfig,
signature::{Keypair, Signer},
system_transaction,
transaction::TransactionError,
},
solana_streamer::socket::SocketAddrSpace,
solana_transaction_status::TransactionWithStatusMeta,
solana_vote_program::{
vote_state::{VoteState, VoteStateVersions},
vote_transaction,
},
std::{
fs::remove_dir_all,
iter,
sync::{atomic::AtomicU64, mpsc::channel, Arc, RwLock},
},
trees::{tr, Tree},
}; };
use crossbeam_channel::unbounded;
use solana_gossip::{cluster_info::Node, crds::Cursor};
use solana_ledger::{
blockstore::make_slot_entries,
blockstore::{entries_to_test_shreds, BlockstoreError},
create_new_tmp_ledger,
entry::{self, Entry},
genesis_utils::{create_genesis_config, create_genesis_config_with_leader},
get_tmp_ledger_path,
shred::{
CodingShredHeader, DataShredHeader, Shred, ShredCommonHeader, DATA_COMPLETE_SHRED,
SIZE_OF_COMMON_SHRED_HEADER, SIZE_OF_DATA_SHRED_HEADER, SIZE_OF_DATA_SHRED_PAYLOAD,
},
};
use solana_rpc::{
optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank,
rpc::create_test_transactions_and_populate_blockstore,
};
use solana_runtime::{
accounts_background_service::AbsRequestSender,
commitment::BlockCommitment,
genesis_utils::{GenesisConfigInfo, ValidatorVoteKeypairs},
};
use solana_sdk::{
clock::NUM_CONSECUTIVE_LEADER_SLOTS,
genesis_config,
hash::{hash, Hash},
instruction::InstructionError,
packet::PACKET_DATA_SIZE,
poh_config::PohConfig,
signature::{Keypair, Signer},
system_transaction,
transaction::TransactionError,
};
use solana_streamer::socket::SocketAddrSpace;
use solana_transaction_status::TransactionWithStatusMeta;
use solana_vote_program::{
vote_state::{VoteState, VoteStateVersions},
vote_transaction,
};
use std::sync::mpsc::channel;
use std::{
fs::remove_dir_all,
iter,
sync::{atomic::AtomicU64, Arc, RwLock},
};
use trees::{tr, Tree};
#[test] #[test]
fn test_is_partition_detected() { fn test_is_partition_detected() {

View File

@@ -1,9 +1,7 @@
//! The `result` module exposes a Result type that propagates one of many different Error types. //! The `result` module exposes a Result type that propagates one of many different Error types.
use { use solana_gossip::{cluster_info, gossip_error::GossipError};
solana_gossip::{cluster_info, gossip_error::GossipError}, use solana_ledger::blockstore;
solana_ledger::blockstore,
};
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
@@ -100,15 +98,14 @@ impl std::convert::From<GossipError> for Error {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use { use crate::result::Error;
crate::result::{Error, Result}, use crate::result::Result;
std::{ use std::io;
io, use std::io::Write;
io::Write, use std::panic;
panic, use std::sync::mpsc::channel;
sync::mpsc::{channel, RecvError, RecvTimeoutError}, use std::sync::mpsc::RecvError;
}, use std::sync::mpsc::RecvTimeoutError;
};
fn send_error() -> Result<()> { fn send_error() -> Result<()> {
let (s, r) = channel(); let (s, r) = channel();

Some files were not shown because too many files have changed in this diff Show More