Skip to content

Commit 29e8ff4

Browse files
authored
remove solana-sdk from gossip (#4986)
1 parent de02874 commit 29e8ff4

31 files changed

+210
-159
lines changed

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gossip/Cargo.toml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,42 @@ siphasher = { workspace = true }
3232
solana-bloom = { workspace = true }
3333
solana-clap-utils = { workspace = true }
3434
solana-client = { workspace = true }
35+
solana-clock = { workspace = true }
3536
solana-connection-cache = { workspace = true }
3637
solana-entry = { workspace = true }
38+
solana-epoch-schedule = { workspace = true }
3739
solana-feature-set = { workspace = true }
3840
solana-frozen-abi = { workspace = true, optional = true, features = [
3941
"frozen-abi",
4042
] }
4143
solana-frozen-abi-macro = { workspace = true, optional = true, features = [
4244
"frozen-abi",
4345
] }
46+
solana-hash = { workspace = true }
47+
solana-keypair = { workspace = true }
4448
solana-ledger = { workspace = true }
4549
solana-logger = { workspace = true }
4650
solana-measure = { workspace = true }
4751
solana-metrics = { workspace = true }
52+
solana-native-token = { workspace = true }
4853
solana-net-utils = { workspace = true }
54+
solana-packet = { workspace = true }
4955
solana-perf = { workspace = true }
50-
solana-pubkey = { workspace = true }
56+
solana-pubkey = { workspace = true, features = ["rand"] }
57+
solana-quic-definitions = { workspace = true }
5158
solana-rayon-threadlimit = { workspace = true }
5259
solana-rpc-client = { workspace = true }
5360
solana-runtime = { workspace = true }
5461
solana-sanitize = { workspace = true }
55-
solana-sdk = { workspace = true }
5662
solana-serde-varint = { workspace = true }
63+
solana-sha256-hasher = { workspace = true }
5764
solana-short-vec = { workspace = true }
65+
solana-signature = { workspace = true }
66+
solana-signer = { workspace = true }
5867
solana-streamer = { workspace = true }
68+
solana-time-utils = { workspace = true }
5969
solana-tpu-client = { workspace = true }
70+
solana-transaction = { workspace = true }
6071
solana-version = { workspace = true }
6172
solana-vote = { workspace = true }
6273
solana-vote-program = { workspace = true }
@@ -72,6 +83,10 @@ rand_chacha0-2 = { workspace = true }
7283
serial_test = { workspace = true }
7384
solana-perf = { workspace = true, features = ["dev-context-only-utils"] }
7485
solana-runtime = { workspace = true, features = ["dev-context-only-utils"] }
86+
solana-sdk = { workspace = true }
87+
solana-system-transaction = { workspace = true }
88+
solana-vote-interface = { workspace = true }
89+
static_assertions = { workspace = true }
7590
test-case = { workspace = true }
7691

7792
[features]

gossip/benches/crds_gossip_pull.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use {
1010
crds_gossip_pull::{CrdsFilter, CrdsGossipPull},
1111
crds_value::CrdsValue,
1212
},
13-
solana_sdk::hash::Hash,
13+
solana_hash::Hash,
1414
std::sync::RwLock,
1515
test::Bencher,
1616
};

gossip/benches/crds_shards.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use {
99
crds_shards::CrdsShards,
1010
crds_value::CrdsValue,
1111
},
12-
solana_sdk::timing::timestamp,
12+
solana_time_utils::timestamp,
1313
std::iter::repeat_with,
1414
test::Bencher,
1515
};

