Skip to content

Commit

Permalink
Merge branch 'master' into rust-1.84.0/clippy/empty_line_after_doc_co…
Browse files Browse the repository at this point in the history
…mments
  • Loading branch information
brooksprumo authored Jan 10, 2025
2 parents 81db0b1 + cb9451c commit 555364b
Show file tree
Hide file tree
Showing 26 changed files with 1,104 additions and 477 deletions.
26 changes: 25 additions & 1 deletion Cargo.lock

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

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
23 changes: 13 additions & 10 deletions accounts-db/src/accounts_db.rs
Original file line number Diff line number Diff line change
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
21 changes: 20 additions & 1 deletion cli-output/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,36 @@ pretty-hex = { workspace = true }
semver = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
solana-account = { workspace = true }
solana-account-decoder = { workspace = true }
solana-bincode = { workspace = true }
solana-clap-utils = { workspace = true }
solana-cli-config = { workspace = true }
solana-clock = { workspace = true }
solana-epoch-info = { workspace = true }
solana-hash = { workspace = true }
solana-message = { workspace = true }
solana-native-token = { workspace = true }
solana-packet = { workspace = true }
solana-program = { workspace = true }
solana-pubkey = { workspace = true }
solana-reserved-account-keys = { workspace = true }
solana-rpc-client-api = { workspace = true }
solana-sdk = { workspace = true }
solana-sdk-ids = { workspace = true }
solana-signature = { workspace = true }
solana-system-interface = { workspace = true }
solana-sysvar = { workspace = true }
solana-transaction = { workspace = true }
solana-transaction-error = { workspace = true }
solana-transaction-status = { workspace = true }
solana-vote-program = { workspace = true }
spl-memo = { workspace = true, features = ["no-entrypoint"] }

[dev-dependencies]
ed25519-dalek = { workspace = true }
solana-keypair = { workspace = true }
solana-signer = { workspace = true }
solana-transaction-context = { workspace = true }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
39 changes: 19 additions & 20 deletions cli-output/src/cli_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,26 @@ use {
inflector::cases::titlecase::to_title_case,
serde::{Deserialize, Serialize},
serde_json::{Map, Value},
solana_account::ReadableAccount,
solana_account_decoder::{
encode_ui_account, parse_account_data::AccountAdditionalDataV2,
parse_token::UiTokenAccount, UiAccountEncoding, UiDataSliceConfig,
},
solana_clap_utils::keypair::SignOnly,
solana_clock::{Epoch, Slot, UnixTimestamp},
solana_epoch_info::EpochInfo,
solana_hash::Hash,
solana_native_token::lamports_to_sol,
solana_program::stake::state::{Authorized, Lockup},
solana_pubkey::Pubkey,
solana_rpc_client_api::response::{
RpcAccountBalance, RpcContactInfo, RpcInflationGovernor, RpcInflationRate, RpcKeyedAccount,
RpcSupply, RpcVoteAccountInfo,
},
solana_sdk::{
account::ReadableAccount,
clock::{Epoch, Slot, UnixTimestamp},
epoch_info::EpochInfo,
hash::Hash,
native_token::lamports_to_sol,
pubkey::Pubkey,
signature::Signature,
stake::state::{Authorized, Lockup},
stake_history::StakeHistoryEntry,
transaction::{Transaction, TransactionError, VersionedTransaction},
},
solana_signature::Signature,
solana_sysvar::stake_history::StakeHistoryEntry,
solana_transaction::{versioned::VersionedTransaction, Transaction},
solana_transaction_error::TransactionError,
solana_transaction_status::{
EncodedConfirmedBlock, EncodedTransaction, TransactionConfirmationStatus,
UiTransactionStatusMeta,
Expand Down Expand Up @@ -3280,13 +3279,13 @@ mod tests {
use {
super::*,
clap::{App, Arg},
solana_sdk::{
message::Message,
pubkey::Pubkey,
signature::{keypair_from_seed, NullSigner, Signature, Signer, SignerError},
system_instruction,
transaction::Transaction,
},
solana_keypair::keypair_from_seed,
solana_message::Message,
solana_pubkey::Pubkey,
solana_signature::Signature,
solana_signer::{null_signer::NullSigner, Signer, SignerError},
solana_system_interface::instruction::transfer,
solana_transaction::Transaction,
};

#[test]
Expand Down Expand Up @@ -3324,7 +3323,7 @@ mod tests {
let fee_payer = absent.pubkey();
let nonce_auth = bad.pubkey();
let mut tx = Transaction::new_unsigned(Message::new_with_nonce(
vec![system_instruction::transfer(&from, &to, 42)],
vec![transfer(&from, &to, 42)],
Some(&fee_payer),
&nonce,
&nonce_auth,
Expand Down
66 changes: 34 additions & 32 deletions cli-output/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@ use {
chrono::{DateTime, Local, SecondsFormat, TimeZone, Utc},
console::style,
indicatif::{ProgressBar, ProgressStyle},
solana_bincode::limited_deserialize,
solana_cli_config::SettingType,
solana_sdk::{
clock::UnixTimestamp,
hash::Hash,
instruction::CompiledInstruction,
message::v0::MessageAddressTableLookup,
native_token::lamports_to_sol,
program_utils::limited_deserialize,
pubkey::Pubkey,
reserved_account_keys::ReservedAccountKeys,
signature::Signature,
stake,
transaction::{TransactionError, TransactionVersion, VersionedTransaction},
},
solana_clock::UnixTimestamp,
solana_hash::Hash,
solana_message::{compiled_instruction::CompiledInstruction, v0::MessageAddressTableLookup},
solana_native_token::lamports_to_sol,
solana_program::stake,
solana_pubkey::Pubkey,
solana_reserved_account_keys::ReservedAccountKeys,
solana_signature::Signature,
solana_transaction::versioned::{TransactionVersion, VersionedTransaction},
solana_transaction_error::TransactionError,
solana_transaction_status::{
Rewards, UiReturnDataEncoding, UiTransactionReturnData, UiTransactionStatusMeta,
},
Expand Down Expand Up @@ -440,24 +438,29 @@ fn write_instruction<'a, W: io::Write>(
let mut raw = true;
if let AccountKeyType::Known(program_pubkey) = program_pubkey {
if program_pubkey == &solana_vote_program::id() {
if let Ok(vote_instruction) = limited_deserialize::<
solana_vote_program::vote_instruction::VoteInstruction,
>(&instruction.data)
if let Ok(vote_instruction) =
limited_deserialize::<solana_vote_program::vote_instruction::VoteInstruction>(
&instruction.data,
solana_packet::PACKET_DATA_SIZE as u64,
)
{
writeln!(w, "{prefix} {vote_instruction:?}")?;
raw = false;
}
} else if program_pubkey == &stake::program::id() {
if let Ok(stake_instruction) =
limited_deserialize::<stake::instruction::StakeInstruction>(&instruction.data)
{
if let Ok(stake_instruction) = limited_deserialize::<stake::instruction::StakeInstruction>(
&instruction.data,
solana_packet::PACKET_DATA_SIZE as u64,
) {
writeln!(w, "{prefix} {stake_instruction:?}")?;
raw = false;
}
} else if program_pubkey == &solana_sdk::system_program::id() {
if let Ok(system_instruction) = limited_deserialize::<
solana_sdk::system_instruction::SystemInstruction,
>(&instruction.data)
} else if program_pubkey == &solana_sdk_ids::system_program::id() {
if let Ok(system_instruction) =
limited_deserialize::<solana_system_interface::instruction::SystemInstruction>(
&instruction.data,
solana_packet::PACKET_DATA_SIZE as u64,
)
{
writeln!(w, "{prefix} {system_instruction:?}")?;
raw = false;
Expand Down Expand Up @@ -723,16 +726,15 @@ pub fn unix_timestamp_to_string(unix_timestamp: UnixTimestamp) -> String {
mod test {
use {
super::*,
solana_sdk::{
message::{
v0::{self, LoadedAddresses},
Message as LegacyMessage, MessageHeader, VersionedMessage,
},
pubkey::Pubkey,
signature::{Keypair, Signer},
transaction::Transaction,
transaction_context::TransactionReturnData,
solana_keypair::Keypair,
solana_message::{
v0::{self, LoadedAddresses},
Message as LegacyMessage, MessageHeader, VersionedMessage,
},
solana_pubkey::Pubkey,
solana_signer::Signer,
solana_transaction::Transaction,
solana_transaction_context::TransactionReturnData,
solana_transaction_status::{Reward, RewardType, TransactionStatusMeta},
std::io::BufWriter,
};
Expand Down
2 changes: 1 addition & 1 deletion gossip/src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3035,7 +3035,7 @@ impl Node {
}
}

pub fn push_messages_to_peer(
pub fn push_messages_to_peer_for_tests(
messages: Vec<CrdsValue>,
self_id: Pubkey,
peer_gossip: SocketAddr,
Expand Down
1 change: 1 addition & 0 deletions ledger/benches/blockstore_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ fn bench_execute_batch(
&mut timing,
None,
&prioritization_fee_cache,
None::<fn(&_) -> _>,
);
}
});
Expand Down
Loading

0 comments on commit 555364b

Please sign in to comment.