Skip to content

Commit

Permalink
Merge pull request #40 from clearmatics/update-zeth
Browse files Browse the repository at this point in the history
Update zeth submodule and related changed (depends on #36)
  • Loading branch information
AntoineRondelet authored Sep 25, 2020
2 parents df21322 + 5b94600 commit c30af7b
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 24 deletions.
10 changes: 4 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,21 @@ set(
PROTO_SRC_DIR
${PROJECT_BINARY_DIR}
)
#file(MAKE_DIRECTORY ${PROTO_SRC_DIR})

# Get the proto files
file(
GLOB
PROTO_FILES
${PROJECT_SOURCE_DIR}/api/*.proto
${PROJECT_SOURCE_DIR}/proto/zecale/api/*.proto
)

# Set the import path to be able to re-use the Zeth proto files
set(PROTOBUF_IMPORT_DIRS ${PROJECT_SOURCE_DIR}/depends/zeth/)
set(PROTOBUF_IMPORT_DIRS ${PROJECT_SOURCE_DIR}/depends/zeth/proto)

set(PROTOBUF_PROTO_PATH ${PROJECT_SOURCE_DIR})
set(PROTOBUF_APPEND_DEST_PATH "/api")
set(PROTOBUF_PROTO_PATH ${PROJECT_SOURCE_DIR}/proto)
set(PROTOBUF_APPEND_DEST_PATH "/zecale/api")
set(PROTOBUF_GENERATE_CPP_APPEND_PATH OFF)
set(GRPC_GENERATE_CPP_APPEND_PATH OFF)
set(Protobuf_DEBUG ON)

# By default, compile with all warning flags
add_compile_options(-Wall -Wextra)
Expand Down
2 changes: 1 addition & 1 deletion aggregator_server/aggregator_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "libzecale/serialization/proto_utils.hpp"
#include "zecale_config.h"

#include <api/aggregator.grpc.pb.h>
#include <boost/program_options.hpp>
#include <fstream>
#include <grpc/grpc.h>
Expand All @@ -29,6 +28,7 @@
#include <memory>
#include <stdio.h>
#include <string>
#include <zecale/api/aggregator.grpc.pb.h>

namespace proto = google::protobuf;
namespace po = boost::program_options;
Expand Down
16 changes: 7 additions & 9 deletions client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@

ZETH_DIR:=../depends/zeth
ZETH_CLIENT_DIR:=$(ZETH_DIR)/client
ZETH_API_DIR:=$(ZETH_DIR)/api
ZETH_API_FILES:=$(wildcard $(ZETH_API_DIR)/*.proto)
ZETH_PROTO_DIR:=$(ZETH_DIR)/proto

ZECALE_API_DIR:=../../zecale/api
ZECALE_API_FILES:=$(wildcard $(ZECALE_API_DIR)/*.proto)
ZECALE_PROTO_DIR:=../proto
ZECALE_PROTO_FILES:=$(wildcard $(ZECALE_PROTO_DIR)/zecale/api/*.proto)

API_DEST_DIR:=zecale/api
API_OUTPUT:= $(addprefix $(API_DEST_DIR)/, \
aggregator_pb2.py aggregator_pb2_grpc.py)
API_OUTPUT:= $(addprefix $(API_DEST_DIR)/, aggregator_pb2.py)

# Create rule to build a grpc file from a source file. Params:
# 1 - .proto file
define grpc_build
$(API_DEST_DIR)/$(notdir $(basename $1))_pb2.py \
$(API_DEST_DIR)/$(notdir $(basename $1))_pb2_grpc.py : $(1)
python -m grpc_tools.protoc -I$(ZETH_DIR) -I.. --proto_path ../.. \
python -m grpc_tools.protoc -I$(ZETH_PROTO_DIR) -I.. --proto_path $(ZECALE_PROTO_DIR) \
--python_out=. --grpc_python_out=. --mypy_out=. \
$(subst $(ZETH_DIR)/,,$1)
$(subst $(ZECALE_PROTO_DIR)/,,$1)

endef

$(foreach src,$(ZECALE_API_FILES) $(ZETH_API_FILES),$(eval \
$(foreach src,$(ZECALE_PROTO_FILES),$(eval \
$(call grpc_build,$(src)) \
))

Expand Down
2 changes: 1 addition & 1 deletion client/zecale/cli/command_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .defaults import \
AGGREGATOR_SERVER_ENDPOINT_DEFAULT, ZKSNARK_NAME_DEFAULT
from ..core.aggregator_client import AggregatorClient
from zeth.zksnark import get_zksnark_provider
from zeth.core.zksnark import get_zksnark_provider
from typing import Optional


Expand Down
2 changes: 1 addition & 1 deletion client/zecale/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: LGPL-3.0+

from zeth.zksnark import GenericVerificationKey, GenericProof
from zeth.core.zksnark import GenericVerificationKey, GenericProof
import json


Expand Down
3 changes: 2 additions & 1 deletion client/zecale/core/aggregator_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from zecale.api import aggregator_pb2_grpc
from zecale.api import aggregator_pb2
import grpc
from zeth.zksnark import IZKSnarkProvider, GenericVerificationKey, GenericProof
from zeth.core.zksnark import \
IZKSnarkProvider, GenericVerificationKey, GenericProof
from google.protobuf import empty_pb2
from typing import Dict

Expand Down
2 changes: 1 addition & 1 deletion depends/zeth
Submodule zeth updated 142 files
3 changes: 2 additions & 1 deletion libzecale/serialization/proto_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
#ifndef __ZECALE_SERIALIZATION_PROTO_UTILS_HPP__
#define __ZECALE_SERIALIZATION_PROTO_UTILS_HPP__

#include "api/aggregator.pb.h"
#include "libzecale/core/transaction_to_aggregate.hpp"

#include <zecale/api/aggregator.pb.h>

namespace libzecale
{

Expand Down
4 changes: 2 additions & 2 deletions libzecale/tests/serialization/proto_utils_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
//
// SPDX-License-Identifier: LGPL-3.0+

#include "api/aggregator.pb.h"
#include "api/ec_group_messages.pb.h"
#include "libzecale/serialization/proto_utils.hpp"

#include "gtest/gtest.h"
Expand All @@ -16,6 +14,8 @@
#include <libzeth/snarks/groth16/groth16_api_handler.hpp>
#include <libzeth/snarks/pghr13/pghr13_api_handler.hpp>
#include <stdio.h>
#include <zecale/api/aggregator.pb.h>
#include <zeth/api/ec_group_messages.pb.h>

using namespace libzecale;

Expand Down
2 changes: 1 addition & 1 deletion api/aggregator.proto → proto/zecale/api/aggregator.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package zecale_proto;

import "google/protobuf/empty.proto";

import "api/snark_messages.proto";
import "zeth/api/snark_messages.proto";

service Aggregator {
// Fetch the verification key corresponding to the aggregator statement
Expand Down

0 comments on commit c30af7b

Please sign in to comment.