Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes compilation errors on Gcc 13 #426

Closed
wants to merge 7 commits into from
Closed
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
53 changes: 38 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ TARGET_TEST := zkProverTest
BUILD_DIR := ./build
SRC_DIRS := ./src ./test ./tools

LIBOMP := $(shell find /usr/lib/llvm-* -name "libomp.so" | sed 's/libomp.so//')
ifndef LIBOMP
$(error LIBOMP is not set, you need to install libomp-dev)
GRPCPP_FLAGS := $(shell pkg-config grpc++ --cflags)
GRPCPP_LIBS := $(shell pkg-config grpc++ --libs) -lgrpc++_reflection
ifndef GRPCPP_LIBS
$(error gRPC++ could not be found via pkg-config, you need to install them)
endif

CXX := g++
AS := nasm
CXXFLAGS := -std=c++17 -Wall -pthread -flarge-source-files -Wno-unused-label -rdynamic -mavx2 #-Wfatal-errors
LDFLAGS := -lprotobuf -lsodium -lgrpc -lgrpc++ -lgrpc++_reflection -lgpr -lpthread -lpqxx -lpq -lgmp -lstdc++ -lomp -lgmpxx -lsecp256k1 -lcrypto -luuid -L$(LIBOMP)
CXXFLAGS := -std=c++17 -Wall -pthread -flarge-source-files -Wno-unused-label -rdynamic -mavx2 $(GRPCPP_FLAGS) #-Wfatal-errors
LDFLAGS := -lprotobuf -lsodium -lgpr -lpthread -lpqxx -lpq -lgmp -lstdc++ -lgmpxx -lsecp256k1 -lcrypto -luuid $(GRPCPP_LIBS)
CFLAGS := -fopenmp
ASFLAGS := -felf64

Expand All @@ -26,21 +27,32 @@ else
CXXFLAGS += -O3
endif

INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))

CPPFLAGS ?= $(INC_FLAGS) -MMD -MP

PROTOC = protoc
GRPC_CPP_PLUGIN = grpc_cpp_plugin
GRPC_CPP_PLUGIN_PATH ?= `which $(GRPC_CPP_PLUGIN)`

PROTOS_PATH = ./src/grpc

PROTO_SRCS := $(shell find $(PROTOS_PATH) -name *.proto)
PROTO_CC := $(PROTO_SRCS:%.proto=$(BUILD_DIR)/gen/%.pb.cc) $(PROTO_SRCS:%.proto=$(BUILD_DIR)/gen/%.grpc.pb.cc)
PROTO_H := $(PROTO_SRCS:%.proto=$(BUILD_DIR)/gen/%.pb.h) $(PROTO_SRCS:%.proto=$(BUILD_DIR)/gen/%.grpc.pb.h)
PROTO_OBJS := $(PROTO_CC:%=$(BUILD_DIR)/%.o)

INC_DIRS := $(shell find $(SRC_DIRS) -type d) $(sort $(dir $(PROTO_H)))
INC_FLAGS := $(addprefix -I,$(INC_DIRS))

SRCS_ZKP := $(shell find $(SRC_DIRS) ! -path "./tools/starkpil/bctree/*" ! -path "./test/prover/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/tests/*" ! -path "./src/main_generator/*" ! -path "./src/pols_generator/*" -name *.cpp -or -name *.c -or -name *.asm -or -name *.cc)
OBJS_ZKP := $(SRCS_ZKP:%=$(BUILD_DIR)/%.o)
OBJS_ZKP := $(SRCS_ZKP:%=$(BUILD_DIR)/%.o) $(PROTO_OBJS)
DEPS_ZKP := $(OBJS_ZKP:.o=.d)

SRCS_BCT := $(shell find $(SRC_DIRS) ! -path "./src/main.cpp" ! -path "./test/prover/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/tests/*" ! -path "./src/main_generator/*" ! -path "./src/pols_generator/*" -name *.cpp -or -name *.c -or -name *.asm -or -name *.cc)
OBJS_BCT := $(SRCS_BCT:%=$(BUILD_DIR)/%.o)
OBJS_BCT := $(SRCS_BCT:%=$(BUILD_DIR)/%.o) $(PROTO_OBJS)
DEPS_BCT := $(OBJS_BCT:.o=.d)

