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

use one definition of builtin program cost in runtime and banking stage #31930

Merged
merged 2 commits into from
Jun 2, 2023

Conversation

tao-stones
Copy link
Contributor

Problem

builtin programs compute units are defined in two places: runtime/src/block_cost_limits.rs and at runtime for each program. This potentially introduces inconsistency. Should define builtin program's CU at one place.

Summary of Changes

  • add pub const DEFAULT_COMPUTE_UNITS for each program,
  • update block_cost_limit to use builtin cost defined in program itself.

Fixes #

(feature::id(), COMPUTE_UNIT_TO_US_RATIO * 2),
(incinerator::id(), COMPUTE_UNIT_TO_US_RATIO * 2),
(native_loader::id(), COMPUTE_UNIT_TO_US_RATIO * 2),
(solana_sdk::stake::config::id(), COMPUTE_UNIT_TO_US_RATIO * 2),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

above four entries are not programs, ref #30639 (comment)


declare_process_instruction!(
process_instruction,
DEFAULT_COMPUTE_UNITS,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the actual changes to this, and other programs, is add and use DEFAULT_COMPUTE_UNITS instead of a number (eg 750). But the rustfmt rearranged large chunk of code.

@codecov
Copy link

codecov bot commented Jun 2, 2023

Codecov Report

Merging #31930 (9470bd1) into master (1302962) will decrease coverage by 0.1%.
The diff coverage is 76.1%.

@@            Coverage Diff            @@
##           master   #31930     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         759      759             
  Lines      207250   207243      -7     
=========================================
- Hits       169807   169790     -17     
- Misses      37443    37453     +10     

@tao-stones tao-stones requested review from Lichtso and alessandrod June 2, 2023 05:09
@tao-stones tao-stones requested a review from Lichtso June 2, 2023 13:51
@tao-stones tao-stones merged commit 10995f6 into solana-labs:master Jun 2, 2023
@tao-stones tao-stones deleted the unify-builtin-cost-def branch June 2, 2023 15:22
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.

2 participants