Skip to content

Commit cc2bacc

Browse files
author
HaoranYi
committed
disable read cache
1 parent a7918a2 commit cc2bacc

File tree

8 files changed

+38
-24
lines changed

8 files changed

+38
-24
lines changed

accounts-db/src/read_only_accounts_cache.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ impl ReadOnlyAccountsCache {
176176
}
177177

178178
pub(crate) fn store(&self, pubkey: Pubkey, slot: Slot, account: AccountSharedData) {
179+
panic!("haha");
179180
let measure_store = Measure::start("");
180181
self.highest_slot_stored.fetch_max(slot, Ordering::Release);
181182
let account_size = Self::account_size(&account);

runtime/src/bank.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ impl Bank {
18201820
where
18211821
F: Fn(&Option<AccountSharedData>) -> AccountSharedData,
18221822
{
1823-
let old_account = self.get_account_with_fixed_root(pubkey);
1823+
let old_account = self.get_account_with_fixed_root_no_cache(pubkey);
18241824
let mut new_account = updater(&old_account);
18251825

18261826
// When new sysvar comes into existence (with RENT_UNADJUSTED_INITIAL_BALANCE lamports),
@@ -2338,7 +2338,7 @@ impl Bank {
23382338
// already have been cached in cached_vote_accounts; so the code
23392339
// below is only for sanity check, and can be removed once
23402340
// vote_accounts_cache_miss_count is shown to be always zero.
2341-
let account = self.get_account_with_fixed_root(vote_pubkey)?;
2341+
let account = self.get_account_with_fixed_root_no_cache(vote_pubkey)?;
23422342
if account.owner() == &solana_vote_program
23432343
&& VoteState::deserialize(account.data()).is_ok()
23442344
{
@@ -3011,7 +3011,7 @@ impl Bank {
30113011

30123012
// Used by tests to simulate clusters with precompiles that aren't owned by the native loader
30133013
fn add_precompiled_account_with_owner(&self, program_id: &Pubkey, owner: Pubkey) {
3014-
if let Some(account) = self.get_account_with_fixed_root(program_id) {
3014+
if let Some(account) = self.get_account_with_fixed_root_no_cache(program_id) {
30153015
if account.executable() {
30163016
return;
30173017
} else {
@@ -3610,7 +3610,7 @@ impl Bank {
36103610

36113611
fn check_message_for_nonce(&self, message: &SanitizedMessage) -> Option<TransactionAccount> {
36123612
let nonce_address = message.get_durable_nonce()?;
3613-
let nonce_account = self.get_account_with_fixed_root(nonce_address)?;
3613+
let nonce_account = self.get_account_with_fixed_root_no_cache(nonce_address)?;
36143614
let nonce_data =
36153615
nonce_account::verify_nonce_account(&nonce_account, message.recent_blockhash())?;
36163616

@@ -5080,7 +5080,7 @@ impl Bank {
50805080
new_account: &AccountSharedData,
50815081
) {
50825082
let old_account_data_size =
5083-
if let Some(old_account) = self.get_account_with_fixed_root(pubkey) {
5083+
if let Some(old_account) = self.get_account_with_fixed_root_no_cache(pubkey) {
50845084
match new_account.lamports().cmp(&old_account.lamports()) {
50855085
std::cmp::Ordering::Greater => {
50865086
let increased = new_account.lamports() - old_account.lamports();
@@ -5122,7 +5122,7 @@ impl Bank {
51225122
}
51235123

51245124
fn withdraw(&self, pubkey: &Pubkey, lamports: u64) -> Result<()> {
5125-
match self.get_account_with_fixed_root(pubkey) {
5125+
match self.get_account_with_fixed_root_no_cache(pubkey) {
51265126
Some(mut account) => {
51275127
let min_balance = match get_system_account_kind(&account) {
51285128
Some(SystemAccountKind::Nonce) => self
@@ -5248,6 +5248,14 @@ impl Bank {
52485248
}
52495249
}
52505250

5251+
pub fn get_account_with_fixed_root_no_cache(
5252+
&self,
5253+
pubkey: &Pubkey,
5254+
) -> Option<AccountSharedData> {
5255+
self.load_account_with(pubkey, |_| false)
5256+
.map(|(acc, _slot)| acc)
5257+
}
5258+
52515259
// Hi! leaky abstraction here....
52525260
// try to use get_account_with_fixed_root() if it's called ONLY from on-chain runtime account
52535261
// processing. That alternative fn provides more safety.
@@ -6427,7 +6435,7 @@ impl Bank {
64276435

64286436
// Update activation slot of features in `new_feature_activations`
64296437
for feature_id in new_feature_activations.iter() {
6430-
if let Some(mut account) = self.get_account_with_fixed_root(feature_id) {
6438+
if let Some(mut account) = self.get_account_with_fixed_root_no_cache(feature_id) {
64316439
if let Some(mut feature) = feature::from_account(&account) {
64326440
feature.activated_at = Some(self.slot());
64336441
if feature::to_account(&feature, &mut account).is_some() {
@@ -6516,7 +6524,7 @@ impl Bank {
65166524

65176525
for feature_id in &self.feature_set.inactive {
65186526
let mut activated = None;
6519-
if let Some(account) = self.get_account_with_fixed_root(feature_id) {
6527+
if let Some(account) = self.get_account_with_fixed_root_no_cache(feature_id) {
65206528
if let Some(feature) = feature::from_account(&account) {
65216529
match feature.activated_at {
65226530
None if include_pending => {
@@ -6653,8 +6661,8 @@ impl Bank {
66536661
new_address: &Pubkey,
66546662
datapoint_name: &'static str,
66556663
) {
6656-
if let Some(old_account) = self.get_account_with_fixed_root(old_address) {
6657-
if let Some(new_account) = self.get_account_with_fixed_root(new_address) {
6664+
if let Some(old_account) = self.get_account_with_fixed_root_no_cache(old_address) {
6665+
if let Some(new_account) = self.get_account_with_fixed_root_no_cache(new_address) {
66586666
datapoint_info!(datapoint_name, ("slot", self.slot, i64));
66596667

66606668
// Burn lamports in the old account

runtime/src/bank/builtins/core_bpf_migration/source_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl SourceBuffer {
2525
) -> Result<Self, CoreBpfMigrationError> {
2626
// The buffer account should exist.
2727
let buffer_account = bank
28-
.get_account_with_fixed_root(buffer_address)
28+
.get_account_with_fixed_root_no_cache(buffer_address)
2929
.ok_or(CoreBpfMigrationError::AccountNotFound(*buffer_address))?;
3030

3131
// The buffer account should be owned by the upgradeable loader.

runtime/src/bank/builtins/core_bpf_migration/target_builtin.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl TargetBuiltin {
2929
CoreBpfMigrationTargetType::Builtin => {
3030
// The program account should exist.
3131
let program_account = bank
32-
.get_account_with_fixed_root(program_address)
32+
.get_account_with_fixed_root_no_cache(program_address)
3333
.ok_or(CoreBpfMigrationError::AccountNotFound(*program_address))?;
3434

3535
// The program account should be owned by the native loader.
@@ -41,7 +41,10 @@ impl TargetBuiltin {
4141
}
4242
CoreBpfMigrationTargetType::Stateless => {
4343
// The program account should _not_ exist.
44-
if bank.get_account_with_fixed_root(program_address).is_some() {
44+
if bank
45+
.get_account_with_fixed_root_no_cache(program_address)
46+
.is_some()
47+
{
4548
return Err(CoreBpfMigrationError::AccountExists(*program_address));
4649
}
4750

@@ -53,7 +56,7 @@ impl TargetBuiltin {
5356

5457
// The program data account should not exist.
5558
if bank
56-
.get_account_with_fixed_root(&program_data_address)
59+
.get_account_with_fixed_root_no_cache(&program_data_address)
5760
.is_some()
5861
{
5962
return Err(CoreBpfMigrationError::ProgramHasDataAccount(

runtime/src/bank/fee_distribution.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,9 @@ impl Bank {
168168
fees: u64,
169169
options: DepositFeeOptions,
170170
) -> Result<u64, DepositFeeError> {
171-
let mut account = self.get_account_with_fixed_root(pubkey).unwrap_or_default();
171+
let mut account = self
172+
.get_account_with_fixed_root_no_cache(pubkey)
173+
.unwrap_or_default();
172174

173175
if options.check_account_owner && !system_program::check_id(account.owner()) {
174176
return Err(DepositFeeError::InvalidAccountOwner);

runtime/src/bank/partitioned_epoch_rewards/calculation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl Bank {
356356
// already have been cached in cached_vote_accounts; so the code
357357
// below is only for sanity checking, and can be removed once
358358
// the cache is deemed to be reliable.
359-
let account = self.get_account_with_fixed_root(vote_pubkey)?;
359+
let account = self.get_account_with_fixed_root_no_cache(vote_pubkey)?;
360360
VoteAccount::try_from(account).ok()
361361
};
362362

@@ -485,7 +485,7 @@ impl Bank {
485485
// already have been cached in cached_vote_accounts; so the code
486486
// below is only for sanity checking, and can be removed once
487487
// the cache is deemed to be reliable.
488-
let account = self.get_account_with_fixed_root(vote_pubkey)?;
488+
let account = self.get_account_with_fixed_root_no_cache(vote_pubkey)?;
489489
VoteAccount::try_from(account).ok()
490490
};
491491

svm/src/account_loader.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@ use {
66
transaction_error_metrics::TransactionErrorMetrics,
77
transaction_processing_callback::TransactionProcessingCallback,
88
},
9-
solana_program_runtime::{
10-
compute_budget_processor::process_compute_budget_instructions,
11-
loaded_programs::ProgramCacheEntry,
12-
},
9+
solana_program_runtime::compute_budget_processor::process_compute_budget_instructions,
1310
solana_sdk::{
1411
account::{Account, AccountSharedData, ReadableAccount, WritableAccount},
1512
feature_set::{
@@ -222,7 +219,8 @@ fn load_transaction_accounts<CB: TransactionProcessingCallback>(
222219
callbacks
223220
.load_account_with(key, |account| {
224221
// only cache non program accounts
225-
!program_owners.contains(account.owner())
222+
// !program_owners.contains(account.owner())
223+
false
226224
})
227225
.map(|(mut account, _slot)| {
228226
if program_owners.contains(account.owner()) {
@@ -350,7 +348,9 @@ fn load_transaction_accounts<CB: TransactionProcessingCallback>(
350348
builtins_start_index.saturating_add(owner_index)
351349
} else {
352350
let owner_index = accounts.len();
353-
if let Some(owner_account) = callbacks.get_account_shared_data(owner_id) {
351+
if let Some((owner_account, _slot)) =
352+
callbacks.load_account_with(owner_id, |_| false)
353+
{
354354
if !native_loader::check_id(owner_account.owner())
355355
|| !owner_account.executable()
356356
{

svm/src/transaction_processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
668668
) {
669669
let mut sysvar_cache = self.sysvar_cache.write().unwrap();
670670
sysvar_cache.fill_missing_entries(|pubkey, set_sysvar| {
671-
if let Some(account) = callbacks.get_account_shared_data(pubkey) {
671+
if let Some((account, _slot)) = callbacks.load_account_with(pubkey, |_| false) {
672672
set_sysvar(account.data());
673673
}
674674
});

0 commit comments

Comments
 (0)