Skip to content

Commit ccd1609

Browse files
committed
Compile apps to Wasm
1 parent be6bfc9 commit ccd1609

File tree

38 files changed

+693
-1073
lines changed

38 files changed

+693
-1073
lines changed

Cargo.lock

Lines changed: 90 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ axum-macros = { version = "0.5.0" }
2121
bincode = { version = "1.3.3" }
2222
bitcoin = { workspace = true, features = ["rand", "rand-std"] }
2323
bitcoincore-rpc = { version = "0.19.0" }
24-
charms-client = { path = "./charms-client", version = "0.6.4" }
25-
charms-data = { path = "./charms-data", version = "0.6.4" }
24+
charms-app-runner = { path = "./charms-app-runner", version = "0.7.0" }
25+
charms-client = { path = "./charms-client", version = "0.7.0" }
26+
charms-data = { path = "./charms-data", version = "0.7.0" }
2627
clap = { version = "4.5.40", features = ["derive"] }
2728
clap_complete = { version = "4.5.54" }
2829
cml-chain = { workspace = true }
@@ -32,13 +33,15 @@ serde = { workspace = true, features = ["derive"] }
3233
serde_json = { workspace = true }
3334
serde_with = { version = "3.13.0", features = ["base64"] }
3435
serde_yaml = { workspace = true }
36+
sha2 = { workspace = true }
3537
sp1-core-executor = { workspace = true }
3638
sp1-core-machine = { workspace = true }
3739
sp1-cuda = { workspace = true }
3840
sp1-primitives = { workspace = true }
3941
sp1-prover = { workspace = true }
4042
sp1-sdk = { workspace = true }
4143
tokio = { version = "1.45", features = ["full"] }
44+
toml = { version = "0.8.23" }
4245
tower-http = { version = "0.6.6", features = ["cors"] }
4346
tracing = { workspace = true }
4447
tracing-forest = { version = "0.1.6" }
@@ -55,7 +58,8 @@ proptest-derive = { workspace = true }
5558

5659
[workspace]
5760
members = [
58-
".",
61+
".", "charms-app-checker",
62+
"charms-app-runner",
5963
"charms-client",
6064
"charms-data",
6165
"charms-sdk",
@@ -76,6 +80,7 @@ proptest-derive = { version = "0.5.1" }
7680
serde = { version = "1.0" }
7781
serde_json = { version = "1.0.140" }
7882
serde_yaml = { version = "0.9.34" }
83+
sha2 = { version = "0.10.8" }
7984
sp1-core-executor = { version = "5.0.5" }
8085
sp1-core-machine = { version = "5.0.5" }
8186
sp1-cuda = { version = "5.0.5" }
@@ -99,3 +104,4 @@ strip = "debuginfo"
99104
[patch.crates-io]
100105
secp256k1 = { git = "https://github.com/sp1-patches/rust-secp256k1", tag = "patch-0.29.1-sp1-5.0.0" }
101106
sha2 = { git = "https://github.com/sp1-patches/RustCrypto-hashes", package = "sha2", tag = "patch-sha2-0.10.8-sp1-4.0.0" }
107+
wasmi = { git = "https://github.com/imikushin/wasmi", branch = "rust-1.85" }

charms-app-checker/Cargo.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "charms-app-checker"
3+
4+
version.workspace = true
5+
authors.workspace = true
6+
edition.workspace = true
7+
license.workspace = true
8+
9+
[dependencies]
10+
charms-app-runner = { path = "../charms-app-runner", version = "0.7.0" }
11+
charms-data = { path = "../charms-data", version = "0.7.0" }
12+
charms-client = { path = "../charms-client", version = "0.7.0" }
13+
serde = { workspace = true, features = ["derive"] }
14+
sp1-primitives = { workspace = true }
15+
sp1-zkvm = { workspace = true, features = ["verify"] }

charms-app-checker/src/bin.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
use charms_client::{AppProverInput, AppProverOutput};
2+
use charms_data::util;
3+
4+
pub fn main() {
5+
// Read an input to the program.
6+
let input_vec = sp1_zkvm::io::read_vec();
7+
let input: AppProverInput = util::read(input_vec.as_slice()).unwrap();
8+
9+
let output = run(input);
10+
11+
eprintln!("about to commit");
12+
13+
// Commit to the public values of the program.
14+
let output_vec = util::write(&output).unwrap();
15+
sp1_zkvm::io::commit_slice(output_vec.as_slice());
16+
}
17+
18+
fn run(input: AppProverInput) -> AppProverOutput {
19+
let app_runner = charms_app_runner::AppRunner::new();
20+
let AppProverInput {
21+
app_binaries,
22+
tx,
23+
app_public_inputs,
24+
app_private_inputs,
25+
} = input;
26+
let cycles = app_runner
27+
.run_all(&app_binaries, &tx, &app_public_inputs, &app_private_inputs)
28+
.expect("all apps should run successfully");
29+
AppProverOutput {
30+
tx,
31+
app_public_inputs,
32+
cycles,
33+
}
34+
}

charms-app-checker/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod bin;

charms-app-checker/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#![no_main]
2+
sp1_zkvm::entrypoint!(charms_app_checker::bin::main);

charms-app-runner/Cargo.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[package]
2+
name = "charms-app-runner"
3+
description = "Charms app runner"
4+
5+
version.workspace = true
6+
authors.workspace = true
7+
edition.workspace = true
8+
license.workspace = true
9+
10+
[dependencies]
11+
anyhow = { workspace = true }
12+
charms-data = { path = "../charms-data", version = "0.7.0" }
13+
sha2 = { workspace = true }
14+
wasmi = { version = "0.47.0", default-features = false, features = ["std", "prefer-btree-collections"] }

0 commit comments

Comments
 (0)