Skip to content

Commit

Permalink
Merge branch 'master' into sai/branch-neq
Browse files Browse the repository at this point in the history
  • Loading branch information
dannywillems committed Dec 24, 2024
2 parents c281b7e + 119f341 commit d40c4c6
Show file tree
Hide file tree
Showing 98 changed files with 2,864 additions and 901 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/o1vm-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,9 @@ name: o1vm CI
on:
workflow_dispatch:
pull_request:
paths:
[
"o1vm/**",
"folding/**",
"groupmap/**",
"kimchi/**",
"msm/**",
"curves/**",
"poseidon/**",
"poly-commitment/",
"internal-tracing/**",
"srs/**",
"utils/**",
]
push:
branches:
- master
paths:
[
"o1vm/**",
"folding/**",
"groupmap/**",
"kimchi/**",
"msm/**",
"curves/**",
"poseidon/**",
"poly-commitment/",
"internal-tracing/**",
"srs/**",
"utils/**",
]

env:
# https://doc.rust-lang.org/cargo/reference/profiles.html#release
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ o1vm/op-program-db*
o1vm/state.json
meta.json
state.json

# Directory for the RISC-V 32bits toolchain
_riscv32-gnu-toolchain
o1vm/resources/programs/riscv32im/bin/*.o
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.90"


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
105 changes: 73 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
# 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

# Default target
all: release
Expand All @@ -21,11 +31,10 @@ setup:
@echo "Git submodules synced."
@echo ""

# Install test dependencies
# https://nexte.st/book/pre-built-binaries.html#using-nextest-in-github-actions
# FIXME: update to 0.9.68 when we get rid of 1.71 and 1.72.
# FIXME: latest 0.8.19+ requires rustc 1.74+
install-test-deps:
install-test-deps: ## Install test dependencies
@echo ""
@echo "Installing the test dependencies."
@echo ""
Expand All @@ -36,76 +45,77 @@ install-test-deps:
@echo "Test dependencies installed."
@echo ""

# Clean the project
clean:

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

# Build the project
build:

build: ## Build the project
cargo build --all-targets --all-features

# Build the project in release mode
release:

release: ## Build the project in release mode
cargo build --release --all-targets --all-features

# Test the project's docs comments
test-doc:

test-doc: ## Test the project's docs comments
cargo test --all-features --release --doc

test-doc-with-coverage:
$(COVERAGE_ENV) $(MAKE) test-doc

# Test the project with non-heavy tests and using native cargo test runner
test:

test: ## Test the project with non-heavy tests and using native cargo test runner
cargo test --all-features --release $(CARGO_EXTRA_ARGS) -- --nocapture --skip heavy $(BIN_EXTRA_ARGS)

test-with-coverage:
$(COVERAGE_ENV) CARGO_EXTRA_ARGS="$(CARGO_EXTRA_ARGS)" BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) test

# Test the project with heavy tests and using native cargo test runner
test-heavy:

test-heavy: ## Test the project with heavy tests and using native cargo test runner
cargo test --all-features --release $(CARGO_EXTRA_ARGS) -- --nocapture heavy $(BIN_EXTRA_ARGS)

test-heavy-with-coverage:
$(COVERAGE_ENV) CARGO_EXTRA_ARGS="$(CARGO_EXTRA_ARGS)" BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) test-heavy

# Test the project with all tests and using native cargo test runner
test-all:

test-all: ## Test the project with all tests and using native cargo test runner
cargo test --all-features --release $(CARGO_EXTRA_ARGS) -- --nocapture $(BIN_EXTRA_ARGS)

test-all-with-coverage:
$(COVERAGE_ENV) CARGO_EXTRA_ARGS="$(CARGO_EXTRA_ARGS)" BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) test-all

# Test the project with non-heavy tests and using nextest test runner
nextest:

nextest: ## Test the project with non-heavy tests and using nextest test runner
cargo nextest run --all-features --release --profile ci -E "not test(heavy)" $(BIN_EXTRA_ARGS)

nextest-with-coverage:
$(COVERAGE_ENV) BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) nextest

# Test the project with heavy tests and using nextest test runner
nextest-heavy:

nextest-heavy: ## Test the project with heavy tests and using nextest test runner
cargo nextest run --all-features --release --profile ci -E "test(heavy)" $(BIN_EXTRA_ARGS)

nextest-heavy-with-coverage:
$(COVERAGE_ENV) BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) nextest-heavy

# Test the project with all tests and using nextest test runner
nextest-all:

nextest-all: ## Test the project with all tests and using nextest test runner
cargo nextest run --all-features --release --profile ci $(BIN_EXTRA_ARGS)

nextest-all-with-coverage:
$(COVERAGE_ENV) BIN_EXTRA_ARGS="$(BIN_EXTRA_ARGS)" $(MAKE) nextest-all

# Format the code
format:

format: ## Format the code
cargo +nightly fmt -- --check

# Lint the code
lint:

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 @@ -119,7 +129,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 @@ -128,4 +138,35 @@ generate-doc:
@echo "The documentation is available at: ./target/doc"
@echo ""

.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: ## 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}'


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 ""

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
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
4 changes: 2 additions & 2 deletions arrabiata/README.md → arrabbiata/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 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

Expand Down Expand Up @@ -54,7 +54,7 @@ activated gate on each row.

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 Down
File renamed without changes.
File renamed without changes.
23 changes: 23 additions & 0 deletions arrabiata/src/columns.rs → arrabbiata/src/columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use std::{
};
use strum_macros::{EnumCount as EnumCountMacro, EnumIter};

use crate::NUMBER_OF_COLUMNS;

/// This enum represents the different gadgets that can be used in the circuit.
/// The selectors are defined at setup time, can take only the values `0` or
/// `1` and are public.
Expand Down Expand Up @@ -36,6 +38,27 @@ pub enum Column {
X(usize),
}

/// Convert a column to a usize. This is used by the library [mvpoly] when we
/// need to compute the cross-terms.
/// For now, only the private inputs and the public inputs are converted,
/// because there might not need to treat the selectors in the polynomial while
/// computing the cross-terms (FIXME: check this later, but pretty sure it's the
/// case).
///
/// Also, the [mvpoly::monomials] implementation of the trait [mvpoly::MVPoly]
/// will be used, and the mapping here is consistent with the one expected by
/// this implementation, i.e. we simply map to an increasing number starting at
/// 0, without any gap.
impl From<Column> for usize {
fn from(val: Column) -> usize {
match val {
Column::X(i) => i,
Column::PublicInput(i) => NUMBER_OF_COLUMNS + i,
Column::Selector(_) => unimplemented!("Selectors are not supported. This method is supposed to be called only to compute the cross-term and an optimisation is in progress to avoid the inclusion of the selectors in the multi-variate polynomial."),
}
}
}

pub struct Challenges<F: Field> {
/// Challenge used to aggregate the constraints
pub alpha: F,
Expand Down
Loading

0 comments on commit d40c4c6

Please sign in to comment.