fix: pass real ELF to SP1 mock prover in property tests#7
Closed
fix: pass real ELF to SP1 mock prover in property tests#7
Conversation
Both proptest cases in crates/prover/tests/property.rs were passing &[] as the ELF argument to run_historical_avg_program, causing the SP1 SDK to fail when attempting to disassemble an empty byte slice. Fix: introduce a OnceLock<Vec<u8>> that loads the pre-built ELF once via build_sp1_program(HISTORICAL_AVG_ELF_PATH) and expose it through a historical_avg_elf() helper. Both failing test cases now pass the real ELF bytes. Agent-Logs-Url: https://github.com/bit2swaz/sonar/sessions/64dea247-0607-400d-81f0-d9621ac2ca7c Co-authored-by: bit2swaz <209277869+bit2swaz@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
bit2swaz
April 7, 2026 13:16
View session
There was a problem hiding this comment.
Pull request overview
Fixes failing SP1 property tests by ensuring the mock prover is initialized with a real ELF bytecode blob instead of an empty slice (which causes prover.setup() to fail when reading the ELF header).
Changes:
- Import
HISTORICAL_AVG_ELF_PATHandbuild_sp1_programinto the property tests. - Add a lazily-initialized, cached
OnceLock<Vec<u8>>to load the historical-avg ELF once for the whole test process. - Update both proptest cases to call
run_historical_avg_program(historical_avg_elf(), ...)instead ofrun_historical_avg_program(&[], ...).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bit2swaz
approved these changes
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Both proptest cases in
crates/prover/tests/property.rswere callingrun_historical_avg_program(&[], ...)— passing an empty byte slice as the ELF. The SP1 SDK'sprover.setup()attempts to read ELF header bytes at[0x0, 0x10)and immediately fails on an empty slice, causing every property test iteration to error withfailed to disassemble program: Could not read bytes in range [0x0, 0x10).Changes
crates/prover/tests/property.rsbuild_sp1_programandHISTORICAL_AVG_ELF_PATH(already used the same way inlib.rstests andprove())static HISTORICAL_AVG_ELF: OnceLock<Vec<u8>>initialized lazily viabuild_sp1_program(HISTORICAL_AVG_ELF_PATH), exposed through ahistorical_avg_elf()helper&[]withhistorical_avg_elf()in both affected proptest casesThe pre-built ELF (
programs/historical_avg/elf/historical-avg-program) is already committed; no build step changes are needed.