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
4 changes: 4 additions & 0 deletions .github/workflows/build-and-test-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ jobs:
cache: false
- name: Build SP1 bindings
run: make build_sp1_linux
- name: Build Old SP1 bindings
run: make build_sp1_linux_old
- name: Build Risc Zero go bindings
run: make build_risc_zero_linux
- name: Build Old Risc Zero go bindings
run: make build_risc_zero_linux_old
- name: Build Merkle Tree bindings
run: make build_merkle_tree_linux
- name: Build operator
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/test-risc-zero-old.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: test-risc-zero-old

on:
merge_group:
push:
branches: [main]
pull_request:
branches: ["*"]
paths:
- "operator/risc_zero_old/**"
- ".github/workflows/test-risc-zero-old.yml"

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Clear device space
run: |
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /usr/local/.ghcup
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
cache: false
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Test Old Risc Zero Rust
run: make test_risc_zero_rust_ffi_old
- name: Test Old Risc Zero go bindings
run: make test_risc_zero_go_bindings_linux_old
28 changes: 28 additions & 0 deletions .github/workflows/test-sp1-old.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: test-sp1-old

on:
merge_group:
push:
branches: [main]
pull_request:
branches: ["*"]
paths:
- 'operator/sp1_old/**'
- '.github/workflows/test-sp1-old.yml'

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: false
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: Test Old SP1 Rust
run: make test_sp1_rust_ffi_old
- name: Test Old SP1 go bindings
run: make test_sp1_go_bindings_linux_old
50 changes: 47 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ifeq ($(OS),Darwin)
endif

ifeq ($(OS),Linux)
LD_LIBRARY_PATH += $(CURDIR)/operator/risc_zero/lib
LD_LIBRARY_PATH+=$(CURDIR)/operator/risc_zero_old/lib:$(CURDIR)/operator/risc_zero/lib
endif

ifeq ($(OS),Linux)
Expand Down Expand Up @@ -513,11 +513,11 @@ build_binaries:
__SP1_FFI__: ##
build_sp1_macos:
@cd operator/sp1/lib && cargo build $(RELEASE_FLAG)
@cp operator/sp1/lib/target/$(TARGET_REL_PATH)/libsp1_verifier_ffi.dylib operator/sp1/lib/libsp1_verifier.dylib
@cp operator/sp1/lib/target/$(TARGET_REL_PATH)/libsp1_verifier_ffi.dylib operator/sp1/lib/libsp1_verifier_ffi.dylib

build_sp1_linux:
@cd operator/sp1/lib && cargo build $(RELEASE_FLAG)
@cp operator/sp1/lib/target/$(TARGET_REL_PATH)/libsp1_verifier_ffi.so operator/sp1/lib/libsp1_verifier.so
@cp operator/sp1/lib/target/$(TARGET_REL_PATH)/libsp1_verifier_ffi.so operator/sp1/lib/libsp1_verifier_ffi.so

test_sp1_rust_ffi:
@echo "Testing SP1 Rust FFI source code..."
Expand All @@ -542,6 +542,25 @@ generate_risc_zero_empty_journal_proof:
@cd scripts/test_files/risc_zero/no_public_inputs && RUST_LOG=info cargo run --release
@echo "Fibonacci proof and ELF with empty journal generated in scripts/test_files/risc_zero/no_public_inputs folder"

build_sp1_macos_old:
@cd operator/sp1_old/lib && cargo build $(RELEASE_FLAG)
@cp operator/sp1_old/lib/target/$(TARGET_REL_PATH)/libsp1_verifier_old_ffi.dylib operator/sp1_old/lib/libsp1_verifier_old_ffi.dylib

build_sp1_linux_old:
@cd operator/sp1_old/lib && cargo build $(RELEASE_FLAG)
@cp operator/sp1_old/lib/target/$(TARGET_REL_PATH)/libsp1_verifier_old_ffi.so operator/sp1_old/lib/libsp1_verifier_old_ffi.so

test_sp1_rust_ffi_old:
@echo "Testing SP1 Rust FFI source code..."
@cd operator/sp1_old/lib && RUST_MIN_STACK=83886080 cargo t --release

test_sp1_go_bindings_macos_old: build_sp1_macos_old
@echo "Testing SP1 Go bindings..."
go test ./operator/sp1_old/... -v

test_sp1_go_bindings_linux_old: build_sp1_linux_old
@echo "Testing SP1 Go bindings..."
go test ./operator/sp1_old/... -v

__RISC_ZERO_FFI__: ##
build_risc_zero_macos:
Expand Down Expand Up @@ -569,6 +588,27 @@ generate_risc_zero_fibonacci_proof:
RUST_LOG=info cargo run --release && \
echo "Fibonacci proof, pub input and image ID generated in scripts/test_files/risc_zero folder"

