From 24ab79ce238d6308846fddf3cad1b9397d80a7c5 Mon Sep 17 00:00:00 2001 From: Brooks Date: Fri, 15 Nov 2024 11:34:17 -0500 Subject: [PATCH 1/2] Startup only sets latest_full_snapshot_slot if generating snapshots (#3633) (cherry picked from commit 4ea10c224ae4a360db0011fb08d4b58d60d3a5a6) # Conflicts: # accounts-db/src/accounts_db.rs # ledger/src/bank_forks_utils.rs --- accounts-db/src/accounts_db.rs | 6 ++++++ ledger/src/bank_forks_utils.rs | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index 9ce0fc6f4eaeb9..b86f356ac21a98 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -1502,12 +1502,18 @@ pub struct AccountsDb { pub epoch_accounts_hash_manager: EpochAccountsHashManager, } +<<<<<<< HEAD #[derive(Debug, Default)] pub struct AccountsStats { delta_hash_scan_time_total_us: AtomicU64, delta_hash_accumulate_time_total_us: AtomicU64, delta_hash_num: AtomicU64, skipped_rewrites_num: AtomicUsize, +======= + /// The latest full snapshot slot dictates how to handle zero lamport accounts + /// Note, this is None if we're told to *not* take snapshots + latest_full_snapshot_slot: SeqLock>, +>>>>>>> 4ea10c224a (Startup only sets latest_full_snapshot_slot if generating snapshots (#3633)) last_store_report: AtomicInterval, store_hash_accounts: AtomicU64, diff --git a/ledger/src/bank_forks_utils.rs b/ledger/src/bank_forks_utils.rs index 6a48ebd2cebc9d..acb97e84b92010 100644 --- a/ledger/src/bank_forks_utils.rs +++ b/ledger/src/bank_forks_utils.rs @@ -336,6 +336,27 @@ fn bank_forks_from_snapshot( bank }; +<<<<<<< HEAD +======= + // We must inform accounts-db of the latest full snapshot slot, which is used by the background + // processes to handle zero lamport accounts. Since we've now successfully loaded the bank + // from snapshots, this is a good time to do that update. + // Note, this must only be set if we should generate snapshots. + if snapshot_config.should_generate_snapshots() { + bank.rc + .accounts + .accounts_db + .set_latest_full_snapshot_slot(full_snapshot_archive_info.slot()); + } else { + assert!(bank + .rc + .accounts + .accounts_db + .latest_full_snapshot_slot() + .is_none()); + } + +>>>>>>> 4ea10c224a (Startup only sets latest_full_snapshot_slot if generating snapshots (#3633)) let full_snapshot_hash = FullSnapshotHash(( full_snapshot_archive_info.slot(), *full_snapshot_archive_info.hash(), From b5b7424f3183e2ad77ce3dd1aa8916bd005451ee Mon Sep 17 00:00:00 2001 From: brooks Date: Fri, 15 Nov 2024 11:46:51 -0500 Subject: [PATCH 2/2] fix backport merge conflict --- accounts-db/src/accounts_db.rs | 6 ------ core/src/validator.rs | 8 +++++++- ledger/src/bank_forks_utils.rs | 21 --------------------- 3 files changed, 7 insertions(+), 28 deletions(-) diff --git a/accounts-db/src/accounts_db.rs b/accounts-db/src/accounts_db.rs index b86f356ac21a98..9ce0fc6f4eaeb9 100644 --- a/accounts-db/src/accounts_db.rs +++ b/accounts-db/src/accounts_db.rs @@ -1502,18 +1502,12 @@ pub struct AccountsDb { pub epoch_accounts_hash_manager: EpochAccountsHashManager, } -<<<<<<< HEAD #[derive(Debug, Default)] pub struct AccountsStats { delta_hash_scan_time_total_us: AtomicU64, delta_hash_accumulate_time_total_us: AtomicU64, delta_hash_num: AtomicU64, skipped_rewrites_num: AtomicUsize, -======= - /// The latest full snapshot slot dictates how to handle zero lamport accounts - /// Note, this is None if we're told to *not* take snapshots - latest_full_snapshot_slot: SeqLock>, ->>>>>>> 4ea10c224a (Startup only sets latest_full_snapshot_slot if generating snapshots (#3633)) last_store_report: AtomicInterval, store_hash_accounts: AtomicU64, diff --git a/core/src/validator.rs b/core/src/validator.rs index d89520c0c83163..e2a250ae668751 100644 --- a/core/src/validator.rs +++ b/core/src/validator.rs @@ -812,7 +812,13 @@ impl Validator { let pruned_banks_request_handler = PrunedBanksRequestHandler { pruned_banks_receiver, }; - let last_full_snapshot_slot = starting_snapshot_hashes.map(|x| x.full.0 .0); + // If we're not generating snapshots, ensure ABS's last full snapshot slot is None to + // ensure we handle zero lamport accounts correctly. + let last_full_snapshot_slot = if config.snapshot_config.should_generate_snapshots() { + starting_snapshot_hashes.map(|x| x.full.0 .0) + } else { + None + }; let accounts_background_service = AccountsBackgroundService::new( bank_forks.clone(), exit.clone(), diff --git a/ledger/src/bank_forks_utils.rs b/ledger/src/bank_forks_utils.rs index acb97e84b92010..6a48ebd2cebc9d 100644 --- a/ledger/src/bank_forks_utils.rs +++ b/ledger/src/bank_forks_utils.rs @@ -336,27 +336,6 @@ fn bank_forks_from_snapshot( bank }; -<<<<<<< HEAD -======= - // We must inform accounts-db of the latest full snapshot slot, which is used by the background - // processes to handle zero lamport accounts. Since we've now successfully loaded the bank - // from snapshots, this is a good time to do that update. - // Note, this must only be set if we should generate snapshots. - if snapshot_config.should_generate_snapshots() { - bank.rc - .accounts - .accounts_db - .set_latest_full_snapshot_slot(full_snapshot_archive_info.slot()); - } else { - assert!(bank - .rc - .accounts - .accounts_db - .latest_full_snapshot_slot() - .is_none()); - } - ->>>>>>> 4ea10c224a (Startup only sets latest_full_snapshot_slot if generating snapshots (#3633)) let full_snapshot_hash = FullSnapshotHash(( full_snapshot_archive_info.slot(), *full_snapshot_archive_info.hash(),