From 7c62efd65a95c21c3e4e593045db3c81f06b698d Mon Sep 17 00:00:00 2001 From: Federica Date: Fri, 10 May 2024 11:53:33 -0300 Subject: [PATCH 1/5] Remove unused VirtualMachineError variants --- vm/src/vm/errors/vm_errors.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/vm/src/vm/errors/vm_errors.rs b/vm/src/vm/errors/vm_errors.rs index c3698eda02..6b94f22966 100644 --- a/vm/src/vm/errors/vm_errors.rs +++ b/vm/src/vm/errors/vm_errors.rs @@ -6,7 +6,6 @@ use crate::types::builtin_name::BuiltinName; use thiserror_no_std::Error; -use crate::Felt252; use crate::{ types::{ errors::math_errors::MathError, @@ -76,8 +75,6 @@ pub enum VirtualMachineError { InvalidRes(u64), #[error("Invalid opcode value: {0}")] InvalidOpcode(u64), - #[error("This is not implemented")] - NotImplemented, #[error("Inconsistent auto-deduction for {}, expected {}, got {:?}", (*.0).0, (*.0).1, (*.0).2)] InconsistentAutoDeduction(Box<(BuiltinName, MaybeRelocatable, Option)>), #[error("Invalid hint encoding at pc: {0}")] @@ -90,34 +87,24 @@ pub enum VirtualMachineError { NoSignatureBuiltin, #[error("Expected {0} to be present")] NoModBuiltin(BuiltinName), - #[error("Div out of range: 0 < {} <= {}", (*.0).0, (*.0).1)] - OutOfValidRange(Box<(Felt252, Felt252)>), #[error("Failed to compare {} and {}, cant compare a relocatable to an integer value", (*.0).0, (*.0).1)] DiffTypeComparison(Box<(MaybeRelocatable, MaybeRelocatable)>), #[error("Failed to compare {} and {}, cant compare two relocatable values of different segment indexes", (*.0).0, (*.0).1)] DiffIndexComp(Box<(Relocatable, Relocatable)>), - #[error("Couldn't convert usize to u32")] - NoneInMemoryRange, #[error("Expected integer, found: {0:?}")] ExpectedIntAtRange(Box>), #[error("Could not convert slice to array")] SliceToArrayError, - #[error("Failed to compile hint: {0}")] - CompileHintFail(Box), #[error("op1_addr is Op1Addr.IMM, but no immediate was given")] NoImm, + #[error("Failed to compile hint: {0}")] + CompileHintFail(Box), #[error("Execution reached the end of the program. Requested remaining steps: {0}.")] EndOfProgram(usize), - #[error("Could not reach the end of the program. Executed steps: {0}.")] - StepsLimit(u64), #[error("Could not reach the end of the program. RunResources has no remaining steps.")] UnfinishedExecution, #[error("Current run is not finished")] RunNotFinished, - #[error("Invalid argument count, expected {} but got {}", (*.0).0, (*.0).1)] - InvalidArgCount(Box<(usize, usize)>), - #[error("Couldn't parse prime: {0}")] - CouldntParsePrime(Box), #[error("{HINT_ERROR_STR}{}", (*.0).1)] Hint(Box<(usize, HintError)>), #[error("Unexpected Failure")] From 2b1ad663ef3bb77acf432e466631367213e1ad52 Mon Sep 17 00:00:00 2001 From: Federica Date: Fri, 10 May 2024 11:57:41 -0300 Subject: [PATCH 2/5] Remove unused error variants from MemoryError --- vm/src/vm/errors/memory_errors.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/vm/src/vm/errors/memory_errors.rs b/vm/src/vm/errors/memory_errors.rs index b6f02b0a85..68e759c07e 100644 --- a/vm/src/vm/errors/memory_errors.rs +++ b/vm/src/vm/errors/memory_errors.rs @@ -71,14 +71,10 @@ pub enum MemoryError { ErrorRetrievingMessage(Box), #[error("Error verifying given signature")] ErrorVerifyingSignature, - #[error("Couldn't obtain a mutable accessed offset")] - CantGetMutAccessedOffset, #[error("ECDSA builtin: Expected public key at address {0} to be an integer")] PubKeyNonInt(Box), #[error("ECDSA builtin: Expected message hash at address {0} to be an integer")] MsgNonInt(Box), - #[error("Failed to convert String: {0} to FieldElement")] - FailedStringToFieldElementConversion(Box), #[error("Failed to fetch {} return values, ap is only {}", (*.0).0, (*.0).1)] FailedToGetReturnValues(Box<(usize, Relocatable)>), #[error("Segment {} has {} amount of accessed addresses but its size is only {}.", (*.0).0, (*.0).1, (*.0).2)] From 071ebe6062b0113048390227bfa5404dc8ee337b Mon Sep 17 00:00:00 2001 From: Federica Date: Fri, 10 May 2024 12:04:50 -0300 Subject: [PATCH 3/5] Remove unused error variants from RunnerError & MathError --- vm/src/types/errors/math_errors.rs | 4 ---- vm/src/vm/errors/runner_errors.rs | 16 ---------------- 2 files changed, 20 deletions(-) diff --git a/vm/src/types/errors/math_errors.rs b/vm/src/types/errors/math_errors.rs index 2a12efe12a..05df81f574 100644 --- a/vm/src/types/errors/math_errors.rs +++ b/vm/src/types/errors/math_errors.rs @@ -11,14 +11,10 @@ use crate::types::relocatable::{MaybeRelocatable, Relocatable}; #[derive(Debug, Error, PartialEq)] pub enum MathError { // Math functions - #[error("Can't calculate the square root of negative number: {0})")] - SqrtNegative(Box), #[error("{} is not divisible by {}", (*.0).0, (*.0).1)] SafeDivFail(Box<(Felt252, Felt252)>), #[error("{} is not divisible by {}", (*.0).0, (*.0).1)] SafeDivFailBigInt(Box<(BigInt, BigInt)>), - #[error("{} is not divisible by {}", (*.0).0, (*.0).1)] - SafeDivFailBigUint(Box<(BigUint, BigUint)>), #[error("{0} is not divisible by {1}")] SafeDivFailU32(u32, u32), #[error("{} is not divisible by {}", (*.0).0, (*.0).1)] diff --git a/vm/src/vm/errors/runner_errors.rs b/vm/src/vm/errors/runner_errors.rs index 561f89997e..83c5bb721b 100644 --- a/vm/src/vm/errors/runner_errors.rs +++ b/vm/src/vm/errors/runner_errors.rs @@ -28,10 +28,6 @@ pub enum RunnerError { MemoryValidationError(MemoryError), #[error("Memory loading failed during state initialization: {0}")] MemoryInitializationError(MemoryError), - #[error("Failed to convert string to FieldElement")] - FailedStringConversion, - #[error("EcOpBuiltin: m should be at most {0}")] - EcOpBuiltinScalarLimit(Box), #[error("Given builtins are not in appropiate order")] DisorderedBuiltins, #[error("Expected integer at address {:?} to be smaller than 2^{}, Got {}", (*.0).0, (*.0).1, (*.0).2)] @@ -62,28 +58,16 @@ pub enum RunnerError { NoProgramStart, #[error("Running in proof-mode but no __end__ label found, try compiling with proof-mode")] NoProgramEnd, - #[error("Could not convert slice to array")] - SliceToArrayError, #[error("Cannot add the return values to the public memory after segment finalization.")] FailedAddingReturnValues, #[error("Missing execution public memory")] NoExecPublicMemory, - #[error("Coulnd't parse prime from felt lib")] - CouldntParsePrime, - #[error("Could not convert vec with Maybe Relocatables into u64 array")] - MaybeRelocVecToU64ArrayError, - #[error("Expected Integer value, got Relocatable instead")] - FoundNonInt, #[error(transparent)] Memory(#[from] MemoryError), #[error(transparent)] Math(#[from] MathError), - #[error("keccak_builtin: Failed to get first input address")] - KeccakNoFirstInput, #[error("{}: Expected integer at address {}", (*.0).0, (*.0).1)] BuiltinExpectedInteger(Box<(BuiltinName, Relocatable)>), - #[error("keccak_builtin: Failed to convert input cells to u64 values")] - KeccakInputCellsNotU64, #[error("Unexpected ret_fp_segment size")] UnexpectedRetFpSegmentSize, #[error("Unexpected ret_pc_segment size")] From e03c0d4de42ad3a69450b76f5a1378815474d72e Mon Sep 17 00:00:00 2001 From: Federica Date: Fri, 10 May 2024 12:05:42 -0300 Subject: [PATCH 4/5] fmt --- vm/src/vm/errors/vm_errors.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vm/src/vm/errors/vm_errors.rs b/vm/src/vm/errors/vm_errors.rs index 6b94f22966..a1299618fa 100644 --- a/vm/src/vm/errors/vm_errors.rs +++ b/vm/src/vm/errors/vm_errors.rs @@ -95,10 +95,10 @@ pub enum VirtualMachineError { ExpectedIntAtRange(Box>), #[error("Could not convert slice to array")] SliceToArrayError, - #[error("op1_addr is Op1Addr.IMM, but no immediate was given")] - NoImm, #[error("Failed to compile hint: {0}")] CompileHintFail(Box), + #[error("op1_addr is Op1Addr.IMM, but no immediate was given")] + NoImm, #[error("Execution reached the end of the program. Requested remaining steps: {0}.")] EndOfProgram(usize), #[error("Could not reach the end of the program. RunResources has no remaining steps.")] From 1094e822e56dd5171af68eeb478f38e02338b1c8 Mon Sep 17 00:00:00 2001 From: Federica Date: Fri, 10 May 2024 12:10:18 -0300 Subject: [PATCH 5/5] Remove unused variant --- vm/src/vm/errors/vm_errors.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/vm/src/vm/errors/vm_errors.rs b/vm/src/vm/errors/vm_errors.rs index a1299618fa..b9e0981920 100644 --- a/vm/src/vm/errors/vm_errors.rs +++ b/vm/src/vm/errors/vm_errors.rs @@ -77,8 +77,6 @@ pub enum VirtualMachineError { InvalidOpcode(u64), #[error("Inconsistent auto-deduction for {}, expected {}, got {:?}", (*.0).0, (*.0).1, (*.0).2)] InconsistentAutoDeduction(Box<(BuiltinName, MaybeRelocatable, Option)>), - #[error("Invalid hint encoding at pc: {0}")] - InvalidHintEncoding(Box), #[error("Expected output builtin to be present")] NoOutputBuiltin, #[error("Expected range_check builtin to be present")]