Skip to content

Commit

Permalink
fix: unconstrained memory checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
ctian1 committed Aug 29, 2024
1 parent b424c14 commit 2b8cfa8
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions crates/core/executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ impl<'a> Executor<'a> {
let addr = Register::from_u32(i as u32) as u32;
let record = self.state.memory.get(&addr);

if self.executor_mode == ExecutorMode::Checkpoint {
if self.executor_mode == ExecutorMode::Checkpoint || self.unconstrained {
match record {
Some(record) => {
self.memory_checkpoint.entry(addr).or_insert_with(|| Some(*record));
Expand All @@ -281,7 +281,7 @@ impl<'a> Executor<'a> {
let addr = register as u32;
let record = self.state.memory.get(&addr);

if self.executor_mode == ExecutorMode::Checkpoint {
if self.executor_mode == ExecutorMode::Checkpoint || self.unconstrained {
match record {
Some(record) => {
self.memory_checkpoint.entry(addr).or_insert_with(|| Some(*record));
Expand All @@ -304,7 +304,7 @@ impl<'a> Executor<'a> {
#[allow(clippy::single_match_else)]
let record = self.state.memory.get(&addr);

if self.executor_mode == ExecutorMode::Checkpoint {
if self.executor_mode == ExecutorMode::Checkpoint || self.unconstrained {
match record {
Some(record) => {
self.memory_checkpoint.entry(addr).or_insert_with(|| Some(*record));
Expand Down Expand Up @@ -352,7 +352,7 @@ impl<'a> Executor<'a> {
pub fn mr(&mut self, addr: u32, shard: u32, timestamp: u32) -> MemoryReadRecord {
// Get the memory record entry.
let entry = self.state.memory.entry(addr);
if self.executor_mode == ExecutorMode::Checkpoint {
if self.executor_mode == ExecutorMode::Checkpoint || self.unconstrained {
match entry {
Entry::Occupied(ref entry) => {
let record = entry.get();
Expand Down Expand Up @@ -397,7 +397,7 @@ impl<'a> Executor<'a> {
pub fn mw(&mut self, addr: u32, value: u32, shard: u32, timestamp: u32) -> MemoryWriteRecord {
// Get the memory record entry.
let entry = self.state.memory.entry(addr);
if self.executor_mode == ExecutorMode::Checkpoint {
if self.executor_mode == ExecutorMode::Checkpoint || self.unconstrained {
match entry {
Entry::Occupied(ref entry) => {
let record = entry.get();
Expand Down Expand Up @@ -689,7 +689,7 @@ impl<'a> Executor<'a> {
let (addr, memory_read_value): (u32, u32);
let mut memory_store_value: Option<u32> = None;

if self.executor_mode == ExecutorMode::Checkpoint {
if self.executor_mode == ExecutorMode::Trace {
self.memory_accesses = MemoryAccessRecord::default();
}
let lookup_id =
Expand Down Expand Up @@ -1127,11 +1127,7 @@ impl<'a> Executor<'a> {
|| self.state.pc.wrapping_sub(self.program.pc_base)
>= (self.program.instructions.len() * 4) as u32;
if done && self.unconstrained {
log::error!(
"program ended in unconstrained mode at pc {} clk {}",
self.state.pc,
self.state.global_clk
);
log::error!("program ended in unconstrained mode at clk {}", self.state.global_clk);
return Err(ExecutionError::EndInUnconstrained());
}
Ok(done)
Expand Down

0 comments on commit 2b8cfa8

Please sign in to comment.