From cfb586c46b9cf255bbed19bf54a62957bbf53a1d Mon Sep 17 00:00:00 2001 From: Matthias Goergens Date: Mon, 9 Dec 2024 22:31:26 +0800 Subject: [PATCH] Round paranoid --- ceno_zkvm/src/tables/ram/ram_circuit.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ceno_zkvm/src/tables/ram/ram_circuit.rs b/ceno_zkvm/src/tables/ram/ram_circuit.rs index 73c3862f7..1dc5e5afe 100644 --- a/ceno_zkvm/src/tables/ram/ram_circuit.rs +++ b/ceno_zkvm/src/tables/ram/ram_circuit.rs @@ -161,8 +161,9 @@ pub trait DynVolatileRamTable { fn name() -> &'static str; fn max_len(params: &ProgramParams) -> usize { - let max_size = (Self::end_addr(params) - Self::offset_addr(params)) as usize; - let max_len: usize = max_size.next_power_of_two().div_ceil(WORD_SIZE); + let max_size = (Self::end_addr(params) as usize).div_ceil(WORD_SIZE) + - (Self::offset_addr(params) as usize) / WORD_SIZE; + let max_len: usize = max_size.next_power_of_two(); assert!( max_size <= max_len, "Did not round up {max_size} correctly, got {max_len}, which is smaller."