From f9e10ef3a925c1183641386aa66d35e3725c91ab Mon Sep 17 00:00:00 2001 From: Ryo Onodera Date: Fri, 7 Feb 2020 02:29:20 +0900 Subject: [PATCH] Restore last_root to fix unintended storage delete --- runtime/src/accounts_db.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 9f40734aa257c1..9aa6467ccc9b8a 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -1265,6 +1265,7 @@ impl AccountsDB { let mut slots: Vec = storage.0.keys().cloned().collect(); slots.sort(); let mut accounts_index = self.accounts_index.write().unwrap(); + let mut last_root = 0; for slot_id in slots.iter() { let mut accumulator: Vec> = self .scan_account_storage( @@ -1289,13 +1290,15 @@ impl AccountsDB { AccountsDB::merge(&mut account_maps, &maps); } if !account_maps.is_empty() { - accounts_index.roots.insert(*slot_id); + last_root = *slot_id; + accounts_index.roots.insert(last_root); let mut _reclaims: Vec<(u64, AccountInfo)> = vec![]; for (pubkey, (_, account_info)) in account_maps.iter() { accounts_index.insert(*slot_id, pubkey, account_info.clone(), &mut _reclaims); } } } + accounts_index.last_root = last_root; let mut counts = HashMap::new(); for slot_list in accounts_index.account_maps.values() {