From 34097b8f1184e8eaff8a4bce3b38746b2a2af4ec Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Mon, 27 May 2024 13:03:53 +0800 Subject: [PATCH 1/8] Foo --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b0731b297..59d1ba629 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "nightly-2024-04-24" +channel = "nightly-2024-05-27" components = ["rustfmt", "rust-src", "clippy"] profile = "minimal" From 909e728e89422dbaa03cd2ff0f194516ad093615 Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Mon, 27 May 2024 15:10:27 +0800 Subject: [PATCH 2/8] Snapshot --- examples-builder/Cargo.toml | 5 ++++ examples-builder/build.rs | 47 ++++++++++++++++--------------------- recproofs/Cargo.toml | 3 ++- sdk/src/lib.rs | 3 ++- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/examples-builder/Cargo.toml b/examples-builder/Cargo.toml index 754afcfad..58b05fda4 100644 --- a/examples-builder/Cargo.toml +++ b/examples-builder/Cargo.toml @@ -10,9 +10,11 @@ repository = "https://github.com/0xmozak/mozak-vm" version = "0.1.0" [features] +bss-tester = [] empty = [] fibonacci = [] inputtape = [] +inputtapebin = [] memory-access = [] min-max = [] mozak-sort = [] @@ -21,4 +23,7 @@ rkyv-serialization = [] sha2 = [] static-mem-access = [] token = [] +# Not sure whether token, tokenbin, wallet and walletbin should all be here, or whether we forget cleaning them up in recent renames? +tokenbin = [] wallet = [] +walletbin = [] diff --git a/examples-builder/build.rs b/examples-builder/build.rs index 3265032c0..94c757adb 100644 --- a/examples-builder/build.rs +++ b/examples-builder/build.rs @@ -47,35 +47,28 @@ const CRATES: &[Crate] = &[ const CARGO_MANIFEST_DIR: &str = env!("CARGO_MANIFEST_DIR"); fn build_elf(dest: &mut File, crate_path: &str, elf_path: &str, glob_name: &str, uses_std: bool) { - // Use a dummy array for clippy, since not building the elf is faster than - // building the elf - if cfg!(feature = "cargo-clippy") { - writeln!(dest, r#"pub const {glob_name}: &[u8] = &[];"#) + let args = if uses_std { + vec!["build", "--release", "--features=std"] } else { - let args = if uses_std { - vec!["build", "--release", "--features=std"] - } else { - vec!["build", "--release"] - }; - let output = Command::new("cargo") - .args(args) - .current_dir(crate_path) - .env_clear() - .envs(std::env::vars().filter(|x| !x.0.starts_with("CARGO_"))) - .output() - .expect("cargo command failed to run"); - if !output.status.success() { - io::stdout().write_all(&output.stdout).unwrap(); - io::stderr().write_all(&output.stderr).unwrap(); - panic!("cargo build {crate_path} failed."); - } - writeln!( - dest, - r#"pub const {glob_name}: &[u8] = - include_bytes!(r"{CARGO_MANIFEST_DIR}/{elf_path}");"# - ) + vec!["build", "--release"] + }; + let output = Command::new("cargo") + .args(args) + .current_dir(crate_path) + .env_clear() + .envs(std::env::vars().filter(|x| !x.0.starts_with("CARGO_"))) + .output() + .expect("cargo command failed to run"); + if !output.status.success() { + io::stdout().write_all(&output.stdout).unwrap(); + io::stderr().write_all(&output.stderr).unwrap(); + panic!("cargo build {crate_path} failed."); } - .expect("failed to write vars.rs"); + writeln!( + dest, + r#"pub const {glob_name}: &[u8] = + include_bytes!(r"{CARGO_MANIFEST_DIR}/{elf_path}");"# + ).expect("failed to write vars.rs"); println!("cargo:rerun-if-changed={crate_path}"); println!("cargo:rerun-if-changed={elf_path}"); diff --git a/recproofs/Cargo.toml b/recproofs/Cargo.toml index 5e8610dcd..c458ec886 100644 --- a/recproofs/Cargo.toml +++ b/recproofs/Cargo.toml @@ -23,7 +23,8 @@ once_cell = "1" tested-fixture = "1" [features] -test = ["plonky2/parallel"] +# test = ["plonky2/parallel"] +test = [] [[bench]] harness = false diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index d811ced49..d9219790c 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -20,7 +20,8 @@ pub mod core; #[cfg(feature = "std")] pub mod common; -#[cfg(all(feature = "std", target_os = "mozakvm"))] +// #[cfg(all(feature = "std", target_os = "mozakvm"))] +#[cfg(all(feature = "std", target_os = "zkvm"))] pub mod mozakvm; #[cfg(all(feature = "std", not(target_os = "mozakvm")))] From 990335b94f2a41b9de0ec79fb7d829b14fe45c6b Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Mon, 27 May 2024 17:24:35 +0800 Subject: [PATCH 3/8] Fix lint --- sdk/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index d9219790c..7e2245aac 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -5,6 +5,7 @@ #![feature(raw_ref_op)] #![feature(stmt_expr_attributes)] #![deny(warnings)] +#![allow(unexpected_cfgs)] #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(feature = "std", feature(restricted_std))] From ba9a4056ce5afe8a579d8a9f69f0710676e613e9 Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Mon, 27 May 2024 17:27:18 +0800 Subject: [PATCH 4/8] Restoer --- recproofs/Cargo.toml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recproofs/Cargo.toml b/recproofs/Cargo.toml index c458ec886..5e8610dcd 100644 --- a/recproofs/Cargo.toml +++ b/recproofs/Cargo.toml @@ -23,8 +23,7 @@ once_cell = "1" tested-fixture = "1" [features] -# test = ["plonky2/parallel"] -test = [] +test = ["plonky2/parallel"] [[bench]] harness = false From 7e8eb03de9e972903175f05c262d71efb8652893 Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Mon, 27 May 2024 17:28:20 +0800 Subject: [PATCH 5/8] Foo --- sdk/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index cbc85ad5a..1840afdbb 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -3,6 +3,7 @@ #![allow(clippy::missing_panics_doc)] #![feature(trait_alias)] #![deny(warnings)] +// To allow `target_os = "mozakvm"` cfg on native, when the defining json file ain't available. #![allow(unexpected_cfgs)] #![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(feature = "std", feature(restricted_std))] From af47a9e275a75f44c2a24f6928b87e53ce1b8b3b Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Mon, 27 May 2024 17:41:47 +0800 Subject: [PATCH 6/8] Clippy --- examples/mozak-sort/Cargo.toml | 2 +- expr/src/lib.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/mozak-sort/Cargo.toml b/examples/mozak-sort/Cargo.toml index 59e9fd7ec..9217c8663 100644 --- a/examples/mozak-sort/Cargo.toml +++ b/examples/mozak-sort/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" [dependencies] mozak-sdk = { path = "../../sdk", default-features = false } -rand = { version = "0.8", default_features = false, features = ["alloc", "small_rng"] } +rand = { version = "0.8", default-features = false, features = ["alloc", "small_rng"] } [[bin]] name = "mozak-sort" diff --git a/expr/src/lib.rs b/expr/src/lib.rs index 49d52e2ce..46d893ea5 100644 --- a/expr/src/lib.rs +++ b/expr/src/lib.rs @@ -55,8 +55,8 @@ //! //! - [ ] TODO: support `|` via multiplication. //! - [ ] TODO support `&` via distributive law, and integration with constraint -//! builder. (a & b) | c == (a | c) & (b | c) == [(a | c), (b | c)] where [..] -//! means split into multiple constraints. +//! builder. (a & b) | c == (a | c) & (b | c) == [(a | c), (b | c)] where [..] +//! means split into multiple constraints. pub mod ops; From f923436c6d14006720b02ecd0df116c5b43d7365 Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Mon, 27 May 2024 17:42:09 +0800 Subject: [PATCH 7/8] fmt --- circuits/src/register/generation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/circuits/src/register/generation.rs b/circuits/src/register/generation.rs index 696f29cc0..ac906b2da 100644 --- a/circuits/src/register/generation.rs +++ b/circuits/src/register/generation.rs @@ -78,8 +78,8 @@ where /// There are 3 steps: /// 1) populate the trace with a similar layout as the /// [`RegisterInit` table](crate::registerinit::columns), -/// 2) go through the program and extract all ops that act on registers, -/// filling up this table, +/// 2) go through the program and extract all ops that act on registers, filling +/// up this table, /// 3) pad with dummy rows (`is_used` == 0) to ensure that trace is a power of /// 2. #[allow(clippy::type_complexity)] From a6a6fbcf8f37aea4cd1a97b3e0faa010056c5d54 Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Mon, 27 May 2024 17:47:10 +0800 Subject: [PATCH 8/8] Linter --- circuits/src/register/generation.rs | 4 ++-- examples-builder/build.rs | 3 ++- examples/bss-tester/Cargo.toml | 3 +++ examples/empty/Cargo.toml | 3 +++ examples/mozak-sort/Cargo.toml | 3 +++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/circuits/src/register/generation.rs b/circuits/src/register/generation.rs index ac906b2da..59f5511ab 100644 --- a/circuits/src/register/generation.rs +++ b/circuits/src/register/generation.rs @@ -76,8 +76,8 @@ where /// Generates the trace for registers. /// /// There are 3 steps: -/// 1) populate the trace with a similar layout as the -/// [`RegisterInit` table](crate::registerinit::columns), +/// 1) populate the trace with a similar layout as the [`RegisterInit` +/// table](crate::registerinit::columns), /// 2) go through the program and extract all ops that act on registers, filling /// up this table, /// 3) pad with dummy rows (`is_used` == 0) to ensure that trace is a power of diff --git a/examples-builder/build.rs b/examples-builder/build.rs index 94c757adb..65cec29d5 100644 --- a/examples-builder/build.rs +++ b/examples-builder/build.rs @@ -68,7 +68,8 @@ fn build_elf(dest: &mut File, crate_path: &str, elf_path: &str, glob_name: &str, dest, r#"pub const {glob_name}: &[u8] = include_bytes!(r"{CARGO_MANIFEST_DIR}/{elf_path}");"# - ).expect("failed to write vars.rs"); + ) + .expect("failed to write vars.rs"); println!("cargo:rerun-if-changed={crate_path}"); println!("cargo:rerun-if-changed={elf_path}"); diff --git a/examples/bss-tester/Cargo.toml b/examples/bss-tester/Cargo.toml index 26778e3cb..31c5baf8e 100644 --- a/examples/bss-tester/Cargo.toml +++ b/examples/bss-tester/Cargo.toml @@ -6,6 +6,9 @@ version = "0.1.0" [dependencies] mozak-sdk = { path = "../../sdk", default-features = false } +[features] +std = [] + [[bin]] name = "bss-tester" path = "main.rs" diff --git a/examples/empty/Cargo.toml b/examples/empty/Cargo.toml index 80b85d99b..ed2a573d3 100644 --- a/examples/empty/Cargo.toml +++ b/examples/empty/Cargo.toml @@ -6,6 +6,9 @@ version = "0.1.0" [dependencies] mozak-sdk = { path = "../../sdk", default-features = false } +[features] +std = [] + [[bin]] name = "empty" path = "main.rs" diff --git a/examples/mozak-sort/Cargo.toml b/examples/mozak-sort/Cargo.toml index 9217c8663..149d87028 100644 --- a/examples/mozak-sort/Cargo.toml +++ b/examples/mozak-sort/Cargo.toml @@ -7,6 +7,9 @@ version = "0.1.0" mozak-sdk = { path = "../../sdk", default-features = false } rand = { version = "0.8", default-features = false, features = ["alloc", "small_rng"] } +[features] +std = [] + [[bin]] name = "mozak-sort" path = "main.rs"