Skip to content

Commit f6a0bc1

Browse files
authored
chore: remove an old assert!(address_space < NATIVE_AS) (#1948)
This resolves INT-4549. The assertion was a sanity check and it essentially checked that the "type size" should be greater than one. I replaced it with an `debug_assert_eq!(align, min block size from config)`. While we are there, I also replaced some `cell_size` being `size_of::<T>()` or 1 with another value from config.
1 parent 4869545 commit f6a0bc1

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

crates/vm/src/system/memory/online.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::{array::from_fn, fmt::Debug, num::NonZero};
22

33
use getset::Getters;
44
use itertools::zip_eq;
5-
use openvm_instructions::{exe::SparseMemoryImage, NATIVE_AS};
5+
use openvm_instructions::exe::SparseMemoryImage;
66
use openvm_stark_backend::{
77
p3_field::{Field, PrimeField32},
88
p3_maybe_rayon::prelude::*,
@@ -690,6 +690,18 @@ impl TracingMemory {
690690
pointer: usize,
691691
prev_values: &[T; BLOCK_SIZE],
692692
) -> u32 {
693+
debug_assert_eq!(ALIGN, self.data.memory.config[address_space].min_block_size);
694+
debug_assert_eq!(
695+
unsafe {
696+
self.data
697+
.memory
698+
.config
699+
.get_unchecked(address_space)
700+
.layout
701+
.size()
702+
},
703+
size_of::<T>()
704+
);
693705
// Calculate what splits and merges are needed for this memory access
694706
let result = if let Some((splits, (merge_ptr, merge_size))) =
695707
self.calculate_splits_and_merges::<BLOCK_SIZE, ALIGN>(address_space, pointer)
@@ -781,15 +793,14 @@ impl TracingMemory {
781793
} else {
782794
// Create a merge record for single-byte initialization
783795
debug_assert_eq!(self.initial_block_size, 1);
784-
debug_assert!((address_space as u32) < NATIVE_AS);
785796
self.add_merge_record(
786797
AccessRecordHeader {
787798
timestamp_and_mask: INITIAL_TIMESTAMP,
788799
address_space: address_space as u32,
789800
pointer: pointer as u32,
790801
block_size: ALIGN as u32,
791802
lowest_block_size: self.initial_block_size as u32,
792-
type_size: 1,
803+
type_size: size_of::<T>() as u32,
793804
},
794805
&INITIAL_CELL_BUFFER[..ALIGN],
795806
&INITIAL_TIMESTAMP_BUFFER[..ALIGN],

0 commit comments

Comments
 (0)