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

Check error types in vm_core.rs + simplify code #837

Merged
merged 9 commits into from
Feb 15, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix
  • Loading branch information
fmoletta committed Feb 14, 2023
commit d13878eed92ba25df66e7b654def440278ed8c6e
26 changes: 10 additions & 16 deletions src/vm/vm_core.rs
Original file line number Diff line number Diff line change
@@ -302,7 +302,7 @@ impl VirtualMachine {
(
Some(MaybeRelocatable::Int(num_dst)),
Some(MaybeRelocatable::Int(num_op0)),
) if num_op0.is_zero() => {
) if !num_op0.is_zero() => {
return Ok((Some(MaybeRelocatable::Int(num_dst / num_op0)), dst.cloned()))
}
_ => (),
@@ -357,7 +357,7 @@ impl VirtualMachine {
res: Option<&MaybeRelocatable>,
) -> Option<MaybeRelocatable> {
match instruction.opcode {
Opcode::AssertEq => res.map(Clone::clone),
Opcode::AssertEq => res.cloned(),
Opcode::Call => Some(self.get_fp().into()),
_ => None,
}
@@ -369,20 +369,14 @@ impl VirtualMachine {
operands: &Operands,
) -> Result<(), VirtualMachineError> {
match instruction.opcode {
Opcode::AssertEq => {
match &operands.res {
None => return Err(VirtualMachineError::UnconstrainedResAssertEq),
Some(res) => {
if res != &operands.dst {
return Err(VirtualMachineError::DiffAssertValues(
operands.dst.clone(),
res.clone(),
));
};
}
};
Ok(())
}
Opcode::AssertEq => match &operands.res {
None => Err(VirtualMachineError::UnconstrainedResAssertEq),
Some(res) if res != &operands.dst => Err(VirtualMachineError::DiffAssertValues(
operands.dst.clone(),
res.clone(),
)),
_ => Ok(()),
},
Opcode::Call => {
let return_pc = MaybeRelocatable::from(self.run_context.pc + instruction.size());
if operands.op0 != return_pc {