From ce63640d6deb29e78d6de9727afbbdc4bb1bcdca Mon Sep 17 00:00:00 2001 From: Ryo Onodera Date: Sun, 13 Aug 2023 14:12:20 +0900 Subject: [PATCH] dcou: make internal function `pub` conditionally (#32822) dcou: make internal function pub conditionally --- Cargo.lock | 12 ++++++++++++ Cargo.toml | 1 + accounts-db/Cargo.toml | 1 + accounts-db/src/accounts_db.rs | 11 +++-------- programs/sbf/Cargo.lock | 12 ++++++++++++ runtime/src/bank/serde_snapshot.rs | 12 +++--------- 6 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 755cd92739..1e5cf035fe 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4101,6 +4101,17 @@ dependencies = [ "percent-encoding 2.3.0", ] +[[package]] +name = "qualifier_attr" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a696aef893ed46a96ed81163ef58856b2da620c2eb4b38623253ad215c600b1d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -5225,6 +5236,7 @@ dependencies = [ "once_cell", "ouroboros", "percentage", + "qualifier_attr", "rand 0.7.3", "rand_chacha 0.2.2", "rayon", diff --git a/Cargo.toml b/Cargo.toml index 9aee5ad03e..dc0b002213 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -259,6 +259,7 @@ prost = "0.11.9" prost-types = "0.11.9" protobuf-src = "1.1.0" qstring = "0.7.2" +qualifier_attr = "0.1.6" quinn = "0.10.2" quinn-proto = "0.10.2" quote = "1.0" diff --git a/accounts-db/Cargo.toml b/accounts-db/Cargo.toml index 1bf07989fe..b53e1d15ef 100644 --- a/accounts-db/Cargo.toml +++ b/accounts-db/Cargo.toml @@ -39,6 +39,7 @@ num_enum = { workspace = true } once_cell = { workspace = true } ouroboros = { workspace = true } percentage = { workspace = true } +qualifier_attr = { workspace = true } rand = { workspace = true } rayon = { workspace = true } regex = { workspace = true } diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index e27da189dc..cf285d8345 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -18,6 +18,8 @@ //! tracks the number of commits to the entire data store. So the latest //! commit for each slot entry would be indexed. +#[cfg(feature = "dev-context-only-utils")] +use qualifier_attr::fn_qualifiers; use { crate::{ account_info::{AccountInfo, StorageLocation}, @@ -7898,6 +7900,7 @@ impl AccountsDb { /// Set the accounts delta hash for `slot` in the `accounts_delta_hashes` map /// /// returns the previous accounts delta hash for `slot` + #[cfg_attr(feature = "dev-context-only-utils", fn_qualifiers(pub))] fn set_accounts_delta_hash( &self, slot: Slot, @@ -9581,14 +9584,6 @@ impl AccountsDb { &self.accounts_delta_hashes } - pub fn set_accounts_delta_hash_for_tests( - &self, - slot: Slot, - accounts_delta_hash: AccountsDeltaHash, - ) { - self.set_accounts_delta_hash(slot, accounts_delta_hash); - } - pub fn accounts_hashes(&self) -> &Mutex> { &self.accounts_hashes } diff --git a/programs/sbf/Cargo.lock b/programs/sbf/Cargo.lock index e5cfb1c8c5..e4262c092d 100644 --- a/programs/sbf/Cargo.lock +++ b/programs/sbf/Cargo.lock @@ -3631,6 +3631,17 @@ dependencies = [ "percent-encoding 2.3.0", ] +[[package]] +name = "qualifier_attr" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a696aef893ed46a96ed81163ef58856b2da620c2eb4b38623253ad215c600b1d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.28", +] + [[package]] name = "quinn" version = "0.10.2" @@ -4560,6 +4571,7 @@ dependencies = [ "once_cell", "ouroboros", "percentage", + "qualifier_attr", "rand 0.7.3", "rayon", "regex", diff --git a/runtime/src/bank/serde_snapshot.rs b/runtime/src/bank/serde_snapshot.rs index d187c7e94a..5360523c7a 100644 --- a/runtime/src/bank/serde_snapshot.rs +++ b/runtime/src/bank/serde_snapshot.rs @@ -352,10 +352,7 @@ mod tests { bank.rc .accounts .accounts_db - .set_accounts_delta_hash_for_tests( - bank.slot(), - AccountsDeltaHash(Hash::new_unique()), - ); + .set_accounts_delta_hash(bank.slot(), AccountsDeltaHash(Hash::new_unique())); bank.rc .accounts .accounts_db @@ -546,7 +543,7 @@ mod tests { bank.rc .accounts .accounts_db - .set_accounts_delta_hash_for_tests(bank.slot(), AccountsDeltaHash(Hash::new_unique())); + .set_accounts_delta_hash(bank.slot(), AccountsDeltaHash(Hash::new_unique())); bank.rc .accounts .accounts_db @@ -628,10 +625,7 @@ mod tests { bank.rc .accounts .accounts_db - .set_accounts_delta_hash_for_tests( - bank.slot(), - AccountsDeltaHash(Hash::new_unique()), - ); + .set_accounts_delta_hash(bank.slot(), AccountsDeltaHash(Hash::new_unique())); bank.rc .accounts .accounts_db