Skip to content

Commit a24c1b8

Browse files
remove NonZeroReservedBits from VirtualMachineError (#1948)
1 parent 5420908 commit a24c1b8

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
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+
* feat: remove `NonZeroReservedBits` from `VirtualMachineError` [#1948](https://github.com/lambdaclass/cairo-vm/pull/1948)
6+
57
* feat: set `encoded_instruction` to be u128 for opcode_extensions to come [#1940](https://github.com/lambdaclass/cairo-vm/pull/1940)
68

79
* 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)

vm/src/vm/decoding/decoder.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ use crate::{
1313
/// opcode_extension_num=0 means the instruction is a Stone instruction.
1414
/// opcode_extension_num>0 is for new Stwo opcodes.
1515
pub fn decode_instruction(encoded_instr: u128) -> Result<Instruction, VirtualMachineError> {
16-
// HIGH_BITS_MASK is a mask to extract the high bits that are yet to be used in any opcode extension.
17-
const HIGH_BITS_MASK: u128 = ((1 << 127) - (1 << 64)) << 1;
1816
const DST_REG_MASK: u128 = 0x0001;
1917
const DST_REG_OFF: u128 = 0;
2018
const OP0_REG_MASK: u128 = 0x0002;
@@ -38,10 +36,6 @@ pub fn decode_instruction(encoded_instr: u128) -> Result<Instruction, VirtualMac
3836
const OFF2_OFF: u128 = 32;
3937
const OFFX_MASK: u128 = 0xFFFF;
4038

41-
if (encoded_instr & HIGH_BITS_MASK) != 0 {
42-
return Err(VirtualMachineError::NonZeroReservedBits);
43-
}
44-
4539
// Grab offsets and convert them from little endian format.
4640
let off0 = decode_offset(encoded_instr >> OFF0_OFF & OFFX_MASK);
4741
let off1 = decode_offset(encoded_instr >> OFF1_OFF & OFFX_MASK);
@@ -189,7 +183,7 @@ mod decoder_test {
189183
let error = decode_instruction(0x214a7800080008000);
190184
assert_eq!(
191185
error.unwrap_err().to_string(),
192-
"Reserved instruction bits must be 0",
186+
"Invalid opcode extension value: 4",
193187
)
194188
}
195189

vm/src/vm/errors/vm_errors.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ pub enum VirtualMachineError {
3434
MainScopeError(#[from] ExecScopeError),
3535
#[error(transparent)]
3636
Other(anyhow::Error),
37-
#[error("Reserved instruction bits must be 0")]
38-
NonZeroReservedBits,
3937
#[error("Instruction should be an int")]
4038
InvalidInstructionEncoding,
4139
#[error("Invalid op1_register value: {0}")]

0 commit comments

Comments
 (0)