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

CI sanity check [do not merge] #2952

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions o1vm/src/interpreters/mips/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ impl<Fp: Field, PreImageOracle: PreImageOracleT> InterpreterEnv for Env<Fp, PreI
);
}

#[allow(unreachable_code)]
fn request_preimage_write(
&mut self,
addr: &Self::Variable,
Expand All @@ -621,9 +622,10 @@ impl<Fp: Field, PreImageOracle: PreImageOracleT> InterpreterEnv for Env<Fp, PreI
preimage_key[4 * i + j] = bytes[j]
}
}
let preimage = self.preimage_oracle.get_preimage(preimage_key).get();
self.preimage = Some(preimage.clone());
self.preimage_key = Some(preimage_key);
panic!(
"Attempted to get preimage key {}",
hex::encode(preimage_key)
);
}

const LENGTH_SIZE: usize = 8;
Expand Down
64 changes: 34 additions & 30 deletions o1vm/src/preimage_oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::cannon::{
PREIMAGE_CLIENT_READ_FD, PREIMAGE_CLIENT_WRITE_FD,
};
use command_fds::{CommandFdExt, FdMapping};
use log::debug;
//use log::debug;
use os_pipe::{PipeReader, PipeWriter};
use std::{
io::{Read, Write},
Expand All @@ -20,7 +20,9 @@ pub struct PreImageOracle {
}

pub trait PreImageOracleT {
fn get_preimage(&mut self, key: [u8; 32]) -> Preimage;
fn get_preimage(&mut self, key: [u8; 32]) -> Preimage {
panic!("This function is never being used {}", hex::encode(key));
}

fn hint(&mut self, hint: Hint);
}
Expand Down Expand Up @@ -176,35 +178,37 @@ impl PreImageOracleT for PreImageOracle {
// +---------------------------------+
// a. a 64-bit integer indicating the length of the actual data
// b. the preimage data, with a size of <length> bits
#[allow(unreachable_code)]
fn get_preimage(&mut self, key: [u8; 32]) -> Preimage {
let RW(ReadWrite { reader, writer }) = &mut self.oracle_client;

let r = writer.write_all(&key);
assert!(r.is_ok());
let r = writer.flush();
assert!(r.is_ok());

debug!("Reading response");
let mut buf = [0_u8; 8];
let resp = reader.read_exact(&mut buf);
assert!(resp.is_ok());

debug!("Extracting contents");
let length = u64::from_be_bytes(buf);
let mut preimage = vec![0_u8; length as usize];
let resp = reader.read_exact(&mut preimage);

assert!(resp.is_ok());

debug!(
"Got preimage of length {}\n {}",
preimage.len(),
hex::encode(&preimage)
);
// We should have read exactly <length> bytes
assert_eq!(preimage.len(), length as usize);

Preimage::create(preimage)
panic!("Attempted to get preimage for key {}", hex::encode(key));
//let RW(ReadWrite { reader, writer }) = &mut self.oracle_client;

//let r = writer.write_all(&key);
//assert!(r.is_ok());
//let r = writer.flush();
//assert!(r.is_ok());

//debug!("Reading response");
//let mut buf = [0_u8; 8];
//let resp = reader.read_exact(&mut buf);
//assert!(resp.is_ok());

//debug!("Extracting contents");
//let length = u64::from_be_bytes(buf);
//let mut preimage = vec![0_u8; length as usize];
//let resp = reader.read_exact(&mut preimage);

//assert!(resp.is_ok());

//debug!(
// "Got preimage of length {}\n {}",
// preimage.len(),
// hex::encode(&preimage)
//);
//// We should have read exactly <length> bytes
//assert_eq!(preimage.len(), length as usize);

//Preimage::create(preimage)
}

// The hint protocol goes as follows:
Expand Down
Loading