build_risc_zero_macos_old:
@cd operator/risc_zero_old/lib && cargo build $(RELEASE_FLAG)
@cp operator/risc_zero_old/lib/target/$(TARGET_REL_PATH)/librisc_zero_verifier_old_ffi.dylib operator/risc_zero_old/lib/librisc_zero_verifier_old_ffi.dylib

build_risc_zero_linux_old:
@cd operator/risc_zero_old/lib && cargo build $(RELEASE_FLAG)
@cp operator/risc_zero_old/lib/target/$(TARGET_REL_PATH)/librisc_zero_verifier_old_ffi.so operator/risc_zero_old/lib/librisc_zero_verifier_old_ffi.so

test_risc_zero_rust_ffi_old:
@echo "Testing RISC Zero Rust FFI source code..."
@cd operator/risc_zero_old/lib && cargo test --release

test_risc_zero_go_bindings_macos_old: build_risc_zero_macos_old
@echo "Testing RISC Zero Go bindings..."
go test ./operator/risc_zero_old/... -v

test_risc_zero_go_bindings_linux_old: build_risc_zero_linux_old
@echo "Testing RISC Zero Go bindings..."
go test ./operator/risc_zero_old/... -v


__MERKLE_TREE_FFI__: ##
build_merkle_tree_macos:
@cd operator/merkle_tree/lib && cargo build $(RELEASE_FLAG)
Expand Down Expand Up @@ -607,13 +647,17 @@ build_all_ffi_macos: ## Build all FFIs for macOS
@echo "Building all FFIs for macOS..."
@$(MAKE) build_sp1_macos
@$(MAKE) build_risc_zero_macos
@$(MAKE) build_sp1_macos_old
@$(MAKE) build_risc_zero_macos_old
@$(MAKE) build_merkle_tree_macos
@echo "All macOS FFIs built successfully."

build_all_ffi_linux: ## Build all FFIs for Linux
@echo "Building all FFIs for Linux..."
@$(MAKE) build_sp1_linux
@$(MAKE) build_risc_zero_linux
@$(MAKE) build_sp1_linux_old
@$(MAKE) build_risc_zero_linux_old
@$(MAKE) build_merkle_tree_linux
@echo "All Linux FFIs built successfully."

Expand Down
21 changes: 18 additions & 3 deletions operator/pkg/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/urfave/cli/v2"
"github.com/yetanotherco/aligned_layer/operator/risc_zero"
"github.com/yetanotherco/aligned_layer/operator/risc_zero_old"
"golang.org/x/crypto/sha3"

"github.com/prometheus/client_golang/prometheus"
"github.com/yetanotherco/aligned_layer/metrics"

"github.com/yetanotherco/aligned_layer/operator/sp1"
"github.com/yetanotherco/aligned_layer/operator/sp1_old"

"github.com/Layr-Labs/eigensdk-go/crypto/bls"
"github.com/Layr-Labs/eigensdk-go/logging"
Expand Down Expand Up @@ -518,15 +520,28 @@ func (o *Operator) verify(verificationData VerificationData, disabledVerifiersBi

case common.SP1:
verificationResult, err := sp1.VerifySp1Proof(verificationData.Proof, verificationData.VmProgramCode)
if !verificationResult {
o.Logger.Infof("SP1 proof verification failed. Trying old SP1 version...")
verificationResult, err = sp1_old.VerifySp1ProofOld(verificationData.Proof, verificationData.VmProgramCode)
if !verificationResult {
o.Logger.Errorf("Old SP1 proof verification failed")
}
}
o.Logger.Infof("SP1 proof verification result: %t", verificationResult)
o.handleVerificationResult(results, verificationResult, err, "SP1 proof verification")

case common.Risc0:
verificationResult, err := risc_zero.VerifyRiscZeroReceipt(verificationData.Proof,
verificationData.VmProgramCode, verificationData.PubInput)
o.handleVerificationResult(results, verificationResult, err, "RiscZero proof verification")

if !verificationResult {
o.Logger.Infof("Risc0 proof verification failed. Trying old Risc0 version...")
verificationResult, err = risc_zero_old.VerifyRiscZeroReceiptOld(verificationData.Proof, verificationData.VmProgramCode, verificationData.PubInput)
if !verificationResult {
o.Logger.Errorf("Old Risc0 proof verification failed")
}
}
o.Logger.Infof("Risc0 proof verification result: %t", verificationResult)
results <- verificationResult
o.handleVerificationResult(results, verificationResult, err, "Risc0 proof verification")
default:
o.Logger.Error("Unrecognized proving system ID")
results <- false
Expand Down
2 changes: 1 addition & 1 deletion operator/risc_zero/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
lib/librisc_zero_verifier_ffi.a
lib/librisc_zero_verifier_ffi.so
lib/librisc_zero_verifier_ffi.dylib
Loading