From 708b8380b7faa335380fad2dc6e126633b1debc1 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Tue, 16 Feb 2021 12:12:59 -0600 Subject: [PATCH] assert 2 items in stores don't have same slot and version with different values (#15250) * assert 2 items in stores don't have same slot and version with different values * add message to assert --- runtime/src/accounts_db.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index c048b074f..103b3c34a 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -4097,6 +4097,14 @@ impl AccountsDB { i = k; look_for_first_key = false; continue 'outer; + } else { + let prev = &slice[k - 1]; + assert!( + !(prev.slot == now.slot + && prev.version == now.version + && (prev.hash != now.hash || prev.lamports != now.lamports)), + "Conflicting store data. Pubkey: {}, Slot: {}, Version: {}, Hashes: {}, {}, Lamports: {}, {}", now.pubkey, now.slot, now.version, prev.hash, now.hash, prev.lamports, now.lamports + ); } } @@ -5938,7 +5946,13 @@ pub mod tests { .zip(keys.iter()) .enumerate() .map(|(i, (hash, key))| { - CalculateHashIntermediate::new(VERSION, hash, (i + 1) as u64, Slot::default(), *key) + CalculateHashIntermediate::new( + VERSION, + hash, + (i + 1) as u64, + u64::MAX - i as u64, + *key, + ) }) .collect();