Skip to content

Commit 49d3777

Browse files
fmolettaFrancoGiachettagabrielbosio
authored
Remove unused error variants (#1760)
* Remove unused VirtualMachineError variants * Remove unused error variants from MemoryError * Remove unused error variants from RunnerError & MathError * fmt * Remove unused variant * update changelog * clippy * fmt * change u64 to u128 * revert InvalidOpcodeExtension removal --------- Co-authored-by: FrancoGiachetta <francogiachetta27@gmail.com> Co-authored-by: Gabriel Bosio <38794644+gabrielbosio@users.noreply.github.com>
1 parent 9cedff9 commit 49d3777

File tree

5 files changed

+3
-40
lines changed

5 files changed

+3
-40
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#### Upcoming Changes
44

5+
* Refactor: Remove unused error variants [#1760](https://github.com/lambdaclass/cairo-vm/pull/1760/)
6+
57
* opt(breaking): Avoid cloning constants when compiling hints [#2208](https://github.com/lambdaclass/cairo-vm/pull/2208)
68

79
* dev(BREAKING): Make blake2s API internal [#2265](https://github.com/lambdaclass/cairo-vm/pull/2265)

vm/src/types/errors/math_errors.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ use crate::types::relocatable::{MaybeRelocatable, Relocatable};
1111
#[derive(Debug, Error, PartialEq)]
1212
pub enum MathError {
1313
// Math functions
14-
#[error("Can't calculate the square root of negative number: {0})")]
15-
SqrtNegative(Box<Felt252>),
1614
#[error("{} is not divisible by {}", (*.0).0, (*.0).1)]
1715
SafeDivFail(Box<(Felt252, Felt252)>),
1816
#[error("{} is not divisible by {}", (*.0).0, (*.0).1)]
1917
SafeDivFailBigInt(Box<(BigInt, BigInt)>),
20-
#[error("{} is not divisible by {}", (*.0).0, (*.0).1)]
21-
SafeDivFailBigUint(Box<(BigUint, BigUint)>),
2218
#[error("{0} is not divisible by {1}")]
2319
SafeDivFailU32(u32, u32),
2420
#[error("{} is not divisible by {}", (*.0).0, (*.0).1)]

vm/src/vm/errors/memory_errors.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,10 @@ pub enum MemoryError {
7171
ErrorRetrievingMessage(Box<str>),
7272
#[error("Error verifying given signature")]
7373
ErrorVerifyingSignature,
74-
#[error("Couldn't obtain a mutable accessed offset")]
75-
CantGetMutAccessedOffset,
7674
#[error("ECDSA builtin: Expected public key at address {0} to be an integer")]
7775
PubKeyNonInt(Box<Relocatable>),
7876
#[error("ECDSA builtin: Expected message hash at address {0} to be an integer")]
7977
MsgNonInt(Box<Relocatable>),
80-
#[error("Failed to convert String: {0} to FieldElement")]
81-
FailedStringToFieldElementConversion(Box<str>),
8278
#[error("Failed to fetch {} return values, ap is only {}", (*.0).0, (*.0).1)]
8379
FailedToGetReturnValues(Box<(usize, Relocatable)>),
8480
#[error("Segment {} has {} amount of accessed addresses but its size is only {}.", (*.0).0, (*.0).1, (*.0).2)]

vm/src/vm/errors/runner_errors.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ pub enum RunnerError {
2828
MemoryValidationError(MemoryError),
2929
#[error("Memory loading failed during state initialization: {0}")]
3030
MemoryInitializationError(MemoryError),
31-
#[error("Failed to convert string to FieldElement")]
32-
FailedStringConversion,
33-
#[error("EcOpBuiltin: m should be at most {0}")]
34-
EcOpBuiltinScalarLimit(Box<Felt252>),
3531
#[error("Given builtins are not in appropiate order")]
3632
DisorderedBuiltins,
3733
#[error("Expected integer at address {:?} to be smaller than 2^{}, Got {}", (*.0).0, (*.0).1, (*.0).2)]
@@ -62,28 +58,16 @@ pub enum RunnerError {
6258
NoProgramStart,
6359
#[error("Running in proof-mode but no __end__ label found, try compiling with proof-mode")]
6460
NoProgramEnd,
65-
#[error("Could not convert slice to array")]
66-
SliceToArrayError,
6761
#[error("Cannot add the return values to the public memory after segment finalization.")]
6862
FailedAddingReturnValues,
6963
#[error("Missing execution public memory")]
7064
NoExecPublicMemory,
71-
#[error("Coulnd't parse prime from felt lib")]
72-
CouldntParsePrime,
73-
#[error("Could not convert vec with Maybe Relocatables into u64 array")]
74-
MaybeRelocVecToU64ArrayError,
75-
#[error("Expected Integer value, got Relocatable instead")]
76-
FoundNonInt,
7765
#[error(transparent)]
7866
Memory(#[from] MemoryError),
7967
#[error(transparent)]
8068
Math(#[from] MathError),
81-
#[error("keccak_builtin: Failed to get first input address")]
82-
KeccakNoFirstInput,
8369
#[error("{}: Expected integer at address {}", (*.0).0, (*.0).1)]
8470
BuiltinExpectedInteger(Box<(BuiltinName, Relocatable)>),
85-
#[error("keccak_builtin: Failed to convert input cells to u64 values")]
86-
KeccakInputCellsNotU64,
8771
#[error("Unexpected ret_fp_segment size")]
8872
UnexpectedRetFpSegmentSize,
8973
#[error("Unexpected ret_pc_segment size")]

vm/src/vm/errors/vm_errors.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// The `(*.0).0` syntax of thiserror falsely triggers this clippy warning
22
#![allow(clippy::explicit_auto_deref)]
33

4-
use crate::stdlib::prelude::*;
54
use crate::types::builtin_name::BuiltinName;
5+
use crate::{stdlib::prelude::*, Felt252};
66

77
use thiserror::Error;
88

9-
use crate::Felt252;
109
use crate::{
1110
types::{
1211
errors::math_errors::MathError,
@@ -80,12 +79,8 @@ pub enum VirtualMachineError {
8079
InvalidOpcode(u128),
8180
#[error("Invalid opcode extension value: {0}")]
8281
InvalidOpcodeExtension(u128),
83-
#[error("This is not implemented")]
84-
NotImplemented,
8582
#[error("Inconsistent auto-deduction for {}, expected {}, got {:?}", (*.0).0, (*.0).1, (*.0).2)]
8683
InconsistentAutoDeduction(Box<(BuiltinName, MaybeRelocatable, Option<MaybeRelocatable>)>),
87-
#[error("Invalid hint encoding at pc: {0}")]
88-
InvalidHintEncoding(Box<MaybeRelocatable>),
8984
#[error("Expected output builtin to be present")]
9085
NoOutputBuiltin,
9186
#[error("Expected range_check builtin to be present")]
@@ -94,14 +89,10 @@ pub enum VirtualMachineError {
9489
NoSignatureBuiltin,
9590
#[error("Expected {0} to be present")]
9691
NoModBuiltin(BuiltinName),
97-
#[error("Div out of range: 0 < {} <= {}", (*.0).0, (*.0).1)]
98-
OutOfValidRange(Box<(Felt252, Felt252)>),
9992
#[error("Failed to compare {} and {}, cant compare a relocatable to an integer value", (*.0).0, (*.0).1)]
10093
DiffTypeComparison(Box<(MaybeRelocatable, MaybeRelocatable)>),
10194
#[error("Failed to compare {} and {}, cant compare two relocatable values of different segment indexes", (*.0).0, (*.0).1)]
10295
DiffIndexComp(Box<(Relocatable, Relocatable)>),
103-
#[error("Couldn't convert usize to u32")]
104-
NoneInMemoryRange,
10596
#[error("Expected integer, found: {0:?}")]
10697
ExpectedIntAtRange(Box<Option<MaybeRelocatable>>),
10798
#[error("Could not convert slice to array")]
@@ -112,16 +103,10 @@ pub enum VirtualMachineError {
112103
NoImm,
113104
#[error("Execution reached the end of the program. Requested remaining steps: {0}.")]
114105
EndOfProgram(usize),
115-
#[error("Could not reach the end of the program. Executed steps: {0}.")]
116-
StepsLimit(u64),
117106
#[error("Could not reach the end of the program. RunResources has no remaining steps.")]
118107
UnfinishedExecution,
119108
#[error("Current run is not finished")]
120109
RunNotFinished,
121-
#[error("Invalid argument count, expected {} but got {}", (*.0).0, (*.0).1)]
122-
InvalidArgCount(Box<(usize, usize)>),
123-
#[error("Couldn't parse prime: {0}")]
124-
CouldntParsePrime(Box<str>),
125110
#[error("{HINT_ERROR_STR}{}", (*.0).1)]
126111
Hint(Box<(usize, HintError)>),
127112
#[error("Unexpected Failure")]

0 commit comments

Comments
 (0)