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

fix sbf sysvar test #32803

Merged
merged 2 commits into from
Aug 21, 2023
Merged

fix sbf sysvar test #32803

merged 2 commits into from
Aug 21, 2023

Conversation

HaoranYi
Copy link
Contributor

Problem

when running sbf program, sbf loader will use runtime sysvar cache to load
sysvar. Therefore, the program will return unsupported sysvar error if the
sysvar doesn't exist in the cache. For normal sysvar, this is not a problem
because the sysvar always exists for every bank. However, for epoch_rewards
sysvar, the situation is different. epoch_rewards sysvar only exists during
the epoch reward period. Therefore, the current program_test framework, by
default, doesn't support epoch_rewards sysvar.

Summary of Changes

  1. add api in program_test to allow mock sysvar.
  2. mock epoch rewards sysvar for sbf tests

Fixes #

@codecov
Copy link

codecov bot commented Aug 11, 2023

Codecov Report

Merging #32803 (e920a84) into master (eae455c) will increase coverage by 0.0%.
Report is 5 commits behind head on master.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master   #32803   +/-   ##
=======================================
  Coverage    82.0%    82.0%           
=======================================
  Files         785      785           
  Lines      211736   211736           
=======================================
+ Hits       173643   173657   +14     
+ Misses      38093    38079   -14     

@HaoranYi
Copy link
Contributor Author

HaoranYi commented Aug 11, 2023

Test passed.

running 1 test

[2023-08-11T13:47:11.332237931Z INFO  solana_program_test] "solana_sbf_rust_sysvar" SBF program from /var/lib/buildkite-agent/builds/ci24/solana-labs/solana/programs/sbf/target/deploy/solana_sbf_rust_sysvar.so, modified 21 seconds, 412 ms, 888 µs and 772 ns ago

[2023-08-11T13:47:11.374448448Z DEBUG solana_runtime::message_processor::stable_log] Program 1111111QLbz7JHiBTspS962RLKV8GndWFwiEaqKM invoke [1]

[2023-08-11T13:47:11.376672883Z DEBUG solana_runtime::message_processor::stable_log] Program log: Clock identifier:

