Skip to content

Commit 08b2010

Browse files
yi-sunlispcshuklaayushQumericjonathanpwang
authored
feat: release v1.4.0-rc.0 (#1887)
Co-authored-by: Zhang Zhuo <[email protected]> Co-authored-by: Ayush Shukla <[email protected]> Co-authored-by: Valery Cherepanov <[email protected]> Co-authored-by: Jonathan Wang <[email protected]> Co-authored-by: Avaneesh Kulkarni <[email protected]>
1 parent ca36de3 commit 08b2010

File tree

67 files changed

+360
-182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+360
-182
lines changed

.github/workflows/versioning.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737

3838
# Build and test from base branch
3939
- name: Build base branch CLI
40-
run: cargo install --force --path crates/cli
40+
run: cargo install --force --locked --path crates/cli
4141

4242
- name: Run setup from base branch and snapshot ~/.openvm
4343
run: |
@@ -81,12 +81,11 @@ jobs:
8181
clean: false
8282

8383
- name: Build tagged CLI
84-
run: cargo install --force --path crates/cli
84+
run: cargo install --force --locked --path crates/cli
8585

8686
- name: Run setup from tagged version
8787
run: |
88-
# TODO: Add --evm after v1.3.0 release
89-
cargo openvm setup
88+
cargo openvm setup --evm
9089
9190
# - name: Build and keygen examples from tagged version
9291
# run: |
@@ -97,9 +96,8 @@ jobs:
9796
# echo "Building and generating keys for example: $example_name"
9897
# cd "$example"
9998
# cargo openvm build --no-transpile
100-
# # TODO(yi): Change --vk-output to --output-dir after v1.3.0 release
10199
# mkdir -p "../../tagged-outputs/examples/$example_name"
102-
# cargo openvm keygen --vk-output "../../tagged-outputs/examples/$example_name/app.vk"
100+
# cargo openvm keygen --output-dir "../../tagged-outputs/examples/$example_name/app.vk"
103101
# cd ../..
104102
# fi
105103
# done
@@ -113,9 +111,8 @@ jobs:
113111
echo "Building and generating keys for benchmark: $benchmark_name"
114112
cd "$benchmark"
115113
cargo openvm build --no-transpile
116-
# TODO(yi): Change --vk-output to --output-dir after v1.3.0 release
117114
mkdir -p "../../../tagged-outputs/benchmarks/$benchmark_name"
118-
cargo openvm keygen --vk-output "../../../tagged-outputs/benchmarks/$benchmark_name/app.vk"
115+
cargo openvm keygen --output-dir "../../../tagged-outputs/benchmarks/$benchmark_name"
119116
cd ../../..
120117
fi
121118
done
@@ -167,19 +164,25 @@ jobs:
167164
fi
168165
169166
# Compare all outputs
170-
# TODO: After v1.3.0 release, just compare the contents of ~/.openvm-base
171-
# and ~/.openvm
172167
- name: Compare ~/.openvm contents
173168
run: |
174169
echo "🔍 Comparing ~/.openvm agg and halo2 outputs between base branch and ${{ env.version }}..."
175170
176171
failed=0
177172
178-
# Compare agg.pk with agg_halo2.pk
179-
if cmp ~/.openvm-base/agg.pk ~/.openvm/agg_halo2.pk; then
180-
echo "✅ agg.pk and agg_halo2.pk are identical"
173+
# Compare agg_stark.pk
174+
if cmp ~/.openvm-base/agg_stark.pk ~/.openvm/agg_stark.pk; then
175+
echo "✅ agg_stark.pk are identical"
176+
else
177+
echo "❌ agg_stark.pk differ"
178+
failed=1
179+
fi
180+
181+
# Compare agg_halo2.pk
182+
if cmp ~/.openvm-base/agg_halo2.pk ~/.openvm/agg_halo2.pk; then
183+
echo "✅ agg_halo2.pk are identical"
181184
else
182-
echo "❌ agg.pk and agg_halo2.pk differ"
185+
echo "❌ agg_halo2.pk differ"
183186
failed=1
184187
fi
185188
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
// This file is automatically generated by cargo openvm. Do not rename or edit.
22
openvm_algebra_guest::moduli_macros::moduli_init! { "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337" }
3-
openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point }
3+
openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point" }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// This file is automatically generated by cargo openvm. Do not rename or edit.
22
openvm_algebra_guest::moduli_macros::moduli_init! { "1000000000000000003", "115792089237316195423570985008687907853269984665640564039457584007908834671663", "115792089237316195423570985008687907852837564279074904382605163141518161494337", "115792089210356248762697446949407573530086143415290314195533631308867097853951", "115792089210356248762697446949407573529996955224135760342422259061068512044369", "21888242871839275222246405745257275088696311157297823662689037894645226208583", "21888242871839275222246405745257275088548364400416034343698204186575808495617", "4002409555221667393417789825735904156556882819939007885332058136124031650490837864442687629129015664037894272559787", "52435875175126190479447740508185965837690552500527637822603658699938581184513", "2305843009213693951", "7" }
3-
openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 5 }, Bls12_381Fp2 { mod_idx = 7 } }
4-
openvm_ecc_guest::sw_macros::sw_init! { Secp256k1Point, P256Point, Bn254G1Affine, Bls12_381G1Affine }
3+
openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 5 }, "Bls12_381Fp2" { mod_idx = 7 } }
4+
openvm_ecc_guest::sw_macros::sw_init! { "Secp256k1Point", "P256Point", "Bn254G1Affine", "Bls12_381G1Affine" }
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// This file is automatically generated by cargo openvm. Do not rename or edit.
22
openvm_algebra_guest::moduli_macros::moduli_init! { "21888242871839275222246405745257275088696311157297823662689037894645226208583", "21888242871839275222246405745257275088548364400416034343698204186575808495617" }
3-
openvm_algebra_guest::complex_macros::complex_init! { Bn254Fp2 { mod_idx = 0 } }
4-
openvm_ecc_guest::sw_macros::sw_init! { Bn254G1Affine }
3+
openvm_algebra_guest::complex_macros::complex_init! { "Bn254Fp2" { mod_idx = 0 } }
4+
openvm_ecc_guest::sw_macros::sw_init! { "Bn254G1Affine" }

