Skip to content
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Cargo.lock
**/.env
.DS_Store

# Log outputs
*.log

.cache/
rustc-*

Expand Down
6 changes: 3 additions & 3 deletions crates/sdk/src/prover/agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ where
E: StarkFriEngine<SC = SC>,
NativeBuilder: VmBuilder<E, VmConfig = NativeConfig>,
{
leaf_prover: VmInstance<E, NativeBuilder>,
leaf_controller: LeafProvingController,
pub leaf_prover: VmInstance<E, NativeBuilder>,
pub leaf_controller: LeafProvingController,

pub internal_prover: VmInstance<E, NativeBuilder>,
#[cfg(feature = "evm-prove")]
root_prover: RootVerifierLocalProver,
pub root_prover: RootVerifierLocalProver,
pub num_children_internal: usize,
pub max_internal_wrapper_layers: usize,
}
Expand Down
20 changes: 19 additions & 1 deletion extensions/native/circuit/src/extension/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ use openvm_instructions::{program::DEFAULT_PC_STEP, LocalOpcode, PhantomDiscrimi
use openvm_native_compiler::{
CastfOpcode, FieldArithmeticOpcode, FieldExtensionOpcode, FriOpcode, NativeBranchEqualOpcode,
NativeJalOpcode, NativeLoadStore4Opcode, NativeLoadStoreOpcode, NativePhantom,
NativeRangeCheckOpcode, Poseidon2Opcode, VerifyBatchOpcode, BLOCK_LOAD_STORE_SIZE,
NativeRangeCheckOpcode, Poseidon2Opcode, SumcheckOpcode, VerifyBatchOpcode,
BLOCK_LOAD_STORE_SIZE,
};
use openvm_poseidon2_air::Poseidon2Config;
use openvm_rv32im_circuit::BranchEqualCoreAir;
Expand Down Expand Up @@ -61,6 +62,10 @@ use crate::{
chip::{NativePoseidon2Executor, NativePoseidon2Filler},
NativePoseidon2Chip,
},
sumcheck::{
air::NativeSumcheckAir,
chip::{NativeSumcheckChip, NativeSumcheckExecutor, NativeSumcheckFiller},
},
};

cfg_if::cfg_if! {
Expand Down Expand Up @@ -94,6 +99,7 @@ pub enum NativeExecutor<F: Field> {
FieldExtension(FieldExtensionExecutor),
FriReducedOpening(FriReducedOpeningExecutor),
VerifyBatch(NativePoseidon2Executor<F, 1>),
TowerVerify(NativeSumcheckExecutor),
}

impl<F: PrimeField32> VmExecutionExtension<F> for Native {
Expand Down Expand Up @@ -169,6 +175,12 @@ impl<F: PrimeField32> VmExecutionExtension<F> for Native {
],
)?;

let tower_verify = NativeSumcheckExecutor::new();
inventory.add_executor(
tower_verify,
[SumcheckOpcode::SUMCHECK_LAYER_EVAL.global_opcode()],
)?;

inventory.add_phantom_sub_executor(
NativeHintInputSubEx,
PhantomDiscriminant(NativePhantom::HintInput as u16),
Expand Down Expand Up @@ -262,6 +274,9 @@ where
);
inventory.add_air(verify_batch);

let tower_evaluate = NativeSumcheckAir::new(exec_bridge, memory_bridge);
inventory.add_air(tower_evaluate);

Ok(())
}
}
Expand Down Expand Up @@ -342,6 +357,9 @@ where
);
inventory.add_executor_chip(poseidon2);

let tower_verify = NativeSumcheckChip::new(NativeSumcheckFiller::new(), mem_helper.clone());
inventory.add_executor_chip(tower_verify);