[2023-08-11T13:47:11.376707519Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarC1ock11111111111111111111111111111111

[2023-08-11T13:47:11.376747836Z DEBUG solana_runtime::message_processor::stable_log] Program log: EpochSchedule identifier:

[2023-08-11T13:47:11.376774326Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarEpochSchedu1e111111111111111111111111

[2023-08-11T13:47:11.376809142Z DEBUG solana_runtime::message_processor::stable_log] Program log: Instructions identifier:

[2023-08-11T13:47:11.376835252Z DEBUG solana_runtime::message_processor::stable_log] Program log: Sysvar1nstructions1111111111111111111111111

[2023-08-11T13:47:11.377070769Z DEBUG solana_runtime::message_processor::stable_log] Program log: RecentBlockhashes identifier:

[2023-08-11T13:47:11.377095155Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarRecentB1ockHashes11111111111111111111

[2023-08-11T13:47:11.377268725Z DEBUG solana_runtime::message_processor::stable_log] Program log: Rent identifier:

[2023-08-11T13:47:11.377291759Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarRent111111111111111111111111111111111

[2023-08-11T13:47:11.377321265Z DEBUG solana_runtime::message_processor::stable_log] Program log: SlotHashes identifier:

[2023-08-11T13:47:11.377348356Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarS1otHashes111111111111111111111111111

[2023-08-11T13:47:11.377361742Z DEBUG solana_runtime::message_processor::stable_log] Program log: SlotHistory identifier:

[2023-08-11T13:47:11.377389524Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarS1otHistory11111111111111111111111111

[2023-08-11T13:47:11.377404864Z DEBUG solana_runtime::message_processor::stable_log] Program log: StakeHistory identifier:

[2023-08-11T13:47:11.377433899Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarStakeHistory1111111111111111111111111

[2023-08-11T13:47:11.377458836Z DEBUG solana_runtime::message_processor::stable_log] Program log: EpochRewards identifier:

[2023-08-11T13:47:11.377486218Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarEpochRewards1111111111111111111111111

[2023-08-11T13:47:11.377545160Z DEBUG solana_runtime::message_processor::stable_log] Program 1111111QLbz7JHiBTspS962RLKV8GndWFwiEaqKM consumed 11240 of 200000 compute units

[2023-08-11T13:47:11.377595436Z DEBUG solana_runtime::message_processor::stable_log] Program 1111111QLbz7JHiBTspS962RLKV8GndWFwiEaqKM success

[2023-08-11T13:47:11.378440992Z INFO  solana_program_test] "solana_sbf_rust_sysvar" SBF program from /var/lib/buildkite-agent/builds/ci24/solana-labs/solana/programs/sbf/target/deploy/solana_sbf_rust_sysvar.so, modified 21 seconds, 459 ms, 107 µs and 823 ns ago

[2023-08-11T13:47:11.416126254Z DEBUG solana_runtime::message_processor::stable_log] Program 1111111QLbz7JHiBTspS962RLKV8GndWFwiEaqKM invoke [1]

[2023-08-11T13:47:11.418309982Z DEBUG solana_runtime::message_processor::stable_log] Program log: Clock identifier:

[2023-08-11T13:47:11.418342634Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarC1ock11111111111111111111111111111111

[2023-08-11T13:47:11.418387048Z DEBUG solana_runtime::message_processor::stable_log] Program log: EpochSchedule identifier:

[2023-08-11T13:47:11.418427194Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarEpochSchedu1e111111111111111111111111

[2023-08-11T13:47:11.418470727Z DEBUG solana_runtime::message_processor::stable_log] Program log: Instructions identifier:

[2023-08-11T13:47:11.418510753Z DEBUG solana_runtime::message_processor::stable_log] Program log: Sysvar1nstructions1111111111111111111111111

[2023-08-11T13:47:11.418800173Z DEBUG solana_runtime::message_processor::stable_log] Program log: RecentBlockhashes identifier:

[2023-08-11T13:47:11.418830500Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarRecentB1ockHashes11111111111111111111

[2023-08-11T13:47:11.418992699Z DEBUG solana_runtime::message_processor::stable_log] Program log: Rent identifier:

[2023-08-11T13:47:11.419013688Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarRent111111111111111111111111111111111

[2023-08-11T13:47:11.419036321Z DEBUG solana_runtime::message_processor::stable_log] Program log: SlotHashes identifier:

[2023-08-11T13:47:11.419057001Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarS1otHashes111111111111111111111111111

[2023-08-11T13:47:11.419066419Z DEBUG solana_runtime::message_processor::stable_log] Program log: SlotHistory identifier:

[2023-08-11T13:47:11.419085765Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarS1otHistory11111111111111111111111111

[2023-08-11T13:47:11.419095594Z DEBUG solana_runtime::message_processor::stable_log] Program log: StakeHistory identifier:

[2023-08-11T13:47:11.419115802Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarStakeHistory1111111111111111111111111

[2023-08-11T13:47:11.419132534Z DEBUG solana_runtime::message_processor::stable_log] Program log: Fee identifier:

[2023-08-11T13:47:11.419152943Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarFees111111111111111111111111111111111

[2023-08-11T13:47:11.419171518Z DEBUG solana_runtime::message_processor::stable_log] Program log: EpochRewards identifier:

[2023-08-11T13:47:11.419192157Z DEBUG solana_runtime::message_processor::stable_log] Program log: SysvarEpochRewards1111111111111111111111111

[2023-08-11T13:47:11.419237834Z DEBUG solana_runtime::message_processor::stable_log] Program 1111111QLbz7JHiBTspS962RLKV8GndWFwiEaqKM consumed 11689 of 200000 compute units

[2023-08-11T13:47:11.419273211Z DEBUG solana_runtime::message_processor::stable_log] Program 1111111QLbz7JHiBTspS962RLKV8GndWFwiEaqKM success

test test_sysvars ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.10s

Copy link
Contributor

@alessandrod alessandrod left a comment

Choose a reason for hiding this comment

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

lgtm. It looks like the no-rewards logic is tested in get_epoch_rewards_sysvar so that's covered too

@t-nelson
Copy link
Contributor

@HaoranYi can this be merged?

@t-nelson
Copy link
Contributor

yolo

@t-nelson t-nelson merged commit 910b0f5 into solana-labs:master Aug 21, 2023
4 checks passed
wen-coding pushed a commit to wen-coding/solana that referenced this pull request Aug 21, 2023
* fix sbf sysvar test

* typo

---------

Co-authored-by: HaoranYi <[email protected]>
@HaoranYi
Copy link
Contributor Author

Thanks for merging it.

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.

3 participants