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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 846 additions and 702 deletions

39
Cargo.lock generated
View File

@ -3929,6 +3929,7 @@ dependencies = [
"solana-client",
"solana-core",
"solana-faucet",
"solana-gossip",
"solana-local-cluster",
"solana-logger 1.7.0",
"solana-measure",
@ -3951,6 +3952,7 @@ dependencies = [
"rayon",
"solana-clap-utils",
"solana-core",
"solana-gossip",
"solana-ledger",
"solana-logger 1.7.0",
"solana-measure",
@ -4028,6 +4030,7 @@ dependencies = [
"solana-exchange-program",
"solana-faucet",
"solana-genesis",
"solana-gossip",
"solana-local-cluster",
"solana-logger 1.7.0",
"solana-metrics",
@ -4065,6 +4068,7 @@ dependencies = [
"solana-core",
"solana-faucet",
"solana-genesis",
"solana-gossip",
"solana-local-cluster",
"solana-logger 1.7.0",
"solana-measure",
@ -4331,6 +4335,7 @@ dependencies = [
"solana-faucet",
"solana-frozen-abi 1.7.0",
"solana-frozen-abi-macro 1.7.0",
"solana-gossip",
"solana-ledger",
"solana-logger 1.7.0",
"solana-measure",
@ -4396,6 +4401,7 @@ dependencies = [
"solana-clap-utils",
"solana-client",
"solana-core",
"solana-gossip",
"solana-ledger",
"solana-logger 1.7.0",
"solana-net-utils",
@ -4562,13 +4568,42 @@ dependencies = [
name = "solana-gossip"
version = "1.7.0"
dependencies = [
"bincode",
"bv",
"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-core",
"solana-client",
"solana-frozen-abi 1.7.0",
"solana-frozen-abi-macro 1.7.0",
"solana-ledger",
"solana-logger 1.7.0",
"solana-measure",
"solana-metrics",
"solana-net-utils",
"solana-perf",
"solana-rayon-threadlimit",
"solana-runtime",
"solana-sdk",
"solana-streamer",
"solana-version",
"solana-vote-program",
"thiserror",
]
[[package]]
@ -4731,6 +4766,7 @@ dependencies = [
"solana-download-utils",
"solana-exchange-program",
"solana-faucet",
"solana-gossip",
"solana-ledger",
"solana-logger 1.7.0",
"solana-rayon-threadlimit",
@ -5452,6 +5488,7 @@ dependencies = [
"solana-download-utils",
"solana-faucet",
"solana-genesis-utils",
"solana-gossip",
"solana-ledger",
"solana-logger 1.7.0",
"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-client = { path = "../client", 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-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-sdk = { path = "../sdk", 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_clap_utils::input_parsers::pubkey_of;
use solana_client::rpc_client::RpcClient;
use solana_core::gossip_service::discover;
use solana_faucet::faucet::{request_airdrop_transaction, FAUCET_PORT};
use solana_gossip::gossip_service::discover;
use solana_measure::measure::Measure;
use solana_runtime::inline_spl_token_v2_0;
use solana_sdk::{

View File

@ -16,12 +16,13 @@ rand = "0.7.0"
rayon = "1.5.0"
solana-core = { path = "../core", version = "=1.7.0" }
solana-clap-utils = { path = "../clap-utils", version = "=1.7.0" }
solana-streamer = { path = "../streamer", version = "=1.7.0" }
solana-perf = { path = "../perf", version = "=1.7.0" }
solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-ledger = { path = "../ledger", 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-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-version = { path = "../version", version = "=1.7.0" }

View File

@ -6,11 +6,10 @@ use rand::{thread_rng, Rng};
use rayon::prelude::*;
use solana_core::{
banking_stage::{create_test_recorder, BankingStage},
cluster_info::ClusterInfo,
cluster_info::Node,
poh_recorder::PohRecorder,
poh_recorder::WorkingBankEntry,
};
use solana_gossip::{cluster_info::ClusterInfo, cluster_info::Node};
use solana_ledger::{
blockstore::Blockstore,
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-genesis = { path = "../genesis", 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-faucet = { path = "../faucet", version = "=1.7.0" }
solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-logger = { path = "../logger", version = "=1.7.0" }
solana-metrics = { path = "../metrics", 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 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;
fn main() {

View File

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

View File

@ -20,6 +20,7 @@ solana-core = { path = "../core", version = "=1.7.0" }
solana-genesis = { path = "../genesis", version = "=1.7.0" }
solana-client = { path = "../client", 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-metrics = { path = "../metrics", version = "=1.7.0" }
solana-measure = { path = "../measure", version = "=1.7.0" }

View File

@ -2,8 +2,8 @@
use log::*;
use solana_bench_tps::bench::{do_bench_tps, generate_and_fund_keypairs, generate_keypairs};
use solana_bench_tps::cli;
use solana_core::gossip_service::{discover_cluster, get_client, get_multi_client};
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::signature::{Keypair, Signer};
use solana_sdk::system_program;

View File

@ -5,8 +5,9 @@ use solana_bench_tps::{
cli::Config,
};
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_gossip::cluster_info::VALIDATOR_PORT_RANGE;
use solana_local_cluster::{
local_cluster::{ClusterConfig, LocalCluster},
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
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/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} \
-- -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
_ "$cargo" nightly bench --manifest-path core/Cargo.toml ${V:+--verbose} \
-- -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-client = { path = "../client", 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-logger = { path = "../logger", version = "=1.7.0" }
solana-merkle-tree = { path = "../merkle-tree", version = "=1.7.0" }
@ -102,13 +103,7 @@ name = "banking_stage"
name = "blockstore"
[[bench]]
name = "crds"
[[bench]]
name = "crds_gossip_pull"
[[bench]]
name = "crds_shards"
name = "cluster_info"
[[bench]]
name = "gen_keys"
@ -122,8 +117,5 @@ name = "poh"
[[bench]]
name = "retransmit_stage"
[[bench]]
name = "cluster_info"
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View File

@ -8,9 +8,9 @@ use log::*;
use rand::{thread_rng, Rng};
use rayon::prelude::*;
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_gossip::cluster_info::ClusterInfo;
use solana_gossip::cluster_info::Node;
use solana_ledger::blockstore_processor::process_entries;
use solana_ledger::entry::{next_hash, Entry};
use solana_ledger::genesis_utils::{create_genesis_config, GenesisConfigInfo};

View File

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

View File

@ -4,9 +4,9 @@ extern crate solana_core;
extern crate test;
use log::*;
use solana_core::cluster_info::{ClusterInfo, Node};
use solana_core::contact_info::ContactInfo;
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::genesis_utils::{create_genesis_config, GenesisConfigInfo};
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
// set and halt the node if a mismatch is detected.
use crate::{
cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES},
snapshot_packager_service::PendingSnapshotPackage,
};
use crate::snapshot_packager_service::PendingSnapshotPackage;
use rayon::ThreadPool;
use solana_gossip::cluster_info::{ClusterInfo, MAX_SNAPSHOT_HASHES};
use solana_runtime::{
accounts_db,
snapshot_package::{AccountsPackage, AccountsPackagePre, AccountsPackageReceiver},
@ -218,8 +216,7 @@ impl AccountsHashVerifier {
#[cfg(test)]
mod tests {
use super::*;
use crate::cluster_info::make_accounts_hashes_message;
use crate::contact_info::ContactInfo;
use solana_gossip::{cluster_info::make_accounts_hashes_message, contact_info::ContactInfo};
use solana_runtime::bank_forks::ArchiveFormat;
use solana_runtime::snapshot_utils::SnapshotVersion;
use solana_sdk::{

View File

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

View File

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

View File

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

View File

@ -494,7 +494,7 @@ impl BroadcastRun for StandardBroadcastRun {
#[cfg(test)]
mod test {
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::{
blockstore::Blockstore, entry::create_ticks, get_tmp_ledger_path,

View File

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

View File

@ -1,8 +1,8 @@
use crate::{
cluster_info::ClusterInfo, contact_info::ContactInfo, crds::Cursor, epoch_slots::EpochSlots,
serve_repair::RepairType,
};
use crate::serve_repair::RepairType;
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_sdk::{clock::Slot, pubkey::Pubkey};
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_measure::measure::Measure;
use solana_runtime::bank_forks::BankForks;
@ -185,7 +186,7 @@ impl ClusterSlotsService {
#[cfg(test)]
mod test {
use super::*;
use crate::{cluster_info::Node, crds_value::CrdsValueLabel};
use solana_gossip::{cluster_info::Node, crds_value::CrdsValueLabel};
#[test]
pub fn test_update_lowest_slot() {

View File

@ -13,40 +13,21 @@ pub mod bigtable_upload_service;
pub mod broadcast_stage;
pub mod cache_block_time_service;
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_slots;
pub mod cluster_slots_service;
pub mod commitment_service;
pub mod completed_data_sets_service;
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 fork_choice;
pub mod gen_keys;
pub mod gossip_service;
pub mod heaviest_subtree_fork_choice;
pub mod latest_validator_votes_for_frozen_banks;
pub mod ledger_cleanup_service;
pub mod optimistic_confirmation_verifier;
pub mod outstanding_requests;
pub mod packet_hasher;
pub mod ping_pong;
pub mod poh_recorder;
pub mod poh_service;
pub mod progress_map;
@ -62,9 +43,11 @@ pub mod rewards_recorder_service;
pub mod rpc;
pub mod rpc_health;
pub mod rpc_service;
pub mod sample_performance_service;
pub mod send_transaction_service;
pub mod serve_repair;
pub mod serve_repair_service;
pub mod shred_fetch_stage;
pub mod sigverify;
pub mod sigverify_shreds;
pub mod sigverify_stage;
@ -78,7 +61,6 @@ pub mod unfrozen_gossip_verified_vote_hashes;
pub mod validator;
pub mod verified_vote_packets;
pub mod vote_stake_tracker;
pub mod weighted_shuffle;
pub mod window_service;
#[macro_use]

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,6 @@
use crate::{
bigtable_upload_service::BigTableUploadService,
cluster_info::ClusterInfo,
poh_recorder::PohRecorder,
rpc::{rpc_deprecated_v1_7::*, rpc_full::*, rpc_minimal::*, rpc_obsolete_v1_7::*, *},
rpc_health::*,
@ -16,6 +15,7 @@ use jsonrpc_http_server::{
};
use regex::Regex;
use solana_client::rpc_cache::LargestAccountsCache;
use solana_gossip::cluster_info::ClusterInfo;
use solana_ledger::{blockstore::Blockstore, leader_schedule_cache::LeaderScheduleCache};
use solana_metrics::inc_new_counter_info;
use solana_rpc::{
@ -479,10 +479,8 @@ impl JsonRpcService {
#[cfg(test)]
mod tests {
use super::*;
use crate::{
crds_value::{CrdsData, CrdsValue, SnapshotHash},
rpc::create_validator_exit,
};
use crate::rpc::create_validator_exit;
use solana_gossip::crds_value::{CrdsData, CrdsValue, SnapshotHash};
use solana_ledger::{
genesis_utils::{create_genesis_config, GenesisConfigInfo},
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`
use crate::cluster_info::ClusterInfo;
use crate::poh_recorder::PohRecorder;
use log::*;
use solana_gossip::cluster_info::ClusterInfo;
use solana_metrics::{datapoint_warn, inc_new_counter_info};
use solana_runtime::{bank::Bank, bank_forks::BankForks};
use solana_sdk::{
@ -313,7 +313,7 @@ impl SendTransactionService {
#[cfg(test)]
mod test {
use super::*;
use crate::contact_info::ContactInfo;
use solana_gossip::contact_info::ContactInfo;
use solana_ledger::{
blockstore::Blockstore, get_tmp_ledger_path, leader_schedule_cache::LeaderScheduleCache,
};

View File

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

View File

@ -1,11 +1,10 @@
use {
crate::{
cluster_info::Node,
gossip_service::discover_cluster,
rpc::JsonRpcConfig,
validator::{Validator, ValidatorConfig, ValidatorExit, ValidatorStartProgress},
},
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_net_utils::PortRange,
solana_runtime::{

View File

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

View File

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

View File

@ -3,15 +3,9 @@
use crate::{
broadcast_stage::BroadcastStageType,
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,
completed_data_sets_service::CompletedDataSetsService,
consensus::{reconcile_blockstore_roots_with_tower, Tower},
contact_info::ContactInfo,
gossip_service::GossipService,
poh_recorder::{PohRecorder, GRACE_TICKS_FACTOR, MAX_GRACE_SLOTS},
poh_service::{self, PohService},
rewards_recorder_service::{RewardsRecorderSender, RewardsRecorderService},
@ -28,6 +22,14 @@ use crate::{
};
use crossbeam_channel::{bounded, unbounded};
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::{
bank_forks_utils,
blockstore::{Blockstore, BlockstoreSignals, CompletedSlotsReceiver, PurgeType},

View File

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

View File

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

View File

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

View File

@ -16,6 +16,7 @@ rand = "0.7.0"
rayon = "1.5.0"
solana-clap-utils = { path = "../clap-utils", 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-logger = { path = "../logger", 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 rand::{thread_rng, Rng};
use solana_client::rpc_client::RpcClient;
use solana_core::{
contact_info::ContactInfo, gossip_service::discover, serve_repair::RepairProtocol,
};
use solana_core::serve_repair::RepairProtocol;
use solana_gossip::{contact_info::ContactInfo, gossip_service::discover};
use solana_sdk::pubkey::Pubkey;
use std::net::{SocketAddr, UdpSocket};
use std::process::exit;

View File

@ -10,13 +10,59 @@ homepage = "https://solana.com/"
documentation = "https://docs.rs/solana-gossip"
[dependencies]
bincode = "1.3.1"
bv = { version = "0.11.1", features = ["serde"] }
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-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-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-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-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]
targets = ["x86_64-unknown-linux-gnu"]

View File

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

View File

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

View File

@ -2,15 +2,17 @@
extern crate test;
use rand::{thread_rng, Rng};
use solana_core::{
crds::{Crds, VersionedCrdsValue},
crds_shards::CrdsShards,
crds_value::CrdsValue,
use {
rand::{thread_rng, Rng},
solana_gossip::{
crds::{Crds, VersionedCrdsValue},
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;

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.
//!
//! Bank needs to provide an interface for us to query the stake weight
use crate::{
cluster_info_metrics::{submit_gossip_stats, Counter, GossipStats, ScopedTimer},
contact_info::ContactInfo,
crds::Cursor,
crds_gossip::CrdsGossip,
crds_gossip_error::CrdsGossipError,
crds_gossip_pull::{CrdsFilter, ProcessPullStats, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS},
crds_value::{
self, CrdsData, CrdsValue, CrdsValueLabel, EpochSlotsIndex, LowestSlot, NodeInstance,
SnapshotHash, Version, Vote, MAX_WALLCLOCK,
use {
crate::{
cluster_info_metrics::{submit_gossip_stats, Counter, GossipStats, ScopedTimer},
contact_info::ContactInfo,
crds::Cursor,
crds_gossip::CrdsGossip,
crds_gossip_error::CrdsGossipError,
crds_gossip_pull::{CrdsFilter, ProcessPullStats, CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS},
crds_value::{
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,
epoch_slots::EpochSlots,
ping_pong::{self, PingCache, Pong},
result::{Error, Result},
weighted_shuffle::weighted_shuffle,
};
use rand::{seq::SliceRandom, CryptoRng, Rng};
use solana_ledger::shred::Shred;
use solana_sdk::sanitize::{Sanitize, SanitizeError};
use bincode::{serialize, serialized_size};
use itertools::Itertools;
use rand::thread_rng;
use rayon::prelude::*;
use rayon::{ThreadPool, ThreadPoolBuilder};
use serde::ser::Serialize;
use solana_measure::measure::Measure;
use solana_metrics::{inc_new_counter_debug, inc_new_counter_error};
use solana_net_utils::{
bind_common, bind_common_in_range, bind_in_range, find_available_port_in_range,
multi_bind_in_range, PortRange,
};
use solana_perf::packet::{
limited_deserialize, to_packets_with_destination, Packet, Packets, PacketsRecycler,
PACKET_DATA_SIZE,
};
use solana_rayon_threadlimit::get_thread_count;
use solana_runtime::bank_forks::BankForks;
use solana_sdk::{
clock::{Slot, DEFAULT_MS_PER_SLOT, DEFAULT_SLOTS_PER_EPOCH},
feature_set::{self, FeatureSet},
hash::Hash,
pubkey::Pubkey,
signature::{Keypair, Signable, Signature, Signer},
timing::timestamp,
transaction::Transaction,
};
use solana_streamer::packet;
use solana_streamer::sendmmsg::multicast;
use solana_streamer::streamer::{PacketReceiver, PacketSender};
use solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY;
use std::{
borrow::Cow,
collections::{hash_map::Entry, HashMap, HashSet, VecDeque},
fmt::Debug,
fs::{self, File},
io::BufReader,
iter::repeat,
net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket},
ops::{Deref, DerefMut, Div},
path::{Path, PathBuf},
sync::{
atomic::{AtomicBool, Ordering},
{Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard},
bincode::{serialize, serialized_size},
itertools::Itertools,
rand::{seq::SliceRandom, thread_rng, CryptoRng, Rng},
rayon::{prelude::*, ThreadPool, ThreadPoolBuilder},
serde::ser::Serialize,
solana_ledger::shred::Shred,
solana_measure::measure::Measure,
solana_metrics::{inc_new_counter_debug, inc_new_counter_error},
solana_net_utils::{
bind_common, bind_common_in_range, bind_in_range, find_available_port_in_range,
multi_bind_in_range, PortRange,
},
solana_perf::packet::{
limited_deserialize, to_packets_with_destination, Packet, Packets, PacketsRecycler,
PACKET_DATA_SIZE,
},
solana_rayon_threadlimit::get_thread_count,
solana_runtime::bank_forks::BankForks,
solana_sdk::{
clock::{Slot, DEFAULT_MS_PER_SLOT, DEFAULT_SLOTS_PER_EPOCH},
feature_set::{self, FeatureSet},
hash::Hash,
pubkey::Pubkey,
sanitize::{Sanitize, SanitizeError},
signature::{Keypair, Signable, Signature, Signer},
timing::timestamp,
transaction::Transaction,
},
solana_streamer::{
packet,
sendmmsg::multicast,
streamer::{PacketReceiver, PacketSender},
},
solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY,
std::{
borrow::Cow,
collections::{hash_map::Entry, HashMap, HashSet, VecDeque},
fmt::Debug,
fs::{self, File},
io::BufReader,
iter::repeat,
net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket},
ops::{Deref, DerefMut, Div},
path::{Path, PathBuf},
result::Result,
sync::{
atomic::{AtomicBool, Ordering},
{Arc, Mutex, RwLock, RwLockReadGuard, RwLockWriteGuard},
},
thread::{sleep, Builder, JoinHandle},
time::{Duration, Instant},
},
thread::{sleep, Builder, JoinHandle},
time::{Duration, Instant},
};
pub const VALIDATOR_PORT_RANGE: PortRange = (8000, 10_000);
@ -209,7 +212,7 @@ pub struct ClusterInfo {
/// The network
pub gossip: RwLock<CrdsGossip>,
/// 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
entrypoints: RwLock<Vec<ContactInfo>>,
outbound_budget: DataBudget,
@ -267,7 +270,7 @@ impl PruneData {
}
impl Sanitize for PruneData {
fn sanitize(&self) -> std::result::Result<(), SanitizeError> {
fn sanitize(&self) -> Result<(), SanitizeError> {
if self.wallclock >= MAX_WALLCLOCK {
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]>;
// 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)]
#[allow(clippy::large_enum_variant)]
enum Protocol {
@ -408,7 +411,7 @@ impl Protocol {
}
impl Sanitize for Protocol {
fn sanitize(&self) -> std::result::Result<(), SanitizeError> {
fn sanitize(&self) -> Result<(), SanitizeError> {
match self {
Protocol::PullRequest(filter, val) => {
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 gossip =
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)
}
pub(crate) fn push_message(&self, message: CrdsValue) {
pub fn push_message(&self, message: CrdsValue) {
self.local_message_pending_push_queue
.lock()
.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 buf = serialize(vote)?;
self.socket.send_to(&buf, &tpu)?;
@ -1119,7 +1126,11 @@ impl ClusterInfo {
(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.keypair,
shred,
@ -1154,7 +1165,7 @@ impl ClusterInfo {
.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 entries = gossip.crds.get_epoch_slots(cursor);
entries
@ -1203,7 +1214,7 @@ impl ClusterInfo {
}
// 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
.read()
.unwrap()
@ -1376,7 +1387,7 @@ impl ClusterInfo {
packet: &Packet,
s: &UdpSocket,
forwarded: bool,
) -> Result<()> {
) -> Result<(), GossipError> {
trace!("retransmit orders {}", peers.len());
let dests: Vec<_> = if forwarded {
peers
@ -1398,7 +1409,7 @@ impl ClusterInfo {
1
);
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();
std::mem::take(&mut *push_queue)
}
#[cfg(test)]
// Used in tests
pub fn flush_push_queue(&self) {
let pending_push_messages = self.drain_push_queue();
let mut gossip = self.gossip.write().unwrap();
@ -1649,7 +1660,7 @@ impl ClusterInfo {
sender: &PacketSender,
generate_pull_requests: bool,
require_stake_for_gossip: bool,
) -> Result<()> {
) -> Result<(), GossipError> {
let reqs = self.generate_new_gossip_requests(
thread_pool,
gossip_validators,
@ -2491,7 +2502,7 @@ impl ClusterInfo {
feature_set: Option<&FeatureSet>,
epoch_duration: Duration,
should_check_duplicate_instance: bool,
) -> Result<()> {
) -> Result<(), GossipError> {
let _st = ScopedTimer::from(&self.stats.process_gossip_packets_time);
self.stats
.packets_received_count
@ -2517,7 +2528,7 @@ impl ClusterInfo {
if should_check_duplicate_instance {
for value in values {
if self.instance.check_duplicate(value) {
return Err(Error::DuplicateNodeInstance);
return Err(GossipError::DuplicateNodeInstance);
}
}
}
@ -2605,7 +2616,7 @@ impl ClusterInfo {
thread_pool: &ThreadPool,
last_print: &mut Instant,
should_check_duplicate_instance: bool,
) -> Result<()> {
) -> Result<(), GossipError> {
const RECV_TIMEOUT: Duration = Duration::from_secs(1);
const SUBMIT_GOSSIP_STATS_INTERVAL: Duration = Duration::from_secs(2);
let packets: Vec<_> = requests_receiver.recv_timeout(RECV_TIMEOUT)?.packets.into();
@ -2678,7 +2689,7 @@ impl ClusterInfo {
should_check_duplicate_instance,
) {
match err {
Error::RecvTimeoutError(_) => {
GossipError::RecvTimeoutError(_) => {
let table_size = self.gossip.read().unwrap().crds.len();
debug!(
"{}: run_listen timeout, table size: {}",
@ -2686,7 +2697,7 @@ impl ClusterInfo {
table_size,
);
}
Error::DuplicateNodeInstance => {
GossipError::DuplicateNodeInstance => {
error!(
"duplicate running instances of the same validator node: {}",
self.id()
@ -3013,7 +3024,7 @@ pub fn push_messages_to_peer(
messages: Vec<CrdsValue>,
self_id: Pubkey,
peer_gossip: SocketAddr,
) -> Result<()> {
) -> Result<(), GossipError> {
let reqs: Vec<_> = ClusterInfo::split_gossip_messages(PUSH_MESSAGE_MAX_PAYLOAD_SIZE, messages)
.map(move |payload| (peer_gossip, Protocol::PushMessage(self_id, payload)))
.collect();
@ -3033,21 +3044,25 @@ pub fn stake_weight_peers(
#[cfg(test)]
mod tests {
use super::*;
use crate::{
crds_gossip_pull::tests::MIN_NUM_BLOOM_FILTERS,
crds_value::{CrdsValue, CrdsValueLabel, Vote as CrdsVote},
duplicate_shred::{self, tests::new_rand_shred, MAX_DUPLICATE_SHREDS},
use {
super::*,
crate::{
crds_gossip_pull::tests::MIN_NUM_BLOOM_FILTERS,
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]
fn test_gossip_node() {

View File

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

View File

@ -1,12 +1,14 @@
use crate::crds_value::MAX_WALLCLOCK;
use solana_sdk::pubkey::Pubkey;
#[cfg(test)]
use solana_sdk::rpc_port;
use solana_sdk::sanitize::{Sanitize, SanitizeError};
#[cfg(test)]
use solana_sdk::signature::{Keypair, Signer};
use solana_sdk::timing::timestamp;
use std::net::{IpAddr, SocketAddr};
use {
crate::crds_value::MAX_WALLCLOCK,
solana_sdk::{
pubkey::Pubkey,
rpc_port,
sanitize::{Sanitize, SanitizeError},
signature::{Keypair, Signer},
timing::timestamp,
},
std::net::{IpAddr, SocketAddr},
};
/// Structure representing a node on the network
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd, AbiExample, Deserialize, Serialize)]
@ -132,8 +134,8 @@ impl ContactInfo {
}
}
#[cfg(test)]
pub(crate) fn new_with_pubkey_socketaddr(pubkey: &Pubkey, bind_addr: &SocketAddr) -> Self {
// Used in tests
pub fn new_with_pubkey_socketaddr(pubkey: &Pubkey, bind_addr: &SocketAddr) -> Self {
fn next_port(addr: &SocketAddr, nxt: u16) -> SocketAddr {
let mut nxt_addr = *addr;
nxt_addr.set_port(addr.port() + nxt);
@ -166,8 +168,8 @@ impl ContactInfo {
}
}
#[cfg(test)]
pub(crate) fn new_with_socketaddr(bind_addr: &SocketAddr) -> Self {
// Used in tests
pub fn new_with_socketaddr(bind_addr: &SocketAddr) -> Self {
let keypair = Keypair::new();
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
//! wallclock is later, or the value hash is greater.
use crate::contact_info::ContactInfo;
use crate::crds_shards::CrdsShards;
use crate::crds_value::{CrdsData, CrdsValue, CrdsValueLabel, LowestSlot};
use bincode::serialize;
use indexmap::map::{rayon::ParValues, Entry, IndexMap};
use indexmap::set::IndexSet;
use rayon::{prelude::*, ThreadPool};
use solana_sdk::hash::{hash, Hash};
use solana_sdk::pubkey::Pubkey;
use std::{
cmp::Ordering,
collections::{hash_map, BTreeMap, HashMap, VecDeque},
ops::{Bound, Index, IndexMut},
use {
crate::{
contact_info::ContactInfo,
crds_shards::CrdsShards,
crds_value::{CrdsData, CrdsValue, CrdsValueLabel, LowestSlot},
},
bincode::serialize,
indexmap::{
map::{rayon::ParValues, Entry, IndexMap},
set::IndexSet,
},
rayon::{prelude::*, ThreadPool},
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;
@ -539,16 +547,18 @@ impl Crds {
#[cfg(test)]
mod test {
use super::*;
use crate::{
contact_info::ContactInfo,
crds_value::{new_rand_timestamp, NodeInstance},
use {
super::*,
crate::{
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]
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
//! packet::PACKET_DATA_SIZE size.
use crate::{
cluster_info::Ping,
contact_info::ContactInfo,
crds::Crds,
crds_gossip_error::CrdsGossipError,
crds_gossip_pull::{CrdsFilter, CrdsGossipPull, ProcessPullStats},
crds_gossip_push::{CrdsGossipPush, CRDS_GOSSIP_NUM_ACTIVE},
crds_value::{CrdsData, CrdsValue},
duplicate_shred::{self, DuplicateShredIndex, LeaderScheduleFn, MAX_DUPLICATE_SHREDS},
ping_pong::PingCache,
};
use itertools::Itertools;
use rayon::ThreadPool;
use solana_ledger::shred::Shred;
use solana_sdk::{
hash::Hash,
pubkey::Pubkey,
signature::{Keypair, Signer},
timing::timestamp,
};
use std::{
collections::{HashMap, HashSet},
net::SocketAddr,
sync::Mutex,
time::Duration,
use {
crate::{
cluster_info::Ping,
contact_info::ContactInfo,
crds::Crds,
crds_gossip_error::CrdsGossipError,
crds_gossip_pull::{CrdsFilter, CrdsGossipPull, ProcessPullStats},
crds_gossip_push::{CrdsGossipPush, CRDS_GOSSIP_NUM_ACTIVE},
crds_value::{CrdsData, CrdsValue},
duplicate_shred::{self, DuplicateShredIndex, LeaderScheduleFn, MAX_DUPLICATE_SHREDS},
ping_pong::PingCache,
},
itertools::Itertools,
rayon::ThreadPool,
solana_ledger::shred::Shred,
solana_sdk::{
hash::Hash,
pubkey::Pubkey,
signature::{Keypair, Signer},
timing::timestamp,
},
std::{
collections::{HashMap, HashSet},
net::SocketAddr,
sync::Mutex,
time::Duration,
},
};
pub struct CrdsGossip {
@ -361,11 +363,11 @@ pub fn get_weight(max_weight: f32, time_since_last_selected: u32, stake: f32) ->
#[cfg(test)]
mod test {
use super::*;
use crate::contact_info::ContactInfo;
use crate::crds_value::CrdsData;
use solana_sdk::hash::hash;
use solana_sdk::timing::timestamp;
use {
super::*,
crate::{contact_info::ContactInfo, crds_value::CrdsData},
solana_sdk::{hash::hash, timing::timestamp},
};
#[test]
fn test_prune_errors() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,20 +1,22 @@
use crate::crds_value::sanitize_wallclock;
use itertools::Itertools;
use solana_ledger::{
blockstore_meta::DuplicateSlotProof,
shred::{Shred, ShredError, ShredType},
use {
crate::crds_value::sanitize_wallclock,
itertools::Itertools,
solana_ledger::{
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;

View File

@ -1,11 +1,17 @@
use crate::cluster_info::MAX_CRDS_OBJECT_SIZE;
use crate::crds_value::{self, MAX_SLOT, MAX_WALLCLOCK};
use bincode::serialized_size;
use bv::BitVec;
use flate2::{Compress, Compression, Decompress, FlushCompress, FlushDecompress};
use solana_sdk::clock::Slot;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::sanitize::{Sanitize, SanitizeError};
use {
crate::{
cluster_info::MAX_CRDS_OBJECT_SIZE,
crds_value::{self, MAX_SLOT, MAX_WALLCLOCK},
},
bincode::serialized_size,
bv::BitVec,
flate2::{Compress, Compression, Decompress, FlushCompress, FlushDecompress},
solana_sdk::{
clock::Slot,
pubkey::Pubkey,
sanitize::{Sanitize, SanitizeError},
},
};
const MAX_SLOTS_PER_ENTRY: usize = 2048 * 8;
#[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.
use crate::cluster_info::{ClusterInfo, VALIDATOR_PORT_RANGE};
use crate::contact_info::ContactInfo;
use rand::{thread_rng, Rng};
use solana_client::thin_client::{create_client, ThinClient};
use solana_perf::recycler::Recycler;
use solana_runtime::bank_forks::BankForks;
use solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signer},
};
use solana_streamer::streamer;
use std::{
collections::HashSet,
net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket},
sync::{
atomic::{AtomicBool, Ordering},
mpsc::channel,
{Arc, RwLock},
use {
crate::{
cluster_info::{ClusterInfo, VALIDATOR_PORT_RANGE},
contact_info::ContactInfo,
},
rand::{thread_rng, Rng},
solana_client::thin_client::{create_client, ThinClient},
solana_perf::recycler::Recycler,
solana_runtime::bank_forks::BankForks,
solana_sdk::{
pubkey::Pubkey,
signature::{Keypair, Signer},
},
solana_streamer::streamer,
std::{
collections::HashSet,
net::{IpAddr, Ipv4Addr, SocketAddr, TcpListener, UdpSocket},
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 {
@ -305,10 +309,11 @@ fn make_gossip_node(
#[cfg(test)]
mod tests {
use super::*;
use crate::cluster_info::{ClusterInfo, Node};
use std::sync::atomic::AtomicBool;
use std::sync::Arc;
use {
super::*,
crate::cluster_info::{ClusterInfo, Node},
std::sync::{atomic::AtomicBool, Arc},
};
#[test]
#[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.
use clap::{
crate_description, crate_name, value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches,
SubCommand,
};
use solana_clap_utils::{
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;
use std::{
error,
net::{IpAddr, Ipv4Addr, SocketAddr},
process::exit,
sync::Arc,
time::Duration,
use {
clap::{
crate_description, crate_name, value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches,
SubCommand,
},
solana_clap_utils::{
input_parsers::keypair_of,
input_validators::{is_keypair_or_ask_keyword, is_port, is_pubkey},
},
solana_gossip::{contact_info::ContactInfo, gossip_service::discover},
solana_sdk::pubkey::Pubkey,
std::{
error,
net::{IpAddr, Ipv4Addr, SocketAddr},
process::exit,
sync::Arc,
time::Duration,
},
};
fn parse_matches() -> ArgMatches<'static> {

View File

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

View File

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

View File

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

View File

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

View File

@ -2,28 +2,33 @@
#[macro_use]
extern crate log;
use rayon::iter::*;
use solana_core::{
cluster_info::{ClusterInfo, Node},
crds::Cursor,
gossip_service::GossipService,
use {
rayon::iter::*,
solana_gossip::{
cluster_info::{ClusterInfo, Node},
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) {
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-client = { path = "../client", 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-faucet = { path = "../faucet", version = "=1.7.0" }
solana-gossip = { path = "../gossip", version = "=1.7.0" }
solana-ledger = { path = "../ledger", version = "=1.7.0" }
solana-logger = { path = "../logger", 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_core::contact_info::ContactInfo;
use solana_core::validator::Validator;
use solana_core::validator::ValidatorConfig;
use solana_gossip::{cluster_info::Node, contact_info::ContactInfo};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::Keypair;
use std::path::PathBuf;
@ -44,10 +44,10 @@ pub trait Cluster {
&mut self,
pubkey: &Pubkey,
cluster_validator_info: &mut ClusterValidatorInfo,
) -> (solana_core::cluster_info::Node, Option<ContactInfo>);
) -> (Node, Option<ContactInfo>);
fn restart_node_with_context(
cluster_validator_info: ClusterValidatorInfo,
restart_context: (solana_core::cluster_info::Node, Option<ContactInfo>),
restart_context: (Node, Option<ContactInfo>),
) -> ClusterValidatorInfo;
fn add_node(&mut self, pubkey: &Pubkey, cluster_validator_info: ClusterValidatorInfo);
fn exit_restart_node(&mut self, pubkey: &Pubkey, config: ValidatorConfig);

View File

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

View File

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

View File

@ -13,14 +13,16 @@ use solana_client::{
};
use solana_core::{
broadcast_stage::BroadcastStageType,
cluster_info::{self, VALIDATOR_PORT_RANGE},
consensus::{Tower, SWITCH_FORK_THRESHOLD, VOTE_THRESHOLD_DEPTH},
crds_value::{self, CrdsData, CrdsValue},
gossip_service::discover_cluster,
optimistic_confirmation_verifier::OptimisticConfirmationVerifier,
validator::ValidatorConfig,
};
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::{
ancestor_iterator::AncestorIterator,
blockstore::{Blockstore, PurgeType},
@ -1393,7 +1395,7 @@ fn test_mainnet_beta_cluster_type() {
let client = create_client(
cluster.entry_point_info.client_facing_addr(),
solana_core::cluster_info::VALIDATOR_PORT_RANGE,
VALIDATOR_PORT_RANGE,
);
// 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-faucet = { path = "../faucet", 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-logger = { path = "../logger", version = "=1.7.0" }
solana-metrics = { path = "../metrics", version = "=1.7.0" }

View File

@ -1,5 +1,6 @@
#![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 {
console::style,
indicatif::{ProgressDrawTarget, ProgressStyle},

View File

@ -20,13 +20,8 @@ use {
rpc_client::RpcClient, rpc_config::RpcLeaderScheduleConfig,
rpc_request::MAX_MULTIPLE_ACCOUNTS,
},
solana_core::ledger_cleanup_service::{
DEFAULT_MAX_LEDGER_SHREDS, DEFAULT_MIN_MAX_LEDGER_SHREDS,
},
solana_core::{
cluster_info::{ClusterInfo, Node, VALIDATOR_PORT_RANGE},
contact_info::ContactInfo,
gossip_service::GossipService,
ledger_cleanup_service::{DEFAULT_MAX_LEDGER_SHREDS, DEFAULT_MIN_MAX_LEDGER_SHREDS},
poh_service,
rpc::JsonRpcConfig,
tpu::DEFAULT_TPU_COALESCE_MS,
@ -36,6 +31,11 @@ use {
},
solana_download_utils::{download_snapshot, DownloadProgressRecord},
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_perf::recycler::enable_recycler_warming,
solana_rpc::rpc_pubsub_service::PubSubConfig,