diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index b882ca931..934fe3f3e 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -43,18 +43,17 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ + guest/target/ key: integration-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - uses: dtolnay/rust-toolchain@nightly - name: Run example env: - RAYON_NUM_THREADS: 2 RUSTFLAGS: "-C opt-level=3" run: cargo run --package ceno_zkvm --example riscv_opcodes -- --start 10 --end 11 - name: Run fibonacci env: - RAYON_NUM_THREADS: 8 RUST_LOG: debug RUSTFLAGS: "-C opt-level=3" run: cargo run --package ceno_zkvm --bin e2e -- --platform=sp1 ceno_zkvm/examples/fibonacci.elf diff --git a/.github/workflows/lints.yml b/.github/workflows/lints.yml index fe7367a54..207769aa8 100644 --- a/.github/workflows/lints.yml +++ b/.github/workflows/lints.yml @@ -49,7 +49,7 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ - examples/target/ + guest/target/ key: lint-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install cargo make @@ -62,13 +62,13 @@ jobs: env: RUSTFLAGS: "-Dwarnings" run: | - cargo check --workspace --all-targets --exclude ceno_rt + cargo check --workspace --all-targets # We have a lot of code under #[cfg(not(debug_assertions))] and similar, # so we need to run cargo check in release mode, too: - cargo check --workspace --all-targets --exclude ceno_rt --release + cargo check --workspace --all-targets --release cargo make clippy # Same for clippy: - cargo clippy --workspace --all-targets --exclude ceno_rt --release + cargo clippy --workspace --all-targets --release - name: Install taplo run: taplo --version || cargo install taplo-cli diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index da0784782..e7d224995 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -47,7 +47,7 @@ jobs: ~/.cargo/registry/cache/ ~/.cargo/git/db/ target/ - examples/target/ + guest/target/ key: tests-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install cargo make diff --git a/Cargo.lock b/Cargo.lock index 865b783f5..35ff0505a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -244,13 +244,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "ceno_rt" -version = "0.1.0" -dependencies = [ - "riscv", -] - [[package]] name = "ceno_zkvm" version = "0.1.0" @@ -468,12 +461,6 @@ dependencies = [ "itertools 0.10.5", ] -[[package]] -name = "critical-section" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "790eea4361631c5e7d22598ecd5723ff611904e3344ce8720784c93e3d83d40b" - [[package]] name = "crossbeam-channel" version = "0.5.13" @@ -602,12 +589,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4445909572dbd556c457c849c4ca58623d84b27c8fff1e74b0b4227d8b90d17b" -[[package]] -name = "embedded-hal" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89" - [[package]] name = "encode_unicode" version = "1.0.0" @@ -655,9 +636,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" [[package]] name = "ff" @@ -973,9 +954,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.167" +version = "0.2.168" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" +checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d" [[package]] name = "libredox" @@ -1416,7 +1397,7 @@ dependencies = [ "smallvec", "symbolic-demangle", "tempfile", - "thiserror 2.0.4", + "thiserror 2.0.6", ] [[package]] @@ -1548,9 +1529,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.7" +version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" +checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ "bitflags", ] @@ -1619,36 +1600,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "riscv" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ea8ff73d3720bdd0a97925f0bf79ad2744b6da8ff36be3840c48ac81191d7a7" -dependencies = [ - "critical-section", - "embedded-hal", - "paste", - "riscv-macros", - "riscv-pac", -] - -[[package]] -name = "riscv-macros" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f265be5d634272320a7de94cea15c22a3bfdd4eb42eb43edc528415f066a1f25" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.90", -] - -[[package]] -name = "riscv-pac" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8188909339ccc0c68cfb5a04648313f09621e8b87dc03095454f1a11f6c5d436" - [[package]] name = "rrs-succinct" version = "0.1.0" @@ -1668,15 +1619,15 @@ checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" [[package]] name = "rustix" -version = "0.38.41" +version = "0.38.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f649912bc1495e167a6edee79151c84b1bad49748cb4f1f1167f459f6224f6" +checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" dependencies = [ "bitflags", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -1708,18 +1659,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" +checksum = "0b9781016e935a97e8beecf0c933758c97a5520d32930e460142b4cd80c6338e" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.215" +version = "1.0.216" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" +checksum = "46f859dbbf73865c6627ed570e78961cd3ac92407a2d117204c49232485da55e" dependencies = [ "proc-macro2", "quote", @@ -1918,11 +1869,11 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.4" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f49a1853cf82743e3b7950f77e0f4d622ca36cf4317cba00c767838bac8d490" +checksum = "8fec2a1820ebd077e2b90c4df007bebf344cd394098a13c563957d0afc83ea47" dependencies = [ - "thiserror-impl 2.0.4", + "thiserror-impl 2.0.6", ] [[package]] @@ -1938,9 +1889,9 @@ dependencies = [ [[package]] name = "thiserror-impl" -version = "2.0.4" +version = "2.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8381894bb3efe0c4acac3ded651301ceee58a15d47c2e34885ed1908ad667061" +checksum = "d65750cab40f4ff1929fb1ba509e9914eb756131cef4210da8d5d700d26f6312" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index ead19b880..93cabd8d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,9 +1,8 @@ [workspace] -exclude = ["examples"] +exclude = ["guest"] members = [ "ceno_emul", "examples-builder", - "ceno_rt", "mpcs", "multilinear_extensions", "sumcheck", @@ -54,6 +53,13 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } [profile.dev] lto = "thin" +# We are running our tests with optimizations turned on to make them faster. +# Please turn optimizations off, when you want accurate stack traces for debugging. +opt-level = 2 + +[profile.dev.package."*"] +# Set the default for dependencies in Development mode. +opt-level = 3 [profile.release] lto = "thin" diff --git a/Makefile.toml b/Makefile.toml index 4a5a93188..199a42528 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,7 +1,5 @@ [env] CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true -CORE = { script = ["nproc"] } -RAYON_NUM_THREADS = "${CORE}" [tasks.tests] args = [ @@ -11,10 +9,7 @@ args = [ "--bins", "--tests", "--examples", - "--release", "--workspace", - "--exclude", - "ceno_rt", ] command = "cargo" workspace = false @@ -34,8 +29,6 @@ args = [ "clippy", "--workspace", "--all-targets", - "--exclude", - "ceno_rt", "--", "-D", "warnings", diff --git a/README.md b/README.md index 82f2e8bfe..0c57ac442 100644 --- a/README.md +++ b/README.md @@ -33,10 +33,9 @@ Clippy and check work as usual: ```sh cargo check cargo clippy +cargo build ``` -Alas, `cargo build` doesn't work. That's a known problem and we're working on it. Please use `cargo make build` instead for now. - ### Setting up self-hosted CI docker container To set up docker container for CI, you can run the following command: diff --git a/ceno_zkvm/Makefile.toml b/ceno_zkvm/Makefile.toml index a4965ba50..45d27cf51 100644 --- a/ceno_zkvm/Makefile.toml +++ b/ceno_zkvm/Makefile.toml @@ -1,9 +1,7 @@ [env] CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true -CORE = { script = ["nproc"] } -RAYON_NUM_THREADS = "${CORE}" [tasks.riscv_opcodes_flamegraph] args = ["run", "--package", "ceno_zkvm", "--release", "--example", "riscv_opcodes"] command = "cargo" -env = { "RUST_LOG" = "debug", "RAYON_NUM_THREADS" = "8" } +env = { "RUST_LOG" = "debug" } diff --git a/examples-builder/build.rs b/examples-builder/build.rs index 7ea9b9628..0e8d90441 100644 --- a/examples-builder/build.rs +++ b/examples-builder/build.rs @@ -26,7 +26,7 @@ fn build_elfs() { // See git history for an attempt to do this. let output = Command::new("cargo") .args(["build", "--release", "--examples"]) - .current_dir("../examples") + .current_dir("../guest/examples") .env_clear() .envs(std::env::vars().filter(|x| !x.0.starts_with("CARGO_"))) .output() @@ -41,11 +41,11 @@ fn build_elfs() { dest, r#"#[allow(non_upper_case_globals)] pub const {example}: &[u8] = - include_bytes!(r"{CARGO_MANIFEST_DIR}/../examples/target/riscv32im-unknown-none-elf/release/examples/{example}");"# + include_bytes!(r"{CARGO_MANIFEST_DIR}/../guest/target/riscv32im-unknown-none-elf/release/examples/{example}");"# ).expect("failed to write vars.rs"); } - let input_path = "../examples/"; - let elfs_path = "../examples/target/riscv32im-unknown-none-elf/release/examples/"; + let input_path = "../guest/"; + let elfs_path = "../guest/target/riscv32im-unknown-none-elf/release/examples/"; println!("cargo:rerun-if-changed={input_path}"); println!("cargo:rerun-if-changed={elfs_path}"); diff --git a/examples/.cargo/config.toml b/examples/.cargo/config.toml deleted file mode 120000 index bade0c189..000000000 --- a/examples/.cargo/config.toml +++ /dev/null @@ -1 +0,0 @@ -../../ceno_rt/.cargo/config.toml \ No newline at end of file diff --git a/examples/Cargo.toml b/examples/Cargo.toml deleted file mode 100644 index 85c975ac1..000000000 --- a/examples/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -edition = "2021" -name = "examples" -readme = "README.md" -resolver = "2" -version = "0.1.0" - -[dependencies] -ceno_rt = { path = "../ceno_rt" } diff --git a/examples/rust-toolchain.toml b/examples/rust-toolchain.toml deleted file mode 120000 index 43fe0ada6..000000000 --- a/examples/rust-toolchain.toml +++ /dev/null @@ -1 +0,0 @@ -../rust-toolchain.toml \ No newline at end of file diff --git a/ceno_rt/.cargo/config.toml b/guest/.cargo/config.toml similarity index 100% rename from ceno_rt/.cargo/config.toml rename to guest/.cargo/config.toml diff --git a/examples/Cargo.lock b/guest/Cargo.lock similarity index 88% rename from examples/Cargo.lock rename to guest/Cargo.lock index 359355930..84c6c3ab6 100644 --- a/examples/Cargo.lock +++ b/guest/Cargo.lock @@ -36,9 +36,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "proc-macro2" -version = "1.0.88" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -84,9 +84,9 @@ checksum = "8188909339ccc0c68cfb5a04648313f09621e8b87dc03095454f1a11f6c5d436" [[package]] name = "syn" -version = "2.0.82" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -95,6 +95,6 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.13" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" diff --git a/guest/Cargo.toml b/guest/Cargo.toml new file mode 100644 index 000000000..0aa06be48 --- /dev/null +++ b/guest/Cargo.toml @@ -0,0 +1,15 @@ +[workspace] +members = ["examples", "ceno_rt"] +resolver = "2" + +[workspace.package] +categories = ["cryptography", "zk", "blockchain", "ceno"] +edition = "2021" +keywords = ["cryptography", "zk", "blockchain", "ceno"] +license = "MIT OR Apache-2.0" +readme = "../README.md" +repository = "https://github.com/scroll-tech/ceno" +version = "0.1.0" + +[profile.release] +lto = "thin" diff --git a/ceno_rt/Cargo.toml b/guest/ceno_rt/Cargo.toml similarity index 100% rename from ceno_rt/Cargo.toml rename to guest/ceno_rt/Cargo.toml diff --git a/ceno_rt/README.md b/guest/ceno_rt/README.md similarity index 100% rename from ceno_rt/README.md rename to guest/ceno_rt/README.md diff --git a/ceno_rt/build.rs b/guest/ceno_rt/build.rs similarity index 100% rename from ceno_rt/build.rs rename to guest/ceno_rt/build.rs diff --git a/ceno_rt/ceno_link.x b/guest/ceno_rt/ceno_link.x similarity index 100% rename from ceno_rt/ceno_link.x rename to guest/ceno_rt/ceno_link.x diff --git a/ceno_rt/memory.x b/guest/ceno_rt/memory.x similarity index 100% rename from ceno_rt/memory.x rename to guest/ceno_rt/memory.x diff --git a/ceno_rt/src/allocator.rs b/guest/ceno_rt/src/allocator.rs similarity index 100% rename from ceno_rt/src/allocator.rs rename to guest/ceno_rt/src/allocator.rs diff --git a/ceno_rt/src/io.rs b/guest/ceno_rt/src/io.rs similarity index 100% rename from ceno_rt/src/io.rs rename to guest/ceno_rt/src/io.rs diff --git a/ceno_rt/src/lib.rs b/guest/ceno_rt/src/lib.rs similarity index 100% rename from ceno_rt/src/lib.rs rename to guest/ceno_rt/src/lib.rs diff --git a/ceno_rt/src/params.rs b/guest/ceno_rt/src/params.rs similarity index 100% rename from ceno_rt/src/params.rs rename to guest/ceno_rt/src/params.rs diff --git a/guest/examples/Cargo.toml b/guest/examples/Cargo.toml new file mode 100644 index 000000000..397e743b1 --- /dev/null +++ b/guest/examples/Cargo.toml @@ -0,0 +1,13 @@ +[package] +categories.workspace = true +description = "Ceno RiscV guest examples" +edition.workspace = true +keywords.workspace = true +license.workspace = true +name = "examples" +readme = "README.md" +repository.workspace = true +version.workspace = true + +[dependencies] +ceno_rt = { path = "../ceno_rt" } diff --git a/examples/examples/ceno_rt_alloc.rs b/guest/examples/examples/ceno_rt_alloc.rs similarity index 100% rename from examples/examples/ceno_rt_alloc.rs rename to guest/examples/examples/ceno_rt_alloc.rs diff --git a/examples/examples/ceno_rt_io.rs b/guest/examples/examples/ceno_rt_io.rs similarity index 100% rename from examples/examples/ceno_rt_io.rs rename to guest/examples/examples/ceno_rt_io.rs diff --git a/examples/examples/ceno_rt_mem.rs b/guest/examples/examples/ceno_rt_mem.rs similarity index 100% rename from examples/examples/ceno_rt_mem.rs rename to guest/examples/examples/ceno_rt_mem.rs diff --git a/examples/examples/ceno_rt_mini.rs b/guest/examples/examples/ceno_rt_mini.rs similarity index 100% rename from examples/examples/ceno_rt_mini.rs rename to guest/examples/examples/ceno_rt_mini.rs diff --git a/examples/examples/ceno_rt_panic.rs b/guest/examples/examples/ceno_rt_panic.rs similarity index 100% rename from examples/examples/ceno_rt_panic.rs rename to guest/examples/examples/ceno_rt_panic.rs diff --git a/mpcs/src/basefold.rs b/mpcs/src/basefold.rs index 1aec0fb9d..c7eb18f71 100644 --- a/mpcs/src/basefold.rs +++ b/mpcs/src/basefold.rs @@ -947,8 +947,6 @@ where transcript: &mut impl Transcript, ) -> Result<(), Error> { let timer = start_timer!(|| "Basefold::batch_verify"); - // let key = "RAYON_NUM_THREADS"; - // env::set_var(key, "32"); let comms = comms.iter().collect_vec(); let num_vars = points.iter().map(|point| point.len()).max().unwrap(); let num_rounds = num_vars - Spec::get_basecode_msg_size_log();