SRCS_TEST := $(shell find $(SRC_DIRS) ! -path "./src/main.cpp" ! -path "./tools/starkpil/bctree/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/benchs/*" ! -path "./src/goldilocks/tests/*" ! -path "./src/main_generator/*" ! -path "./src/pols_generator/*" -name *.cpp -or -name *.c -or -name *.asm -or -name *.cc)
OBJS_TEST := $(SRCS_TEST:%=$(BUILD_DIR)/%.o)
OBJS_TEST := $(SRCS_TEST:%=$(BUILD_DIR)/%.o) $(PROTO_OBJS)
DEPS_TEST := $(OBJS_TEST:.o=.d)

all: $(BUILD_DIR)/$(TARGET_ZKP)
Expand All @@ -50,13 +62,24 @@ bctree: $(BUILD_DIR)/$(TARGET_BCT)
test: $(BUILD_DIR)/$(TARGET_TEST)

$(BUILD_DIR)/$(TARGET_ZKP): $(OBJS_ZKP)
$(CXX) $(OBJS_ZKP) $(CXXFLAGS) -o $@ $(LDFLAGS)
$(CXX) $(OBJS_ZKP) $(CXXFLAGS) -o $@ $(CFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS)

$(BUILD_DIR)/$(TARGET_BCT): $(OBJS_BCT)
$(CXX) $(OBJS_BCT) $(CXXFLAGS) -o $@ $(LDFLAGS)
$(CXX) $(OBJS_BCT) $(CXXFLAGS) -o $@ $(CFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS)

$(BUILD_DIR)/$(TARGET_TEST): $(OBJS_TEST)
$(CXX) $(OBJS_TEST) $(CXXFLAGS) -o $@ $(LDFLAGS)
$(CXX) $(OBJS_TEST) $(CXXFLAGS) -o $@ $(CFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS)

# protobuf
$(BUILD_DIR)/gen/%.pb.cc $(BUILD_DIR)/gen/%.pb.h $(BUILD_DIR)/gen/%.grpc.pb.cc $(BUILD_DIR)/gen/%.grpc.pb.h &: %.proto
$(MKDIR_P) $(dir $@)
$(PROTOC) -I $(PROTOS_PATH) --grpc_out=$(dir $@) --plugin=protoc-gen-grpc=$(GRPC_CPP_PLUGIN_PATH) $<
$(PROTOC) -I $(PROTOS_PATH) --cpp_out=$(dir $@) $<

# Tells that objects depends on protobuf headers (it would be nice to be more
# fine grained than this, but it would require listing object files
# individually).
$(OBJS_ZKP) $(OBJS_BCT) $(OBJS_TEST): | $(PROTO_H)

# assembly
$(BUILD_DIR)/%.asm.o: %.asm
Expand Down Expand Up @@ -92,4 +115,4 @@ clean:
-include $(DEPS_ZKP)
-include $(DEPS_BCT)

MKDIR_P ?= mkdir -p
MKDIR_P ?= mkdir -p
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ $ git submodule update
```

### Compile
The following packages must be installed.
The following packages must be installed (Ubuntu variants):
```sh
$ sudo apt update && sudo apt install build-essential libbenchmark-dev libomp-dev libgmp-dev nlohmann-json3-dev postgresql libpqxx-dev libpqxx-doc nasm libsecp256k1-dev grpc-proto libsodium-dev libprotobuf-dev libssl-dev cmake libgrpc++-dev protobuf-compiler protobuf-compiler-grpc uuid-dev
```
The equivalent for Arch Linux is:
```sh
$ sudo pacman -S base-devel extra/protobuf community/grpc-cli community/nlohmann-json extra/libpqxx nasm extra/libsodium community/libsecp256k1
```
To download the files needed to run the prover, you have to execute the following command
```sh
$ wget https://de012a78750e59b808d922b39535e862.s3.eu-west-1.amazonaws.com/v1.1.0-rc.1-fork.4.tgz
Expand Down Expand Up @@ -80,23 +84,23 @@ $ sudo docker run --rm --network host -ti -p 50051:50051 -p 50061:50061 -p 50071
## Usage
To execute the Prover you need to provide a `config.json` file that contains the parameters that allow us to configure the different Prover options. By default, the Prover loads the `config.json`file located in the `testvectors`folder. The most relevant parameters are commented below with the default value for the provided `config.json` file:

