Skip to content

Commit efb26e9

Browse files
author
shgandhi
committed
gRPC upgrade version
This commit upgrades gRPC from 1.37.x to the latest release version 1.48.0. Over the past ten versions of gRPC multiple optimizations and bug fixes have been introduced. Please see https://github.com/grpc/grpc/releases for the detailed breakdown of updates from 1.38.0 to 1.48.0. This upgrade would also allow for batching of updates natively via setting the buffer hint flag for improved performance. This change updates client, TRS and UTT CMakeLists files to account for the upgrade.
1 parent cb84fa5 commit efb26e9

File tree

7 files changed

+325
-83
lines changed

7 files changed

+325
-83
lines changed

client/clientservice/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
set(CMAKE_CXX_STANDARD 17)
3+
14
find_package(GRPC REQUIRED)
5+
find_package(absl CONFIG REQUIRED)
6+
find_package(Protobuf CONFIG REQUIRED)
27
find_package(Boost ${MIN_BOOST_VERSION} COMPONENTS program_options REQUIRED)
38
find_package(jaegertracing REQUIRED)
49

@@ -13,6 +18,7 @@ target_link_libraries(clientservice-lib PUBLIC
1318
concordclient
1419
gRPC::grpc++
1520
gRPC::grpc++_reflection
21+
protobuf::libprotobuf
1622
logging
1723
yaml-cpp
1824
secret_retriever

client/proto/CMakeLists.txt

Lines changed: 102 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,105 @@
1-
find_package(Protobuf REQUIRED)
1+
cmake_minimum_required(VERSION 3.5)
2+
set(CMAKE_CXX_STANDARD 17)
3+
4+
project(concord)
5+
6+
find_package(absl CONFIG REQUIRED)
27
find_package(GRPC REQUIRED)
38

4-
include_directories(${GRPC_INCLUDE_DIR})
5-
6-
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${CMAKE_CURRENT_BINARY_DIR}
7-
request/v1/request.proto
8-
event/v1/event.proto
9-
state_snapshot/v1/state_snapshot.proto
10-
../concordclient/proto/concord_client_request/v1/concord_client_request.proto
11-
)
12-
grpc_generate_cpp(GRPC_SRCS GRPC_HDRS ${CMAKE_CURRENT_BINARY_DIR}
13-
request/v1/request.proto
14-
event/v1/event.proto
15-
state_snapshot/v1/state_snapshot.proto
16-
../concordclient/proto/concord_client_request/v1/concord_client_request.proto
17-
)
18-
19-
add_library(clientservice-proto STATIC ${PROTO_SRCS} ${GRPC_SRCS})
20-
target_link_libraries(clientservice-proto PRIVATE protobuf::libprotobuf gRPC::grpc++)
9+
# Proto file
10+
get_filename_component(rs_proto "request/v1/request.proto" ABSOLUTE)
11+
get_filename_component(es_proto "event/v1/event.proto" ABSOLUTE)
12+
get_filename_component(ss_proto "state_snapshot/v1/state_snapshot.proto" ABSOLUTE)
13+
get_filename_component(ccr_proto "../concordclient/proto/concord_client_request/v1/concord_client_request.proto" ABSOLUTE)
14+
get_filename_component(rs_proto_path "${rs_proto}" PATH)
15+
get_filename_component(es_proto_path "${es_proto}" PATH)
16+
get_filename_component(ss_proto_path "${ss_proto}" PATH)
17+
get_filename_component(ccr_proto_path "${ccr_proto}" PATH)
18+
19+
get_target_property(grpc_cpp_plugin_location gRPC::grpc_cpp_plugin LOCATION)
20+
21+
# Generated sources
22+
set(rs_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/request.pb.cc")
23+
set(rs_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/request.pb.h")
24+
set(rs_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/request.grpc.pb.cc")
25+
set(rs_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/request.grpc.pb.h")
26+
add_custom_command(
27+
OUTPUT "${rs_proto_srcs}" "${rs_proto_hdrs}" "${rs_grpc_srcs}" "${rs_grpc_hdrs}"
28+
COMMAND protoc
29+
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
30+
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
31+
-I "${rs_proto_path}"
32+
--plugin=protoc-gen-grpc="${grpc_cpp_plugin_location}"
33+
"${rs_proto}"
34+
DEPENDS "${rs_proto}")
35+
36+
set(es_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/event.pb.cc")
37+
set(es_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/event.pb.h")
38+
set(es_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/event.grpc.pb.cc")
39+
set(es_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/event.grpc.pb.h")
40+
add_custom_command(
41+
OUTPUT "${es_proto_srcs}" "${es_proto_hdrs}" "${es_grpc_srcs}" "${es_grpc_hdrs}"
42+
COMMAND protoc
43+
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
44+
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
45+
-I "${es_proto_path}"
46+
--plugin=protoc-gen-grpc="${grpc_cpp_plugin_location}"
47+
"${es_proto}"
48+
DEPENDS "${es_proto}")
49+
50+
set(ss_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/state_snapshot.pb.cc")
51+
set(ss_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/state_snapshot.pb.h")
52+
set(ss_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/state_snapshot.grpc.pb.cc")
53+
set(ss_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/state_snapshot.grpc.pb.h")
54+
add_custom_command(
55+
OUTPUT "${ss_proto_srcs}" "${ss_proto_hdrs}" "${ss_grpc_srcs}" "${ss_grpc_hdrs}"
56+
COMMAND protoc
57+
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
58+
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
59+
-I "${ss_proto_path}"
60+
--plugin=protoc-gen-grpc="${grpc_cpp_plugin_location}"
61+
"${ss_proto}"
62+
DEPENDS "${ss_proto}")
63+
64+
set(ccr_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/concord_client_request.pb.cc")
65+
set(ccr_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/concord_client_request.pb.h")
66+
set(ccr_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/concord_client_request.grpc.pb.cc")
67+
set(ccr_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/concord_client_request.grpc.pb.h")
68+
add_custom_command(
69+
OUTPUT "${ccr_proto_srcs}" "${ccr_proto_hdrs}" "${ccr_grpc_srcs}" "${ccr_grpc_hdrs}"
70+
COMMAND protoc
71+
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
72+
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
73+
-I "${ccr_proto_path}"
74+
--plugin=protoc-gen-grpc="${grpc_cpp_plugin_location}"
75+
"${ccr_proto}"
76+
DEPENDS "${ccr_proto}")
77+
78+
79+
# Include generated *.pb.h files
80+
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
81+
82+
# clientservice-proto
83+
add_library(clientservice-proto STATIC
84+
${rs_grpc_srcs}
85+
${rs_grpc_hdrs}
86+
${rs_proto_srcs}
87+
${rs_proto_hdrs}
88+
${es_grpc_srcs}
89+
${es_grpc_hdrs}
90+
${es_proto_srcs}
91+
${es_proto_hdrs}
92+
${ss_grpc_srcs}
93+
${ss_grpc_hdrs}
94+
${ss_proto_srcs}
95+
${ss_proto_hdrs}
96+
${ccr_grpc_srcs}
97+
${ccr_grpc_hdrs}
98+
${ccr_proto_srcs}
99+
${ccr_proto_hdrs})
100+
target_link_libraries(clientservice-proto PRIVATE
101+
${_REFLECTION}
102+
${_GRPC_GRPCPP}
103+
${_PROTOBUF_LIBPROTOBUF}
104+
absl::synchronization)
21105
target_include_directories(clientservice-proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

cmake/common.cmake

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
3+
set(CMAKE_CXX_STANDARD 17)
4+
5+
find_package(Threads REQUIRED)
6+
7+
if(GRPC_AS_SUBMODULE)
8+
# One way to build a projects that uses gRPC is to just include the
9+
# entire gRPC project tree via "add_subdirectory".
10+
# This approach is very simple to use, but the are some potential
11+
# disadvantages:
12+
# * it includes gRPC's CMakeLists.txt directly into your build script
13+
# without and that can make gRPC's internal setting interfere with your
14+
# own build.
15+
# * depending on what's installed on your system, the contents of submodules
16+
# in gRPC's third_party/* might need to be available (and there might be
17+
# additional prerequisites required to build them). Consider using
18+
# the gRPC_*_PROVIDER options to fine-tune the expected behavior.
19+
#
20+
# A more robust approach to add dependency on gRPC is using
21+
# cmake's ExternalProject_Add (see cmake_externalproject/CMakeLists.txt).
22+
23+
# Include the gRPC's cmake build (normally grpc source code would live
24+
# in a git submodule called "third_party/grpc", but this example lives in
25+
# the same repository as gRPC sources, so we just look a few directories up)
26+
add_subdirectory(../../.. ${CMAKE_CURRENT_BINARY_DIR}/grpc EXCLUDE_FROM_ALL)
27+
message(STATUS "Using gRPC via add_subdirectory.")
28+
29+
# After using add_subdirectory, we can now use the grpc targets directly from
30+
# this build.
31+
set(_PROTOBUF_LIBPROTOBUF libprotobuf)
32+
set(_REFLECTION buf_protoc)
33+
if(CMAKE_CROSSCOMPILING)
34+
find_program(_PROTOBUF_PROTOC protoc)
35+
else()
36+
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
37+
endif()
38+
set(_GRPC_GRPCPP grpc++)
39+
if(CMAKE_CROSSCOMPILING)
40+
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
41+
else()
42+
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:grpc_cpp_plugin>)
43+
endif()
44+
elseif(GRPC_FETCHCONTENT)
45+
# Another way is to use CMake's FetchContent module to clone gRPC at
46+
# configure time. This makes gRPC's source code available to your project,
47+
# similar to a git submodule.
48+
message(STATUS "Using gRPC via add_subdirectory (FetchContent).")
49+
include(FetchContent)
50+
FetchContent_Declare(
51+
grpc
52+
GIT_REPOSITORY https://github.com/grpc/grpc.git
53+
# when using gRPC, you will actually set this to an existing tag, such as
54+
# v1.25.0, v1.26.0 etc..
55+
# For the purpose of testing, we override the tag used to the commit
56+
# that's currently under test.
57+
GIT_TAG vGRPC_TAG_VERSION_OF_YOUR_CHOICE)
58+
FetchContent_MakeAvailable(grpc)
59+
60+
# Since FetchContent uses add_subdirectory under the hood, we can use
61+
# the grpc targets directly from this build.
62+
set(_PROTOBUF_LIBPROTOBUF libprotobuf)
63+
set(_REFLECTION grpc++_reflection)
64+
set(_PROTOBUF_PROTOC $<TARGET_FILE:protoc>)
65+
set(_GRPC_GRPCPP grpc++)
66+
if(CMAKE_CROSSCOMPILING)
67+
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
68+
else()
69+
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:grpc_cpp_plugin>)
70+
endif()
71+
else()
72+
# This branch assumes that gRPC and all its dependencies are already installed
73+
# on this system, so they can be located by find_package().
74+
75+
# Include Concord-bft CMake dependencies.
76+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake")
77+
78+
# Find Protobuf installation
79+
# Looks for protobuf-config.cmake file installed by Protobuf's cmake installation.
80+
set(protobuf_MODULE_COMPATIBLE TRUE)
81+
find_package(Protobuf REQUIRED)
82+
message(STATUS "Using protobuf ${Protobuf_VERSION}")
83+
84+
set(_PROTOBUF_LIBPROTOBUF protobuf::libprotobuf)
85+
set(_REFLECTION gRPC::grpc++_reflection)
86+
if(CMAKE_CROSSCOMPILING)
87+
find_program(_PROTOBUF_PROTOC protoc)
88+
else()
89+
set(_PROTOBUF_PROTOC $<TARGET_FILE:protobuf::protoc>)
90+
endif()
91+
92+
# Find gRPC installation
93+
# Looks for gRPCConfig.cmake file installed by gRPC's cmake installation.
94+
find_package(GRPC REQUIRED)
95+
include_directories(${GRPC_INCLUDE_DIR})
96+
message(STATUS "Using gRPC ${gRPC_VERSION}")
97+
98+
set(_GRPC_GRPCPP gRPC::grpc++)
99+
if(CMAKE_CROSSCOMPILING)
100+
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
101+
else()
102+
set(_GRPC_CPP_PLUGIN_EXECUTABLE $<TARGET_FILE:gRPC::grpc_cpp_plugin>)
103+
endif()
104+
endif()

install_deps.sh

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ install_third_party_libraries() {
7676
pytest \
7777
pycryptodome \
7878
ecdsa \
79-
protobuf==3.15.8 \
80-
grpcio==1.37.1 \
81-
grpcio-tools==1.37.1
79+
protobuf==3.21.5 \
80+
grpcio==1.48.0 \
81+
grpcio-tools==1.48.0
8282
}
8383

8484

@@ -300,36 +300,20 @@ install_openssl() {
300300
# https://github.com/grpc/grpc/blob/master/test/distrib/cpp/run_distrib_test_cmake.sh
301301
install_grpc() {
302302
cd ${HOME}
303-
git clone -b v1.37.1 --depth 1 --recurse-submodules https://github.com/grpc/grpc && \
304-
cd grpc && \
305-
mkdir -p ${HOME}/grpc/third_party/abseil-cpp/cmake/build && \
306-
cd ${HOME}/grpc/third_party/abseil-cpp/cmake/build && \
307-
cmake -DCMAKE_BUILD_TYPE=Release \
308-
-DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
309-
-DCMAKE_INSTALL_PREFIX=/usr/local \
310-
../.. && \
311-
make -j$(nproc) install && \
312-
mkdir -p ${HOME}/grpc/third_party/protobuf/cmake/build && \
313-
cd ${HOME}/grpc/third_party/protobuf/cmake/build && \
314-
cmake -DBUILD_SHARED_LIBS=ON \
315-
-DCMAKE_BUILD_TYPE=Release \
316-
-DCMAKE_INSTALL_PREFIX=/usr/local \
317-
.. && \
318-
make -j$(nproc) install && \
319-
mkdir -p ${HOME}/grpc/cmake/build && \
320-
cd ${HOME}/grpc/cmake/build && \
321-
cmake -DgRPC_INSTALL=ON \
322-
-DgRPC_ABSL_PROVIDER=package \
323-
-DgRPC_PROTOBUF_PROVIDER=package \
324-
-DgRPC_SSL_PROVIDER=package \
325-
-DBUILD_SHARED_LIBS=ON \
326-
-DCMAKE_BUILD_TYPE=Release \
327-
-DCMAKE_INSTALL_PREFIX=/usr/local \
328-
../.. && \
329-
make -j$(nproc) install &&
330-
cd ${HOME} && \
331-
rm -r ${HOME}/grpc
332-
303+
git clone -b v1.48.x --depth 1 --recurse-submodules https://github.com/grpc/grpc && \
304+
mkdir -p ${HOME}/grpc/cmake/build && \
305+
cd ${HOME}/grpc/cmake/build && \
306+
cmake -DCMAKE_CXX_STANDARD=17 \
307+
-DCMAKE_BUILD_TYPE=Release \
308+
-DBUILD_SHARED_LIBS=ON \
309+
-DgRPC_INSTALL=ON \
310+
-DgRPC_BUILD_TESTS=OFF \
311+
-DgRPC_SSL_PROVIDER=package \
312+
-DCMAKE_INSTALL_PREFIX=/opt/grpc \
313+
../.. && \
314+
make -j$(nproc) install && \
315+
cd ${HOME} && \
316+
rm -r ${HOME}/grpc
333317
}
334318

335319
install_prometheus() {

kvbc/proto/CMakeLists.txt

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
1-
find_package(Protobuf REQUIRED)
1+
cmake_minimum_required(VERSION 3.5)
2+
set(CMAKE_CXX_STANDARD 17)
3+
4+
find_package(absl CONFIG REQUIRED)
5+
find_package(GRPC REQUIRED)
6+
find_package(Protobuf CONFIG REQUIRED)
7+
8+
# Proto file
9+
get_filename_component(concord_kvbc_proto "concord_kvbc.proto" ABSOLUTE)
10+
get_filename_component(concord_kvbc_proto_path "${concord_kvbc_proto}" PATH)
11+
12+
set(ck_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/concord_kvbc.pb.cc")
13+
set(ck_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/concord_kvbc.pb.h")
14+
15+
add_custom_command(
16+
OUTPUT "${ck_proto_srcs}" "${ck_proto_hdrs}"
17+
COMMAND protoc
18+
ARGS --proto_path="${concord_kvbc_proto_path}"
19+
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
20+
"${concord_kvbc_proto}"
21+
DEPENDS "${concord_kvbc_proto}")
222

3-
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${CMAKE_CURRENT_BINARY_DIR}
4-
concord_kvbc.proto
5-
)
623
message(STATUS "Concord KVBC protobuf generated - see " ${CMAKE_CURRENT_BINARY_DIR})
724

8-
add_library(concord-kvbc-proto STATIC ${PROTO_SRCS})
25+
add_library(concord-kvbc-proto STATIC ${ck_proto_srcs})
926
target_link_libraries(concord-kvbc-proto protobuf::libprotobuf)
1027
target_include_directories(concord-kvbc-proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

0 commit comments

Comments
 (0)