From d3cfe9cf0f275467fec56ef1498b272e4839a71f Mon Sep 17 00:00:00 2001 From: buffalu <85544055+buffalu@users.noreply.github.com> Date: Sun, 12 Nov 2023 21:04:32 -0600 Subject: [PATCH] Don't unlock accounts in TransactionBatches used during simulation (#449) --- runtime/src/bank.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 9b359c50f1..bbc780e8f0 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -3696,7 +3696,12 @@ impl Bank { let mut account_locks = AccountLocks::default(); let lock_results = Accounts::lock_accounts_sequential(&mut account_locks, tx_account_locks_results); - TransactionBatch::new(lock_results, self, Cow::Borrowed(transactions)) + let mut batch = TransactionBatch::new(lock_results, self, Cow::Borrowed(transactions)); + // this is required to ensure that accounts aren't unlocked accidentally, which can be problematic during replay. + // more specifically, during process_entries, if the lock counts are accidentally decremented, + // one might end up replaying a block incorrectly + batch.set_needs_unlock(false); + batch } /// Prepare a transaction batch without locking accounts for transaction simulation.