Skip to content

Commit

Permalink
fix: feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
leruaa committed Nov 14, 2024
1 parent a509902 commit 04aa81f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions crates/core/machine/src/syscall/precompiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ pub fn default_syscall_map() -> HashMap<SyscallCode, Arc<dyn Syscall>> {

## 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"
Expand All @@ -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...
Expand Down
7 changes: 6 additions & 1 deletion crates/test-artifacts/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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");

Expand Down

0 comments on commit 04aa81f

Please sign in to comment.