diff --git a/program-runtime/src/invoke_context.rs b/program-runtime/src/invoke_context.rs index fc39f1de78b39c..08ea807556e46f 100644 --- a/program-runtime/src/invoke_context.rs +++ b/program-runtime/src/invoke_context.rs @@ -773,15 +773,13 @@ impl<'a> InvokeContext<'a> { let post_remaining_units = self.get_remaining(); *compute_units_consumed = pre_remaining_units.saturating_sub(post_remaining_units); - // startign from feature `native_programs_consume_cu`, all builtin programs should consume - // compute unitsi, otherwise will result to InstructionError. if is_builtin_program && *compute_units_consumed == 0 && self .feature_set .is_active(&native_programs_consume_cu::id()) { - return Err(InstructionError::BuiltinProgramsMustConsumeUnits); + return Err(InstructionError::BuiltinProgramsMustConsumeComputeUnits); } process_executable_chain_time.stop(); diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index 1affa7b5d82936..6062a9e1d6e46a 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -465,8 +465,8 @@ impl Default for ProgramTest { // deactivate feature `native_program_consume_cu` to continue support existing mock/test // programs that do not consume units. - let mut deactivate_feature_set = HashSet::default(); - deactivate_feature_set.insert(solana_sdk::feature_set::native_programs_consume_cu::id()); + let deactivate_feature_set = + HashSet::from([solana_sdk::feature_set::native_programs_consume_cu::id()]); Self { accounts: vec![], diff --git a/programs/sbf/tests/programs.rs b/programs/sbf/tests/programs.rs index 41fe40e2136f7a..2d137ad4adc6ca 100644 --- a/programs/sbf/tests/programs.rs +++ b/programs/sbf/tests/programs.rs @@ -2181,18 +2181,17 @@ fn test_program_sbf_disguised_as_sbf_loader() { for program in programs.iter() { let GenesisConfigInfo { - mut genesis_config, + genesis_config, mint_keypair, .. } = create_genesis_config(50); - // disable native_programs_consume_cu feature to allow test program - // not consume units. - genesis_config - .accounts - .remove(&solana_sdk::feature_set::native_programs_consume_cu::id()) - .unwrap(); let mut bank = Bank::new_for_tests(&genesis_config); + // disable native_programs_consume_cu feature to allow test program + // not consume units. + let mut feature_set = FeatureSet::all_enabled(); + feature_set.deactivate(&solana_sdk::feature_set::native_programs_consume_cu::id()); + bank.feature_set = Arc::new(feature_set); let (name, id, entrypoint) = solana_bpf_loader_program!(); bank.add_builtin(&name, &id, entrypoint); bank.deactivate_feature( diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 4e29fd44303200..ece48700ad208c 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -282,7 +282,7 @@ impl RentDebits { } pub type BankStatusCache = StatusCache>; -#[frozen_abi(digest = "FT6XYtzchg9h2JACEKKf8FZD5skSnPzKY4YrJ1jUWr8U")] +#[frozen_abi(digest = "GBTLfFjModD9ykS9LV4pGi4S8eCrUj2JjWSDQLf8tMwV")] pub type BankSlotDelta = SlotDelta>; // Eager rent collection repeats in cyclic manner. diff --git a/sdk/program/src/instruction.rs b/sdk/program/src/instruction.rs index 56e66ed269b68e..7a5516d25bc4e0 100644 --- a/sdk/program/src/instruction.rs +++ b/sdk/program/src/instruction.rs @@ -263,7 +263,7 @@ pub enum InstructionError { /// Builtin programs must consume compute units #[error("Builtin programs must consume compute units")] - BuiltinProgramsMustConsumeUnits, + BuiltinProgramsMustConsumeComputeUnits, // Note: For any new error added here an equivalent ProgramError and its // conversions must also be added } diff --git a/sdk/program/src/program_error.rs b/sdk/program/src/program_error.rs index 126143dbcc5a6a..8644b6ad78dd5e 100644 --- a/sdk/program/src/program_error.rs +++ b/sdk/program/src/program_error.rs @@ -58,7 +58,7 @@ pub enum ProgramError { #[error("Instruction trace length exceeded the maximum allowed per transaction")] MaxInstructionTraceLengthExceeded, #[error("Builtin programs must consume compute units")] - BuiltinProgramsMustConsumeUnits, + BuiltinProgramsMustConsumeComputeUnits, } pub trait PrintProgramError { @@ -104,8 +104,8 @@ impl PrintProgramError for ProgramError { Self::MaxInstructionTraceLengthExceeded => { msg!("Error: MaxInstructionTraceLengthExceeded") } - Self::BuiltinProgramsMustConsumeUnits => { - msg!("Error: BuiltinProgramsMustConsumeUnits") + Self::BuiltinProgramsMustConsumeComputeUnits => { + msg!("Error: BuiltinProgramsMustConsumeComputeUnits") } } } @@ -140,7 +140,7 @@ pub const ILLEGAL_OWNER: u64 = to_builtin!(18); pub const MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED: u64 = to_builtin!(19); pub const INVALID_ACCOUNT_DATA_REALLOC: u64 = to_builtin!(20); pub const MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED: u64 = to_builtin!(21); -pub const BUILTIN_PROGRAMS_MUST_CONSUME_UNITS: u64 = to_builtin!(22); +pub const BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS: u64 = to_builtin!(22); // Warning: Any new program errors added here must also be: // - Added to the below conversions // - Added as an equivalent to InstructionError @@ -174,7 +174,9 @@ impl From for u64 { ProgramError::MaxInstructionTraceLengthExceeded => { MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED } - ProgramError::BuiltinProgramsMustConsumeUnits => BUILTIN_PROGRAMS_MUST_CONSUME_UNITS, + ProgramError::BuiltinProgramsMustConsumeComputeUnits => { + BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS + } ProgramError::Custom(error) => { if error == 0 { CUSTOM_ZERO @@ -210,7 +212,9 @@ impl From for ProgramError { MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED => Self::MaxAccountsDataAllocationsExceeded, INVALID_ACCOUNT_DATA_REALLOC => Self::InvalidRealloc, MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED => Self::MaxInstructionTraceLengthExceeded, - BUILTIN_PROGRAMS_MUST_CONSUME_UNITS => Self::BuiltinProgramsMustConsumeUnits, + BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS => { + Self::BuiltinProgramsMustConsumeComputeUnits + } _ => Self::Custom(error as u32), } } @@ -246,8 +250,8 @@ impl TryFrom for ProgramError { Self::Error::MaxInstructionTraceLengthExceeded => { Ok(Self::MaxInstructionTraceLengthExceeded) } - Self::Error::BuiltinProgramsMustConsumeUnits => { - Ok(Self::BuiltinProgramsMustConsumeUnits) + Self::Error::BuiltinProgramsMustConsumeComputeUnits => { + Ok(Self::BuiltinProgramsMustConsumeComputeUnits) } _ => Err(error), } @@ -282,7 +286,9 @@ where MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED => Self::MaxAccountsDataAllocationsExceeded, INVALID_ACCOUNT_DATA_REALLOC => Self::InvalidRealloc, MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED => Self::MaxInstructionTraceLengthExceeded, - BUILTIN_PROGRAMS_MUST_CONSUME_UNITS => Self::BuiltinProgramsMustConsumeUnits, + BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS => { + Self::BuiltinProgramsMustConsumeComputeUnits + } _ => { // A valid custom error has no bits set in the upper 32 if error >> BUILTIN_BIT_SHIFT == 0 { diff --git a/storage-proto/proto/transaction_by_addr.proto b/storage-proto/proto/transaction_by_addr.proto index bcba73795c8b3f..375b6d189ae204 100644 --- a/storage-proto/proto/transaction_by_addr.proto +++ b/storage-proto/proto/transaction_by_addr.proto @@ -125,7 +125,7 @@ enum InstructionErrorType { MAX_ACCOUNTS_DATA_ALLOCATIONS_EXCEEDED = 50; MAX_ACCOUNTS_EXCEEDED = 51; MAX_INSTRUCTION_TRACE_LENGTH_EXCEEDED = 52; - BUILTIN_PROGRAMS_MUST_CONSUME_UNITS = 53; + BUILTIN_PROGRAMS_MUST_CONSUME_COMPUTE_UNITS = 53; } message UnixTimestamp { diff --git a/storage-proto/src/convert.rs b/storage-proto/src/convert.rs index 1255f40902d007..44c332051fc71e 100644 --- a/storage-proto/src/convert.rs +++ b/storage-proto/src/convert.rs @@ -745,7 +745,7 @@ impl TryFrom for TransactionError { 50 => InstructionError::MaxAccountsDataAllocationsExceeded, 51 => InstructionError::MaxAccountsExceeded, 52 => InstructionError::MaxInstructionTraceLengthExceeded, - 53 => InstructionError::BuiltinProgramsMustConsumeUnits, + 53 => InstructionError::BuiltinProgramsMustConsumeComputeUnits, _ => return Err("Invalid InstructionError"), }; @@ -1076,8 +1076,8 @@ impl From for tx_by_addr::TransactionError { InstructionError::MaxInstructionTraceLengthExceeded => { tx_by_addr::InstructionErrorType::MaxInstructionTraceLengthExceeded } - InstructionError::BuiltinProgramsMustConsumeUnits => { - tx_by_addr::InstructionErrorType::BuiltinProgramsMustConsumeUnits + InstructionError::BuiltinProgramsMustConsumeComputeUnits => { + tx_by_addr::InstructionErrorType::BuiltinProgramsMustConsumeComputeUnits } } as i32, custom: match instruction_error {