Skip to content

Commit 1ab6a19

Browse files
authored
Merge branch 'feature-milestone2' into feature-milestone2
2 parents 45a3208 + f48a01f commit 1ab6a19

File tree

362 files changed

+43736
-4377
lines changed

Some content is hidden

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

362 files changed

+43736
-4377
lines changed

.github/workflows/cpp_workflow.yml

+15-12
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ jobs:
7575
if: runner.os != 'Windows'
7676
run: |
7777
cd cpp/build && CTEST_OUTPUT_ON_FAILURE=TRUE ctest
78-
make coverage
7978
8079
build_sdk:
8180
name: build sdk
@@ -129,20 +128,24 @@ jobs:
129128
- name: Build for macos
130129
if: runner.os == 'macOS'
131130
run: |
131+
brew install lcov
132132
bash cpp/tools/install_depends.sh -o macos
133-
mkdir -p cpp/build && cd cpp/build && cmake -DTESTS=ON -DCOVERAGE=ON -DBUILD_SDK=ON -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake ../
133+
mkdir -p cpp/build && cd cpp/build && cmake -DTESTS=ON -DCOVERAGE=OFF -DBUILD_SDK=ON -DCMAKE_TOOLCHAIN_FILE=${{ env.VCPKG_ROOT }}/scripts/buildsystems/vcpkg.cmake ../
134134
make -j3
135135
- name: Test
136-
if: runner.os != 'Windows'
136+
if: runner.os == 'macOS'
137137
run: |
138138
cd cpp/build && CTEST_OUTPUT_ON_FAILURE=TRUE make test
139-
make coverage
140-
- uses: actions/upload-artifact@v2
139+
- name: Test and upload coverage
140+
if: runner.os == 'Linux'
141+
run: |
142+
cd cpp/build && CTEST_OUTPUT_ON_FAILURE=TRUE make test
143+
- uses: actions/upload-artifact@v4
141144
if: runner.os == 'macos'
142145
with:
143146
name: libppc-crypto-sdk-jni.dylib
144147
path: ./cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.dylib
145-
- uses: actions/upload-artifact@v2
148+
- uses: actions/upload-artifact@v4
146149
if: runner.os == 'Windows'
147150
with:
148151
name: libppc-crypto-sdk-jni.dylib
@@ -185,7 +188,7 @@ jobs:
185188
- name: Prepare vcpkg
186189
if: runner.os != 'Windows'
187190
uses: friendlyanon/setup-vcpkg@v1
188-
with: { committish: 7e3dcf74e37034eea358934a90a11d618520e139 }
191+
with: { committish: 51b14cd4e1230dd51c11ffeff6f7d53c61cc5297 }
189192
- uses: actions-rs/toolchain@v1
190193
with:
191194
toolchain: nightly-2022-07-28
@@ -206,19 +209,19 @@ jobs:
206209
run: |
207210
export OMP_NUM_THREADS=1
208211
cd build && CTEST_OUTPUT_ON_FAILURE=TRUE make test
209-
- uses: actions/upload-artifact@v2
212+
- uses: actions/upload-artifact@v4
210213
with:
211214
name: ppc-air-node-centos-x64
212215
path: ./cpp/build/bin/ppc-air-node
213-
- uses: actions/upload-artifact@v2
216+
- uses: actions/upload-artifact@v4
214217
with:
215218
name: ppc-pro-node-centos-x64
216219
path: ./cpp/build/bin/ppc-pro-node
217-
- uses: actions/upload-artifact@v2
220+
- uses: actions/upload-artifact@v4
218221
with:
219222
name: ppc-gateway-service-centos-x64
220223
path: ./cpp/build/bin/ppc-gateway-service
221-
- uses: actions/upload-artifact@v2
224+
- uses: actions/upload-artifact@v4
222225
with:
223226
name: libppc-crypto-sdk-jni.so
224-
path: ./cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.so
227+
path: ./cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.so

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.venv
2+
13
# Prerequisites
24
*.d
35

@@ -36,13 +38,15 @@ cmake-build-debug
3638
*.exe
3739
*.out
3840
*.app
41+
**/*.class
3942

4043
build/**
4144
GPATH
4245
GRTAGS
4346
GTAGS
4447
deps
4548
deps/**
49+
**/bin
4650

