Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Tracer simple zkc binary run and go-corset check

on:
pull_request:
branches:
- main
paths:
- 'arithmetization/**'
- '.github/actions/setup-arithmetization-riscv/**'
- '.github/workflows/arithmetization-*.yml'
push:
branches:
- main
paths:
- 'arithmetization/**'
- '.github/actions/setup-arithmetization-riscv/**'
- '.github/workflows/arithmetization-*.yml'
workflow_call:
workflow_dispatch:

permissions:
contents: read
actions: read

jobs:
build:
runs-on: gha-runner-scale-set-ubuntu-24-amd64-small
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
submodules: false

- name: Setup Environment
uses: ./.github/actions/setup-arithmetization-riscv

- name: Install zkc, compile risc binary for simple zkc test program and go-corset check it
run: make -C arithmetization zkc-compile-and-check
env:
ZKC_MAIN: src/test/examples/zkc/simple_add.zkc
ZKC_FILES: src/test/examples/zkc/simple_add.zkc
ZKC_INPUT: src/test/examples/zkc/simple_add.json
21 changes: 15 additions & 6 deletions arithmetization/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ GO_CORSET_REF_FOR_ZKC ?=
# Used to install go-corset
GO_CORSET_VERSION ?= v1.2.17

ZKC_FILES := $(shell find $(MAKEFILE_DIR)src/main/riscv/* -name "*.zkc")
ZKC_MAIN := $(MAKEFILE_DIR)src/main/riscv/main.zkc
ZKC_BINDIR := $(MAKEFILE_DIR)bin
ZKC_BINARY := riscv.bin
ZKC_FILES ?= $(shell find $(MAKEFILE_DIR)src/main/riscv/* -name "*.zkc")
ZKC_MAIN ?= $(MAKEFILE_DIR)src/main/riscv/main.zkc
ZKC_BINDIR ?= $(MAKEFILE_DIR)bin
ZKC_BINARY ?= riscv.bin
ZKC_INPUT ?= input.json

.PHONY: checkout-go-corset install-go-corset install-zkc zkc-compile check
.PHONY: checkout-go-corset install-go-corset install-zkc zkc-compile zkc-check zkc-compile-and-check check

# Fetch go-corset if missing (no-op when CI already checked it out into GO_CORSET).
checkout-go-corset:
Expand All @@ -41,17 +42,25 @@ checkout-go-corset:
install-zkc: checkout-go-corset
cd "$(GO_CORSET)" && go install ./cmd/zkc

# Compile the main RISC-V ZKC program.
# Compile zkc program in a binary file
zkc-compile: $(ZKC_FILES)
mkdir -p $(ZKC_BINDIR)
zkc compile -o $(ZKC_BINDIR)/$(ZKC_BINARY) --wir $(ZKC_MAIN)

# Check execution of the compiled zkc binary against an input JSON
# Only works for small zkc programs for now
zkc-check:
zkc exec --check $(ZKC_INPUT) $(ZKC_BINDIR)/$(ZKC_BINARY)

zkc-compile-and-check: install-zkc zkc-compile zkc-check

zkc-lint:
zkc format --check $(ZKC_FILES)

zkc-lint-apply:
zkc format $(ZKC_FILES)

# Compile the main RISC-V zkc program in a binary file
riscv-check-compilation: install-zkc zkc-compile

riscv-check-lint: install-zkc zkc-lint
Expand Down
1 change: 1 addition & 0 deletions arithmetization/src/test/examples/zkc/simple_add.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "data": "0x0001_0002_0003" }
13 changes: 13 additions & 0 deletions arithmetization/src/test/examples/zkc/simple_add.zkc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// This main function is used for test purposes to integrate the different compilation steps in CI
pub input data(address:u16) -> (byte:u16)

// prove that two numbers add up to a third.
fn main() {
var lhs:u16 = data[0]
var rhs:u16 = data[1]
var sum:u16
sum = lhs + rhs
if sum != data[2] {
fail
}
}
Loading