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

Arch portability #415

Closed
wants to merge 5 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
19 changes: 10 additions & 9 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 Down Expand Up @@ -50,13 +51,13 @@ 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)

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

MKDIR_P ?= mkdir -p
MKDIR_P ?= mkdir -p
11 changes: 10 additions & 1 deletion 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 All @@ -50,6 +54,11 @@ $ rm config
$ mv v1.1.0-rc.1-fork.4.tgz/config .
```

Depending on your `protobuf` version, you may need to regenerate gRPC files:
```sh
$ make -C src/grpc
```

Run `make` to compile the project
```sh
$ make clean
Expand Down
2 changes: 1 addition & 1 deletion src/goldilocks
4 changes: 2 additions & 2 deletions src/service/aggregator/aggregator_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AggregatorClient::AggregatorClient (Goldilocks &fr, const Config &config, Prover
prover(prover)
{
// Create channel
std::shared_ptr<grpc_impl::Channel> channel = ::grpc::CreateChannel(config.aggregatorClientHost + ":" + to_string(config.aggregatorClientPort), grpc::InsecureChannelCredentials());
std::shared_ptr<grpc::Channel> channel = ::grpc::CreateChannel(config.aggregatorClientHost + ":" + to_string(config.aggregatorClientPort), grpc::InsecureChannelCredentials());

// Create stub (i.e. client)
stub = new aggregator::v1::AggregatorService::Stub(channel);
Expand Down Expand Up @@ -662,4 +662,4 @@ void* aggregatorClientThread(void* arg)
sleep(5);
}
return NULL;
}
}
4 changes: 2 additions & 2 deletions src/service/statedb/statedb_remote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ using json = nlohmann::json;
StateDBRemote::StateDBRemote (Goldilocks &fr, const Config &config) : fr(fr), config(config)
{
// Create channel
std::shared_ptr<grpc_impl::Channel> channel = ::grpc::CreateChannel(config.stateDBURL, grpc::InsecureChannelCredentials());
std::shared_ptr<grpc::Channel> channel = ::grpc::CreateChannel(config.stateDBURL, grpc::InsecureChannelCredentials());

// Create stub (i.e. client)
stub = new statedb::v1::StateDBService::Stub(channel);
Expand Down Expand Up @@ -301,4 +301,4 @@ zkresult StateDBRemote::flush()
tms.add("flush", TimeDiff(t));
#endif
return static_cast<zkresult>(response.result().code());
}
}
4 changes: 2 additions & 2 deletions test/service/aggregator/aggregator_client_mock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AggregatorClientMock::AggregatorClientMock (Goldilocks &fr, const Config &config
config(config)
{
// Create channel
std::shared_ptr<grpc_impl::Channel> channel = ::grpc::CreateChannel(config.aggregatorClientHost + ":" + to_string(config.aggregatorClientPort), grpc::InsecureChannelCredentials());
std::shared_ptr<grpc::Channel> channel = ::grpc::CreateChannel(config.aggregatorClientHost + ":" + to_string(config.aggregatorClientPort), grpc::InsecureChannelCredentials());

// Create stub (i.e. client)
stub = new aggregator::v1::AggregatorService::Stub(channel);
Expand Down Expand Up @@ -384,4 +384,4 @@ void* aggregatorClientMockThread(void* arg)
sleep(5);
}
return NULL;
}
}
4 changes: 2 additions & 2 deletions test/service/executor/executor_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ ExecutorClient::ExecutorClient (Goldilocks &fr, const Config &config) :
config(config)
{
// Create channel
std::shared_ptr<grpc_impl::Channel> channel = ::grpc::CreateChannel(config.executorClientHost + ":" + to_string(config.executorClientPort), grpc::InsecureChannelCredentials());
std::shared_ptr<grpc::Channel> channel = ::grpc::CreateChannel(config.executorClientHost + ":" + to_string(config.executorClientPort), grpc::InsecureChannelCredentials());

// Create stub (i.e. client)
stub = new executor::v1::ExecutorService::Stub(channel);
Expand Down Expand Up @@ -173,4 +173,4 @@ void* executorClientThreads (void* arg)
}

return NULL;
}
}