Skip to content
This repository was archived by the owner on Oct 25, 2025. It is now read-only.
Closed
9 changes: 7 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ exclude = ["sdk"]
members = [
"circuits",
"cli",
"sdk-core-types",
"examples-builder",
"expr",
"node",
Expand Down
2 changes: 1 addition & 1 deletion circuits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ itertools = "0.12"
log = "0.4"
mozak-circuits-derive = { path = "./derive" }
mozak-runner = { path = "../runner" }
mozak-sdk = { path = "../sdk" }
plonky2 = { workspace = true, default-features = false }
plonky2_maybe_rayon = { workspace = true, default-features = false }
sdk-core-types = { path = "../sdk-core-types" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
starky = { workspace = true, default-features = false, features = ["std"] }
Expand Down
20 changes: 10 additions & 10 deletions circuits/src/cpu/ecall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use expr::Expr;
use itertools::izip;
use mozak_sdk::core::ecall;
use sdk_core_types::ecall_id;

use super::columns::CpuState;
use crate::expr::ConstraintBuilder;
Expand Down Expand Up @@ -51,7 +51,7 @@ pub(crate) fn halt_constraints<'a, P: Copy>(
// anywhere else.
// Enable only for halt !!!
cb.transition(lv.is_halt * (lv.inst.ops.ecall + nv.is_running - 1));
cb.always(lv.is_halt * (lv.op1_value - i64::from(ecall::HALT)));
cb.always(lv.is_halt * (lv.op1_value - i64::from(ecall_id::HALT)));

// We also need to make sure that the program counter is not changed by the
// 'halt' system call.
Expand All @@ -77,25 +77,25 @@ pub(crate) fn storage_device_constraints<'a, P: Copy>(
lv: &CpuState<Expr<'a, P>>,
cb: &mut ConstraintBuilder<Expr<'a, P>>,
) {
cb.always(lv.is_private_tape * (lv.op1_value - i64::from(ecall::PRIVATE_TAPE)));
cb.always(lv.is_public_tape * (lv.op1_value - i64::from(ecall::PUBLIC_TAPE)));
cb.always(lv.is_call_tape * (lv.op1_value - i64::from(ecall::CALL_TAPE)));
cb.always(lv.is_event_tape * (lv.op1_value - i64::from(ecall::EVENT_TAPE)));
cb.always(lv.is_private_tape * (lv.op1_value - i64::from(ecall_id::PRIVATE_TAPE)));
cb.always(lv.is_public_tape * (lv.op1_value - i64::from(ecall_id::PUBLIC_TAPE)));
cb.always(lv.is_call_tape * (lv.op1_value - i64::from(ecall_id::CALL_TAPE)));
cb.always(lv.is_event_tape * (lv.op1_value - i64::from(ecall_id::EVENT_TAPE)));
cb.always(
lv.is_events_commitment_tape * (lv.op1_value - i64::from(ecall::EVENTS_COMMITMENT_TAPE)),
lv.is_events_commitment_tape * (lv.op1_value - i64::from(ecall_id::EVENTS_COMMITMENT_TAPE)),
);
cb.always(
lv.is_cast_list_commitment_tape
* (lv.op1_value - i64::from(ecall::CAST_LIST_COMMITMENT_TAPE)),
* (lv.op1_value - i64::from(ecall_id::CAST_LIST_COMMITMENT_TAPE)),
);
cb.always(lv.is_self_prog_id_tape * (lv.op1_value - i64::from(ecall::SELF_PROG_ID_TAPE)));
cb.always(lv.is_self_prog_id_tape * (lv.op1_value - i64::from(ecall_id::SELF_PROG_ID_TAPE)));
}

pub(crate) fn poseidon2_constraints<'a, P: Copy>(
lv: &CpuState<Expr<'a, P>>,
cb: &mut ConstraintBuilder<Expr<'a, P>>,
) {
cb.always(lv.is_poseidon2 * (lv.op1_value - i64::from(ecall::POSEIDON2)));
cb.always(lv.is_poseidon2 * (lv.op1_value - i64::from(ecall_id::POSEIDON2)));
}

