diff --git a/Cargo.lock b/Cargo.lock index f1b68e2ef..73f395cc9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -924,11 +924,11 @@ dependencies = [ "log", "mozak-circuits-derive", "mozak-runner", - "mozak-sdk", "plonky2", "plonky2_maybe_rayon", "proptest", "rand", + "sdk-core-types", "serde", "serde_json", "starky", @@ -1022,9 +1022,9 @@ dependencies = [ "log", "mimalloc", "mozak-examples", - "mozak-sdk", "plonky2", "proptest", + "sdk-core-types", "serde", "serde_json", "test-case", @@ -1042,6 +1042,7 @@ dependencies = [ "rand_chacha", "rkyv", "rkyv_derive", + "sdk-core-types", "serde", "serde-hex", "serde_json", @@ -1533,6 +1534,10 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sdk-core-types" +version = "0.1.0" + [[package]] name = "serde" version = "1.0.201" diff --git a/Cargo.toml b/Cargo.toml index c8a0014ba..42fe9bfd0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ exclude = ["sdk"] members = [ "circuits", "cli", + "sdk-core-types", "examples-builder", "expr", "node", diff --git a/circuits/Cargo.toml b/circuits/Cargo.toml index 74efdb20d..cf5dfdc68 100644 --- a/circuits/Cargo.toml +++ b/circuits/Cargo.toml @@ -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"] } diff --git a/circuits/src/cpu/ecall.rs b/circuits/src/cpu/ecall.rs index ae1a2b7cc..54d5cb2c6 100644 --- a/circuits/src/cpu/ecall.rs +++ b/circuits/src/cpu/ecall.rs @@ -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; @@ -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. @@ -77,25 +77,25 @@ pub(crate) fn storage_device_constraints<'a, P: Copy>( lv: &CpuState>, cb: &mut ConstraintBuilder>, ) { - 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>, cb: &mut ConstraintBuilder>, ) { - 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`. diff --git a/circuits/src/generation/cpu.rs b/circuits/src/generation/cpu.rs index 8e1719b07..1d8a0d9f7 100644 --- a/circuits/src/generation/cpu.rs +++ b/circuits/src/generation/cpu.rs @@ -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; @@ -110,7 +110,7 @@ pub fn generate_cpu_trace(record: &ExecutionRecord) -> Vec(raw_id: u32) -> &'a str { + match raw_id { + ecall_id::HALT => "halt", + ecall_id::PANIC => "panic", + ecall_id::PUBLIC_TAPE => "ioread public tape", + ecall_id::POSEIDON2 => "poseidon2", + ecall_id::PRIVATE_TAPE => "ioread private tape", + ecall_id::CALL_TAPE => "ioread call tape", + ecall_id::EVENT_TAPE => "ioread event tape", + ecall_id::EVENTS_COMMITMENT_TAPE => "ioread events commitment tape", + ecall_id::CAST_LIST_COMMITMENT_TAPE => "ioread cast list commitment tape", + ecall_id::SELF_PROG_ID_TAPE => "self prog id tape", + ecall_id::VM_TRACE_LOG => "vm trace log", + _ => "", + } +} + +use crate::reg_abi::{REG_A0, REG_A1, REG_A2}; use crate::state::{read_bytes, Aux, State, StorageDeviceEntry, StorageDeviceOpcode}; impl State { @@ -134,23 +152,24 @@ impl State { pub fn ecall(self) -> (Aux, Self) { log::trace!( "ecall '{}' at clk: {}", - ecall::log(self.get_register_value(REG_A0)), + log(self.get_register_value(REG_A0)), self.clk ); match self.get_register_value(REG_A0) { - ecall::HALT => self.ecall_halt(), - ecall::PRIVATE_TAPE => self.ecall_read(StorageDeviceOpcode::StorePrivate), - ecall::PUBLIC_TAPE => self.ecall_read(StorageDeviceOpcode::StorePublic), - ecall::CALL_TAPE => self.ecall_read(StorageDeviceOpcode::StoreCallTape), - ecall::EVENT_TAPE => self.ecall_read(StorageDeviceOpcode::StoreEventTape), - ecall::EVENTS_COMMITMENT_TAPE => + ecall_id::HALT => self.ecall_halt(), + ecall_id::PRIVATE_TAPE => self.ecall_read(StorageDeviceOpcode::StorePrivate), + ecall_id::PUBLIC_TAPE => self.ecall_read(StorageDeviceOpcode::StorePublic), + ecall_id::CALL_TAPE => self.ecall_read(StorageDeviceOpcode::StoreCallTape), + ecall_id::EVENT_TAPE => self.ecall_read(StorageDeviceOpcode::StoreEventTape), + ecall_id::EVENTS_COMMITMENT_TAPE => self.ecall_read(StorageDeviceOpcode::StoreEventsCommitmentTape), - ecall::CAST_LIST_COMMITMENT_TAPE => + ecall_id::CAST_LIST_COMMITMENT_TAPE => self.ecall_read(StorageDeviceOpcode::StoreCastListCommitmentTape), - ecall::SELF_PROG_ID_TAPE => self.ecall_read(StorageDeviceOpcode::StoreSelfProgIdTape), - ecall::PANIC => self.ecall_panic(), - ecall::POSEIDON2 => self.ecall_poseidon2(), - ecall::VM_TRACE_LOG => self.ecall_trace_log(), + ecall_id::SELF_PROG_ID_TAPE => + self.ecall_read(StorageDeviceOpcode::StoreSelfProgIdTape), + ecall_id::PANIC => self.ecall_panic(), + ecall_id::POSEIDON2 => self.ecall_poseidon2(), + ecall_id::VM_TRACE_LOG => self.ecall_trace_log(), _ => (Aux::default(), self.bump_pc()), } } diff --git a/runner/src/lib.rs b/runner/src/lib.rs index ea4279164..ae143603a 100644 --- a/runner/src/lib.rs +++ b/runner/src/lib.rs @@ -15,6 +15,7 @@ pub mod ecall; pub mod elf; pub mod instruction; pub mod poseidon2; +pub mod reg_abi; pub mod state; #[cfg(any(feature = "test", test))] pub mod test_utils; diff --git a/runner/src/poseidon2.rs b/runner/src/poseidon2.rs index c87cfeadf..d132d3b23 100644 --- a/runner/src/poseidon2.rs +++ b/runner/src/poseidon2.rs @@ -1,13 +1,13 @@ use std::iter::repeat; use itertools::{chain, izip}; -use mozak_sdk::core::constants::DIGEST_BYTES; -use mozak_sdk::core::reg_abi::{REG_A1, REG_A2, REG_A3}; use plonky2::hash::hash_types::{HashOut, RichField, NUM_HASH_OUT_ELTS}; use plonky2::hash::hashing::PlonkyPermutation; use plonky2::hash::poseidon2::{Poseidon2Permutation, WIDTH}; use plonky2::plonk::config::GenericHashOut; +use sdk_core_types::constants::poseidon2::DIGEST_BYTES; +use crate::reg_abi::{REG_A1, REG_A2, REG_A3}; use crate::state::{Aux, State}; #[derive(Debug, Clone, Default)] diff --git a/sdk/src/core/reg_abi.rs b/runner/src/reg_abi.rs similarity index 100% rename from sdk/src/core/reg_abi.rs rename to runner/src/reg_abi.rs diff --git a/runner/src/state.rs b/runner/src/state.rs index d4362e9bd..5d306a74d 100644 --- a/runner/src/state.rs +++ b/runner/src/state.rs @@ -7,8 +7,8 @@ use derive_more::{Deref, Display}; use im::hashmap::HashMap; use im::HashSet; use log::trace; -use mozak_sdk::core::constants::DIGEST_BYTES; use plonky2::hash::hash_types::RichField; +use sdk_core_types::constants::poseidon2::DIGEST_BYTES; use serde::{Deserialize, Serialize}; use crate::code::Code; diff --git a/sdk-core-types/Cargo.toml b/sdk-core-types/Cargo.toml new file mode 100644 index 000000000..cf352170e --- /dev/null +++ b/sdk-core-types/Cargo.toml @@ -0,0 +1,10 @@ +[package] +categories = ["development-tools", "zk"] +description = "Provides types for used by sdk::core" +edition = "2021" +keywords = ["sdk", "types"] +license = "Apache-2.0" +name = "sdk-core-types" +readme = "README.md" +repository = "https://github.com/0xmozak/mozak-node/sdk-core-types" +version = "0.1.0" diff --git a/sdk-core-types/src/constants.rs b/sdk-core-types/src/constants.rs new file mode 100644 index 000000000..ce361068f --- /dev/null +++ b/sdk-core-types/src/constants.rs @@ -0,0 +1,8 @@ +pub mod poseidon2 { + /// The size of a `Poseidon2Hash` digest in bytes. + pub const DIGEST_BYTES: usize = 32; + + /// `RATE` of `Poseidon2Permutation` we use + #[allow(dead_code)] + pub const RATE: usize = 8; +} diff --git a/sdk-core-types/src/ecall_id.rs b/sdk-core-types/src/ecall_id.rs new file mode 100644 index 000000000..521d58878 --- /dev/null +++ b/sdk-core-types/src/ecall_id.rs @@ -0,0 +1,12 @@ +pub const HALT: u32 = 0; +pub const PANIC: u32 = 1; +pub const PRIVATE_TAPE: u32 = 2; +pub const POSEIDON2: u32 = 3; +pub const PUBLIC_TAPE: u32 = 4; +pub const CALL_TAPE: u32 = 5; +pub const EVENT_TAPE: u32 = 6; +pub const EVENTS_COMMITMENT_TAPE: u32 = 7; +pub const CAST_LIST_COMMITMENT_TAPE: u32 = 8; +pub const SELF_PROG_ID_TAPE: u32 = 9; +/// Syscall to output the VM trace log at `clk`. Useful for debugging. +pub const VM_TRACE_LOG: u32 = 10; diff --git a/sdk-core-types/src/lib.rs b/sdk-core-types/src/lib.rs new file mode 100644 index 000000000..78e6fbe5a --- /dev/null +++ b/sdk-core-types/src/lib.rs @@ -0,0 +1,4 @@ +#![cfg_attr(target_os = "mozakvm", no_std)] + +pub mod constants; +pub mod ecall_id; diff --git a/sdk/Cargo.lock b/sdk/Cargo.lock index 9b6115790..14f2351a3 100644 --- a/sdk/Cargo.lock +++ b/sdk/Cargo.lock @@ -188,6 +188,7 @@ dependencies = [ "rand_chacha", "rkyv", "rkyv_derive", + "sdk-core-types", "serde", "serde-hex", "serde_json", @@ -455,6 +456,10 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "sdk-core-types" +version = "0.1.0" + [[package]] name = "serde" version = "1.0.201" diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 640617f28..6065128b2 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -16,6 +16,7 @@ itertools = { version = "0.12", default-features = false } once_cell = { version = "1.19", default-features = false, features = ["race"] } rkyv = { version = "=0.8.0-alpha.1", default-features = false, features = ["pointer_width_32", "alloc"] } rkyv_derive = "=0.8.0-alpha.1" +sdk-core-types = { path = "../sdk-core-types" } slice-group-by = { version = "0.3", default-features = false, features = ["nightly"] } [target.'cfg(not(target_os="mozakvm"))'.dependencies] diff --git a/sdk/src/common/merkle.rs b/sdk/src/common/merkle.rs index 8dd83cd34..f601c991d 100644 --- a/sdk/src/common/merkle.rs +++ b/sdk/src/common/merkle.rs @@ -48,10 +48,10 @@ fn merkleize_group(mut group: Vec) -> Option { #[cfg(test)] mod tests { use itertools::chain; + use sdk_core_types::constants::poseidon2::DIGEST_BYTES; use crate::common::merkle::merkleize; use crate::common::types::Poseidon2Hash; - use crate::core::constants::DIGEST_BYTES; use crate::native::helpers::poseidon2_hash_no_pad; #[test] diff --git a/sdk/src/common/system.rs b/sdk/src/common/system.rs index 68a067cfc..d33e2ebf3 100644 --- a/sdk/src/common/system.rs +++ b/sdk/src/common/system.rs @@ -5,13 +5,13 @@ use { crate::common::types::{ CanonicalOrderedTemporalHints, CrossProgramCall, Poseidon2Hash, ProgramIdentifier, }, - crate::core::constants::DIGEST_BYTES, crate::core::ecall::{ call_tape_read, event_tape_read, ioread_private, ioread_public, self_prog_id_tape_read, }, core::ptr::slice_from_raw_parts, rkyv::rancor::{Panic, Strategy}, rkyv::Deserialize, + sdk_core_types::constants::poseidon2::DIGEST_BYTES, std::collections::BTreeSet, }; #[cfg(not(target_os = "mozakvm"))] diff --git a/sdk/src/common/types/poseidon2hash.rs b/sdk/src/common/types/poseidon2hash.rs index 31b4a00bd..14cce0cef 100644 --- a/sdk/src/common/types/poseidon2hash.rs +++ b/sdk/src/common/types/poseidon2hash.rs @@ -1,8 +1,7 @@ +use sdk_core_types::constants::poseidon2::DIGEST_BYTES; #[cfg(not(target_os = "mozakvm"))] use serde_hex::{SerHex, StrictPfx}; -use crate::core::constants::DIGEST_BYTES; - #[derive( Clone, Copy, diff --git a/sdk/src/common/types/program_identifier.rs b/sdk/src/common/types/program_identifier.rs index f67105ab3..f0a59f4f8 100644 --- a/sdk/src/common/types/program_identifier.rs +++ b/sdk/src/common/types/program_identifier.rs @@ -1,4 +1,5 @@ -use crate::core::constants::DIGEST_BYTES; +use sdk_core_types::constants::poseidon2::DIGEST_BYTES; + #[cfg(target_os = "mozakvm")] use crate::mozakvm::helpers::poseidon2_hash_with_pad; #[cfg(not(target_os = "mozakvm"))] diff --git a/sdk/src/core/ecall.rs b/sdk/src/core/ecall.rs index 681bf7309..16179c622 100644 --- a/sdk/src/core/ecall.rs +++ b/sdk/src/core/ecall.rs @@ -2,45 +2,16 @@ use core::arch::asm; #[cfg(target_os = "mozakvm")] -use crate::core::constants::DIGEST_BYTES; - -pub const HALT: u32 = 0; -pub const PANIC: u32 = 1; -pub const PRIVATE_TAPE: u32 = 2; -pub const POSEIDON2: u32 = 3; -pub const PUBLIC_TAPE: u32 = 4; -pub const CALL_TAPE: u32 = 5; -pub const EVENT_TAPE: u32 = 6; -pub const EVENTS_COMMITMENT_TAPE: u32 = 7; -pub const CAST_LIST_COMMITMENT_TAPE: u32 = 8; -pub const SELF_PROG_ID_TAPE: u32 = 9; -/// Syscall to output the VM trace log at `clk`. Useful for debugging. -pub const VM_TRACE_LOG: u32 = 10; - -#[must_use] -pub fn log<'a>(raw_id: u32) -> &'a str { - match raw_id { - HALT => "halt", - PANIC => "panic", - PUBLIC_TAPE => "ioread public tape", - POSEIDON2 => "poseidon2", - PRIVATE_TAPE => "ioread private tape", - CALL_TAPE => "ioread call tape", - EVENT_TAPE => "ioread event tape", - EVENTS_COMMITMENT_TAPE => "ioread events commitment tape", - CAST_LIST_COMMITMENT_TAPE => "ioread cast list commitment tape", - SELF_PROG_ID_TAPE => "self prog id tape", - VM_TRACE_LOG => "vm trace log", - _ => "", - } -} +use sdk_core_types::constants::poseidon2::DIGEST_BYTES; +#[cfg(target_os = "mozakvm")] +use sdk_core_types::ecall_id; #[cfg(target_os = "mozakvm")] pub fn poseidon2(input_ptr: *const u8, input_len: usize, output_ptr: *mut u8) { unsafe { core::arch::asm!( "ecall", - in ("a0") POSEIDON2, + in ("a0") ecall_id::POSEIDON2, in ("a1") input_ptr, in ("a2") input_len, in ("a3") output_ptr, @@ -53,7 +24,7 @@ pub fn ioread_private(buf_ptr: *mut u8, buf_len: usize) { unsafe { core::arch::asm!( "ecall", - in ("a0") PRIVATE_TAPE, + in ("a0") ecall_id::PRIVATE_TAPE, in ("a1") buf_ptr, in ("a2") buf_len, ); @@ -65,7 +36,7 @@ pub fn ioread_public(buf_ptr: *mut u8, buf_len: usize) { unsafe { core::arch::asm!( "ecall", - in ("a0") PUBLIC_TAPE, + in ("a0") ecall_id::PUBLIC_TAPE, in ("a1") buf_ptr, in ("a2") buf_len, ); @@ -77,7 +48,7 @@ pub fn call_tape_read(buf_ptr: *mut u8, buf_len: usize) { unsafe { core::arch::asm!( "ecall", - in ("a0") CALL_TAPE, + in ("a0") ecall_id::CALL_TAPE, in ("a1") buf_ptr, in ("a2") buf_len, ); @@ -89,7 +60,7 @@ pub fn event_tape_read(buf_ptr: *mut u8, buf_len: usize) { unsafe { core::arch::asm!( "ecall", - in ("a0") EVENT_TAPE, + in ("a0") ecall_id::EVENT_TAPE, in ("a1") buf_ptr, in ("a2") buf_len, ); @@ -101,7 +72,7 @@ pub fn events_commitment_tape_read(buf_ptr: *mut u8) { unsafe { core::arch::asm!( "ecall", - in ("a0") EVENTS_COMMITMENT_TAPE, + in ("a0") ecall_id::EVENTS_COMMITMENT_TAPE, in ("a1") buf_ptr, in ("a2") DIGEST_BYTES, ); @@ -113,7 +84,7 @@ pub fn cast_list_commitment_tape_read(buf_ptr: *mut u8) { unsafe { core::arch::asm!( "ecall", - in ("a0") CAST_LIST_COMMITMENT_TAPE, + in ("a0") ecall_id::CAST_LIST_COMMITMENT_TAPE, in ("a1") buf_ptr, in ("a2") DIGEST_BYTES, ); @@ -125,7 +96,7 @@ pub fn self_prog_id_tape_read(buf_ptr: *mut u8) { unsafe { core::arch::asm!( "ecall", - in ("a0") SELF_PROG_ID_TAPE, + in ("a0") ecall_id::SELF_PROG_ID_TAPE, in ("a1") buf_ptr, in ("a2") DIGEST_BYTES, ); @@ -137,7 +108,7 @@ pub fn panic(msg_ptr: *const u8, msg_len: usize) { unsafe { core::arch::asm!( "ecall", - in ("a0") PANIC, + in ("a0") ecall_id::PANIC, in ("a1") msg_len, in ("a2") msg_ptr, ); @@ -149,7 +120,7 @@ pub fn trace(msg_ptr: *const u8, msg_len: usize) { unsafe { core::arch::asm!( "ecall", - in ("a0") VM_TRACE_LOG, + in ("a0") ecall_id::VM_TRACE_LOG, in ("a1") msg_len, in ("a2") msg_ptr, ); @@ -161,7 +132,7 @@ pub fn halt(output: u8) { unsafe { asm!( "ecall", - in ("a0") HALT, + in ("a0") ecall_id::HALT, in ("a1") output, ); unreachable!(); diff --git a/sdk/src/core/mod.rs b/sdk/src/core/mod.rs index cc419024c..4e71ead04 100644 --- a/sdk/src/core/mod.rs +++ b/sdk/src/core/mod.rs @@ -2,16 +2,6 @@ mod alloc; pub mod ecall; pub mod env; -pub mod reg_abi; - -pub mod constants { - /// The size of a `Poseidon2Hash` digest in bytes. - pub const DIGEST_BYTES: usize = 32; - - /// `RATE` of `Poseidon2Permutation` we use - #[allow(dead_code)] - pub const RATE: usize = 8; -} #[macro_export] macro_rules! entry { diff --git a/sdk/src/mozakvm/helpers.rs b/sdk/src/mozakvm/helpers.rs index fd8bd432f..57839d9f5 100644 --- a/sdk/src/mozakvm/helpers.rs +++ b/sdk/src/mozakvm/helpers.rs @@ -1,7 +1,8 @@ // This file contains code snippets used in mozakvm execution +use sdk_core_types::constants::poseidon2::{DIGEST_BYTES, RATE}; + use crate::common::types::Poseidon2Hash; -use crate::core::constants::{DIGEST_BYTES, RATE}; /// Hashes the input slice to `Poseidon2Hash` after padding. /// We use the well known "Bit padding scheme". diff --git a/sdk/src/mozakvm/inputtape.rs b/sdk/src/mozakvm/inputtape.rs index 17b979f4d..3882aacec 100644 --- a/sdk/src/mozakvm/inputtape.rs +++ b/sdk/src/mozakvm/inputtape.rs @@ -1,6 +1,6 @@ use core::ops::{Deref, DerefMut}; -use crate::core::ecall; +use sdk_core_types::ecall_id; #[derive(Default, Clone)] pub struct RandomAccessEcallTape { @@ -111,7 +111,7 @@ pub struct PublicInputTape(RandomAccessEcallTape); impl Default for PrivateInputTape { fn default() -> Self { Self(RandomAccessEcallTape { - ecall_id: ecall::PRIVATE_TAPE, + ecall_id: ecall_id::PRIVATE_TAPE, read_offset: 0, size_hint: 0, internal_buf: vec![], @@ -123,7 +123,7 @@ impl PrivateInputTape { /// Creates a new `PrivateInputTape` with a given `size_hint`. pub fn with_size_hint(size_hint: usize) -> Self { Self(RandomAccessEcallTape { - ecall_id: ecall::PRIVATE_TAPE, + ecall_id: ecall_id::PRIVATE_TAPE, read_offset: 0, size_hint, internal_buf: vec![], @@ -134,7 +134,7 @@ impl PrivateInputTape { impl Default for PublicInputTape { fn default() -> Self { Self(RandomAccessEcallTape { - ecall_id: ecall::PUBLIC_TAPE, + ecall_id: ecall_id::PUBLIC_TAPE, read_offset: 0, size_hint: 0, internal_buf: vec![], @@ -146,7 +146,7 @@ impl PublicInputTape { /// Creates a new `PublicInputTape` with a given `size_hint`. pub fn with_size_hint(size_hint: usize) -> Self { Self(RandomAccessEcallTape { - ecall_id: ecall::PUBLIC_TAPE, + ecall_id: ecall_id::PUBLIC_TAPE, read_offset: 0, size_hint, internal_buf: vec![], diff --git a/sdk/src/native/helpers.rs b/sdk/src/native/helpers.rs index 864bed100..b6888515c 100644 --- a/sdk/src/native/helpers.rs +++ b/sdk/src/native/helpers.rs @@ -5,9 +5,9 @@ use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::field::types::Field; use plonky2::hash::poseidon2::Poseidon2Hash as Plonky2Poseidon2Hash; use plonky2::plonk::config::{GenericHashOut, Hasher}; +use sdk_core_types::constants::poseidon2::RATE; use crate::common::types::Poseidon2Hash; -use crate::core::constants::RATE; /// Hashes the input slice to `Poseidon2Hash` after padding. /// We use the well known "Bit padding scheme".