4751
d1-encrypted
4852
d2-encrypted
@@ -137,6 +141,7 @@ ENV/
137141
*.crt
138142
*/bin
139143
*/logs
144+
*/bin
140145
*.csv
141146
*/*/logs
142147
*/start.out

cpp/CMakeLists.txt

+8-12
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ set(CEM_SOURCE "")
7272
if(BUILD_CEM)
7373
set(CEM_SOURCE "wedpr-computing/ppc-cem")
7474
endif()
75+
76+
set(TRANSPORT_SDK_SOURCE_LIST
77+
wedpr-protocol
78+
wedpr-transport/ppc-front
79+
wedpr-transport/sdk wedpr-transport/sdk-wrapper)
80+
7581
set(ALL_SOURCE_LIST
7682
${SDK_SOURCE_LIST}
7783
wedpr-crypto/ppc-crypto
@@ -83,24 +89,14 @@ set(ALL_SOURCE_LIST
8389
wedpr-computing/ppc-psi wedpr-computing/ppc-mpc wedpr-computing/ppc-pir ${CEM_SOURCE}
8490
wedpr-initializer wedpr-main)
8591

86-
if(BUILD_WEDPR_TOOLKIT)
87-
# fetch the python dependencies
88-
option(FETCH_PYTHON_DEPS "Install python required modules if not available" ON)
89-
message(STATUS "Python fetch dependencies: ${FETCH_PYTHON_DEPS}")
90-
if(WIN32)
91-
message(STATUS "Getting SWIG for Windows: ...")
92-
include(swig)
93-
message(STATUS "Getting SWIG for Windows: ...DONE")
94-
endif()
95-
add_subdirectory(wedpr-transport/sdk-wrapper)
96-
endif()
97-
9892
if(BUILD_ALL)
9993
add_sources("${ALL_SOURCE_LIST}")
10094
elseif(BUILD_UDF)
10195
add_sources("${UDF_SOURCE_LIST}")
10296
elseif(BUILD_SDK)
10397
add_sources("${SDK_SOURCE_LIST}")
98+
elseif(BUILD_WEDPR_TOOLKIT)
99+
add_sources("${TRANSPORT_SDK_SOURCE_LIST}")
104100
endif()
105101
########### set the sources end ###########
106102

cpp/cmake/BuildInfo.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function(create_build_info)
22
# Set build platform; to be written to BuildInfo.h
3-
set(PPC_BUILD_OS "${CMAKE_SYSTEM_NAME}")
3+
set(PPC_BUILD_OS "${CMAKE_HOST_SYSTEM_NAME}")
44

55
if (CMAKE_COMPILER_IS_MINGW)
66
set(PPC_BUILD_COMPILER "mingw")
@@ -27,7 +27,7 @@ function(create_build_info)
2727
# Generate header file containing useful build information
2828
add_custom_target(BuildInfo.h ALL
2929
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
30-
COMMAND ${CMAKE_COMMAND} -DPPC_SOURCE_DIR="${PROJECT_SOURCE_DIR}"
30+
COMMAND ${CMAKE_COMMAND} -DPPC_SOURCE_DIR="${PROJECT_SOURCE_DIR}/.."
3131
-DPPC_BUILDINFO_IN="${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/BuildInfo.h.in"
3232
-DPPC_DST_DIR="${PROJECT_BINARY_DIR}/include"
3333
-DPPC_CMAKE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/cmake"

cpp/cmake/CompilerSettings.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MA
101101
add_compile_options(-fstack-protector)
102102
add_compile_options(-Winconsistent-missing-override)
103103
# Some Linux-specific Clang settings. We don't want these for OS X.
104-
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
104+
if ("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Linux")
105105
# Tell Boost that we're using Clang's libc++. Not sure exactly why we need to do.
106106
add_definitions(-DBOOST_ASIO_HAS_CLANG_LIBCXX)
107107
# Use fancy colors in the compiler diagnostics

cpp/cmake/Coverage.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ function(config_coverage TARGET REMOVE_FILE_PATTERN)
2626
message(STATUS "coverage REMOVE_FILE_PATTERN: " ${REMOVE_FILE_PATTERN})
2727
if (APPLE)
2828
add_custom_target(${TARGET}
29-
COMMAND ${LCOV_TOOL} -keep-going --ignore-errors inconsistent,unmapped,source --rc lcov_branch_coverage=1 -o ${CMAKE_BINARY_DIR}/coverage.info.in -c -i -d ${CMAKE_BINARY_DIR}/
29+
COMMAND ${LCOV_TOOL} -keep-going --ignore-errors inconsistent,unmapped,source --rc lcov_branch_coverage=1 -o ${CMAKE_BINARY_DIR}/coverage.info.in -c -d ${CMAKE_BINARY_DIR}/
3030
COMMAND ${LCOV_TOOL} -keep-going --ignore-errors inconsistent,unmapped,source --rc lcov_branch_coverage=1 -r ${CMAKE_BINARY_DIR}/coverage.info.in '*MacOS*' '/usr*' '.*vcpkg_installed*' '.*boost/*' '*test*' '*build*' '*deps*' ${REMOVE_FILE_PATTERN} -o ${CMAKE_BINARY_DIR}/coverage.info
3131
COMMAND genhtml --keep-going --ignore-errors inconsistent,unmapped,source --rc lcov_branch_coverage=1 -q -o ${CMAKE_BINARY_DIR}/CodeCoverage ${CMAKE_BINARY_DIR}/coverage.info)
3232
else()
3333
add_custom_target(${TARGET}
34-
COMMAND ${LCOV_TOOL} --rc lcov_branch_coverage=1 -o ${CMAKE_BINARY_DIR}/coverage.info.in -c -i -d ${CMAKE_BINARY_DIR}/
34+
COMMAND ${LCOV_TOOL} --rc lcov_branch_coverage=1 -o ${CMAKE_BINARY_DIR}/coverage.info.in -c -d ${CMAKE_BINARY_DIR}/
3535
COMMAND ${LCOV_TOOL} --rc lcov_branch_coverage=1 -r ${CMAKE_BINARY_DIR}/coverage.info.in '*MacOS*' '/usr*' '.*vcpkg_installed*' '.*boost/*' '*test*' '*build*' '*deps*' ${REMOVE_FILE_PATTERN} -o ${CMAKE_BINARY_DIR}/coverage.info
3636
COMMAND genhtml --rc lcov_branch_coverage=1 -q -o ${CMAKE_BINARY_DIR}/CodeCoverage ${CMAKE_BINARY_DIR}/coverage.info)
3737
endif()

cpp/cmake/Dependencies.cmake

+6-4
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,19 @@ find_package(unofficial-sodium CONFIG REQUIRED)
2121

2222

2323
##### the full-dependencies #####
24-
if(BUILD_ALL)
25-
find_package(TBB REQUIRED)
24+
if(BUILD_ALL OR BUILD_WEDPR_TOOLKIT)
2625
find_package(jsoncpp REQUIRED)
27-
26+
find_package(TBB REQUIRED)
27+
find_package(gRPC REQUIRED)
2828
find_package(${BCOS_BOOSTSSL_TARGET} REQUIRED)
29+
endif()
30+
31+
if(BUILD_ALL)
2932
# tcmalloc
3033
include(ProjectTCMalloc)
3134

3235
find_package(SEAL REQUIRED)
3336
find_package(Kuku REQUIRED)
34-
find_package(gRPC REQUIRED)
3537

3638
# APSI: Note: APSI depends on seal 4.0 and Kuku 2.1
3739
include(ProjectAPSI)

cpp/cmake/Installlibhdfs3.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
find_package(libxml2 REQUIRED)
22
find_package(protobuf REQUIRED)
3-
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
3+
if ("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Linux")
44
find_package(unofficial-libuuid REQUIRED)
55
endif()
66
find_package(libhdfs3 REQUIRED)

cpp/cmake/Options.cmake

+17-5
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ macro(configure_project)
8282
if (${SUPPORTED_INSTRUCTIONS} MATCHES ".*SSE4.2.*")
8383
set(ENABLE_SSE ON)
8484
endif ()
85-
elseif(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows")
85+
elseif(NOT ${CMAKE_HOST_SYSTEM_NAME} MATCHES "Windows")
8686
# detect sse4_2
8787
FILE(READ "/proc/cpuinfo" SUPPORTED_INSTRUCTIONS)
88+
message("* Linux SUPPORTED_INSTRUCTIONS: ${SUPPORTED_INSTRUCTIONS}")
8889
if (${SUPPORTED_INSTRUCTIONS} MATCHES ".*sse4_2.*")
8990
set(ENABLE_SSE ON)
9091
endif ()
@@ -130,13 +131,23 @@ macro(configure_project)
130131
set(VISIBILITY_FLAG "")
131132
set(BUILD_ALL OFF)
132133
endif()
134+
if (BUILD_WEDPR_TOOLKIT)
135+
set(VISIBILITY_FLAG "")
136+
set(BUILD_ALL OFF)
137+
endif()
133138
if (BUILD_ALL)
134139
# install all dependencies
135140
list(APPEND VCPKG_MANIFEST_FEATURES "all")
141+
if(ENABLE_SSE)
142+
# enable sse for libhdfs3
143+
list(APPEND VCPKG_MANIFEST_FEATURES "sse-libhdfs3")
144+
else()
145+
list(APPEND VCPKG_MANIFEST_FEATURES "default-libhdfs3")
146+
endif()
136147
endif()
137-
if(ENABLE_SSE)
138-
# enable sse for libhdfs3
139-
list(APPEND VCPKG_MANIFEST_FEATURES "sse")
148+
if (BUILD_WEDPR_TOOLKIT)
149+
# install wedpr dependencies
150+
list(APPEND VCPKG_MANIFEST_FEATURES "toolkit")
140151
endif()
141152
# cpp_features
142153
if(ENABLE_CPU_FEATURES)
@@ -156,7 +167,7 @@ macro(print_config NAME)
156167
message("-- CMAKE_BUILD_TYPE Build type ${CMAKE_BUILD_TYPE}")
157168
message("-- VCPKG_MANIFEST_FEATURES VCPKG manifest features ${VCPKG_MANIFEST_FEATURES}")
158169
message("-- CMAKE_TOOLCHAIN_FILE Cmake toolchain file ${CMAKE_TOOLCHAIN_FILE}")
159-
message("-- TARGET_PLATFORM Target platform ${CMAKE_SYSTEM_NAME} ${ARCHITECTURE}")
170+
message("-- TARGET_PLATFORM Target platform ${CMAKE_HOST_SYSTEM_NAME} ${ARCHITECTURE}")
160171
message("-- BUILD_STATIC Build static ${BUILD_STATIC}")
161172
message("-- COVERAGE Build code coverage ${COVERAGE}")
162173
message("-- TESTS Build tests ${TESTS}")
@@ -170,6 +181,7 @@ macro(print_config NAME)
170181
message("-- BUILD_SDK BUILD SDK ${BUILD_SDK}")
171182
message("-- BUILD_UDF BUILD UDF ${BUILD_UDF}")
172183
message("-- BUILD_WEDPR_TOOLKIT BUILD_WEDPR_TOOLKIT ${BUILD_WEDPR_TOOLKIT}")
184+
message("-- AUTO_GENERATE AUTO_GENERATE ${AUTO_GENERATE}")
173185
message("-- DEBUG ${DEBUG}")
174186
message("------------------------------------------------------------------------")
175187
message("")

cpp/cmake/TargetSettings.cmake

+5-3
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ set(WEDPR_TRANSPORT_SDK_TARGET wedpr-transport-sdk)
138138

139139
# ==== the swig wrapper =====
140140
set(WEDPR_PYTHON_TRANSPORT "wedpr_python_transport")
141-
set(WEDPR_PYTHON_TRANSPORT_DIR ${PROJECT_BINARY_DIR}/python/${WEDPR_PYTHON_TRANSPORT})
141+
set(WEDPR_PYTHON_TRANSPORT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/python/generated/${WEDPR_PYTHON_TRANSPORT})
142+
set(WEDPR_PYTHON_TRANSPORT_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wedpr-transport/sdk-wrapper/python/bindings/libs)
142143

143-
set(WEDPR_JAVA_TRANSPORT "wedpr_java_transport")
144-
set(WEDPR_JAVA_TRANSPORT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/java/${WEDPR_JAVA_TRANSPORT})
144+
set(WEDPR_JAVA_TRANSPORT "wedpr_java_transport_jni")
145+
set(WEDPR_JAVA_TRANSPORT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/java/generated/${WEDPR_JAVA_TRANSPORT})
146+
set(WEDPR_JAVA_TRANSPORT_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wedpr-transport/sdk-wrapper/java/bindings/src/main/resources/META-INF/native)

cpp/cmake/python.cmake

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ if(UNIX AND NOT APPLE)
1919
endif()
2020

2121
# Find Python 3
22-
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
22+
find_package(Python REQUIRED COMPONENTS Interpreter Development)
23+
message("Python_FOUND:${Python_FOUND}")
24+
message("Python_VERSION:${Python_VERSION}")
25+
message("Python_Development_FOUND:${Python_Development_FOUND}")
26+
message("Python_LIBRARIES:${Python_LIBRARIES}")
27+
message("Python_INCLUDE_DIRS:${Python_INCLUDE_DIRS}")
28+
2329
list(APPEND CMAKE_SWIG_FLAGS "-py3" "-DPY3")
2430

2531
function(search_python_module)

cpp/ppc-framework/Common.h

-22
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,6 @@ DERIVE_PPC_EXCEPTION(DataSchemaNotSetted);
6161
DERIVE_PPC_EXCEPTION(UnsupportedDataSchema);
6262
DERIVE_PPC_EXCEPTION(WeDPRException);
6363

64-
constexpr static int MAX_PORT = 65535;
65-
constexpr static int DEFAULT_SECURITY_PARAM = 128;
66-
67-
constexpr static size_t RSA_PUBLIC_KEY_PREFIX = 18;
68-
constexpr static size_t RSA_PUBLIC_KEY_TRUNC = 8;
69-
constexpr static size_t RSA_PUBLIC_KEY_TRUNC_LENGTH = 26;
70-
71-
inline std::string_view printP2PIDElegantly(std::string_view p2pId) noexcept
72-
{
73-
if (p2pId.length() < RSA_PUBLIC_KEY_TRUNC_LENGTH)
74-
{
75-
return p2pId;
76-
}
77-
return p2pId.substr(RSA_PUBLIC_KEY_PREFIX, RSA_PUBLIC_KEY_TRUNC);
78-
}
79-
80-
template <typename T>
81-
inline std::string printNodeID(T const& nodeID)
82-
{
83-
return std::string(nodeID.begin(), nodeID.begin() + 8);
84-
}
85-
8664
#if ENABLE_CPU_FEATURES
8765
#if X86
8866
static const cpu_features::X86Features CPU_FEATURES = cpu_features::GetX86Info().features;

cpp/ppc-framework/Helper.h

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (C) 2022 WeDPR.
3+
* SPDX-License-Identifier: Apache-2.0
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* @file Common.h
17+
* @author: yujiechen
18+
* @date 2022-10-20
19+
*/
20+
#pragma once
21+
#include <sstream>
22+
#include <string>
23+
namespace ppc
24+
{
25+
constexpr static int MAX_PORT = 65535;
26+
constexpr static int DEFAULT_SECURITY_PARAM = 128;
27+
28+
constexpr static size_t RSA_PUBLIC_KEY_PREFIX = 18;
29+
constexpr static size_t RSA_PUBLIC_KEY_TRUNC = 8;
30+
constexpr static size_t RSA_PUBLIC_KEY_TRUNC_LENGTH = 26;
31+
32+
inline std::string_view printP2PIDElegantly(std::string_view p2pId) noexcept
33+
{
34+
if (p2pId.length() < RSA_PUBLIC_KEY_TRUNC_LENGTH)
35+
{
36+
return p2pId;
37+
}
38+
return p2pId.substr(RSA_PUBLIC_KEY_PREFIX, RSA_PUBLIC_KEY_TRUNC);
39+
}
40+
41+
42+
template <typename T>
43+
inline std::string_view printNodeID(T const& nodeID)
44+
{
45+
size_t offset = nodeID.size() >= 15 ? 15 : nodeID.size();
46+
return std::string_view((const char*)nodeID.data(), offset);
47+
}
48+
} // namespace ppc

cpp/ppc-framework/front/FrontConfig.h

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class FrontConfig
7373
virtual std::vector<std::string> const& getComponents() const { return m_components; }
7474
void setComponents(std::vector<std::string> const& components) { m_components = components; }
7575

76+
void addComponent(std::string const& component) { m_components.emplace_back(component); }
77+
7678
std::vector<std::string>& mutableComponents() { return m_components; }
7779

7880
protected:

0 commit comments

Comments
 (0)