-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Fix program buffer account rent-exempt lamport calculation #34722
Conversation
I find this issue when working on #34691.
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #34722 +/- ##
=======================================
Coverage 81.8% 81.8%
=======================================
Files 824 824
Lines 222687 222687
=======================================
+ Hits 182245 182286 +41
+ Misses 40442 40401 -41 |
Nice find. I wonder why this wasn't an issue for people deploying programs? Is it that no one uses loader v2? |
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 to me. r+ with signoff from @Lichtso
I think people are using cli to deploy v2 programs, not load_util.rs. With cli, they would often choose the minimal rent exempt lamport. |
…35162) * Upgrade sbf tests to use bpf loader v3 (#34691) * update sbf test to use bpf_loader v2 * update test_program_sbf_invoke_sanity test * update test bpf program owner * update test_program_sbf_invoke_upgradeable_via_cpi * update test_program_sbf_disguised_as_sbf_loader * update test_program_reads_from_program_account * update test_program_sbf_program_id_spoofing * update test_program_sbf_caller_has_access_to_cpi_program * update 3 more tests * fix program buffer size in minimul for rent exempt calculation * more test updates * more update * more test updates * comments * undo c format * typo * add sol_alloc_free not deployable and deployable tests * comments * review feedback - move buffer_keypair and program_keypair inside callee fn. * more refactor * delete sof_alloc_free_syscall enabled tests * revert lamport change --------- Co-authored-by: HaoranYi <haoran.yi@solana.com> (cherry picked from commit 8869d0c) # Conflicts: # programs/sbf/tests/programs.rs * fix merge conflicts * update tests to avoid using the new test api from 1.18 * manually backport #34722 to fix a test * Ignore failing benchmark tests and fix compilation --------- Co-authored-by: HaoranYi <haoran.yi@gmail.com> Co-authored-by: HaoranYi <haoran.yi@solana.com> Co-authored-by: haoran <haoran@mbook> Co-authored-by: Stephen Akridge <sakridge@gmail.com>
Problem
When we use bpf_loader v2 to load a program, we create a buffer account to
upload the program data. However, the required minimum balance of the account
is calculated directly from the program data length, which is not the correct
length for the actual account's data. The actual accounts' data include the additional
45 bytes of metadata.
Therefore, this can result that buffer account doesn't have enough lamport to be rent
exempted and fails the transaction.
Example:
In this example, the program data is 102496 bytes, while the account's data is
102533 bytes. The lamports (714263040) on the account is calculated based on 102496, which
is not enough for 102533 bytes, and makes this account rent-paying, and failed the transaction.
Summary of Changes
Include buffer meta-data when calculating the minimal required lamports for
program buffer account.
Fixes #