// We are already testing ecall halt with our coda of every `code::execute`.
6 changes: 3 additions & 3 deletions circuits/src/generation/cpu.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use expr::{Evaluator, ExprBuilder};
use itertools::{chain, Itertools};
use mozak_runner::instruction::{Instruction, Op};
use mozak_runner::reg_abi::REG_A0;
use mozak_runner::state::{Aux, State, StorageDeviceEntry, StorageDeviceOpcode};
use mozak_runner::vm::{ExecutionRecord, Row};
use mozak_sdk::core::ecall;
use mozak_sdk::core::reg_abi::REG_A0;
use plonky2::hash::hash_types::RichField;
use sdk_core_types::ecall_id;

use crate::bitshift::columns::Bitshift;
use crate::cpu::columns as cpu_cols;
Expand Down Expand Up @@ -110,7 +110,7 @@ pub fn generate_cpu_trace<F: RichField>(record: &ExecutionRecord<F>) -> Vec<CpuS
)),
is_halt: F::from_bool(matches!(
(inst.op, state.registers[usize::from(REG_A0)]),
(Op::ECALL, ecall::HALT)
(Op::ECALL, ecall_id::HALT)
)),
..CpuState::default()
};
Expand Down
2 changes: 1 addition & 1 deletion circuits/src/poseidon2_sponge/columns.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::ops::Add;

