Skip to content

Commit 7ac17c8

Browse files
committed
Stone v2.
1 parent 00b274b commit 7ac17c8

File tree

280 files changed

+78290
-21490
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+78290
-21490
lines changed

.bazelrc

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Put all output in build directory.
2+
build --symlink_prefix=build/bazel
3+
4+
# Don't inherit the user environment as that trashes the cache.
5+
build --incompatible_strict_action_env
6+
build --profile=bazel_build.profile
7+
8+
# Prevent Bazel from adding empty __init__.py files. Those files prevent the packages from becoming
9+
# a namespace package and can cause an import collision.
10+
build --incompatible_default_to_explicit_init_py
11+
12+
build --test_output=errors
13+
14+
# Allow c++ optimizations.
15+
build -c opt
16+
17+
# Compile c++ with clang-12 via llvm toolchain
18+
build --incompatible_enable_cc_toolchain_resolution
19+
build --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux

CMakeLists.txt

-63
This file was deleted.

Dockerfile

+15-12
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,28 @@ RUN /app/install_deps.sh
66
# Install Cairo0 for end-to-end test.
77
RUN pip install cairo-lang==0.12.0
88

9-
COPY CMakeLists.txt /app/
9+
COPY docker_common_deps.sh /app/
10+
WORKDIR /app/
11+
RUN ./docker_common_deps.sh
12+
RUN chown -R starkware:starkware /app
13+
14+
COPY WORKSPACE /app/
15+
COPY .bazelrc /app/
1016
COPY src /app/src
1117
COPY e2e_test /app/e2e_test
18+
COPY bazel_utils /app/bazel_utils
1219

13-
RUN mkdir -p /app/build/Release
14-
15-
WORKDIR /app/build/Release
20+
# Build.
21+
RUN bazel build //...
1622

17-
# Use `--build-arg CMAKE_ARGS=-DNO_AVX=1` to disable the field multiplication optimization
18-
# and other AVX optimizations.
19-
ARG CMAKE_ARGS
20-
RUN cmake ../.. -DCMAKE_BUILD_TYPE=Release ${CMAKE_ARGS}
21-
RUN make -j8
23+
FROM base_image
2224

23-
RUN ctest -V
25+
# Run tests.
26+
RUN bazel test //...
2427

2528
# Copy cpu_air_prover and cpu_air_verifier.
26-
RUN ln -s /app/build/Release/src/starkware/main/cpu/cpu_air_prover /bin/cpu_air_prover
27-
RUN ln -s /app/build/Release/src/starkware/main/cpu/cpu_air_verifier /bin/cpu_air_verifier
29+
RUN ln -s /app/build/bazelbin/src/starkware/main/cpu/cpu_air_prover /bin/cpu_air_prover
30+
RUN ln -s /app/build/bazelbin/src/starkware/main/cpu/cpu_air_verifier /bin/cpu_air_verifier
2831

2932
# End to end test.
3033
WORKDIR /app/e2e_test

README.md

-15
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,3 @@ FRI steps should typically be in the range 2-4;
114114
the degree bound should be in the range 4-7.
115115

116116
The constant 4 that appears in the equation is hardcoded `log₂(trace_rows_per_step) = log₂(16) = 4`.
117-
118-
## For Mac users
119-
120-
To build the docker, run:
121-
122-
```bash
123-
docker build --tag prover . --build-arg CMAKE_ARGS=-DNO_AVX=1
124-
```
125-
126-
To freely use the `cairo-run`, `cpu_air_prover`, and `cpu_air_verifier` commands,
127-
work inside the docker using:
128-
129-
```bash
130-
docker run -it prover bash
131-
```

WORKSPACE

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
2+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
3+
4+
git_repository(
5+
name = "com_github_gflags_gflags",
6+
commit = "986e8eed00ded8168ef4eaa6f925dc6be50b40fa",
7+
patches = ["//src/third_party:gflags.patch"],
8+
remote = "https://github.com/gflags/gflags.git",
9+
shallow_since = "1641684284 +0000",
10+
)
11+
12+
git_repository(
13+
name = "com_github_glog_glog",
14+
commit = "96a2f23dca4cc7180821ca5f32e526314395d26a",
15+
patches = ["//src/third_party:glog.patch"],
16+
remote = "https://github.com/google/glog.git",
17+
shallow_since = "1553223106 +0900",
18+
# tag = "v0.4.0",
19+
)
20+
21+
git_repository(
22+
name = "com_github_gtest_gtest",
23+
commit = "703bd9caab50b139428cea1aaff9974ebee5742e",
24+
remote = "https://github.com/google/googletest.git",
25+
shallow_since = "1570114335 -0400",
26+
# tag = "release-1.11.0",
27+
)
28+
29+
BAZEL_TOOLCHAIN_TAG = "0.8"
30+
31+
BAZEL_TOOLCHAIN_SHA = "f121449dd565d59274b7421a62f3ed1f16ad7ceab4575c5b34f882ba441093bd"
32+
33+
http_archive(
34+
name = "com_grail_bazel_toolchain",
35+
canonical_id = BAZEL_TOOLCHAIN_TAG,
36+
patch_args = [
37+
"-p1",
38+
], # from man patch, "-pnum or --strip=num" Strip the smallest prefix containing num leading slashes from each file name found in the patch file.
39+
patches = ["//bazel_utils/patches:llvm_toolchain.patch"],
40+
sha256 = BAZEL_TOOLCHAIN_SHA,
41+
strip_prefix = "toolchains_llvm-{tag}".format(tag = BAZEL_TOOLCHAIN_TAG),
42+
url = "https://starkware-third-party.s3.us-east-2.amazonaws.com/bazel/toolchains_llvm-{tag}.tar.gz".format(
43+
tag = BAZEL_TOOLCHAIN_TAG,
44+
),
45+
)
46+
47+
load("@com_grail_bazel_toolchain//toolchain:deps.bzl", "bazel_toolchain_dependencies")
48+
49+
bazel_toolchain_dependencies()
50+
51+
load("@com_grail_bazel_toolchain//toolchain:rules.bzl", "llvm_toolchain")
52+
53+
llvm_toolchain(
54+
name = "llvm_toolchain",
55+
compile_flags = {
56+
"": [
57+
"-DUSE_REGISTER_HINT",
58+
"-fno-omit-frame-pointer",
59+
"-fno-strict-aliasing",
60+
"-fPIC",
61+
"-Isrc",
62+
"-maes",
63+
"-mpclmul",
64+
"-Wall",
65+
"-Wextra",
66+
"-Wno-mismatched-tags",
67+
],
68+
},
69+
cxx_flags = {
70+
"": [
71+
"-std=c++17",
72+
"-fconstexpr-steps=20000000",
73+
],
74+
},
75+
link_flags = {
76+
"": [
77+
"-fuse-ld=gold",
78+
"-Wl,-no-as-needed",
79+
"-Wl,-z,relro,-z,now",
80+
"-B/usr/bin",
81+
"-lstdc++",
82+
"-lm",
83+
],
84+
},
85+
llvm_version = "12.0.0",
86+
opt_compile_flags = {
87+
"": [
88+
"-g0",
89+
"-O3",
90+
"-D_FORTIFY_SOURCE=1",
91+
"-DNDEBUG",
92+
"-ffunction-sections",
93+
"-fdata-sections",
94+
],
95+
},
96+
stdlib = {"": "stdc++"},
97+
)
98+
99+
load("@llvm_toolchain//:toolchains.bzl", "llvm_register_toolchains")
100+
101+
llvm_register_toolchains()

