Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove CairoRunError::CairoPieValidation error #1750

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions vm/src/cairo_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use crate::{
hint_processor::hint_processor_definition::HintProcessor,
types::{builtin_name::BuiltinName, layout_name::LayoutName, program::Program},
vm::{
errors::{
cairo_run_errors::CairoRunError, runner_errors::RunnerError, vm_exception::VmException,
},
errors::{runner_errors::RunnerError, vm_exception::VmException},
runners::{cairo_pie::CairoPie, cairo_runner::CairoRunner},
security::verify_secure_runner,
vm_core::VirtualMachine,
Expand Down Expand Up @@ -112,6 +110,7 @@ pub fn cairo_run(
/// WARNING: As the RunResources are part of the HintProcessor trait, the caller should make sure that
/// the number of steps in the `RunResources` matches that of the `ExecutionResources` in the `CairoPie`.
/// An error will be returned if this doesn't hold.
use crate::vm::errors::cairo_run_errors::CairoRunError;
pub fn cairo_run_pie(
pie: &CairoPie,
cairo_run_config: &CairoRunConfig,
Expand All @@ -126,7 +125,7 @@ pub fn cairo_run_pie(
{
return Err(RunnerError::PieNStepsVsRunResourcesNStepsMismatch.into());
}
pie.run_validity_checks()?;
pie.run_validity_checks().unwrap();
let secure_run = cairo_run_config.secure_run.unwrap_or(true);

let allow_missing_builtins = cairo_run_config.allow_missing_builtins.unwrap_or_default();
Expand Down Expand Up @@ -170,7 +169,8 @@ pub fn cairo_run_pie(
// Check that the Cairo PIE produced by this run is compatible with the Cairo PIE received
cairo_runner
.get_cairo_pie(&vm)?
.check_pie_compatibility(pie)?;
.check_pie_compatibility(pie)
.unwrap();
}
cairo_runner.relocate(&mut vm, cairo_run_config.relocate_mem)?;

Expand Down
4 changes: 0 additions & 4 deletions vm/src/types/errors/math_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Felt252>),
#[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)]
Expand Down
3 changes: 0 additions & 3 deletions vm/src/vm/errors/cairo_run_errors.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use thiserror_no_std::Error;

use super::cairo_pie_errors::CairoPieValidationError;
use super::memory_errors::MemoryError;
use super::vm_exception::VmException;
use crate::types::errors::program_errors::ProgramError;
Expand All @@ -22,6 +21,4 @@ pub enum CairoRunError {
MemoryError(#[from] MemoryError),
#[error(transparent)]
VmException(#[from] VmException),
#[error("Cairo Pie validation failed: {0}")]
CairoPieValidation(#[from] CairoPieValidationError),
}
12 changes: 0 additions & 12 deletions vm/src/vm/errors/memory_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ pub enum MemoryError {
MissingMemoryCells(Box<BuiltinName>),
#[error("Missing memory cells for {}: {:?}", (*.0).0, (*.0).1)]
MissingMemoryCellsWithOffsets(Box<(BuiltinName, Vec<usize>)>),
#[error("ErrorInitializing Verifying Key from public key: {0:?}")]
InitializingVerifyingKey(Box<Vec<u8>>),
#[error(
"Signature {}, is invalid, with respect to the public key {},
and the message hash {}.", (*.0).0, (*.0).1, (*.0).2
Expand All @@ -65,20 +63,10 @@ pub enum MemoryError {
Add it using 'ecdsa_builtin.add_signature'."
)]
SignatureNotFound(Box<Relocatable>),
#[error("Could not create pubkey from: {0:?}")]
ErrorParsingPubKey(Box<str>),
#[error("Could not retrieve message from: {0:?}")]
ErrorRetrievingMessage(Box<str>),
#[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<Relocatable>),
#[error("ECDSA builtin: Expected message hash at address {0} to be an integer")]
MsgNonInt(Box<Relocatable>),
#[error("Failed to convert String: {0} to FieldElement")]
FailedStringToFieldElementConversion(Box<str>),
#[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)]
Expand Down
12 changes: 0 additions & 12 deletions vm/src/vm/errors/runner_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +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<Felt252>),
#[error("Given builtins are not in appropiate order")]
Expand Down Expand Up @@ -68,22 +66,12 @@ pub enum RunnerError {
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")]
Expand Down
20 changes: 4 additions & 16 deletions vm/src/vm/errors/vm_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ pub enum VirtualMachineError {
TracerError(#[from] TraceError),
#[error(transparent)]
MainScopeError(#[from] ExecScopeError),
#[error(transparent)]
Other(anyhow::Error),
// TODO: CHECK THIS
// #[error(transparent)]
// Other(anyhow::Error),
#[error("Instruction MSB should be 0")]
InstructionNonZeroHighBit,
#[error("Instruction should be an int")]
Expand Down Expand Up @@ -76,12 +77,8 @@ 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<MaybeRelocatable>)>),
#[error("Invalid hint encoding at pc: {0}")]
InvalidHintEncoding(Box<MaybeRelocatable>),
#[error("Expected output builtin to be present")]
NoOutputBuiltin,
#[error("Expected range_check builtin to be present")]
Expand All @@ -96,8 +93,6 @@ pub enum VirtualMachineError {
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<Option<MaybeRelocatable>>),
#[error("Could not convert slice to array")]
Expand All @@ -108,18 +103,13 @@ pub enum VirtualMachineError {
NoImm,
#[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<str>),
#[error("{HINT_ERROR_STR}{}", (*.0).1)]
Hint(Box<(usize, HintError)>),
// TODO CHECK THIS
#[error("Unexpected Failure")]
Unexpected,
#[error("Out of bounds access to builtin segment")]
Expand All @@ -128,8 +118,6 @@ pub enum VirtualMachineError {
OutOfBoundsProgramSegmentAccess,
#[error("Security Error: Invalid Memory Value: temporary address not relocated: {0}")]
InvalidMemoryValueTemporaryAddress(Box<Relocatable>),
#[error("accessed_addresses is None.")]
MissingAccessedAddresses,
#[error("Failed to write the output builtin content")]
FailedToWriteOutput,
#[error("Failed to find index {0} in the vm's relocation table")]
Expand Down
2 changes: 1 addition & 1 deletion vm/src/vm/runners/cairo_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
},
types::{builtin_name::BuiltinName, layout::MEMORY_UNITS_PER_STEP, layout_name::LayoutName},
vm::{
errors::cairo_run_errors::CairoRunError,
runners::builtin_runner::SegmentArenaBuiltinRunner,
trace::trace_entry::{relocate_trace_register, RelocatedTraceEntry},
},
Expand All @@ -28,7 +29,6 @@ use crate::{
utils::is_subsequence,
vm::{
errors::{
cairo_run_errors::CairoRunError,
memory_errors::{InsufficientAllocatedCellsError, MemoryError},
runner_errors::RunnerError,
trace_errors::TraceError,
Expand Down
Loading