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

STR-907 Generation of consistant verification key using datatool binary #628

Merged
merged 3 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bin/datatool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ zeroize.workspace = true
default = []
risc0 = ["strata-risc0-guest-builder", "bytemuck"]
sp1 = ["strata-sp1-guest-builder"]
sp1-docker = ["sp1", "strata-sp1-guest-builder/docker-build"]
20 changes: 17 additions & 3 deletions bin/datatool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ strata-datatool genparams \
Alternatively, instead of passing `-f`, you can pass `-E` and define either
`STRATA_SEQ_KEY` or `STRATA_OP_KEY` to pass the seed keys to the program.

## Correct Setup for VerifyingKey
To ensure the RollupParams contain the correct verifying key, you must run the binary in release mode. This is necessary because the SP1 build process requires release mode for proper functioning.
Before proceeding, make sure that you have SP1 correctly set up by following the installation instructions provided [here](https://docs.succinct.xyz/getting-started/install.html). Additionally, refer to the [common errors section](https://docs.succinct.xyz/developers/common-issues.html#c-binding-errors) here to troubleshoot any issues, especially C binding errors.
## Generating VerifyingKey
MdTeach marked this conversation as resolved.
Show resolved Hide resolved

MdTeach marked this conversation as resolved.
Show resolved Hide resolved
Before proceeding, make sure that you have SP1 correctly set up by following the installation instructions provided [here](https://docs.succinct.xyz/getting-started/install.html)

To ensure that the RollupParams contain the correct verifying key, build the binary in release mode and confirm that SP1 is set up correctly by following its installation instructions.

For production usage—since SP1 verification key generation is platform and workspace dependent—build the data tool in release mode with the sp1-docker feature:

```bash
cargo build --bin strata-datatool -F "sp1-docker" --release
```

Because building the guest code in Docker can be time-consuming, you can generate the verification key locally for testing or development using:

```bash
cargo build --bin strata-datatool -F "sp1" --release
```
3 changes: 2 additions & 1 deletion provers/sp1/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ strata-sp1-adapter = { path = "../../crates/zkvm/adapters/sp1", features = [
bincode.workspace = true
cargo_metadata = "0.19.1"
sha2.workspace = true
sp1-helper = "4.0.0"
sp1-helper = { git = "https://github.com/succinctlabs/sp1.git", rev = "6c5a7f2846cd3610ecd38b1641f0e370fd07ee83" }
sp1-sdk = "4.0.0"

[features]
default = ["prover"]
mock = []
prover = ["strata-sp1-adapter"]
docker-build = []
18 changes: 13 additions & 5 deletions provers/sp1/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,11 @@ fn ensure_cache_validity(program: &str) -> Result<SP1VerifyingKey, String> {
/// Generates the ELF contents and VK hash for a given program.
#[cfg(not(debug_assertions))]
fn generate_elf_contents_and_vk_hash(program: &str) -> ([u32; 8], String) {
let features = {
let mut build_args = BuildArgs {
..Default::default()
};

build_args.features = {
#[cfg(feature = "mock")]
{
vec!["mock".to_string()]
Expand All @@ -235,10 +239,14 @@ fn generate_elf_contents_and_vk_hash(program: &str) -> ([u32; 8], String) {
}
};

let build_args = BuildArgs {
features,
..Default::default()
};
// In the Docker build, override the guest program’s Cargo workspace root with the Strata
// workspace root so Docker mounts the entire Strata workspace, enabling the guest program
// to import Strata crates relatively.
#[cfg(feature = "docker-build")]
{
build_args.docker = true;
build_args.workspace_directory = Some("../../..".to_owned());
MdTeach marked this conversation as resolved.
Show resolved Hide resolved
}

// Build the program with the specified arguments
// Note: SP1_v4's build_programs_with_args does not handle ELF migration
Expand Down
53 changes: 31 additions & 22 deletions provers/sp1/guest-btc-blockspace/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading