Skip to content

Commit

Permalink
Merge pull request #1333 from o1-labs/feature/mips-next-ip
Browse files Browse the repository at this point in the history
Track next_instruction_pointer in MIPS VM
  • Loading branch information
mrmr1993 authored Nov 16, 2023
2 parents 5ea4861 + b46a860 commit ad91893
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion optimism/src/cannon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct State {
pub preimage_offset: u32,
pub pc: u32,
#[serde(rename = "nextPC")]
next_pc: u32, //
pub next_pc: u32,
pub lo: u32,
pub hi: u32,
pub heap: u32,
Expand Down
3 changes: 3 additions & 0 deletions optimism/src/mips/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub struct Env<Fp> {
pub registers: Registers<u32>,
pub registers_write_index: Registers<usize>,
pub instruction_pointer: u32,
pub next_instruction_pointer: u32,
pub scratch_state_idx: usize,
pub scratch_state: [Fp; SCRATCH_SIZE],
pub halt: bool,
Expand Down Expand Up @@ -94,6 +95,7 @@ fn memory_size(total: usize) -> String {
impl<Fp: Field> Env<Fp> {
pub fn create(page_size: usize, state: State) -> Self {
let initial_instruction_pointer = state.pc;
let next_instruction_pointer = state.next_pc;

let syscall_env = SyscallEnv::create(&state);

Expand Down Expand Up @@ -130,6 +132,7 @@ impl<Fp: Field> Env<Fp> {
registers: initial_registers.clone(),
registers_write_index: Registers::default(),
instruction_pointer: initial_instruction_pointer,
next_instruction_pointer,
scratch_state_idx: 0,
scratch_state: fresh_scratch_state(),
halt: state.exited,
Expand Down

0 comments on commit ad91893

Please sign in to comment.