Skip to content

Commit

Permalink
feat: update precomiples doc
Browse files Browse the repository at this point in the history
  • Loading branch information
leruaa committed Nov 14, 2024
1 parent 7cae2a8 commit a509902
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/core/machine/src/syscall/precompiles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ 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/tests`. 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`. An example `Cargo.toml` for this may look like
```toml
[workspace]
[package]
Expand All @@ -198,8 +198,8 @@ edition = "2021"
publish = false

[dependencies]
sp1-zkvm = { path = "../../zkvm/entrypoint" }
sp1-derive = { path = "../../derive" }
sp1-zkvm = { path = "../../../../zkvm/entrypoint" }
sp1-derive = { path = "../../../../derive" }
num-bigint = "0.4.6"
rand = "0.8.5"
```
Expand All @@ -208,8 +208,7 @@ 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`.
```rust
pub const CUSTOM_PRECOMPILE_ELF: &[u8] =
include_bytes!("path/to/generated/elf/file");
pub const CUSTOM_PRECOMPILE_ELF: &[u8] = include_elf!("your-test-crate-name");
// Other ELF files...
```

Expand All @@ -230,10 +229,11 @@ mod tests {
utils::{
self,
run_test_io,
tests::CUSTOM_PRECOMPILE_ELF,
},
};

use test_artifacts::CUSTOM_PRECOMPILE_ELF;

#[test]
fn test_custom_precompile() {
utils::setup_logger();
Expand Down

0 comments on commit a509902

Please sign in to comment.