From ad072ccd422ff5a8dc69ac1a35dd0fd3781df88e Mon Sep 17 00:00:00 2001 From: Philippe Laferriere Date: Thu, 9 Nov 2023 10:26:20 -0500 Subject: [PATCH] Derive `PartialEq, Eq` for `ExecutionError` --- core/src/program/blocks/call_block.rs | 2 +- core/src/program/blocks/dyn_block.rs | 2 +- core/src/program/blocks/join_block.rs | 2 +- core/src/program/blocks/loop_block.rs | 2 +- core/src/program/blocks/mod.rs | 2 +- core/src/program/blocks/proxy_block.rs | 2 +- core/src/program/blocks/span_block.rs | 4 ++-- core/src/program/blocks/split_block.rs | 2 +- processor/src/errors.rs | 4 ++-- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/core/src/program/blocks/call_block.rs b/core/src/program/blocks/call_block.rs index b6e84c36f9..ecd9262e6c 100644 --- a/core/src/program/blocks/call_block.rs +++ b/core/src/program/blocks/call_block.rs @@ -14,7 +14,7 @@ use crate::utils::to_hex; /// > hash(fn_hash || padding, domain=SYSCALL_DOMAIN) # when a syscall is used /// /// Where `fn_hash` is 4 field elements (256 bits), and `padding` is 4 ZERO elements (256 bits). -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Call { hash: Digest, fn_hash: Digest, diff --git a/core/src/program/blocks/dyn_block.rs b/core/src/program/blocks/dyn_block.rs index 9f93b4069b..a257d93272 100644 --- a/core/src/program/blocks/dyn_block.rs +++ b/core/src/program/blocks/dyn_block.rs @@ -24,7 +24,7 @@ const DYN_CONSTANT: Digest = Digest::new([ /// affect the representation of the Dyn block. Therefore all Dyn blocks are represented by the same /// constant (rather than by unique hashes), which is computed as an RPO hash of two empty words /// ([ZERO, ZERO, ZERO, ZERO]) with a domain value of `DYN_DOMAIN`. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Dyn {} impl Dyn { diff --git a/core/src/program/blocks/join_block.rs b/core/src/program/blocks/join_block.rs index d5ae4ad88b..03269f6de6 100644 --- a/core/src/program/blocks/join_block.rs +++ b/core/src/program/blocks/join_block.rs @@ -11,7 +11,7 @@ use super::{fmt, hasher, Box, CodeBlock, Digest, Felt, Operation}; /// > hash(left_block_hash || right_block_hash, domain=JOIN_DOMAIN) /// /// Where `left_block_hash` and `right_block_hash` are 4 field elements (256 bits) each. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Join { body: Box<[CodeBlock; 2]>, hash: Digest, diff --git a/core/src/program/blocks/loop_block.rs b/core/src/program/blocks/loop_block.rs index 74e1cbb032..572f33f817 100644 --- a/core/src/program/blocks/loop_block.rs +++ b/core/src/program/blocks/loop_block.rs @@ -12,7 +12,7 @@ use super::{fmt, hasher, Box, CodeBlock, Digest, Felt, Operation}; /// > hash(body_hash || padding, domain=LOOP_DOMAIN) /// /// Where `body_hash` is 4 field elements (256 bits), and `padding` is 4 ZERO elements (256 bits). -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Loop { body: Box, hash: Digest, diff --git a/core/src/program/blocks/mod.rs b/core/src/program/blocks/mod.rs index cce75235c0..7fc2074dd9 100644 --- a/core/src/program/blocks/mod.rs +++ b/core/src/program/blocks/mod.rs @@ -24,7 +24,7 @@ pub use split_block::Split; // PROGRAM BLOCK // ================================================================================================ /// TODO: add comments -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum CodeBlock { Span(Span), Join(Join), diff --git a/core/src/program/blocks/proxy_block.rs b/core/src/program/blocks/proxy_block.rs index 6d9e04bfa1..ca37816429 100644 --- a/core/src/program/blocks/proxy_block.rs +++ b/core/src/program/blocks/proxy_block.rs @@ -8,7 +8,7 @@ use super::{fmt, Digest}; /// of the program secret. Fails if executed. /// /// Hash of a proxy block is not computed but is rather defined at instantiation time. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Proxy { hash: Digest, } diff --git a/core/src/program/blocks/span_block.rs b/core/src/program/blocks/span_block.rs index e9aadf610b..80bc3a2c3d 100644 --- a/core/src/program/blocks/span_block.rs +++ b/core/src/program/blocks/span_block.rs @@ -45,7 +45,7 @@ const MAX_OPS_PER_BATCH: usize = GROUP_SIZE * BATCH_SIZE; /// /// Where `batches` is the concatenation of each `batch` in the span, and each batch is 8 field /// elements (512 bits). -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Span { op_batches: Vec, hash: Digest, @@ -170,7 +170,7 @@ impl fmt::Display for Span { /// /// An operation batch consists of up to 8 operation groups, with each group containing up to 9 /// operations or a single immediate value. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct OpBatch { ops: Vec, groups: [Felt; BATCH_SIZE], diff --git a/core/src/program/blocks/split_block.rs b/core/src/program/blocks/split_block.rs index 873f0d7917..59f041a685 100644 --- a/core/src/program/blocks/split_block.rs +++ b/core/src/program/blocks/split_block.rs @@ -12,7 +12,7 @@ use super::{fmt, hasher, Box, CodeBlock, Digest, Felt, Operation}; /// > hash(true_branch_hash || false_branch_hash, domain=SPLIT_DOMAIN) /// /// Where `true_branch_hash` and `false_branch_hash` are 4 field elements (256 bits) each. -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct Split { branches: Box<[CodeBlock; 2]>, hash: Digest, diff --git a/processor/src/errors.rs b/processor/src/errors.rs index 41e9f200b8..5c817ba0bd 100644 --- a/processor/src/errors.rs +++ b/processor/src/errors.rs @@ -16,7 +16,7 @@ use std::error::Error; // EXECUTION ERROR // ================================================================================================ -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq)] pub enum ExecutionError { AdviceMapKeyNotFound(Word), AdviceMapValueInvalidLength(Word, usize, usize), @@ -169,7 +169,7 @@ impl From for ExecutionError { // EXT2INTT ERROR // ================================================================================================ -#[derive(Debug)] +#[derive(Debug, PartialEq, Eq)] pub enum Ext2InttError { DomainSizeNotPowerOf2(u64), DomainSizeTooSmall(u64),