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

Commit b09c916

Browse files
committed
partialeq bank
1 parent 29a63cd commit b09c916

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

core/tests/snapshots.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ mod tests {
156156
.get(&deserialized_bank.slot())
157157
.unwrap()
158158
.clone();
159-
bank.compare_bank(&deserialized_bank);
159+
assert!(*bank == deserialized_bank);
160160

161161
let slot_snapshot_paths = snapshot_utils::get_snapshot_paths(&snapshot_path);
162162

runtime/src/bank.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ use std::{
7171
mem,
7272
ops::RangeInclusive,
7373
path::PathBuf,
74-
ptr,
7574
rc::Rc,
7675
sync::{
7776
atomic::{AtomicBool, AtomicU64, Ordering::Relaxed},
@@ -478,18 +477,18 @@ pub(crate) struct BankFieldsToSerialize<'a> {
478477
pub(crate) is_delta: bool,
479478
}
480479

481-
impl<'a> PartialEq for BankFieldsToSerialize<'a> {
480+
impl PartialEq for Bank {
482481
fn eq(&self, other: &Self) -> bool {
483482
*self.blockhash_queue.read().unwrap() == *other.blockhash_queue.read().unwrap()
484483
&& self.ancestors == other.ancestors
485-
&& self.hash == other.hash
484+
&& *self.hash.read().unwrap() == *other.hash.read().unwrap()
486485
&& self.parent_hash == other.parent_hash
487486
&& self.parent_slot == other.parent_slot
488487
&& *self.hard_forks.read().unwrap() == *other.hard_forks.read().unwrap()
489-
&& self.transaction_count == other.transaction_count
490-
&& self.tick_height == other.tick_height
491-
&& self.signature_count == other.signature_count
492-
&& self.capitalization == other.capitalization
488+
&& self.transaction_count.load(Relaxed) == other.transaction_count.load(Relaxed)
489+
&& self.tick_height.load(Relaxed) == other.tick_height.load(Relaxed)
490+
&& self.signature_count.load(Relaxed) == other.signature_count.load(Relaxed)
491+
&& self.capitalization.load(Relaxed) == other.capitalization.load(Relaxed)
493492
&& self.max_tick_height == other.max_tick_height
494493
&& self.hashes_per_tick == other.hashes_per_tick
495494
&& self.ticks_per_slot == other.ticks_per_slot
@@ -501,16 +500,16 @@ impl<'a> PartialEq for BankFieldsToSerialize<'a> {
501500
&& self.epoch == other.epoch
502501
&& self.block_height == other.block_height
503502
&& self.collector_id == other.collector_id
504-
&& self.collector_fees == other.collector_fees
503+
&& self.collector_fees.load(Relaxed) == other.collector_fees.load(Relaxed)
505504
&& self.fee_calculator == other.fee_calculator
506505
&& self.fee_rate_governor == other.fee_rate_governor
507-
&& self.collected_rent == other.collected_rent
506+
&& self.collected_rent.load(Relaxed) == other.collected_rent.load(Relaxed)
508507
&& self.rent_collector == other.rent_collector
509508
&& self.epoch_schedule == other.epoch_schedule
510-
&& self.inflation == other.inflation
509+
&& *self.inflation.read().unwrap() == *other.inflation.read().unwrap()
511510
&& *self.stakes.read().unwrap() == *other.stakes.read().unwrap()
512511
&& self.epoch_stakes == other.epoch_stakes
513-
&& self.is_delta == other.is_delta
512+
&& self.is_delta.load(Relaxed) == other.is_delta.load(Relaxed)
514513
}
515514
}
516515

@@ -3631,13 +3630,6 @@ impl Bank {
36313630
}
36323631
}
36333632

3634-
pub fn compare_bank(&self, dbank: &Bank) {
3635-
assert_eq!(
3636-
self.get_fields_to_serialize(),
3637-
dbank.get_fields_to_serialize()
3638-
)
3639-
}
3640-
36413633
pub fn clean_accounts(&self, skip_last: bool) {
36423634
let max_clean_slot = if skip_last {
36433635
// Don't clean the slot we're snapshotting because it may have zero-lamport

runtime/src/serde_snapshot/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn test_bank_serialize_style(serde_style: SerdeStyle) {
219219
assert_eq!(dbank.get_balance(&key1.pubkey()), 0);
220220
assert_eq!(dbank.get_balance(&key2.pubkey()), 10);
221221
assert_eq!(dbank.get_balance(&key3.pubkey()), 0);
222-
bank2.compare_bank(&dbank);
222+
assert!(bank2 == dbank);
223223
}
224224

225225
#[cfg(test)]

0 commit comments

Comments
 (0)