From 04aa81f816960b22b5b05d1e9f794a8bcf800df5 Mon Sep 17 00:00:00 2001 From: leruaa Date: Thu, 14 Nov 2024 14:30:30 -0800 Subject: [PATCH] fix: feedbacks --- .github/workflows/pr.yml | 2 +- crates/core/machine/src/syscall/precompiles/README.md | 10 +++++----- crates/test-artifacts/src/lib.rs | 7 ++++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 703eb9bef8..be3f32b2ca 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -128,7 +128,7 @@ jobs: env: CARGO_INCREMENTAL: 1 - - name: Build test-artifacts + - name: Check test-artifacts uses: actions-rs/cargo@v1 with: command: check diff --git a/crates/core/machine/src/syscall/precompiles/README.md b/crates/core/machine/src/syscall/precompiles/README.md index 1369775633..a6d26bd3fe 100644 --- a/crates/core/machine/src/syscall/precompiles/README.md +++ b/crates/core/machine/src/syscall/precompiles/README.md @@ -188,9 +188,9 @@ pub fn default_syscall_map() -> HashMap> { ## Write Unit Tests for the New Precompile ### Create a New SP1 Test Package -Create a new SP1 crate for your custom precompile test package inside the directory `sp1/crates/test-artifacts`. An example `Cargo.toml` for this may look like +Create a new SP1 crate for your custom precompile test package inside the directory +`sp1/crates/test-artifacts/programs`. An example `Cargo.toml` for this may look like: ```toml -[workspace] [package] name = "custom-precompile-test" version = "1.0.0" @@ -203,10 +203,10 @@ sp1-derive = { path = "../../../../derive" } num-bigint = "0.4.6" rand = "0.8.5" ``` -Then implement the tests and run `cargo prove build` to generate an ELF file. +Don't forget to include your crate to the workspace at `crates/test-artifacts/programs/Cargo.toml`. Then implement the tests and run `cargo prove build` to generate an ELF file. -### Include the ELF File in `program.rs` -In your main SP1 project, include the generated ELF file by updating `program.rs`. +### Include the ELF File in `test-artifacts` crate `lib.rs` +In your main SP1 project, include the generated ELF file by updating `crates/test-artifacts/src/lib.rs`. ```rust pub const CUSTOM_PRECOMPILE_ELF: &[u8] = include_elf!("your-test-crate-name"); // Other ELF files... diff --git a/crates/test-artifacts/src/lib.rs b/crates/test-artifacts/src/lib.rs index a17f86477a..8707526193 100644 --- a/crates/test-artifacts/src/lib.rs +++ b/crates/test-artifacts/src/lib.rs @@ -1,7 +1,12 @@ #![warn(clippy::pedantic)] +//! This crate goal is to compile all programs in the `programs` folders to ELFs files, +//! and give an easy access to these ELFs from other crates, using the constants below. +//! +//! **Note:** If you added a new program, don't forget to add it to the workspace in the +//! `programs` folder to have if compiled to an ELF file. + use sp1_build::include_elf; -/// Compiled test programs. TODO elaborate. pub const FIBONACCI_ELF: &[u8] = include_elf!("fibonacci-program-tests");