Skip to content

Commit

Permalink
Merge pull request #4 from NilFoundation/directly-include-zkevm-frame…
Browse files Browse the repository at this point in the history
…work

Directly include zkevm framework
  • Loading branch information
AndreyMlashkin authored Sep 6, 2024
2 parents 6d9263b + 51a9955 commit da0ced4
Show file tree
Hide file tree
Showing 94 changed files with 16,278 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crypto3/crypto3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ in stdenv.mkDerivation {

cmakeFlags =
[
(if runTests then "-DBUILD_TESTS=TRUE" else "")
(if runTests then "-DBUILD_TESTS=TRUE" else "-DBUILD_TESTS=False")
(if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release")
"-G Ninja"
];
Expand Down
36 changes: 33 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
};
in {
packages = rec {
crypto3 = (pkgs.callPackage ./crypto3/crypto3.nix { });
crypto3 = (pkgs.callPackage ./crypto3/crypto3.nix {
runTests = false;
enableDebug = false;
});
crypto3-tests = (pkgs.callPackage ./crypto3/crypto3.nix {
runTests = true;
enableDebug = false;
Expand All @@ -33,8 +36,9 @@
});

evm-assigner = (pkgs.callPackage ./evm-assigner/evm-assigner.nix {
crypto3 = crypto3;
runTests = false;
enableDebug = false;
crypto3 = crypto3;
});
evm-assigner-tests = (pkgs.callPackage ./evm-assigner/evm-assigner.nix {
runTests = true;
Expand All @@ -47,6 +51,25 @@
crypto3 = crypto3;
});

zkevm-framework = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
runTests = false;
enableDebug = false;
crypto3 = crypto3;
evm-assigner = evm-assigner;
});
zkevm-framework-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
runTests = true;
enableDebug = false;
crypto3 = crypto3;
evm-assigner = evm-assigner;
});
zkevm-framework-debug-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
enableDebug = true;
runTests = true;
crypto3 = crypto3;
evm-assigner = evm-assigner;
});

# The "all" package will build all packages. Convenient for CI,
# so that "nix build" will check that all packages are correct.
# The packages that have no changes will not be rebuilt, and instead
Expand Down Expand Up @@ -81,13 +104,20 @@
crypto3 = crypto3-clang;
});

zkevm-framework-gcc = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
runTests = true;
enableDebug = false;
crypto3 = crypto3-gcc;
evm-assigner = evm-assigner-gcc;
});

all-clang = pkgs.symlinkJoin {
name = "all";
paths = [ crypto3-clang evm-assigner-clang ];
};
all-gcc = pkgs.symlinkJoin {
name = "all";
paths = [ crypto3-gcc evm-assigner-gcc ];
paths = [ crypto3-gcc evm-assigner-gcc zkevm-framework-gcc ];
};
default = all-gcc;
};
Expand Down
12 changes: 12 additions & 0 deletions zkevm-framework/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
Language: Cpp
BasedOnStyle: Google

AccessModifierOffset: -2
ColumnLimit: 100
IndentWidth: 4
InsertNewlineAtEOF: true
NamespaceIndentation: All
SpaceAfterTemplateKeyword: false
TabWidth: 4
...
1 change: 1 addition & 0 deletions zkevm-framework/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
14 changes: 14 additions & 0 deletions zkevm-framework/.github/scripts/pure_cmake_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash -e

nix develop -c "env" | grep CMAKE_PREFIX_PATH >cmake_prefix
echo "export `cat cmake_prefix`" > cmake_prefix
source cmake_prefix
cat cmake_prefix
rm cmake_prefix
CMAKE_BINARY=$(nix develop -c bash -c 'which cmake' | tail -1)
NINJA_BINARY=$(nix develop -c bash -c 'which ninja' | tail -1)
CC=$(nix develop -c bash -c 'which gcc' | tail -1)
CXX=$(nix develop -c bash -c 'which g++' | tail -1)
set -x
$CMAKE_BINARY -GNinja -DCMAKE_MAKE_PROGRAM=$NINJA_BINARY -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DENABLE_TESTS=TRUE
$NINJA_BINARY -C build
41 changes: 41 additions & 0 deletions zkevm-framework/.github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Check formatting

on:
push:
branches: [ master ]
pull_request:

concurrency:
# In master we want to run for every commit, in other branches — only for the last one
group: ${{
( github.ref == 'refs/heads/master' &&
format('{0}/{1}/{2}', github.workflow, github.ref, github.sha) )
||
format('{0}/{1}', github.workflow, github.ref) }}
cancel-in-progress: true

jobs:
code-formatting-check:
name: Code formatting check
runs-on: [ self-hosted, Linux, X64, aws_autoscaling ]
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Run clang-format
uses: jidicula/[email protected]
with:
clang-format-version: "17"

markdown-formatting-check:
name: Markdown formatting check
runs-on: [ self-hosted, Linux, X64, aws_autoscaling ]
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Run markdownlint
uses: DavidAnson/markdownlint-cli2-action@v16
with:
config: .markdownlint.yml
globs: '**/*.md'
42 changes: 42 additions & 0 deletions zkevm-framework/.github/workflows/run-tests-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Run tests on Linux

on:
push:
branches: [ master ]
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'

concurrency:
# In master we want to run for every commit, in other branches — only for the last one
group: ${{
( github.ref == 'refs/heads/master' &&
format('{0}/{1}/{2}', github.workflow, github.ref, github.sha) )
||
format('{0}/{1}', github.workflow, github.ref) }}
cancel-in-progress: true

jobs:
build-and-test:
name: Run tests workflow on Release build
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 zkEVM-framework
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Run build
run: nix build -L

- name: Run checks
run: nix flake -L check

- name: Check build without nix environment
run: .github/scripts/pure_cmake_build.sh
Loading

0 comments on commit da0ced4

Please sign in to comment.