bazel_utils/patches/BUILD

Whitespace-only changes.
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/toolchain/BUILD.llvm_repo b/toolchain/BUILD.llvm_repo
2+
index 4158551..48567e6 100644
3+
--- a/toolchain/BUILD.llvm_repo
4+
+++ b/toolchain/BUILD.llvm_repo
5+
@@ -59,6 +59,7 @@ filegroup(
6+
"lib/clang/*/lib/**/*.a",
7+
# clang_rt.*.o supply crtbegin and crtend sections.
8+
"lib/**/clang_rt.*.o",
9+
+ "lib/**/libclang*.so",
10+
],
11+
exclude = [
12+
"lib/libLLVM*.a",

docker_common_deps.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
curl -L -o /tmp/bazel_install.sh https://github.com/bazelbuild/bazel/releases/download/5.4.0/bazel-5.4.0-installer-linux-x86_64.sh
2+
chmod +x /tmp/bazel_install.sh
3+
/tmp/bazel_install.sh
4+
5+
groupadd -g 1234 starkware && useradd -m starkware -u 1234 -g 1234

install_deps.sh

+2-37
Original file line numberDiff line numberDiff line change
@@ -6,48 +6,13 @@ set -o xtrace
66
set -e
77

88
apt update
9-
apt install -y python3.9-dev git wget gnupg2 elfutils libdw-dev python3-pip libgmp3-dev
9+
apt install -y python3.9-dev git wget gnupg2 elfutils libdw-dev python3-pip libgmp3-dev unzip
1010

11+
pip install --upgrade pip
1112
pip install cpplint pytest numpy
12-
pip install cmake
1313

1414
apt install -y clang-12 clang-format-12 clang-tidy-6.0 libclang-12-dev llvm-12
1515

1616
ln -sf /usr/bin/clang++-12 /usr/bin/clang++
1717
ln -sf /usr/bin/clang-12 /usr/bin/clang
1818

19-
# Install gtest.
20-
(
21-
cd /tmp
22-
rm -rf /tmp/googletest
23-
git clone -b release-1.8.0 https://github.com/google/googletest.git
24-
cd /tmp/googletest
25-
cmake CMakeLists.txt && make -j && make install
26-
)
27-
28-
# Install gflags.
29-
(
30-
cd /tmp
31-
rm -rf /tmp/gflags
32-
git clone -b v2.2.1 https://github.com/gflags/gflags.git
33-
cd /tmp/gflags
34-
cmake CMakeLists.txt && make -j && make install
35-
)
36-
37-
# Install glog.
38-
(
39-
cd /tmp
40-
rm -rf /tmp/glog
41-
git clone -b v0.3.5 https://github.com/google/glog.git
42-
cd glog
43-
cmake CMakeLists.txt && make -j && make install
44-
)
45-
46-
# Install google benchmark.
47-
(
48-
cd /tmp
49-
rm -rf /tmp/benchmark
50-
git clone -b v1.4.0 https://github.com/google/benchmark.git
51-
cd /tmp/benchmark
52-
cmake CMakeLists.txt -DCMAKE_BUILD_TYPE=Release && make -j && make install
53-
)

src/CMakeLists.txt

-6
This file was deleted.

src/starkware/BUILD

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cc_library(
2+
name = "starkware_common",
3+
srcs = [],
4+
hdrs = [],
5+
visibility = ["//visibility:public"],
6+
deps = [
7+
# Do not sort.
8+
"//src/starkware/utils:task_manager",
9+
"//src/starkware/error_handling",
10+
"//src/starkware/utils:to_from_string",
11+
],
12+
)

src/starkware/CMakeLists.txt

-19
This file was deleted.

0 commit comments

Comments
 (0)