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

Commit

Permalink
ledger-tool create-snapshot uses write cache (#29119)
Browse files Browse the repository at this point in the history
* ledger-tool create-snapshot uses write cache

* ledger tool create snapshot works with write cache
  • Loading branch information
jeffwashington authored Dec 8, 2022
1 parent 019f276 commit 2f47315
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions ledger-tool/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3018,6 +3018,7 @@ fn main() {
&genesis_config,
&blockstore,
ProcessOptions {
accounts_db_caching_enabled: true,
new_hard_forks,
halt_at_slot: Some(snapshot_slot),
poh_verify: false,
Expand Down
3 changes: 2 additions & 1 deletion runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,14 +884,15 @@ impl Accounts {
debug_verify: bool,
epoch_schedule: &EpochSchedule,
rent_collector: &RentCollector,
data_source: CalcAccountsHashDataSource,
) -> u64 {
let is_startup = true;
self.accounts_db
.verify_accounts_hash_in_bg
.wait_for_complete();
self.accounts_db
.update_accounts_hash(
CalcAccountsHashDataSource::Storages,
data_source,
debug_verify,
slot,
ancestors,
Expand Down
7 changes: 6 additions & 1 deletion runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7009,6 +7009,8 @@ impl Bank {
debug_verify,
self.epoch_schedule(),
&self.rent_collector,
// we have to use the index since the slot could be in the write cache still
CalcAccountsHashDataSource::IndexForTests,
)
}

Expand All @@ -7031,7 +7033,10 @@ impl Bank {
/// This should only be used for developing purposes.
pub fn set_capitalization(&self) -> u64 {
let old = self.capitalization();
let debug_verify = true;
// We cannot debug verify the hash calculation here becuase calculate_capitalization will use the index calculation due to callers using the write cache.
// debug_verify only exists as an extra debugging step under the assumption that this code path is only used for tests. But, this is used by ledger-tool create-snapshot
// for example.
let debug_verify = false;
self.capitalization
.store(self.calculate_capitalization(debug_verify), Relaxed);
old
Expand Down

0 comments on commit 2f47315

Please sign in to comment.