diff --git a/core/src/memory/global.rs b/core/src/memory/global.rs index 4ed8e6048d..8bb93618ba 100644 --- a/core/src/memory/global.rs +++ b/core/src/memory/global.rs @@ -41,8 +41,8 @@ impl MachineAir for MemoryChip { fn name(&self) -> String { match self.kind { - MemoryChipType::Initialize => "MemoryInit".to_string(), - MemoryChipType::Finalize => "MemoryFinalize".to_string(), + MemoryChipType::Initialize => "MemoryGlobalInit".to_string(), + MemoryChipType::Finalize => "MemoryGlobalFinalize".to_string(), } } @@ -56,8 +56,20 @@ impl MachineAir for MemoryChip { _output: &mut ExecutionRecord, ) -> RowMajorMatrix { let mut memory_events = match self.kind { - MemoryChipType::Initialize => input.global_memory_initialize_events.clone(), - MemoryChipType::Finalize => input.global_memory_finalize_events.clone(), + MemoryChipType::Initialize => { + println!( + "Global memory initialize table: {:?}", + input.global_memory_initialize_events.len() + ); + input.global_memory_initialize_events.clone() + } + MemoryChipType::Finalize => { + println!( + "Global memory finalize table: {:?}", + input.global_memory_finalize_events.len() + ); + input.global_memory_finalize_events.clone() + } }; let previous_addr_bits = match self.kind { diff --git a/core/src/memory/local.rs b/core/src/memory/local.rs index 513e01888f..32688cadd6 100644 --- a/core/src/memory/local.rs +++ b/core/src/memory/local.rs @@ -69,8 +69,20 @@ impl MachineAir for MemoryLocalChip { _output: &mut ExecutionRecord, ) -> RowMajorMatrix { let local_memory_accesses = match self.kind { - MemoryChipType::Initialize => &input.local_memory_initialize_access, - MemoryChipType::Finalize => &input.local_memory_finalize_access, + MemoryChipType::Initialize => { + println!( + "Local memory initialize table: {:?}", + input.local_memory_initialize_access.len() + ); + &input.local_memory_initialize_access + } + MemoryChipType::Finalize => { + println!( + "Local memory finalize table: {:?}", + input.local_memory_finalize_access.len() + ); + &input.local_memory_finalize_access + } }; let mut rows = diff --git a/core/src/memory/mod.rs b/core/src/memory/mod.rs index 440c9c530e..4758e84d1c 100644 --- a/core/src/memory/mod.rs +++ b/core/src/memory/mod.rs @@ -6,6 +6,7 @@ mod trace; pub use columns::*; pub use global::*; +pub use local::*; pub use program::*; use serde::{Deserialize, Serialize}; diff --git a/core/src/stark/air.rs b/core/src/stark/air.rs index 433fcdcc10..4ade730c66 100644 --- a/core/src/stark/air.rs +++ b/core/src/stark/air.rs @@ -19,7 +19,7 @@ pub(crate) mod riscv_chips { pub use crate::alu::ShiftRightChip; pub use crate::bytes::ByteChip; pub use crate::cpu::CpuChip; - pub use crate::memory::MemoryChip; + pub use crate::memory::{MemoryChip, MemoryLocalChip}; pub use crate::program::ProgramChip; pub use crate::syscall::precompiles::edwards::EdAddAssignChip; pub use crate::syscall::precompiles::edwards::EdDecompressChip; @@ -66,9 +66,13 @@ pub enum RiscvAir { /// A lookup table for byte operations. ByteLookup(ByteChip), /// A table for initializing the memory state. - MemoryInit(MemoryChip), + MemoryGlobalInit(MemoryChip), /// A table for finalizing the memory state. - MemoryFinal(MemoryChip), + MemoryGlobalFinal(MemoryChip), + /// A table for initializing the memory state. + MemoryLocalInit(MemoryLocalChip), + /// A table for finalizing the memory state. + MemoryLocalFinal(MemoryLocalChip), /// A table for initializing the program memory. ProgramMemory(MemoryProgramChip), /// A precompile for sha256 extend. @@ -165,10 +169,14 @@ impl RiscvAir { chips.push(RiscvAir::ShiftLeft(shift_left)); let lt = LtChip::default(); chips.push(RiscvAir::Lt(lt)); - let memory_init = MemoryChip::new(MemoryChipType::Initialize); - chips.push(RiscvAir::MemoryInit(memory_init)); - let memory_finalize = MemoryChip::new(MemoryChipType::Finalize); - chips.push(RiscvAir::MemoryFinal(memory_finalize)); + let memory_global_init = MemoryChip::new(MemoryChipType::Initialize); + chips.push(RiscvAir::MemoryGlobalInit(memory_global_init)); + let memory_global_finalize = MemoryChip::new(MemoryChipType::Finalize); + chips.push(RiscvAir::MemoryGlobalFinal(memory_global_finalize)); + let memory_local_init = MemoryLocalChip::new(MemoryChipType::Initialize); + chips.push(RiscvAir::MemoryLocalInit(memory_local_init)); + let memory_local_finalize = MemoryLocalChip::new(MemoryChipType::Finalize); + chips.push(RiscvAir::MemoryLocalFinal(memory_local_finalize)); let program_memory_init = MemoryProgramChip::new(); chips.push(RiscvAir::ProgramMemory(program_memory_init)); let byte = ByteChip::default(); diff --git a/core/src/utils/prove.rs b/core/src/utils/prove.rs index e6e1ae3013..56a5744924 100644 --- a/core/src/utils/prove.rs +++ b/core/src/utils/prove.rs @@ -1,3 +1,4 @@ +use p3_matrix::Matrix; use std::collections::VecDeque; use std::fs::File; use std::io::Seek; @@ -349,10 +350,25 @@ where // Commit to each shard. let commitments = records - .into_par_iter() - .zip(traces.into_par_iter()) + .into_iter() + .zip(traces.into_iter()) .map(|(record, traces)| { let _span = span.enter(); + + // let chips = prover.machine().shard_chips(&record).collect::>(); + for (name, trace) in traces.clone() { + let trace_width = trace.width(); + let trace_height = trace.height(); + tracing::debug!( + "Phase 1 area: {:<15} | Main Cols = {:<5} | Rows = {:<5} | Cells = {:<10}", + name, + trace_width, + trace_height, + trace_width * trace_height, + ); + + } + let data = prover.commit(record, traces); let main_commit = data.main_commit.clone(); drop(data); diff --git a/examples/Cargo.lock b/examples/Cargo.lock index 7736faa6c4..40ffdf06d0 100644 --- a/examples/Cargo.lock +++ b/examples/Cargo.lock @@ -4809,7 +4809,7 @@ dependencies = [ [[package]] name = "sp1-build" -version = "1.1.0" +version = "1.1.1" dependencies = [ "anyhow", "cargo_metadata", @@ -4819,7 +4819,7 @@ dependencies = [ [[package]] name = "sp1-core" -version = "1.1.0" +version = "1.1.1" dependencies = [ "anyhow", "arrayref", @@ -4880,7 +4880,7 @@ dependencies = [ [[package]] name = "sp1-derive" -version = "1.1.0" +version = "1.1.1" dependencies = [ "proc-macro2", "quote", @@ -4889,7 +4889,7 @@ dependencies = [ [[package]] name = "sp1-helper" -version = "1.1.0" +version = "1.1.1" dependencies = [ "cargo_metadata", "chrono", @@ -4898,7 +4898,7 @@ dependencies = [ [[package]] name = "sp1-primitives" -version = "1.1.0" +version = "1.1.1" dependencies = [ "itertools 0.13.0", "lazy_static", @@ -4910,7 +4910,7 @@ dependencies = [ [[package]] name = "sp1-prover" -version = "1.1.0" +version = "1.1.1" dependencies = [ "anyhow", "bincode", @@ -4946,7 +4946,7 @@ dependencies = [ [[package]] name = "sp1-recursion-circuit" -version = "1.1.0" +version = "1.1.1" dependencies = [ "bincode", "itertools 0.13.0", @@ -4968,7 +4968,7 @@ dependencies = [ [[package]] name = "sp1-recursion-compiler" -version = "1.1.0" +version = "1.1.1" dependencies = [ "backtrace", "itertools 0.13.0", @@ -4992,7 +4992,7 @@ dependencies = [ [[package]] name = "sp1-recursion-core" -version = "1.1.0" +version = "1.1.1" dependencies = [ "arrayref", "backtrace", @@ -5026,7 +5026,7 @@ dependencies = [ [[package]] name = "sp1-recursion-derive" -version = "1.1.0" +version = "1.1.1" dependencies = [ "proc-macro2", "quote", @@ -5035,7 +5035,7 @@ dependencies = [ [[package]] name = "sp1-recursion-gnark-ffi" -version = "1.1.0" +version = "1.1.1" dependencies = [ "anyhow", "bincode", @@ -5059,7 +5059,7 @@ dependencies = [ [[package]] name = "sp1-recursion-program" -version = "1.1.0" +version = "1.1.1" dependencies = [ "itertools 0.13.0", "p3-air", @@ -5087,7 +5087,7 @@ dependencies = [ [[package]] name = "sp1-sdk" -version = "1.1.0" +version = "1.1.1" dependencies = [ "alloy-sol-types", "anyhow", diff --git a/examples/tendermint/program/Cargo.lock b/examples/tendermint/program/Cargo.lock index c6c0aea2ea..a5475b2fbe 100644 --- a/examples/tendermint/program/Cargo.lock +++ b/examples/tendermint/program/Cargo.lock @@ -573,7 +573,7 @@ checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" [[package]] name = "sp1-lib" -version = "1.1.0" +version = "1.1.1" dependencies = [ "anyhow", "bincode", @@ -583,7 +583,7 @@ dependencies = [ [[package]] name = "sp1-zkvm" -version = "1.1.0" +version = "1.1.1" dependencies = [ "bincode", "cfg-if", diff --git a/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf b/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf index 7e38cf4299..8353c16206 100755 Binary files a/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf and b/examples/tendermint/program/elf/riscv32im-succinct-zkvm-elf differ diff --git a/examples/tendermint/script/src/main.rs b/examples/tendermint/script/src/main.rs index 4184fadd0c..0b8a9d5e2d 100644 --- a/examples/tendermint/script/src/main.rs +++ b/examples/tendermint/script/src/main.rs @@ -29,10 +29,10 @@ async fn get_light_blocks() -> (LightBlock, LightBlock) { let latest_commit = fetch_latest_commit(&client, &url).await.unwrap(); let block: u64 = latest_commit.result.signed_header.header.height.into(); println!("Latest block: {}", block); - let light_block_1 = fetch_light_block(2279100, peer_id, BASE_URL) + let light_block_1 = fetch_light_block(2439100, peer_id, BASE_URL) .await .expect("Failed to generate light block 1"); - let light_block_2 = fetch_light_block(2279130, peer_id, BASE_URL) + let light_block_2 = fetch_light_block(2439130, peer_id, BASE_URL) .await .expect("Failed to generate light block 2"); (light_block_1, light_block_2)