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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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/1136270266436173886This 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 thani64::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 ani64
. In the meantime, add a debug assertion to help users fix the problem themselves.Fixes #