Skip to content

Commit

Permalink
danny pr review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
martyall committed Jan 2, 2025
1 parent b81e92d commit 57c7ec1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 64 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ You can visualize the documentation by opening the file `target/doc/index.html`.
This workflow runs benchmarks when a pull request is labeled with "benchmark." It sets up the Rust and OCaml environments, installs necessary tools, and executes cargo criterion benchmarks on the kimchi crate. The benchmark results are then posted as a comment on the pull request for review.
- [Deploy Specifications & Docs to GitHub Pages](.github/workflows/gh-page.yml).
When CI passes on master, the documentation built from the rust code will be available by this [link](https://o1-labs.github.io/proof-systems/rustdoc) and the book will be available by this [link](https://o1-labs.github.io/proof-systems).
- [MIPS Build and Package](.github/workflows/mips-build.yml)
This workflow runs the assembler and linker on the programs from the OpenMips test suite, and provides a link where you can download the artifacts (recommended if you don't have / can't install the required MIPS tooling). This workflow also runs the o1vm ELF parser on the artifacts to check that our parsing is working. Currently it is run via manual trigger only -- you can find the trigger in the [GitHub actions tab](https://github.com/o1-labs/proof-systems/actions/workflows/mips-build.yml) and the link to the artifacts will appear in logs of the `Upload Artifacts` stage.

## Nix for Dependencies (WIP)

Expand Down
37 changes: 0 additions & 37 deletions o1vm/meta_test.json

This file was deleted.

4 changes: 2 additions & 2 deletions o1vm/src/elf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::{collections::HashMap, path::Path};

pub enum Architecture {
Mips,
RiscV,
RiscV32,
}

pub fn make_state<T: EndianParse>(file: ElfBytes<T>) -> Result<State, String> {
Expand Down Expand Up @@ -157,7 +157,7 @@ pub fn parse_elf(arch: Architecture, path: &Path) -> Result<State, String> {
assert_eq!(file.ehdr.e_machine, 8);
make_state(file)
}
Architecture::RiscV => {
Architecture::RiscV32 => {
let file =
ElfBytes::<LittleEndian>::minimal_parse(slice).expect("Open ELF file failed.");
assert_eq!(file.ehdr.e_machine, 243);
Expand Down
2 changes: 1 addition & 1 deletion o1vm/tests/test_elf_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn test_correctly_parsing_elf() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/fibonacci",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();

// This is the output we get by running objdump -d fibonacci
assert_eq!(state.pc, 69932);
Expand Down
48 changes: 24 additions & 24 deletions o1vm/tests/test_riscv_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn test_registers_indexed_by_alias() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/sll",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

assert_eq!(witness.registers[Ip], 65652);
Expand Down Expand Up @@ -46,7 +46,7 @@ fn test_no_action() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/no-action",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);
// This is the output we get by running objdump -d no-action
assert_eq!(witness.registers.current_instruction_pointer, 69844);
Expand All @@ -73,7 +73,7 @@ fn test_fibonacci_7() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/fibonacci-7",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);
// This is the output we get by running objdump -d fibonacci-7
assert_eq!(witness.registers.current_instruction_pointer, 69932);
Expand All @@ -95,7 +95,7 @@ fn test_sll() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/sll",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -112,7 +112,7 @@ fn test_addi() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/addi",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -128,7 +128,7 @@ fn test_add_1() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/add_1",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -144,7 +144,7 @@ fn test_add_2() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/add_2",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -166,7 +166,7 @@ fn test_add_overflow() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/add_overflow",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -186,7 +186,7 @@ fn test_addi_negative() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/addi_negative",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -206,7 +206,7 @@ fn test_add_sub_swap() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/add_sub_swap",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -224,7 +224,7 @@ fn test_addi_overflow() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/addi_overflow",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -242,7 +242,7 @@ fn test_addi_boundary_immediate() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/addi_boundary_immediate",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -259,7 +259,7 @@ fn test_sub() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/sub",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -276,7 +276,7 @@ fn test_sub_2() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/sub_2",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -293,7 +293,7 @@ fn test_sub_3() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/sub_3",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -310,7 +310,7 @@ fn test_xor() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/xor",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -328,7 +328,7 @@ fn test_and() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/and",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -346,7 +346,7 @@ fn test_slt() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/slt",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -365,7 +365,7 @@ fn test_div_by_zero() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/div_by_zero",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -380,7 +380,7 @@ fn test_divu_by_zero() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/divu_by_zero",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -395,7 +395,7 @@ fn test_rem_by_zero() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/rem_by_zero",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -410,7 +410,7 @@ fn test_remu_by_zero() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/remu_by_zero",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -424,7 +424,7 @@ fn test_mul_overflow() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/mul_overflow",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand All @@ -440,7 +440,7 @@ fn test_jal() {
let path = curr_dir.join(std::path::PathBuf::from(
"resources/programs/riscv32im/bin/jal",
));
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV, &path).unwrap();
let state = o1vm::elf_loader::parse_elf(Architecture::RiscV32, &path).unwrap();
let mut witness = Env::<Fp>::create(PAGE_SIZE.try_into().unwrap(), state);

while !witness.halt {
Expand Down

0 comments on commit 57c7ec1

Please sign in to comment.