Skip to content

Commit

Permalink
chore: update comments to fix clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Fumuran committed Aug 26, 2024
1 parent 98ce230 commit bb5fcc1
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 42 deletions.
8 changes: 5 additions & 3 deletions air/src/constraints/stack/field_ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ pub fn enforce_expacc_constraints<E: FieldElement>(
4
}

/// Enforces constraints of the EXT2MUL operation. The EXT2MUL operation computes the product of
/// two elements in the extension field of degree 2. Therefore, the following constraints are
/// enforced, assuming the first 4 elements of the stack in the current frame are a1, a0, b1, b0:
/// Enforces constraints of the EXT2MUL operation.
///
/// The EXT2MUL operation computes the product of two elements in the extension field of degree 2.
/// Therefore, the following constraints are enforced, assuming the first 4 elements of the stack in
/// the current frame are a1, a0, b1, b0:
/// - The first element in the next frame should be a1.
/// - The second element in the next frame should be a0.
/// - The third element in the next frame should be equal to (b0 + b1) * (a0 + a1) - b0 * a0.
Expand Down
18 changes: 10 additions & 8 deletions air/src/constraints/stack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ pub const NUM_ASSERTIONS: usize = 2 * STACK_TOP_SIZE + 2;
/// The number of general constraints in the stack operations.
pub const NUM_GENERAL_CONSTRAINTS: usize = 17;

