add epoch_schedule and rent_collector to hash calc (#23857)
This commit is contained in:
committed by
GitHub
parent
db5d68f01f
commit
f1a411c897
@@ -125,6 +125,7 @@ fn main() {
|
|||||||
None,
|
None,
|
||||||
false,
|
false,
|
||||||
None,
|
None,
|
||||||
|
None,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
time_store.stop();
|
time_store.stop();
|
||||||
|
@@ -114,7 +114,9 @@ fn test_accounts_hash_bank_hash(bencher: &mut Bencher) {
|
|||||||
0,
|
0,
|
||||||
&ancestors,
|
&ancestors,
|
||||||
total_lamports,
|
total_lamports,
|
||||||
test_hash_calculation
|
test_hash_calculation,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
))
|
))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -42,7 +42,7 @@ use {
|
|||||||
pubkey::Pubkey,
|
pubkey::Pubkey,
|
||||||
slot_hashes::SlotHashes,
|
slot_hashes::SlotHashes,
|
||||||
system_program,
|
system_program,
|
||||||
sysvar::{self, instructions::construct_instructions_data},
|
sysvar::{self, epoch_schedule::EpochSchedule, instructions::construct_instructions_data},
|
||||||
transaction::{Result, SanitizedTransaction, TransactionAccountLocks, TransactionError},
|
transaction::{Result, SanitizedTransaction, TransactionAccountLocks, TransactionError},
|
||||||
transaction_context::TransactionAccount,
|
transaction_context::TransactionAccount,
|
||||||
},
|
},
|
||||||
@@ -747,6 +747,8 @@ impl Accounts {
|
|||||||
slot: Slot,
|
slot: Slot,
|
||||||
can_cached_slot_be_unflushed: bool,
|
can_cached_slot_be_unflushed: bool,
|
||||||
debug_verify: bool,
|
debug_verify: bool,
|
||||||
|
epoch_schedule: Option<&EpochSchedule>,
|
||||||
|
rent_collector: Option<&RentCollector>,
|
||||||
) -> u64 {
|
) -> u64 {
|
||||||
let use_index = false;
|
let use_index = false;
|
||||||
let is_startup = false; // there may be conditions where this is called at startup.
|
let is_startup = false; // there may be conditions where this is called at startup.
|
||||||
@@ -758,7 +760,8 @@ impl Accounts {
|
|||||||
ancestors,
|
ancestors,
|
||||||
None,
|
None,
|
||||||
can_cached_slot_be_unflushed,
|
can_cached_slot_be_unflushed,
|
||||||
None,
|
epoch_schedule,
|
||||||
|
rent_collector,
|
||||||
is_startup,
|
is_startup,
|
||||||
)
|
)
|
||||||
.1
|
.1
|
||||||
@@ -772,12 +775,16 @@ impl Accounts {
|
|||||||
ancestors: &Ancestors,
|
ancestors: &Ancestors,
|
||||||
total_lamports: u64,
|
total_lamports: u64,
|
||||||
test_hash_calculation: bool,
|
test_hash_calculation: bool,
|
||||||
|
epoch_schedule: Option<&EpochSchedule>,
|
||||||
|
rent_collector: Option<&RentCollector>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if let Err(err) = self.accounts_db.verify_bank_hash_and_lamports(
|
if let Err(err) = self.accounts_db.verify_bank_hash_and_lamports_new(
|
||||||
slot,
|
slot,
|
||||||
ancestors,
|
ancestors,
|
||||||
total_lamports,
|
total_lamports,
|
||||||
test_hash_calculation,
|
test_hash_calculation,
|
||||||
|
epoch_schedule,
|
||||||
|
rent_collector,
|
||||||
) {
|
) {
|
||||||
warn!("verify_bank_hash failed: {:?}", err);
|
warn!("verify_bank_hash failed: {:?}", err);
|
||||||
false
|
false
|
||||||
|
@@ -5233,13 +5233,13 @@ impl AccountsDb {
|
|||||||
|
|
||||||
pub fn update_accounts_hash(&self, slot: Slot, ancestors: &Ancestors) -> (Hash, u64) {
|
pub fn update_accounts_hash(&self, slot: Slot, ancestors: &Ancestors) -> (Hash, u64) {
|
||||||
self.update_accounts_hash_with_index_option(
|
self.update_accounts_hash_with_index_option(
|
||||||
true, false, slot, ancestors, None, false, None, false,
|
true, false, slot, ancestors, None, false, None, None, false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_accounts_hash_test(&self, slot: Slot, ancestors: &Ancestors) -> (Hash, u64) {
|
pub fn update_accounts_hash_test(&self, slot: Slot, ancestors: &Ancestors) -> (Hash, u64) {
|
||||||
self.update_accounts_hash_with_index_option(
|
self.update_accounts_hash_with_index_option(
|
||||||
true, true, slot, ancestors, None, false, None, false,
|
true, true, slot, ancestors, None, false, None, None, false,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5575,6 +5575,7 @@ impl AccountsDb {
|
|||||||
Ok((hash, total_lamports))
|
Ok((hash, total_lamports))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn update_accounts_hash_with_index_option(
|
pub fn update_accounts_hash_with_index_option(
|
||||||
&self,
|
&self,
|
||||||
use_index: bool,
|
use_index: bool,
|
||||||
@@ -5583,10 +5584,12 @@ impl AccountsDb {
|
|||||||
ancestors: &Ancestors,
|
ancestors: &Ancestors,
|
||||||
expected_capitalization: Option<u64>,
|
expected_capitalization: Option<u64>,
|
||||||
can_cached_slot_be_unflushed: bool,
|
can_cached_slot_be_unflushed: bool,
|
||||||
slots_per_epoch: Option<Slot>,
|
epoch_schedule: Option<&EpochSchedule>,
|
||||||
|
_rent_collector: Option<&RentCollector>,
|
||||||
is_startup: bool,
|
is_startup: bool,
|
||||||
) -> (Hash, u64) {
|
) -> (Hash, u64) {
|
||||||
let check_hash = false;
|
let check_hash = false;
|
||||||
|
let slots_per_epoch = epoch_schedule.map(|epoch_schedule| epoch_schedule.slots_per_epoch);
|
||||||
let (hash, total_lamports) = self
|
let (hash, total_lamports) = self
|
||||||
.calculate_accounts_hash_helper_with_verify(
|
.calculate_accounts_hash_helper_with_verify(
|
||||||
use_index,
|
use_index,
|
||||||
@@ -5782,6 +5785,26 @@ impl AccountsDb {
|
|||||||
ancestors: &Ancestors,
|
ancestors: &Ancestors,
|
||||||
total_lamports: u64,
|
total_lamports: u64,
|
||||||
test_hash_calculation: bool,
|
test_hash_calculation: bool,
|
||||||
|
) -> Result<(), BankHashVerificationError> {
|
||||||
|
self.verify_bank_hash_and_lamports_new(
|
||||||
|
slot,
|
||||||
|
ancestors,
|
||||||
|
total_lamports,
|
||||||
|
test_hash_calculation,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Only called from startup or test code.
|
||||||
|
pub fn verify_bank_hash_and_lamports_new(
|
||||||
|
&self,
|
||||||
|
slot: Slot,
|
||||||
|
ancestors: &Ancestors,
|
||||||
|
total_lamports: u64,
|
||||||
|
test_hash_calculation: bool,
|
||||||
|
_epoch_schedule: Option<&EpochSchedule>,
|
||||||
|
_rent_collector: Option<&RentCollector>,
|
||||||
) -> Result<(), BankHashVerificationError> {
|
) -> Result<(), BankHashVerificationError> {
|
||||||
use BankHashVerificationError::*;
|
use BankHashVerificationError::*;
|
||||||
|
|
||||||
@@ -5798,7 +5821,7 @@ impl AccountsDb {
|
|||||||
None,
|
None,
|
||||||
can_cached_slot_be_unflushed,
|
can_cached_slot_be_unflushed,
|
||||||
check_hash,
|
check_hash,
|
||||||
None,
|
None, // could use epoch_schedule.slots_per_epoch here
|
||||||
is_startup,
|
is_startup,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
@@ -5857,6 +5857,8 @@ impl Bank {
|
|||||||
&self.ancestors,
|
&self.ancestors,
|
||||||
self.capitalization(),
|
self.capitalization(),
|
||||||
test_hash_calculation,
|
test_hash_calculation,
|
||||||
|
Some(self.epoch_schedule()),
|
||||||
|
Some(&self.rent_collector),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5924,6 +5926,8 @@ impl Bank {
|
|||||||
self.slot(),
|
self.slot(),
|
||||||
can_cached_slot_be_unflushed,
|
can_cached_slot_be_unflushed,
|
||||||
debug_verify,
|
debug_verify,
|
||||||
|
Some(self.epoch_schedule()),
|
||||||
|
Some(&self.rent_collector),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5965,7 +5969,6 @@ impl Bank {
|
|||||||
mut debug_verify: bool,
|
mut debug_verify: bool,
|
||||||
is_startup: bool,
|
is_startup: bool,
|
||||||
) -> Hash {
|
) -> Hash {
|
||||||
let slots_per_epoch = Some(self.epoch_schedule().get_slots_in_epoch(self.epoch));
|
|
||||||
let (hash, total_lamports) = self
|
let (hash, total_lamports) = self
|
||||||
.rc
|
.rc
|
||||||
.accounts
|
.accounts
|
||||||
@@ -5977,7 +5980,8 @@ impl Bank {
|
|||||||
&self.ancestors,
|
&self.ancestors,
|
||||||
Some(self.capitalization()),
|
Some(self.capitalization()),
|
||||||
false,
|
false,
|
||||||
slots_per_epoch,
|
Some(self.epoch_schedule()),
|
||||||
|
Some(&self.rent_collector),
|
||||||
is_startup,
|
is_startup,
|
||||||
);
|
);
|
||||||
if total_lamports != self.capitalization() {
|
if total_lamports != self.capitalization() {
|
||||||
@@ -6002,7 +6006,8 @@ impl Bank {
|
|||||||
&self.ancestors,
|
&self.ancestors,
|
||||||
Some(self.capitalization()),
|
Some(self.capitalization()),
|
||||||
false,
|
false,
|
||||||
slots_per_epoch,
|
Some(self.epoch_schedule()),
|
||||||
|
Some(&self.rent_collector),
|
||||||
is_startup,
|
is_startup,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user