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

CPI: improve test coverage #31986

Merged
merged 10 commits into from
Sep 5, 2023

Conversation

alessandrod
Copy link
Contributor

@alessandrod alessandrod commented Jun 6, 2023

This adds a number of tests and checks the behavior with direct mapping on and off.

@alessandrod alessandrod force-pushed the dm-cpi-memory-perms branch 2 times, most recently from df1c36b to c6a8b29 Compare June 6, 2023 13:49
@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Merging #31986 (bde85d6) into master (8970a37) will decrease coverage by 0.1%.
The diff coverage is 64.6%.

❗ Current head bde85d6 differs from pull request most recent head abc693a. Consider uploading reports for the commit abc693a to get more accurate results

@@            Coverage Diff            @@
##           master   #31986     +/-   ##
=========================================
- Coverage    82.0%    82.0%   -0.1%     
=========================================
  Files         784      784             
  Lines      212534   212755    +221     
=========================================
+ Hits       174341   174460    +119     
- Misses      38193    38295    +102     

@ryoqun ryoqun self-requested a review June 7, 2023 05:43
@ryoqun ryoqun added the v1.16 PRs that should be backported to v1.16 label Jun 7, 2023
@@ -3933,3 +3933,98 @@ fn test_program_sbf_inner_instruction_alignment_checks() {
let result = bank_client.send_and_confirm_instruction(&mint_keypair, instruction.clone());
assert!(result.is_ok());
}

#[test]
Copy link
Member

Choose a reason for hiding this comment

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

these test looks nice. if it's not too much trouble, how about backporting only these tests to v1.14? after all our test coverage isn't that good, esp for error/edge cases. I think these tests should have existed way before direct mapping...

@alessandrod alessandrod force-pushed the dm-cpi-memory-perms branch 6 times, most recently from b00ef5c to fa28958 Compare June 20, 2023 10:21
@alessandrod
Copy link
Contributor Author

Ok this is now ready for another round of reviews:

  • I've locked down all AccountInfo pointers. In theory I could remove account info parsing entirely for direct mapping, but in the interest of not having the diff get unnecessarily larger I'm planning to do that only in master later.
  • I've tweaked the serialization code to split realloc padding in its own region so we can set permissions more granularly
  • I've changed the way CallerAccount::serialized_data is set (or rather not set) when direct mapping is enabled

The diff has grown kinda large, but it's mostly new tests for edge conditions that weren't tested before. I've found some other unrelated, not direct mapping related bugs that I'm going to fix separately

@alessandrod alessandrod requested review from ryoqun and Lichtso June 20, 2023 10:28
programs/bpf_loader/src/serialization.rs Outdated Show resolved Hide resolved
programs/bpf_loader/src/lib.rs Outdated Show resolved Hide resolved
programs/bpf_loader/src/serialization.rs Outdated Show resolved Hide resolved
@alessandrod
Copy link
Contributor Author

alessandrod commented Jun 20, 2023

Note to self: this still needs a test for a builtin program that uses AccountSharedData directly to change the backing storage of an account, and a test and fix for ref_to_len_in_vm in the same vein as serialized_data

Done

@alessandrod alessandrod force-pushed the dm-cpi-memory-perms branch 2 times, most recently from cb7833b to eca410e Compare June 25, 2023 06:28
@alessandrod alessandrod added the work in progress This isn't quite right yet label Jun 27, 2023
@alessandrod alessandrod force-pushed the dm-cpi-memory-perms branch 2 times, most recently from ad813b7 to ed1f9f4 Compare July 7, 2023 15:01
@alessandrod alessandrod force-pushed the dm-cpi-memory-perms branch 3 times, most recently from 8a79403 to 291e0a0 Compare July 18, 2023 02:24
@alessandrod
Copy link
Contributor Author

Alright this is now ready for another round of reviews! I actually have a couple more tests that I want to add, but they aren't around known issues they're just for coverage, so no reason to delay this. Ideally I want to land and enable in testnet asap.

@alessandrod alessandrod removed the work in progress This isn't quite right yet label Jul 18, 2023
@ryoqun ryoqun self-requested a review August 29, 2023 04:51
@ryoqun
Copy link
Member

ryoqun commented Aug 29, 2023

seems stable-sbf is failing in CI..

@alessandrod alessandrod force-pushed the dm-cpi-memory-perms branch 3 times, most recently from 9ec1798 to c0cb53e Compare August 29, 2023 11:11
@alessandrod
Copy link
Contributor Author

seems stable-sbf is failing in CI..

fixed, a test had to be updated after the ref_to_len_in_vm >= MM_INPUT_START check

ryoqun
ryoqun previously approved these changes Aug 29, 2023
Copy link
Member

@ryoqun ryoqun left a comment

Choose a reason for hiding this comment

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

lgtm with nits.

really thanks for the hard work.

@alessandrod alessandrod changed the title direct mapping: update memory permissions after CPI CPI: improve test coverage Sep 5, 2023
@alessandrod alessandrod merged commit 6679153 into solana-labs:master Sep 5, 2023
@yihau
Copy link
Member

yihau commented Sep 5, 2023

hey! it seems that this one broke master CI after merged 😢

Screenshot 2023-09-05 at 3 56 51 PM

https://buildkite.com/solana-labs/solana/builds/101262#018a643d-750f-4021-b395-4188ff9a982d

@alessandrod
Copy link
Contributor Author

oops, fixing!

behzadnouri added a commit to behzadnouri/solana that referenced this pull request Sep 5, 2023
behzadnouri added a commit to behzadnouri/solana that referenced this pull request Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants