Skip to content

Commit

Permalink
Merge pull request #10 from cyjseagull/feature-milestone2
Browse files Browse the repository at this point in the history
add Message and router implement
  • Loading branch information
cyjseagull authored Aug 26, 2024
2 parents 00d7e4b + ef3a682 commit ca71127
Show file tree
Hide file tree
Showing 96 changed files with 2,114 additions and 63 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cpp_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ jobs:
if: runner.os == 'macos'
with:
name: libppc-crypto-sdk-jni.dylib
path: ./cpp/ppc-crypto-c-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.dylib
path: ./cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.dylib
- uses: actions/upload-artifact@v2
if: runner.os == 'Windows'
with:
name: libppc-crypto-sdk-jni.dylib
path: D:\a\WeDPR-Component\cpp\ppc-crypto-c-sdk\bindings\java\src\main\resources\META-INF\native\Release\ppc-crypto-sdk-jni.dll
path: D:\a\WeDPR-Component\cpp\wedpr-component-sdk\bindings\java\src\main\resources\META-INF\native\Release\ppc-crypto-sdk-jni.dll

build_centos:
name: build_centos full node
Expand Down Expand Up @@ -221,4 +221,4 @@ jobs:
- uses: actions/upload-artifact@v2
with:
name: libppc-crypto-sdk-jni.so
path: ./cpp/ppc-crypto-c-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.so
path: ./cpp/wedpr-component-sdk/bindings/java/src/main/resources/META-INF/native/libppc-crypto-sdk-jni.so
17 changes: 15 additions & 2 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ include(TargetSettings)
include(Dependencies)

########### set the sources ###########
set(JNI_SOURCE_PATH ppc-crypto-c-sdk/bindings/java/src/main/c)
set(SDK_SOURCE_LIST ppc-homo ppc-crypto-core ppc-crypto-c-sdk ${JNI_SOURCE_PATH})
set(JNI_SOURCE_PATH wedpr-component-sdk/bindings/java/src/main/c)
set(SDK_SOURCE_LIST ppc-homo ppc-crypto-core wedpr-component-sdk ${JNI_SOURCE_PATH})
# Note: the udf depends on mysql, not enabled in the full node mode
set(UDF_SOURCE_LIST ${SDK_SOURCE_LIST} ppc-udf)
set(ALL_SOURCE_LIST
Expand All @@ -79,6 +79,19 @@ if(BUILD_CEM)
set(CEM_SOURCE "ppc-cem")
endif()

if(BUILD_WEDPR_TOOLKIT)
# fetch the python dependencies
option(FETCH_PYTHON_DEPS "Install python required modules if not available" ON)
message(STATUS "Python fetch dependencies: ${FETCH_PYTHON_DEPS}")
include(python)
if(WIN32)
message(STATUS "Getting SWIG for Windows: ...")
include(swig)
message(STATUS "Getting SWIG for Windows: ...DONE")
endif()
add_subdirectory(wedpr-toolkit-wrapper)
endif()

if(BUILD_ALL)
add_sources("${ALL_SOURCE_LIST}")
elseif(BUILD_UDF)
Expand Down
3 changes: 2 additions & 1 deletion cpp/cmake/IncludeDirectories.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_BINARY_DIR}/generated/)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-front)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-gateway)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-crypto-c-sdk)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/wedpr-component-sdk)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ppc-tars-protocol)

