Skip to content

Commit

Permalink
Fixes accounts lt hash verification at startup (#3465)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Nov 4, 2024
1 parent 3bf9c2e commit eb3b18e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5721,7 +5721,7 @@ impl Bank {
let start = Instant::now();
let mut lattice_verify_time = None;
let mut merkle_verify_time = None;
match verify_kind {
let is_ok = match verify_kind {
VerifyKind::Lattice => {
// accounts lt hash is *enabled* so use lattice-based verification
let accounts_db = &accounts_.accounts_db;
Expand All @@ -5733,24 +5733,26 @@ impl Bank {
&duplicates_lt_hash.unwrap(),
)
}));
if calculated_accounts_lt_hash != expected_accounts_lt_hash {
let is_ok =
calculated_accounts_lt_hash == expected_accounts_lt_hash;
if !is_ok {
let expected = expected_accounts_lt_hash.0.checksum();
let calculated = calculated_accounts_lt_hash.0.checksum();
error!(
"Verifying accounts failed: accounts lattice hashes do not \
match, expected: {expected}, calculated: {calculated}",
);
return false;
}
lattice_verify_time = Some(duration);
is_ok
}
VerifyKind::Merkle => {
// accounts lt hash is *disabled* so use merkle-based verification
let snapshot_storages_and_slots = (
snapshot_storages.0.as_slice(),
snapshot_storages.1.as_slice(),
);
let (result, duration) = meas_dur!(accounts_
let (is_ok, duration) = meas_dur!(accounts_
.verify_accounts_hash_and_lamports(
snapshot_storages_and_slots,
slot,
Expand All @@ -5763,12 +5765,10 @@ impl Bank {
..verify_config
},
));
if !result {
return false;
}
merkle_verify_time = Some(duration);
is_ok
}
}
};
accounts_
.accounts_db
.verify_accounts_hash_in_bg
Expand All @@ -5788,7 +5788,7 @@ impl Bank {
),
);
info!("Initial background accounts hash verification has stopped");
true
is_ok
})
.unwrap()
});
Expand Down Expand Up @@ -5827,15 +5827,15 @@ impl Bank {
snapshot_storages.0.as_slice(),
snapshot_storages.1.as_slice(),
);
let result = accounts.verify_accounts_hash_and_lamports(
let is_ok = accounts.verify_accounts_hash_and_lamports(
snapshot_storages_and_slots,
slot,
capitalization,
base,
verify_config,
);
self.set_initial_accounts_hash_verification_completed();
result
is_ok
}
}
}
Expand Down

0 comments on commit eb3b18e

Please sign in to comment.