Skip to content

Conversation

shariqnaiyer
Copy link
Contributor

@shariqnaiyer shariqnaiyer commented Oct 17, 2025

What was wrong?

risc0 and sp1 use unsupported targets for getrandom and cause an error in our worflow

How was it fixed?

risc0/risc0#634
https://docs.rs/getrandom/latest/getrandom/#opt-in-backends

The workaround as suggested by the above issue is to use a rust flag to tell getrandom a that custom backend will be used.

Opt-in backends can be enabled using the getrandom_backend configuration flag. The flag can be set either by specifying the rustflags field in [.cargo/config.toml](https://doc.rust-lang.org/cargo/reference/config.html):

# It's recommended to set the flag on a per-target basis:
[target.wasm32-unknown-unknown]
rustflags = ['--cfg', 'getrandom_backend="wasm_js"']

We can put in the config.toml so devs don't have to add it with environment variables.

To-Do

@shariqnaiyer shariqnaiyer marked this pull request as ready for review October 17, 2025 03:40
@shariqnaiyer shariqnaiyer requested a review from KolbyML as a code owner October 17, 2025 03:40
@shariqnaiyer shariqnaiyer changed the title fix: error with getrandom in risc0 and sp1 workflow fix: error with getrandom target in risc0 and sp1 workflow Oct 17, 2025
@shariqnaiyer shariqnaiyer changed the title fix: error with getrandom target in risc0 and sp1 workflow fix: getrandom target error in risc0 and sp1 workflow Oct 17, 2025
Copy link
Contributor

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

I don't think this is a suitable solution

Copy link
Member

@syjn99 syjn99 left a comment

Choose a reason for hiding this comment

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

Great! We might use .cargo/config.toml for applying this at all zkVM target compilation. This config.toml works for me:

[target.'cfg(target_os = "zkvm")']
rustflags = ["--cfg", "getrandom_backend=\"custom\""]

@shariqnaiyer shariqnaiyer force-pushed the fix/shariqnaiyer/get-random branch from d33b544 to 7c6739f Compare October 17, 2025 05:12
@KolbyML
Copy link
Contributor

KolbyML commented Oct 17, 2025

It looks like both of you guys didn't read this issue #857 @shariqnaiyer @syjn99

@KolbyML
Copy link
Contributor

KolbyML commented Oct 17, 2025

I will mark this PR as fixing the issue

@KolbyML
Copy link
Contributor

KolbyML commented Oct 17, 2025

@shariqnaiyer before we merge this, we should get the issues opened on hashsig/plonky3/ream first

@shariqnaiyer
Copy link
Contributor Author

shariqnaiyer commented Oct 17, 2025

The following issues were made to handle this upstream:

Ream: #862
Hash-sig: b-wagn/hash-sig#90
Plonky3: Plonky3/Plonky3#1089

Copy link
Contributor

@KolbyML KolbyML left a comment

Choose a reason for hiding this comment

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

:shipit: looks good

@KolbyML KolbyML added this pull request to the merge queue Oct 17, 2025
Merged via the queue into ReamLabs:master with commit 46d812b Oct 17, 2025
15 checks passed
@shariqnaiyer shariqnaiyer deleted the fix/shariqnaiyer/get-random branch October 18, 2025 01:53
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.

hashsig crate incompatibility prevents RISC Zero guest code compilation for ream-consensus-lean

3 participants