Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
Increase transaction account lock limit from 64 to 256
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Aug 22, 2022
1 parent f617374 commit 21b22b1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 10 deletions.
10 changes: 9 additions & 1 deletion programs/bpf_loader/src/syscalls/cpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,8 +799,16 @@ fn check_account_infos(
.feature_set
.is_active(&feature_set::loosen_cpi_size_restriction::id())
{
let max_cpi_account_infos = if invoke_context
.feature_set
.is_active(&feature_set::increase_tx_account_lock_limit::id())
{
MAX_CPI_ACCOUNT_INFOS
} else {
64
};
let num_account_infos = num_account_infos as u64;
let max_account_infos = MAX_CPI_ACCOUNT_INFOS as u64;
let max_account_infos = max_cpi_account_infos as u64;
if num_account_infos > max_account_infos {
return Err(SyscallError::MaxInstructionAccountInfosExceeded {
num_account_infos,
Expand Down
11 changes: 8 additions & 3 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3902,8 +3902,13 @@ impl Bank {
self.runtime_config.transaction_account_lock_limit
{
transaction_account_lock_limit
} else {
} else if self
.feature_set
.is_active(&feature_set::increase_tx_account_lock_limit::id())
{
MAX_TX_ACCOUNT_LOCKS
} else {
64
}
}

Expand Down Expand Up @@ -8060,7 +8065,6 @@ pub(crate) mod tests {
system_instruction::{self, SystemError, MAX_PERMITTED_DATA_LENGTH},
system_program,
timing::duration_as_s,
transaction::MAX_TX_ACCOUNT_LOCKS,
},
solana_vote_program::{
vote_instruction,
Expand Down Expand Up @@ -14283,7 +14287,8 @@ pub(crate) mod tests {
bank.last_blockhash(),
);

while tx.message.account_keys.len() <= MAX_TX_ACCOUNT_LOCKS {
let transaction_account_lock_limit = bank.get_transaction_account_lock_limit();
while tx.message.account_keys.len() <= transaction_account_lock_limit {
tx.message.account_keys.push(solana_sdk::pubkey::new_rand());
}

Expand Down
4 changes: 2 additions & 2 deletions sdk/bpf/c/inc/sol/cpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ static const uint8_t MAX_CPI_INSTRUCTION_ACCOUNTS = 255;
/**
* Maximum number of account info structs that can be used in a single CPI
* invocation. A limit on account info structs is effectively the same as
* limiting the number of unique accounts. 64 was chosen to match the max
* limiting the number of unique accounts. 256 was chosen to match the max
* number of locked accounts per transaction (MAX_TX_ACCOUNT_LOCKS).
*/
static const uint8_t MAX_CPI_ACCOUNT_INFOS = 64;
static const uint16_t MAX_CPI_ACCOUNT_INFOS = 256;

/**
* Account Meta
Expand Down
4 changes: 2 additions & 2 deletions sdk/bpf/c/inc/sol/inc/cpi.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ static const uint8_t MAX_CPI_INSTRUCTION_ACCOUNTS = 255;
/**
* Maximum number of account info structs that can be used in a single CPI
* invocation. A limit on account info structs is effectively the same as
* limiting the number of unique accounts. 64 was chosen to match the max
* limiting the number of unique accounts. 256 was chosen to match the max
* number of locked accounts per transaction (MAX_TX_ACCOUNT_LOCKS).
*/
static const uint8_t MAX_CPI_ACCOUNT_INFOS = 64;
static const uint16_t MAX_CPI_ACCOUNT_INFOS = 256;

/**
* Account Meta
Expand Down
4 changes: 2 additions & 2 deletions sdk/program/src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ pub const MAX_CPI_INSTRUCTION_ACCOUNTS: u8 = u8::MAX;

/// Maximum number of account info structs that can be used in a single CPI
/// invocation. A limit on account info structs is effectively the same as
/// limiting the number of unique accounts. 64 was chosen to match the max
/// limiting the number of unique accounts. 256 was chosen to match the max
/// number of locked accounts per transaction (MAX_TX_ACCOUNT_LOCKS).
pub const MAX_CPI_ACCOUNT_INFOS: usize = 64;
pub const MAX_CPI_ACCOUNT_INFOS: usize = 256;
5 changes: 5 additions & 0 deletions sdk/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ pub mod disable_cpi_setting_executable_and_rent_epoch {
solana_sdk::declare_id!("B9cdB55u4jQsDNsdTK525yE9dmSc5Ga7YBaBrDFvEhM9");
}

pub mod increase_tx_account_lock_limit {
solana_sdk::declare_id!("9LZdXeKGeBV6hRLdxS1rHbHoEUsKqesCC2ZAPTPKJAbK");
}

lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -622,6 +626,7 @@ lazy_static! {
(check_ping_ancestor_requests::id(), "ancestor hash repair socket ping/pong support #26963"),
(incremental_snapshot_only_incremental_hash_calculation::id(), "only hash accounts in incremental snapshot during incremental snapshot creation #26799"),
(disable_cpi_setting_executable_and_rent_epoch::id(), "disable setting is_executable and_rent_epoch in CPI #26987"),
(increase_tx_account_lock_limit::id(), "increase tx account lock limit to 256 #27241"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down

0 comments on commit 21b22b1

Please sign in to comment.