Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Golovanov399 committed Jan 21, 2025
1 parent b772fb0 commit 6a0f1fd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions extensions/native/circuit/src/extension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl<F: PrimeField32> VmExtension<F> for Native {
memory_bridge,
NativeLoadStoreOpcode::CLASS_OFFSET,
),
NativeLoadStoreCoreChip::new(),
NativeLoadStoreCoreChip::new(NativeLoadStoreOpcode::CLASS_OFFSET),
offline_memory.clone(),
);
load_store_chip.core.set_streams(builder.streams().clone());
Expand All @@ -134,7 +134,7 @@ impl<F: PrimeField32> VmExtension<F> for Native {
memory_bridge,
NativeLoadStore4Opcode::CLASS_OFFSET,
),
NativeLoadStoreCoreChip::new(),
NativeLoadStoreCoreChip::new(NativeLoadStore4Opcode::CLASS_OFFSET),
offline_memory.clone(),
);
block_load_store_chip
Expand Down
19 changes: 10 additions & 9 deletions extensions/native/circuit/src/loadstore/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ pub struct NativeLoadStoreCoreRecord<F, const NUM_CELLS: usize> {
}

#[derive(Clone, Debug)]
pub struct NativeLoadStoreCoreAir<const NUM_CELLS: usize> {}
pub struct NativeLoadStoreCoreAir<const NUM_CELLS: usize> {
pub offset: usize,
}

impl<F: Field, const NUM_CELLS: usize> BaseAir<F> for NativeLoadStoreCoreAir<NUM_CELLS> {
fn width(&self) -> usize {
Expand Down Expand Up @@ -107,7 +109,7 @@ where
}

fn start_offset(&self) -> usize {
NativeLoadStoreOpcode::CLASS_OFFSET
self.offset
}
}

Expand All @@ -118,9 +120,9 @@ pub struct NativeLoadStoreCoreChip<F: Field, const NUM_CELLS: usize> {
}

impl<F: Field, const NUM_CELLS: usize> NativeLoadStoreCoreChip<F, NUM_CELLS> {
pub fn new() -> Self {
pub fn new(offset: usize) -> Self {
Self {
air: NativeLoadStoreCoreAir::<NUM_CELLS> {},
air: NativeLoadStoreCoreAir::<NUM_CELLS> { offset },
streams: OnceLock::new(),
}
}
Expand All @@ -131,7 +133,7 @@ impl<F: Field, const NUM_CELLS: usize> NativeLoadStoreCoreChip<F, NUM_CELLS> {

impl<F: Field, const NUM_CELLS: usize> Default for NativeLoadStoreCoreChip<F, NUM_CELLS> {
fn default() -> Self {
Self::new()
Self::new(NativeLoadStoreOpcode::CLASS_OFFSET)
}
}

Expand All @@ -151,9 +153,8 @@ where
reads: I::Reads,
) -> Result<(AdapterRuntimeContext<F, I>, Self::Record)> {
let Instruction { opcode, .. } = *instruction;
let local_opcode = NativeLoadStoreOpcode::from_usize(
opcode.local_opcode_idx(NativeLoadStoreOpcode::CLASS_OFFSET),
);
let local_opcode =
NativeLoadStoreOpcode::from_usize(opcode.local_opcode_idx(self.air.offset));
let (pointer_read, data_read) = reads.into();

let data_write = if local_opcode == NativeLoadStoreOpcode::HINT_STOREW {
Expand Down Expand Up @@ -181,7 +182,7 @@ where
fn get_opcode_name(&self, opcode: usize) -> String {
format!(
"{:?}",
NativeLoadStoreOpcode::from_usize(opcode - NativeLoadStoreOpcode::CLASS_OFFSET)
NativeLoadStoreOpcode::from_usize(opcode - self.air.offset)
)
}

Expand Down
2 changes: 1 addition & 1 deletion extensions/native/circuit/src/loadstore/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ fn setup() -> (StdRng, VmChipTestBuilder<F>, NativeLoadStoreChip<F, 1>) {
tester.memory_bridge(),
NativeLoadStoreOpcode::CLASS_OFFSET,
);
let mut inner = NativeLoadStoreCoreChip::new();
let mut inner = NativeLoadStoreCoreChip::new(NativeLoadStoreOpcode::CLASS_OFFSET);
inner.set_streams(Arc::new(Mutex::new(Streams::default())));
let chip = NativeLoadStoreChip::<F, 1>::new(adapter, inner, tester.offline_memory_mutex_arc());
(rng, tester, chip)
Expand Down

0 comments on commit 6a0f1fd

Please sign in to comment.