set(VCPKG_INCLUDE_PATH "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
Expand Down
1 change: 1 addition & 0 deletions cpp/cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ macro(configure_project)
default_option(BUILD_ALL ON)
default_option(BUILD_SDK OFF)
default_option(BUILD_UDF OFF)
default_option(BUILD_WEDPR_TOOLKIT OFF)

# Suffix like "-rc1" e.t.c. to append to versions wherever needed.
if (NOT DEFINED VERSION_SUFFIX)
Expand Down
12 changes: 9 additions & 3 deletions cpp/cmake/TargetSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,19 @@ if (ENABLE_CPU_FEATURES)
set(CPU_FEATURES_LIB CpuFeatures::cpu_features)
endif ()

#====== ppc-crypto-c-sdk ===========
#====== wedpr-component-sdk ===========
set(PPC_CRYPTO_C_SDK_STATIC_TARGET ppc-crypto-c-sdk-static)
set(PPC_CRYPTO_C_SDK_TARGET ppc-crypto-c-sdk)

set(PPC_FRONT_C_SDK_STATIC_TARGET ppc-front-c-sdk-static)

# add suffix for arm
if(ARCH_NATIVE)
message(STATUS "Building arm architecture, CMAKE_HOST_SYSTEM_PROCESSOR => ${CMAKE_HOST_SYSTEM_PROCESSOR}")
set(PPC_CRYPTO_C_SDK_STATIC_TARGET "ppc-crypto-c-sdk-aarch64")
set(PPC_CRYPTO_C_SDK_TARGET "ppc-crypto-c-sdk-static-aarch64")
endif()
#====== ppc-crypto-c-sdk ===========
#====== wedpr-component-sdk ===========


#====== ppc-crypto-sdk-jni ===========
Expand All @@ -119,4 +121,8 @@ if(ARCH_NATIVE)
endif()
# ========== ppc-udf ===========

set(BOOST_UNIT_TEST Boost::unit_test_framework)
set(BOOST_UNIT_TEST Boost::unit_test_framework)

# ==== the swig wrapper =====
set(WEDPR_PYTHON_TOOLKIT "wedpr_python_toolkit")
set(WEDPR_PYTHON_TOOLKIT_DIR ${PROJECT_BINARY_DIR}/python/${WEDPR_PYTHON_TOOLKIT})
1 change: 1 addition & 0 deletions cpp/cmake/Version.cmake
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
set(VERSION "1.0.0")
set(PYTHON_TOOLKIT_VERSION "1.0.0")
23 changes: 0 additions & 23 deletions cpp/ppc-crypto-c-sdk/CMakeLists.txt

This file was deleted.

27 changes: 27 additions & 0 deletions cpp/ppc-framework/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,40 @@ namespace ppc
{ \
}

#define CHECK_OFFSET_WITH_THROW_EXCEPTION(offset, length) \
do \
{ \
if (offset > length) \
{ \
throw std::out_of_range("Out of range error, offset:" + std::to_string(offset) + \
" ,length: " + std::to_string(length) + \
" ,file: " + __FILE__ + " ,func: " + __func__ + \
" ,line: " + std::to_string(__LINE__)); \
} \
} while (0);

DERIVE_PPC_EXCEPTION(OpenFileFailed);
DERIVE_PPC_EXCEPTION(DataSchemaNotSetted);
DERIVE_PPC_EXCEPTION(UnsupportedDataSchema);
DERIVE_PPC_EXCEPTION(WeDPRException);

constexpr static int MAX_PORT = 65535;
constexpr static int DEFAULT_SECURITY_PARAM = 128;

constexpr static size_t RSA_PUBLIC_KEY_PREFIX = 18;
constexpr static size_t RSA_PUBLIC_KEY_TRUNC = 8;
constexpr static size_t RSA_PUBLIC_KEY_TRUNC_LENGTH = 26;

inline std::string_view printP2PIDElegantly(std::string_view p2pId) noexcept
{
if (p2pId.length() < RSA_PUBLIC_KEY_TRUNC_LENGTH)
{
return p2pId;
}
return p2pId.substr(RSA_PUBLIC_KEY_PREFIX, RSA_PUBLIC_KEY_TRUNC);
}


#if ENABLE_CPU_FEATURES
#if X86
static const cpu_features::X86Features CPU_FEATURES = cpu_features::GetX86Info().features;
Expand Down
37 changes: 37 additions & 0 deletions cpp/ppc-framework/gateway/GatewayProtocol.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright (C) 2023 WeDPR.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @file Message.h
* @author: yujiechen
* @date 2024-08-22
*/
#pragma once
#include <stdint.h>

namespace ppc::gateway
{
enum class GatewayPacketType : uint16_t
{
P2PMessage = 0x00,
RouterTableSyncSeq = 0x10,
RouterTableResponse = 0x11,
RouterTableRequest = 0x12
};

enum class GatewayMsgExtFlag : uint16_t
{
Response = 0x1,
};
} // namespace ppc::gateway
Loading

0 comments on commit ca71127

Please sign in to comment.