Move gossip modules into solana-gossip crate (#17352)

* Move gossip modules to solana-gossip

* Update Protocol abi digest due to move

* Move gossip benches and hook up CI

* Remove unneeded Result entries

* Single use statements
This commit is contained in:
Tyera Eulberg
2021-05-26 09:15:46 -06:00
committed by GitHub
parent 752cd7d15e
commit 9a5330b7eb
80 changed files with 846 additions and 702 deletions

39
Cargo.lock generated
View File

@ -3929,6 +3929,7 @@ dependencies = [
"solana-client", "solana-client",
"solana-core", "solana-core",
"solana-faucet", "solana-faucet",
"solana-gossip",
"solana-local-cluster", "solana-local-cluster",
"solana-logger 1.7.0", "solana-logger 1.7.0",
"solana-measure", "solana-measure",
@ -3951,6 +3952,7 @@ dependencies = [
"rayon", "rayon",
"solana-clap-utils", "solana-clap-utils",
"solana-core", "solana-core",
"solana-gossip",
"solana-ledger", "solana-ledger",
"solana-logger 1.7.0", "solana-logger 1.7.0",
"solana-measure", "solana-measure",
@ -4028,6 +4030,7 @@ dependencies = [
"solana-exchange-program", "solana-exchange-program",
"solana-faucet", "solana-faucet",
"solana-genesis", "solana-genesis",
"solana-gossip",
"solana-local-cluster", "solana-local-cluster",
"solana-logger 1.7.0", "solana-logger 1.7.0",
"solana-metrics", "solana-metrics",
@ -4065,6 +4068,7 @@ dependencies = [
"solana-core", "solana-core",
"solana-faucet", "solana-faucet",
"solana-genesis", "solana-genesis",
"solana-gossip",
"solana-local-cluster", "solana-local-cluster",
"solana-logger 1.7.0", "solana-logger 1.7.0",
"solana-measure", "solana-measure",
@ -4331,6 +4335,7 @@ dependencies = [
"solana-faucet", "solana-faucet",
"solana-frozen-abi 1.7.0", "solana-frozen-abi 1.7.0",
"solana-frozen-abi-macro 1.7.0", "solana-frozen-abi-macro 1.7.0",
"solana-gossip",
"solana-ledger", "solana-ledger",
"solana-logger 1.7.0", "solana-logger 1.7.0",
"solana-measure", "solana-measure",
@ -4396,6 +4401,7 @@ dependencies = [
"solana-clap-utils", "solana-clap-utils",
"solana-client", "solana-client",
"solana-core", "solana-core",
"solana-gossip",
"solana-ledger", "solana-ledger",
"solana-logger 1.7.0", "solana-logger 1.7.0",
"solana-net-utils", "solana-net-utils",
@ -4562,13 +4568,42 @@ dependencies = [
name = "solana-gossip" name = "solana-gossip"
version = "1.7.0" version = "1.7.0"
dependencies = [ dependencies = [
"bincode",
"bv",
"clap", "clap",
"flate2",
"indexmap",
"itertools",
"log 0.4.11",
"lru",
"matches",
"num-traits",
"num_cpus",
"rand 0.7.3",
"rand_chacha 0.2.2",
"rayon",
"rustc_version",
"serde",
"serde_bytes",
"serde_derive",
"serial_test",
"solana-clap-utils", "solana-clap-utils",
"solana-core", "solana-client",
"solana-frozen-abi 1.7.0",
"solana-frozen-abi-macro 1.7.0",
"solana-ledger",
"solana-logger 1.7.0", "solana-logger 1.7.0",
"solana-measure",
"solana-metrics",
"solana-net-utils", "solana-net-utils",
"solana-perf",
"solana-rayon-threadlimit",
"solana-runtime",
"solana-sdk", "solana-sdk",
"solana-streamer",
"solana-version", "solana-version",
"solana-vote-program",
"thiserror",
] ]
[[package]] [[package]]
@ -4731,6 +4766,7 @@ dependencies = [
"solana-download-utils", "solana-download-utils",
"solana-exchange-program", "solana-exchange-program",
"solana-faucet", "solana-faucet",
"solana-gossip",
"solana-ledger", "solana-ledger",
"solana-logger 1.7.0", "solana-logger 1.7.0",
"solana-rayon-threadlimit", "solana-rayon-threadlimit",
@ -5452,6 +5488,7 @@ dependencies = [
"solana-download-utils", "solana-download-utils",
"solana-faucet", "solana-faucet",
"solana-genesis-utils", "solana-genesis-utils",
"solana-gossip",
"solana-ledger", "solana-ledger",
"solana-logger 1.7.0", "solana-logger 1.7.0",
"solana-metrics", "solana-metrics",

View File

@ -17,10 +17,11 @@ solana-account-decoder = { path = "../account-decoder", version = "=1.7.0" }
solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" } solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" }
solana-client = { path = "../client", version = "=1.7.0" } solana-client = { path = "../client", version = "=1.7.0" }
solana-core = { path = "../core", version = "=1.7.0" } solana-core = { path = "../core", version = "=1.7.0" }
solana-measure = { path = "../measure", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" }
solana-net-utils = { path = "../net-utils", version = "=1.7.0" }
solana-faucet = { path = "../faucet", version = "=1.7.0" } solana-faucet = { path = "../faucet", version = "=1.7.0" }
solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" }
solana-measure = { path = "../measure", version = "=1.7.0" }
solana-net-utils = { path = "../net-utils", version = "=1.7.0" }
solana-runtime = { path = "../runtime", version = "=1.7.0" } solana-runtime = { path = "../runtime", version = "=1.7.0" }
solana-sdk = { path = "../sdk", version = "=1.7.0" } solana-sdk = { path = "../sdk", version = "=1.7.0" }
solana-transaction-status = { path = "../transaction-status", version = "=1.7.0" } solana-transaction-status = { path = "../transaction-status", version = "=1.7.0" }

View File

@ -6,8 +6,8 @@ use rayon::prelude::*;
use solana_account_decoder::parse_token::spl_token_v2_0_pubkey; use solana_account_decoder::parse_token::spl_token_v2_0_pubkey;
use solana_clap_utils::input_parsers::pubkey_of; use solana_clap_utils::input_parsers::pubkey_of;
use solana_client::rpc_client::RpcClient; use solana_client::rpc_client::RpcClient;
use solana_core::gossip_service::discover;
use solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT}; use solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT};
use solana_gossip::gossip_service::discover;
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_runtime::inline_spl_token_v2_0; use solana_runtime::inline_spl_token_v2_0;
use solana_sdk::{ use solana_sdk::{

View File

@ -16,12 +16,13 @@ rand = "0.7.0"
rayon = "1.5.0" rayon = "1.5.0"
solana-core = { path = "../core", version = "=1.7.0" } solana-core = { path = "../core", version = "=1.7.0" }
solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" } solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" }
solana-streamer = { path = "../streamer", version = "=1.7.0" } solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-perf = { path = "../perf", version = "=1.7.0" }
solana-ledger = { path = "../ledger", version = "=1.7.0" } solana-ledger = { path = "../ledger", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" } solana-logger = { path = "../logger", version = "=1.7.0" }
solana-runtime = { path = "../runtime", version = "=1.7.0" }
solana-measure = { path = "../measure", version = "=1.7.0" } solana-measure = { path = "../measure", version = "=1.7.0" }
solana-perf = { path = "../perf", version = "=1.7.0" }
solana-runtime = { path = "../runtime", version = "=1.7.0" }
solana-streamer = { path = "../streamer", version = "=1.7.0" }
solana-sdk = { path = "../sdk", version = "=1.7.0" } solana-sdk = { path = "../sdk", version = "=1.7.0" }
solana-version = { path = "../version", version = "=1.7.0" } solana-version = { path = "../version", version = "=1.7.0" }

View File

@ -6,11 +6,10 @@ use rand::{thread_rng, Rng};
use rayon::prelude::*; use rayon::prelude::*;
use solana_core::{ use solana_core::{
banking_stage::{create_test_recorder, BankingStage}, banking_stage::{create_test_recorder, BankingStage},
cluster_info::ClusterInfo,
cluster_info::Node,
poh_recorder::PohRecorder, poh_recorder::PohRecorder,
poh_recorder::WorkingBankEntry, poh_recorder::WorkingBankEntry,
}; };
use solana_gossip::{cluster_info::ClusterInfo, cluster_info::Node};
use solana_ledger::{ use solana_ledger::{
blockstore::Blockstore, blockstore::Blockstore,
genesis_utils::{create_genesis_config, GenesisConfigInfo}, genesis_utils::{create_genesis_config, GenesisConfigInfo},

View File

@ -22,8 +22,9 @@ solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" }
solana-core = { path = "../core", version = "=1.7.0" } solana-core = { path = "../core", version = "=1.7.0" }
solana-genesis = { path = "../genesis", version = "=1.7.0" } solana-genesis = { path = "../genesis", version = "=1.7.0" }
solana-client = { path = "../client", version = "=1.7.0" } solana-client = { path = "../client", version = "=1.7.0" }
solana-faucet = { path = "../faucet", version = "=1.7.0" }
solana-exchange-program = { path = "../programs/exchange", version = "=1.7.0" } solana-exchange-program = { path = "../programs/exchange", version = "=1.7.0" }
solana-faucet = { path = "../faucet", version = "=1.7.0" }
solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" } solana-logger = { path = "../logger", version = "=1.7.0" }
solana-metrics = { path = "../metrics", version = "=1.7.0" } solana-metrics = { path = "../metrics", version = "=1.7.0" }
solana-net-utils = { path = "../net-utils", version = "=1.7.0" } solana-net-utils = { path = "../net-utils", version = "=1.7.0" }

View File

@ -5,7 +5,7 @@ pub mod order_book;
use crate::bench::{airdrop_lamports, create_client_accounts_file, do_bench_exchange, Config}; use crate::bench::{airdrop_lamports, create_client_accounts_file, do_bench_exchange, Config};
use log::*; use log::*;
use solana_core::gossip_service::{discover_cluster, get_multi_client}; use solana_gossip::gossip_service::{discover_cluster, get_multi_client};
use solana_sdk::signature::Signer; use solana_sdk::signature::Signer;
fn main() { fn main() {

View File

@ -1,13 +1,11 @@
use log::*; use log::*;
use solana_bench_exchange::bench::{airdrop_lamports, do_bench_exchange, Config}; use solana_bench_exchange::bench::{airdrop_lamports, do_bench_exchange, Config};
use solana_core::{ use solana_core::validator::ValidatorConfig;
gossip_service::{discover_cluster, get_multi_client},
validator::ValidatorConfig,
};
use solana_exchange_program::{ use solana_exchange_program::{
exchange_processor::process_instruction, id, solana_exchange_program, exchange_processor::process_instruction, id, solana_exchange_program,
}; };
use solana_faucet::faucet::run_local_faucet_with_port; use solana_faucet::faucet::run_local_faucet_with_port;
use solana_gossip::gossip_service::{discover_cluster, get_multi_client};
use solana_local_cluster::{ use solana_local_cluster::{
local_cluster::{ClusterConfig, LocalCluster}, local_cluster::{ClusterConfig, LocalCluster},
validator_configs::make_identical_validator_configs, validator_configs::make_identical_validator_configs,

View File

@ -20,6 +20,7 @@ solana-core = { path = "../core", version = "=1.7.0" }
solana-genesis = { path = "../genesis", version = "=1.7.0" } solana-genesis = { path = "../genesis", version = "=1.7.0" }
solana-client = { path = "../client", version = "=1.7.0" } solana-client = { path = "../client", version = "=1.7.0" }
solana-faucet = { path = "../faucet", version = "=1.7.0" } solana-faucet = { path = "../faucet", version = "=1.7.0" }
solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" } solana-logger = { path = "../logger", version = "=1.7.0" }
solana-metrics = { path = "../metrics", version = "=1.7.0" } solana-metrics = { path = "../metrics", version = "=1.7.0" }
solana-measure = { path = "../measure", version = "=1.7.0" } solana-measure = { path = "../measure", version = "=1.7.0" }

View File

@ -2,8 +2,8 @@
use log::*; use log::*;
use solana_bench_tps::bench::{do_bench_tps, generate_and_fund_keypairs, generate_keypairs}; use solana_bench_tps::bench::{do_bench_tps, generate_and_fund_keypairs, generate_keypairs};
use solana_bench_tps::cli; use solana_bench_tps::cli;
use solana_core::gossip_service::{discover_cluster, get_client, get_multi_client};
use solana_genesis::Base64Account; use solana_genesis::Base64Account;
use solana_gossip::gossip_service::{discover_cluster, get_client, get_multi_client};
use solana_sdk::fee_calculator::FeeRateGovernor; use solana_sdk::fee_calculator::FeeRateGovernor;
use solana_sdk::signature::{Keypair, Signer}; use solana_sdk::signature::{Keypair, Signer};
use solana_sdk::system_program; use solana_sdk::system_program;

View File

@ -5,8 +5,9 @@ use solana_bench_tps::{
cli::Config, cli::Config,
}; };
use solana_client::thin_client::create_client; use solana_client::thin_client::create_client;
use solana_core::{cluster_info::VALIDATOR_PORT_RANGE, validator::ValidatorConfig}; use solana_core::validator::ValidatorConfig;
use solana_faucet::faucet::run_local_faucet_with_port; use solana_faucet::faucet::run_local_faucet_with_port;
use solana_gossip::cluster_info::VALIDATOR_PORT_RANGE;
use solana_local_cluster::{ use solana_local_cluster::{
local_cluster::{ClusterConfig, LocalCluster}, local_cluster::{ClusterConfig, LocalCluster},
validator_configs::make_identical_validator_configs, validator_configs::make_identical_validator_configs,

View File

@ -27,7 +27,7 @@ BENCH_ARTIFACT=current_bench_results.log
_ "$cargo" build --manifest-path=keygen/Cargo.toml _ "$cargo" build --manifest-path=keygen/Cargo.toml
export PATH="$PWD/target/debug":$PATH export PATH="$PWD/target/debug":$PATH
# Clear the C dependency files, if dependeny moves these files are not regenerated # Clear the C dependency files, if dependency moves these files are not regenerated
test -d target/debug/bpf && find target/debug/bpf -name '*.d' -delete test -d target/debug/bpf && find target/debug/bpf -name '*.d' -delete
test -d target/release/bpf && find target/release/bpf -name '*.d' -delete test -d target/release/bpf && find target/release/bpf -name '*.d' -delete
@ -45,6 +45,10 @@ _ "$cargo" nightly bench --manifest-path sdk/Cargo.toml ${V:+--verbose} \
_ "$cargo" nightly bench --manifest-path runtime/Cargo.toml ${V:+--verbose} \ _ "$cargo" nightly bench --manifest-path runtime/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE" -- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
# Run gossip benches
_ "$cargo" nightly bench --manifest-path gossip/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE"
# Run core benches # Run core benches
_ "$cargo" nightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \ _ "$cargo" nightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \
-- -Z unstable-options --format=json | tee -a "$BENCH_FILE" -- -Z unstable-options --format=json | tee -a "$BENCH_FILE"

View File

@ -55,6 +55,7 @@ solana-banks-server = { path = "../banks-server", version = "=1.7.0" }
solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" } solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" }
solana-client = { path = "../client", version = "=1.7.0" } solana-client = { path = "../client", version = "=1.7.0" }
solana-faucet = { path = "../faucet", version = "=1.7.0" } solana-faucet = { path = "../faucet", version = "=1.7.0" }
solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-ledger = { path = "../ledger", version = "=1.7.0" } solana-ledger = { path = "../ledger", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" } solana-logger = { path = "../logger", version = "=1.7.0" }
solana-merkle-tree = { path = "../merkle-tree", version = "=1.7.0" } solana-merkle-tree = { path = "../merkle-tree", version = "=1.7.0" }
@ -102,13 +103,7 @@ name = "banking_stage"
name = "blockstore" name = "blockstore"
[[bench]] [[bench]]
name = "crds" name = "cluster_info"
[[bench]]
name = "crds_gossip_pull"
[[bench]]
name = "crds_shards"
[[bench]] [[bench]]
name = "gen_keys" name = "gen_keys"
@ -122,8 +117,5 @@ name = "poh"
[[bench]] [[bench]]
name = "retransmit_stage" name = "retransmit_stage"
[[bench]]
name = "cluster_info"
[package.metadata.docs.rs] [package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"] targets = ["x86_64-unknown-linux-gnu"]

View File

@ -8,9 +8,9 @@ use log::*;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use rayon::prelude::*; use rayon::prelude::*;
use solana_core::banking_stage::{create_test_recorder, BankingStage, BankingStageStats}; use solana_core::banking_stage::{create_test_recorder, BankingStage, BankingStageStats};
use solana_core::cluster_info::ClusterInfo;
use solana_core::cluster_info::Node;
use solana_core::poh_recorder::WorkingBankEntry; use solana_core::poh_recorder::WorkingBankEntry;
use solana_gossip::cluster_info::ClusterInfo;
use solana_gossip::cluster_info::Node;
use solana_ledger::blockstore_processor::process_entries; use solana_ledger::blockstore_processor::process_entries;
use solana_ledger::entry::{next_hash, Entry}; use solana_ledger::entry::{next_hash, Entry};
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}; use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};

View File

@ -5,8 +5,8 @@ extern crate test;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use solana_core::broadcast_stage::broadcast_metrics::TransmitShredsStats; use solana_core::broadcast_stage::broadcast_metrics::TransmitShredsStats;
use solana_core::broadcast_stage::{broadcast_shreds, get_broadcast_peers}; use solana_core::broadcast_stage::{broadcast_shreds, get_broadcast_peers};
use solana_core::cluster_info::{ClusterInfo, Node}; use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_core::contact_info::ContactInfo; use solana_gossip::contact_info::ContactInfo;
use solana_ledger::shred::Shred; use solana_ledger::shred::Shred;
use solana_sdk::pubkey; use solana_sdk::pubkey;
use solana_sdk::timing::timestamp; use solana_sdk::timing::timestamp;

View File

@ -4,9 +4,9 @@ extern crate solana_core;
extern crate test; extern crate test;
use log::*; use log::*;
use solana_core::cluster_info::{ClusterInfo, Node};
use solana_core::contact_info::ContactInfo;
use solana_core::retransmit_stage::retransmitter; use solana_core::retransmit_stage::retransmitter;
use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_gossip::contact_info::ContactInfo;
use solana_ledger::entry::Entry; use solana_ledger::entry::Entry;
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}; use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};
use solana_ledger::leader_schedule_cache::LeaderScheduleCache; use solana_ledger::leader_schedule_cache::LeaderScheduleCache;

View File

@ -4,11 +4,9 @@
// hash on gossip. Monitor gossip for messages from validators in the --trusted-validators // hash on gossip. Monitor gossip for messages from validators in the --trusted-validators
// set and halt the node if a mismatch is detected. // set and halt the node if a mismatch is detected.
use crate::{ use crate::snapshot_packager_service::PendingSnapshotPackage;
cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES},
snapshot_packager_service::PendingSnapshotPackage,
};
use rayon::ThreadPool; use rayon::ThreadPool;
use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES};
use solana_runtime::{ use solana_runtime::{
accounts_db, accounts_db,
snapshot_package::{AccountsPackage, AccountsPackagePre, AccountsPackageReceiver}, snapshot_package::{AccountsPackage, AccountsPackagePre, AccountsPackageReceiver},
@ -218,8 +216,7 @@ impl AccountsHashVerifier {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::cluster_info::make_accounts_hashes_message; use solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo};
use crate::contact_info::ContactInfo;
use solana_runtime::bank_forks::ArchiveFormat; use solana_runtime::bank_forks::ArchiveFormat;
use solana_runtime::snapshot_utils::SnapshotVersion; use solana_runtime::snapshot_utils::SnapshotVersion;
use solana_sdk::{ use solana_sdk::{

View File

@ -2,7 +2,6 @@
//! 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 crate::{ use crate::{
cluster_info::ClusterInfo,
packet_hasher::PacketHasher, packet_hasher::PacketHasher,
poh_recorder::{PohRecorder, PohRecorderError, TransactionRecorder, WorkingBankEntry}, poh_recorder::{PohRecorder, PohRecorderError, TransactionRecorder, WorkingBankEntry},
poh_service::{self, PohService}, poh_service::{self, PohService},
@ -11,6 +10,7 @@ use crossbeam_channel::{Receiver as CrossbeamReceiver, RecvTimeoutError};
use itertools::Itertools; use itertools::Itertools;
use lru::LruCache; use lru::LruCache;
use retain_mut::RetainMut; use retain_mut::RetainMut;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{ use solana_ledger::{
blockstore::Blockstore, blockstore_processor::TransactionStatusSender, blockstore::Blockstore, blockstore_processor::TransactionStatusSender,
entry::hash_transactions, leader_schedule_cache::LeaderScheduleCache, entry::hash_transactions, leader_schedule_cache::LeaderScheduleCache,
@ -1435,11 +1435,12 @@ pub fn create_test_recorder(
mod tests { mod tests {
use super::*; use super::*;
use crate::{ use crate::{
cluster_info::Node, poh_recorder::Record, poh_recorder::WorkingBank, poh_recorder::Record, poh_recorder::WorkingBank,
transaction_status_service::TransactionStatusService, transaction_status_service::TransactionStatusService,
}; };
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use itertools::Itertools; use itertools::Itertools;
use solana_gossip::cluster_info::Node;
use solana_ledger::{ use solana_ledger::{
blockstore::entries_to_test_shreds, blockstore::entries_to_test_shreds,
entry::{next_entry, Entry, EntrySlice}, entry::{next_entry, Entry, EntrySlice},

View File

@ -5,11 +5,7 @@ use self::{
fail_entry_verification_broadcast_run::FailEntryVerificationBroadcastRun, fail_entry_verification_broadcast_run::FailEntryVerificationBroadcastRun,
standard_broadcast_run::StandardBroadcastRun, standard_broadcast_run::StandardBroadcastRun,
}; };
use crate::contact_info::ContactInfo;
use crate::crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS;
use crate::weighted_shuffle::weighted_best;
use crate::{ use crate::{
cluster_info::{ClusterInfo, ClusterInfoError},
poh_recorder::WorkingBankEntry, poh_recorder::WorkingBankEntry,
result::{Error, Result}, result::{Error, Result},
}; };
@ -17,6 +13,12 @@ use crossbeam_channel::{
Receiver as CrossbeamReceiver, RecvTimeoutError as CrossbeamRecvTimeoutError, Receiver as CrossbeamReceiver, RecvTimeoutError as CrossbeamRecvTimeoutError,
Sender as CrossbeamSender, Sender as CrossbeamSender,
}; };
use solana_gossip::{
cluster_info::{self, ClusterInfo, ClusterInfoError},
contact_info::ContactInfo,
crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS,
weighted_shuffle::weighted_best,
};
use solana_ledger::{blockstore::Blockstore, shred::Shred}; use solana_ledger::{blockstore::Blockstore, shred::Shred};
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_metrics::{inc_new_counter_error, inc_new_counter_info}; use solana_metrics::{inc_new_counter_error, inc_new_counter_info};
@ -363,7 +365,6 @@ pub fn get_broadcast_peers(
cluster_info: &ClusterInfo, cluster_info: &ClusterInfo,
stakes: Option<&HashMap<Pubkey, u64>>, stakes: Option<&HashMap<Pubkey, u64>>,
) -> (Vec<ContactInfo>, Vec<(u64, usize)>) { ) -> (Vec<ContactInfo>, Vec<(u64, usize)>) {
use crate::cluster_info;
let mut peers = cluster_info.tvu_peers(); let mut peers = cluster_info.tvu_peers();
let peers_and_stakes = cluster_info::stake_weight_peers(&mut peers, stakes); let peers_and_stakes = cluster_info::stake_weight_peers(&mut peers, stakes);
(peers, peers_and_stakes) (peers, peers_and_stakes)
@ -440,8 +441,8 @@ fn num_live_peers(peers: &[ContactInfo]) -> i64 {
#[cfg(test)] #[cfg(test)]
pub mod test { pub mod test {
use super::*; use super::*;
use crate::cluster_info::{ClusterInfo, Node};
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_ledger::{ use solana_ledger::{
blockstore::{make_slot_entries, Blockstore}, blockstore::{make_slot_entries, Blockstore},
entry::create_ticks, entry::create_ticks,

View File

@ -138,7 +138,7 @@ impl BroadcastRun for BroadcastFakeShredsRun {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::contact_info::ContactInfo; use solana_gossip::contact_info::ContactInfo;
use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::net::{IpAddr, Ipv4Addr, SocketAddr};
#[test] #[test]

View File

@ -494,7 +494,7 @@ impl BroadcastRun for StandardBroadcastRun {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::cluster_info::{ClusterInfo, Node}; use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_ledger::genesis_utils::create_genesis_config; use solana_ledger::genesis_utils::create_genesis_config;
use solana_ledger::{ use solana_ledger::{
blockstore::Blockstore, entry::create_ticks, get_tmp_ledger_path, blockstore::Blockstore, entry::create_ticks, get_tmp_ledger_path,

View File

@ -1,7 +1,4 @@
use crate::{ use crate::{
cluster_info::{ClusterInfo, GOSSIP_SLEEP_MILLIS},
crds::Cursor,
crds_value::CrdsValueLabel,
optimistic_confirmation_verifier::OptimisticConfirmationVerifier, optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
poh_recorder::PohRecorder, poh_recorder::PohRecorder,
replay_stage::DUPLICATE_THRESHOLD, replay_stage::DUPLICATE_THRESHOLD,
@ -15,6 +12,11 @@ use crossbeam_channel::{
}; };
use itertools::izip; use itertools::izip;
use log::*; use log::*;
use solana_gossip::{
cluster_info::{ClusterInfo, GOSSIP_SLEEP_MILLIS},
crds::Cursor,
crds_value::CrdsValueLabel,
};
use solana_ledger::blockstore::Blockstore; use solana_ledger::blockstore::Blockstore;
use solana_metrics::inc_new_counter_debug; use solana_metrics::inc_new_counter_debug;
use solana_perf::packet::{self, Packets}; use solana_perf::packet::{self, Packets};

View File

@ -1,8 +1,8 @@
use crate::{ use crate::serve_repair::RepairType;
cluster_info::ClusterInfo, contact_info::ContactInfo, crds::Cursor, epoch_slots::EpochSlots,
serve_repair::RepairType,
};
use itertools::Itertools; use itertools::Itertools;
use solana_gossip::{
cluster_info::ClusterInfo, contact_info::ContactInfo, crds::Cursor, epoch_slots::EpochSlots,
};
use solana_runtime::{bank_forks::BankForks, epoch_stakes::NodeIdToVoteAccounts}; use solana_runtime::{bank_forks::BankForks, epoch_stakes::NodeIdToVoteAccounts};
use solana_sdk::{clock::Slot, pubkey::Pubkey}; use solana_sdk::{clock::Slot, pubkey::Pubkey};
use std::{ use std::{

View File

@ -1,4 +1,5 @@
use crate::{cluster_info::ClusterInfo, cluster_slots::ClusterSlots}; use crate::cluster_slots::ClusterSlots;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::blockstore::{Blockstore, CompletedSlotsReceiver}; use solana_ledger::blockstore::{Blockstore, CompletedSlotsReceiver};
use solana_measure::measure::Measure; use solana_measure::measure::Measure;
use solana_runtime::bank_forks::BankForks; use solana_runtime::bank_forks::BankForks;
@ -185,7 +186,7 @@ impl ClusterSlotsService {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::{cluster_info::Node, crds_value::CrdsValueLabel}; use solana_gossip::{cluster_info::Node, crds_value::CrdsValueLabel};
#[test] #[test]
pub fn test_update_lowest_slot() { pub fn test_update_lowest_slot() {

View File

@ -13,40 +13,21 @@ pub mod bigtable_upload_service;
pub mod broadcast_stage; pub mod broadcast_stage;
pub mod cache_block_time_service; pub mod cache_block_time_service;
pub mod cluster_info_vote_listener; pub mod cluster_info_vote_listener;
pub mod commitment_service;
pub mod completed_data_sets_service;
mod deprecated;
pub mod sample_performance_service;
pub mod shred_fetch_stage;
#[macro_use]
pub mod contact_info;
pub mod cluster_info;
mod cluster_info_metrics;
pub mod cluster_slot_state_verifier; pub mod cluster_slot_state_verifier;
pub mod cluster_slots; pub mod cluster_slots;
pub mod cluster_slots_service; pub mod cluster_slots_service;
pub mod commitment_service;
pub mod completed_data_sets_service;
pub mod consensus; pub mod consensus;
pub mod crds;
pub mod crds_gossip;
pub mod crds_gossip_error;
pub mod crds_gossip_pull;
pub mod crds_gossip_push;
pub mod crds_shards;
pub mod crds_value;
pub mod data_budget;
pub mod duplicate_shred;
pub mod epoch_slots;
pub mod fetch_stage; pub mod fetch_stage;
pub mod fork_choice; pub mod fork_choice;
pub mod gen_keys; pub mod gen_keys;
pub mod gossip_service;
pub mod heaviest_subtree_fork_choice; pub mod heaviest_subtree_fork_choice;
pub mod latest_validator_votes_for_frozen_banks; pub mod latest_validator_votes_for_frozen_banks;
pub mod ledger_cleanup_service; pub mod ledger_cleanup_service;
pub mod optimistic_confirmation_verifier; pub mod optimistic_confirmation_verifier;
pub mod outstanding_requests; pub mod outstanding_requests;
pub mod packet_hasher; pub mod packet_hasher;
pub mod ping_pong;
pub mod poh_recorder; pub mod poh_recorder;
pub mod poh_service; pub mod poh_service;
pub mod progress_map; pub mod progress_map;
@ -62,9 +43,11 @@ pub mod rewards_recorder_service;
pub mod rpc; pub mod rpc;
pub mod rpc_health; pub mod rpc_health;
pub mod rpc_service; pub mod rpc_service;
pub mod sample_performance_service;
pub mod send_transaction_service; pub mod send_transaction_service;
pub mod serve_repair; pub mod serve_repair;
pub mod serve_repair_service; pub mod serve_repair_service;
pub mod shred_fetch_stage;
pub mod sigverify; pub mod sigverify;
pub mod sigverify_shreds; pub mod sigverify_shreds;
pub mod sigverify_stage; pub mod sigverify_stage;
@ -78,7 +61,6 @@ pub mod unfrozen_gossip_verified_vote_hashes;
pub mod validator; pub mod validator;
pub mod verified_vote_packets; pub mod verified_vote_packets;
pub mod vote_stake_tracker; pub mod vote_stake_tracker;
pub mod weighted_shuffle;
pub mod window_service; pub mod window_service;
#[macro_use] #[macro_use]

View File

@ -1,7 +1,6 @@
//! 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 crate::{ use crate::{
cluster_info::ClusterInfo,
cluster_info_vote_listener::VerifiedVoteReceiver, cluster_info_vote_listener::VerifiedVoteReceiver,
cluster_slots::ClusterSlots, cluster_slots::ClusterSlots,
outstanding_requests::OutstandingRequests, outstanding_requests::OutstandingRequests,
@ -10,6 +9,7 @@ use crate::{
serve_repair::{RepairType, ServeRepair}, serve_repair::{RepairType, ServeRepair},
}; };
use crossbeam_channel::{Receiver as CrossbeamReceiver, Sender as CrossbeamSender}; use crossbeam_channel::{Receiver as CrossbeamReceiver, Sender as CrossbeamSender};
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{ use solana_ledger::{
blockstore::{Blockstore, SlotMeta}, blockstore::{Blockstore, SlotMeta},
shred::Nonce, shred::Nonce,
@ -668,8 +668,8 @@ impl RepairService {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::cluster_info::Node;
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use solana_gossip::cluster_info::Node;
use solana_ledger::blockstore::{ use solana_ledger::blockstore::{
make_chaining_slot_entries, make_many_slot_entries, make_slot_entries, make_chaining_slot_entries, make_many_slot_entries, make_slot_entries,
}; };

View File

@ -3,7 +3,6 @@
use crate::{ use crate::{
broadcast_stage::RetransmitSlotsSender, broadcast_stage::RetransmitSlotsSender,
cache_block_time_service::CacheBlockTimeSender, cache_block_time_service::CacheBlockTimeSender,
cluster_info::ClusterInfo,
cluster_info_vote_listener::{ cluster_info_vote_listener::{
GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, VoteTracker, GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, VoteTracker,
}, },
@ -25,6 +24,7 @@ use crate::{
window_service::DuplicateSlotReceiver, window_service::DuplicateSlotReceiver,
}; };
use solana_client::rpc_response::SlotUpdate; use solana_client::rpc_response::SlotUpdate;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{ use solana_ledger::{
block_error::BlockError, block_error::BlockError,
blockstore::Blockstore, blockstore::Blockstore,
@ -2473,15 +2473,14 @@ impl ReplayStage {
pub(crate) mod tests { pub(crate) mod tests {
use super::*; use super::*;
use crate::{ use crate::{
cluster_info::Node,
consensus::test::{initialize_state, VoteSimulator}, consensus::test::{initialize_state, VoteSimulator},
consensus::Tower, consensus::Tower,
crds::Cursor,
progress_map::ValidatorStakeInfo, progress_map::ValidatorStakeInfo,
replay_stage::ReplayStage, replay_stage::ReplayStage,
transaction_status_service::TransactionStatusService, transaction_status_service::TransactionStatusService,
}; };
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use solana_gossip::{cluster_info::Node, crds::Cursor};
use solana_ledger::{ use solana_ledger::{
blockstore::make_slot_entries, blockstore::make_slot_entries,
blockstore::{entries_to_test_shreds, BlockstoreError}, blockstore::{entries_to_test_shreds, BlockstoreError},

View File

@ -1,39 +1,23 @@
//! 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 crate::poh_recorder; use solana_gossip::{cluster_info, gossip_error::GossipError};
use crate::{cluster_info, duplicate_shred};
use solana_ledger::block_error;
use solana_ledger::blockstore; use solana_ledger::blockstore;
use solana_runtime::snapshot_utils;
use solana_sdk::transaction;
use std::any::Any;
#[derive(Debug)] #[derive(Debug)]
pub enum Error { pub enum Error {
Io(std::io::Error), Io(std::io::Error),
Json(serde_json::Error),
AddrParse(std::net::AddrParseError),
JoinError(Box<dyn Any + Send + 'static>),
RecvError(std::sync::mpsc::RecvError), RecvError(std::sync::mpsc::RecvError),
TryCrossbeamRecvError(crossbeam_channel::TryRecvError),
CrossbeamRecvTimeoutError(crossbeam_channel::RecvTimeoutError), CrossbeamRecvTimeoutError(crossbeam_channel::RecvTimeoutError),
ReadyTimeoutError, ReadyTimeoutError,
RecvTimeoutError(std::sync::mpsc::RecvTimeoutError), RecvTimeoutError(std::sync::mpsc::RecvTimeoutError),
CrossbeamSendError, CrossbeamSendError,
TryCrossbeamSendError, TryCrossbeamSendError,
TryRecvError(std::sync::mpsc::TryRecvError),
Serialize(std::boxed::Box<bincode::ErrorKind>), Serialize(std::boxed::Box<bincode::ErrorKind>),
TransactionError(transaction::TransactionError),
ClusterInfoError(cluster_info::ClusterInfoError), ClusterInfoError(cluster_info::ClusterInfoError),
SendError, SendError,
PohRecorderError(poh_recorder::PohRecorderError),
BlockError(block_error::BlockError),
BlockstoreError(blockstore::BlockstoreError), BlockstoreError(blockstore::BlockstoreError),
FsExtra(fs_extra::error::Error),
SnapshotError(snapshot_utils::SnapshotError),
WeightedIndexError(rand::distributions::weighted::WeightedError), WeightedIndexError(rand::distributions::weighted::WeightedError),
DuplicateNodeInstance, GossipError(GossipError),
DuplicateShredError(duplicate_shred::Error),
} }
pub type Result<T> = std::result::Result<T, Error>; pub type Result<T> = std::result::Result<T, Error>;
@ -51,16 +35,6 @@ impl std::convert::From<std::sync::mpsc::RecvError> for Error {
Error::RecvError(e) Error::RecvError(e)
} }
} }
impl std::convert::From<crossbeam_channel::TryRecvError> for Error {
fn from(e: crossbeam_channel::TryRecvError) -> Error {
Error::TryCrossbeamRecvError(e)
}
}
impl std::convert::From<std::sync::mpsc::TryRecvError> for Error {
fn from(e: std::sync::mpsc::TryRecvError) -> Error {
Error::TryRecvError(e)
}
}
impl std::convert::From<crossbeam_channel::RecvTimeoutError> for Error { impl std::convert::From<crossbeam_channel::RecvTimeoutError> for Error {
fn from(e: crossbeam_channel::RecvTimeoutError) -> Error { fn from(e: crossbeam_channel::RecvTimeoutError) -> Error {
Error::CrossbeamRecvTimeoutError(e) Error::CrossbeamRecvTimeoutError(e)
@ -76,11 +50,6 @@ impl std::convert::From<std::sync::mpsc::RecvTimeoutError> for Error {
Error::RecvTimeoutError(e) Error::RecvTimeoutError(e)
} }
} }
impl std::convert::From<transaction::TransactionError> for Error {
fn from(e: transaction::TransactionError) -> Error {
Error::TransactionError(e)
}
}
impl std::convert::From<cluster_info::ClusterInfoError> for Error { impl std::convert::From<cluster_info::ClusterInfoError> for Error {
fn from(e: cluster_info::ClusterInfoError) -> Error { fn from(e: cluster_info::ClusterInfoError) -> Error {
Error::ClusterInfoError(e) Error::ClusterInfoError(e)
@ -101,59 +70,29 @@ impl<T> std::convert::From<std::sync::mpsc::SendError<T>> for Error {
Error::SendError Error::SendError
} }
} }
impl std::convert::From<Box<dyn Any + Send + 'static>> for Error {
fn from(e: Box<dyn Any + Send + 'static>) -> Error {
Error::JoinError(e)
}
}
impl std::convert::From<std::io::Error> for Error { impl std::convert::From<std::io::Error> for Error {
fn from(e: std::io::Error) -> Error { fn from(e: std::io::Error) -> Error {
Error::Io(e) Error::Io(e)
} }
} }
impl std::convert::From<fs_extra::error::Error> for Error {
fn from(e: fs_extra::error::Error) -> Error {
Error::FsExtra(e)
}
}
impl std::convert::From<serde_json::Error> for Error {
fn from(e: serde_json::Error) -> Error {
Error::Json(e)
}
}
impl std::convert::From<std::net::AddrParseError> for Error {
fn from(e: std::net::AddrParseError) -> Error {
Error::AddrParse(e)
}
}
impl std::convert::From<std::boxed::Box<bincode::ErrorKind>> for Error { impl std::convert::From<std::boxed::Box<bincode::ErrorKind>> for Error {
fn from(e: std::boxed::Box<bincode::ErrorKind>) -> Error { fn from(e: std::boxed::Box<bincode::ErrorKind>) -> Error {
Error::Serialize(e) Error::Serialize(e)
} }
} }
impl std::convert::From<poh_recorder::PohRecorderError> for Error {
fn from(e: poh_recorder::PohRecorderError) -> Error {
Error::PohRecorderError(e)
}
}
impl std::convert::From<blockstore::BlockstoreError> for Error { impl std::convert::From<blockstore::BlockstoreError> for Error {
fn from(e: blockstore::BlockstoreError) -> Error { fn from(e: blockstore::BlockstoreError) -> Error {
Error::BlockstoreError(e) Error::BlockstoreError(e)
} }
} }
impl std::convert::From<snapshot_utils::SnapshotError> for Error {
fn from(e: snapshot_utils::SnapshotError) -> Error {
Error::SnapshotError(e)
}
}
impl std::convert::From<rand::distributions::weighted::WeightedError> for Error { impl std::convert::From<rand::distributions::weighted::WeightedError> for Error {
fn from(e: rand::distributions::weighted::WeightedError) -> Error { fn from(e: rand::distributions::weighted::WeightedError) -> Error {
Error::WeightedIndexError(e) Error::WeightedIndexError(e)
} }
} }
impl std::convert::From<duplicate_shred::Error> for Error { impl std::convert::From<GossipError> for Error {
fn from(e: duplicate_shred::Error) -> Error { fn from(e: GossipError) -> Error {
Error::DuplicateShredError(e) Error::GossipError(e)
} }
} }
@ -163,24 +102,11 @@ mod tests {
use crate::result::Result; use crate::result::Result;
use std::io; use std::io;
use std::io::Write; use std::io::Write;
use std::net::SocketAddr;
use std::panic; use std::panic;
use std::sync::mpsc::channel; use std::sync::mpsc::channel;
use std::sync::mpsc::RecvError; use std::sync::mpsc::RecvError;
use std::sync::mpsc::RecvTimeoutError; use std::sync::mpsc::RecvTimeoutError;
use std::thread;
fn addr_parse_error() -> Result<SocketAddr> {
Ok("12fdfasfsafsadfs".parse()?)
}
fn join_error() -> Result<()> {
panic::set_hook(Box::new(|_info| {}));
Ok(thread::spawn(|| panic!("hi")).join()?)
}
fn json_error() -> Result<()> {
Ok(serde_json::from_slice(b"=342{;;;;:}")?)
}
fn send_error() -> Result<()> { fn send_error() -> Result<()> {
let (s, r) = channel(); let (s, r) = channel();
drop(r); drop(r);
@ -190,25 +116,20 @@ mod tests {
#[test] #[test]
fn from_test() { fn from_test() {
assert_matches!(addr_parse_error(), Err(Error::AddrParse(_)));
assert_matches!(Error::from(RecvError {}), Error::RecvError(_)); assert_matches!(Error::from(RecvError {}), Error::RecvError(_));
assert_matches!( assert_matches!(
Error::from(RecvTimeoutError::Timeout), Error::from(RecvTimeoutError::Timeout),
Error::RecvTimeoutError(_) Error::RecvTimeoutError(_)
); );
assert_matches!(send_error(), Err(Error::SendError)); assert_matches!(send_error(), Err(Error::SendError));
assert_matches!(join_error(), Err(Error::JoinError(_)));
let ioe = io::Error::new(io::ErrorKind::NotFound, "hi"); let ioe = io::Error::new(io::ErrorKind::NotFound, "hi");
assert_matches!(Error::from(ioe), Error::Io(_)); assert_matches!(Error::from(ioe), Error::Io(_));
} }
#[test] #[test]
fn fmt_test() { fn fmt_test() {
write!(io::sink(), "{:?}", addr_parse_error()).unwrap();
write!(io::sink(), "{:?}", Error::from(RecvError {})).unwrap(); write!(io::sink(), "{:?}", Error::from(RecvError {})).unwrap();
write!(io::sink(), "{:?}", Error::from(RecvTimeoutError::Timeout)).unwrap(); write!(io::sink(), "{:?}", Error::from(RecvTimeoutError::Timeout)).unwrap();
write!(io::sink(), "{:?}", send_error()).unwrap(); write!(io::sink(), "{:?}", send_error()).unwrap();
write!(io::sink(), "{:?}", join_error()).unwrap();
write!(io::sink(), "{:?}", json_error()).unwrap();
write!( write!(
io::sink(), io::sink(),
"{:?}", "{:?}",

View File

@ -2,12 +2,10 @@
#![allow(clippy::rc_buffer)] #![allow(clippy::rc_buffer)]
use crate::{ use crate::{
cluster_info::{compute_retransmit_peers, ClusterInfo, DATA_PLANE_FANOUT},
cluster_info_vote_listener::VerifiedVoteReceiver, cluster_info_vote_listener::VerifiedVoteReceiver,
cluster_slots::ClusterSlots, cluster_slots::ClusterSlots,
cluster_slots_service::ClusterSlotsService, cluster_slots_service::ClusterSlotsService,
completed_data_sets_service::CompletedDataSetsSender, completed_data_sets_service::CompletedDataSetsSender,
contact_info::ContactInfo,
repair_service::DuplicateSlotsResetSender, repair_service::DuplicateSlotsResetSender,
repair_service::RepairInfo, repair_service::RepairInfo,
result::{Error, Result}, result::{Error, Result},
@ -16,6 +14,10 @@ use crate::{
use crossbeam_channel::{Receiver, Sender}; use crossbeam_channel::{Receiver, Sender};
use lru::LruCache; use lru::LruCache;
use solana_client::rpc_response::SlotUpdate; use solana_client::rpc_response::SlotUpdate;
use solana_gossip::{
cluster_info::{compute_retransmit_peers, ClusterInfo, DATA_PLANE_FANOUT},
contact_info::ContactInfo,
};
use solana_ledger::shred::{get_shred_slot_index_type, ShredFetchStats}; use solana_ledger::shred::{get_shred_slot_index_type, ShredFetchStats};
use solana_ledger::{ use solana_ledger::{
blockstore::{Blockstore, CompletedSlotsReceiver}, blockstore::{Blockstore, CompletedSlotsReceiver},
@ -691,7 +693,7 @@ impl RetransmitStage {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::contact_info::ContactInfo; use solana_gossip::contact_info::ContactInfo;
use solana_ledger::blockstore_processor::{process_blockstore, ProcessOptions}; use solana_ledger::blockstore_processor::{process_blockstore, ProcessOptions};
use solana_ledger::create_new_tmp_ledger; use solana_ledger::create_new_tmp_ledger;
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo}; use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};

View File

@ -1,8 +1,6 @@
//! The `rpc` module implements the Solana RPC interface. //! The `rpc` module implements the Solana RPC interface.
use crate::{ use crate::{
cluster_info::ClusterInfo,
contact_info::ContactInfo,
rpc_health::*, rpc_health::*,
send_transaction_service::{SendTransactionService, TransactionInfo}, send_transaction_service::{SendTransactionService, TransactionInfo},
validator::ValidatorExit, validator::ValidatorExit,
@ -32,6 +30,7 @@ use solana_client::{
rpc_response::*, rpc_response::*,
}; };
use solana_faucet::faucet::request_airdrop_transaction; use solana_faucet::faucet::request_airdrop_transaction;
use solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo};
use solana_ledger::{ use solana_ledger::{
blockstore::Blockstore, blockstore_db::BlockstoreError, get_tmp_ledger_path, blockstore::Blockstore, blockstore_db::BlockstoreError, get_tmp_ledger_path,
leader_schedule_cache::LeaderScheduleCache, leader_schedule_cache::LeaderScheduleCache,
@ -3719,14 +3718,12 @@ pub(crate) fn create_validator_exit(exit: &Arc<AtomicBool>) -> Arc<RwLock<Valida
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::{rpc_full::*, rpc_minimal::*, *}; use super::{rpc_full::*, rpc_minimal::*, *};
use crate::{ use crate::replay_stage::tests::create_test_transactions_and_populate_blockstore;
contact_info::ContactInfo,
replay_stage::tests::create_test_transactions_and_populate_blockstore,
};
use bincode::deserialize; use bincode::deserialize;
use jsonrpc_core::{futures, ErrorCode, MetaIoHandler, Output, Response, Value}; use jsonrpc_core::{futures, ErrorCode, MetaIoHandler, Output, Response, Value};
use jsonrpc_core_client::transports::local; use jsonrpc_core_client::transports::local;
use solana_client::rpc_filter::{Memcmp, MemcmpEncodedBytes}; use solana_client::rpc_filter::{Memcmp, MemcmpEncodedBytes};
use solana_gossip::{contact_info::ContactInfo, socketaddr};
use solana_ledger::{ use solana_ledger::{
blockstore_meta::PerfSample, blockstore_meta::PerfSample,
blockstore_processor::fill_blockstore_slot_with_ticks, blockstore_processor::fill_blockstore_slot_with_ticks,

View File

@ -1,5 +1,5 @@
use { use {
crate::cluster_info::ClusterInfo, solana_gossip::cluster_info::ClusterInfo,
solana_sdk::{clock::Slot, pubkey::Pubkey}, solana_sdk::{clock::Slot, pubkey::Pubkey},
std::{ std::{
collections::HashSet, collections::HashSet,

View File

@ -2,7 +2,6 @@
use crate::{ use crate::{
bigtable_upload_service::BigTableUploadService, bigtable_upload_service::BigTableUploadService,
cluster_info::ClusterInfo,
poh_recorder::PohRecorder, poh_recorder::PohRecorder,
rpc::{rpc_deprecated_v1_7::*, rpc_full::*, rpc_minimal::*, rpc_obsolete_v1_7::*, *}, rpc::{rpc_deprecated_v1_7::*, rpc_full::*, rpc_minimal::*, rpc_obsolete_v1_7::*, *},
rpc_health::*, rpc_health::*,
@ -16,6 +15,7 @@ use jsonrpc_http_server::{
}; };
use regex::Regex; use regex::Regex;
use solana_client::rpc_cache::LargestAccountsCache; use solana_client::rpc_cache::LargestAccountsCache;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{blockstore::Blockstore, leader_schedule_cache::LeaderScheduleCache}; use solana_ledger::{blockstore::Blockstore, leader_schedule_cache::LeaderScheduleCache};
use solana_metrics::inc_new_counter_info; use solana_metrics::inc_new_counter_info;
use solana_rpc::{ use solana_rpc::{
@ -479,10 +479,8 @@ impl JsonRpcService {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use crate::{ use crate::rpc::create_validator_exit;
crds_value::{CrdsData, CrdsValue, SnapshotHash}, use solana_gossip::crds_value::{CrdsData, CrdsValue, SnapshotHash};
rpc::create_validator_exit,
};
use solana_ledger::{ use solana_ledger::{
genesis_utils::{create_genesis_config, GenesisConfigInfo}, genesis_utils::{create_genesis_config, GenesisConfigInfo},
get_tmp_ledger_path, get_tmp_ledger_path,

View File

@ -1,7 +1,7 @@
// TODO: Merge this implementation with the one at `banks-server/src/send_transaction_service.rs` // TODO: Merge this implementation with the one at `banks-server/src/send_transaction_service.rs`
use crate::cluster_info::ClusterInfo;
use crate::poh_recorder::PohRecorder; use crate::poh_recorder::PohRecorder;
use log::*; use log::*;
use solana_gossip::cluster_info::ClusterInfo;
use solana_metrics::{datapoint_warn, inc_new_counter_info}; use solana_metrics::{datapoint_warn, inc_new_counter_info};
use solana_runtime::{bank::Bank, bank_forks::BankForks}; use solana_runtime::{bank::Bank, bank_forks::BankForks};
use solana_sdk::{ use solana_sdk::{
@ -313,7 +313,7 @@ impl SendTransactionService {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::contact_info::ContactInfo; use solana_gossip::contact_info::ContactInfo;
use solana_ledger::{ use solana_ledger::{
blockstore::Blockstore, get_tmp_ledger_path, leader_schedule_cache::LeaderScheduleCache, blockstore::Blockstore, get_tmp_ledger_path, leader_schedule_cache::LeaderScheduleCache,
}; };

View File

@ -1,15 +1,17 @@
use crate::{ use crate::{
cluster_info::{ClusterInfo, ClusterInfoError},
cluster_slots::ClusterSlots, cluster_slots::ClusterSlots,
contact_info::ContactInfo,
repair_response, repair_response,
repair_service::{OutstandingRepairs, RepairStats}, repair_service::{OutstandingRepairs, RepairStats},
request_response::RequestResponse, request_response::RequestResponse,
result::{Error, Result}, result::{Error, Result},
weighted_shuffle::weighted_best,
}; };
use bincode::serialize; use bincode::serialize;
use rand::distributions::{Distribution, WeightedIndex}; use rand::distributions::{Distribution, WeightedIndex};
use solana_gossip::{
cluster_info::{ClusterInfo, ClusterInfoError},
contact_info::ContactInfo,
weighted_shuffle::weighted_best,
};
use solana_ledger::{ use solana_ledger::{
blockstore::Blockstore, blockstore::Blockstore,
shred::{Nonce, Shred}, shred::{Nonce, Shred},
@ -607,6 +609,7 @@ impl ServeRepair {
mod tests { mod tests {
use super::*; use super::*;
use crate::{repair_response, result::Error}; use crate::{repair_response, result::Error};
use solana_gossip::{socketaddr, socketaddr_any};
use solana_ledger::get_tmp_ledger_path; use solana_ledger::get_tmp_ledger_path;
use solana_ledger::{ use solana_ledger::{
blockstore::make_many_slot_entries, blockstore::make_many_slot_entries,

View File

@ -1,4 +1,4 @@
use crate::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES}; use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES};
use solana_runtime::{snapshot_package::AccountsPackage, snapshot_utils}; use solana_runtime::{snapshot_package::AccountsPackage, snapshot_utils};
use solana_sdk::{clock::Slot, hash::Hash}; use solana_sdk::{clock::Slot, hash::Hash};
use std::{ use std::{

View File

@ -1,11 +1,10 @@
use { use {
crate::{ crate::{
cluster_info::Node,
gossip_service::discover_cluster,
rpc::JsonRpcConfig, rpc::JsonRpcConfig,
validator::{Validator, ValidatorConfig, ValidatorExit, ValidatorStartProgress}, validator::{Validator, ValidatorConfig, ValidatorExit, ValidatorStartProgress},
}, },
solana_client::rpc_client::RpcClient, solana_client::rpc_client::RpcClient,
solana_gossip::{cluster_info::Node, gossip_service::discover_cluster, socketaddr},
solana_ledger::{blockstore::create_new_ledger, create_new_tmp_ledger}, solana_ledger::{blockstore::create_new_ledger, create_new_tmp_ledger},
solana_net_utils::PortRange, solana_net_utils::PortRange,
solana_runtime::{ solana_runtime::{

View File

@ -4,7 +4,6 @@
use crate::{ use crate::{
banking_stage::BankingStage, banking_stage::BankingStage,
broadcast_stage::{BroadcastStage, BroadcastStageType, RetransmitSlotsReceiver}, broadcast_stage::{BroadcastStage, BroadcastStageType, RetransmitSlotsReceiver},
cluster_info::ClusterInfo,
cluster_info_vote_listener::{ cluster_info_vote_listener::{
ClusterInfoVoteListener, GossipDuplicateConfirmedSlotsSender, GossipVerifiedVoteHashSender, ClusterInfoVoteListener, GossipDuplicateConfirmedSlotsSender, GossipVerifiedVoteHashSender,
VerifiedVoteSender, VoteTracker, VerifiedVoteSender, VoteTracker,
@ -15,6 +14,7 @@ use crate::{
sigverify_stage::SigVerifyStage, sigverify_stage::SigVerifyStage,
}; };
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{blockstore::Blockstore, blockstore_processor::TransactionStatusSender}; use solana_ledger::{blockstore::Blockstore, blockstore_processor::TransactionStatusSender};
use solana_rpc::{ use solana_rpc::{
optimistically_confirmed_bank_tracker::BankNotificationSender, optimistically_confirmed_bank_tracker::BankNotificationSender,

View File

@ -5,7 +5,6 @@ use crate::{
accounts_hash_verifier::AccountsHashVerifier, accounts_hash_verifier::AccountsHashVerifier,
broadcast_stage::RetransmitSlotsSender, broadcast_stage::RetransmitSlotsSender,
cache_block_time_service::CacheBlockTimeSender, cache_block_time_service::CacheBlockTimeSender,
cluster_info::ClusterInfo,
cluster_info_vote_listener::{ cluster_info_vote_listener::{
GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver, GossipDuplicateConfirmedSlotsReceiver, GossipVerifiedVoteHashReceiver,
VerifiedVoteReceiver, VoteTracker, VerifiedVoteReceiver, VoteTracker,
@ -24,6 +23,7 @@ use crate::{
snapshot_packager_service::PendingSnapshotPackage, snapshot_packager_service::PendingSnapshotPackage,
}; };
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{ use solana_ledger::{
blockstore::{Blockstore, CompletedSlotsReceiver}, blockstore::{Blockstore, CompletedSlotsReceiver},
blockstore_processor::TransactionStatusSender, blockstore_processor::TransactionStatusSender,
@ -338,11 +338,9 @@ impl Tvu {
#[cfg(test)] #[cfg(test)]
pub mod tests { pub mod tests {
use super::*; use super::*;
use crate::{ use crate::banking_stage::create_test_recorder;
banking_stage::create_test_recorder,
cluster_info::{ClusterInfo, Node},
};
use serial_test::serial; use serial_test::serial;
use solana_gossip::cluster_info::{ClusterInfo, Node};
use solana_ledger::{ use solana_ledger::{
blockstore::BlockstoreSignals, blockstore::BlockstoreSignals,
create_new_tmp_ledger, create_new_tmp_ledger,

View File

@ -3,15 +3,9 @@
use crate::{ use crate::{
broadcast_stage::BroadcastStageType, broadcast_stage::BroadcastStageType,
cache_block_time_service::{CacheBlockTimeSender, CacheBlockTimeService}, cache_block_time_service::{CacheBlockTimeSender, CacheBlockTimeService},
cluster_info::{
ClusterInfo, Node, DEFAULT_CONTACT_DEBUG_INTERVAL_MILLIS,
DEFAULT_CONTACT_SAVE_INTERVAL_MILLIS,
},
cluster_info_vote_listener::VoteTracker, cluster_info_vote_listener::VoteTracker,
completed_data_sets_service::CompletedDataSetsService, completed_data_sets_service::CompletedDataSetsService,
consensus::{reconcile_blockstore_roots_with_tower, Tower}, consensus::{reconcile_blockstore_roots_with_tower, Tower},
contact_info::ContactInfo,
gossip_service::GossipService,
poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS}, poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS},
poh_service::{self, PohService}, poh_service::{self, PohService},
rewards_recorder_service::{RewardsRecorderSender, RewardsRecorderService}, rewards_recorder_service::{RewardsRecorderSender, RewardsRecorderService},
@ -28,6 +22,14 @@ use crate::{
}; };
use crossbeam_channel::{bounded, unbounded}; use crossbeam_channel::{bounded, unbounded};
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use solana_gossip::{
cluster_info::{
ClusterInfo, Node, DEFAULT_CONTACT_DEBUG_INTERVAL_MILLIS,
DEFAULT_CONTACT_SAVE_INTERVAL_MILLIS,
},
contact_info::ContactInfo,
gossip_service::GossipService,
};
use solana_ledger::{ use solana_ledger::{
bank_forks_utils, bank_forks_utils,
blockstore::{Blockstore, BlockstoreSignals, CompletedSlotsReceiver, PurgeType}, blockstore::{Blockstore, BlockstoreSignals, CompletedSlotsReceiver, PurgeType},

View File

@ -1,7 +1,5 @@
use crate::{ use crate::{cluster_info_vote_listener::VerifiedLabelVotePacketsReceiver, result::Result};
cluster_info_vote_listener::VerifiedLabelVotePacketsReceiver, crds_value::CrdsValueLabel, use solana_gossip::crds_value::CrdsValueLabel;
result::Result,
};
use solana_perf::packet::Packets; use solana_perf::packet::Packets;
use solana_sdk::clock::Slot; use solana_sdk::clock::Slot;
use std::{ use std::{

View File

@ -2,7 +2,6 @@
//! blockstore and retransmitting where required //! blockstore and retransmitting where required
//! //!
use crate::{ use crate::{
cluster_info::ClusterInfo,
cluster_info_vote_listener::VerifiedVoteReceiver, cluster_info_vote_listener::VerifiedVoteReceiver,
cluster_slots::ClusterSlots, cluster_slots::ClusterSlots,
completed_data_sets_service::CompletedDataSetsSender, completed_data_sets_service::CompletedDataSetsSender,
@ -17,6 +16,7 @@ use crossbeam_channel::{
use rayon::iter::IntoParallelRefMutIterator; use rayon::iter::IntoParallelRefMutIterator;
use rayon::iter::ParallelIterator; use rayon::iter::ParallelIterator;
use rayon::ThreadPool; use rayon::ThreadPool;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{ use solana_ledger::{
blockstore::{self, Blockstore, BlockstoreInsertionMetrics, MAX_DATA_SHREDS_PER_SLOT}, blockstore::{self, Blockstore, BlockstoreInsertionMetrics, MAX_DATA_SHREDS_PER_SLOT},
leader_schedule_cache::LeaderScheduleCache, leader_schedule_cache::LeaderScheduleCache,
@ -614,7 +614,7 @@ impl WindowService {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use super::*;
use crate::contact_info::ContactInfo; use solana_gossip::contact_info::ContactInfo;
use solana_ledger::{ use solana_ledger::{
blockstore::{make_many_slot_entries, Blockstore}, blockstore::{make_many_slot_entries, Blockstore},
entry::{create_ticks, Entry}, entry::{create_ticks, Entry},

View File

@ -39,11 +39,8 @@ mod tests {
use crossbeam_channel::unbounded; use crossbeam_channel::unbounded;
use fs_extra::dir::CopyOptions; use fs_extra::dir::CopyOptions;
use itertools::Itertools; use itertools::Itertools;
use solana_core::{ use solana_core::snapshot_packager_service::{PendingSnapshotPackage, SnapshotPackagerService};
cluster_info::ClusterInfo, use solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo};
contact_info::ContactInfo,
snapshot_packager_service::{PendingSnapshotPackage, SnapshotPackagerService},
};
use solana_runtime::{ use solana_runtime::{
accounts_background_service::{AbsRequestSender, SnapshotRequestHandler}, accounts_background_service::{AbsRequestSender, SnapshotRequestHandler},
accounts_db, accounts_db,

View File

@ -16,6 +16,7 @@ rand = "0.7.0"
rayon = "1.5.0" rayon = "1.5.0"
solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" } solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" }
solana-core = { path = "../core", version = "=1.7.0" } solana-core = { path = "../core", version = "=1.7.0" }
solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-ledger = { path = "../ledger", version = "=1.7.0" } solana-ledger = { path = "../ledger", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" } solana-logger = { path = "../logger", version = "=1.7.0" }
solana-net-utils = { path = "../net-utils", version = "=1.7.0" } solana-net-utils = { path = "../net-utils", version = "=1.7.0" }

View File

@ -3,9 +3,8 @@ use clap::{crate_description, crate_name, value_t, value_t_or_exit, App, Arg};
use log::*; use log::*;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use solana_client::rpc_client::RpcClient; use solana_client::rpc_client::RpcClient;
use solana_core::{ use solana_core::serve_repair::RepairProtocol;
contact_info::ContactInfo, gossip_service::discover, serve_repair::RepairProtocol, use solana_gossip::{contact_info::ContactInfo, gossip_service::discover};
};
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use std::net::{SocketAddr, UdpSocket}; use std::net::{SocketAddr, UdpSocket};
use std::process::exit; use std::process::exit;

View File

@ -10,13 +10,59 @@ homepage = "https://solana.com/"
documentation = "https://docs.rs/solana-gossip" documentation = "https://docs.rs/solana-gossip"
[dependencies] [dependencies]
bincode = "1.3.1"
bv = { version = "0.11.1", features = ["serde"] }
clap = "2.33.1" clap = "2.33.1"
flate2 = "1.0"
indexmap = { version = "1.5", features = ["rayon"] }
itertools = "0.9.0"
log = "0.4.11"
lru = "0.6.1"
num-traits = "0.2"
rand = "0.7.0"
rand_chacha = "0.2.2"
rayon = "1.5.0"
serde = "1.0.122"
serde_bytes = "0.11"
serde_derive = "1.0.103"
solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" } solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" }
solana-core = { path = "../core", version = "=1.7.0" } solana-client = { path = "../client", version = "=1.7.0" }
solana-frozen-abi = { path = "../frozen-abi", version = "=1.7.0" }
solana-frozen-abi-macro = { path = "../frozen-abi/macro", version = "=1.7.0" }
solana-ledger = { path = "../ledger", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" } solana-logger = { path = "../logger", version = "=1.7.0" }
solana-measure = { path = "../measure", version = "=1.7.0" }
solana-metrics = { path = "../metrics", version = "=1.7.0" }
solana-net-utils = { path = "../net-utils", version = "=1.7.0" } solana-net-utils = { path = "../net-utils", version = "=1.7.0" }
solana-perf = { path = "../perf", version = "=1.7.0" }
solana-rayon-threadlimit = { path = "../rayon-threadlimit", version = "=1.7.0" }
solana-runtime = { path = "../runtime", version = "=1.7.0" }
solana-streamer = { path = "../streamer", version = "=1.7.0" }
solana-sdk = { path = "../sdk", version = "=1.7.0" } solana-sdk = { path = "../sdk", version = "=1.7.0" }
solana-version = { path = "../version", version = "=1.7.0" } solana-version = { path = "../version", version = "=1.7.0" }
solana-vote-program = { path = "../programs/vote", version = "=1.7.0" }
thiserror = "1.0"
[dev-dependencies]
matches = "0.1.6"
num_cpus = "1.13.0"
serial_test = "0.4.0"
[build-dependencies]
rustc_version = "0.2"
[[bench]]
name = "crds"
[[bench]]
name = "crds_gossip_pull"
[[bench]]
name = "crds_shards"
[[bin]]
name = "solana-gossip"
path = "src/main.rs"
[package.metadata.docs.rs] [package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"] targets = ["x86_64-unknown-linux-gnu"]

View File

@ -2,14 +2,16 @@
extern crate test; extern crate test;
use rand::{thread_rng, Rng}; use {
use rayon::ThreadPoolBuilder; rand::{thread_rng, Rng},
use solana_core::crds::Crds; rayon::ThreadPoolBuilder,
use solana_core::crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS; solana_gossip::{
use solana_core::crds_value::CrdsValue; crds::Crds, crds_gossip_pull::CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS, crds_value::CrdsValue,
use solana_sdk::pubkey::Pubkey; },
use std::collections::HashMap; solana_sdk::pubkey::Pubkey,
use test::Bencher; std::collections::HashMap,
test::Bencher,
};
#[bench] #[bench]
fn bench_find_old_labels(bencher: &mut Bencher) { fn bench_find_old_labels(bencher: &mut Bencher) {

View File

@ -2,14 +2,18 @@
extern crate test; extern crate test;
use rand::{thread_rng, Rng}; use {
use rayon::ThreadPoolBuilder; rand::{thread_rng, Rng},
use solana_core::cluster_info::MAX_BLOOM_SIZE; rayon::ThreadPoolBuilder,
use solana_core::crds::Crds; solana_gossip::{
use solana_core::crds_gossip_pull::{CrdsFilter, CrdsGossipPull}; cluster_info::MAX_BLOOM_SIZE,
use solana_core::crds_value::CrdsValue; crds::Crds,
use solana_sdk::hash; crds_gossip_pull::{CrdsFilter, CrdsGossipPull},
use test::Bencher; crds_value::CrdsValue,
},
solana_sdk::hash,
test::Bencher,
};
#[bench] #[bench]
fn bench_hash_as_u64(bencher: &mut Bencher) { fn bench_hash_as_u64(bencher: &mut Bencher) {

View File

@ -2,15 +2,17 @@
extern crate test; extern crate test;
use rand::{thread_rng, Rng}; use {
use solana_core::{ rand::{thread_rng, Rng},
crds::{Crds, VersionedCrdsValue}, solana_gossip::{
crds_shards::CrdsShards, crds::{Crds, VersionedCrdsValue},
crds_value::CrdsValue, crds_shards::CrdsShards,
crds_value::CrdsValue,
},
solana_sdk::timing::timestamp,
std::iter::repeat_with,
test::Bencher,
}; };
use solana_sdk::timing::timestamp;
use std::iter::repeat_with;
use test::Bencher;
const CRDS_SHARDS_BITS: u32 = 8; const CRDS_SHARDS_BITS: u32 = 8;

1
gossip/build.rs Symbolic link
View File

@ -0,0 +1 @@
../frozen-abi/build.rs

View File

@ -12,74 +12,77 @@
//! * layer 2 - Everyone else, if layer 1 is `2^10`, layer 2 should be able to fit `2^20` number of nodes. //! * layer 2 - Everyone else, if layer 1 is `2^10`, layer 2 should be able to fit `2^20` number of nodes.
//! //!
//! Bank needs to provide an interface for us to query the stake weight //! Bank needs to provide an interface for us to query the stake weight
use crate::{ use {
cluster_info_metrics::{submit_gossip_stats, Counter, GossipStats, ScopedTimer}, crate::{
contact_info::ContactInfo, cluster_info_metrics::{submit_gossip_stats, Counter, GossipStats, ScopedTimer},
crds::Cursor, contact_info::ContactInfo,
crds_gossip::CrdsGossip, crds::Cursor,
crds_gossip_error::CrdsGossipError, crds_gossip::CrdsGossip,
crds_gossip_pull::{CrdsFilter, ProcessPullStats, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS}, crds_gossip_error::CrdsGossipError,
crds_value::{ crds_gossip_pull::{CrdsFilter, ProcessPullStats, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS},
self, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, LowestSlot, NodeInstance, crds_value::{
SnapshotHash, Version, Vote, MAX_WALLCLOCK, self, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, LowestSlot, NodeInstance,
SnapshotHash, Version, Vote, MAX_WALLCLOCK,
},
data_budget::DataBudget,
epoch_slots::EpochSlots,
gossip_error::GossipError,
ping_pong::{self, PingCache, Pong},
socketaddr, socketaddr_any,
weighted_shuffle::weighted_shuffle,
}, },
data_budget::DataBudget, bincode::{serialize, serialized_size},
epoch_slots::EpochSlots, itertools::Itertools,
ping_pong::{self, PingCache, Pong}, rand::{seq::SliceRandom, thread_rng, CryptoRng, Rng},
result::{Error, Result}, rayon::{prelude::*, ThreadPool, ThreadPoolBuilder},
weighted_shuffle::weighted_shuffle, serde::ser::Serialize,
}; solana_ledger::shred::Shred,
use rand::{seq::SliceRandom, CryptoRng, Rng}; solana_measure::measure::Measure,
use solana_ledger::shred::Shred; solana_metrics::{inc_new_counter_debug, inc_new_counter_error},
use solana_sdk::sanitize::{Sanitize, SanitizeError}; solana_net_utils::{
bind_common, bind_common_in_range, bind_in_range, find_available_port_in_range,
use bincode::{serialize, serialized_size}; multi_bind_in_range, PortRange,
use itertools::Itertools; },
use rand::thread_rng; solana_perf::packet::{
use rayon::prelude::*; limited_deserialize, to_packets_with_destination, Packet, Packets, PacketsRecycler,
use rayon::{ThreadPool, ThreadPoolBuilder}; PACKET_DATA_SIZE,
use serde::ser::Serialize; },
use solana_measure::measure::Measure; solana_rayon_threadlimit::get_thread_count,
use solana_metrics::{inc_new_counter_debug, inc_new_counter_error}; solana_runtime::bank_forks::BankForks,
use solana_net_utils::{ solana_sdk::{
bind_common, bind_common_in_range, bind_in_range, find_available_port_in_range, clock::{Slot, DEFAULT_MS_PER_SLOT, DEFAULT_SLOTS_PER_EPOCH},
multi_bind_in_range, PortRange, feature_set::{self, FeatureSet},
}; hash::Hash,
use solana_perf::packet::{ pubkey::Pubkey,
limited_deserialize, to_packets_with_destination, Packet, Packets, PacketsRecycler, sanitize::{Sanitize, SanitizeError},
PACKET_DATA_SIZE, signature::{Keypair, Signable, Signature, Signer},
}; timing::timestamp,
use solana_rayon_threadlimit::get_thread_count; transaction::Transaction,
use solana_runtime::bank_forks::BankForks; },
use solana_sdk::{ solana_streamer::{
clock::{Slot, DEFAULT_MS_PER_SLOT, DEFAULT_SLOTS_PER_EPOCH}, packet,
feature_set::{self, FeatureSet}, sendmmsg::multicast,
hash::Hash, streamer::{PacketReceiver, PacketSender},
pubkey::Pubkey, },
signature::{Keypair, Signable, Signature, Signer}, solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY,
timing::timestamp, std::{
transaction::Transaction, borrow::Cow,
}; collections::{hash_map::Entry, HashMap, HashSet, VecDeque},
use solana_streamer::packet; fmt::Debug,
use solana_streamer::sendmmsg::multicast; fs::{self, File},
use solana_streamer::streamer::{PacketReceiver, PacketSender}; io::BufReader,
use solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY; iter::repeat,
use std::{ net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket},
borrow::Cow, ops::{Deref, DerefMut, Div},
collections::{hash_map::Entry, HashMap, HashSet, VecDeque}, path::{Path, PathBuf},
fmt::Debug, result::Result,
fs::{self, File}, sync::{
io::BufReader, atomic::{AtomicBool, Ordering},
iter::repeat, {Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard},
net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket}, },
ops::{Deref, DerefMut, Div}, thread::{sleep, Builder, JoinHandle},
path::{Path, PathBuf}, time::{Duration, Instant},
sync::{
atomic::{AtomicBool, Ordering},
{Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard},
}, },
thread::{sleep, Builder, JoinHandle},
time::{Duration, Instant},
}; };
pub const VALIDATOR_PORT_RANGE: PortRange = (8000, 10_000); pub const VALIDATOR_PORT_RANGE: PortRange = (8000, 10_000);
@ -209,7 +212,7 @@ pub struct ClusterInfo {
/// The network /// The network
pub gossip: RwLock<CrdsGossip>, pub gossip: RwLock<CrdsGossip>,
/// set the keypair that will be used to sign crds values generated. It is unset only in tests. /// set the keypair that will be used to sign crds values generated. It is unset only in tests.
pub(crate) keypair: Arc<Keypair>, pub keypair: Arc<Keypair>,
/// Network entrypoints /// Network entrypoints
entrypoints: RwLock<Vec<ContactInfo>>, entrypoints: RwLock<Vec<ContactInfo>>,
outbound_budget: DataBudget, outbound_budget: DataBudget,
@ -267,7 +270,7 @@ impl PruneData {
} }
impl Sanitize for PruneData { impl Sanitize for PruneData {
fn sanitize(&self) -> std::result::Result<(), SanitizeError> { fn sanitize(&self) -> Result<(), SanitizeError> {
if self.wallclock >= MAX_WALLCLOCK { if self.wallclock >= MAX_WALLCLOCK {
return Err(SanitizeError::ValueOutOfBounds); return Err(SanitizeError::ValueOutOfBounds);
} }
@ -323,7 +326,7 @@ pub fn make_accounts_hashes_message(
pub(crate) type Ping = ping_pong::Ping<[u8; GOSSIP_PING_TOKEN_SIZE]>; pub(crate) type Ping = ping_pong::Ping<[u8; GOSSIP_PING_TOKEN_SIZE]>;
// TODO These messages should go through the gpu pipeline for spam filtering // TODO These messages should go through the gpu pipeline for spam filtering
#[frozen_abi(digest = "CH5BWuhAyvUiUQYgu2Lcwu7eoiW6bQitvtLS1yFsdmrE")] #[frozen_abi(digest = "GANv3KVkTYF84kmg1bAuWEZd9MaiYzPquuu13hup3379")]
#[derive(Serialize, Deserialize, Debug, AbiEnumVisitor, AbiExample)] #[derive(Serialize, Deserialize, Debug, AbiEnumVisitor, AbiExample)]
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]
enum Protocol { enum Protocol {
@ -408,7 +411,7 @@ impl Protocol {
} }
impl Sanitize for Protocol { impl Sanitize for Protocol {
fn sanitize(&self) -> std::result::Result<(), SanitizeError> { fn sanitize(&self) -> Result<(), SanitizeError> {
match self { match self {
Protocol::PullRequest(filter, val) => { Protocol::PullRequest(filter, val) => {
filter.sanitize()?; filter.sanitize()?;
@ -894,7 +897,7 @@ impl ClusterInfo {
} }
} }
pub(crate) fn push_epoch_slots(&self, mut update: &[Slot]) { pub fn push_epoch_slots(&self, mut update: &[Slot]) {
let current_slots: Vec<_> = { let current_slots: Vec<_> = {
let gossip = let gossip =
self.time_gossip_read_lock("lookup_epoch_slots", &self.stats.epoch_slots_lookup); self.time_gossip_read_lock("lookup_epoch_slots", &self.stats.epoch_slots_lookup);
@ -968,7 +971,7 @@ impl ClusterInfo {
GossipWriteLock::new(self.gossip.write().unwrap(), label, counter) GossipWriteLock::new(self.gossip.write().unwrap(), label, counter)
} }
pub(crate) fn push_message(&self, message: CrdsValue) { pub fn push_message(&self, message: CrdsValue) {
self.local_message_pending_push_queue self.local_message_pending_push_queue
.lock() .lock()
.unwrap() .unwrap()
@ -1094,7 +1097,11 @@ impl ClusterInfo {
} }
} }
pub fn send_vote(&self, vote: &Transaction, tpu: Option<SocketAddr>) -> Result<()> { pub fn send_vote(
&self,
vote: &Transaction,
tpu: Option<SocketAddr>,
) -> Result<(), GossipError> {
let tpu = tpu.unwrap_or_else(|| self.my_contact_info().tpu); let tpu = tpu.unwrap_or_else(|| self.my_contact_info().tpu);
let buf = serialize(vote)?; let buf = serialize(vote)?;
self.socket.send_to(&buf, &tpu)?; self.socket.send_to(&buf, &tpu)?;
@ -1119,7 +1126,11 @@ impl ClusterInfo {
(labels, txs) (labels, txs)
} }
pub(crate) fn push_duplicate_shred(&self, shred: &Shred, other_payload: &[u8]) -> Result<()> { pub fn push_duplicate_shred(
&self,
shred: &Shred,
other_payload: &[u8],
) -> Result<(), GossipError> {
self.gossip.write().unwrap().push_duplicate_shred( self.gossip.write().unwrap().push_duplicate_shred(
&self.keypair, &self.keypair,
shred, shred,
@ -1154,7 +1165,7 @@ impl ClusterInfo {
.map(map) .map(map)
} }
pub(crate) fn get_epoch_slots(&self, cursor: &mut Cursor) -> Vec<EpochSlots> { pub fn get_epoch_slots(&self, cursor: &mut Cursor) -> Vec<EpochSlots> {
let gossip = self.gossip.read().unwrap(); let gossip = self.gossip.read().unwrap();
let entries = gossip.crds.get_epoch_slots(cursor); let entries = gossip.crds.get_epoch_slots(cursor);
entries entries
@ -1203,7 +1214,7 @@ impl ClusterInfo {
} }
// All nodes in gossip (including spy nodes) and the last time we heard about them // All nodes in gossip (including spy nodes) and the last time we heard about them
pub(crate) fn all_peers(&self) -> Vec<(ContactInfo, u64)> { pub fn all_peers(&self) -> Vec<(ContactInfo, u64)> {
self.gossip self.gossip
.read() .read()
.unwrap() .unwrap()
@ -1376,7 +1387,7 @@ impl ClusterInfo {
packet: &Packet, packet: &Packet,
s: &UdpSocket, s: &UdpSocket,
forwarded: bool, forwarded: bool,
) -> Result<()> { ) -> Result<(), GossipError> {
trace!("retransmit orders {}", peers.len()); trace!("retransmit orders {}", peers.len());
let dests: Vec<_> = if forwarded { let dests: Vec<_> = if forwarded {
peers peers
@ -1398,7 +1409,7 @@ impl ClusterInfo {
1 1
); );
error!("retransmit result {:?}", e); error!("retransmit result {:?}", e);
return Err(Error::Io(e)); return Err(GossipError::Io(e));
} }
} }
} }
@ -1561,7 +1572,7 @@ impl ClusterInfo {
let mut push_queue = self.local_message_pending_push_queue.lock().unwrap(); let mut push_queue = self.local_message_pending_push_queue.lock().unwrap();
std::mem::take(&mut *push_queue) std::mem::take(&mut *push_queue)
} }
#[cfg(test)] // Used in tests
pub fn flush_push_queue(&self) { pub fn flush_push_queue(&self) {
let pending_push_messages = self.drain_push_queue(); let pending_push_messages = self.drain_push_queue();
let mut gossip = self.gossip.write().unwrap(); let mut gossip = self.gossip.write().unwrap();
@ -1649,7 +1660,7 @@ impl ClusterInfo {
sender: &PacketSender, sender: &PacketSender,
generate_pull_requests: bool, generate_pull_requests: bool,
require_stake_for_gossip: bool, require_stake_for_gossip: bool,
) -> Result<()> { ) -> Result<(), GossipError> {
let reqs = self.generate_new_gossip_requests( let reqs = self.generate_new_gossip_requests(
thread_pool, thread_pool,
gossip_validators, gossip_validators,
@ -2491,7 +2502,7 @@ impl ClusterInfo {
feature_set: Option<&FeatureSet>, feature_set: Option<&FeatureSet>,
epoch_duration: Duration, epoch_duration: Duration,
should_check_duplicate_instance: bool, should_check_duplicate_instance: bool,
) -> Result<()> { ) -> Result<(), GossipError> {
let _st = ScopedTimer::from(&self.stats.process_gossip_packets_time); let _st = ScopedTimer::from(&self.stats.process_gossip_packets_time);
self.stats self.stats
.packets_received_count .packets_received_count
@ -2517,7 +2528,7 @@ impl ClusterInfo {
if should_check_duplicate_instance { if should_check_duplicate_instance {
for value in values { for value in values {
if self.instance.check_duplicate(value) { if self.instance.check_duplicate(value) {
return Err(Error::DuplicateNodeInstance); return Err(GossipError::DuplicateNodeInstance);
} }
} }
} }
@ -2605,7 +2616,7 @@ impl ClusterInfo {
thread_pool: &ThreadPool, thread_pool: &ThreadPool,
last_print: &mut Instant, last_print: &mut Instant,
should_check_duplicate_instance: bool, should_check_duplicate_instance: bool,
) -> Result<()> { ) -> Result<(), GossipError> {
const RECV_TIMEOUT: Duration = Duration::from_secs(1); const RECV_TIMEOUT: Duration = Duration::from_secs(1);
const SUBMIT_GOSSIP_STATS_INTERVAL: Duration = Duration::from_secs(2); const SUBMIT_GOSSIP_STATS_INTERVAL: Duration = Duration::from_secs(2);
let packets: Vec<_> = requests_receiver.recv_timeout(RECV_TIMEOUT)?.packets.into(); let packets: Vec<_> = requests_receiver.recv_timeout(RECV_TIMEOUT)?.packets.into();
@ -2678,7 +2689,7 @@ impl ClusterInfo {
should_check_duplicate_instance, should_check_duplicate_instance,
) { ) {
match err { match err {
Error::RecvTimeoutError(_) => { GossipError::RecvTimeoutError(_) => {
let table_size = self.gossip.read().unwrap().crds.len(); let table_size = self.gossip.read().unwrap().crds.len();
debug!( debug!(
"{}: run_listen timeout, table size: {}", "{}: run_listen timeout, table size: {}",
@ -2686,7 +2697,7 @@ impl ClusterInfo {
table_size, table_size,
); );
} }
Error::DuplicateNodeInstance => { GossipError::DuplicateNodeInstance => {
error!( error!(
"duplicate running instances of the same validator node: {}", "duplicate running instances of the same validator node: {}",
self.id() self.id()
@ -3013,7 +3024,7 @@ pub fn push_messages_to_peer(
messages: Vec<CrdsValue>, messages: Vec<CrdsValue>,
self_id: Pubkey, self_id: Pubkey,
peer_gossip: SocketAddr, peer_gossip: SocketAddr,
) -> Result<()> { ) -> Result<(), GossipError> {
let reqs: Vec<_> = ClusterInfo::split_gossip_messages(PUSH_MESSAGE_MAX_PAYLOAD_SIZE, messages) let reqs: Vec<_> = ClusterInfo::split_gossip_messages(PUSH_MESSAGE_MAX_PAYLOAD_SIZE, messages)
.map(move |payload| (peer_gossip, Protocol::PushMessage(self_id, payload))) .map(move |payload| (peer_gossip, Protocol::PushMessage(self_id, payload)))
.collect(); .collect();
@ -3033,21 +3044,25 @@ pub fn stake_weight_peers(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use {
use crate::{ super::*,
crds_gossip_pull::tests::MIN_NUM_BLOOM_FILTERS, crate::{
crds_value::{CrdsValue, CrdsValueLabel, Vote as CrdsVote}, crds_gossip_pull::tests::MIN_NUM_BLOOM_FILTERS,
duplicate_shred::{self, tests::new_rand_shred, MAX_DUPLICATE_SHREDS}, crds_value::{CrdsValue, CrdsValueLabel, Vote as CrdsVote},
duplicate_shred::{self, tests::new_rand_shred, MAX_DUPLICATE_SHREDS},
},
itertools::izip,
rand::{seq::SliceRandom, SeedableRng},
rand_chacha::ChaChaRng,
solana_ledger::shred::Shredder,
solana_sdk::signature::{Keypair, Signer},
solana_vote_program::{vote_instruction, vote_state::Vote},
std::{
iter::repeat_with,
net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddrV4},
sync::Arc,
},
}; };
use itertools::izip;
use rand::{seq::SliceRandom, SeedableRng};
use rand_chacha::ChaChaRng;
use solana_ledger::shred::Shredder;
use solana_sdk::signature::{Keypair, Signer};
use solana_vote_program::{vote_instruction, vote_state::Vote};
use std::iter::repeat_with;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddrV4};
use std::sync::Arc;
#[test] #[test]
fn test_gossip_node() { fn test_gossip_node() {

View File

@ -1,13 +1,15 @@
use crate::crds_gossip::CrdsGossip; use {
use solana_measure::measure::Measure; crate::crds_gossip::CrdsGossip,
use solana_sdk::pubkey::Pubkey; solana_measure::measure::Measure,
use std::{ solana_sdk::pubkey::Pubkey,
collections::HashMap, std::{
sync::{ collections::HashMap,
atomic::{AtomicU64, Ordering}, sync::{
RwLock, atomic::{AtomicU64, Ordering},
RwLock,
},
time::Instant,
}, },
time::Instant,
}; };
#[derive(Default)] #[derive(Default)]

View File

@ -1,12 +1,14 @@
use crate::crds_value::MAX_WALLCLOCK; use {
use solana_sdk::pubkey::Pubkey; crate::crds_value::MAX_WALLCLOCK,
#[cfg(test)] solana_sdk::{
use solana_sdk::rpc_port; pubkey::Pubkey,
use solana_sdk::sanitize::{Sanitize, SanitizeError}; rpc_port,
#[cfg(test)] sanitize::{Sanitize, SanitizeError},
use solana_sdk::signature::{Keypair, Signer}; signature::{Keypair, Signer},
use solana_sdk::timing::timestamp; timing::timestamp,
use std::net::{IpAddr, SocketAddr}; },
std::net::{IpAddr, SocketAddr},
};
/// Structure representing a node on the network /// Structure representing a node on the network
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, AbiExample, Deserialize, Serialize)] #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, AbiExample, Deserialize, Serialize)]
@ -132,8 +134,8 @@ impl ContactInfo {
} }
} }
#[cfg(test)] // Used in tests
pub(crate) fn new_with_pubkey_socketaddr(pubkey: &Pubkey, bind_addr: &SocketAddr) -> Self { pub fn new_with_pubkey_socketaddr(pubkey: &Pubkey, bind_addr: &SocketAddr) -> Self {
fn next_port(addr: &SocketAddr, nxt: u16) -> SocketAddr { fn next_port(addr: &SocketAddr, nxt: u16) -> SocketAddr {
let mut nxt_addr = *addr; let mut nxt_addr = *addr;
nxt_addr.set_port(addr.port() + nxt); nxt_addr.set_port(addr.port() + nxt);
@ -166,8 +168,8 @@ impl ContactInfo {
} }
} }
#[cfg(test)] // Used in tests
pub(crate) fn new_with_socketaddr(bind_addr: &SocketAddr) -> Self { pub fn new_with_socketaddr(bind_addr: &SocketAddr) -> Self {
let keypair = Keypair::new(); let keypair = Keypair::new();
Self::new_with_pubkey_socketaddr(&keypair.pubkey(), bind_addr) Self::new_with_pubkey_socketaddr(&keypair.pubkey(), bind_addr)
} }

View File

@ -24,19 +24,27 @@
//! A value is updated to a new version if the labels match, and the value //! A value is updated to a new version if the labels match, and the value
//! wallclock is later, or the value hash is greater. //! wallclock is later, or the value hash is greater.
use crate::contact_info::ContactInfo; use {
use crate::crds_shards::CrdsShards; crate::{
use crate::crds_value::{CrdsData, CrdsValue, CrdsValueLabel, LowestSlot}; contact_info::ContactInfo,
use bincode::serialize; crds_shards::CrdsShards,
use indexmap::map::{rayon::ParValues, Entry, IndexMap}; crds_value::{CrdsData, CrdsValue, CrdsValueLabel, LowestSlot},
use indexmap::set::IndexSet; },
use rayon::{prelude::*, ThreadPool}; bincode::serialize,
use solana_sdk::hash::{hash, Hash}; indexmap::{
use solana_sdk::pubkey::Pubkey; map::{rayon::ParValues, Entry, IndexMap},
use std::{ set::IndexSet,
cmp::Ordering, },
collections::{hash_map, BTreeMap, HashMap, VecDeque}, rayon::{prelude::*, ThreadPool},
ops::{Bound, Index, IndexMut}, solana_sdk::{
hash::{hash, Hash},
pubkey::Pubkey,
},
std::{
cmp::Ordering,
collections::{hash_map, BTreeMap, HashMap, VecDeque},
ops::{Bound, Index, IndexMut},
},
}; };
const CRDS_SHARDS_BITS: u32 = 8; const CRDS_SHARDS_BITS: u32 = 8;
@ -539,16 +547,18 @@ impl Crds {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use {
use crate::{ super::*,
contact_info::ContactInfo, crate::{
crds_value::{new_rand_timestamp, NodeInstance}, contact_info::ContactInfo,
crds_value::{new_rand_timestamp, NodeInstance},
},
rand::{thread_rng, Rng, SeedableRng},
rand_chacha::ChaChaRng,
rayon::ThreadPoolBuilder,
solana_sdk::signature::{Keypair, Signer},
std::{collections::HashSet, iter::repeat_with},
}; };
use rand::{thread_rng, Rng, SeedableRng};
use rand_chacha::ChaChaRng;
use rayon::ThreadPoolBuilder;
use solana_sdk::signature::{Keypair, Signer};
use std::{collections::HashSet, iter::repeat_with};
#[test] #[test]
fn test_insert() { fn test_insert() {

View File

@ -3,31 +3,33 @@
//! designed to run with a simulator or over a UDP network connection with messages up to a //! designed to run with a simulator or over a UDP network connection with messages up to a
//! packet::PACKET_DATA_SIZE size. //! packet::PACKET_DATA_SIZE size.
use crate::{ use {
cluster_info::Ping, crate::{
contact_info::ContactInfo, cluster_info::Ping,
crds::Crds, contact_info::ContactInfo,
crds_gossip_error::CrdsGossipError, crds::Crds,
crds_gossip_pull::{CrdsFilter, CrdsGossipPull, ProcessPullStats}, crds_gossip_error::CrdsGossipError,
crds_gossip_push::{CrdsGossipPush, CRDS_GOSSIP_NUM_ACTIVE}, crds_gossip_pull::{CrdsFilter, CrdsGossipPull, ProcessPullStats},
crds_value::{CrdsData, CrdsValue}, crds_gossip_push::{CrdsGossipPush, CRDS_GOSSIP_NUM_ACTIVE},
duplicate_shred::{self, DuplicateShredIndex, LeaderScheduleFn, MAX_DUPLICATE_SHREDS}, crds_value::{CrdsData, CrdsValue},
ping_pong::PingCache, duplicate_shred::{self, DuplicateShredIndex, LeaderScheduleFn, MAX_DUPLICATE_SHREDS},
}; ping_pong::PingCache,
use itertools::Itertools; },
use rayon::ThreadPool; itertools::Itertools,
use solana_ledger::shred::Shred; rayon::ThreadPool,
use solana_sdk::{ solana_ledger::shred::Shred,
hash::Hash, solana_sdk::{
pubkey::Pubkey, hash::Hash,
signature::{Keypair, Signer}, pubkey::Pubkey,
timing::timestamp, signature::{Keypair, Signer},
}; timing::timestamp,
use std::{ },
collections::{HashMap, HashSet}, std::{
net::SocketAddr, collections::{HashMap, HashSet},
sync::Mutex, net::SocketAddr,
time::Duration, sync::Mutex,
time::Duration,
},
}; };
pub struct CrdsGossip { pub struct CrdsGossip {
@ -361,11 +363,11 @@ pub fn get_weight(max_weight: f32, time_since_last_selected: u32, stake: f32) ->
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use {
use crate::contact_info::ContactInfo; super::*,
use crate::crds_value::CrdsData; crate::{contact_info::ContactInfo, crds_value::CrdsData},
use solana_sdk::hash::hash; solana_sdk::{hash::hash, timing::timestamp},
use solana_sdk::timing::timestamp; };
#[test] #[test]
fn test_prune_errors() { fn test_prune_errors() {

View File

@ -9,32 +9,37 @@
//! with random hash functions. So each subsequent request will have a different distribution //! with random hash functions. So each subsequent request will have a different distribution
//! of false positives. //! of false positives.
use crate::{ use {
cluster_info::{Ping, CRDS_UNIQUE_PUBKEY_CAPACITY}, crate::{
contact_info::ContactInfo, cluster_info::{Ping, CRDS_UNIQUE_PUBKEY_CAPACITY},
crds::Crds, contact_info::ContactInfo,
crds_gossip::{get_stake, get_weight}, crds::Crds,
crds_gossip_error::CrdsGossipError, crds_gossip::{get_stake, get_weight},
crds_value::CrdsValue, crds_gossip_error::CrdsGossipError,
ping_pong::PingCache, crds_value::CrdsValue,
}; ping_pong::PingCache,
use itertools::Itertools; },
use lru::LruCache; itertools::Itertools,
use rand::distributions::{Distribution, WeightedIndex}; lru::LruCache,
use rand::Rng; rand::{
use rayon::{prelude::*, ThreadPool}; distributions::{Distribution, WeightedIndex},
use solana_runtime::bloom::{AtomicBloom, Bloom}; Rng,
use solana_sdk::{ },
hash::{hash, Hash}, rayon::{prelude::*, ThreadPool},
pubkey::Pubkey, solana_runtime::bloom::{AtomicBloom, Bloom},
signature::{Keypair, Signer}, solana_sdk::{
}; hash::{hash, Hash},
use std::{ pubkey::Pubkey,
collections::{HashMap, HashSet, VecDeque}, signature::{Keypair, Signer},
convert::TryInto, },
net::SocketAddr, std::{
sync::Mutex, collections::{HashMap, HashSet, VecDeque},
time::{Duration, Instant}, convert::TryInto,
iter::repeat_with,
net::SocketAddr,
sync::Mutex,
time::{Duration, Instant},
},
}; };
pub const CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS: u64 = 15000; pub const CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS: u64 = 15000;
@ -140,11 +145,10 @@ impl CrdsFilterSet {
let max_bits = (max_bytes * 8) as f64; let max_bits = (max_bytes * 8) as f64;
let max_items = CrdsFilter::max_items(max_bits, FALSE_RATE, KEYS); let max_items = CrdsFilter::max_items(max_bits, FALSE_RATE, KEYS);
let mask_bits = CrdsFilter::mask_bits(num_items as f64, max_items as f64); let mask_bits = CrdsFilter::mask_bits(num_items as f64, max_items as f64);
let filters = std::iter::repeat_with(|| { let filters =
Bloom::random(max_items as usize, FALSE_RATE, max_bits as usize).into() repeat_with(|| Bloom::random(max_items as usize, FALSE_RATE, max_bits as usize).into())
}) .take(1 << mask_bits)
.take(1 << mask_bits) .collect();
.collect();
Self { filters, mask_bits } Self { filters, mask_bits }
} }
@ -238,7 +242,7 @@ impl CrdsGossipPull {
let num_samples = peers.len() * 2; let num_samples = peers.len() * 2;
let index = WeightedIndex::new(weights).unwrap(); let index = WeightedIndex::new(weights).unwrap();
let sample_peer = move || peers[index.sample(&mut rng)]; let sample_peer = move || peers[index.sample(&mut rng)];
std::iter::repeat_with(sample_peer).take(num_samples) repeat_with(sample_peer).take(num_samples)
}; };
let peer = { let peer = {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
@ -607,20 +611,23 @@ impl CrdsGossipPull {
} }
#[cfg(test)] #[cfg(test)]
pub(crate) mod tests { pub(crate) mod tests {
use super::*; use {
use crate::cluster_info::MAX_BLOOM_SIZE; super::*,
use crate::contact_info::ContactInfo; crate::{
use crate::crds_value::{CrdsData, Vote}; cluster_info::MAX_BLOOM_SIZE,
use itertools::Itertools; contact_info::ContactInfo,
use rand::{seq::SliceRandom, thread_rng}; crds_value::{CrdsData, Vote},
use rayon::ThreadPoolBuilder; },
use solana_perf::test_tx::test_tx; itertools::Itertools,
use solana_sdk::{ rand::{seq::SliceRandom, thread_rng},
hash::{hash, HASH_BYTES}, rayon::ThreadPoolBuilder,
packet::PACKET_DATA_SIZE, solana_perf::test_tx::test_tx,
timing::timestamp, solana_sdk::{
hash::{hash, HASH_BYTES},
packet::PACKET_DATA_SIZE,
timing::timestamp,
},
}; };
use std::{iter::repeat_with, time::Duration};
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
pub(crate) const MIN_NUM_BLOOM_FILTERS: usize = 1; pub(crate) const MIN_NUM_BLOOM_FILTERS: usize = 1;
@ -816,7 +823,7 @@ pub(crate) mod tests {
let mut rng = thread_rng(); let mut rng = thread_rng();
let crds_filter_set = let crds_filter_set =
CrdsFilterSet::new(/*num_items=*/ 9672788, /*max_bytes=*/ 8196); CrdsFilterSet::new(/*num_items=*/ 9672788, /*max_bytes=*/ 8196);
let hash_values: Vec<_> = std::iter::repeat_with(|| solana_sdk::hash::new_rand(&mut rng)) let hash_values: Vec<_> = repeat_with(|| solana_sdk::hash::new_rand(&mut rng))
.take(1024) .take(1024)
.collect(); .collect();
for hash_value in &hash_values { for hash_value in &hash_values {

View File

@ -8,25 +8,27 @@
//! the local nodes wallclock window they are dropped silently. //! the local nodes wallclock window they are dropped silently.
//! 2. The prune set is stored in a Bloom filter. //! 2. The prune set is stored in a Bloom filter.
use crate::{ use {
cluster_info::CRDS_UNIQUE_PUBKEY_CAPACITY, crate::{
contact_info::ContactInfo, cluster_info::CRDS_UNIQUE_PUBKEY_CAPACITY,
crds::{Crds, Cursor}, contact_info::ContactInfo,
crds_gossip::{get_stake, get_weight}, crds::{Crds, Cursor},
crds_gossip_error::CrdsGossipError, crds_gossip::{get_stake, get_weight},
crds_value::CrdsValue, crds_gossip_error::CrdsGossipError,
weighted_shuffle::weighted_shuffle, crds_value::CrdsValue,
}; weighted_shuffle::weighted_shuffle,
use bincode::serialized_size; },
use indexmap::map::IndexMap; bincode::serialized_size,
use lru::LruCache; indexmap::map::IndexMap,
use rand::{seq::SliceRandom, Rng}; lru::LruCache,
use solana_runtime::bloom::{AtomicBloom, Bloom}; rand::{seq::SliceRandom, Rng},
use solana_sdk::{packet::PACKET_DATA_SIZE, pubkey::Pubkey, timing::timestamp}; solana_runtime::bloom::{AtomicBloom, Bloom},
use std::{ solana_sdk::{packet::PACKET_DATA_SIZE, pubkey::Pubkey, timing::timestamp},
cmp, std::{
collections::{HashMap, HashSet}, cmp,
ops::RangeBounds, collections::{HashMap, HashSet},
ops::RangeBounds,
},
}; };
pub const CRDS_GOSSIP_NUM_ACTIVE: usize = 30; pub const CRDS_GOSSIP_NUM_ACTIVE: usize = 30;
@ -395,9 +397,10 @@ impl CrdsGossipPush {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use {
use crate::contact_info::ContactInfo; super::*,
use crate::crds_value::CrdsData; crate::{contact_info::ContactInfo, crds_value::CrdsData},
};
#[test] #[test]
fn test_prune() { fn test_prune() {

View File

@ -1,8 +1,11 @@
use crate::crds::VersionedCrdsValue; use {
use crate::crds_gossip_pull::CrdsFilter; crate::{crds::VersionedCrdsValue, crds_gossip_pull::CrdsFilter},
use indexmap::map::IndexMap; indexmap::map::IndexMap,
use std::cmp::Ordering; std::{
use std::ops::{Index, IndexMut}; cmp::Ordering,
ops::{Index, IndexMut},
},
};
#[derive(Clone)] #[derive(Clone)]
pub struct CrdsShards { pub struct CrdsShards {
@ -129,11 +132,13 @@ where
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use {
use crate::{crds::Crds, crds_value::CrdsValue}; super::*,
use rand::{thread_rng, Rng}; crate::{crds::Crds, crds_value::CrdsValue},
use solana_sdk::timing::timestamp; rand::{thread_rng, Rng},
use std::{collections::HashSet, iter::repeat_with, ops::Index}; solana_sdk::timing::timestamp,
std::{collections::HashSet, iter::repeat_with, ops::Index},
};
fn new_test_crds_value<R: Rng>(rng: &mut R) -> VersionedCrdsValue { fn new_test_crds_value<R: Rng>(rng: &mut R) -> VersionedCrdsValue {
let value = CrdsValue::new_rand(rng, None); let value = CrdsValue::new_rand(rng, None);

View File

@ -1,28 +1,30 @@
use crate::{ use {
cluster_info::MAX_SNAPSHOT_HASHES, crate::{
contact_info::ContactInfo, cluster_info::MAX_SNAPSHOT_HASHES,
deprecated, contact_info::ContactInfo,
duplicate_shred::{DuplicateShred, DuplicateShredIndex, MAX_DUPLICATE_SHREDS}, deprecated,
epoch_slots::EpochSlots, duplicate_shred::{DuplicateShred, DuplicateShredIndex, MAX_DUPLICATE_SHREDS},
}; epoch_slots::EpochSlots,
use bincode::{serialize, serialized_size}; },
use rand::{CryptoRng, Rng}; bincode::{serialize, serialized_size},
use serde::de::{Deserialize, Deserializer}; rand::{CryptoRng, Rng},
use solana_sdk::sanitize::{Sanitize, SanitizeError}; serde::de::{Deserialize, Deserializer},
use solana_sdk::timing::timestamp; solana_sdk::sanitize::{Sanitize, SanitizeError},
use solana_sdk::{ solana_sdk::timing::timestamp,
clock::Slot, solana_sdk::{
hash::Hash, clock::Slot,
pubkey::{self, Pubkey}, hash::Hash,
signature::{Keypair, Signable, Signature, Signer}, pubkey::{self, Pubkey},
transaction::Transaction, signature::{Keypair, Signable, Signature, Signer},
}; transaction::Transaction,
use solana_vote_program::vote_transaction::parse_vote_transaction; },
use std::{ solana_vote_program::vote_transaction::parse_vote_transaction,
borrow::{Borrow, Cow}, std::{
cmp::Ordering, borrow::{Borrow, Cow},
collections::{hash_map::Entry, BTreeSet, HashMap}, cmp::Ordering,
fmt, collections::{hash_map::Entry, BTreeSet, HashMap},
fmt,
},
}; };
pub const MAX_WALLCLOCK: u64 = 1_000_000_000_000_000; pub const MAX_WALLCLOCK: u64 = 1_000_000_000_000_000;
@ -684,17 +686,20 @@ pub(crate) fn sanitize_wallclock(wallclock: u64) -> Result<(), SanitizeError> {
#[cfg(test)] #[cfg(test)]
mod test { mod test {
use super::*; use {
use crate::contact_info::ContactInfo; super::*,
use bincode::{deserialize, Options}; crate::contact_info::ContactInfo,
use rand::SeedableRng; bincode::{deserialize, Options},
use rand_chacha::ChaChaRng; rand::SeedableRng,
use solana_perf::test_tx::test_tx; rand_chacha::ChaChaRng,
use solana_sdk::signature::{Keypair, Signer}; solana_perf::test_tx::test_tx,
use solana_sdk::timing::timestamp; solana_sdk::{
use solana_vote_program::{vote_instruction, vote_state}; signature::{Keypair, Signer},
use std::cmp::Ordering; timing::timestamp,
use std::iter::repeat_with; },
solana_vote_program::{vote_instruction, vote_state},
std::{cmp::Ordering, iter::repeat_with},
};
#[test] #[test]
fn test_keys_and_values() { fn test_keys_and_values() {

View File

@ -87,8 +87,7 @@ impl DataBudget {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use {super::*, std::time::Duration};
use std::time::Duration;
#[test] #[test]
fn test_data_budget() { fn test_data_budget() {

View File

@ -1,20 +1,22 @@
use crate::crds_value::sanitize_wallclock; use {
use itertools::Itertools; crate::crds_value::sanitize_wallclock,
use solana_ledger::{ itertools::Itertools,
blockstore_meta::DuplicateSlotProof, solana_ledger::{
shred::{Shred, ShredError, ShredType}, blockstore_meta::DuplicateSlotProof,
shred::{Shred, ShredError, ShredType},
},
solana_sdk::{
clock::Slot,
pubkey::Pubkey,
sanitize::{Sanitize, SanitizeError},
},
std::{
collections::{hash_map::Entry, HashMap},
convert::TryFrom,
num::TryFromIntError,
},
thiserror::Error,
}; };
use solana_sdk::{
clock::Slot,
pubkey::Pubkey,
sanitize::{Sanitize, SanitizeError},
};
use std::{
collections::{hash_map::Entry, HashMap},
convert::TryFrom,
num::TryFromIntError,
};
use thiserror::Error;
const DUPLICATE_SHRED_HEADER_SIZE: usize = 63; const DUPLICATE_SHRED_HEADER_SIZE: usize = 63;

View File

@ -1,11 +1,17 @@
use crate::cluster_info::MAX_CRDS_OBJECT_SIZE; use {
use crate::crds_value::{self, MAX_SLOT, MAX_WALLCLOCK}; crate::{
use bincode::serialized_size; cluster_info::MAX_CRDS_OBJECT_SIZE,
use bv::BitVec; crds_value::{self, MAX_SLOT, MAX_WALLCLOCK},
use flate2::{Compress, Compression, Decompress, FlushCompress, FlushDecompress}; },
use solana_sdk::clock::Slot; bincode::serialized_size,
use solana_sdk::pubkey::Pubkey; bv::BitVec,
use solana_sdk::sanitize::{Sanitize, SanitizeError}; flate2::{Compress, Compression, Decompress, FlushCompress, FlushDecompress},
solana_sdk::{
clock::Slot,
pubkey::Pubkey,
sanitize::{Sanitize, SanitizeError},
},
};
const MAX_SLOTS_PER_ENTRY: usize = 2048 * 8; const MAX_SLOTS_PER_ENTRY: usize = 2048 * 8;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)] #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, AbiExample)]

View File

@ -0,0 +1,27 @@
use {
crate::duplicate_shred,
std::{io, sync},
thiserror::Error,
};
#[derive(Error, Debug)]
pub enum GossipError {
#[error("duplicate node instance")]
DuplicateNodeInstance,
#[error(transparent)]
DuplicateShredError(#[from] duplicate_shred::Error),
#[error(transparent)]
Io(#[from] io::Error),
#[error(transparent)]
RecvTimeoutError(#[from] sync::mpsc::RecvTimeoutError),
#[error("send error")]
SendError,
#[error("serialization error")]
Serialize(#[from] Box<bincode::ErrorKind>),
}
impl<T> std::convert::From<sync::mpsc::SendError<T>> for GossipError {
fn from(_e: sync::mpsc::SendError<T>) -> GossipError {
GossipError::SendError
}
}

View File

@ -1,26 +1,30 @@
//! The `gossip_service` module implements the network control plane. //! The `gossip_service` module implements the network control plane.
use crate::cluster_info::{ClusterInfo, VALIDATOR_PORT_RANGE}; use {
use crate::contact_info::ContactInfo; crate::{
use rand::{thread_rng, Rng}; cluster_info::{ClusterInfo, VALIDATOR_PORT_RANGE},
use solana_client::thin_client::{create_client, ThinClient}; contact_info::ContactInfo,
use solana_perf::recycler::Recycler; },
use solana_runtime::bank_forks::BankForks; rand::{thread_rng, Rng},
use solana_sdk::{ solana_client::thin_client::{create_client, ThinClient},
pubkey::Pubkey, solana_perf::recycler::Recycler,
signature::{Keypair, Signer}, solana_runtime::bank_forks::BankForks,
}; solana_sdk::{
use solana_streamer::streamer; pubkey::Pubkey,
use std::{ signature::{Keypair, Signer},
collections::HashSet, },
net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket}, solana_streamer::streamer,
sync::{ std::{
atomic::{AtomicBool, Ordering}, collections::HashSet,
mpsc::channel, net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket},
{Arc, RwLock}, sync::{
atomic::{AtomicBool, Ordering},
mpsc::channel,
{Arc, RwLock},
},
thread::{self, sleep, JoinHandle},
time::{Duration, Instant},
}, },
thread::{self, sleep, JoinHandle},
time::{Duration, Instant},
}; };
pub struct GossipService { pub struct GossipService {
@ -305,10 +309,11 @@ fn make_gossip_node(
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use {
use crate::cluster_info::{ClusterInfo, Node}; super::*,
use std::sync::atomic::AtomicBool; crate::cluster_info::{ClusterInfo, Node},
use std::sync::Arc; std::sync::{atomic::AtomicBool, Arc},
};
#[test] #[test]
#[ignore] #[ignore]

38
gossip/src/lib.rs Normal file
View File

@ -0,0 +1,38 @@
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
pub mod cluster_info;
mod cluster_info_metrics;
#[macro_use]
pub mod contact_info;
pub mod crds;
pub mod crds_gossip;
pub mod crds_gossip_error;
pub mod crds_gossip_pull;
pub mod crds_gossip_push;
pub mod crds_shards;
pub mod crds_value;
pub mod data_budget;
mod deprecated;
pub mod duplicate_shred;
pub mod epoch_slots;
pub mod gossip_error;
pub mod gossip_service;
pub mod ping_pong;
pub mod weighted_shuffle;
#[macro_use]
extern crate log;
#[cfg(test)]
#[macro_use]
extern crate matches;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate solana_frozen_abi_macro;
#[macro_use]
extern crate solana_metrics;

View File

@ -1,21 +1,23 @@
//! A command-line executable for monitoring a cluster's gossip plane. //! A command-line executable for monitoring a cluster's gossip plane.
use clap::{ use {
crate_description, crate_name, value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, clap::{
SubCommand, crate_description, crate_name, value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches,
}; SubCommand,
use solana_clap_utils::{ },
input_parsers::keypair_of, solana_clap_utils::{
input_validators::{is_keypair_or_ask_keyword, is_port, is_pubkey}, input_parsers::keypair_of,
}; input_validators::{is_keypair_or_ask_keyword, is_port, is_pubkey},
use solana_core::{contact_info::ContactInfo, gossip_service::discover}; },
use solana_sdk::pubkey::Pubkey; solana_gossip::{contact_info::ContactInfo, gossip_service::discover},
use std::{ solana_sdk::pubkey::Pubkey,
error, std::{
net::{IpAddr, Ipv4Addr, SocketAddr}, error,
process::exit, net::{IpAddr, Ipv4Addr, SocketAddr},
sync::Arc, process::exit,
time::Duration, sync::Arc,
time::Duration,
},
}; };
fn parse_matches() -> ArgMatches<'static> { fn parse_matches() -> ArgMatches<'static> {

View File

@ -1,14 +1,20 @@
use bincode::{serialize, Error}; use {
use lru::LruCache; bincode::{serialize, Error},
use rand::{AsByteSliceMut, CryptoRng, Rng}; lru::LruCache,
use serde::Serialize; rand::{AsByteSliceMut, CryptoRng, Rng},
use solana_sdk::hash::{self, Hash}; serde::Serialize,
use solana_sdk::pubkey::Pubkey; solana_sdk::{
use solana_sdk::sanitize::{Sanitize, SanitizeError}; hash::{self, Hash},
use solana_sdk::signature::{Keypair, Signable, Signature, Signer}; pubkey::Pubkey,
use std::borrow::Cow; sanitize::{Sanitize, SanitizeError},
use std::net::SocketAddr; signature::{Keypair, Signable, Signature, Signer},
use std::time::{Duration, Instant}; },
std::{
borrow::Cow,
net::SocketAddr,
time::{Duration, Instant},
},
};
#[derive(AbiExample, Debug, Deserialize, Serialize)] #[derive(AbiExample, Debug, Deserialize, Serialize)]
pub struct Ping<T> { pub struct Ping<T> {
@ -252,10 +258,14 @@ impl PingCache {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use {
use std::collections::HashSet; super::*,
use std::iter::repeat_with; std::{
use std::net::{Ipv4Addr, SocketAddrV4}; collections::HashSet,
iter::repeat_with,
net::{Ipv4Addr, SocketAddrV4},
},
};
type Token = [u8; 32]; type Token = [u8; 32];

View File

@ -1,11 +1,12 @@
//! The `weighted_shuffle` module provides an iterator over shuffled weights. //! The `weighted_shuffle` module provides an iterator over shuffled weights.
use itertools::Itertools; use {
use num_traits::{FromPrimitive, ToPrimitive}; itertools::Itertools,
use rand::{Rng, SeedableRng}; num_traits::{FromPrimitive, ToPrimitive},
use rand_chacha::ChaChaRng; rand::{Rng, SeedableRng},
use std::iter; rand_chacha::ChaChaRng,
use std::ops::Div; std::{iter, ops::Div},
};
/// Returns a list of indexes shuffled based on the input weights /// Returns a list of indexes shuffled based on the input weights
/// Note - The sum of all weights must not exceed `u64::MAX` /// Note - The sum of all weights must not exceed `u64::MAX`

View File

@ -1,17 +1,21 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use rayon::iter::ParallelIterator; use {
use rayon::prelude::*; rayon::{iter::ParallelIterator, prelude::*},
use serial_test::serial; serial_test::serial,
use solana_core::cluster_info::{compute_retransmit_peers, ClusterInfo}; solana_gossip::{
use solana_core::contact_info::ContactInfo; cluster_info::{compute_retransmit_peers, ClusterInfo},
use solana_sdk::pubkey::Pubkey; contact_info::ContactInfo,
use std::collections::{HashMap, HashSet}; },
use std::sync::mpsc::channel; solana_sdk::pubkey::Pubkey,
use std::sync::mpsc::TryRecvError; std::{
use std::sync::mpsc::{Receiver, Sender}; collections::{HashMap, HashSet},
use std::sync::Arc; sync::{
use std::sync::Mutex; mpsc::{channel, Receiver, Sender, TryRecvError},
use std::time::Instant; Arc, Mutex,
},
time::Instant,
},
};
type Nodes = HashMap<Pubkey, (bool, HashSet<i32>, Receiver<(i32, bool)>)>; type Nodes = HashMap<Pubkey, (bool, HashSet<i32>, Receiver<(i32, bool)>)>;

View File

@ -1,31 +1,32 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
use bincode::serialized_size; use {
use log::*; bincode::serialized_size,
use rayon::prelude::*; log::*,
use rayon::{ThreadPool, ThreadPoolBuilder}; rayon::{prelude::*, ThreadPool, ThreadPoolBuilder},
use serial_test::serial; serial_test::serial,
use solana_core::{ solana_gossip::{
cluster_info, cluster_info,
contact_info::ContactInfo, contact_info::ContactInfo,
crds_gossip::*, crds_gossip::*,
crds_gossip_error::CrdsGossipError, crds_gossip_error::CrdsGossipError,
crds_gossip_pull::{ProcessPullStats, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS}, crds_gossip_pull::{ProcessPullStats, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS},
crds_gossip_push::CRDS_GOSSIP_PUSH_MSG_TIMEOUT_MS, crds_gossip_push::CRDS_GOSSIP_PUSH_MSG_TIMEOUT_MS,
crds_value::{CrdsData, CrdsValue, CrdsValueLabel}, crds_value::{CrdsData, CrdsValue, CrdsValueLabel},
ping_pong::PingCache, ping_pong::PingCache,
}; },
use solana_rayon_threadlimit::get_thread_count; solana_rayon_threadlimit::get_thread_count,
use solana_sdk::{ solana_sdk::{
hash::hash, hash::hash,
pubkey::Pubkey, pubkey::Pubkey,
signature::{Keypair, Signer}, signature::{Keypair, Signer},
timing::timestamp, timing::timestamp,
}; },
use std::{ std::{
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
ops::Deref, ops::Deref,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
time::{Duration, Instant}, time::{Duration, Instant},
},
}; };
#[derive(Clone)] #[derive(Clone)]

View File

@ -2,28 +2,33 @@
#[macro_use] #[macro_use]
extern crate log; extern crate log;
use rayon::iter::*; use {
use solana_core::{ rayon::iter::*,
cluster_info::{ClusterInfo, Node}, solana_gossip::{
crds::Cursor, cluster_info::{ClusterInfo, Node},
gossip_service::GossipService, crds::Cursor,
gossip_service::GossipService,
},
solana_perf::packet::Packet,
solana_runtime::bank_forks::BankForks,
solana_sdk::{
hash::Hash,
pubkey::Pubkey,
signature::{Keypair, Signer},
timing::timestamp,
transaction::Transaction,
},
solana_vote_program::{vote_instruction, vote_state::Vote},
std::{
net::UdpSocket,
sync::{
atomic::{AtomicBool, Ordering},
Arc, RwLock,
},
thread::sleep,
time::Duration,
},
}; };
use solana_runtime::bank_forks::BankForks;
use solana_perf::packet::Packet;
use solana_sdk::{
hash::Hash,
pubkey::Pubkey,
signature::{Keypair, Signer},
timing::timestamp,
transaction::Transaction,
};
use solana_vote_program::{vote_instruction, vote_state::Vote};
use std::net::UdpSocket;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, RwLock};
use std::thread::sleep;
use std::time::Duration;
fn test_node(exit: &Arc<AtomicBool>) -> (Arc<ClusterInfo>, GossipService, UdpSocket) { fn test_node(exit: &Arc<AtomicBool>) -> (Arc<ClusterInfo>, GossipService, UdpSocket) {
let keypair = Arc::new(Keypair::new()); let keypair = Arc::new(Keypair::new());

View File

@ -21,8 +21,9 @@ solana-config-program = { path = "../programs/config", version = "=1.7.0" }
solana-core = { path = "../core", version = "=1.7.0" } solana-core = { path = "../core", version = "=1.7.0" }
solana-client = { path = "../client", version = "=1.7.0" } solana-client = { path = "../client", version = "=1.7.0" }
solana-download-utils = { path = "../download-utils", version = "=1.7.0" } solana-download-utils = { path = "../download-utils", version = "=1.7.0" }
solana-faucet = { path = "../faucet", version = "=1.7.0" }
solana-exchange-program = { path = "../programs/exchange", version = "=1.7.0" } solana-exchange-program = { path = "../programs/exchange", version = "=1.7.0" }
solana-faucet = { path = "../faucet", version = "=1.7.0" }
solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-ledger = { path = "../ledger", version = "=1.7.0" } solana-ledger = { path = "../ledger", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" } solana-logger = { path = "../logger", version = "=1.7.0" }
solana-runtime = { path = "../runtime", version = "=1.7.0" } solana-runtime = { path = "../runtime", version = "=1.7.0" }

View File

@ -1,7 +1,7 @@
use solana_client::thin_client::ThinClient; use solana_client::thin_client::ThinClient;
use solana_core::contact_info::ContactInfo;
use solana_core::validator::Validator; use solana_core::validator::Validator;
use solana_core::validator::ValidatorConfig; use solana_core::validator::ValidatorConfig;
use solana_gossip::{cluster_info::Node, contact_info::ContactInfo};
use solana_sdk::pubkey::Pubkey; use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::Keypair; use solana_sdk::signature::Keypair;
use std::path::PathBuf; use std::path::PathBuf;
@ -44,10 +44,10 @@ pub trait Cluster {
&mut self, &mut self,
pubkey: &Pubkey, pubkey: &Pubkey,
cluster_validator_info: &mut ClusterValidatorInfo, cluster_validator_info: &mut ClusterValidatorInfo,
) -> (solana_core::cluster_info::Node, Option<ContactInfo>); ) -> (Node, Option<ContactInfo>);
fn restart_node_with_context( fn restart_node_with_context(
cluster_validator_info: ClusterValidatorInfo, cluster_validator_info: ClusterValidatorInfo,
restart_context: (solana_core::cluster_info::Node, Option<ContactInfo>), restart_context: (Node, Option<ContactInfo>),
) -> ClusterValidatorInfo; ) -> ClusterValidatorInfo;
fn add_node(&mut self, pubkey: &Pubkey, cluster_validator_info: ClusterValidatorInfo); fn add_node(&mut self, pubkey: &Pubkey, cluster_validator_info: ClusterValidatorInfo);
fn exit_restart_node(&mut self, pubkey: &Pubkey, config: ValidatorConfig); fn exit_restart_node(&mut self, pubkey: &Pubkey, config: ValidatorConfig);

View File

@ -6,10 +6,10 @@ use log::*;
use rand::{thread_rng, Rng}; use rand::{thread_rng, Rng};
use rayon::prelude::*; use rayon::prelude::*;
use solana_client::thin_client::create_client; use solana_client::thin_client::create_client;
use solana_core::consensus::VOTE_THRESHOLD_DEPTH;
use solana_core::validator::ValidatorExit; use solana_core::validator::ValidatorExit;
use solana_core::{ use solana_gossip::{
cluster_info::VALIDATOR_PORT_RANGE, consensus::VOTE_THRESHOLD_DEPTH, contact_info::ContactInfo, cluster_info::VALIDATOR_PORT_RANGE, contact_info::ContactInfo, gossip_service::discover_cluster,
gossip_service::discover_cluster,
}; };
use solana_ledger::{ use solana_ledger::{
blockstore::Blockstore, blockstore::Blockstore,

View File

@ -6,11 +6,11 @@ use crate::{
use itertools::izip; use itertools::izip;
use log::*; use log::*;
use solana_client::thin_client::{create_client, ThinClient}; use solana_client::thin_client::{create_client, ThinClient};
use solana_core::{ use solana_core::validator::{Validator, ValidatorConfig, ValidatorStartProgress};
use solana_gossip::{
cluster_info::{Node, VALIDATOR_PORT_RANGE}, cluster_info::{Node, VALIDATOR_PORT_RANGE},
contact_info::ContactInfo, contact_info::ContactInfo,
gossip_service::discover_cluster, gossip_service::discover_cluster,
validator::{Validator, ValidatorConfig, ValidatorStartProgress},
}; };
use solana_ledger::create_new_tmp_ledger; use solana_ledger::create_new_tmp_ledger;
use solana_runtime::genesis_utils::{ use solana_runtime::genesis_utils::{
@ -628,7 +628,7 @@ impl Cluster for LocalCluster {
&mut self, &mut self,
pubkey: &Pubkey, pubkey: &Pubkey,
cluster_validator_info: &mut ClusterValidatorInfo, cluster_validator_info: &mut ClusterValidatorInfo,
) -> (solana_core::cluster_info::Node, Option<ContactInfo>) { ) -> (Node, Option<ContactInfo>) {
// Update the stored ContactInfo for this node // Update the stored ContactInfo for this node
let node = Node::new_localhost_with_pubkey(&pubkey); let node = Node::new_localhost_with_pubkey(&pubkey);
cluster_validator_info.info.contact_info = node.info.clone(); cluster_validator_info.info.contact_info = node.info.clone();

View File

@ -13,14 +13,16 @@ use solana_client::{
}; };
use solana_core::{ use solana_core::{
broadcast_stage::BroadcastStageType, broadcast_stage::BroadcastStageType,
cluster_info::{self, VALIDATOR_PORT_RANGE},
consensus::{Tower, SWITCH_FORK_THRESHOLD, VOTE_THRESHOLD_DEPTH}, consensus::{Tower, SWITCH_FORK_THRESHOLD, VOTE_THRESHOLD_DEPTH},
crds_value::{self, CrdsData, CrdsValue},
gossip_service::discover_cluster,
optimistic_confirmation_verifier::OptimisticConfirmationVerifier, optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
validator::ValidatorConfig, validator::ValidatorConfig,
}; };
use solana_download_utils::{download_snapshot, DownloadProgressRecord}; use solana_download_utils::{download_snapshot, DownloadProgressRecord};
use solana_gossip::{
cluster_info::{self, VALIDATOR_PORT_RANGE},
crds_value::{self, CrdsData, CrdsValue},
gossip_service::discover_cluster,
};
use solana_ledger::{ use solana_ledger::{
ancestor_iterator::AncestorIterator, ancestor_iterator::AncestorIterator,
blockstore::{Blockstore, PurgeType}, blockstore::{Blockstore, PurgeType},
@ -1393,7 +1395,7 @@ fn test_mainnet_beta_cluster_type() {
let client = create_client( let client = create_client(
cluster.entry_point_info.client_facing_addr(), cluster.entry_point_info.client_facing_addr(),
solana_core::cluster_info::VALIDATOR_PORT_RANGE, VALIDATOR_PORT_RANGE,
); );
// Programs that are available at epoch 0 // Programs that are available at epoch 0

View File

@ -35,6 +35,7 @@ solana-core = { path = "../core", version = "=1.7.0" }
solana-download-utils = { path = "../download-utils", version = "=1.7.0" } solana-download-utils = { path = "../download-utils", version = "=1.7.0" }
solana-faucet = { path = "../faucet", version = "=1.7.0" } solana-faucet = { path = "../faucet", version = "=1.7.0" }
solana-genesis-utils = { path = "../genesis-utils", version = "=1.7.0" } solana-genesis-utils = { path = "../genesis-utils", version = "=1.7.0" }
solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-ledger = { path = "../ledger", version = "=1.7.0" } solana-ledger = { path = "../ledger", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" } solana-logger = { path = "../logger", version = "=1.7.0" }
solana-metrics = { path = "../metrics", version = "=1.7.0" } solana-metrics = { path = "../metrics", version = "=1.7.0" }

View File

@ -1,5 +1,6 @@
#![allow(clippy::integer_arithmetic)] #![allow(clippy::integer_arithmetic)]
pub use solana_core::{cluster_info::MINIMUM_VALIDATOR_PORT_RANGE_WIDTH, test_validator}; pub use solana_core::test_validator;
pub use solana_gossip::cluster_info::MINIMUM_VALIDATOR_PORT_RANGE_WIDTH;
use { use {
console::style, console::style,
indicatif::{ProgressDrawTarget, ProgressStyle}, indicatif::{ProgressDrawTarget, ProgressStyle},

View File

@ -20,13 +20,8 @@ use {
rpc_client::RpcClient, rpc_config::RpcLeaderScheduleConfig, rpc_client::RpcClient, rpc_config::RpcLeaderScheduleConfig,
rpc_request::MAX_MULTIPLE_ACCOUNTS, rpc_request::MAX_MULTIPLE_ACCOUNTS,
}, },
solana_core::ledger_cleanup_service::{
DEFAULT_MAX_LEDGER_SHREDS, DEFAULT_MIN_MAX_LEDGER_SHREDS,
},
solana_core::{ solana_core::{
cluster_info::{ClusterInfo, Node, VALIDATOR_PORT_RANGE}, ledger_cleanup_service::{DEFAULT_MAX_LEDGER_SHREDS, DEFAULT_MIN_MAX_LEDGER_SHREDS},
contact_info::ContactInfo,
gossip_service::GossipService,
poh_service, poh_service,
rpc::JsonRpcConfig, rpc::JsonRpcConfig,
tpu::DEFAULT_TPU_COALESCE_MS, tpu::DEFAULT_TPU_COALESCE_MS,
@ -36,6 +31,11 @@ use {
}, },
solana_download_utils::{download_snapshot, DownloadProgressRecord}, solana_download_utils::{download_snapshot, DownloadProgressRecord},
solana_genesis_utils::download_then_check_genesis_hash, solana_genesis_utils::download_then_check_genesis_hash,
solana_gossip::{
cluster_info::{ClusterInfo, Node, VALIDATOR_PORT_RANGE},
contact_info::ContactInfo,
gossip_service::GossipService,
},
solana_ledger::blockstore_db::BlockstoreRecoveryMode, solana_ledger::blockstore_db::BlockstoreRecoveryMode,
solana_perf::recycler::enable_recycler_warming, solana_perf::recycler::enable_recycler_warming,
solana_rpc::rpc_pubsub_service::PubSubConfig, solana_rpc::rpc_pubsub_service::PubSubConfig,