gossip/src/cluster_info.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ use {
4848
itertools::{Either, Itertools},
4949
rand::{seq::SliceRandom, CryptoRng, Rng},
5050
rayon::{prelude::*, ThreadPool, ThreadPoolBuilder},
51+
solana_clock::{Slot, DEFAULT_MS_PER_SLOT, DEFAULT_SLOTS_PER_EPOCH},
52+
solana_hash::Hash,
53+
solana_keypair::{signable::Signable, Keypair},
5154
solana_ledger::shred::Shred,
5255
solana_net_utils::{
5356
bind_common_in_range_with_config, bind_common_with_config, bind_in_range,
@@ -59,24 +62,21 @@ use {
5962
data_budget::DataBudget,
6063
packet::{Packet, PacketBatch, PacketBatchRecycler, PACKET_DATA_SIZE},
6164
},
65+
solana_pubkey::Pubkey,
66+
solana_quic_definitions::QUIC_PORT_OFFSET,
6267
solana_rayon_threadlimit::get_thread_count,
6368
solana_runtime::bank_forks::BankForks,
6469
solana_sanitize::Sanitize,
65-
solana_sdk::{
66-
clock::{Slot, DEFAULT_MS_PER_SLOT, DEFAULT_SLOTS_PER_EPOCH},
67-
hash::Hash,
68-
pubkey::Pubkey,
69-
quic::QUIC_PORT_OFFSET,
70-
signature::{Keypair, Signable, Signature, Signer},
71-
timing::timestamp,
72-
transaction::Transaction,
73-
},
70+
solana_signature::Signature,
71+
solana_signer::Signer,
7472
solana_streamer::{
7573
packet,
7674
quic::DEFAULT_QUIC_ENDPOINTS,
7775
socket::SocketAddrSpace,
7876
streamer::{PacketBatchReceiver, PacketBatchSender},
7977
},
78+
solana_time_utils::timestamp,
79+
solana_transaction::Transaction,
8080
solana_vote::vote_parser,
8181
solana_vote_program::vote_state::MAX_LOCKOUT_HISTORY,
8282
std::{
@@ -119,7 +119,7 @@ pub const DEFAULT_CONTACT_SAVE_INTERVAL_MILLIS: u64 = 60_000;
119119
pub(crate) const CRDS_UNIQUE_PUBKEY_CAPACITY: usize = 8192;
120120
/// Minimum stake that a node should have so that its CRDS values are
121121
/// propagated through gossip (few types are exempted).
122-
const MIN_STAKE_FOR_GOSSIP: u64 = solana_sdk::native_token::LAMPORTS_PER_SOL;
122+
const MIN_STAKE_FOR_GOSSIP: u64 = solana_native_token::LAMPORTS_PER_SOL;
123123
/// Minimum number of staked nodes for enforcing stakes in gossip.
124124
const MIN_NUM_STAKED_NODES: usize = 500;
125125

@@ -3037,9 +3037,10 @@ mod tests {
30373037
},
30383038
bincode::serialize,
30393039
itertools::izip,
3040+
solana_keypair::Keypair,
30403041
solana_ledger::shred::Shredder,
30413042
solana_net_utils::bind_to,
3042-
solana_sdk::signature::{Keypair, Signer},
3043+
solana_signer::Signer,
30433044
solana_vote_program::{vote_instruction, vote_state::Vote},
30443045
std::{
30453046
iter::repeat_with,

gossip/src/cluster_info_metrics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use {
22
crate::{crds_gossip::CrdsGossip, protocol::Protocol},
33
itertools::Itertools,
4+
solana_clock::Slot,
45
solana_measure::measure::Measure,
5-
solana_sdk::{clock::Slot, pubkey::Pubkey},
6+
solana_pubkey::Pubkey,
67
std::{
78
cmp::Reverse,
89
collections::HashMap,

gossip/src/contact_info.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ use {
33
crate::{crds_data::MAX_WALLCLOCK, legacy_contact_info::LegacyContactInfo},
44
assert_matches::{assert_matches, debug_assert_matches},
55
serde::{Deserialize, Deserializer, Serialize},
6+
solana_pubkey::Pubkey,
7+
solana_quic_definitions::QUIC_PORT_OFFSET,
68
solana_sanitize::{Sanitize, SanitizeError},
7-
solana_sdk::{
8-
pubkey::Pubkey,
9-
quic::QUIC_PORT_OFFSET,
10-
rpc_port::{DEFAULT_RPC_PORT, DEFAULT_RPC_PUBSUB_PORT},
11-
},
129
solana_serde_varint as serde_varint, solana_short_vec as short_vec,
1310
solana_streamer::socket::SocketAddrSpace,
1411
static_assertions::const_assert_eq,
@@ -21,6 +18,17 @@ use {
2118
thiserror::Error,
2219
};
2320

21+
// inline consts to avoid solana-sdk dep
22+
const DEFAULT_RPC_PORT: u16 = 8899;
23+
const DEFAULT_RPC_PUBSUB_PORT: u16 = 8900;
24+
#[cfg(test)]
25+
static_assertions::const_assert_eq!(DEFAULT_RPC_PORT, solana_sdk::rpc_port::DEFAULT_RPC_PORT);
26+
#[cfg(test)]
27+
static_assertions::const_assert_eq!(
28+
DEFAULT_RPC_PUBSUB_PORT,
29+
solana_sdk::rpc_port::DEFAULT_RPC_PUBSUB_PORT
30+
);
31+
2432
pub const SOCKET_ADDR_UNSPECIFIED: SocketAddr =
2533
SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), /*port:*/ 0u16);
2634
const EMPTY_SOCKET_ADDR_CACHE: [SocketAddr; SOCKET_CACHE_SIZE] =
@@ -397,7 +405,7 @@ impl ContactInfo {
397405
/// New random ContactInfo for tests and simulations.
398406
pub fn new_rand<R: rand::Rng>(rng: &mut R, pubkey: Option<Pubkey>) -> Self {
399407
let delay = 10 * 60 * 1000; // 10 minutes
400-
let now = solana_sdk::timing::timestamp() - delay + rng.gen_range(0..2 * delay);
408+
let now = solana_time_utils::timestamp() - delay + rng.gen_range(0..2 * delay);
401409
let pubkey = pubkey.unwrap_or_else(solana_pubkey::new_rand);
402410
let mut node = ContactInfo::new_localhost(&pubkey, now);
403411
let _ = node.set_gossip((Ipv4Addr::LOCALHOST, rng.gen_range(1024..u16::MAX)));
@@ -408,8 +416,8 @@ impl ContactInfo {
408416
pub fn new_gossip_entry_point(gossip_addr: &SocketAddr) -> Self {
409417
let mut node = Self::new(
410418
Pubkey::default(),
411-
solana_sdk::timing::timestamp(), // wallclock
412-
0, // shred_version
419+
solana_time_utils::timestamp(), // wallclock
420+
0, // shred_version
413421
);
414422
if let Err(err) = node.set_gossip(*gossip_addr) {
415423
error!("Invalid entrypoint: {gossip_addr}, {err:?}");
@@ -446,8 +454,8 @@ impl ContactInfo {
446454
assert_matches!(sanitize_socket(socket), Ok(()));
447455
let mut node = Self::new(
448456
*pubkey,
449-
solana_sdk::timing::timestamp(), // wallclock,
450-
0u16, // shred_version
457+
solana_time_utils::timestamp(), // wallclock,
458+
0u16, // shred_version
451459
);
452460
let (addr, port) = (socket.ip(), socket.port());
453461
node.set_gossip((addr, port + 1)).unwrap();
@@ -679,7 +687,8 @@ mod tests {
679687
use {
680688
super::*,
681689
rand::{seq::SliceRandom, Rng},
682-
solana_sdk::signature::{Keypair, Signer},
690+
solana_keypair::Keypair,
691+
solana_signer::Signer,
683692
std::{
684693
collections::{HashMap, HashSet},
685694
iter::repeat_with,
@@ -1001,7 +1010,7 @@ mod tests {
10011010
fn test_new_localhost() {
10021011
let node = ContactInfo::new_localhost(
10031012
&Keypair::new().pubkey(),
1004-
solana_sdk::timing::timestamp(), // wallclock
1013+
solana_time_utils::timestamp(), // wallclock
10051014
);
10061015
cross_verify_with_legacy(&node);
10071016
}

gossip/src/crds.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ use {
4141
},
4242
lru::LruCache,
4343
rayon::{prelude::*, ThreadPool},
44-
solana_sdk::{clock::Slot, hash::Hash, pubkey::Pubkey, signature::Signature},
44+
solana_clock::Slot,
45+
solana_hash::Hash,
46+
solana_pubkey::Pubkey,
47+
solana_signature::Signature,
4548
std::{
4649
cmp::Ordering,
4750
collections::{hash_map, BTreeMap, HashMap, VecDeque},
@@ -785,10 +788,9 @@ mod tests {
785788
rand::{thread_rng, Rng, SeedableRng},
786789
rand_chacha::ChaChaRng,
787790
rayon::ThreadPoolBuilder,
788-
solana_sdk::{
789-
signature::{Keypair, Signer},
790-
timing::timestamp,
791-
},
791+
solana_keypair::Keypair,
792+
solana_signer::Signer,
793+
solana_time_utils::timestamp,
792794
std::{collections::HashSet, iter::repeat_with, net::Ipv4Addr, time::Duration},
793795
};
794796

gossip/src/crds_data.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ use {
99
},
1010
rand::Rng,
1111
serde::de::{Deserialize, Deserializer},
12+
solana_clock::Slot,
13+
solana_hash::Hash,
14+
solana_pubkey::{self, Pubkey},
1215
solana_sanitize::{Sanitize, SanitizeError},
13-
solana_sdk::{
14-
clock::Slot,
15-
hash::Hash,
16-
pubkey::{self, Pubkey},
17-
timing::timestamp,
18-
transaction::Transaction,
19-
},
16+
solana_time_utils::timestamp,
17+
solana_transaction::Transaction,
2018
solana_vote::vote_parser,
2119
std::{cmp::Ordering, collections::BTreeSet},
2220
};
@@ -245,7 +243,7 @@ impl AccountsHashes {
245243
.take(num_hashes)
246244
.collect();
247245
Self {
248-
from: pubkey.unwrap_or_else(pubkey::new_rand),
246+
from: pubkey.unwrap_or_else(solana_pubkey::new_rand),
249247
hashes,
250248
wallclock: new_rand_timestamp(rng),
251249
}
@@ -307,7 +305,7 @@ impl LowestSlot {
307305
/// New random LowestSlot for tests and benchmarks.
308306
fn new_rand<R: Rng>(rng: &mut R, pubkey: Option<Pubkey>) -> Self {
309307
Self {
310-
from: pubkey.unwrap_or_else(pubkey::new_rand),
308+
from: pubkey.unwrap_or_else(solana_pubkey::new_rand),
311309
root: rng.gen(),
312310
lowest: rng.gen(),
313311
slots: BTreeSet::default(),
@@ -368,7 +366,7 @@ impl Vote {
368366
/// New random Vote for tests and benchmarks.
369367
fn new_rand<R: Rng>(rng: &mut R, pubkey: Option<Pubkey>) -> Self {
370368
Self {
371-
from: pubkey.unwrap_or_else(pubkey::new_rand),
369+
from: pubkey.unwrap_or_else(solana_pubkey::new_rand),
372370
transaction: Transaction::default(),
373371
wallclock: new_rand_timestamp(rng),
374372
slot: None,
@@ -503,11 +501,10 @@ mod test {
503501
super::*,
504502
crate::crds_value::CrdsValue,
505503
bincode::Options,
504+
solana_keypair::Keypair,
506505
solana_perf::test_tx::new_test_vote_tx,
507-
solana_sdk::{
508-
signature::{Keypair, Signer},
509-
timing::timestamp,
510-
},
506+
solana_signer::Signer,
507+
solana_time_utils::timestamp,
511508
solana_vote_program::{vote_instruction, vote_state},
512509
};
513510

gossip/src/crds_entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ mod tests {
6868
crds_data::new_rand_timestamp,
6969
},
7070
rand::seq::SliceRandom,
71-
solana_sdk::signature::Keypair,
71+
solana_keypair::Keypair,
7272
std::collections::HashMap,
7373
};
7474

0 commit comments

Comments
 (0)