Skip to content
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

Runtime: Core BPF: Add test for CPI post-migration #2531

Merged

Conversation

buffalojoec
Copy link

Problem

Our test suite for migrating builtin programs to BPF sends a transaction with an instruction for the newly migrated program, to test that it can be loaded and executed successfully. However, this test suite is missing a test for CPI'ing to this program.

Building on the back of #2483, we should have coverage for this case.

Summary of Changes

Add a mocked-out builtin processor designed to CPI to the provided program to the test suite. Then simply send a transaction to this builtin (like we're already doing with the newly migrated program) directing it to CPI to the newly migrated program.

Copy link

@CriesofCarrots CriesofCarrots left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm. I'd get @2501babe 's sign-off as well, though

@buffalojoec buffalojoec requested a review from 2501babe August 9, 2024 19:07
@buffalojoec buffalojoec added the v2.0 Backport to v2.0 branch label Aug 13, 2024
Copy link

mergify bot commented Aug 13, 2024

Backports to the beta branch are to be avoided unless absolutely necessary for fixing bugs, security issues, and perf regressions. Changes intended for backport should be structured such that a minimum effective diff can be committed separately from any refactoring, plumbing, cleanup, etc that are not strictly necessary to achieve the goal. Any of the latter should go only into master and ride the normal stabilization schedule. Exceptions include CI/metrics changes, CLI improvements and documentation updates on a case by case basis.

@2501babe
Copy link
Member

2501babe commented Aug 14, 2024

does this new test fail if you turn off your fix (ie if the builtin is not marked executable)? the check im aware of that would fail this is before control drops to invoke context, though there might be another check inside it

not that you shouldnt merge this, i think a lot more testing of transaction loading needs to take place and im brainstorming myself how to do that

@buffalojoec
Copy link
Author

buffalojoec commented Aug 14, 2024

does this new test fail if you turn off your fix (ie if the builtin is not marked executable)? the check im aware of that would fail this is before control drops to invoke context, though there might be another check inside it

Yep. Directly invoking it works, but via CPI it throws InstructionError(0, AccountNotExecutable).

Looks to me like this callsite:

if !borrowed_program_account.is_executable() {
ic_msg!(self, "Account {} is not executable", callee_program_id);
return Err(InstructionError::AccountNotExecutable);

@buffalojoec buffalojoec merged commit 8f675eb into anza-xyz:master Aug 19, 2024
42 checks passed
@buffalojoec buffalojoec deleted the core-bpf-executable-cpi-test branch August 19, 2024 20:18
mergify bot pushed a commit that referenced this pull request Aug 19, 2024
buffalojoec added a commit that referenced this pull request Aug 20, 2024
buffalojoec added a commit that referenced this pull request Aug 20, 2024
…2531) (#2665)

Runtime: Core BPF: Add test for CPI post-migration (#2531)

(cherry picked from commit 8f675eb)

Co-authored-by: Joe C <[email protected]>
ray-kast pushed a commit to abklabs/agave that referenced this pull request Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v2.0 Backport to v2.0 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants