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

add get_u32_range to impl VirtualMachine add get_u32 and get_u32_range to impl Memory #1936

Merged
merged 1 commit into from
Feb 11, 2025

Conversation

ohad-nir-starkware
Copy link
Collaborator

@ohad-nir-starkware ohad-nir-starkware commented Feb 4, 2025

add get_u32_range to impl VirtualMachine add get_u32 and get_u32_range to impl Memory

Description

The Blake opcode will use u32 values stored as Felt252s inside memory cells.
In preparation for the implementation of the opcode, I added the function add get_u32_range to impl VirtualMachine and added the functions get_u32 and get_u32_range to impl Memory.

get_u32 receives a Relocatable and returns Result<u32, MemoryError>.
If the input address points to a u32 sized integer num it returns OK(num),
otherwise it returns a MemoryError::ExpectedU32 error.

get_u32_range receives a starting address and a size and returns Result<Vec, MemoryError>.
If all the locations addr, addr+1, ... addr+size-1 contain u32 integers, it returns them as a vector inside OK.
If any of those addresses don't contain a u32 sized integer, it returns an error.

Checklist

  • Linked to Github Issue
  • Unit tests added
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.
    • CHANGELOG has been updated.

This change is Reviewable

Copy link

github-actions bot commented Feb 4, 2025

**Hyper Thereading Benchmark results**




hyperfine -r 2 -n "hyper_threading_main threads: 1" 'RAYON_NUM_THREADS=1 ./hyper_threading_main' -n "hyper_threading_pr threads: 1" 'RAYON_NUM_THREADS=1 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 1
  Time (mean ± σ):     32.378 s ±  0.529 s    [User: 31.693 s, System: 0.683 s]
  Range (min … max):   32.004 s … 32.752 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     31.871 s ±  0.258 s    [User: 31.154 s, System: 0.716 s]
  Range (min … max):   31.689 s … 32.053 s    2 runs
 
Summary
  hyper_threading_pr threads: 1 ran
    1.02 ± 0.02 times faster than hyper_threading_main threads: 1




hyperfine -r 2 -n "hyper_threading_main threads: 2" 'RAYON_NUM_THREADS=2 ./hyper_threading_main' -n "hyper_threading_pr threads: 2" 'RAYON_NUM_THREADS=2 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 2
  Time (mean ± σ):     17.780 s ±  0.049 s    [User: 30.971 s, System: 0.802 s]
  Range (min … max):   17.745 s … 17.815 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     17.664 s ±  0.057 s    [User: 30.976 s, System: 0.786 s]
  Range (min … max):   17.623 s … 17.704 s    2 runs
 
Summary
  hyper_threading_pr threads: 2 ran
    1.01 ± 0.00 times faster than hyper_threading_main threads: 2




hyperfine -r 2 -n "hyper_threading_main threads: 4" 'RAYON_NUM_THREADS=4 ./hyper_threading_main' -n "hyper_threading_pr threads: 4" 'RAYON_NUM_THREADS=4 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 4
  Time (mean ± σ):     12.060 s ±  0.254 s    [User: 43.955 s, System: 0.920 s]
  Range (min … max):   11.880 s … 12.240 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     12.274 s ±  0.784 s    [User: 44.690 s, System: 0.901 s]
  Range (min … max):   11.720 s … 12.829 s    2 runs
 
Summary
  hyper_threading_main threads: 4 ran
    1.02 ± 0.07 times faster than hyper_threading_pr threads: 4




hyperfine -r 2 -n "hyper_threading_main threads: 6" 'RAYON_NUM_THREADS=6 ./hyper_threading_main' -n "hyper_threading_pr threads: 6" 'RAYON_NUM_THREADS=6 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 6
  Time (mean ± σ):     12.140 s ±  0.149 s    [User: 43.932 s, System: 0.929 s]
  Range (min … max):   12.035 s … 12.245 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     12.132 s ±  0.089 s    [User: 44.237 s, System: 0.901 s]
  Range (min … max):   12.069 s … 12.195 s    2 runs
 
Summary
  hyper_threading_pr threads: 6 ran
    1.00 ± 0.01 times faster than hyper_threading_main threads: 6




hyperfine -r 2 -n "hyper_threading_main threads: 8" 'RAYON_NUM_THREADS=8 ./hyper_threading_main' -n "hyper_threading_pr threads: 8" 'RAYON_NUM_THREADS=8 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 8
  Time (mean ± σ):     11.946 s ±  0.067 s    [User: 44.450 s, System: 0.895 s]
  Range (min … max):   11.899 s … 11.994 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     11.878 s ±  0.293 s    [User: 44.685 s, System: 0.913 s]
  Range (min … max):   11.671 s … 12.085 s    2 runs
 
Summary
  hyper_threading_pr threads: 8 ran
    1.01 ± 0.03 times faster than hyper_threading_main threads: 8




hyperfine -r 2 -n "hyper_threading_main threads: 16" 'RAYON_NUM_THREADS=16 ./hyper_threading_main' -n "hyper_threading_pr threads: 16" 'RAYON_NUM_THREADS=16 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 16
  Time (mean ± σ):     12.000 s ±  0.172 s    [User: 44.673 s, System: 1.012 s]
  Range (min … max):   11.878 s … 12.122 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     11.877 s ±  0.124 s    [User: 44.732 s, System: 0.988 s]
  Range (min … max):   11.789 s … 11.964 s    2 runs
 
Summary
  hyper_threading_pr threads: 16 ran
    1.01 ± 0.02 times faster than hyper_threading_main threads: 16


Copy link

github-actions bot commented Feb 4, 2025

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.533 ± 0.064 2.470 2.656 1.01 ± 0.03
head big_factorial 2.498 ± 0.021 2.479 2.539 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.446 ± 0.034 2.405 2.485 1.00 ± 0.02
head big_fibonacci 2.441 ± 0.018 2.421 2.476 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 9.205 ± 0.086 9.064 9.327 1.00
head blake2s_integration_benchmark 9.241 ± 0.187 9.129 9.732 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.624 ± 0.040 2.573 2.709 1.00
head compare_arrays_200000 2.627 ± 0.051 2.590 2.764 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.718 ± 0.030 1.673 1.788 1.00
head dict_integration_benchmark 1.721 ± 0.029 1.697 1.797 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.436 ± 0.019 1.415 1.471 1.00
head field_arithmetic_get_square_benchmark 1.460 ± 0.031 1.431 1.537 1.02 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 9.351 ± 0.152 9.134 9.688 1.00
head integration_builtins 9.386 ± 0.299 9.197 10.170 1.00 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 9.610 ± 0.283 9.397 10.393 1.01 ± 0.03
head keccak_integration_benchmark 9.542 ± 0.038 9.490 9.619 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.587 ± 0.025 2.546 2.613 1.00
head linear_search 2.616 ± 0.040 2.565 2.677 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.756 ± 0.015 1.744 1.790 1.00
head math_cmp_and_pow_integration_benchmark 1.774 ± 0.017 1.757 1.814 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.709 ± 0.046 1.681 1.830 1.00
head math_integration_benchmark 1.736 ± 0.044 1.699 1.838 1.02 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.439 ± 0.021 1.411 1.484 1.00
head memory_integration_benchmark 1.452 ± 0.016 1.425 1.473 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.816 ± 0.035 1.791 1.908 1.00 ± 0.02
head operations_with_data_structures_benchmarks 1.812 ± 0.012 1.791 1.834 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 588.5 ± 10.4 580.7 609.5 1.01 ± 0.02
head pedersen 585.0 ± 2.0 582.3 587.7 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 698.8 ± 7.4 689.8 712.6 1.00
head poseidon_integration_benchmark 705.4 ± 11.1 695.3 733.8 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.064 ± 0.014 2.048 2.083 1.00
head secp_integration_benchmark 2.075 ± 0.023 2.052 2.134 1.01 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 722.7 ± 13.1 694.2 745.2 1.04 ± 0.08
head set_integration_benchmark 697.4 ± 55.5 676.6 855.4 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 5.111 ± 0.112 5.012 5.402 1.00
head uint256_integration_benchmark 5.151 ± 0.124 5.061 5.474 1.01 ± 0.03

Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.37%. Comparing base (aa3ec83) to head (4598d76).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1936   +/-   ##
=======================================
  Coverage   96.36%   96.37%           
=======================================
  Files         102      102           
  Lines       41173    41238   +65     
