Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

program-test: Prohibit setting the compute unit limit past i64::MAX #32807

Merged
merged 1 commit into from
Aug 11, 2023

Conversation

joncinque
Copy link
Contributor

Problem

As reported by users, setting u64::MAX for the max compute units in solana-program-test causes all sBPF tests to fail: https://discord.com/channels/428295358100013066/774014770402689065/1136270266436173886

This happens because the rbpf vm actually represents compute unit budget with a i64 in order to catch using too many units, so if we set anything larger than i64::MAX, the compute units becomes negative, which immediately errors.

Summary of Changes

While it may be better to change everything to use i64 and match the vm, this would allow people to set negative numbers for their program's compute units, which we'll need to properly define.

Once that work is done, we can expose a new function on solana-program-test which accepts an i64. In the meantime, add a debug assertion to help users fix the problem themselves.

Fixes #

@joncinque joncinque added the v1.16 PRs that should be backported to v1.16 label Aug 11, 2023
@joncinque joncinque requested a review from Lichtso August 11, 2023 13:11
@codecov
Copy link

codecov bot commented Aug 11, 2023

Codecov Report

Merging #32807 (8cf5d52) into master (3dcb382) will increase coverage by 0.0%.
Report is 70 commits behind head on master.
The diff coverage is 0.0%.

@@           Coverage Diff           @@
##           master   #32807   +/-   ##
=======================================
  Coverage    82.0%    82.0%           
=======================================
  Files         785      785           
  Lines      211100   211102    +2     
=======================================
+ Hits       173170   173187   +17     
+ Misses      37930    37915   -15     

@joncinque joncinque merged commit 194c959 into solana-labs:master Aug 11, 2023
@joncinque joncinque deleted the ptunits branch August 11, 2023 16:30
mergify bot pushed a commit that referenced this pull request Aug 11, 2023
…#32807)

program-test: Prohibit setting the compute unit limit past the max
(cherry picked from commit 194c959)
joncinque added a commit that referenced this pull request Aug 11, 2023
…4::MAX` (backport of #32807) (#32811)

program-test: Prohibit setting the compute unit limit past `i64::MAX` (#32807)

program-test: Prohibit setting the compute unit limit past the max
(cherry picked from commit 194c959)

Co-authored-by: Jon Cinque <me@jonc.dev>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
v1.16 PRs that should be backported to v1.16
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants