Skip to content

Commit 6ccfebf

Browse files
authored
chore: increase compute budget for table mania create lookup table (#450)
## Summary Increased the compute budget for creating lookup tables in table mania from 2,400 to 2,650 compute units to account for variation in PDA derivation costs. ## Detail The create lookup table instruction includes PDA derivation which can vary in compute unit consumption by approximately 25 CUs. To ensure we don't run out of compute units due to this variation, we've added a safety buffer of 250 CUs (10x the observed variation). Changes made: - Updated `CREATE_AND_EXTEND_TABLE_CUS` constant from 2,400 to 2,650 CUs - Added detailed documentation explaining the reasoning and referencing test data - Modified integration test to use `assert!` instead of `assert_eq!` to allow for CU variation below the budgeted amount The 250 CU buffer ensures reliable execution while maintaining efficiency, as verified by test repository data showing PDA derivation variation around 25 CUs. See this repo to see how we determined the variation: https://github.com/thlorenz/create-program-address-cus This code is relevant to know it's only needed for create instructions: https://github.com/solana-program/address-lookup-table/blob/main/program/src/processor.rs
1 parent c24571a commit 6ccfebf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

magicblock-table-mania/src/compute_budget.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ use solana_sdk::{
55
/// Compute units required to create and extend a lookup table, with the initial
66
/// pubkeys. This is the same no matter how many pubkeys are added to the table
77
/// initially.
8-
pub const CREATE_AND_EXTEND_TABLE_CUS: u32 = 2_400;
8+
/// The added 250 ensure we don't run out of CUs due to variation in the PDA derivation.
9+
/// Only the create table instruction has one, see
10+
/// https://github.com/solana-program/address-lookup-table/blob/main/program/src/processor.rs .
11+
/// This test repo (https://github.com/thlorenz/create-program-address-cus) verified
12+
/// that the variation is around 25 CUs, but to be on the safe side we add 10x that.
13+
pub const CREATE_AND_EXTEND_TABLE_CUS: u32 = 2_400 + 250;
914
/// Compute units required to extend a lookup table with additional pubkeys
1015
/// This is the same no matter how many pubkeys are added to the table.
1116
pub const EXTEND_TABLE_CUS: u32 = 1_200;

test-integration/test-table-mania/tests/ix_lookup_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ async fn test_lookup_table_ixs_cus_per_pubkey() {
250250
let cus = get_tx_cus(&rpc_client, &init_sig).await;
251251

252252
debug!("Create for {i:03} {cus:04}CUs");
253-
assert_eq!(cus, CREATE_AND_EXTEND_TABLE_CUS as u64);
253+
assert!(cus <= CREATE_AND_EXTEND_TABLE_CUS as u64);
254254

255255
lookup_table
256256
.extend(

0 commit comments

Comments
 (0)