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

RISC0 Rust backend #2792

Merged
merged 24 commits into from
Jun 7, 2024
Merged

RISC0 Rust backend #2792

merged 24 commits into from
Jun 7, 2024

Conversation

lukaszcz
Copy link
Collaborator

@lukaszcz lukaszcz commented May 29, 2024

  • Adds a RISC0 backend which generates Rust code that can be compiled with the official RISC0 toolchain.
  • The RISC0 backend is a wrapper around the Rust backend.
  • Adds the risc0-rust to the compile CLI command, which creates a directory containing host and guest Rust sources for the RISC0 zkVM. The generated code can be compiled/run using cargo from inside the created directory (requires having RISC0 installed: https://dev.risczero.com/api/zkvm/install).

@lukaszcz lukaszcz added this to the 0.6.2 milestone May 29, 2024
@lukaszcz lukaszcz self-assigned this May 29, 2024
@lukaszcz lukaszcz changed the title Risc0 Rust backend RISC0 Rust backend May 29, 2024
@lukaszcz lukaszcz force-pushed the rust-risc0 branch 2 times, most recently from c68eac8 to 7d9891a Compare June 4, 2024 17:38
@lukaszcz lukaszcz marked this pull request as ready for review June 5, 2024 10:26
let fs' = map (first relFile) fs
forM_ (first (outDir <//>) <$> fs') (uncurry writeFile)

writeFile :: Path Abs File -> ByteString -> Sem r ()
Copy link
Collaborator

Choose a reason for hiding this comment

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

This function seems generic enough to be defined somewhere else. Maybe in Juvix.Data.Effect.Files

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

mainFile <- getMainFile inp
invokeDir <- askInvokeDir
let baseOutputDir = invokeDir <//> filename (replaceExtension' (fileExtToString ext) mainFile)
return $ absDir $ toFilePath baseOutputDir
Copy link
Collaborator

Choose a reason for hiding this comment

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

having some helper function like pathFileToPathDir : Path b File -> path b Dir would make this more readable. The helper function can go to Juvix.Prelude.Path.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@lukaszcz lukaszcz requested a review from janmasrovira June 6, 2024 17:36
- name: Install RISC0 VM
shell: bash
run: |
cargo install cargo-binstall
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be cached? This can be done in a subsequent PR if possible.

- name: Install RISC0 VM
shell: bash
run: |
cargo install cargo-binstall
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can this be cached? This can be done in a subsequent PR if possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried caching ~/.cargo/bin/r0vm, but apparently it needs more than that. I think caching the whole ~/.cargo directory would be enough, but I'm not sure how this should interact with the caching of the Rust toolchain that's done by the "Install Rust" action.

@janmasrovira janmasrovira merged commit a4f5515 into main Jun 7, 2024
4 checks passed
@janmasrovira janmasrovira deleted the rust-risc0 branch June 7, 2024 05:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants