Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
HaoranYi committed Feb 26, 2024
1 parent 94cedbc commit 865029b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4638,6 +4638,7 @@ impl Bank {
account_overrides,
self.builtin_programs.iter(),
log_messages_bytes_limit,
&self.old_written_accounts,
);

let mut signature_count = 0;
Expand Down
17 changes: 17 additions & 0 deletions svm/src/account_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ pub fn load_accounts<CB: TransactionProcessingCallback>(
account_overrides: Option<&AccountOverrides>,
program_accounts: &HashMap<Pubkey, (&Pubkey, u64)>,
loaded_programs: &LoadedProgramsForTxBatch,
old_written_accounts: &RwLock<
HashMap<Pubkey, (Option<AccountSharedData>, Option<AccountHash>)>,
>,
) -> Vec<TransactionLoadResult> {
let feature_set = callbacks.get_feature_set();
txs.iter()
Expand Down Expand Up @@ -92,6 +95,7 @@ pub fn load_accounts<CB: TransactionProcessingCallback>(
account_overrides,
program_accounts,
loaded_programs,
old_written_accounts,
) {
Ok(loaded_transaction) => loaded_transaction,
Err(e) => return (Err(e), None),
Expand Down Expand Up @@ -127,6 +131,9 @@ fn load_transaction_accounts<CB: TransactionProcessingCallback>(
account_overrides: Option<&AccountOverrides>,
program_accounts: &HashMap<Pubkey, (&Pubkey, u64)>,
loaded_programs: &LoadedProgramsForTxBatch,
old_written_accounts: &RwLock<
HashMap<Pubkey, (Option<AccountSharedData>, Option<AccountHash>)>,
>,
) -> Result<LoadedTransaction> {
// NOTE: this check will never fail because `tx` is sanitized
if tx.signatures().is_empty() && fee != 0 {
Expand Down Expand Up @@ -186,6 +193,16 @@ fn load_transaction_accounts<CB: TransactionProcessingCallback>(
.get_account_shared_data(key)
.map(|mut account| {
if message.is_writable(i) {
{
// todo: find all the places this has to happen
let mut old_written_accounts =
old_written_accounts.write().unwrap();
if !old_written_accounts.contains_key(key) {
old_written_accounts
.insert(*key, (Some(account.clone()), None));
}
}

if !feature_set
.is_active(&feature_set::disable_rent_fees_collection::id())
{
Expand Down
4 changes: 4 additions & 0 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
account_overrides: Option<&AccountOverrides>,
builtin_programs: impl Iterator<Item = &'a Pubkey>,
log_messages_bytes_limit: Option<usize>,
old_written_accounts: &RwLock<
HashMap<Pubkey, (Option<AccountSharedData>, Option<AccountHash>)>,
>,
) -> LoadAndExecuteSanitizedTransactionsOutput {
let mut program_accounts_map = Self::filter_executable_program_accounts(
callbacks,
Expand All @@ -216,6 +219,7 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
account_overrides,
&program_accounts_map,
&programs_loaded_for_tx_batch.borrow(),
old_written_accounts,
);
load_time.stop();

Expand Down

0 comments on commit 865029b

Please sign in to comment.