use itertools::izip;
use mozak_sdk::core::reg_abi::{REG_A1, REG_A2, REG_A3};
use mozak_runner::reg_abi::{REG_A1, REG_A2, REG_A3};
use plonky2::field::goldilocks_field::GoldilocksField;
use plonky2::hash::hash_types::NUM_HASH_OUT_ELTS;
use plonky2::hash::hashing::PlonkyPermutation;
Expand Down
4 changes: 2 additions & 2 deletions circuits/src/stark/recursive_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::marker::PhantomData;
use anyhow::Result;
use itertools::{zip_eq, Itertools};
use log::info;
use mozak_sdk::core::constants::DIGEST_BYTES;
use plonky2::field::extension::Extendable;
use plonky2::field::types::Field;
use plonky2::fri::witness_util::set_fri_proof_target;
Expand All @@ -22,6 +21,7 @@ use plonky2::plonk::config::{AlgebraicHasher, GenericConfig};
use plonky2::plonk::proof::{ProofWithPublicInputs, ProofWithPublicInputsTarget};
use plonky2::util::reducing::ReducingFactorTarget;
use plonky2::with_context;
use sdk_core_types::constants::poseidon2::DIGEST_BYTES;
use starky::config::StarkConfig;
use starky::constraint_consumer::RecursiveConstraintConsumer;
use starky::evaluation_frame::StarkEvaluationFrame;
Expand Down Expand Up @@ -654,12 +654,12 @@ mod tests {
use log::info;
use mozak_runner::code;
use mozak_runner::instruction::{Args, Instruction, Op};
use mozak_sdk::core::constants::DIGEST_BYTES;
use plonky2::field::goldilocks_field::GoldilocksField;
use plonky2::iop::witness::{PartialWitness, WitnessWrite};
use plonky2::plonk::circuit_builder::CircuitBuilder;
use plonky2::plonk::circuit_data::CircuitConfig;
use plonky2::util::timing::TimingTree;
use sdk_core_types::constants::poseidon2::DIGEST_BYTES;
use starky::config::StarkConfig;

use crate::stark::mozak_stark::{MozakStark, PublicInputs};
Expand Down
4 changes: 2 additions & 2 deletions circuits/src/storage_device/columns.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use core::ops::Add;

use mozak_sdk::core::constants::DIGEST_BYTES;
use mozak_sdk::core::reg_abi::REG_A1;
use mozak_runner::reg_abi::REG_A1;
use sdk_core_types::constants::poseidon2::DIGEST_BYTES;
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this look weird?


use crate::columns_view::{columns_view_impl, make_col_map, NumberOfColumns};
use crate::cross_table_lookup::{Column, ColumnWithTypedInput};
Expand Down
28 changes: 14 additions & 14 deletions circuits/src/storage_device/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ mod tests {
use mozak_runner::code::execute_code_with_ro_memory;
use mozak_runner::decode::ECALL;
use mozak_runner::instruction::{Args, Instruction, Op};
use mozak_runner::reg_abi::{REG_A0, REG_A1, REG_A2};
use mozak_runner::state::RawTapes;
use mozak_runner::test_utils::{u32_extra, u8_extra};
use mozak_sdk::core::constants::DIGEST_BYTES;
use mozak_sdk::core::ecall::{self};
use mozak_sdk::core::reg_abi::{REG_A0, REG_A1, REG_A2};
use plonky2::plonk::config::Poseidon2GoldilocksConfig;
use proptest::prelude::ProptestConfig;
use proptest::proptest;
use sdk_core_types::constants::poseidon2::DIGEST_BYTES;
use sdk_core_types::ecall_id;
use starky::stark_testing::test_stark_circuit_constraints;

use crate::stark::mozak_stark::MozakStark;
Expand All @@ -139,7 +139,7 @@ mod tests {
&[],
&[(address, 0)],
&[
(REG_A0, ecall::PRIVATE_TAPE),
(REG_A0, ecall_id::PRIVATE_TAPE),
(REG_A1, address), // A1 - address
(REG_A2, 0), // A2 - size
],
Expand All @@ -155,7 +155,7 @@ mod tests {
&[],
&[(address, 0)],
&[
(REG_A0, ecall::PUBLIC_TAPE),
(REG_A0, ecall_id::PUBLIC_TAPE),
(REG_A1, address), // A1 - address
(REG_A2, 0), // A2 - size
],
Expand All @@ -171,7 +171,7 @@ mod tests {
&[],
&[(address, 0)],
&[
(REG_A0, ecall::CALL_TAPE),
(REG_A0, ecall_id::CALL_TAPE),
(REG_A1, address), // A1 - address
(REG_A2, 0), // A2 - size
],
Expand All @@ -187,7 +187,7 @@ mod tests {
&[],
&[(address, 0)],
&[
(REG_A0, ecall::EVENT_TAPE),
(REG_A0, ecall_id::EVENT_TAPE),
(REG_A1, address), // A1 - address
(REG_A2, 0), // A2 - size
],
Expand All @@ -203,7 +203,7 @@ mod tests {
&[],
&[(address, 0)],
&[
(REG_A0, ecall::PRIVATE_TAPE),
(REG_A0, ecall_id::PRIVATE_TAPE),
(REG_A1, address), // A1 - address
(REG_A2, 1), // A2 - size
],
Expand All @@ -228,7 +228,7 @@ mod tests {
&[],
&[(address, 0)],
&[
(REG_A0, ecall::PUBLIC_TAPE),
(REG_A0, ecall_id::PUBLIC_TAPE),
(REG_A1, address), // A1 - address
(REG_A2, 1), // A2 - size
],
Expand All @@ -254,7 +254,7 @@ mod tests {
&[],
&[(address, 0)],
&[
(REG_A0, ecall::CALL_TAPE),
(REG_A0, ecall_id::CALL_TAPE),
(REG_A1, address), // A1 - address
(REG_A2, 1), // A2 - size
],
Expand All @@ -278,7 +278,7 @@ mod tests {
&[],
&[(address, 0)],
&[
(REG_A0, ecall::EVENT_TAPE),
(REG_A0, ecall_id::EVENT_TAPE),
(REG_A1, address), // A1 - address
(REG_A2, 1), // A2 - size
],
Expand Down Expand Up @@ -307,7 +307,7 @@ mod tests {
.map(|i| (address.wrapping_add(u32::try_from(i).unwrap()), 0_u8))
.collect_vec(),
&[
(REG_A0, ecall::EVENTS_COMMITMENT_TAPE),
(REG_A0, ecall_id::EVENTS_COMMITMENT_TAPE),
(REG_A1, address), // A1 - address
(REG_A2, u32::try_from(DIGEST_BYTES).unwrap()), // A2 - size
],
Expand Down Expand Up @@ -338,7 +338,7 @@ mod tests {
.map(|i| (address.wrapping_add(u32::try_from(i).unwrap()), 0_u8))
.collect_vec(),
&[
(REG_A0, ecall::CAST_LIST_COMMITMENT_TAPE),
(REG_A0, ecall_id::CAST_LIST_COMMITMENT_TAPE),
(REG_A1, address), // A1 - address
(REG_A2, u32::try_from(DIGEST_BYTES).unwrap()), // A2 - size
],
Expand Down Expand Up @@ -382,7 +382,7 @@ mod tests {
op: Op::ADD,
args: Args {
rd: REG_A0,
imm: ecall::PRIVATE_TAPE,
imm: ecall_id::PRIVATE_TAPE,
..Args::default()
},
},
Expand Down
2 changes: 1 addition & 1 deletion circuits/src/tape_commitments/columns.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use mozak_sdk::core::constants::DIGEST_BYTES;
use sdk_core_types::constants::poseidon2::DIGEST_BYTES;

use crate::columns_view::{columns_view_impl, make_col_map};
use crate::linear_combination::Column;
Expand Down
10 changes: 5 additions & 5 deletions circuits/src/tape_commitments/stark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ mod tests {
use mozak_runner::code;
use mozak_runner::decode::ECALL;
use mozak_runner::instruction::{Args, Instruction, Op};
use mozak_runner::reg_abi::{REG_A0, REG_A1, REG_A2};
use mozak_runner::state::RawTapes;
use mozak_sdk::core::constants::DIGEST_BYTES;
use mozak_sdk::core::ecall::{self};
use mozak_sdk::core::reg_abi::{REG_A0, REG_A1, REG_A2};
use plonky2::field::types::Field;
use plonky2::plonk::circuit_data::CircuitConfig;
use plonky2::plonk::config::{GenericConfig, Poseidon2GoldilocksConfig};
use plonky2::util::timing::TimingTree;
use rand::Rng;
use sdk_core_types::constants::poseidon2::DIGEST_BYTES;
use sdk_core_types::ecall_id;
use starky::config::StarkConfig;
use starky::stark_testing::test_stark_circuit_constraints;

Expand Down Expand Up @@ -147,12 +147,12 @@ mod tests {
]
}
let code_ecall_cast_list_commitment_tape = read_ecall_code(
ecall::CAST_LIST_COMMITMENT_TAPE,
ecall_id::CAST_LIST_COMMITMENT_TAPE,
CAST_LIST_COMMITMENT_ADDRESS,
DIGEST_BYTES,
);
let code_ecall_events_commitment_tape = read_ecall_code(
ecall::EVENTS_COMMITMENT_TAPE,
ecall_id::EVENTS_COMMITMENT_TAPE,
EVENTS_COMMITMENT_ADDRESS,
DIGEST_BYTES,
);
Expand Down
6 changes: 3 additions & 3 deletions circuits/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ use mozak_runner::code;
use mozak_runner::decode::ECALL;
use mozak_runner::elf::Program;
use mozak_runner::instruction::{Args, Instruction, Op};
use mozak_runner::reg_abi::{REG_A0, REG_A1, REG_A2, REG_A3};
use mozak_runner::vm::ExecutionRecord;
use mozak_sdk::core::ecall;
use mozak_sdk::core::reg_abi::{REG_A0, REG_A1, REG_A2, REG_A3};
use plonky2::field::goldilocks_field::GoldilocksField;
use plonky2::field::types::Field;
use plonky2::fri::FriConfig;
Expand All @@ -18,6 +17,7 @@ use plonky2::plonk::circuit_data::CircuitConfig;
use plonky2::plonk::config::{GenericConfig, Hasher, Poseidon2GoldilocksConfig};
use plonky2::util::log2_ceil;
use plonky2::util::timing::TimingTree;
use sdk_core_types::ecall_id;
use starky::config::StarkConfig;
use starky::prover::prove as prove_table;
use starky::stark::Stark;
Expand Down Expand Up @@ -523,7 +523,7 @@ pub fn create_poseidon2_test(
op: Op::ADD,
args: Args {
rd: REG_A0,
imm: ecall::POSEIDON2,
imm: ecall_id::POSEIDON2,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We moved from ecall_id -> ecall -> ecall_id again

..Args::default()
},
},
Expand Down
5 changes: 5 additions & 0 deletions examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading