Skip to content

Commit

Permalink
implement verify-proofs derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreyMlashkin committed Feb 12, 2025
1 parent 9f6c389 commit fc8c070
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ jobs:
always() && !cancelled()
secrets: inherit

verify-proof-by-proof-producer:
name: Verify Proof
uses: ./.github/workflows/verify-proof-by-proof-producer.yml
if: |
always() && !cancelled()
secrets: inherit

build-linux-proof-producer-deb-package:
name: Build and upload deb package
uses: ./.github/workflows/deb-package-proof-producer-bundler.yaml
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/verify-proof-by-proof-producer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Verify proofs by means of proof-producer

on:
workflow_call:

jobs:
build-and-test:
name: "Verify proofs by means of proof-producer"
runs-on: [self-hosted, Linux, X64, aws_autoscaling]
steps:
# https://github.com/actions/checkout/issues/1552
- name: Clean up after previous checkout
run: chmod +w -R ${GITHUB_WORKSPACE}; rm -rf ${GITHUB_WORKSPACE}/*;

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Run checks for proofs-verification
run: |
nix build -L .?#checks.x86_64-linux.verify-proofs
1 change: 0 additions & 1 deletion crypto3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
boost,
gdb,
lldb,
mold,
cmake_modules,
enableDebugging,
enableDebug ? false,
Expand Down
5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@
sanitize = true;
});

verify-proofs = (pkgs.callPackage ./verify-proofs.nix {
enableDebug = false;
proof-producer = packages.proof-producer;
});

all-clang = pkgs.symlinkJoin {
name = "all";
paths = [ crypto3-clang parallel-crypto3-clang proof-producer-clang ];
Expand Down
86 changes: 86 additions & 0 deletions verify-proofs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{ lib,
stdenv,
ninja,
pkg-config,
cmake,
boost,
gdb,
lldb,
mold,
protobuf,
glibc,
cmake_modules,
enableDebugging,
enableDebug ? false,
staticBuild ? false,
sanitize ? false,
crypto3_tests ? false,
proof-producer
}:
let
inherit (lib) optional;
in stdenv.mkDerivation rec {
name = "Proof verifier test";
pname = "proof-verifier-test";

src = lib.sourceByRegex ./. [ "^crypto3(/.*)?$" "CMakeLists.txt" ];
hardeningDisable = [ "fortify" ];

nativeBuildInputs = [ cmake ninja pkg-config ] ++
(lib.optional (!stdenv.isDarwin) gdb) ++
(lib.optional (stdenv.isDarwin) lldb);

# enableDebugging will keep debug symbols in boost
propagatedBuildInputs = [ (if enableDebug then (enableDebugging boost) else boost) ];

buildInputs = [cmake_modules protobuf] ++
( lib.optional (staticBuild) glibc.static );

cmakeFlags =
[
"-DBUILD_CRYPTO3_TESTS=TRUE"
(if sanitize then "-DSANITIZE=ON" else "-DSANITIZE=OFF")
"-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" # to allow VSCode navigation/completion/etc
"-G Ninja"
];

buildPhase = ''
ninja blueprint_zkevm_bbf_hardhat_test
./crypto3/libs/blueprint/test/blueprint_zkevm_bbf_hardhat_test -- --print
'';

cmakeBuildType = if enableDebug then "Debug" else "Release";
doCheck = true;

test_names = [
"zkevm_bbf_hardhat_keccak_copy"
"zkevm_bbf_hardhat_minimal_math_zkevm"
"zkevm_bbf_hardhat_minimal_math_rw"
"zkevm_bbf_hardhat_minimal_math_bytecode"

"zkevm_bbf_hardhat_calldatacopy_copy"
"zkevm_bbf_hardhat_exp_copy"
"zkevm_bbf_hardhat_exp_rw"
"zkevm_bbf_hardhat_minimal_math_copy"
"zkevm_bbf_hardhat_modular_operations_copy"
];

checkPhase = ''
for test_name in ${lib.concatMapStringsSep " " lib.escapeShellArg test_names}; do
set -x
echo "Running ''${test_name}"
${proof-producer}/bin/proof-producer-multi-threaded -l trace \
--stage "all" \
--circuit "''${test_name}_circuit.crct" \
--assignment-table="''${test_name}_table.tbl" -q 20
done
'';

dontInstall = true;
installPhase = "true";

shellHook = ''
PS1="\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
echo "Welcome to verify-proofs environment!"
'';
}

0 comments on commit fc8c070

Please sign in to comment.