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

chore: examples/tests folder refactor #234

Merged
merged 1 commit into from
Feb 14, 2024
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
50 changes: 34 additions & 16 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,40 @@
],
"rust-analyzer.linkedProjects": [
"Cargo.toml",
"programs/test/cycle-tracker/Cargo.toml",
"programs/test/ed-add/Cargo.toml",
"programs/test/ed-decompress/Cargo.toml",
"programs/demo/ed25519/Cargo.toml",
"programs/demo/fibonacci/Cargo.toml",
"programs/demo/fibonacci-io/Cargo.toml",
"programs/demo/io/Cargo.toml",
"programs/test/keccak-permute/Cargo.toml",
"programs/test/secp256k1-add/Cargo.toml",
"programs/test/secp256k1-decompress/Cargo.toml",
"programs/test/secp256k1-double/Cargo.toml",
"programs/test/sha-compress/Cargo.toml",
"programs/test/sha-extend/Cargo.toml",
"programs/test/sha2/Cargo.toml",
"programs/demo/ssz-withdrawals/Cargo.toml",
"programs/test/ecrecover/Cargo.toml",
// Examples.
"examples/chess/program/Cargo.toml",
"examples/chess/script/Cargo.toml",
"examples/ed25519/script/Cargo.toml",
"examples/ed25519/program/Cargo.toml",
"examples/fibonacci/program/Cargo.toml",
"examples/fibonacci/script/Cargo.toml",
"examples/fibonacci-io/program/Cargo.toml",
"examples/fibonacci-io/script/Cargo.toml",
"examples/io/program/Cargo.toml",
"examples/io/script/Cargo.toml",
"examples/json/program/Cargo.toml",
"examples/json/script/Cargo.toml",
"examples/regex/program/Cargo.toml",
"examples/regex/script/Cargo.toml",
"examples/rsa/program/Cargo.toml",
"examples/rsa/script/Cargo.toml",
"examples/ssz-withdrawals/program/Cargo.toml",
"examples/ssz-withdrawals/script/Cargo.toml",
"examples/tendermint/program/Cargo.toml",
"examples/tendermint/script/Cargo.toml",
// Tests.
Copy link
Contributor

Choose a reason for hiding this comment

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

can u do this in json?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

vscode uses jsonc

"tests/blake3-compress/Cargo.toml",
"tests/cycle-tracker/Cargo.toml",
"tests/ecrecover/Cargo.toml",
"tests/ed-add/Cargo.toml",
"tests/ed-decompress/Cargo.toml",
"tests/keccak-permute/Cargo.toml",
"tests/secp256k1-add/Cargo.toml",
"tests/secp256k1-decompress/Cargo.toml",
"tests/secp256k1-double/Cargo.toml",
"tests/sha-compress/Cargo.toml",
"tests/sha-expand/Cargo.toml",
"tests/sha2/Cargo.toml",
],
"rust-analyzer.showUnlinkedFileNotification": false
}
49 changes: 0 additions & 49 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[workspace]
members = ["core", "cli", "derive", "examples/*", "zkvm"]
members = ["core", "cli", "derive", "zkvm"]
exclude = ["examples/target"]
resolver = "2"

Expand Down
61 changes: 39 additions & 22 deletions core/src/utils/programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,71 @@
pub mod tests {
/// Demos.

pub const CHESS_ELF: &[u8] =
include_bytes!("../../../examples/chess/program/elf/riscv32im-succinct-zkvm-elf");

pub const ED25519_ELF: &[u8] =
include_bytes!("../../../programs/demo/ed25519/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../examples/ed25519/program/elf/riscv32im-succinct-zkvm-elf");

pub const FIBONACCI_ELF: &[u8] =
include_bytes!("../../../examples/fibonacci/program/elf/riscv32im-succinct-zkvm-elf");

pub const FIBONACCI_IO_ELF: &[u8] =
include_bytes!("../../../examples/fibonacci-io/program/elf/riscv32im-succinct-zkvm-elf");

pub const IO_ELF: &[u8] =
include_bytes!("../../../programs/demo/io/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../examples/io/program/elf/riscv32im-succinct-zkvm-elf");

pub const JSON_ELF: &[u8] =
include_bytes!("../../../examples/json/program/elf/riscv32im-succinct-zkvm-elf");

pub const REGEX_ELF: &[u8] =
include_bytes!("../../../examples/regex/program/elf/riscv32im-succinct-zkvm-elf");

pub const RSA_ELF: &[u8] =
include_bytes!("../../../examples/rsa/program/elf/riscv32im-succinct-zkvm-elf");

pub const SSZ_WITHDRAWALS_ELF: &[u8] =
include_bytes!("../../../programs/demo/ssz-withdrawals/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../examples/ssz-withdrawals/program/elf/riscv32im-succinct-zkvm-elf");

pub const TENDERMINT_ELF: &[u8] =
include_bytes!("../../../programs/demo/tendermint/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf");

/// Tests.

pub const BLAKE3_COMPRESS_ELF: &[u8] =
include_bytes!("../../../tests/blake3-compress/elf/riscv32im-succinct-zkvm-elf");

pub const CYCLE_TRACKER_ELF: &[u8] =
include_bytes!("../../../programs/test/cycle-tracker/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../tests/cycle-tracker/elf/riscv32im-succinct-zkvm-elf");

pub const ECRECOVER_ELF: &[u8] =
include_bytes!("../../../tests/ecrecover/elf/riscv32im-succinct-zkvm-elf");

pub const ED_ADD_ELF: &[u8] =
include_bytes!("../../../programs/test/ed-add/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../tests/ed-add/elf/riscv32im-succinct-zkvm-elf");

pub const ED_DECOMPRESS_ELF: &[u8] =
include_bytes!("../../../programs/test/ed-decompress/elf/riscv32im-succinct-zkvm-elf");

pub const FIBONACCI_ELF: &[u8] =
include_bytes!("../../../programs/demo/fibonacci/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../tests/ed-decompress/elf/riscv32im-succinct-zkvm-elf");

pub const KECCAK_PERMUTE_ELF: &[u8] =
include_bytes!("../../../programs/test/keccak-permute/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../tests/keccak-permute/elf/riscv32im-succinct-zkvm-elf");

pub const SECP256K1_ADD_ELF: &[u8] =
include_bytes!("../../../programs/test/secp256k1-add/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../tests/secp256k1-add/elf/riscv32im-succinct-zkvm-elf");

pub const SECP256K1_DECOMPRESS_ELF: &[u8] = include_bytes!(
"../../../programs/test/secp256k1-decompress/elf/riscv32im-succinct-zkvm-elf"
);
pub const SECP256K1_DECOMPRESS_ELF: &[u8] =
include_bytes!("../../../tests/secp256k1-decompress/elf/riscv32im-succinct-zkvm-elf");

pub const SECP256K1_DOUBLE_ELF: &[u8] =
include_bytes!("../../../programs/test/secp256k1-double/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../tests/secp256k1-double/elf/riscv32im-succinct-zkvm-elf");

pub const SHA_COMPRESS_ELF: &[u8] =
include_bytes!("../../../programs/test/sha-compress/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../tests/sha-compress/elf/riscv32im-succinct-zkvm-elf");

pub const SHA_EXTEND_ELF: &[u8] =
include_bytes!("../../../programs/test/sha-extend/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../tests/sha-extend/elf/riscv32im-succinct-zkvm-elf");

pub const SHA2_ELF: &[u8] =
include_bytes!("../../../programs/test/sha2/elf/riscv32im-succinct-zkvm-elf");

pub const BLAKE3_COMPRESS_ELF: &[u8] =
include_bytes!("../../../programs/test/blake3-compress/elf/riscv32im-succinct-zkvm-elf");
include_bytes!("../../../tests/sha2/elf/riscv32im-succinct-zkvm-elf");
}
13 changes: 13 additions & 0 deletions examples/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
SHELL := /bin/bash

all:
@for dir in */ ; do \
if [ -d "$${dir}program" ]; then \
echo "Building in $${dir}program..."; \
cd $${dir}program && cargo clean && cargo prove build && cd ../../; \
else \
echo "No program directory in $${dir}, skipping..."; \
fi; \
done

.PHONY: all
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ pub fn main() {
let b = Board::from_str(&fen).expect("valid FEN board");

// Try to parse the SAN as a legal chess move
let is_valid_move = match ChessMove::from_san(&b, &san) {
Ok(_) => true,
Err(_) => false,
};
let is_valid_move = ChessMove::from_san(&b, &san).is_ok();

// Write whether or not the move is legal
sp1_zkvm::io::write(&is_valid_move);
Expand Down
Loading
Loading