Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Add address lookup tables to minimized snapshot (#30158)
Browse files Browse the repository at this point in the history
* Add address lookup tables to minimized snapshot

* Add comment for future posterity

* Add reference to the issue

* Adjust comment a bit

Co-authored-by: Andrew Fitzgerald <[email protected]>

---------

Co-authored-by: Andrew Fitzgerald <[email protected]>
  • Loading branch information
ryoqun and apfitzge authored Feb 10, 2023
1 parent 60cf8ce commit 3e6162e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
4 changes: 3 additions & 1 deletion ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ fn minimize_bank_for_snapshot(
ending_slot: Slot,
) {
let (transaction_account_set, transaction_accounts_measure) = measure!(
blockstore.get_accounts_used_in_range(snapshot_slot, ending_slot),
blockstore.get_accounts_used_in_range(bank, snapshot_slot, ending_slot),
"get transaction accounts"
);
let total_accounts_len = transaction_account_set.len();
Expand Down Expand Up @@ -1971,6 +1971,7 @@ fn main() {
.arg(&no_snapshot_arg)
.arg(&account_paths_arg)
.arg(&accounts_db_skip_initial_hash_calc_arg)
.arg(&accountsdb_skip_shrink)
.arg(&ancient_append_vecs)
.arg(&hard_forks_arg)
.arg(&max_genesis_archive_unpacked_size_arg)
Expand Down Expand Up @@ -3068,6 +3069,7 @@ fn main() {
halt_at_slot: Some(snapshot_slot),
poh_verify: false,
accounts_db_config: Some(get_accounts_db_config(&ledger_path, arg_matches)),
accounts_db_skip_shrink: arg_matches.is_present("accounts_db_skip_shrink"),
..ProcessOptions::default()
},
snapshot_archive_path,
Expand Down
32 changes: 26 additions & 6 deletions ledger/src/blockstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ use {
poh_timing_point::{send_poh_timing_point, PohTimingSender, SlotPohTimingInfo},
},
solana_rayon_threadlimit::get_max_thread_count,
solana_runtime::hardened_unpack::{unpack_genesis_archive, MAX_GENESIS_ARCHIVE_UNPACKED_SIZE},
solana_runtime::{
bank::Bank,
hardened_unpack::{unpack_genesis_archive, MAX_GENESIS_ARCHIVE_UNPACKED_SIZE},
},
solana_sdk::{
clock::{Slot, UnixTimestamp, DEFAULT_TICKS_PER_SECOND},
genesis_config::{GenesisConfig, DEFAULT_GENESIS_ARCHIVE, DEFAULT_GENESIS_FILE},
Expand Down Expand Up @@ -2853,6 +2856,7 @@ impl Blockstore {
/// Used by ledger-tool to create a minimized snapshot
pub fn get_accounts_used_in_range(
&self,
bank: &Bank,
starting_slot: Slot,
ending_slot: Slot,
) -> DashSet<Pubkey> {
Expand All @@ -2862,11 +2866,27 @@ impl Blockstore {
.into_par_iter()
.for_each(|slot| {
if let Ok(entries) = self.get_slot_entries(slot, 0) {
entries.par_iter().for_each(|entry| {
entry.transactions.iter().for_each(|tx| {
tx.message.static_account_keys().iter().for_each(|pubkey| {
result.insert(*pubkey);
});
entries.into_par_iter().for_each(|entry| {
entry.transactions.into_iter().for_each(|tx| {
if let Some(lookups) = tx.message.address_table_lookups() {
lookups.iter().for_each(|lookup| {
result.insert(lookup.account_key);
});
}
// howdy, anybody who reached here from the panic messsage!
// the .unwrap() below could indicate there was an odd error or there
// could simply be a tx with a new ALT, which is just created/updated
// in this range. too bad... this edge case isn't currently supported.
// see: https://github.com/solana-labs/solana/issues/30165
// for casual use, please choose different slot range.
let sanitized_tx = bank.fully_verify_transaction(tx).unwrap();
sanitized_tx
.message()
.account_keys()
.iter()
.for_each(|&pubkey| {
result.insert(pubkey);
});
});
});
}
Expand Down
8 changes: 8 additions & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,7 @@ impl Bank {
additional_builtins,
debug_do_not_add_builtins,
);
bank.fill_missing_sysvar_cache_entries();

// Sanity assertions between bank snapshot and genesis config
// Consider removing from serializable bank state
Expand Down Expand Up @@ -6937,6 +6938,13 @@ impl Bank {
Ok(sanitized_tx)
}

pub fn fully_verify_transaction(
&self,
tx: VersionedTransaction,
) -> Result<SanitizedTransaction> {
self.verify_transaction(tx, TransactionVerificationMode::FullVerification)
}

/// only called from ledger-tool or tests
fn calculate_capitalization(&self, debug_verify: bool) -> u64 {
let is_startup = true;
Expand Down

0 comments on commit 3e6162e

Please sign in to comment.