=======================================
+ Hits        39677    39742   +65     
  Misses       1496     1496           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

@DavidLevitGurevich DavidLevitGurevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @ohad-nir-starkware, @Oppen, @pefontana, and @YairVaknin-starkware)


vm/src/vm/vm_core.rs line 936 at r2 (raw file):

    pub fn get_u32_range(
        &self,
        addr: &MaybeRelocatable,

the other functions in this file get Relocatable, why this is different?

@ohad-nir-starkware ohad-nir-starkware force-pushed the ohadn/get_u32_range branch 2 times, most recently from 961435d to a4b95e7 Compare February 5, 2025 07:42
Copy link
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 1 of 4 files reviewed, 1 unresolved discussion (waiting on @DavidLevitGurevich, @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, @pefontana, and @YairVaknin-starkware)


vm/src/vm/vm_core.rs line 936 at r2 (raw file):

Previously, DavidLevitGurevich wrote…

the other functions in this file get Relocatable, why this is different?

refactored the code, now it gets Relocatable.

@ohad-nir-starkware ohad-nir-starkware changed the title add the functions get_u32_range and get_u32_from_felt252 to impl VirtualMachine add get_u32_range to impl VirtualMachine add get_u32 and get_u32_range to impl Memory Feb 5, 2025
Copy link

@DavidLevitGurevich DavidLevitGurevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

please wait for @YairVaknin-starkware before you merge

Reviewed 4 of 4 files at r3, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, @pefontana, and @YairVaknin-starkware)

Copy link

@Stavbe Stavbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, @pefontana, and @YairVaknin-starkware)

Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ohad-nir-starkware! I left you some small comments.