Ok(())
}
}
Expand Down
4 changes: 2 additions & 2 deletions extensions/native/circuit/src/field_extension/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,10 @@ pub(crate) struct FieldExtension;
impl FieldExtension {
pub(crate) fn add<V, E>(x: [V; EXT_DEG], y: [V; EXT_DEG]) -> [E; EXT_DEG]
where
V: Copy,
V: Clone,
V: Add<V, Output = E>,
{
array::from_fn(|i| x[i] + y[i])
array::from_fn(|i| x[i].clone() + y[i].clone())
}

pub(crate) fn subtract<V, E>(x: [V; EXT_DEG], y: [V; EXT_DEG]) -> [E; EXT_DEG]
Expand Down
2 changes: 1 addition & 1 deletion extensions/native/circuit/src/fri/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ fn assert_array_eq<AB: AirBuilder, I1: Into<AB::Expr>, I2: Into<AB::Expr>, const
}
}

fn elem_to_ext<F: Field>(elem: F) -> [F; EXT_DEG] {
pub fn elem_to_ext<F: Field>(elem: F) -> [F; EXT_DEG] {
let mut ret = [F::ZERO; EXT_DEG];
ret[0] = elem;
ret
Expand Down
2 changes: 2 additions & 0 deletions extensions/native/circuit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ mod fri;
mod jal_rangecheck;
mod loadstore;
mod poseidon2;
mod sumcheck;

mod extension;
pub use extension::*;
pub use field_extension::EXT_DEG;

mod utils;
#[cfg(any(test, feature = "test-utils"))]
Expand Down
41 changes: 11 additions & 30 deletions extensions/native/circuit/src/poseidon2/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ use std::borrow::{Borrow, BorrowMut};
use openvm_circuit::{
arch::*,
system::{
memory::{offline_checker::MemoryBaseAuxCols, online::TracingMemory, MemoryAuxColsFactory},
native_adapter::util::{
memory_read_native, tracing_read_native, tracing_write_native_inplace,
},
memory::{online::TracingMemory, MemoryAuxColsFactory},
native_adapter::util::{memory_read_native, tracing_write_native_inplace},
},
};
use openvm_instructions::{instruction::Instruction, program::DEFAULT_PC_STEP, LocalOpcode};
Expand All @@ -23,12 +21,16 @@ use openvm_stark_backend::{
p3_maybe_rayon::prelude::{IntoParallelIterator, ParallelSliceMut, *},
};

use crate::poseidon2::{
columns::{
InsideRowSpecificCols, MultiObserveCols, NativePoseidon2Cols, SimplePoseidonSpecificCols,
TopLevelSpecificCols,
use crate::{
mem_fill_helper,
poseidon2::{
columns::{
InsideRowSpecificCols, MultiObserveCols, NativePoseidon2Cols,
SimplePoseidonSpecificCols, TopLevelSpecificCols,
},
CHUNK,
},
CHUNK,
tracing_read_native_helper,
};

#[derive(Clone)]
Expand Down Expand Up @@ -1240,24 +1242,3 @@ impl<F: PrimeField32, const SBOX_REGISTERS: usize> NativePoseidon2Filler<F, SBOX
&inner.ending_full_rounds.last().unwrap().post
}
}

fn tracing_read_native_helper<F: PrimeField32, const BLOCK_SIZE: usize>(
memory: &mut TracingMemory,
ptr: u32,
base_aux: &mut MemoryBaseAuxCols<F>,
) -> [F; BLOCK_SIZE] {
let mut prev_ts = 0;
let ret = tracing_read_native(memory, ptr, &mut prev_ts);
base_aux.set_prev(F::from_canonical_u32(prev_ts));
ret
}

/// Fill `MemoryBaseAuxCols`, assuming that the `prev_timestamp` is already set in `base_aux`.
fn mem_fill_helper<F: PrimeField32>(
mem_helper: &MemoryAuxColsFactory<F>,
timestamp: u32,
base_aux: &mut MemoryBaseAuxCols<F>,
) {
let prev_ts = base_aux.prev_timestamp.as_canonical_u32();
mem_helper.fill(prev_ts, timestamp, base_aux);
}
Loading
Loading