From a24c1b84dc70476d4c7e8ccde36db83f5b0dbcfa Mon Sep 17 00:00:00 2001 From: Ohad Nir <141617878+ohad-nir-starkware@users.noreply.github.com> Date: Wed, 12 Feb 2025 21:01:39 +0200 Subject: [PATCH] remove NonZeroReservedBits from VirtualMachineError (#1948) --- CHANGELOG.md | 2 ++ vm/src/vm/decoding/decoder.rs | 8 +------- vm/src/vm/errors/vm_errors.rs | 2 -- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0497cac9cf..8c655c11d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ #### Upcoming Changes +* feat: remove `NonZeroReservedBits` from `VirtualMachineError` [#1948](https://github.com/lambdaclass/cairo-vm/pull/1948) + * feat: set `encoded_instruction` to be u128 for opcode_extensions to come [#1940](https://github.com/lambdaclass/cairo-vm/pull/1940) * feat: add `get_u32_range` to `impl VirtualMachine` add `get_u32` and `get_u32_range` to `impl Memory` [#1936](https://github.com/lambdaclass/cairo-vm/pull/1936) diff --git a/vm/src/vm/decoding/decoder.rs b/vm/src/vm/decoding/decoder.rs index 70049cc2f5..5f78a81e02 100644 --- a/vm/src/vm/decoding/decoder.rs +++ b/vm/src/vm/decoding/decoder.rs @@ -13,8 +13,6 @@ use crate::{ /// opcode_extension_num=0 means the instruction is a Stone instruction. /// opcode_extension_num>0 is for new Stwo opcodes. pub fn decode_instruction(encoded_instr: u128) -> Result { - // HIGH_BITS_MASK is a mask to extract the high bits that are yet to be used in any opcode extension. - const HIGH_BITS_MASK: u128 = ((1 << 127) - (1 << 64)) << 1; const DST_REG_MASK: u128 = 0x0001; const DST_REG_OFF: u128 = 0; const OP0_REG_MASK: u128 = 0x0002; @@ -38,10 +36,6 @@ pub fn decode_instruction(encoded_instr: u128) -> Result> OFF0_OFF & OFFX_MASK); let off1 = decode_offset(encoded_instr >> OFF1_OFF & OFFX_MASK); @@ -189,7 +183,7 @@ mod decoder_test { let error = decode_instruction(0x214a7800080008000); assert_eq!( error.unwrap_err().to_string(), - "Reserved instruction bits must be 0", + "Invalid opcode extension value: 4", ) } diff --git a/vm/src/vm/errors/vm_errors.rs b/vm/src/vm/errors/vm_errors.rs index 3733c12270..e225f96d5f 100644 --- a/vm/src/vm/errors/vm_errors.rs +++ b/vm/src/vm/errors/vm_errors.rs @@ -34,8 +34,6 @@ pub enum VirtualMachineError { MainScopeError(#[from] ExecScopeError), #[error(transparent)] Other(anyhow::Error), - #[error("Reserved instruction bits must be 0")] - NonZeroReservedBits, #[error("Instruction should be an int")] InvalidInstructionEncoding, #[error("Invalid op1_register value: {0}")]