-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature gate builtin consumes static units during processing instruct…
…ion (#30702) * add feature gate * builtins consume statically defined units at beginning of process_instruction() * Add new instructionError; return error if builtin did not consume units to enforce builtin to consume units; * updated related tests * updated ProgramTest with deactivated native_programs_consume_cu feature to continue support existing mock/test programs that do not consume units
- Loading branch information
1 parent
5a05e9b
commit 3e500d9
Showing
20 changed files
with
204 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
use { | ||
solana_program_runtime::invoke_context::InvokeContext, | ||
solana_sdk::instruction::InstructionError, | ||
solana_sdk::{feature_set, instruction::InstructionError}, | ||
}; | ||
|
||
pub fn process_instruction(_invoke_context: &mut InvokeContext) -> Result<(), InstructionError> { | ||
pub fn process_instruction(invoke_context: &mut InvokeContext) -> Result<(), InstructionError> { | ||
// Consume compute units if feature `native_programs_consume_cu` is activated, | ||
if invoke_context | ||
.feature_set | ||
.is_active(&feature_set::native_programs_consume_cu::id()) | ||
{ | ||
invoke_context.consume_checked(150)?; | ||
} | ||
|
||
// Do nothing, compute budget instructions handled by the runtime | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.