From 631a98a3b6f21e5d89be9e76ed79f060b158f903 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Fri, 9 Dec 2022 16:28:18 -0600 Subject: [PATCH] warp_from_parents works with write_cache enabled (#29185) --- core/src/validator.rs | 1 + core/tests/epoch_accounts_hash.rs | 2 ++ ledger-tool/src/main.rs | 1 + program-test/src/lib.rs | 2 ++ runtime/src/bank.rs | 11 +++++++---- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/validator.rs b/core/src/validator.rs index c50b03378..d2a8883e7 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -1668,6 +1668,7 @@ fn maybe_warp_slot( &root_bank, &Pubkey::default(), warp_slot, + solana_runtime::accounts_db::CalcAccountsHashDataSource::Storages, )); bank_forks.set_root( warp_slot, diff --git a/core/tests/epoch_accounts_hash.rs b/core/tests/epoch_accounts_hash.rs index 36a5c7fc6..53de1712d 100755 --- a/core/tests/epoch_accounts_hash.rs +++ b/core/tests/epoch_accounts_hash.rs @@ -594,6 +594,7 @@ fn test_epoch_accounts_hash_and_warping() { &bank, &Pubkey::default(), eah_stop_slot_in_next_epoch, + solana_runtime::accounts_db::CalcAccountsHashDataSource::IndexForTests, )); let bank = bank_forks.write().unwrap().insert(Bank::new_from_parent( &bank, @@ -625,6 +626,7 @@ fn test_epoch_accounts_hash_and_warping() { &bank, &Pubkey::default(), eah_start_slot_in_next_epoch, + solana_runtime::accounts_db::CalcAccountsHashDataSource::Storages, )); let bank = bank_forks.write().unwrap().insert(Bank::new_from_parent( &bank, diff --git a/ledger-tool/src/main.rs b/ledger-tool/src/main.rs index 99a2bd18e..19429b29f 100644 --- a/ledger-tool/src/main.rs +++ b/ledger-tool/src/main.rs @@ -3229,6 +3229,7 @@ fn main() { &bank, bank.collector_id(), warp_slot, + solana_runtime::accounts_db::CalcAccountsHashDataSource::IndexForTests, )) } else { bank diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index 336c04363..b41bd5db2 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -1125,6 +1125,8 @@ impl ProgramTestContext { &bank, &Pubkey::default(), pre_warp_slot, + // some warping tests cannot use the append vecs because of the sequence of adding roots and flushing + solana_runtime::accounts_db::CalcAccountsHashDataSource::IndexForTests, )) }; diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 41f0901a0..86cba643e 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -1881,7 +1881,12 @@ impl Bank { /// * Adjusts the new bank's tick height to avoid having to run PoH for millions of slots /// * Freezes the new bank, assuming that the user will `Bank::new_from_parent` from this bank /// * Calculates and sets the epoch accounts hash from the parent - pub fn warp_from_parent(parent: &Arc, collector_id: &Pubkey, slot: Slot) -> Self { + pub fn warp_from_parent( + parent: &Arc, + collector_id: &Pubkey, + slot: Slot, + data_source: CalcAccountsHashDataSource, + ) -> Self { parent.freeze(); parent .rc @@ -1889,9 +1894,7 @@ impl Bank { .accounts_db .epoch_accounts_hash_manager .set_in_flight(parent.slot()); - parent.force_flush_accounts_cache(); - let accounts_hash = - parent.update_accounts_hash(CalcAccountsHashDataSource::Storages, false, true); + let accounts_hash = parent.update_accounts_hash(data_source, false, true); let epoch_accounts_hash = accounts_hash.into(); parent .rc