Comment on lines 420 to 429
let value = Cow::into_owned(self.get_integer(key)?);
let le_digits = value.to_le_digits();
if le_digits[0] >= (1_u64 << 32)
|| le_digits[1] != 0
|| le_digits[2] != 0
|| le_digits[3] != 0
{
return Err(MemoryError::ExpectedU32(Box::new(key)));
}
Ok(le_digits[0] as u32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly to get_usize method, I think we could call felt.to_u32() here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 104 to 105
#[error("Expected u32 valued at address {0} to be u32")]
ExpectedU32(Box<Relocatable>),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the following is a bit more clearer and consistent:

Suggested change
#[error("Expected u32 valued at address {0} to be u32")]
ExpectedU32(Box<Relocatable>),
#[error("Expected u32 at address {0}")]
ExpectedU32(Box<Relocatable>),

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering your comment on felt.to_u32(), we might not need this variant of MemoryError

Copy link
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 3 of 4 files reviewed, 2 unresolved discussions (waiting on @DavidLevitGurevich, @fmoletta, @gabrielbosio, @igaray, @juanbono, @JulianGCalderon, @Oppen, @pefontana, and @YairVaknin-starkware)

Comment on lines 104 to 105
#[error("Expected u32 valued at address {0} to be u32")]
ExpectedU32(Box<Relocatable>),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering your comment on felt.to_u32(), we might not need this variant of MemoryError

Comment on lines 420 to 429
let value = Cow::into_owned(self.get_integer(key)?);
let le_digits = value.to_le_digits();
if le_digits[0] >= (1_u64 << 32)
|| le_digits[1] != 0
|| le_digits[2] != 0
|| le_digits[3] != 0
{
return Err(MemoryError::ExpectedU32(Box::new(key)));
}
Ok(le_digits[0] as u32)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

@YairVaknin-starkware YairVaknin-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 4 files at r3.
Reviewable status: 2 of 5 files reviewed, 6 unresolved discussions (waiting on @DavidLevitGurevich, @fmoletta, @gabrielbosio, @igaray, @juanbono, @JulianGCalderon, @Oppen, and @pefontana)


vm/src/vm/vm_core.rs line 933 at r5 (raw file):

    /// Gets n u32 values from memory starting from addr (n being size),
    pub fn get_u32_range(&self, addr: Relocatable, size: usize) -> Result<Vec<u32>, MemoryError> {

Add failure cases to docstring with tests for them.

Code quote:

pub fn get_u32_range(&self, addr: Relocatable, size: usize) -> Result<Vec<u32>, MemoryError>

vm/src/vm/vm_core.rs line 4383 at r5 (raw file):

    #[test]
    #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
    fn get_u32_range_ok() {

Add a test covering the error flow too.

Code quote:

get_u32_range_ok

vm/src/vm/vm_memory/memory.rs line 635 at r5 (raw file):

    /// Gets a range of u32 memory values from addr to addr + size
    /// Fails if there if any of the values inside the range is missing (memory gap) or is not a u32

Add tests covering both of those failure scenarios.
Also, maybe add a test for the happy flow (though the one in the vm module pretty much tests this logic, so up to you).

Code quote:

Fails if there if any of the values inside the range is missing (memory gap) or is not a u32

vm/src/vm/vm_memory/memory.rs line 641 at r5 (raw file):

        for i in 0..size {
            values.push(self.get_u32((addr + i)?)?);
        }

Would something along the lines of:
(0..size) .map(|i| (addr + i).and_then(|a| self.get_u32(a))) .collect()
work instead? (prolly would also need to pay attention to the error from the addition).

Non-blocking.

Code quote:

        let mut values = Vec::new();

        for i in 0..size {
            values.push(self.get_u32((addr + i)?)?);
        }

Copy link
Collaborator

@YairVaknin-starkware YairVaknin-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 4 files at r3, all commit messages.
Reviewable status: 2 of 5 files reviewed, 7 unresolved discussions (waiting on @DavidLevitGurevich, @fmoletta, @gabrielbosio, @igaray, @juanbono, @JulianGCalderon, @ohad-nir-starkware, @Oppen, and @pefontana)


vm/src/vm/decoding/decoder.rs line 11 at r5 (raw file):

//           ... 15|14 13 12|    11 10|  9  8  7|     6  5|4  3  2|      1|      0

/// Decodes an instruction. The encoding is little endian, so flags go from bit 64 to 48.

63

Code quote:

64

@@ -8,7 +8,7 @@ use crate::{
// opcode_extension| opcode|ap_update|pc_update|res_logic|op1_src|op0_reg|dst_reg
// ... 15|14 13 12| 11 10| 9 8 7| 6 5|4 3 2| 1| 0

/// Decodes an instruction. The encoding is little endian, so flags go from bit 63 to 48.
/// Decodes an instruction. The encoding is little endian, so flags go from bit 64 to 48.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change attempts to sync a change done in another PR (#1933). It would be better to have this change in that PR instead of this one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +1158 to +1174
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn get_u32_too_big() {
let mut segments = MemorySegmentManager::new();
segments.add();
segments
.memory
.insert(Relocatable::from((0, 0)), &Felt252::from(1_u64 << 32))
.unwrap();
assert_matches!(
segments.memory.get_u32(Relocatable::from((0, 0))),
Err(MemoryError::Math(MathError::Felt252ToU32Conversion(
bx
))) if *bx == Felt252::from(1_u64 << 32)
);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add more test cases:

  • Happy paths
  • Memory gap inside the range passed to get_u32_range

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link

@DavidLevitGurevich DavidLevitGurevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r5, all commit messages.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @fmoletta, @igaray, @juanbono, @JulianGCalderon, @ohad-nir-starkware, @Oppen, and @pefontana)

Copy link
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @JulianGCalderon, @Oppen, @pefontana, and @YairVaknin-starkware)


vm/src/vm/vm_core.rs line 933 at r5 (raw file):

Previously, YairVaknin-starkware wrote…

Add failure cases to docstring with tests for them.

Done.


vm/src/vm/vm_core.rs line 4383 at r5 (raw file):

Previously, YairVaknin-starkware wrote…

Add a test covering the error flow too.

Done.


vm/src/vm/decoding/decoder.rs line 11 at r5 (raw file):

Previously, YairVaknin-starkware wrote…

63

Done.


vm/src/vm/vm_memory/memory.rs line 635 at r5 (raw file):

Previously, YairVaknin-starkware wrote…

Add tests covering both of those failure scenarios.
Also, maybe add a test for the happy flow (though the one in the vm module pretty much tests this logic, so up to you).

Done.


vm/src/vm/vm_memory/memory.rs line 641 at r5 (raw file):

Previously, YairVaknin-starkware wrote…

Would something along the lines of:
(0..size) .map(|i| (addr + i).and_then(|a| self.get_u32(a))) .collect()
work instead? (prolly would also need to pay attention to the error from the addition).

Non-blocking.

not sure, but this is how it was done in get_integer_range, get_continuous_rangeand get_range

@@ -8,7 +8,7 @@ use crate::{
// opcode_extension| opcode|ap_update|pc_update|res_logic|op1_src|op0_reg|dst_reg
// ... 15|14 13 12| 11 10| 9 8 7| 6 5|4 3 2| 1| 0

/// Decodes an instruction. The encoding is little endian, so flags go from bit 63 to 48.
/// Decodes an instruction. The encoding is little endian, so flags go from bit 64 to 48.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines +1158 to +1174
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn get_u32_too_big() {
let mut segments = MemorySegmentManager::new();
segments.add();
segments
.memory
.insert(Relocatable::from((0, 0)), &Felt252::from(1_u64 << 32))
.unwrap();
assert_matches!(
segments.memory.get_u32(Relocatable::from((0, 0))),
Err(MemoryError::Math(MathError::Felt252ToU32Conversion(
bx
))) if *bx == Felt252::from(1_u64 << 32)
);
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

@YairVaknin-starkware YairVaknin-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 3 files at r6, all commit messages.
Reviewable status: 4 of 5 files reviewed, 5 unresolved discussions (waiting on @DavidLevitGurevich, @fmoletta, @gabrielbosio, @igaray, @juanbono, @JulianGCalderon, @Oppen, and @pefontana)

Copy link
Collaborator

@YairVaknin-starkware YairVaknin-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 3 files at r5.
Reviewable status: 4 of 5 files reviewed, 5 unresolved discussions (waiting on @DavidLevitGurevich, @fmoletta, @gabrielbosio, @igaray, @juanbono, @JulianGCalderon, @Oppen, and @pefontana)

Copy link
Collaborator

@YairVaknin-starkware YairVaknin-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: 4 of 5 files reviewed, 5 unresolved discussions (waiting on @DavidLevitGurevich, @fmoletta, @gabrielbosio, @igaray, @juanbono, @JulianGCalderon, @Oppen, and @pefontana)

Copy link
Collaborator

@YairVaknin-starkware YairVaknin-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 3 files at r6.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @JulianGCalderon, @Oppen, and @pefontana)

@ohad-nir-starkware ohad-nir-starkware changed the base branch from ohadn/opcode_extension to main February 11, 2025 15:21
@@ -42,7 +43,7 @@ pub fn decode_instruction(encoded_instr: u64) -> Result<Instruction, VirtualMach
let off2 = decode_offset(encoded_instr >> OFF2_OFF & OFFX_MASK);

// Grab flags
let flags = encoded_instr >> FLAGS_OFFSET;
let flags = (encoded_instr >> FLAGS_OFFSET) & FLAGS_MASK;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -31,6 +31,7 @@ pub fn decode_instruction(encoded_instr: u64) -> Result<Instruction, VirtualMach

// Flags start on the 48th bit.
const FLAGS_OFFSET: u64 = 48;
const FLAGS_MASK: u64 = 0x7FFF;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @JulianGCalderon, @Oppen, and @pefontana)

@@ -31,6 +31,7 @@ pub fn decode_instruction(encoded_instr: u64) -> Result<Instruction, VirtualMach

// Flags start on the 48th bit.
const FLAGS_OFFSET: u64 = 48;
const FLAGS_MASK: u64 = 0x7FFF;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -42,7 +43,7 @@ pub fn decode_instruction(encoded_instr: u64) -> Result<Instruction, VirtualMach
let off2 = decode_offset(encoded_instr >> OFF2_OFF & OFFX_MASK);

// Grab flags
let flags = encoded_instr >> FLAGS_OFFSET;
let flags = (encoded_instr >> FLAGS_OFFSET) & FLAGS_MASK;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@gabrielbosio gabrielbosio added this pull request to the merge queue Feb 11, 2025
Merged via the queue into main with commit 974e621 Feb 11, 2025
91 checks passed
@gabrielbosio gabrielbosio deleted the ohadn/get_u32_range branch February 11, 2025 19:06
Copy link

@DavidLevitGurevich DavidLevitGurevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 2 of 3 files at r6, 2 of 2 files at r7, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants