From 029f7b1d56e60ab3df7e90ec87490a0d6cf07d38 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Fri, 28 Jul 2023 14:10:43 +0700 Subject: [PATCH] BorrowedAccount: reserve() doesn't need to check for can_data_be_changed() (#32642) reserve() only changes the capacity of the vector that holds the account data, it doesn't modify the account in any way --- sdk/src/transaction_context.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sdk/src/transaction_context.rs b/sdk/src/transaction_context.rs index 8e8247bdb..21e8d2080 100644 --- a/sdk/src/transaction_context.rs +++ b/sdk/src/transaction_context.rs @@ -964,7 +964,10 @@ impl<'a> BorrowedAccount<'a> { /// in the given account. Does nothing if capacity is already sufficient. #[cfg(not(target_os = "solana"))] pub fn reserve(&mut self, additional: usize) -> Result<(), InstructionError> { - self.can_data_be_changed()?; + // Note that we don't need to call can_data_be_changed() here nor + // touch() the account. reserve() only changes the capacity of the + // memory that holds the account but it doesn't actually change content + // nor length of the account. self.make_data_mut(); self.account.reserve(additional);