From 03e38bce4ced55dc9aa589e027559e5044325504 Mon Sep 17 00:00:00 2001 From: Ryo Onodera Date: Sun, 9 Jul 2023 14:26:05 +0900 Subject: [PATCH 1/3] dcou: mod banking_trace::for_test --- Cargo.lock | 1 + core/Cargo.toml | 4 ++++ core/src/banking_trace.rs | 14 ++++++++------ 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efe6c3084b4cf9..fba1d9ed570e0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5649,6 +5649,7 @@ dependencies = [ "solana-address-lookup-table-program", "solana-bloom", "solana-client", + "solana-core", "solana-cost-model", "solana-entry", "solana-frozen-abi", diff --git a/core/Cargo.toml b/core/Cargo.toml index 03407c2fc1d882..62ca46bbf9229f 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -80,6 +80,7 @@ matches = { workspace = true } raptorq = { workspace = true } serde_json = { workspace = true } serial_test = { workspace = true } +solana-core = { workspace = true, features = ["dev-context-only-utils"] } solana-logger = { workspace = true } solana-program-runtime = { workspace = true } solana-stake-program = { workspace = true } @@ -93,6 +94,9 @@ sysctl = { workspace = true } [build-dependencies] rustc_version = { workspace = true } +[features] +dev-context-only-utils = [] + [[bench]] name = "banking_stage" diff --git a/core/src/banking_trace.rs b/core/src/banking_trace.rs index b245e1fb59287b..7a5c8d42da45ae 100644 --- a/core/src/banking_trace.rs +++ b/core/src/banking_trace.rs @@ -4,10 +4,7 @@ use { chrono::{DateTime, Local}, crossbeam_channel::{unbounded, Receiver, SendError, Sender, TryRecvError}, rolling_file::{RollingCondition, RollingConditionBasic, RollingFileAppender}, - solana_perf::{ - packet::{to_packet_batches, PacketBatch}, - test_tx::test_tx, - }, + solana_perf::packet::PacketBatch, solana_sdk::{hash::Hash, slot_history::Slot}, std::{ fs::{create_dir_all, remove_dir_all}, @@ -20,7 +17,6 @@ use { thread::{self, sleep, JoinHandle}, time::{Duration, SystemTime}, }, - tempfile::TempDir, thiserror::Error, }; @@ -358,8 +354,13 @@ impl TracedSender { } } +#[cfg(any(test, feature = "dev-context-only-utils"))] pub mod for_test { - use super::*; + use { + super::*, + solana_perf::{packet::to_packet_batches, test_tx::test_tx}, + tempfile::TempDir, + }; pub fn sample_packet_batch() -> BankingPacketBatch { BankingPacketBatch::new((to_packet_batches(&vec![test_tx(); 4], 10), None)) @@ -400,6 +401,7 @@ mod tests { io::{BufReader, ErrorKind::UnexpectedEof}, str::FromStr, }, + tempfile::TempDir, }; #[test] From 03f0e5ff9066582834261b9e9fe19089a3c60ec6 Mon Sep 17 00:00:00 2001 From: Ryo Onodera Date: Mon, 10 Jul 2023 14:36:47 +0900 Subject: [PATCH 2/3] Add comment --- core/Cargo.toml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 62ca46bbf9229f..d0da2c1e4c8d16 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -80,7 +80,11 @@ matches = { workspace = true } raptorq = { workspace = true } serde_json = { workspace = true } serial_test = { workspace = true } -solana-core = { workspace = true, features = ["dev-context-only-utils"] } +# Even if we want to activate features only for dev-dep., `cargo publish` +# complains about self-dep with version specified. So don't inherit with +# `workspace = true`. In this way, `cargo publish` will strip this self-dep +# according to https://github.com/rust-lang/cargo/pull/7333 +solana-core = { path = ".", features = ["dev-context-only-utils"] } solana-logger = { workspace = true } solana-program-runtime = { workspace = true } solana-stake-program = { workspace = true } From a61b2911a64d4ce409cdda91d56615ad9cbc919e Mon Sep 17 00:00:00 2001 From: Ryo Onodera Date: Thu, 13 Jul 2023 14:59:22 +0900 Subject: [PATCH 3/3] Simplify comment to avoid being redundant --- core/Cargo.toml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index d0da2c1e4c8d16..1e93de93b6b1af 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -80,10 +80,7 @@ matches = { workspace = true } raptorq = { workspace = true } serde_json = { workspace = true } serial_test = { workspace = true } -# Even if we want to activate features only for dev-dep., `cargo publish` -# complains about self-dep with version specified. So don't inherit with -# `workspace = true`. In this way, `cargo publish` will strip this self-dep -# according to https://github.com/rust-lang/cargo/pull/7333 +# See order-crates-for-publishing.py for using this unusual `path = "."` solana-core = { path = ".", features = ["dev-context-only-utils"] } solana-logger = { workspace = true } solana-program-runtime = { workspace = true }