| Parameter | Description |
| --------- | ----------- |
| runStateDBServer | Enables StateDB GRPC service, provides SMT (Sparse Merkle Tree) and Database access |
| runExecutorServer | Enables Executor GRPC service, provides a service to process transaction batches |
| runAggregatorClient | Enables Aggregator GRPC client, connects to the Aggregator and process its requests |
| aggregatorClientHost | IP address of the Aggregator server to which the Aggregator client must connect to |
| runProverServer | Enables Prover GRPC service |
| runFileProcessBatch | Processes a batch using as input a JSON file defined in the `"inputFile"` parameter |
| runFileGenProof | Generates a proof using as input a JSON file defined in the `"inputFile"` parameter |
| inputFile | Input JSON file with path relative to the `testvectors` folder |
| outputPath | Output path folder to store the result files, with path relative to the `testvectors` folder |
| databaseURL | Connection string for the PostgreSQL database used by the StateDB service. If the value is `"local"` then the service will not use a database and the data will be stored only in memory (no persistence). The PostgreSQL database connection string has the following format: `"postgresql://<user>:<password>@<ip>:<port>/<database>"`. For example: `"postgresql://statedb:[email protected]:5432/testdb"` |
| stateDBURL | Connection string for the StateDB service. If the value is `"local"` then the GRPC StateDB service will not be used and local StateDB client will be used instead. The StateDB service connection string has the following format: `"<ip>:<port>"`. For example: `"127.0.0.1:50061"` |
| saveRequestToFile | Saves service received requests to a text file |
| saveResponseToFile | Saves service returned responses to a text file |
| saveInputToFile | Saves service received input data to a JSON file |
| saveOutputToFile | Saves service returned output data to a JSON file |
| Parameter | Description |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| runStateDBServer | Enables StateDB GRPC service, provides SMT (Sparse Merkle Tree) and Database access |
| runExecutorServer | Enables Executor GRPC service, provides a service to process transaction batches |
| runAggregatorClient | Enables Aggregator GRPC client, connects to the Aggregator and process its requests |
| aggregatorClientHost | IP address of the Aggregator server to which the Aggregator client must connect to |
| runProverServer | Enables Prover GRPC service |
| runFileProcessBatch | Processes a batch using as input a JSON file defined in the `"inputFile"` parameter |
| runFileGenProof | Generates a proof using as input a JSON file defined in the `"inputFile"` parameter |
| inputFile | Input JSON file with path relative to the `testvectors` folder |
| outputPath | Output path folder to store the result files, with path relative to the `testvectors` folder |
| databaseURL | Connection string for the PostgreSQL database used by the StateDB service. If the value is `"local"` then the service will not use a database and the data will be stored only in memory (no persistence). The PostgreSQL database connection string has the following format: `"postgresql://<user>:<password>@<ip>:<port>/<database>"`. For example: `"postgresql://statedb:[email protected]:5432/testdb"` |
| stateDBURL | Connection string for the StateDB service. If the value is `"local"` then the GRPC StateDB service will not be used and local StateDB client will be used instead. The StateDB service connection string has the following format: `"<ip>:<port>"`. For example: `"127.0.0.1:50061"` |
| saveRequestToFile | Saves service received requests to a text file |
| saveResponseToFile | Saves service returned responses to a text file |
| saveInputToFile | Saves service received input data to a JSON file |
| saveOutputToFile | Saves service returned output data to a JSON file |

To run a proof test you must perform the following steps:
- Edit the `config.json` file and set the parameter `"runFileGenProof"` to `"true"`. The rest of the parameters must be set to `"false"`. Also set the parameter `"databaseURL` to `"local"` if you don't want to use a postgreSQL database to run the test
Expand Down
2 changes: 1 addition & 1 deletion src/goldilocks
104 changes: 0 additions & 104 deletions src/grpc/Makefile

This file was deleted.

File renamed without changes.
File renamed without changes.
Loading