diff --git a/air/src/errors.rs b/air/src/errors.rs index ce9c50b8be..ea55050af0 100644 --- a/air/src/errors.rs +++ b/air/src/errors.rs @@ -5,7 +5,7 @@ use core::fmt::{Display, Formatter}; // EXECUTION ERROR // ================================================================================================ -#[derive(Debug)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum ExecutionOptionsError { ExpectedCyclesTooBig(u32, u32), MaxCycleNumTooSmall(u32), diff --git a/air/src/lib.rs b/air/src/lib.rs index d954eef7fa..0fccda40b6 100644 --- a/air/src/lib.rs +++ b/air/src/lib.rs @@ -43,6 +43,7 @@ pub use winter_air::FieldExtension; // ================================================================================================ /// TODO: add docs +#[derive(Clone, PartialEq, Eq)] pub struct ProcessorAir { context: AirContext, stack_inputs: StackInputs, @@ -250,7 +251,7 @@ impl Air for ProcessorAir { // PUBLIC INPUTS // ================================================================================================ -#[derive(Debug)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct PublicInputs { program_info: ProgramInfo, stack_inputs: StackInputs, diff --git a/air/src/options.rs b/air/src/options.rs index 175d41140a..e348b0fbcc 100644 --- a/air/src/options.rs +++ b/air/src/options.rs @@ -6,7 +6,7 @@ use super::{ // ================================================================================================ /// A set of parameters specifying how Miden VM execution proofs are to be generated. -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ProvingOptions { exec_options: ExecutionOptions, proof_options: WinterProofOptions, @@ -146,7 +146,7 @@ impl From for WinterProofOptions { /// /// - `max_cycles` specifies the maximum number of cycles a program is allowed to execute. /// - `expected_cycles` specifies the number of cycles a program is expected to execute. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ExecutionOptions { max_cycles: u32, expected_cycles: u32, diff --git a/air/src/utils.rs b/air/src/utils.rs index 7cd7a04a03..ebb68a0f07 100644 --- a/air/src/utils.rs +++ b/air/src/utils.rs @@ -49,7 +49,7 @@ impl EvaluationResult for Vec { /// Manages the starting index and length of transition constraints for individual processors so /// indices can be handled easily during transition evaluation. -#[derive(Debug)] +#[derive(Debug, Clone, Hash, PartialEq, Eq)] pub struct TransitionConstraintRange { pub(super) stack: Range, pub(super) range_checker: Range, diff --git a/assembly/src/errors.rs b/assembly/src/errors.rs index f11cfc3685..b100005c74 100644 --- a/assembly/src/errors.rs +++ b/assembly/src/errors.rs @@ -172,7 +172,7 @@ impl std::error::Error for AssemblyError {} // ================================================================================================ /// An error which can be generated while parsing a Miden assembly source code into an AST. -#[derive(Clone, Eq, PartialEq)] +#[derive(Clone, Eq, PartialEq, Hash)] pub struct ParsingError { message: String, location: SourceLocation, @@ -679,7 +679,7 @@ impl std::error::Error for ParsingError {} // NAME ERROR // ================================================================================================ -#[derive(Debug, Clone, Eq, PartialEq)] +#[derive(Debug, Clone, Eq, PartialEq, Hash)] pub enum LabelError { EmptyLabel, RpoDigestHexLabelIncorrectLength(usize), @@ -943,7 +943,7 @@ impl From for LibraryError { // PATH ERROR // ================================================================================================ -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq, Hash)] pub enum PathError { ComponentInvalidChar { component: String }, ComponentInvalidFirstChar { component: String }, diff --git a/assembly/src/procedures/mod.rs b/assembly/src/procedures/mod.rs index 5a6591da9d..319d936996 100644 --- a/assembly/src/procedures/mod.rs +++ b/assembly/src/procedures/mod.rs @@ -17,7 +17,7 @@ use core::{ /// Procedure metadata includes: /// - Number of procedure locals available to the procedure. /// - A set of MAST roots of procedures which are invoked from this procedure. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Procedure { num_locals: u32, code: CodeBlock, @@ -56,7 +56,7 @@ impl Procedure { /// - Procedure name. /// - A boolean flag indicating whether the procedure is exported from a module. /// - A set of MAST roots of procedures which are invoked from this procedure. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct NamedProcedure { name: ProcedureName, is_export: bool, diff --git a/core/src/errors.rs b/core/src/errors.rs index 1a1e98ceb0..ede1e69531 100644 --- a/core/src/errors.rs +++ b/core/src/errors.rs @@ -3,7 +3,7 @@ use core::fmt; // INPUT ERROR // ================================================================================================ -#[derive(Clone, Debug)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum InputError { NotFieldElement(u64, &'static str), DuplicateAdviceRoot([u8; 32]), diff --git a/core/src/operations/decorators/assembly_op.rs b/core/src/operations/decorators/assembly_op.rs index 1ade86fb22..aee1377529 100644 --- a/core/src/operations/decorators/assembly_op.rs +++ b/core/src/operations/decorators/assembly_op.rs @@ -5,7 +5,7 @@ use core::fmt; // ================================================================================================ /// Contains information corresponding to an assembly instruction (only applicable in debug mode). -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct AssemblyOp { context_name: String, num_cycles: u8, diff --git a/core/src/operations/decorators/debug.rs b/core/src/operations/decorators/debug.rs index 90f276abc1..97459c9219 100644 --- a/core/src/operations/decorators/debug.rs +++ b/core/src/operations/decorators/debug.rs @@ -7,7 +7,7 @@ use core::fmt; /// /// These options define the debug info which gets printed out when the Debug decorator is /// executed. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] pub enum DebugOptions { /// Print out the entire contents of the stack for the current execution context. StackAll, diff --git a/core/src/program/mod.rs b/core/src/program/mod.rs index 972d85db99..148529bc2f 100644 --- a/core/src/program/mod.rs +++ b/core/src/program/mod.rs @@ -25,7 +25,7 @@ mod tests; /// A program is described by a Merkelized Abstract Syntax Tree (MAST), where each node is a /// [CodeBlock]. Internal nodes describe control flow semantics of the program, while leaf nodes /// contain linear sequences of instructions which contain no control flow. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Program { root: CodeBlock, kernel: Kernel, @@ -87,7 +87,7 @@ impl fmt::Display for Program { /// This table is used to hold code blocks which are referenced from the program MAST but are /// actually not a part of the MAST itself. Thus, for example, multiple nodes in the MAST can /// reference the same code block in the table. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct CodeBlockTable(BTreeMap<[u8; 32], CodeBlock>); impl CodeBlockTable { diff --git a/core/src/random.rs b/core/src/random.rs index 58cc8910f2..c3d3e8c068 100644 --- a/core/src/random.rs +++ b/core/src/random.rs @@ -24,6 +24,7 @@ const HALF_RATE_WIDTH: usize = (Rpo256::RATE_RANGE.end - Rpo256::RATE_RANGE.star /// This is possible because in our case we never reseed with more than 4 field elements. /// 2. As a result of the previous point, we dont make use of an input buffer to accumulate seed /// material. +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub struct RpoRandomCoin { state: [Felt; STATE_WIDTH], current: usize, diff --git a/core/src/stack/inputs.rs b/core/src/stack/inputs.rs index 4e8c6520e7..bfc089f8f1 100644 --- a/core/src/stack/inputs.rs +++ b/core/src/stack/inputs.rs @@ -8,7 +8,7 @@ use core::slice; /// /// The program execution expects the inputs to be a stack on the VM, and it will be stored in /// reversed order on this struct. -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct StackInputs { values: Vec, } diff --git a/miden/src/cli/bundle.rs b/miden/src/cli/bundle.rs index d66f01e52a..a6a6771f31 100644 --- a/miden/src/cli/bundle.rs +++ b/miden/src/cli/bundle.rs @@ -2,7 +2,7 @@ use assembly::{LibraryNamespace, MaslLibrary, Version}; use clap::Parser; use std::path::PathBuf; -#[derive(Debug, Clone, Parser)] +#[derive(Debug, Clone, Parser, PartialEq, Eq, PartialOrd, Ord, Hash)] #[clap( name = "Compile Library", about = "Bundles .masm files into a single .masl library" diff --git a/miden/src/cli/compile.rs b/miden/src/cli/compile.rs index 7b0de2e6ce..cfa0eb2685 100644 --- a/miden/src/cli/compile.rs +++ b/miden/src/cli/compile.rs @@ -3,7 +3,7 @@ use clap::Parser; use super::data::{Debug, Libraries, ProgramFile}; use std::path::PathBuf; -#[derive(Debug, Clone, Parser)] +#[derive(Debug, Clone, Parser, PartialEq, Eq, PartialOrd, Ord, Hash)] #[clap(about = "Compile a miden program")] pub struct CompileCmd { /// Path to .masm assembly file diff --git a/miden/src/cli/data.rs b/miden/src/cli/data.rs index aef6b6b691..b2435a62d7 100644 --- a/miden/src/cli/data.rs +++ b/miden/src/cli/data.rs @@ -20,6 +20,7 @@ use stdlib::StdLibrary; // ================================================================================================ /// Indicates whether debug mode is on or off. +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Debug { On, Off, @@ -37,7 +38,7 @@ impl Debug { /// Struct used to deserialize merkle data from input file. Merkle data can be represented as a /// merkle tree or a Sparse Merkle Tree. -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum MerkleData { /// String representation of a merkle tree. The merkle tree is represented as a vector of /// 32 byte hex strings where each string represents a leaf in the tree. @@ -65,7 +66,7 @@ pub enum MerkleData { /// - advice_stack /// - advice_map /// - merkle_store -#[derive(Deserialize, Debug)] +#[derive(Deserialize, Debug, Clone, PartialEq, Eq)] pub struct InputFile { /// String representation of the initial operand stack, composed of chained field elements. pub operand_stack: Vec, @@ -295,7 +296,7 @@ impl InputFile { // ================================================================================================ /// Output file struct -#[derive(Deserialize, Serialize, Debug)] +#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct OutputFile { pub stack: Vec, pub overflow_addrs: Vec, @@ -371,6 +372,7 @@ impl OutputFile { // PROGRAM FILE // ================================================================================================ +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ProgramFile { ast: ProgramAst, path: PathBuf, @@ -527,6 +529,7 @@ impl ProgramHash { // LIBRARY FILE // ================================================================================================ +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Libraries { pub libraries: Vec, } diff --git a/miden/src/cli/debug/command.rs b/miden/src/cli/debug/command.rs index 71447f1f2a..447409e930 100644 --- a/miden/src/cli/debug/command.rs +++ b/miden/src/cli/debug/command.rs @@ -1,5 +1,5 @@ /// debug commands supported by the debugger -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum DebugCommand { Continue, Next(usize), diff --git a/miden/src/cli/debug/executor.rs b/miden/src/cli/debug/executor.rs index 80dd021d5a..0a4d856666 100644 --- a/miden/src/cli/debug/executor.rs +++ b/miden/src/cli/debug/executor.rs @@ -5,6 +5,7 @@ use miden::{ }; /// Holds debugger state and iterator used for debugging. +#[derive(Debug, Clone)] pub struct DebugExecutor { vm_state_iter: VmStateIterator, vm_state: VmState, diff --git a/miden/src/cli/debug/mod.rs b/miden/src/cli/debug/mod.rs index bd683fde29..4606456646 100644 --- a/miden/src/cli/debug/mod.rs +++ b/miden/src/cli/debug/mod.rs @@ -9,7 +9,7 @@ use command::DebugCommand; mod executor; use executor::DebugExecutor; -#[derive(Debug, Clone, Parser)] +#[derive(Debug, Clone, Parser, PartialEq, Eq)] #[clap(about = "Debug a miden program")] pub struct DebugCmd { /// Path to .masm assembly file diff --git a/miden/src/cli/prove.rs b/miden/src/cli/prove.rs index eb9b7d8d33..189ac2d569 100644 --- a/miden/src/cli/prove.rs +++ b/miden/src/cli/prove.rs @@ -5,7 +5,7 @@ use processor::{DefaultHost, ExecutionOptions, ExecutionOptionsError}; use std::{io::Write, path::PathBuf, time::Instant}; // TODO check if clap is supporting automatic generation of list values of hash function -#[derive(Debug, Clone, Parser)] +#[derive(Parser, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[clap(about = "Prove a miden program")] pub struct ProveCmd { /// Path to .masm assembly file diff --git a/miden/src/cli/repl.rs b/miden/src/cli/repl.rs index c2f5570351..f6b7e1e526 100644 --- a/miden/src/cli/repl.rs +++ b/miden/src/cli/repl.rs @@ -3,7 +3,7 @@ use std::path::PathBuf; use crate::repl::start_repl; -#[derive(Debug, Clone, Parser)] +#[derive(Parser, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[clap(about = "Initiates the Miden REPL tool")] pub struct ReplCmd { /// Paths to .masl library files diff --git a/miden/src/cli/run.rs b/miden/src/cli/run.rs index f123093dd2..581dc7c6af 100644 --- a/miden/src/cli/run.rs +++ b/miden/src/cli/run.rs @@ -3,7 +3,7 @@ use clap::Parser; use processor::{DefaultHost, ExecutionOptions}; use std::{path::PathBuf, time::Instant}; -#[derive(Debug, Clone, Parser)] +#[derive(Parser, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[clap(about = "Run a miden program")] pub struct RunCmd { /// Path to .masm assembly file diff --git a/miden/src/cli/verify.rs b/miden/src/cli/verify.rs index 9e81863b26..4573c45969 100644 --- a/miden/src/cli/verify.rs +++ b/miden/src/cli/verify.rs @@ -3,7 +3,7 @@ use clap::Parser; use miden::{Kernel, ProgramInfo}; use std::{path::PathBuf, time::Instant}; -#[derive(Debug, Clone, Parser)] +#[derive(Parser, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] #[clap(about = "Verify a miden program")] pub struct VerifyCmd { /// Path to input file diff --git a/miden/src/examples/mod.rs b/miden/src/examples/mod.rs index c3b3d26a49..02e705573f 100644 --- a/miden/src/examples/mod.rs +++ b/miden/src/examples/mod.rs @@ -23,7 +23,7 @@ where // EXAMPLE OPTIONS // ================================================================================================ -#[derive(Debug, Clone, Parser)] +#[derive(Debug, Clone, Parser, PartialEq, Eq)] #[clap(about = "Run an example miden program")] pub struct ExampleOptions { #[clap(subcommand)] @@ -46,7 +46,7 @@ pub struct ExampleOptions { security: String, } -#[derive(Debug, Clone, Parser)] +#[derive(Debug, Clone, Parser, PartialEq, Eq)] //#[clap(about = "available examples")] pub enum ExampleType { /// Compute a Fibonacci sequence of the specified length diff --git a/miden/src/main.rs b/miden/src/main.rs index cd3e8bb64b..458cf67426 100644 --- a/miden/src/main.rs +++ b/miden/src/main.rs @@ -16,7 +16,7 @@ pub struct Cli { } /// CLI actions -#[derive(Debug, Parser)] +#[derive(Debug, Parser, PartialEq, Eq)] pub enum Actions { Analyze(tools::Analyze), Compile(cli::CompileCmd), diff --git a/miden/src/tools/mod.rs b/miden/src/tools/mod.rs index 9e9a766293..7d2075bad2 100644 --- a/miden/src/tools/mod.rs +++ b/miden/src/tools/mod.rs @@ -10,7 +10,7 @@ use stdlib::StdLibrary; // ================================================================================================ /// Defines cli interface -#[derive(Debug, Clone, Parser)] +#[derive(Debug, Clone, Parser, PartialEq, Eq)] #[clap(about = "Analyze a miden program")] pub struct Analyze { /// Path to .masm assembly file diff --git a/processor/src/chiplets/aux_trace/bus.rs b/processor/src/chiplets/aux_trace/bus.rs index 50d603572c..6aac255358 100644 --- a/processor/src/chiplets/aux_trace/bus.rs +++ b/processor/src/chiplets/aux_trace/bus.rs @@ -16,7 +16,7 @@ use super::{ /// attributed to the correct chiplet and operation, a unique chiplet operation label must be /// included in the lookup row value when it is computed. -#[derive(Default)] +#[derive(Default, Debug, Clone, PartialEq, Eq)] pub struct ChipletsBus { lookup_hints: BTreeMap, requests: Vec, diff --git a/processor/src/chiplets/aux_trace/mod.rs b/processor/src/chiplets/aux_trace/mod.rs index 03d75f877b..20c36d1a54 100644 --- a/processor/src/chiplets/aux_trace/mod.rs +++ b/processor/src/chiplets/aux_trace/mod.rs @@ -11,6 +11,7 @@ pub(crate) use virtual_table::{ChipletsVTableRow, ChipletsVTableUpdate}; /// Contains all relevant information and describes how to construct the execution trace for /// chiplets-related auxiliary columns (used in multiset checks). +#[derive(Debug, Clone, PartialEq, Eq)] pub struct AuxTraceBuilder { bus_builder: BusTraceBuilder, table_builder: ChipletsVTableTraceBuilder, @@ -45,6 +46,7 @@ impl AuxTraceBuilder { // ================================================================================================ /// Describes how to construct the execution trace of the chiplets bus auxiliary trace column. +#[derive(Debug, Clone, PartialEq, Eq)] pub struct BusTraceBuilder { pub(super) lookup_hints: Vec<(u32, ChipletsBusRow)>, pub(super) requests: Vec, @@ -137,7 +139,7 @@ impl AuxColumnBuilder for BusTraceBuilder { /// procedures contained in the kernel ROM. Thus, it is expected that the initial value is ONE, the /// value after all sibling table updates are completed is again ONE, and the value at the end of /// the trace is the product of the representations of the kernel ROM procedures. -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct ChipletsVTableTraceBuilder { pub(super) hints: Vec<(u32, ChipletsVTableUpdate)>, pub(super) rows: Vec, diff --git a/processor/src/chiplets/aux_trace/virtual_table.rs b/processor/src/chiplets/aux_trace/virtual_table.rs index 77d0736c99..aed927ab11 100644 --- a/processor/src/chiplets/aux_trace/virtual_table.rs +++ b/processor/src/chiplets/aux_trace/virtual_table.rs @@ -13,7 +13,7 @@ use crate::trace::LookupTableRow; /// - The kernel procedure table contains all kernel procedures along with the address where they /// first appear in the kernel ROM trace. Each kernel procedure is expected to be included exactly /// once, regardless of whether it is ever called or not. -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum ChipletsVTableUpdate { SiblingAdded(u32), SiblingRemoved(u32), diff --git a/processor/src/chiplets/bitwise/mod.rs b/processor/src/chiplets/bitwise/mod.rs index b7d84e47a1..41c7279b01 100644 --- a/processor/src/chiplets/bitwise/mod.rs +++ b/processor/src/chiplets/bitwise/mod.rs @@ -48,6 +48,7 @@ const INIT_TRACE_CAPACITY: usize = 128; /// significant 4-bit limbs of the input values. With every subsequent row, the next most /// significant 4-bit limb of the result is appended to it. Thus, by the 8th row, column `z` /// contains the full result of the bitwise operation. +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Bitwise { trace: [Vec; TRACE_WIDTH], } diff --git a/processor/src/chiplets/hasher/lookups.rs b/processor/src/chiplets/hasher/lookups.rs index 98db0ea177..dc204d8d2d 100644 --- a/processor/src/chiplets/hasher/lookups.rs +++ b/processor/src/chiplets/hasher/lookups.rs @@ -19,7 +19,7 @@ const NUM_HEADER_ALPHAS: usize = 4; /// Specifies the context of the [HasherLookup], indicating whether it describes the beginning of a /// hash operation, the return of a specified result, or the absorption of additional elements, /// initiating a new hash cycle with the provided [HasherState]. -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum HasherLookupContext { Start, Absorb, diff --git a/processor/src/chiplets/hasher/mod.rs b/processor/src/chiplets/hasher/mod.rs index 6ffd083abf..4c251badfa 100644 --- a/processor/src/chiplets/hasher/mod.rs +++ b/processor/src/chiplets/hasher/mod.rs @@ -62,7 +62,7 @@ mod tests; /// the trace of a control or span block that can be copied to be used later for program blocks /// encountered with the same digest instead of building it from scratch everytime. The hash of /// the block is used as the key here after converting it to a bytes array. -#[derive(Default)] +#[derive(Default, Debug, Clone, PartialEq, Eq)] pub struct Hasher { trace: HasherTrace, aux_trace: ChipletsVTableTraceBuilder, @@ -544,7 +544,7 @@ impl Hasher { // ================================================================================================ /// Specifies the context of a Merkle path computation. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] enum MerklePathContext { /// The computation is for verifying a Merkle path (MPVERIFY). MpVerify, diff --git a/processor/src/chiplets/hasher/trace.rs b/processor/src/chiplets/hasher/trace.rs index 2efa840104..379d037d66 100644 --- a/processor/src/chiplets/hasher/trace.rs +++ b/processor/src/chiplets/hasher/trace.rs @@ -12,7 +12,7 @@ use vm_core::chiplets::hasher::apply_round; /// - 3 selector columns. /// - 12 columns describing hasher state. /// - 1 node index column used for Merkle path related computations. -#[derive(Default)] +#[derive(Default, Debug, Clone, PartialEq, Eq)] pub struct HasherTrace { selectors: [Vec; 3], hasher_state: [Vec; STATE_WIDTH], diff --git a/processor/src/chiplets/kernel_rom/mod.rs b/processor/src/chiplets/kernel_rom/mod.rs index ee2a4a2422..e943ed9c19 100644 --- a/processor/src/chiplets/kernel_rom/mod.rs +++ b/processor/src/chiplets/kernel_rom/mod.rs @@ -38,6 +38,7 @@ type ProcHashBytes = [u8; 32]; /// `h3` can change. /// - `h0` - `h3` columns contain roots of procedures in a given kernel. Together with `idx` /// column, these form tuples (index, procedure root) for all procedures in the kernel. +#[derive(Debug, Clone, PartialEq, Eq)] pub struct KernelRom { access_map: BTreeMap, kernel: Kernel, @@ -146,6 +147,7 @@ impl KernelRom { // ================================================================================================ /// Procedure access information for a given kernel procedure. +#[derive(Debug, Clone, PartialEq, Eq)] struct ProcAccessInfo { proc_hash: Word, num_accesses: usize, diff --git a/processor/src/chiplets/memory/mod.rs b/processor/src/chiplets/memory/mod.rs index b24a957eb4..e4a7d98733 100644 --- a/processor/src/chiplets/memory/mod.rs +++ b/processor/src/chiplets/memory/mod.rs @@ -72,7 +72,7 @@ const INIT_MEM_VALUE: Word = EMPTY_WORD; /// clock cycles computed as described above. /// /// For the first row of the trace, values in `d0`, `d1`, and `d_inv` are set to zeros. -#[derive(Default)] +#[derive(Default, Debug, Clone, PartialEq, Eq)] pub struct Memory { /// Memory segment traces sorted by their execution context ID. trace: BTreeMap, diff --git a/processor/src/chiplets/memory/segment.rs b/processor/src/chiplets/memory/segment.rs index 15ceb760ec..6769997412 100644 --- a/processor/src/chiplets/memory/segment.rs +++ b/processor/src/chiplets/memory/segment.rs @@ -13,7 +13,7 @@ use super::{BTreeMap, Felt, StarkField, Vec, Word, INIT_MEM_VALUE}; /// A memory segment is an isolated address space accessible from a specific execution context. /// Within each segment, the memory is word-addressable. That is, four field elements are located /// at each memory address, and we can read and write elements to/from memory in batches of four. -#[derive(Default)] +#[derive(Default, Debug, Clone, PartialEq, Eq)] pub struct MemorySegmentTrace(BTreeMap>); impl MemorySegmentTrace { @@ -129,7 +129,7 @@ impl MemorySegmentTrace { // MEMORY ACCESS // ================================================================================================ -#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum MemoryOperation { InitRead, CopyRead, @@ -138,7 +138,7 @@ pub enum MemoryOperation { /// A single memory access representing the specified memory operation with the specified value at /// the specified clock cycle. -#[derive(Copy, Debug, Clone)] +#[derive(Copy, Debug, Clone, PartialEq, Eq)] pub struct MemorySegmentAccess { clk: Felt, op: MemoryOperation, diff --git a/processor/src/chiplets/mod.rs b/processor/src/chiplets/mod.rs index 92a14d0395..cefa1602cf 100644 --- a/processor/src/chiplets/mod.rs +++ b/processor/src/chiplets/mod.rs @@ -102,6 +102,7 @@ impl MerkleRootUpdate { /// exactly enough rows remaining for the specified number of random rows. /// - columns 0-3: selector columns with values set to ONE /// - columns 3-17: unused columns padded with ZERO +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Chiplets { /// Current clock cycle of the VM. clk: u32, diff --git a/processor/src/debug.rs b/processor/src/debug.rs index 82291a2984..c488fb90e3 100644 --- a/processor/src/debug.rs +++ b/processor/src/debug.rs @@ -47,6 +47,7 @@ impl fmt::Display for VmState { /// at each clock cycle. /// If the execution returned an error, it returns that error on the clock cycle /// it stopped. +#[derive(Debug, Clone, PartialEq, Eq)] pub struct VmStateIterator { chiplets: Chiplets, decoder: Decoder, diff --git a/processor/src/decoder/aux_hints.rs b/processor/src/decoder/aux_hints.rs index c6333d37e0..dcb19de30d 100644 --- a/processor/src/decoder/aux_hints.rs +++ b/processor/src/decoder/aux_hints.rs @@ -10,6 +10,7 @@ use super::{ /// Contains information which can be used to simplify construction of execution traces of /// decoder-related auxiliary trace segment columns (used in multiset checks). +#[derive(Debug, Clone, PartialEq, Eq)] pub struct AuxTraceHints { /// A list of updates made to the block stack and block hash tables. Each entry contains a /// clock cycle at which the update was made, as well as the description of the update. diff --git a/processor/src/decoder/block_stack.rs b/processor/src/decoder/block_stack.rs index 4fdc1e995a..687e2d1498 100644 --- a/processor/src/decoder/block_stack.rs +++ b/processor/src/decoder/block_stack.rs @@ -5,7 +5,7 @@ use crate::system::ContextId; // ================================================================================================ /// Keeps track of code blocks which are currently being executed by the VM. -#[derive(Default)] +#[derive(Default, Debug, Clone, PartialEq, Eq)] pub struct BlockStack { blocks: Vec, } @@ -94,7 +94,7 @@ impl BlockStack { // ================================================================================================ /// Contains basic information about a code block. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct BlockInfo { pub addr: Felt, block_type: BlockType, @@ -160,7 +160,7 @@ impl BlockInfo { /// Contains information about an execution context. Execution contexts are relevant only for CALL /// and SYSCALL blocks. -#[derive(Debug, Default, Clone, Copy)] +#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)] pub struct ExecutionContextInfo { /// Context ID of the block's parent. pub parent_ctx: ContextId, @@ -198,7 +198,7 @@ impl ExecutionContextInfo { // ================================================================================================ /// Specifies type of a code block with additional info for some block types. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum BlockType { Join(bool), // internal value set to true when the first child is fully executed Split, diff --git a/processor/src/decoder/mod.rs b/processor/src/decoder/mod.rs index ea08cb620e..d92c920422 100644 --- a/processor/src/decoder/mod.rs +++ b/processor/src/decoder/mod.rs @@ -359,6 +359,7 @@ where /// - An instance of [DebugInfo] which is only populated in debug mode. This debug_info instance /// includes operations executed by the VM and AsmOp decorators. AsmOp decorators are populated /// only when both the processor and assembler are in debug mode. +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Decoder { block_stack: BlockStack, span_context: Option, @@ -805,7 +806,7 @@ impl Default for Decoder { /// encoded as opcodes (7 bits) appended one after another into a single field element, with the /// next operation to be executed located at the least significant position. /// - Number of operation groups left to be executed in the entire SPAN block. -#[derive(Default)] +#[derive(Default, Debug, Clone, PartialEq, Eq)] struct SpanContext { group_ops_left: Felt, num_groups_left: Felt, @@ -851,6 +852,7 @@ pub fn build_op_group(ops: &[Operation]) -> Felt { // DEBUG INFO // ================================================================================================ +#[derive(Debug, Clone, PartialEq, Eq)] pub struct DebugInfo { in_debug_mode: bool, operations: Vec, diff --git a/processor/src/decoder/trace.rs b/processor/src/decoder/trace.rs index 286601264b..f0d36c1c20 100644 --- a/processor/src/decoder/trace.rs +++ b/processor/src/decoder/trace.rs @@ -37,6 +37,7 @@ pub const USER_OP_HELPERS: Range = Range { /// group. /// - 3 columns for keeping track of operation batch flags. /// - 2 columns used for op flag degree reduction (to support degree 4 and 5 operations). +#[derive(Debug, Clone, PartialEq, Eq)] pub struct DecoderTrace { addr_trace: Vec, op_bits_trace: [Vec; NUM_OP_BITS], diff --git a/processor/src/errors.rs b/processor/src/errors.rs index 5c817ba0bd..3a7f419929 100644 --- a/processor/src/errors.rs +++ b/processor/src/errors.rs @@ -16,7 +16,7 @@ use std::error::Error; // EXECUTION ERROR // ================================================================================================ -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum ExecutionError { AdviceMapKeyNotFound(Word), AdviceMapValueInvalidLength(Word, usize, usize), @@ -169,7 +169,7 @@ impl From for ExecutionError { // EXT2INTT ERROR // ================================================================================================ -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Ext2InttError { DomainSizeNotPowerOf2(u64), DomainSizeTooSmall(u64), diff --git a/processor/src/host/advice/extractors.rs b/processor/src/host/advice/extractors.rs index ed9175015d..741480a28b 100644 --- a/processor/src/host/advice/extractors.rs +++ b/processor/src/host/advice/extractors.rs @@ -5,7 +5,7 @@ use core::fmt; /// Defines a set of actions which can be initiated from the VM to extract data from the advice /// provider. These actions can only modify the advice stack. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, Hash)] pub enum AdviceExtractor { /// Pops an element from the advice stack and returns it. /// diff --git a/processor/src/host/advice/inputs.rs b/processor/src/host/advice/inputs.rs index 00bdbe3b32..f017624693 100644 --- a/processor/src/host/advice/inputs.rs +++ b/processor/src/host/advice/inputs.rs @@ -15,7 +15,7 @@ use super::{BTreeMap, Felt, InnerNodeInfo, InputError, MerkleStore, Vec}; /// 3. Merkle store, which is used to provide nondeterministic inputs for instructions that /// operates with Merkle trees. #[cfg(not(feature = "internals"))] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct AdviceInputs { stack: Vec, map: BTreeMap<[u8; 32], Vec>, @@ -128,7 +128,7 @@ impl AdviceInputs { // ================================================================================================ #[cfg(feature = "internals")] -#[derive(Clone, Debug, Default)] +#[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct AdviceInputs { pub stack: Vec, pub map: BTreeMap<[u8; 32], Vec>, diff --git a/processor/src/host/advice/providers.rs b/processor/src/host/advice/providers.rs index 899ede0cdd..a57e024a94 100644 --- a/processor/src/host/advice/providers.rs +++ b/processor/src/host/advice/providers.rs @@ -20,7 +20,7 @@ type RecordingAdviceMap = RecordingMap<[u8; 32], Vec>; /// An in-memory [AdviceProvider] implementation which serves as the base for advice providers /// bundles with Miden VM. -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct BaseAdviceProvider where M: KvMap<[u8; 32], Vec>, @@ -238,7 +238,7 @@ where // ================================================================================================ /// An in-memory `[AdviceProvider]` implementation which uses [BTreeMap]s as its backing storage. -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct MemAdviceProvider { provider: BaseAdviceProvider, } @@ -358,7 +358,7 @@ impl MemAdviceProvider { /// /// The recorder can be converted into a proof which can be used to provide the non-deterministic /// inputs for program execution. -#[derive(Debug, Clone, Default)] +#[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct RecAdviceProvider { provider: BaseAdviceProvider, init_stack: Vec, diff --git a/processor/src/host/debug.rs b/processor/src/host/debug.rs index 3177b6e77d..83c177d2ed 100644 --- a/processor/src/host/debug.rs +++ b/processor/src/host/debug.rs @@ -30,6 +30,7 @@ pub fn print_debug_info(process: &S, options: &DebugOptions) { // HELPER FUNCTIONS // ================================================================================================ +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] struct Printer { clk: u32, ctx: ContextId, diff --git a/processor/src/host/mod.rs b/processor/src/host/mod.rs index 93a9f8c305..c23763dfe0 100644 --- a/processor/src/host/mod.rs +++ b/processor/src/host/mod.rs @@ -178,7 +178,7 @@ where // ================================================================================================ /// Response returned by the host upon successful execution of a [HostFunction]. -#[derive(Debug)] +#[derive(Debug, Clone, PartialEq, Eq)] pub enum HostResponse { MerklePath(MerklePath), DoubleWord([Word; 2]), diff --git a/processor/src/lib.rs b/processor/src/lib.rs index 78b8d885ed..d8c314d31c 100644 --- a/processor/src/lib.rs +++ b/processor/src/lib.rs @@ -91,21 +91,25 @@ type QuadFelt = QuadExtension; type SysTrace = [Vec; SYS_TRACE_WIDTH]; +#[derive(Debug, Clone, PartialEq, Eq)] pub struct DecoderTrace { trace: [Vec; DECODER_TRACE_WIDTH], aux_trace_hints: decoder::AuxTraceHints, } +#[derive(Debug, Clone, PartialEq, Eq)] pub struct StackTrace { trace: [Vec; STACK_TRACE_WIDTH], aux_builder: stack::AuxTraceBuilder, } +#[derive(Debug, Clone, PartialEq, Eq)] pub struct RangeCheckTrace { trace: [Vec; RANGE_CHECK_TRACE_WIDTH], aux_builder: range::AuxTraceBuilder, } +#[derive(Debug, Clone, PartialEq, Eq)] pub struct ChipletsTrace { trace: [Vec; CHIPLETS_WIDTH], aux_builder: chiplets::AuxTraceBuilder, @@ -607,6 +611,7 @@ impl ProcessState for Process { // ================================================================================================ #[cfg(any(test, feature = "internals"))] +#[cfg_attr(any(test, feature = "internals"), derive(Debug, Clone, PartialEq, Eq))] pub struct Process where H: Host, diff --git a/processor/src/range/aux_trace.rs b/processor/src/range/aux_trace.rs index 531a6dba55..3b36bf5686 100644 --- a/processor/src/range/aux_trace.rs +++ b/processor/src/range/aux_trace.rs @@ -7,6 +7,7 @@ use vm_core::StarkField; /// Describes how to construct the execution trace of columns related to the range checker in the /// auxiliary segment of the trace. These are used in multiset checks. +#[derive(Debug, Clone, PartialEq, Eq)] pub struct AuxTraceBuilder { /// A list of the unique values for which range checks are performed. lookup_values: Vec, diff --git a/processor/src/range/mod.rs b/processor/src/range/mod.rs index e1d12fe436..9bdd711799 100644 --- a/processor/src/range/mod.rs +++ b/processor/src/range/mod.rs @@ -37,6 +37,7 @@ mod tests; /// Thus, for example, if a value was range-checked just once, we'll need to add a single row to /// the table with (m, v) set to (1, v), where v is the value. If the value was range-checked 5 /// times, we'll need to specify the row (5, v). +#[derive(Debug, Clone, PartialEq, Eq)] pub struct RangeChecker { /// Tracks lookup count for each checked value. lookups: BTreeMap, diff --git a/processor/src/range/request.rs b/processor/src/range/request.rs index 28cf9c0704..0178f0a82d 100644 --- a/processor/src/range/request.rs +++ b/processor/src/range/request.rs @@ -5,7 +5,7 @@ use super::{ColMatrix, Felt, FieldElement, LookupTableRow}; /// A struct containing all the range check lookups requested by user operations at a single clock /// cycle, grouped by the processor performing the lookup. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct CycleRangeChecks { memory: Option, stack: Option, diff --git a/processor/src/stack/aux_trace.rs b/processor/src/stack/aux_trace.rs index d040a63b83..4f077fbc10 100644 --- a/processor/src/stack/aux_trace.rs +++ b/processor/src/stack/aux_trace.rs @@ -8,6 +8,7 @@ use super::{ /// Describes how to construct execution traces of stack-related auxiliary trace segment columns /// (used in multiset checks). +#[derive(Debug, Clone, PartialEq, Eq)] pub struct AuxTraceBuilder { /// A list of updates made to the overflow table during program execution. For each update we /// also track the cycle at which the update happened. diff --git a/processor/src/stack/mod.rs b/processor/src/stack/mod.rs index bbfee3de17..40ddf61f6d 100644 --- a/processor/src/stack/mod.rs +++ b/processor/src/stack/mod.rs @@ -53,6 +53,7 @@ const MAX_TOP_IDX: usize = STACK_TOP_SIZE - 1; /// - Helper column h0 is used to ensure that stack depth does not drop below 16. Values in this /// column are set by the prover non-deterministically to 1 / (b0−16) when b0 != 16, and to any /// other value otherwise. +#[derive(Debug, Clone, PartialEq, Eq)] pub struct Stack { clk: u32, trace: StackTrace, diff --git a/processor/src/stack/overflow.rs b/processor/src/stack/overflow.rs index e4d1cc4872..049f6b1129 100644 --- a/processor/src/stack/overflow.rs +++ b/processor/src/stack/overflow.rs @@ -13,6 +13,7 @@ use vm_core::{utils::uninit_vector, StarkField}; /// /// When `trace_enabled` is set to true, we also record all changes to the table so that we can /// reconstruct the overflow table at any clock cycle. This can be used for debugging purposes. +#[derive(Debug, Clone, PartialEq, Eq)] pub struct OverflowTable { /// A list of all rows that were added to and then removed from the overflow table. all_rows: Vec, @@ -249,7 +250,7 @@ impl OverflowTable { /// - The clock cycle at which the stack item was pushed into the overflow table. /// - The clock cycle of the value which was at the top of the overflow table when this value /// was pushed onto it. -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, PartialEq, Eq, Clone)] pub struct OverflowTableRow { val: Felt, clk: Felt, diff --git a/processor/src/stack/trace.rs b/processor/src/stack/trace.rs index f90faccfe3..5fe0330020 100644 --- a/processor/src/stack/trace.rs +++ b/processor/src/stack/trace.rs @@ -12,6 +12,7 @@ use vm_core::utils::math::batch_inversion; /// The trace consists of 19 columns grouped logically as follows: /// - 16 stack columns holding the top of the stack. /// - 3 columns for bookkeeping and helper values that manage left and right shifts. +#[derive(Debug, Clone, PartialEq, Eq)] pub struct StackTrace { stack: [Vec; STACK_TOP_SIZE], helpers: [Vec; NUM_STACK_HELPER_COLS], diff --git a/processor/src/system/mod.rs b/processor/src/system/mod.rs index 614c611949..f1a38f0858 100644 --- a/processor/src/system/mod.rs +++ b/processor/src/system/mod.rs @@ -38,6 +38,7 @@ pub const FMP_MAX: u64 = 3 * 2_u64.pow(30) - 1; /// - in_syscall flag which indicates whether the execution is currently in a SYSCALL block. /// - hash of the function which initiated the current execution context. if the context was /// initiated from the root context, this will be set to ZEROs. +#[derive(Debug, Clone, PartialEq, Eq)] pub struct System { clk: u32, ctx: ContextId, @@ -302,7 +303,7 @@ impl System { // ================================================================================================ /// Represents the ID of an execution context -#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Copy, Debug, Default, Eq, Ord, PartialEq, PartialOrd, Hash)] pub struct ContextId(u32); impl ContextId { diff --git a/processor/src/trace/mod.rs b/processor/src/trace/mod.rs index 88f9ee1236..7836e5aaa5 100644 --- a/processor/src/trace/mod.rs +++ b/processor/src/trace/mod.rs @@ -38,6 +38,7 @@ pub const NUM_RAND_ROWS: usize = 1; // VM EXECUTION TRACE // ================================================================================================ +#[derive(Debug, Clone, PartialEq, Eq)] pub struct AuxTraceHints { pub(crate) decoder: DecoderAuxTraceHints, pub(crate) stack: StackAuxTraceBuilder, diff --git a/processor/src/trace/utils.rs b/processor/src/trace/utils.rs index 705fa314ba..4218662718 100644 --- a/processor/src/trace/utils.rs +++ b/processor/src/trace/utils.rs @@ -7,6 +7,7 @@ use vm_core::utils::uninit_vector; // ================================================================================================ /// TODO: add docs +#[derive(Debug, PartialEq, Eq)] pub struct TraceFragment<'a> { data: Vec<&'a mut [Felt]>, } diff --git a/prover/src/gpu.rs b/prover/src/gpu.rs index 530d18fa74..452ed1129f 100644 --- a/prover/src/gpu.rs +++ b/prover/src/gpu.rs @@ -34,6 +34,7 @@ const RPO_RATE: usize = Rpo256::RATE_RANGE.end - Rpo256::RATE_RANGE.start; // ================================================================================================ /// Wraps an [ExecutionProver] and provides GPU acceleration for building Rpo256 trace commitments. +#[derive(Debug, Clone, PartialEq, Eq)] pub(crate) struct MetalRpoExecutionProver(pub ExecutionProver) where R: RandomCoin; diff --git a/prover/src/lib.rs b/prover/src/lib.rs index feb4ac63f1..2830fbdd71 100644 --- a/prover/src/lib.rs +++ b/prover/src/lib.rs @@ -112,6 +112,7 @@ where // PROVER // ================================================================================================ +#[derive(Debug, Clone, PartialEq, Eq)] struct ExecutionProver where H: ElementHasher,