-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Record instructions which are precompiles #24743
Conversation
Would it be too hacky to do /// Convert from an InstructionTrace to InnerInstructionsList
pub fn inner_instructions_list_from_instruction_trace(
instruction_trace: &InstructionTrace,
) -> InnerInstructionsList {
instruction_trace
.iter()
.map(|inner_instructions_trace| {
inner_instructions_trace
.iter()
.skip(1)
.map(|instruction_context| { |
Do you mean moving invoke_context
.transaction_context
.push(
program_indices,
&instruction_accounts,
&instruction.data,
true,
)
.and_then(|_| invoke_context.transaction_context.pop()) into a function Or to use TransactionContext::record_instruction() in the Or, do you want to not actually record anything but sneak in fake entries in |
Yeah, this.
Good point, could we protect against this with an enum? Precompiles will always need special handling so might be worth doing something like this: pub type InstructionTrace = Vec<InstructionTraceRecord>;
pub enum InstructionTraceRecord {
Precompile { program_id: Pubkey },
ProgramInstruction(Vec<InstructionContext>),
} |
I'm just hoping we can find a way to avoid adding too much complexity.. the precompile transition has had a lot of bugs from corner cases |
The enum sounds like a lot more complexity. Keep in mind that in ABIv2 the instruction stack, trace and record are all the same thing. And it is designed to reflect the incoming message as close as possible. |
How do precompiles fit into ABIv2? |
That is actually a good question as they were not taken into account yet. |
Got it, well I suggested the enum because I'd prefer avoiding trying to make a precompile act like an instruction because it's bound to introduce bugs. Using an enum forces us to handle precompiles explicitly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. A bit hard to follow but I think when these feature gates get cleaned up in the future this should get more simplified.
runtime/src/message_processor.rs
Outdated
let is_precompile = | ||
is_precompile(program_id, |id| invoke_context.feature_set.is_active(id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you &&
this with the check that the prevent_calling_precompiles_as_programs
feature is active? Technically there are no "precompiles" unless that feature is active. We should also ensure that the usage of is_precompile
below also incorporates the feature gate check.
…` to `is_precompile`.
automerge label removed due to a CI failure |
* Record instructions which are "is_precompile". (cherry picked from commit eae9a66)
* Record instructions which are "is_precompile". (cherry picked from commit eae9a66) Co-authored-by: Alexander Meißner <[email protected]>
* Record instructions which are "is_precompile".
Problem
See #24705
Summary of Changes
Don't just skip instructions when
is_precompile
bycontinue
,instead have them be recorded in the
transaction_context
.Additionally feature gated behind
record_instruction_in_transaction_context_push
.Fixes #24705
Updates Feature Gate: #24965