Skip to content

Commit

Permalink
Merge branch 'master' into shred-index-next
Browse files Browse the repository at this point in the history
  • Loading branch information
cpubot authored Jan 10, 2025
2 parents c6d6b80 + 117ab20 commit c7f7529
Show file tree
Hide file tree
Showing 125 changed files with 2,287 additions and 2,043 deletions.
166 changes: 100 additions & 66 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ atty = "0.2.11"
backoff = "0.4.0"
base64 = "0.22.1"
bincode = "1.3.3"
bitflags = { version = "2.6.0" }
bitflags = { version = "2.7.0" }
blake3 = "1.5.5"
borsh = { version = "1.5.3", features = ["derive", "unstable__schema"] }
borsh0-10 = { package = "borsh", version = "0.10.3" }
Expand Down
2 changes: 1 addition & 1 deletion account-decoder/src/parse_address_lookup_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub struct UiLookupTable {
pub addresses: Vec<String>,
}

impl<'a> From<AddressLookupTable<'a>> for UiLookupTable {
impl From<AddressLookupTable<'_>> for UiLookupTable {
fn from(address_lookup_table: AddressLookupTable) -> Self {
Self {
deactivation_slot: address_lookup_table.meta.deactivation_slot.to_string(),
Expand Down
6 changes: 3 additions & 3 deletions accounts-db/src/account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<'a> AccountStorageIter<'a> {
}
}

impl<'a> Iterator for AccountStorageIter<'a> {
impl Iterator for AccountStorageIter<'_> {
type Item = (Slot, Arc<AccountStorageEntry>);

fn next(&mut self) -> Option<Self::Item> {
Expand All @@ -264,7 +264,7 @@ pub struct ShrinkInProgress<'a> {
}

/// called when the shrink is no longer in progress. This means we can release the old append vec and update the map of slot -> append vec
impl<'a> Drop for ShrinkInProgress<'a> {
impl Drop for ShrinkInProgress<'_> {
fn drop(&mut self) {
assert_eq!(
self.storage
Expand All @@ -289,7 +289,7 @@ impl<'a> Drop for ShrinkInProgress<'a> {
}
}

impl<'a> ShrinkInProgress<'a> {
impl ShrinkInProgress<'_> {
pub fn new_storage(&self) -> &Arc<AccountStorageEntry> {
&self.new_store
}
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/account_storage/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<'storage> StoredAccountMeta<'storage> {
}
}

impl<'storage> ReadableAccount for StoredAccountMeta<'storage> {
impl ReadableAccount for StoredAccountMeta<'_> {
fn lamports(&self) -> u64 {
match self {
Self::AppendVec(av) => av.lamports(),
Expand Down
5 changes: 1 addition & 4 deletions accounts-db/src/accounts_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,7 @@ impl AccountsCache {
}

pub fn add_root(&self, root: Slot) {
let max_flushed_root = self.fetch_max_flush_root();
if root > max_flushed_root || (root == max_flushed_root && root == 0) {
self.maybe_unflushed_roots.write().unwrap().insert(root);
}
self.maybe_unflushed_roots.write().unwrap().insert(root);
}

pub fn clear_roots(&self, max_root: Option<Slot>) -> BTreeSet<Slot> {
Expand Down
31 changes: 17 additions & 14 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ enum StoreTo<'a> {
Storage(&'a Arc<AccountStorageEntry>),
}

impl<'a> StoreTo<'a> {
impl StoreTo<'_> {
fn is_cached(&self) -> bool {
matches!(self, StoreTo::Cache)
}
Expand Down Expand Up @@ -1091,7 +1091,7 @@ pub enum LoadedAccount<'a> {
Cached(Cow<'a, CachedAccount>),
}

impl<'a> LoadedAccount<'a> {
impl LoadedAccount<'_> {
pub fn loaded_hash(&self) -> AccountHash {
match self {
LoadedAccount::Stored(stored_account_meta) => *stored_account_meta.hash(),
Expand Down Expand Up @@ -1131,7 +1131,7 @@ impl<'a> LoadedAccount<'a> {
}
}

impl<'a> ReadableAccount for LoadedAccount<'a> {
impl ReadableAccount for LoadedAccount<'_> {
fn lamports(&self) -> u64 {
match self {
LoadedAccount::Stored(stored_account_meta) => stored_account_meta.lamports(),
Expand Down Expand Up @@ -1875,7 +1875,7 @@ impl solana_frozen_abi::abi_example::AbiExample for AccountsDb {
}
}

impl<'a> ZeroLamport for StoredAccountMeta<'a> {
impl ZeroLamport for StoredAccountMeta<'_> {
fn is_zero_lamport(&self) -> bool {
self.lamports() == 0
}
Expand Down Expand Up @@ -6296,30 +6296,33 @@ impl AccountsDb {
});

// Always flush up to `requested_flush_root`, which is necessary for things like snapshotting.
let cached_roots: BTreeSet<Slot> = self.accounts_cache.clear_roots(requested_flush_root);
let flushed_roots: BTreeSet<Slot> = self.accounts_cache.clear_roots(requested_flush_root);

// Iterate from highest to lowest so that we don't need to flush earlier
// outdated updates in earlier roots
let mut num_roots_flushed = 0;
let mut flush_stats = FlushStats::default();
for &root in cached_roots.iter().rev() {
for &root in flushed_roots.iter().rev() {
if let Some(stats) =
self.flush_slot_cache_with_clean(root, should_flush_f.as_mut(), max_clean_root)
{
num_roots_flushed += 1;
flush_stats.accumulate(&stats);
}
}

// Regardless of whether this slot was *just* flushed from the cache by the above
// `flush_slot_cache()`, we should update the `max_flush_root`.
// This is because some rooted slots may be flushed to storage *before* they are marked as root.
// This can occur for instance when
// the cache is overwhelmed, we flushed some yet to be rooted frozen slots
// These slots may then *later* be marked as root, so we still need to handle updating the
// `max_flush_root` in the accounts cache.
// Note that self.flush_slot_cache_with_clean() can return None if the
// slot is already been flushed. This can happen if the cache is
// overwhelmed and we flushed some yet to be rooted frozen slots.
// However, Independent of whether the last slot was actually flushed
// from the cache by the above loop, we should always update the
// `max_flush_root` to the max of the flushed roots, because that's
// max_flushed_root tracks the logical last root that was flushed to
// storage by snapshotting.
if let Some(&root) = flushed_roots.last() {
self.accounts_cache.set_max_flush_root(root);
}
let num_new_roots = cached_roots.len();
let num_new_roots = flushed_roots.len();
(num_new_roots, num_roots_flushed, flush_stats)
}

Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/accounts_db/scan_account_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct ScanState<'a> {
stats_num_zero_lamport_accounts_ancient: Arc<AtomicU64>,
}

impl<'a> AppendVecScan for ScanState<'a> {
impl AppendVecScan for ScanState<'_> {
fn set_slot(&mut self, slot: Slot, is_ancient: bool) {
self.current_slot = slot;
self.is_ancient = is_ancient;
Expand Down
8 changes: 6 additions & 2 deletions accounts-db/src/accounts_db/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2361,7 +2361,7 @@ lazy_static! {
pub static ref RENT_COLLECTOR: RentCollector = RentCollector::default();
}

impl<'a> CalcAccountsHashConfig<'a> {
impl CalcAccountsHashConfig<'_> {
pub(crate) fn default() -> Self {
Self {
use_bg_thread_pool: false,
Expand Down Expand Up @@ -7040,6 +7040,7 @@ pub(crate) fn get_all_accounts(
.collect::<Vec<_>>()
}

#[track_caller]
pub(crate) fn compare_all_accounts(
one: &[(Pubkey, AccountSharedData)],
two: &[(Pubkey, AccountSharedData)],
Expand Down Expand Up @@ -7234,7 +7235,10 @@ fn test_shrink_ancient_overflow() {

let num_normal_slots = 2;
// build an ancient append vec at slot 'ancient_slot'
let (db, ancient_slot) = get_one_ancient_append_vec_and_others(true, num_normal_slots);
let (mut db, ancient_slot) = get_one_ancient_append_vec_and_others(true, num_normal_slots);

// This test is testing the squash-append code, which can only work with mmaps.
db.set_storage_access(StorageAccess::Mmap);

let max_slot_inclusive = ancient_slot + (num_normal_slots as Slot);
let initial_accounts = get_all_accounts(&db, ancient_slot..(max_slot_inclusive + 1));
Expand Down
4 changes: 2 additions & 2 deletions accounts-db/src/accounts_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ struct ItemLocation<'a> {
pointer: SlotGroupPointer,
}

impl<'a> AccountsHasher<'a> {
impl AccountsHasher<'_> {
pub fn calculate_hash(hashes: Vec<Vec<Hash>>) -> (Hash, usize) {
let cumulative_offsets = CumulativeOffsets::from_raw(&hashes);

Expand Down Expand Up @@ -1384,7 +1384,7 @@ mod tests {
static ref ACTIVE_STATS: ActiveStats = ActiveStats::default();
}

impl<'a> AccountsHasher<'a> {
impl AccountsHasher<'_> {
fn new(dir_for_temp_cache_files: PathBuf) -> Self {
Self {
zero_lamport_accounts: ZeroLamportAccounts::Excluded,
Expand Down
4 changes: 2 additions & 2 deletions accounts-db/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,8 @@ impl<'a, T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndexIter
}
}

impl<'a, T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> Iterator
for AccountsIndexIterator<'a, T, U>
impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> Iterator
for AccountsIndexIterator<'_, T, U>
{
type Item = Vec<(Pubkey, AccountMapEntry<T>)>;
fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/active_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub struct ActiveStatGuard<'a> {
item: ActiveStatItem,
}

impl<'a> Drop for ActiveStatGuard<'a> {
impl Drop for ActiveStatGuard<'_> {
fn drop(&mut self) {
self.stats.update_and_log(self.item, |stat| {
stat.fetch_sub(1, Ordering::Relaxed).wrapping_sub(1)
Expand Down
2 changes: 1 addition & 1 deletion accounts-db/src/ancient_append_vecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ fn div_ceil(x: u64, y: NonZeroU64) -> u64 {
// SAFETY: Since `y` is NonZero:
// - we know the denominator is > 0, and thus safe (cannot have divide-by-zero)
// - we know `x + y` is non-zero, and thus the numerator is safe (cannot underflow)
(x + y - 1) / y
x.div_ceil(y)
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions accounts-db/src/storable_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<'a> From<&'a StoredAccountMeta<'a>> for AccountForStorage<'a> {
}
}

impl<'a> ZeroLamport for AccountForStorage<'a> {
impl ZeroLamport for AccountForStorage<'_> {
fn is_zero_lamport(&self) -> bool {
self.lamports() == 0
}
Expand All @@ -47,7 +47,7 @@ impl<'a> AccountForStorage<'a> {
}
}

impl<'a> ReadableAccount for AccountForStorage<'a> {
impl ReadableAccount for AccountForStorage<'_> {
fn lamports(&self) -> u64 {
match self {
AccountForStorage::AddressAndAccount((_pubkey, account)) => account.lamports(),
Expand Down
12 changes: 6 additions & 6 deletions banks-server/src/banks_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use {
solana_send_transaction_service::{
send_transaction_service::{SendTransactionService, TransactionInfo},
tpu_info::NullTpuInfo,
transaction_client::ConnectionCacheClient,
},
std::{
io,
Expand Down Expand Up @@ -455,16 +454,17 @@ pub async fn start_tcp_server(
.map(move |chan| {
let (sender, receiver) = unbounded();

let client = ConnectionCacheClient::<NullTpuInfo>::new(
connection_cache.clone(),
SendTransactionService::new::<NullTpuInfo>(
tpu_addr,
&bank_forks,
None,
None,
receiver,
&connection_cache,
5_000,
0,
exit.clone(),
);

SendTransactionService::new(&bank_forks, receiver, client, 5_000, exit.clone());

let server = BanksServer::new(
bank_forks.clone(),
block_commitment_cache.clone(),
Expand Down
5 changes: 2 additions & 3 deletions bench-tps/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@ fn main() {
let max_fee = FeeRateGovernor::new(*target_lamports_per_signature, 0)
.max_lamports_per_signature
.saturating_add(max_lamports_for_prioritization(compute_unit_price));
let num_lamports_per_account = (num_accounts - 1 + NUM_SIGNATURES_FOR_TXS * max_fee)
/ num_accounts
+ num_lamports_per_account;
let num_lamports_per_account =
(NUM_SIGNATURES_FOR_TXS * max_fee).div_ceil(num_accounts) + num_lamports_per_account;
let mut accounts = HashMap::new();
keypairs.iter().for_each(|keypair| {
accounts.insert(
Expand Down
2 changes: 1 addition & 1 deletion bench-tps/src/send_batch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ trait Sliceable {
fn get_pubkey(&self) -> Pubkey;
}

impl<'a, T: Sliceable + Send + Sync> SendBatchTransactions<'a, T> for Vec<(T, Transaction)>
impl<T: Sliceable + Send + Sync> SendBatchTransactions<'_, T> for Vec<(T, Transaction)>
where
<T as Sliceable>::Slice: Signers,
{
Expand Down
6 changes: 4 additions & 2 deletions clap-v3-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ solana-clock = { workspace = true }
solana-cluster-type = { workspace = true }
solana-commitment-config = { workspace = true }
solana-derivation-path = { workspace = true }
solana-hash = { workspace = true }
# the borsh feature is required to use the value_parser macro
solana-hash = { workspace = true, features = ["borsh"] }
solana-keypair = { workspace = true, features = ["seed-derivable"] }
solana-message = { workspace = true }
solana-native-token = { workspace = true }
solana-presigner = { workspace = true }
solana-program = { workspace = true }
solana-pubkey = { workspace = true }
solana-remote-wallet = { workspace = true, features = ["default"] }
solana-seed-derivable = { workspace = true }
Expand All @@ -37,6 +38,7 @@ url = { workspace = true }
[dev-dependencies]
assert_matches = { workspace = true }
solana-pubkey = { workspace = true, features = ["rand"] }
solana-system-interface = { workspace = true, features = ["bincode"] }
tempfile = { workspace = true }

[lib]
Expand Down
10 changes: 3 additions & 7 deletions clap-v3-utils/src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use {
solana_derivation_path::DerivationPath,
solana_hash::Hash,
solana_keypair::{read_keypair, read_keypair_file, Keypair},
solana_message::Message,
solana_presigner::Presigner,
solana_program::message::Message,
solana_pubkey::Pubkey,
solana_remote_wallet::{
remote_keypair::generate_remote_keypair,
Expand Down Expand Up @@ -1211,8 +1211,8 @@ mod tests {
crate::offline::OfflineArgs,
clap::{Arg, Command},
solana_keypair::write_keypair_file,
solana_program::system_instruction,
solana_remote_wallet::remote_wallet::initialize_wallet_manager,
solana_system_interface::instruction::transfer,
tempfile::TempDir,
};

Expand All @@ -1233,11 +1233,7 @@ mod tests {
let nonsigner2 = Keypair::new();
let recipient = Pubkey::new_unique();
let message = Message::new(
&[system_instruction::transfer(
&source.pubkey(),
&recipient,
42,
)],
&[transfer(&source.pubkey(), &recipient, 42)],
Some(&fee_payer.pubkey()),
);
let signers = vec![
Expand Down
2 changes: 1 addition & 1 deletion cli-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Config {
return "".to_string();
}
let json_rpc_url = json_rpc_url.unwrap();
let is_secure = json_rpc_url.scheme().to_ascii_lowercase() == "https";
let is_secure = json_rpc_url.scheme().eq_ignore_ascii_case("https");
let mut ws_url = json_rpc_url.clone();
ws_url
.set_scheme(if is_secure { "wss" } else { "ws" })
Expand Down
Loading

0 comments on commit c7f7529

Please sign in to comment.