/// The degrees of constraints in the general stack operations. Each operation being executed
/// either shifts the stack to the left, right or doesn't effect it at all. Therefore, majority
/// of the general transitions of a stack item would be common across the operations and composite
/// flags were introduced to compute the individual stack item transition. A particular item lets
/// say at depth ith in the next stack frame can be transitioned into from ith depth (no shift op)
/// or (i+1)th depth(left shift) or (i-1)th depth(right shift) in the current frame. Therefore, the
/// VM would require only 16 general constraints to encompass all the 16 stack positions.
/// The last constraint checks if the top element in the stack is a binary or not.
/// The degrees of constraints in the general stack operations.
///
/// Each operation being executed either shifts the stack to the left, right or doesn't effect it at
/// all. Therefore, majority of the general transitions of a stack item would be common across the
/// operations and composite flags were introduced to compute the individual stack item transition.
/// A particular item lets say at depth ith in the next stack frame can be transitioned into from
/// ith depth (no shift op) or (i+1)th depth(left shift) or (i-1)th depth(right shift) in the
/// current frame. Therefore, the VM would require only 16 general constraints to encompass all the
/// 16 stack positions. The last constraint checks if the top element in the stack is a binary or
/// not.
pub const CONSTRAINT_DEGREES: [usize; NUM_GENERAL_CONSTRAINTS] = [
// Each degree are being multiplied with the respective composite flags which are of degree 7.
// Therefore, all the degree would incorporate 7 in their degree calculation.
Expand Down
8 changes: 5 additions & 3 deletions air/src/constraints/stack/stack_manipulation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ pub fn enforce_pad_constraints<E: FieldElement>(
1
}

/// Enforces constraints of the DUPn and MOVUPn operations. The DUPn operation copies the element
/// at depth n in the stack and pushes the copy onto the stack, whereas MOVUPn opearation moves the
/// element at depth n to the top of the stack. Therefore, the following constraints are enforced:
/// Enforces constraints of the DUPn and MOVUPn operations.
///
/// The DUPn operation copies the element at depth n in the stack and pushes the copy onto the
/// stack, whereas MOVUPn opearation moves the element at depth n to the top of the stack.
/// Therefore, the following constraints are enforced:
/// - The top element in the next frame should be equal to the element at depth n in the current
/// frame. s0` - sn = 0.
pub fn enforce_dup_movup_n_constraints<E: FieldElement>(
Expand Down
7 changes: 4 additions & 3 deletions air/src/constraints/stack/system_ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ pub fn enforce_fmpadd_constraints<E: FieldElement>(
1
}

/// Enforces constraints of the FMPUPDATE operation. The FMPUPDATE operation increments the fmp
/// register value by the first element value in the current trace. Therefore, the following
/// constraints are enforced:
/// Enforces constraints of the FMPUPDATE operation.
///
/// The FMPUPDATE operation increments the fmp register value by the first element value in the
/// current trace. Therefore, the following constraints are enforced:
/// - The fmp register value in the next frame should be equal to the sum of the fmp register value
/// and the top stack element in the current frame. fmp` - (s0 + fmp) = 0.
pub fn enforce_fmpupdate_constraints<E: FieldElement>(
Expand Down
7 changes: 4 additions & 3 deletions air/src/constraints/stack/u32_ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,10 @@ pub fn enforce_u32mul_constraints<E: FieldElement<BaseField = Felt>>(
1
}

/// Enforces constraints of the U32MADD operation. The U32MADD operation adds the third
/// element to the product of the first two elements in the current trace. Therefore, the
/// following constraints are enforced:
/// Enforces constraints of the U32MADD operation.
///
/// The U32MADD operation adds the third element to the product of the first two elements in the
/// current trace. Therefore, the following constraints are enforced:
/// - The aggregation of all the limbs in the helper registers is equal to the sum of the third
/// element with the product of the first two elements in the current trace.
pub fn enforce_u32madd_constraints<E: FieldElement<BaseField = Felt>>(
Expand Down
7 changes: 4 additions & 3 deletions air/src/trace/chiplets/kernel_rom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ pub const TRACE_WIDTH: usize = 6;

// --- OPERATION SELECTORS ------------------------------------------------------------------------

/// Specifies a kernel procedure call operation to access a procedure in the kernel ROM. The unique
/// operation label is computed as 1 plus the combined chiplet and internal selector with the bits
/// reversed.
/// Specifies a kernel procedure call operation to access a procedure in the kernel ROM.
///
/// The unique operation label is computed as 1 plus the combined chiplet and internal selector with
/// the bits reversed.
/// kernel ROM selector=[1, 1, 1, 0] +1=[0, 0, 0, 1]
pub const KERNEL_PROC_LABEL: Felt = Felt::new(0b1000);
8 changes: 5 additions & 3 deletions air/src/trace/chiplets/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ pub const TRACE_WIDTH: usize = 12;
/// Number of selector columns in the trace.
pub const NUM_SELECTORS: usize = 2;

/// Type for Memory trace selectors. These selectors are used to define which operation and memory
/// state update (init & read / copy & read / write) is to be applied at a specific row of the
/// memory execution trace.
/// Type for Memory trace selectors.
///
/// These selectors are used to define which operation and memory state update
/// (init & read / copy & read / write) is to be applied at a specific row of the memory execution
/// trace.
pub type Selectors = [Felt; NUM_SELECTORS];

// --- OPERATION SELECTORS ------------------------------------------------------------------------
Expand Down
5 changes: 3 additions & 2 deletions assembly/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ impl From<Label> for LabeledSpan {
// RELATED LABEL
// ================================================================================================

/// This type is used to associate a more complex label or set of labels with some other error. In
/// particular, it is used to reference related bits of source code distinct from that of the
/// This type is used to associate a more complex label or set of labels with some other error.
///
/// In particular, it is used to reference related bits of source code distinct from that of the
/// original error.
///
/// A related label can have a distinct severity, its own message, and its own sub-labels, and may
Expand Down
11 changes: 6 additions & 5 deletions assembly/src/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,12 @@ macro_rules! assert_diagnostic {
}};
}

/// Like [assert_diagnostic], but matches each non-empty line of the rendered output
/// to a corresponding pattern. So if the output has 3 lines, the second of which is
/// empty, and you provide 2 patterns, the assertion passes if the first line matches
/// the first pattern, and the third line matches the second pattern - the second
/// line is ignored because it is empty.
/// Like [assert_diagnostic], but matches each non-empty line of the rendered output to a
/// corresponding pattern.
///
/// So if the output has 3 lines, the second of which is empty, and you provide 2 patterns, the
/// assertion passes if the first line matches the first pattern, and the third line matches the
/// second pattern - the second line is ignored because it is empty.
#[macro_export]
macro_rules! assert_diagnostic_lines {
($diagnostic:expr, $($expected:expr),+) => {{
Expand Down
7 changes: 3 additions & 4 deletions processor/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ impl fmt::Display for VmState {
}

/// Iterator that iterates through vm state at each step of the execution.
/// This allows debugging or replaying ability to view various process state
/// at each clock cycle.
/// If the execution returned an error, it returns that error on the clock cycle
/// it stopped.
///
/// This allows debugging or replaying ability to view various process state at each clock cycle. If
/// the execution returned an error, it returns that error on the clock cycle it stopped.
pub struct VmStateIterator {
chiplets: Chiplets,
decoder: Decoder,
Expand Down
11 changes: 6 additions & 5 deletions test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,12 @@ macro_rules! expect_exec_error {
};
}

/// Like [assembly::assert_diagnostic], but matches each non-empty line of the rendered output
/// to a corresponding pattern. So if the output has 3 lines, the second of which is
/// empty, and you provide 2 patterns, the assertion passes if the first line matches
/// the first pattern, and the third line matches the second pattern - the second
/// line is ignored because it is empty.
/// Like [assembly::assert_diagnostic], but matches each non-empty line of the rendered output to a
/// corresponding pattern.
///
/// So if the output has 3 lines, the second of which is empty, and you provide 2 patterns, the
/// assertion passes if the first line matches the first pattern, and the third line matches the
/// second pattern - the second line is ignored because it is empty.
#[cfg(all(feature = "std", not(target_family = "wasm")))]
#[macro_export]
macro_rules! assert_diagnostic_lines {
Expand Down

0 comments on commit bb5fcc1

Please sign in to comment.