@@ -2,6 +2,14 @@ use solana_sdk::{
22 compute_budget:: ComputeBudgetInstruction , instruction:: Instruction ,
33} ;
44
5+ /// We multiply the CU values that we determined since we've seen compute budget exceeded errors
6+ /// if we use them as is. The only way to determine CUs for a particular transaction 100% is
7+ /// to simulate that exact transaction.
8+ /// This would make table management even slower, but is an option to consider for the future.
9+ /// The multiplier is based on the observation that [CREATE_AND_EXTEND_TABLE_CUS] were _safe_ at
10+ /// 16K-17K CUs which we slightly exceed if we multiply by this multiplier.
11+ const SAFETY_MULTIPLIER : u32 = 7 ;
12+
513/// Compute units required to create and extend a lookup table, with the initial
614/// pubkeys. This is the same no matter how many pubkeys are added to the table
715/// initially.
@@ -10,14 +18,14 @@ use solana_sdk::{
1018/// https://github.com/solana-program/address-lookup-table/blob/main/program/src/processor.rs .
1119/// This test repo (https://github.com/thlorenz/create-program-address-cus) verified
1220/// 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 ;
21+ pub const CREATE_AND_EXTEND_TABLE_CUS : u32 = ( 2_400 + 250 ) * SAFETY_MULTIPLIER ;
1422/// Compute units required to extend a lookup table with additional pubkeys
1523/// This is the same no matter how many pubkeys are added to the table.
16- pub const EXTEND_TABLE_CUS : u32 = 1_200 ;
24+ pub const EXTEND_TABLE_CUS : u32 = 1_200 * SAFETY_MULTIPLIER ;
1725/// Compute units required to deactivate a lookup table.
18- pub const DEACTIVATE_TABLE_CUS : u32 = 1_050 ;
26+ pub const DEACTIVATE_TABLE_CUS : u32 = 1_050 * SAFETY_MULTIPLIER ;
1927/// Compute units required to close a lookup table.
20- pub const CLOSE_TABLE_CUS : u32 = 1_050 ;
28+ pub const CLOSE_TABLE_CUS : u32 = 1_050 * SAFETY_MULTIPLIER ;
2129
2230#[ derive( Clone ) ]
2331pub struct TableManiaComputeBudget {
0 commit comments