Skip to content

Commit

Permalink
Merge branch 'master' into dw/merge-back-develop-in-master
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Jan 12, 2025
2 parents c54f985 + c7f78ba commit 0c64141
Show file tree
Hide file tree
Showing 187 changed files with 4,059 additions and 3,415 deletions.
22 changes: 22 additions & 0 deletions .github/actions/build-mips/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: 'Build MIPS Programs'
description: 'Builds MIPS programs for testing'

runs:
using: "composite"
steps:
- name: Cache apt packages
uses: actions/cache@v4
with:
path: |
/var/cache/apt/archives/*.deb
key: ${{ runner.os }}-apt-${{ hashFiles('.github/workflows/o1vm-mips-build.yml') }}

- name: Install MIPS tools
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y binutils-mips-linux-gnu
- name: Build MIPS programs
shell: bash
run: make build-mips-programs
3 changes: 3 additions & 0 deletions .github/workflows/ci-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ jobs:
run: |
make install-test-deps
- name: Build the MIPS binaries
uses: ./.github/actions/build-mips

- name: Run all tests with the code coverage
run: |
eval $(opam env)
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
RUST_TOOLCHAIN_COVERAGE_VERSION: "1.74"
strategy:
matrix:
rust_toolchain_version: ["1.71", "1.72", "1.73", "1.74"]
rust_toolchain_version: ["1.72", "1.73", "1.74", "1.75", "1.76", "1.77", "1.78", "1.79"]
# FIXME: currently not available for 5.0.0.
# It might be related to boxroot dependency, and we would need to bump
# up the ocaml-rs dependency
Expand Down Expand Up @@ -131,11 +131,6 @@ jobs:
run: |
git diff --exit-code ":(exclude)rust-toolchain"
- name: Build cargo docs
run: |
eval $(opam env)
make generate-doc
#
# Coding guidelines
#
Expand All @@ -162,6 +157,9 @@ jobs:
run: |
make install-test-deps
- name: Build the MIPS binaries
uses: ./.github/actions/build-mips

- name: Doc tests
if: ${{ matrix.rust_toolchain_version != env.RUST_TOOLCHAIN_COVERAGE_VERSION }}
run: |
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/o1vm-upload-mips-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Upload MIPS Binaries

on:
workflow_dispatch:

jobs:
build_and_upload:
name: Build and Upload MIPS Programs
runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: Build MIPS binaries
uses: ./.github/actions/build-mips

- name: Create tar archive
run: |
cd o1vm/resources/programs/mips
tar -czf mips-binaries.tar.gz bin/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: mips-binaries
path: o1vm/resources/programs/mips/mips-binaries.tar.gz
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ o1vm/op-program-db*
o1vm/state.json
meta.json
state.json
o1vm/meta_test.json

# Directory for the RISC-V 32bits toolchain
_riscv32-gnu-toolchain
o1vm/resources/programs/riscv32im/bin/*.o

# modified assembly files generated from cannon's open mips tests
o1vm/resources/programs/mips/src
# mips binary files for open mips tests
o1vm/resources/programs/mips/bin
17 changes: 15 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
members = [
"arrabiata",
"arrabbiata",
"book",
"turshi",
"curves",
Expand Down Expand Up @@ -81,7 +81,7 @@ tinytemplate = "1.1"
wasm-bindgen = "=0.2.87"


arrabiata = { path = "./arrabiata", version = "0.1.0" }
arrabbiata = { path = "./arrabbiata", version = "0.1.0" }
folding = { path = "./folding", version = "0.1.0" }
groupmap = { path = "./groupmap", version = "0.1.0" }
internal-tracing = { path = "./internal-tracing", version = "0.1.0" }
Expand Down
84 changes: 77 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@
# Known coverage limitations and issues:
# - https://github.com/rust-lang/rust/issues/79417
# - https://github.com/nextest-rs/nextest/issues/16
# FIXME: Update or remove the `codecov.yml` file to enable the `patch` coverage report and the corresponding PR check,
# once situation with the Rust's Doctests will be improved.
# FIXME: Update or remove the `codecov.yml` file to enable the `patch` coverage
# report and the corresponding PR check, once situation with the Rust's Doctests
# will be improved.
COVERAGE_ENV = CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' RUSTDOCFLAGS="-Cinstrument-coverage" LLVM_PROFILE_FILE=$(shell pwd)/target/profraw/cargo-test-%p-%m.profraw
# FIXME: In latest 0.8.19+ -t CLI argument can accept comma separated list of custom output types, hence, no need in double invocation
# FIXME: In latest 0.8.19+ -t CLI argument can accept comma separated list of
# custom output types, hence, no need in double invocation
GRCOV_CALL = grcov ./target/profraw --binary-path ./target/release/deps/ -s . --branch --ignore-not-existing --ignore "**/tests/**"
RISCV32_TOOLCHAIN_PATH = $(shell pwd)/_riscv32-gnu-toolchain

O1VM_RESOURCES_PATH = $(shell pwd)/o1vm/resources/programs
O1VM_RISCV32IM_SOURCE_DIR = ${O1VM_RESOURCES_PATH}/riscv32im/src
O1VM_RISCV32IM_SOURCE_FILES = $(wildcard ${O1VM_RISCV32IM_SOURCE_DIR}/*.S)
O1VM_RISCV32IM_BIN_DIR = ${O1VM_RESOURCES_PATH}/riscv32im/bin
O1VM_RISCV32IM_BIN_FILES = $(patsubst ${O1VM_RISCV32IM_SOURCE_DIR}/%.S,${O1VM_RISCV32IM_BIN_DIR}/%.o,${O1VM_RISCV32IM_SOURCE_FILES})
RISCV32_AS_FLAGS = --warn --fatal-warnings

OPTIMISM_MIPS_SOURCE_DIR = $(shell pwd)/o1vm/ethereum-optimism/cannon/mipsevm/open_mips_tests/test
OPTIMISM_MIPS_SOURCE_FILES = $(wildcard ${OPTIMISM_MIPS_SOURCE_DIR}/*.asm)
O1VM_MIPS_SOURCE_DIR = ${O1VM_RESOURCES_PATH}/mips/src
O1VM_MIPS_SOURCE_FILES = $(patsubst ${OPTIMISM_MIPS_SOURCE_DIR}/%.asm,${O1VM_MIPS_SOURCE_DIR}/%.asm,${OPTIMISM_MIPS_SOURCE_FILES})
O1VM_MIPS_BIN_DIR = ${O1VM_RESOURCES_PATH}/mips/bin
O1VM_MIPS_BIN_FILES = $(patsubst ${O1VM_MIPS_SOURCE_DIR}/%.asm,${O1VM_MIPS_BIN_DIR}/%.o,${O1VM_MIPS_SOURCE_FILES})

# Default target
all: release
Expand Down Expand Up @@ -37,7 +54,9 @@ install-test-deps: ## Install test dependencies


clean: ## Clean the project
cargo clean
@cargo clean
@rm -rf $(O1VM_RISCV32IM_BIN_FILES)
@rm -rf $(O1VM_MIPS_BIN_DIR)


build: ## Build the project
Expand Down Expand Up @@ -104,7 +123,7 @@ format: ## Format the code
lint: ## Lint the code
cargo clippy --all-features --all-targets --tests $(CARGO_EXTRA_ARGS) -- -W clippy::all -D warnings

generate-test-coverage-report:
generate-test-coverage-report: ## Generate the code coverage report
@echo ""
@echo "Generating the test coverage report."
@echo ""
Expand All @@ -118,7 +137,7 @@ generate-test-coverage-report:
@echo "The test coverage report is available at: ./target/coverage"
@echo ""

generate-doc:
generate-doc: ## Generate the Rust documentation
@echo ""
@echo "Generating the documentation."
@echo ""
Expand All @@ -131,4 +150,55 @@ help: ## Ask for help!
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'


.PHONY: all setup install-test-deps clean build release test-doc test-doc-with-coverage test test-with-coverage test-heavy test-heavy-with-coverage test-all test-all-with-coverage nextest nextest-with-coverage nextest-heavy nextest-heavy-with-coverage nextest-all nextest-all-with-coverage format lint generate-test-coverage-report generate-doc help
setup-riscv32-toolchain: ## Download and compile the RISC-V 32bits toolchain
@echo ""
@echo "Setting up the RISC-V 32-bit toolchain"
@echo ""
if [ ! -d $(RISCV32_TOOLCHAIN_PATH) ]; then \
git clone https://github.com/riscv-collab/riscv-gnu-toolchain ${RISCV32_TOOLCHAIN_PATH}; \
fi
cd ${RISCV32_TOOLCHAIN_PATH} && ./configure --with-arch=rv32gc --with-abi=ilp32d --prefix=${RISCV32_TOOLCHAIN_PATH}/build
cd ${RISCV32_TOOLCHAIN_PATH} && make -j 32 # require a good internet connection and some minutes
@echo ""
@echo "RISC-V 32-bits toolchain is ready in ${RISCV32_TOOLCHAIN_PATH}/build"
@echo ""

build-riscv32-programs: setup-riscv32-toolchain ${O1VM_RISCV32IM_BIN_FILES} ## Build all RISC-V 32 bits programs written for the o1vm

${O1VM_RISCV32IM_BIN_DIR}/%.o: ${O1VM_RISCV32IM_SOURCE_DIR}/%.S
@echo ""
@echo "Building the RISC-V 32-bits binary: $@ using $<"
@echo ""
mkdir -p ${O1VM_RISCV32IM_BIN_DIR}
${RISCV32_TOOLCHAIN_PATH}/build/bin/riscv32-unknown-elf-as ${RISCV32_AS_FLAGS} -o $@ $<
${RISCV32_TOOLCHAIN_PATH}/build/bin/riscv32-unknown-elf-ld -s -o $(basename $@) $@
@echo ""

build-mips-programs: ${O1VM_MIPS_SOURCE_FILES} ${O1VM_MIPS_BIN_FILES} ## Build all MIPS programs written for the o1vm

${O1VM_MIPS_SOURCE_DIR}/%.asm: ${OPTIMISM_MIPS_SOURCE_DIR}/%.asm
@mkdir -p ${O1VM_MIPS_SOURCE_DIR}
@echo "Transforming $< to $@, making it compatible for o1vm"
@sed \
-e '/\.balign 4/d' \
-e 's/^\s*\.set\s*noreorder/.set noreorder/' \
-e '/\.ent\s*test/d' \
-e '/\.end test/d' \
-e 's/\.section .test, "x"/.section .text/' \
-e 's/\s*\.section .text/.section .text/' \
-e 's/\.global test/.global __start/' \
-e "s/^\s*\.global __start/.global __start/" \
-e "s/test\:/__start:/" \
-e "/\.global __start/a\\" \
$< > $@

${O1VM_MIPS_BIN_DIR}/%.o: ${O1VM_MIPS_SOURCE_DIR}/%.asm
@echo "Building the MIPS binary: $(basename $@) using $<"
@mkdir -p ${O1VM_MIPS_BIN_DIR}
@mips-linux-gnu-as -defsym big_endian=1 -march=mips32r2 -o $@ $<
@mips-linux-gnu-ld -s -o $(basename $@) $@

fclean: clean ## Clean the tooling artefacts in addition to running clean
rm -rf ${RISCV32_TOOLCHAIN_PATH}

.PHONY: all setup install-test-deps clean build release test-doc test-doc-with-coverage test test-with-coverage test-heavy test-heavy-with-coverage test-all test-all-with-coverage nextest nextest-with-coverage nextest-heavy nextest-heavy-with-coverage nextest-all nextest-all-with-coverage format lint generate-test-coverage-report generate-doc setup-riscv32-toolchain help fclean build-riscv32-programs build-mips-programs
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
4 changes: 2 additions & 2 deletions arrabiata/Cargo.toml → arrabbiata/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "arrabiata"
name = "arrabbiata"
version = "0.1.0"
repository = "https://github.com/o1-labs/proof-systems"
homepage = "https://o1-labs.github.io/proof-systems/"
Expand All @@ -8,7 +8,7 @@ edition = "2021"
license = "Apache-2.0"

[[bin]]
name = "arrabiata"
name = "arrabbiata"
path = "src/main.rs"

[dependencies]
Expand Down
27 changes: 18 additions & 9 deletions arrabiata/README.md → arrabbiata/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Arrabiata - a generic recursive zero-knowledge argument implementation based on folding schemes
# Arrabbiata - a generic recursive zero-knowledge argument implementation based on folding schemes

### Motivation
## Motivation

This library provides an implementation of a generic recursive zero-knowledge
argument based on folding schemes (initially defined in
Expand Down Expand Up @@ -28,7 +28,7 @@ Not even sure it is possible right now.
**This will change. We might go up to degree 6 or 7, as we're building the
different gadgets (EC addition, EC scalar multiplication, Poseidon).

### Implementation details
## Implementation details

We provide a binary to run arbitrarily large computation.
The implementation of the circuits will follow the one used by the o1vm
Expand All @@ -50,11 +50,11 @@ While building the witness, the cross terms are also computed on the fly, to be
used in the next iteration. This way, the prover only pays the price of the
activated gate on each row.

### Examples
## Examples

Different built-in examples are provided. For instance:
```
cargo run --bin arrabiata --release -- square-root --n 10 --srs-size 16
cargo run --bin arrabbiata --release -- square-root --n 10 --srs-size 16
```

will generate 10 full folding iterations of the polynomial-time function `f(X, Y) =
Expand All @@ -64,13 +64,13 @@ the end.
You can also activate logging which contains benchmarking by using the
environment variable `RUST_LOG=debug`.

### Run tests
## Run tests

```
cargo nextest run --all-features --release --nocapture -p arrabiata
cargo nextest run --all-features --release --nocapture -p arrabbiata
```

### Registry of zkApps
## Registry of zkApps

A registry of zkApps is already preconfigured.
To write a zkApp, check TODO.
Expand All @@ -87,7 +87,16 @@ lib.rs file. In this registry, we could have for instance o1VM -->
versions over time. It can also be done using a registry. We keep only one IVC
circuit for now -->

### References
## References

- The name is not only used as a reference to Kimchi and Pickles, but also to
the mathematician [Aryabhata](https://en.wikipedia.org/wiki/Aryabhata).

## Resources

- [Nova: Recursive Zero-Knowledge Arguments from Folding Schemes](https://eprint.iacr.org/2021/370)
- [ProtoStar: Generic Efficient Accumulation/Folding for Special Sound Protocols](https://eprint.iacr.org/2023/620)
- [ProtoGalaxy: Efficient ProtoStar-style folding of multiple instances](https://eprint.iacr.org/2023/1106)
- [Behind Nova: cross-terms computation for high degree gates](https://hackmd.io/qq_Awc1AR3ywzkruE4Wq9Q)
- [CycleFold: Folding-scheme-based recursive arguments over a cycle of elliptic curves](https://eprint.iacr.org/2023/1192)
- [Revisiting the Nova Proof System on a Cycle of Curves](https://eprint.iacr.org/2023/969)
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 0c64141

Please sign in to comment.