book/src/custom-extensions/algebra.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ moduli_init! {
8080
"21888242871839275222246405745257275088696311157297823662689037894645226208583"
8181
}
8282
complex_init! {
83-
Bn254Fp2 { mod_idx = 0 },
83+
"Bn254Fp2" { mod_idx = 0 },
8484
}
8585
*/
8686
```

book/src/custom-extensions/ecc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ This creates `Bls12_381G1Affine` and `P256Affine` structs which implement the `G
4949
openvm::init!();
5050
/* This expands to
5151
sw_init! {
52-
Bls12_381G1Affine, P256Affine,
52+
"Bls12_381G1Affine", "P256Affine",
5353
}
5454
*/
5555
```

crates/cli/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ pub mod util;
66
use std::process::{Command, Stdio};
77

88
use eyre::{Context, Result};
9-
10-
pub const RUSTUP_TOOLCHAIN_NAME: &str = "nightly-2025-02-14";
9+
pub use openvm_build::{get_rustup_toolchain_name, DEFAULT_RUSTUP_TOOLCHAIN_NAME};
1110

1211
pub const OPENVM_VERSION_MESSAGE: &str = concat!(
1312
"v",

crates/toolchain/build/src/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ mod config;
2121

2222
/// The rustc compiler [target](https://doc.rust-lang.org/rustc/targets/index.html).
2323
pub const RUSTC_TARGET: &str = "riscv32im-risc0-zkvm-elf";
24-
const RUSTUP_TOOLCHAIN_NAME: &str = "nightly-2025-02-14";
24+
/// The default Rust toolchain name to use if OPENVM_RUST_TOOLCHAIN is not set
25+
pub const DEFAULT_RUSTUP_TOOLCHAIN_NAME: &str = "nightly-2025-02-14";
26+
27+
/// Get the Rust toolchain name from environment variable or default
28+
pub fn get_rustup_toolchain_name() -> String {
29+
env::var("OPENVM_RUST_TOOLCHAIN").unwrap_or_else(|_| DEFAULT_RUSTUP_TOOLCHAIN_NAME.to_string())
30+
}
2531
const BUILD_LOCKED_ENV: &str = "OPENVM_BUILD_LOCKED";
2632
const SKIP_BUILD_ENV: &str = "OPENVM_SKIP_BUILD";
2733
const GUEST_LOGFILE_ENV: &str = "OPENVM_GUEST_LOGFILE";
@@ -240,7 +246,7 @@ fn sanitized_cmd(tool: &str) -> Command {
240246
/// Creates a std::process::Command to execute the given cargo
241247
/// command in an environment suitable for targeting the zkvm guest.
242248
pub fn cargo_command(subcmd: &str, rust_flags: &[&str]) -> Command {
243-
let toolchain = format!("+{RUSTUP_TOOLCHAIN_NAME}");
249+
let toolchain = format!("+{}", get_rustup_toolchain_name());
244250

245251
let rustc = sanitized_cmd("rustup")
246252
.args([&toolchain, "which", "rustc"])
@@ -382,7 +388,7 @@ pub fn build_generic(guest_opts: &GuestOptions) -> Result<PathBuf, Option<i32>>
382388

383389
// Check if the required toolchain and rust-src component are installed, and if not, install
384390
// them. This requires that `rustup` is installed.
385-
if let Err(code) = ensure_toolchain_installed(RUSTUP_TOOLCHAIN_NAME, &["rust-src"]) {
391+
if let Err(code) = ensure_toolchain_installed(&get_rustup_toolchain_name(), &["rust-src"]) {
386392
eprintln!("rustup toolchain commands failed. Please ensure rustup is installed (https://www.rust-lang.org/tools/install)");
387393
return Err(Some(code));
388394
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
extern crate alloc;
2+
3+
use alloc::alloc::{alloc, dealloc, handle_alloc_error, Layout};
4+
use core::ptr::NonNull;
5+
6+
/// Bytes allocated according to the given Layout
7+
pub struct AlignedBuf {
8+
pub ptr: *mut u8,
9+
pub layout: Layout,
10+
}
11+
12+
impl AlignedBuf {
13+
/// Allocate a new buffer whose start address is aligned to `align` bytes.
14+
/// *NOTE* if `len` is zero then a creates new `NonNull` that is dangling and 16-byte aligned.
15+
pub fn uninit(len: usize, align: usize) -> Self {
16+
let layout = Layout::from_size_align(len, align).unwrap();
17+
if layout.size() == 0 {
18+
return Self {
19+
ptr: NonNull::<u128>::dangling().as_ptr() as *mut u8,
20+
layout,
21+
};
22+
}
23+
// TODO[jpw]: replace `alloc` with `allocate` once the `Allocator` trait is stabilized.
24+
// (see https://doc.rust-lang.org/alloc/alloc/fn.alloc.html)
25+
// SAFETY: `len` is nonzero
26+
let ptr = unsafe { alloc(layout) };
27+
if ptr.is_null() {
28+
handle_alloc_error(layout);
29+
}
30+
AlignedBuf { ptr, layout }
31+
}
32+
33+
/// Allocate a new buffer whose start address is aligned to `align` bytes
34+
/// and copy the given data into it.
35+
///
36+
/// # Safety
37+
/// - `bytes` must not be null
38+
/// - `len` should not be zero
39+
///
40+
/// See [alloc]. In particular `data` should not be empty.
41+
pub unsafe fn new(bytes: *const u8, len: usize, align: usize) -> Self {
42+
let buf = Self::uninit(len, align);
43+
// SAFETY:
44+
// - src and dst are not null
45+
// - src and dst are allocated for size
46+
// - no alignment requirements on u8
47+
// - non-overlapping since ptr is newly allocated
48+
unsafe {
49+
core::ptr::copy_nonoverlapping(bytes, buf.ptr, len);
50+
}
51+
52+
buf
53+
}
54+
}
55+
56+
impl Drop for AlignedBuf {
57+
fn drop(&mut self) {
58+
if self.layout.size() != 0 {
59+
unsafe {
60+
dealloc(self.ptr, self.layout);
61+
}
62+
}
63+
}
64+
}

crates/toolchain/platform/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
#![deny(rustdoc::broken_intra_doc_links)]
55
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
66

7-
#[cfg(all(feature = "rust-runtime", target_os = "zkvm"))]
7+
#[cfg(target_os = "zkvm")]
88
pub use openvm_custom_insn::{custom_insn_i, custom_insn_r};
9+
#[cfg(target_os = "zkvm")]
10+
pub mod alloc;
911
#[cfg(all(feature = "rust-runtime", target_os = "zkvm"))]
1012
pub mod heap;
1113
#[cfg(all(feature = "export-libm", target_os = "zkvm"))]
1214
mod libm_extern;
15+
1316
pub mod memory;
1417
pub mod print;
1518
#[cfg(feature = "rust-runtime")]
@@ -19,9 +22,6 @@ pub mod rust_rt;
1922
/// 4 bytes (i.e. 32 bits) as the zkVM is an implementation of the rv32im ISA.
2023
pub const WORD_SIZE: usize = core::mem::size_of::<u32>();
2124

22-
/// Size of a zkVM memory page.
23-
pub const PAGE_SIZE: usize = 1024;
24-
2525
/// Standard IO file descriptors for use with sys_read and sys_write.
2626
pub mod fileno {
2727
pub const STDIN: u32 = 0;

0 commit comments

Comments
 (0)