diff --git a/emulator/src/state.rs b/emulator/src/state.rs index b8f30de1..58e0afe5 100644 --- a/emulator/src/state.rs +++ b/emulator/src/state.rs @@ -573,7 +573,7 @@ impl InstrumentedState { log::debug!("input: {:?}", vec); assert_eq!(a0 % 4, 0, "hint read address not aligned to 4 bytes"); if a1 >= 1 { - self.state.cycle += (a1 as u64 + 31) / 32; + self.state.cycle += (a1 as u64).div_ceil(32); } for i in (0..a1).step_by(4) { // Get each byte in the chunk diff --git a/prover/examples/Cargo.toml b/prover/examples/Cargo.toml index f9c50110..a8d6efb0 100644 --- a/prover/examples/Cargo.toml +++ b/prover/examples/Cargo.toml @@ -2,7 +2,7 @@ members = [ "revme/host", "sha2-rust/host", - "sha2-precompile/host", + "sha2-composition/host", "sha2-go/host", "keccak/host", "split-seg", diff --git a/prover/examples/README.md b/prover/examples/README.md index 401fde5e..4770fa00 100644 --- a/prover/examples/README.md +++ b/prover/examples/README.md @@ -76,15 +76,15 @@ RUST_LOG=info JSON_PATH=../../../../emulator/test-vectors/test.json SEG_OUTPUT=/ ``` -## Prove precompile code +## Prove composition code * Build the sha2-rust (**new**) ``` cd prover/examples/sha2-rust/host cargo check ``` -* Build and run the sha2-precompile (**new**) +* Build and run the sha2-composition (**new**) ``` -cd ../../sha2-precompile/host +cd ../../sha2-composition/host RUST_LOG=info PRECOMPILE_PATH=../../sha2-rust/guest/elf/mips-zkm-zkvm-elf SEG_OUTPUT=/tmp/output cargo run --release ``` diff --git a/prover/examples/sha2-precompile/guest/Cargo.lock b/prover/examples/sha2-composition/guest/Cargo.lock similarity index 100% rename from prover/examples/sha2-precompile/guest/Cargo.lock rename to prover/examples/sha2-composition/guest/Cargo.lock diff --git a/prover/examples/sha2-precompile/guest/Cargo.toml b/prover/examples/sha2-composition/guest/Cargo.toml similarity index 100% rename from prover/examples/sha2-precompile/guest/Cargo.toml rename to prover/examples/sha2-composition/guest/Cargo.toml diff --git a/prover/examples/sha2-precompile/guest/src/main.rs b/prover/examples/sha2-composition/guest/src/main.rs similarity index 100% rename from prover/examples/sha2-precompile/guest/src/main.rs rename to prover/examples/sha2-composition/guest/src/main.rs diff --git a/prover/examples/sha2-precompile/host/Cargo.toml b/prover/examples/sha2-composition/host/Cargo.toml similarity index 95% rename from prover/examples/sha2-precompile/host/Cargo.toml rename to prover/examples/sha2-composition/host/Cargo.toml index e5e78bd2..ac4d8df6 100644 --- a/prover/examples/sha2-precompile/host/Cargo.toml +++ b/prover/examples/sha2-composition/host/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "precompile-host" +name = "composition-host" version = { workspace = true } edition = { workspace = true } publish = false diff --git a/prover/examples/sha2-precompile/host/build.rs b/prover/examples/sha2-composition/host/build.rs similarity index 100% rename from prover/examples/sha2-precompile/host/build.rs rename to prover/examples/sha2-composition/host/build.rs diff --git a/prover/examples/sha2-precompile/host/src/main.rs b/prover/examples/sha2-composition/host/src/main.rs similarity index 100% rename from prover/examples/sha2-precompile/host/src/main.rs rename to prover/examples/sha2-composition/host/src/main.rs diff --git a/prover/src/cpu/cpu_stark.rs b/prover/src/cpu/cpu_stark.rs index de688cb3..01d625d5 100644 --- a/prover/src/cpu/cpu_stark.rs +++ b/prover/src/cpu/cpu_stark.rs @@ -1,5 +1,5 @@ use std::borrow::Borrow; -use std::iter::repeat; +use std::iter::repeat_n; use std::marker::PhantomData; use itertools::Itertools; @@ -167,7 +167,7 @@ pub fn ctl_data_code_memory() -> Vec> { cols.push(Column::le_bits(base)); // High limbs of the value are all zero. - cols.extend(repeat(Column::constant(F::ZERO)).take(VALUE_LIMBS - 1)); + cols.extend(repeat_n(Column::constant(F::ZERO), VALUE_LIMBS - 1)); cols.push(mem_time_and_channel(MEM_CODE_CHANNEL_IDX)); diff --git a/runtime/precompiles/src/io.rs b/runtime/precompiles/src/io.rs index 335b7d4f..10c519db 100644 --- a/runtime/precompiles/src/io.rs +++ b/runtime/precompiles/src/io.rs @@ -38,7 +38,7 @@ impl std::io::Write for SyscallWriter { pub fn read_vec() -> Vec { let len = unsafe { syscall_hint_len() }; // Round up to the nearest multiple of 4 so that the memory allocated is in whole words - let capacity = (len + 3) / 4 * 4; + let capacity = len.div_ceil(4); // Allocate a buffer of the required length that is 4 byte aligned let layout = Layout::from_size_align(capacity, 4).expect("vec is too large");