Skip to content

Commit

Permalink
remove solana-sdk from poh (#4240)
Browse files Browse the repository at this point in the history
* remove solana-sdk from poh

* update some types

* fmt
  • Loading branch information
kevinheavey authored Jan 6, 2025
1 parent f594a32 commit 990551f
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 48 deletions.
11 changes: 10 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion core/src/banking_stage/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,9 @@ impl Consumer {
starting_transaction_index,
} = record_transactions_summary;
execute_and_commit_timings.record_transactions_timings = RecordTransactionsTimings {
processing_results_to_transactions_us,
processing_results_to_transactions_us: Saturating(
processing_results_to_transactions_us,
),
..record_transactions_timings
};

Expand Down
6 changes: 3 additions & 3 deletions core/src/banking_stage/leader_slot_timing_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ impl LeaderExecuteAndCommitTimings {
(
"processing_results_to_transactions_us",
self.record_transactions_timings
.processing_results_to_transactions_us as i64,
.processing_results_to_transactions_us.0 as i64,
i64
),
(
"hash_us",
self.record_transactions_timings.hash_us as i64,
self.record_transactions_timings.hash_us.0 as i64,
i64
),
(
"poh_record_us",
self.record_transactions_timings.poh_record_us as i64,
self.record_transactions_timings.poh_record_us.0 as i64,
i64
),
);
Expand Down
11 changes: 10 additions & 1 deletion poh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,31 @@ edition = { workspace = true }
core_affinity = { workspace = true }
crossbeam-channel = { workspace = true }
log = { workspace = true }
solana-clock = { workspace = true }
solana-entry = { workspace = true }
solana-hash = { workspace = true }
solana-ledger = { workspace = true }
solana-measure = { workspace = true }
solana-metrics = { workspace = true }
solana-poh-config = { workspace = true }
solana-pubkey = { workspace = true }
solana-runtime = { workspace = true }
solana-sdk = { workspace = true }
solana-time-utils = { workspace = true }
solana-transaction = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
assert_matches = { workspace = true }
bincode = { workspace = true }
rand = { workspace = true }
solana-keypair = { workspace = true }
solana-logger = { workspace = true }
solana-perf = { workspace = true, features = ["dev-context-only-utils"] }
solana-poh = { path = ".", features = ["dev-context-only-utils"] }
solana-runtime = { workspace = true, features = ["dev-context-only-utils"] }
solana-sha256-hasher = { workspace = true }
solana-signer = { workspace = true }
solana-system-transaction = { workspace = true }

[features]
dev-context-only-utils = []
Expand Down
9 changes: 4 additions & 5 deletions poh/benches/poh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern crate test;

use {
solana_entry::poh::Poh,
solana_hash::Hash,
solana_ledger::{
blockstore::Blockstore,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
Expand All @@ -13,12 +14,10 @@ use {
},
solana_perf::test_tx::test_tx,
solana_poh::{poh_recorder::PohRecorder, poh_service::DEFAULT_HASHES_PER_BATCH},
solana_poh_config::PohConfig,
solana_runtime::bank::Bank,
solana_sdk::{
hash::{hash, Hash},
poh_config::PohConfig,
transaction::SanitizedTransaction,
},
solana_sha256_hasher::hash,
solana_transaction::sanitized::SanitizedTransaction,
std::sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex,
Expand Down
12 changes: 6 additions & 6 deletions poh/benches/poh_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ extern crate test;

use {
solana_entry::entry::{self, next_entry_mut, Entry, EntrySlice},
solana_sdk::{
hash::{hash, Hash},
signature::{Keypair, Signer},
system_transaction,
},
solana_hash::Hash,
solana_keypair::Keypair,
solana_sha256_hasher::hash,
solana_signer::Signer,
solana_system_transaction::transfer,
test::Bencher,
};

Expand Down Expand Up @@ -46,7 +46,7 @@ fn bench_poh_verify_transaction_entries(bencher: &mut Bencher) {

let mut ticks: Vec<Entry> = Vec::with_capacity(NUM_ENTRIES);
for _ in 0..NUM_ENTRIES {
let tx = system_transaction::transfer(&keypair1, &pubkey1, 42, cur_hash);
let tx = transfer(&keypair1, &pubkey1, 42, cur_hash);
ticks.push(next_entry_mut(&mut cur_hash, NUM_HASHES, vec![tx]));
}

Expand Down
2 changes: 1 addition & 1 deletion poh/src/leader_bank_notifier.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
solana_clock::Slot,
solana_runtime::bank::Bank,
solana_sdk::slot_history::Slot,
std::{
sync::{Arc, Condvar, Mutex, MutexGuard, Weak},
time::{Duration, Instant},
Expand Down
46 changes: 21 additions & 25 deletions poh/src/poh_recorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,22 @@ use {
bounded, unbounded, Receiver, RecvTimeoutError, SendError, Sender, TrySendError,
},
log::*,
solana_clock::{Slot, NUM_CONSECUTIVE_LEADER_SLOTS},
solana_entry::{
entry::{hash_transactions, Entry},
poh::Poh,
},
solana_hash::Hash,
solana_ledger::{blockstore::Blockstore, leader_schedule_cache::LeaderScheduleCache},
solana_measure::measure_us,
solana_metrics::poh_timing_point::{send_poh_timing_point, PohTimingSender, SlotPohTimingInfo},
solana_poh_config::PohConfig,
solana_pubkey::Pubkey,
solana_runtime::{bank::Bank, installed_scheduler_pool::BankWithScheduler},
solana_sdk::{
clock::{Slot, NUM_CONSECUTIVE_LEADER_SLOTS},
hash::Hash,
poh_config::PohConfig,
pubkey::Pubkey,
saturating_add_assign,
transaction::VersionedTransaction,
},
solana_transaction::versioned::VersionedTransaction,
std::{
cmp,
num::Saturating,
sync::{
atomic::{AtomicBool, Ordering},
Arc, Mutex, RwLock,
Expand Down Expand Up @@ -115,19 +113,16 @@ impl Record {

#[derive(Default, Debug)]
pub struct RecordTransactionsTimings {
pub processing_results_to_transactions_us: u64,
pub hash_us: u64,
pub poh_record_us: u64,
pub processing_results_to_transactions_us: Saturating<u64>,
pub hash_us: Saturating<u64>,
pub poh_record_us: Saturating<u64>,
}

impl RecordTransactionsTimings {
pub fn accumulate(&mut self, other: &RecordTransactionsTimings) {
saturating_add_assign!(
self.processing_results_to_transactions_us,
other.processing_results_to_transactions_us
);
saturating_add_assign!(self.hash_us, other.hash_us);
saturating_add_assign!(self.poh_record_us, other.poh_record_us);
self.processing_results_to_transactions_us += other.processing_results_to_transactions_us;
self.hash_us += other.hash_us;
self.poh_record_us += other.poh_record_us;
}
}

Expand Down Expand Up @@ -167,10 +162,10 @@ impl TransactionRecorder {

if !transactions.is_empty() {
let (hash, hash_us) = measure_us!(hash_transactions(&transactions));
record_transactions_timings.hash_us = hash_us;
record_transactions_timings.hash_us = Saturating(hash_us);

let (res, poh_record_us) = measure_us!(self.record(bank_slot, hash, transactions));
record_transactions_timings.poh_record_us = poh_record_us;
record_transactions_timings.poh_record_us = Saturating(poh_record_us);

match res {
Ok(starting_index) => {
Expand Down Expand Up @@ -672,7 +667,7 @@ impl PohRecorder {
SlotPohTimingInfo::new_slot_start_poh_time_point(
self.start_slot() + 1,
None,
solana_sdk::timing::timestamp(),
solana_time_utils::timestamp(),
),
);
}
Expand Down Expand Up @@ -720,7 +715,7 @@ impl PohRecorder {
SlotPohTimingInfo::new_slot_start_poh_time_point(
slot,
None,
solana_sdk::timing::timestamp(),
solana_time_utils::timestamp(),
),
);
}
Expand Down Expand Up @@ -821,7 +816,7 @@ impl PohRecorder {
SlotPohTimingInfo::new_slot_end_poh_time_point(
self.slot_for_tick_height(self.tick_height),
None,
solana_sdk::timing::timestamp(),
solana_time_utils::timestamp(),
),
);
}
Expand All @@ -834,7 +829,7 @@ impl PohRecorder {
SlotPohTimingInfo::new_slot_start_poh_time_point(
self.slot_for_tick_height(self.tick_height),
None,
solana_sdk::timing::timestamp(),
solana_time_utils::timestamp(),
),
);
}
Expand All @@ -850,7 +845,7 @@ impl PohRecorder {
SlotPohTimingInfo::new_slot_end_poh_time_point(
slot,
None,
solana_sdk::timing::timestamp(),
solana_time_utils::timestamp(),
),
);
}
Expand Down Expand Up @@ -1195,11 +1190,12 @@ mod tests {
super::*,
bincode::serialize,
crossbeam_channel::bounded,
solana_clock::DEFAULT_TICKS_PER_SLOT,
solana_ledger::{
blockstore::Blockstore, blockstore_meta::SlotMeta, get_tmp_ledger_path_auto_delete,
},
solana_perf::test_tx::test_tx,
solana_sdk::{clock::DEFAULT_TICKS_PER_SLOT, hash::hash},
solana_sha256_hasher::hash,
};

#[test]
Expand Down
8 changes: 5 additions & 3 deletions poh/src/poh_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {
log::*,
solana_entry::poh::Poh,
solana_measure::{measure::Measure, measure_us},
solana_sdk::poh_config::PohConfig,
solana_poh_config::PohConfig,
std::{
sync::{
atomic::{AtomicBool, Ordering},
Expand Down Expand Up @@ -377,6 +377,7 @@ mod tests {
use {
super::*,
rand::{thread_rng, Rng},
solana_clock::DEFAULT_HASHES_PER_TICK,
solana_ledger::{
blockstore::Blockstore,
genesis_utils::{create_genesis_config, GenesisConfigInfo},
Expand All @@ -386,7 +387,8 @@ mod tests {
solana_measure::measure::Measure,
solana_perf::test_tx::test_tx,
solana_runtime::bank::Bank,
solana_sdk::{clock, hash::hash, transaction::VersionedTransaction},
solana_sha256_hasher::hash,
solana_transaction::versioned::VersionedTransaction,
std::{thread::sleep, time::Duration},
};

Expand All @@ -405,7 +407,7 @@ mod tests {
PohConfig::default().target_tick_duration.as_micros() as u64;
let target_tick_duration = Duration::from_micros(default_target_tick_duration);
let poh_config = PohConfig {
hashes_per_tick: Some(clock::DEFAULT_HASHES_PER_TICK),
hashes_per_tick: Some(DEFAULT_HASHES_PER_TICK),
target_tick_duration,
target_tick_count: None,
};
Expand Down
7 changes: 6 additions & 1 deletion programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion svm/examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 990551f

Please sign in to comment.