This commit is contained in:
Amaury Chamayou 2020-01-28 18:09:42 +00:00 коммит произвёл GitHub
Родитель ae327aa09a
Коммит 9f65d22fb6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
12 изменённых файлов: 1140 добавлений и 960 удалений

Просмотреть файл

@ -23,4 +23,10 @@ jobs:
source env/bin/activate
pip install black
black --check sphinx/ tests/ notice-check.py
displayName: 'Check Python code format'
displayName: 'Check Python code format'
- script: |
source env/bin/activate
pip install cmake_format
cmake-format --check CMakeLists.txt $(find . -name "*.cmake" | tr "\n" " ")
displayName: 'Check CMake code format'

245
.cmake-format.py Normal file
Просмотреть файл

@ -0,0 +1,245 @@
# ----------------------------------
# Options affecting listfile parsing
# ----------------------------------
with section("parse"):
# Specify structure for custom cmake functions
additional_commands = {
"add_ccf_app": {
"kwargs": {
"SRCS": "*",
"INCLUDE_DIRS": "*",
"LINK_LIBS_ENCLAVE": "*",
"LINK_LIBS_VIRTUAL": "*",
},
},
"add_client_exe": {
"kwargs": {"SRCS": "*", "INCLUDE_DIRS": "*", "LINK_LIBS": "*"},
},
"add_e2e_test": {
"kwargs": {
"NAME": "*",
"PYTHON_SCRIPT": "*",
"IS_SUITE": "*",
"CURL_CLIENT": "*",
"ADDITIONAL_ARGS": "*",
},
},
"add_perf_test": {
"kwargs": {
"NAME": "*",
"PYTHON_SCRIPT": "*",
"CLIENT_BIN": "*",
"VERIFICATION_FILE": "*",
"LABEL": "*",
"ADDITIONAL_ARGS": "*",
},
},
"add_picobench": {
"kwargs": {"SRCS": "*", "INCLUDE_DIRS": "*", "LINK_LIBS": "*",},
},
}
# -----------------------------
# Options effecting formatting.
# -----------------------------
with section("format"):
# How wide to allow formatted cmake files
line_width = 80
# How many spaces to tab for indent
tab_size = 2
# If an argument group contains more than this many sub-groups (parg or kwarg
# groups) then force it to a vertical layout.
max_subgroups_hwrap = 2
# If a positional argument group contains more than this many arguments, then
# force it to a vertical layout.
max_pargs_hwrap = 6
# If a cmdline positional group consumes more than this many lines without
# nesting, then invalidate the layout (and nest)
max_rows_cmdline = 2
# If true, separate flow control names from their parentheses with a space
separate_ctrl_name_with_space = False
# If true, separate function names from parentheses with a space
separate_fn_name_with_space = False
# If a statement is wrapped to more than one line, than dangle the closing
# parenthesis on its own line.
dangle_parens = True
# If the trailing parenthesis must be 'dangled' on its on line, then align it
# to this reference: `prefix`: the start of the statement, `prefix-indent`:
# the start of the statement, plus one indentation level, `child`: align to
# the column of the arguments
dangle_align = "prefix"
# If the statement spelling length (including space and parenthesis) is
# smaller than this amount, then force reject nested layouts.
min_prefix_chars = 4
# If the statement spelling length (including space and parenthesis) is larger
# than the tab width by more than this amount, then force reject un-nested
# layouts.
max_prefix_chars = 10
# If a candidate layout is wrapped horizontally but it exceeds this many
# lines, then reject the layout.
max_lines_hwrap = 2
# What style line endings to use in the output.
line_ending = "unix"
# Format command names consistently as 'lower' or 'upper' case
command_case = "canonical"
# Format keywords consistently as 'lower' or 'upper' case
keyword_case = "unchanged"
# A list of command names which should always be wrapped
always_wrap = []
# If true, the argument lists which are known to be sortable will be sorted
# lexicographicall
enable_sort = True
# If true, the parsers may infer whether or not an argument list is sortable
# (without annotation).
autosort = False
# By default, if cmake-format cannot successfully fit everything into the
# desired linewidth it will apply the last, most agressive attempt that it
# made. If this flag is True, however, cmake-format will print error, exit
# with non-zero status code, and write-out nothing
require_valid_layout = False
# A dictionary mapping layout nodes to a list of wrap decisions. See the
# documentation for more information.
layout_passes = {}
# ------------------------------------------------
# Options affecting comment reflow and formatting.
# ------------------------------------------------
with section("markup"):
# What character to use for bulleted lists
bullet_char = "*"
# What character to use as punctuation after numerals in an enumerated list
enum_char = "."
# If comment markup is enabled, don't reflow the first comment block in each
# listfile. Use this to preserve formatting of your copyright/license
# statements.
first_comment_is_literal = True
# If comment markup is enabled, don't reflow any comment block which matches
# this (regex) pattern. Default is `None` (disabled).
literal_comment_pattern = None
# Regular expression to match preformat fences in comments
# default=r'^\s*([`~]{3}[`~]*)(.*)$'
fence_pattern = "^\\s*([`~]{3}[`~]*)(.*)$"
# Regular expression to match rulers in comments
# default=r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'
ruler_pattern = "^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$"
# If a comment line matches starts with this pattern then it is explicitly a
# trailing comment for the preceeding argument. Default is '#<'
explicit_trailing_pattern = "#<"
# If a comment line starts with at least this many consecutive hash
# characters, then don't lstrip() them off. This allows for lazy hash rulers
# where the first hash char is not separated by space
hashruler_min_length = 10
# If true, then insert a space between the first hash char and remaining hash
# chars in a hash ruler, and normalize its length to fill the column
canonicalize_hashrulers = True
# enable comment markup parsing and reflow
enable_markup = True
# ----------------------------
# Options affecting the linter
# ----------------------------
with section("lint"):
# a list of lint codes to disable
disabled_codes = []
# regular expression pattern describing valid function names
function_pattern = "[0-9a-z_]+"
# regular expression pattern describing valid macro names
macro_pattern = "[0-9A-Z_]+"
# regular expression pattern describing valid names for variables with global
# scope
global_var_pattern = "[0-9A-Z][0-9A-Z_]+"
# regular expression pattern describing valid names for variables with global
# scope (but internal semantic)
internal_var_pattern = "_[0-9A-Z][0-9A-Z_]+"
# regular expression pattern describing valid names for variables with local
# scope
local_var_pattern = "[0-9a-z_]+"
# regular expression pattern describing valid names for privatedirectory
# variables
private_var_pattern = "_[0-9a-z_]+"
# regular expression pattern describing valid names for publicdirectory
# variables
public_var_pattern = "[0-9A-Z][0-9A-Z_]+"
# regular expression pattern describing valid names for keywords used in
# functions or macros
keyword_pattern = "[0-9A-Z_]+"
# In the heuristic for C0201, how many conditionals to match within a loop in
# before considering the loop a parser.
max_conditionals_custom_parser = 2
# Require at least this many newlines between statements
min_statement_spacing = 1
# Require no more than this many newlines between statements
max_statement_spacing = 1
max_returns = 6
max_branches = 12
max_arguments = 5
max_localvars = 15
max_statements = 50
# -------------------------------
# Options effecting file encoding
# -------------------------------
with section("encode"):
# If true, emit the unicode byte-order mark (BOM) at the start of the file
emit_byteorder_mark = False
# Specify the encoding of the input file. Defaults to utf-8
input_encoding = "utf-8"
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
# only claims to support utf-8 so be careful when using anything else
output_encoding = "utf-8"
# -------------------------------------
# Miscellaneous configurations options.
# -------------------------------------
with section("misc"):
# A dictionary containing any per-command configuration overrides. Currently
# only `command_case` is supported.
per_command = {}

Просмотреть файл

@ -5,22 +5,26 @@ cmake_minimum_required(VERSION 3.11)
set(CCF_DIR ${CMAKE_CURRENT_SOURCE_DIR})
include(${CCF_DIR}/cmake/preproject.cmake)
project(ccf
project(
ccf
VERSION 0.6
LANGUAGES C CXX)
LANGUAGES C CXX
)
set(TESTS_SUFFIX $ENV{TESTS_SUFFIX})
message(STATUS "Setting TESTS_SUFFIX on performance tests to '${TESTS_SUFFIX}'")
set(ENV{BETTER_EXCEPTIONS} 1)
# Set the default install prefix for CCF. Users may override this value
# with the cmake command. For example:
# Set the default install prefix for CCF. Users may override this value with the
# cmake command. For example:
#
# $ cmake -DCMAKE_INSTALL_PREFIX=/opt/myplace ..
# $ cmake -DCMAKE_INSTALL_PREFIX=/opt/myplace ..
#
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX
"/opt/ccf/ccf-${PROJECT_VERSION}" CACHE PATH "Default install prefix" FORCE)
"/opt/ccf/ccf-${PROJECT_VERSION}"
CACHE PATH "Default install prefix" FORCE
)
endif()
message(STATUS "CMAKE_INSTALL_PREFIX is '${CMAKE_INSTALL_PREFIX}'")
@ -30,395 +34,375 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common.cmake)
option(BUILD_TESTS "Build tests" ON)
option(BUILD_SMALLBANK "Build SmallBank sample app and clients" ON)
# TODO: remove once FTCP support is disabled
# MemberClient executable
# TODO: remove once FTCP support is disabled MemberClient executable
add_executable(memberclient src/clients/memberclient.cpp)
use_client_mbedtls(memberclient)
target_link_libraries(memberclient PRIVATE
${CMAKE_THREAD_LIBS_INIT}
ccfcrypto.host
secp256k1.host
http_parser.host
target_link_libraries(
memberclient PRIVATE ${CMAKE_THREAD_LIBS_INIT} ccfcrypto.host secp256k1.host
http_parser.host
)
add_dependencies(memberclient flatbuffers)
# TODO: remove once FTCP support is disabled
# Logging Client executable
# TODO: remove once FTCP support is disabled Logging Client executable
add_executable(logging_client src/clients/logging_client.cpp)
use_client_mbedtls(logging_client)
target_link_libraries(logging_client PRIVATE
${CMAKE_THREAD_LIBS_INIT}
http_parser.host
target_link_libraries(
logging_client PRIVATE ${CMAKE_THREAD_LIBS_INIT} http_parser.host
)
# Build common library for CCF enclaves
add_custom_target(ccf ALL)
if ("sgx" IN_LIST TARGET)
if("sgx" IN_LIST TARGET)
# enclave version
add_library(ccf.enclave STATIC
${CCF_DIR}/src/enclave/main.cpp
${CCF_DIR}/src/enclave/thread_local.cpp
add_library(
ccf.enclave STATIC
${CCF_DIR}/src/enclave/main.cpp ${CCF_DIR}/src/enclave/thread_local.cpp
${CCF_GENERATED_DIR}/ccf_t.cpp
)
target_compile_definitions(ccf.enclave PUBLIC
INSIDE_ENCLAVE
_LIBCPP_HAS_THREAD_API_PTHREAD
target_compile_definitions(
ccf.enclave PUBLIC INSIDE_ENCLAVE _LIBCPP_HAS_THREAD_API_PTHREAD
)
target_compile_options(ccf.enclave PUBLIC
-nostdinc
-nostdinc++
)
target_compile_options(ccf.enclave PUBLIC -nostdinc -nostdinc++)
target_include_directories(ccf.enclave SYSTEM PUBLIC
${EVERCRYPT_INC}
${CCF_GENERATED_DIR}
target_include_directories(
ccf.enclave SYSTEM PUBLIC ${EVERCRYPT_INC} ${CCF_GENERATED_DIR}
)
add_dependencies(ccf.enclave flatbuffers)
if (PBFT)
target_link_libraries(ccf.enclave PUBLIC
libbyz.enclave
)
if(PBFT)
target_link_libraries(ccf.enclave PUBLIC libbyz.enclave)
endif()
target_link_libraries(ccf.enclave PUBLIC
openenclave::oeenclave
openenclave::oelibcxx
openenclave::oelibc
ccfcrypto.enclave
evercrypt.enclave
http_parser.enclave
lua.enclave
secp256k1.enclave
target_link_libraries(
ccf.enclave
PUBLIC openenclave::oeenclave
openenclave::oelibcxx
openenclave::oelibc
ccfcrypto.enclave
evercrypt.enclave
http_parser.enclave
lua.enclave
secp256k1.enclave
)
set_property(TARGET ccf.enclave
PROPERTY POSITION_INDEPENDENT_CODE ON
)
set_property(TARGET ccf.enclave PROPERTY POSITION_INDEPENDENT_CODE ON)
enable_quote_code(ccf.enclave)
install(
TARGETS ccf.enclave
DESTINATION lib
)
install(TARGETS ccf.enclave DESTINATION lib)
add_dependencies(ccf ccf.enclave)
endif()
if ("virtual" IN_LIST TARGET)
if("virtual" IN_LIST TARGET)
# virtual version
add_library(ccf.virtual STATIC
${CCF_DIR}/src/enclave/main.cpp
${CCF_DIR}/src/enclave/thread_local.cpp
add_library(
ccf.virtual STATIC ${CCF_DIR}/src/enclave/main.cpp
${CCF_DIR}/src/enclave/thread_local.cpp
)
target_compile_definitions(ccf.virtual PUBLIC
INSIDE_ENCLAVE
VIRTUAL_ENCLAVE
_LIBCPP_HAS_THREAD_API_PTHREAD
target_compile_definitions(
ccf.virtual PUBLIC INSIDE_ENCLAVE VIRTUAL_ENCLAVE
_LIBCPP_HAS_THREAD_API_PTHREAD
)
target_compile_options(ccf.virtual PUBLIC
-stdlib=libc++
)
target_compile_options(ccf.virtual PUBLIC -stdlib=libc++)
target_include_directories(ccf.virtual SYSTEM PUBLIC
${EVERCRYPT_INC}
${CCF_GENERATED_DIR}
target_include_directories(
ccf.virtual SYSTEM PUBLIC ${EVERCRYPT_INC} ${CCF_GENERATED_DIR}
)
add_dependencies(ccf.virtual flatbuffers)
if (PBFT)
target_link_libraries(ccf.virtual PUBLIC
libbyz.host
)
if(PBFT)
target_link_libraries(ccf.virtual PUBLIC libbyz.host)
endif()
target_link_libraries(ccf.virtual PUBLIC
-stdlib=libc++
-lc++
-lc++abi
ccfcrypto.host
evercrypt.host
http_parser.host
lua.host
secp256k1.host
${CMAKE_THREAD_LIBS_INIT}
target_link_libraries(
ccf.virtual
PUBLIC -stdlib=libc++
-lc++
-lc++abi
ccfcrypto.host
evercrypt.host
http_parser.host
lua.host
secp256k1.host
${CMAKE_THREAD_LIBS_INIT}
)
set_property(TARGET ccf.virtual
PROPERTY POSITION_INDEPENDENT_CODE ON
)
set_property(TARGET ccf.virtual PROPERTY POSITION_INDEPENDENT_CODE ON)
enable_coverage(ccf.virtual)
use_client_mbedtls(ccf.virtual)
add_san(ccf.virtual)
install(
TARGETS ccf.virtual
DESTINATION lib
)
install(TARGETS ccf.virtual DESTINATION lib)
add_dependencies(ccf ccf.virtual)
endif()
# Create patched alternative of library, to test code version changes
function(create_patched_enclave_lib name app_oe_conf_path enclave_sign_key_path)
set(enc_name ${name}.enclave)
if (TARGET ${enc_name})
if(TARGET ${enc_name})
set(patched_name ${name}.patched.enclave)
set(patched_lib_name lib${patched_name}.so)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${patched_lib_name}
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/lib${enc_name}.so ${CMAKE_CURRENT_BINARY_DIR}/${patched_lib_name}
COMMAND PYTHONPATH=${CCF_DIR}/tests:$ENV{PYTHONPATH} python3 patch_binary.py -p ${CMAKE_CURRENT_BINARY_DIR}/${patched_lib_name}
WORKING_DIRECTORY ${CCF_DIR}/tests
DEPENDS ${enc_name}
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${patched_lib_name}
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/lib${enc_name}.so
${CMAKE_CURRENT_BINARY_DIR}/${patched_lib_name}
COMMAND PYTHONPATH=${CCF_DIR}/tests:$ENV{PYTHONPATH} python3
patch_binary.py -p ${CMAKE_CURRENT_BINARY_DIR}/${patched_lib_name}
WORKING_DIRECTORY ${CCF_DIR}/tests
DEPENDS ${enc_name}
)
add_custom_target(${patched_name} ALL
add_custom_target(
${patched_name} ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${patched_lib_name}
)
sign_app_library(${patched_name} ${app_oe_conf_path} ${enclave_sign_key_path})
sign_app_library(
${patched_name} ${app_oe_conf_path} ${enclave_sign_key_path}
)
endif()
endfunction()
add_ccf_app(logging
SRCS
src/apps/logging/logging.cpp
src/apps/logging/stub_for_code_signing.cpp
add_ccf_app(
logging SRCS src/apps/logging/logging.cpp
src/apps/logging/stub_for_code_signing.cpp
)
sign_app_library(logging.enclave
${CMAKE_CURRENT_SOURCE_DIR}/src/apps/logging/oe_sign.conf
sign_app_library(
logging.enclave ${CMAKE_CURRENT_SOURCE_DIR}/src/apps/logging/oe_sign.conf
${CMAKE_CURRENT_SOURCE_DIR}/src/apps/sample_key.pem
)
create_patched_enclave_lib(logging
${CMAKE_CURRENT_SOURCE_DIR}/src/apps/logging/oe_sign.conf
create_patched_enclave_lib(
logging ${CMAKE_CURRENT_SOURCE_DIR}/src/apps/logging/oe_sign.conf
${CMAKE_CURRENT_SOURCE_DIR}/src/apps/sample_key.pem
)
set(OE_SIGN_PATH ${OE_BINDIR}/oesign)
if (BUILD_TESTS)
if(BUILD_TESTS)
enable_testing()
# Unit tests
add_unit_test(map_test
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/map_test.cpp)
add_unit_test(map_test ${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/map_test.cpp)
add_unit_test(json_schema
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/json_schema.cpp)
add_unit_test(
json_schema ${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/json_schema.cpp
)
add_unit_test(logger_json_test
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/logger_json_test.cpp)
add_unit_test(
logger_json_test
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/logger_json_test.cpp
)
add_unit_test(kv_test
${CMAKE_CURRENT_SOURCE_DIR}/src/kv/test/kv_test.cpp
add_unit_test(
kv_test ${CMAKE_CURRENT_SOURCE_DIR}/src/kv/test/kv_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/kv/test/kv_contention.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/kv/test/kv_serialisation.cpp)
${CMAKE_CURRENT_SOURCE_DIR}/src/kv/test/kv_serialisation.cpp
)
use_client_mbedtls(kv_test)
target_link_libraries(kv_test PRIVATE
${CMAKE_THREAD_LIBS_INIT}
secp256k1.host)
target_link_libraries(
kv_test PRIVATE ${CMAKE_THREAD_LIBS_INIT} secp256k1.host
)
add_unit_test(ds_test
add_unit_test(
ds_test
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/ringbuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/messaging.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/oversized.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/serializer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/hash.cpp)
target_link_libraries(ds_test PRIVATE
${CMAKE_THREAD_LIBS_INIT})
${CMAKE_CURRENT_SOURCE_DIR}/src/ds/test/hash.cpp
)
target_link_libraries(ds_test PRIVATE ${CMAKE_THREAD_LIBS_INIT})
add_unit_test(ledger_test
${CMAKE_CURRENT_SOURCE_DIR}/src/host/test/ledger.cpp)
add_unit_test(
ledger_test ${CMAKE_CURRENT_SOURCE_DIR}/src/host/test/ledger.cpp
)
if (NOT PBFT)
add_unit_test(raft_test
${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/raft/test/main.cpp)
target_link_libraries(raft_test PRIVATE
${CRYPTO_LIBRARY})
if(NOT PBFT)
add_unit_test(
raft_test ${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/raft/test/main.cpp
)
target_link_libraries(raft_test PRIVATE ${CRYPTO_LIBRARY})
add_unit_test(raft_enclave_test
${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/raft/test/enclave.cpp)
target_include_directories(raft_enclave_test PRIVATE
${CCFCRYPTO_INC})
target_link_libraries(raft_enclave_test PRIVATE
${CRYPTO_LIBRARY}
secp256k1.host)
add_unit_test(
raft_enclave_test
${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/raft/test/enclave.cpp
)
target_include_directories(raft_enclave_test PRIVATE ${CCFCRYPTO_INC})
target_link_libraries(
raft_enclave_test PRIVATE ${CRYPTO_LIBRARY} secp256k1.host
)
endif()
add_unit_test(crypto_test
${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/test/crypto.cpp)
target_include_directories(crypto_test PRIVATE
${CCFCRYPTO_INC})
target_link_libraries(crypto_test PRIVATE
${CRYPTO_LIBRARY})
add_unit_test(
crypto_test ${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/test/crypto.cpp
)
target_include_directories(crypto_test PRIVATE ${CCFCRYPTO_INC})
target_link_libraries(crypto_test PRIVATE ${CRYPTO_LIBRARY})
add_unit_test(history_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/history.cpp)
target_include_directories(history_test PRIVATE
${EVERCRYPT_INC})
target_link_libraries(history_test PRIVATE
${CRYPTO_LIBRARY}
evercrypt.host
secp256k1.host)
add_unit_test(
history_test ${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/history.cpp
)
target_include_directories(history_test PRIVATE ${EVERCRYPT_INC})
target_link_libraries(
history_test PRIVATE ${CRYPTO_LIBRARY} evercrypt.host secp256k1.host
)
add_unit_test(encryptor_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/encryptor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/symmkey.cpp)
add_unit_test(
encryptor_test ${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/encryptor.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/crypto/symmkey.cpp
)
use_client_mbedtls(encryptor_test)
target_link_libraries(encryptor_test PRIVATE
secp256k1.host)
target_link_libraries(encryptor_test PRIVATE secp256k1.host)
add_unit_test(msgpack_serialization_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/msgpack_serialization.cpp)
add_unit_test(
msgpack_serialization_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/msgpack_serialization.cpp
)
add_unit_test(tls_test
${CMAKE_CURRENT_SOURCE_DIR}/src/tls/test/main.cpp)
target_link_libraries(tls_test PRIVATE
${CMAKE_THREAD_LIBS_INIT}
secp256k1.host)
add_unit_test(tls_test ${CMAKE_CURRENT_SOURCE_DIR}/src/tls/test/main.cpp)
target_link_libraries(
tls_test PRIVATE ${CMAKE_THREAD_LIBS_INIT} secp256k1.host
)
add_unit_test(keyexchange_test
${CMAKE_CURRENT_SOURCE_DIR}/src/tls/test/keyexchange.cpp)
add_unit_test(
keyexchange_test ${CMAKE_CURRENT_SOURCE_DIR}/src/tls/test/keyexchange.cpp
)
use_client_mbedtls(keyexchange_test)
target_link_libraries(keyexchange_test PRIVATE
secp256k1.host)
target_link_libraries(keyexchange_test PRIVATE secp256k1.host)
add_unit_test(channels_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/channels.cpp)
add_unit_test(
channels_test ${CMAKE_CURRENT_SOURCE_DIR}/src/node/test/channels.cpp
)
use_client_mbedtls(channels_test)
target_link_libraries(channels_test PRIVATE secp256k1.host)
add_unit_test(http_test
${CMAKE_CURRENT_SOURCE_DIR}/src/enclave/test/http.cpp)
add_unit_test(http_test ${CMAKE_CURRENT_SOURCE_DIR}/src/enclave/test/http.cpp)
target_link_libraries(http_test PRIVATE http_parser.host)
add_unit_test(frontend_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/rpc/test/frontend_test.cpp)
target_link_libraries(frontend_test PRIVATE
${CMAKE_THREAD_LIBS_INIT}
evercrypt.host
lua.host
secp256k1.host
add_unit_test(
frontend_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/rpc/test/frontend_test.cpp
)
target_link_libraries(
frontend_test PRIVATE ${CMAKE_THREAD_LIBS_INIT} evercrypt.host lua.host
secp256k1.host
)
if(NOT PBFT)
add_unit_test(
membervoting_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/rpc/test/membervoting_test.cpp
)
target_link_libraries(
membervoting_test PRIVATE ${CMAKE_THREAD_LIBS_INIT} evercrypt.host
lua.host secp256k1.host
)
if (NOT PBFT)
add_unit_test(membervoting_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/rpc/test/membervoting_test.cpp)
target_link_libraries(membervoting_test PRIVATE
${CMAKE_THREAD_LIBS_INIT}
evercrypt.host
lua.host
secp256k1.host)
add_unit_test(
nodefrontend_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/rpc/test/nodefrontend_test.cpp
)
target_link_libraries(
nodefrontend_test PRIVATE ${CMAKE_THREAD_LIBS_INIT} evercrypt.host
lua.host secp256k1.host
)
add_unit_test(nodefrontend_test
${CMAKE_CURRENT_SOURCE_DIR}/src/node/rpc/test/nodefrontend_test.cpp)
target_link_libraries(nodefrontend_test PRIVATE
${CMAKE_THREAD_LIBS_INIT}
evercrypt.host
lua.host
secp256k1.host)
if (NOT ENV{RUNTIME_CONFIG_DIR})
set_tests_properties(membervoting_test PROPERTIES ENVIRONMENT RUNTIME_CONFIG_DIR=${CMAKE_SOURCE_DIR}/src/runtime_config)
if(NOT ENV{RUNTIME_CONFIG_DIR})
set_tests_properties(
membervoting_test
PROPERTIES ENVIRONMENT
RUNTIME_CONFIG_DIR=${CMAKE_SOURCE_DIR}/src/runtime_config
)
endif()
add_unit_test(luageneric_test
add_unit_test(
luageneric_test
${CMAKE_CURRENT_SOURCE_DIR}/src/apps/luageneric/test/luageneric_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/apps/luageneric/luageneric.cpp)
target_include_directories(luageneric_test PRIVATE
${LUA_DIR})
target_link_libraries(luageneric_test PRIVATE
lua.host
secp256k1.host)
${CMAKE_CURRENT_SOURCE_DIR}/src/apps/luageneric/luageneric.cpp
)
target_include_directories(luageneric_test PRIVATE ${LUA_DIR})
target_link_libraries(luageneric_test PRIVATE lua.host secp256k1.host)
endif()
add_unit_test(lua_test
${CMAKE_CURRENT_SOURCE_DIR}/src/luainterp/test/lua_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/luainterp/test/luakv.cpp)
target_include_directories(lua_test PRIVATE
${LUA_DIR})
target_link_libraries(lua_test PRIVATE
lua.host)
add_unit_test(
lua_test ${CMAKE_CURRENT_SOURCE_DIR}/src/luainterp/test/lua_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/luainterp/test/luakv.cpp
)
target_include_directories(lua_test PRIVATE ${LUA_DIR})
target_link_libraries(lua_test PRIVATE lua.host)
## Picobench benchmarks
add_picobench(map_bench
SRCS src/ds/test/map_bench.cpp
)
add_picobench(logger_bench
SRCS src/ds/test/logger_bench.cpp
)
add_picobench(json_bench
SRCS src/ds/test/json_bench.cpp
)
add_picobench(ringbuffer_bench
SRCS src/ds/test/ringbuffer_bench.cpp
)
add_picobench(tls_bench
# Picobench benchmarks
add_picobench(map_bench SRCS src/ds/test/map_bench.cpp)
add_picobench(logger_bench SRCS src/ds/test/logger_bench.cpp)
add_picobench(json_bench SRCS src/ds/test/json_bench.cpp)
add_picobench(ringbuffer_bench SRCS src/ds/test/ringbuffer_bench.cpp)
add_picobench(
tls_bench
SRCS src/tls/test/bench.cpp
LINK_LIBS secp256k1.host
)
add_picobench(merkle_bench
add_picobench(
merkle_bench
SRCS src/node/test/merkle_bench.cpp
LINK_LIBS ccfcrypto.host evercrypt.host secp256k1.host
INCLUDE_DIRS ${EVERCRYPT_INC}
)
add_picobench(history_bench
add_picobench(
history_bench
SRCS src/node/test/history_bench.cpp
LINK_LIBS ccfcrypto.host evercrypt.host secp256k1.host
INCLUDE_DIRS ${EVERCRYPT_INC}
)
add_picobench(kv_bench
SRCS src/kv/test/kv_bench.cpp src/crypto/symmkey.cpp
)
add_picobench(kv_bench SRCS src/kv/test/kv_bench.cpp src/crypto/symmkey.cpp)
# Merkle Tree memory test
add_executable(merkle_mem src/node/test/merkle_mem.cpp)
target_link_libraries(merkle_mem PRIVATE
ccfcrypto.host
evercrypt.host
secp256k1.host
${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(
merkle_mem PRIVATE ccfcrypto.host evercrypt.host secp256k1.host
${CMAKE_THREAD_LIBS_INIT}
)
use_client_mbedtls(merkle_mem)
target_include_directories(merkle_mem PRIVATE
${EVERCRYPT_INC}
src)
target_include_directories(merkle_mem PRIVATE ${EVERCRYPT_INC} src)
add_dependencies(merkle_mem flatbuffers)
if (NOT PBFT)
if(NOT PBFT)
# Raft driver and scenario test
add_executable(raft_driver
${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/raft/test/driver.cpp)
add_executable(
raft_driver
${CMAKE_CURRENT_SOURCE_DIR}/src/consensus/raft/test/driver.cpp
)
use_client_mbedtls(raft_driver)
target_include_directories(raft_driver PRIVATE
src/raft)
target_include_directories(raft_driver PRIVATE src/raft)
add_dependencies(raft_driver flatbuffers)
add_test(
NAME raft_scenario_test
COMMAND
${PYTHON} ${CMAKE_SOURCE_DIR}/tests/raft_scenarios_runner.py ./raft_driver
${CMAKE_SOURCE_DIR}/tests/raft_scenarios ${CMAKE_SOURCE_DIR})
${PYTHON} ${CMAKE_SOURCE_DIR}/tests/raft_scenarios_runner.py
./raft_driver ${CMAKE_SOURCE_DIR}/tests/raft_scenarios
${CMAKE_SOURCE_DIR}
)
set_property(TEST raft_scenario_test PROPERTY LABELS raft_scenario)
## Storing signed votes test
# Storing signed votes test
add_e2e_test(
NAME voting_history_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/votinghistory.py)
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/votinghistory.py
)
# TODO: Sends an ACK via C++ memberclient, which must be signed. # Member client end to end tests
# ACK should be sent from Python, AND HTTP memberclient should sign
if (NOT HTTP)
# TODO: Sends an ACK via C++ memberclient, which must be signed. #
# Member client end to end tests ACK should be sent from Python, AND HTTP
# memberclient should sign
if(NOT HTTP)
# Member client end to end tests
add_e2e_test(
NAME member_client_test
@ -426,94 +410,92 @@ if (BUILD_TESTS)
)
endif()
## Logging client end to end test
# Logging client end to end test
add_e2e_test(
NAME logging_client_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/loggingclient.py
)
## Lua sample app (tx regulator) end to end test
# Lua sample app (tx regulator) end to end test
add_e2e_test(
NAME lua_txregulator_test
PYTHON_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/samples/apps/txregulator/tests/txregulatorclient.py
PYTHON_SCRIPT
${CMAKE_CURRENT_SOURCE_DIR}/samples/apps/txregulator/tests/txregulatorclient.py
ADDITIONAL_ARGS
--app-script ${CMAKE_CURRENT_SOURCE_DIR}/samples/apps/txregulator/app/txregulator.lua
--datafile ${CMAKE_CURRENT_SOURCE_DIR}/samples/apps/txregulator/dataset/sample_data.csv)
## Receipts end to end test
add_e2e_test(
NAME receipts_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/receipts.py
--app-script
${CMAKE_CURRENT_SOURCE_DIR}/samples/apps/txregulator/app/txregulator.lua
--datafile
${CMAKE_CURRENT_SOURCE_DIR}/samples/apps/txregulator/dataset/sample_data.csv
)
if (QUOTES_ENABLED)
# Receipts end to end test
add_e2e_test(
NAME receipts_test PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/receipts.py
)
if(QUOTES_ENABLED)
add_e2e_test(
NAME governance_tests
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/governance.py
ADDITIONAL_ARGS
--oesign ${OE_SIGN_PATH}
ADDITIONAL_ARGS --oesign ${OE_SIGN_PATH}
)
endif()
add_e2e_test(
NAME recovery_tests
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/recovery.py
ADDITIONAL_ARGS
${RECOVERY_ARGS}
ADDITIONAL_ARGS ${RECOVERY_ARGS}
)
add_e2e_test(
NAME test_suite
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_suite.py
IS_SUITE TRUE
ADDITIONAL_ARGS
--test-duration 150
--enforce-reqs
ADDITIONAL_ARGS --test-duration 150 --enforce-reqs
)
add_e2e_test(
NAME lua_end_to_end_batched
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_batched.py
ADDITIONAL_ARGS
--app-script ${CMAKE_SOURCE_DIR}/src/apps/batched/batched.lua)
ADDITIONAL_ARGS --app-script
${CMAKE_SOURCE_DIR}/src/apps/batched/batched.lua
)
add_e2e_test(
NAME js_end_to_end_logging
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_logging.py
ADDITIONAL_ARGS
--js-app-script ${CMAKE_SOURCE_DIR}/src/apps/logging/loggingjs.lua
ADDITIONAL_ARGS --js-app-script
${CMAKE_SOURCE_DIR}/src/apps/logging/loggingjs.lua
)
add_e2e_test(
NAME lua_end_to_end_logging
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_logging.py
ADDITIONAL_ARGS
--app-script ${CMAKE_SOURCE_DIR}/src/apps/logging/logging.lua
ADDITIONAL_ARGS --app-script
${CMAKE_SOURCE_DIR}/src/apps/logging/logging.lua
)
add_e2e_test(
NAME end_to_end_scenario
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/e2e_scenarios.py
ADDITIONAL_ARGS
--scenario ${CMAKE_SOURCE_DIR}/tests/simple_logging_scenario.json
ADDITIONAL_ARGS --scenario
${CMAKE_SOURCE_DIR}/tests/simple_logging_scenario.json
)
if (NOT SAN)
if(NOT SAN)
add_e2e_test(
NAME connections
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/connections.py
NAME connections PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/connections.py
)
endif()
add_e2e_test(
NAME schema_tests
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/schema.py
ADDITIONAL_ARGS
-p liblogging
--schema-dir ${CMAKE_SOURCE_DIR}/sphinx/source/schemas
ADDITIONAL_ARGS -p liblogging --schema-dir
${CMAKE_SOURCE_DIR}/sphinx/source/schemas
)
if (QUOTES_ENABLED)
if(QUOTES_ENABLED)
add_e2e_test(
NAME reconfiguration_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/reconfiguration.py
@ -523,12 +505,15 @@ if (BUILD_TESTS)
NAME code_update_test
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/code_update.py
ADDITIONAL_ARGS
--oesign ${OE_SIGN_PATH}
# TODO: This test spins up many nodes that go through the join protocol
# Since oe_verify_report can take quite a long time to execute (~2s)
# and trigger Raft elections, the election timeout should stay high
# until https://github.com/microsoft/CCF/issues/480 is fixed
--election-timeout 10000
--oesign
${OE_SIGN_PATH}
# TODO: This test spins up many nodes that go through the join
# protocol Since oe_verify_report can take quite a long time to
# execute (~2s) and trigger Raft elections, the election timeout
# should stay high until https://github.com/microsoft/CCF/issues/480
# is fixed
--election-timeout
10000
)
endif()
@ -537,7 +522,7 @@ if (BUILD_TESTS)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/pbft.cmake)
endif()
if (BUILD_SMALLBANK)
if(BUILD_SMALLBANK)
include(${CMAKE_CURRENT_SOURCE_DIR}/samples/apps/smallbank/smallbank.cmake)
endif()
@ -550,11 +535,10 @@ if (BUILD_TESTS)
add_e2e_test(
NAME election_tests
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/election.py
ADDITIONAL_ARGS
--election-timeout 2000
ADDITIONAL_ARGS --election-timeout 2000
)
if (NOT PBFT)
if(NOT PBFT)
# Logging scenario perf test
add_perf_test(
NAME logging_scenario_perf_test
@ -562,14 +546,18 @@ if (BUILD_TESTS)
CLIENT_BIN ./scenario_perf_client
LABEL log_scenario
ADDITIONAL_ARGS
--package liblogging
--scenario-file ${CMAKE_CURRENT_LIST_DIR}/tests/perf_logging_scenario_100txs.json
--max-writes-ahead 1000
--repetitions 1000
--package
liblogging
--scenario-file
${CMAKE_CURRENT_LIST_DIR}/tests/perf_logging_scenario_100txs.json
--max-writes-ahead
1000
--repetitions
1000
)
endif()
if (EXTENSIVE_TESTS)
if(EXTENSIVE_TESTS)
set_tests_properties(recovery_tests PROPERTIES TIMEOUT 2000)
endif()
endif()

Просмотреть файл

@ -7,10 +7,16 @@ find_library(MBEDTLS_LIBRARY mbedtls)
find_library(MBEDX509_LIBRARY mbedx509)
find_library(MBEDCRYPTO_LIBRARY mbedcrypto)
set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}")
set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}"
"${MBEDCRYPTO_LIBRARY}"
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MBEDTLS DEFAULT_MSG
MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
find_package_handle_standard_args(
MBEDTLS DEFAULT_MSG MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY
MBEDCRYPTO_LIBRARY
)
mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY)
mark_as_advanced(
MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY
)

Просмотреть файл

@ -4,32 +4,37 @@
set(ALLOWED_TARGETS "sgx;virtual")
set(IS_VALID_TARGET "FALSE")
foreach(REQUESTED_TARGET ${TARGET})
if (${REQUESTED_TARGET} IN_LIST ALLOWED_TARGETS)
if(${REQUESTED_TARGET} IN_LIST ALLOWED_TARGETS)
set(IS_VALID_TARGET "TRUE")
else()
message(FATAL_ERROR "${REQUESTED_TARGET} is not a valid target. Choose from: ${ALLOWED_TARGETS}")
message(
FATAL_ERROR
"${REQUESTED_TARGET} is not a valid target. Choose from: ${ALLOWED_TARGETS}"
)
endif()
endforeach()
if ((NOT ${IS_VALID_TARGET}))
message(FATAL_ERROR "Variable list 'TARGET' must include at least one supported target. Choose from: ${ALLOWED_TARGETS}")
if((NOT ${IS_VALID_TARGET}))
message(
FATAL_ERROR
"Variable list 'TARGET' must include at least one supported target. Choose from: ${ALLOWED_TARGETS}"
)
endif()
# Sign a built enclave library with oesign
function(sign_app_library name app_oe_conf_path enclave_sign_key_path)
if (TARGET ${name})
if(TARGET ${name})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.signed
COMMAND openenclave::oesign sign
-e ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so
-c ${app_oe_conf_path}
-k ${enclave_sign_key_path}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so
${app_oe_conf_path}
${enclave_sign_key_path}
COMMAND
openenclave::oesign sign -e ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so -c
${app_oe_conf_path} -k ${enclave_sign_key_path}
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so ${app_oe_conf_path}
${enclave_sign_key_path}
)
add_custom_target(${name}_signed ALL
add_custom_target(
${name}_signed ALL
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.signed
)
endif()
@ -37,29 +42,37 @@ endfunction()
# Util functions used by add_ccf_app and others
function(enable_quote_code name)
if (QUOTES_ENABLED)
if(QUOTES_ENABLED)
target_compile_definitions(${name} PUBLIC -DGET_QUOTE)
endif()
endfunction()
function(add_san name)
if (SAN)
target_compile_options(${name} PRIVATE
-fsanitize=undefined,address -fno-omit-frame-pointer -fno-sanitize-recover=all
-fno-sanitize=function -fsanitize-blacklist=${CCF_DIR}/src/ubsan.blacklist
if(SAN)
target_compile_options(
${name}
PRIVATE -fsanitize=undefined,address -fno-omit-frame-pointer
-fno-sanitize-recover=all -fno-sanitize=function
-fsanitize-blacklist=${CCF_DIR}/src/ubsan.blacklist
)
target_link_libraries(${name} PRIVATE
-fsanitize=undefined,address -fno-omit-frame-pointer -fno-sanitize-recover=all
-fno-sanitize=function -fsanitize-blacklist=${CCF_DIR}/src/ubsan.blacklist
target_link_libraries(
${name}
PRIVATE -fsanitize=undefined,address -fno-omit-frame-pointer
-fno-sanitize-recover=all -fno-sanitize=function
-fsanitize-blacklist=${CCF_DIR}/src/ubsan.blacklist
)
endif()
endfunction()
separate_arguments(COVERAGE_FLAGS UNIX_COMMAND "-fprofile-instr-generate -fcoverage-mapping")
separate_arguments(COVERAGE_LINK UNIX_COMMAND "-fprofile-instr-generate -fcoverage-mapping")
separate_arguments(
COVERAGE_FLAGS UNIX_COMMAND "-fprofile-instr-generate -fcoverage-mapping"
)
separate_arguments(
COVERAGE_LINK UNIX_COMMAND "-fprofile-instr-generate -fcoverage-mapping"
)
function(enable_coverage name)
if (COVERAGE)
if(COVERAGE)
target_compile_options(${name} PRIVATE ${COVERAGE_FLAGS})
target_link_libraries(${name} PRIVATE ${COVERAGE_LINK})
endif()
@ -71,51 +84,48 @@ function(use_client_mbedtls name)
endfunction()
function(use_oe_mbedtls name)
target_link_libraries(${name} PRIVATE
openenclave::oeenclave
openenclave::oelibcxx
openenclave::oelibc
target_link_libraries(
${name} PRIVATE openenclave::oeenclave openenclave::oelibcxx
openenclave::oelibc
)
endfunction()
if (NOT CCF_GENERATED_DIR)
if(NOT CCF_GENERATED_DIR)
set(CCF_GENERATED_DIR ${CCF_DIR}/generated)
endif()
add_custom_target(flatbuffers ALL
DEPENDS ${CCF_GENERATED_DIR}/frame_generated.h
add_custom_target(
flatbuffers ALL DEPENDS ${CCF_GENERATED_DIR}/frame_generated.h
)
# Enclave library wrapper
function(add_ccf_app name)
cmake_parse_arguments(PARSE_ARGV 1 PARSED_ARGS
""
""
cmake_parse_arguments(
PARSE_ARGV 1 PARSED_ARGS "" ""
"SRCS;INCLUDE_DIRS;LINK_LIBS_ENCLAVE;LINK_LIBS_VIRTUAL"
)
add_custom_target(${name} ALL)
if ("sgx" IN_LIST TARGET)
if("sgx" IN_LIST TARGET)
set(enc_name ${name}.enclave)
add_library(${enc_name} SHARED
${PARSED_ARGS_SRCS}
add_library(${enc_name} SHARED ${PARSED_ARGS_SRCS})
target_include_directories(
${enc_name} SYSTEM PRIVATE ${PARSED_ARGS_INCLUDE_DIRS}
)
target_include_directories(${enc_name} SYSTEM PRIVATE
${PARSED_ARGS_INCLUDE_DIRS}
)
target_link_libraries(${enc_name} PRIVATE
${PARSED_ARGS_LINK_LIBS_ENCLAVE}
# These oe libraries must be linked in correct order, so they are
# re-declared here
openenclave::oeenclave
openenclave::oecore
openenclave::oesyscall
ccf.enclave
target_link_libraries(
${enc_name}
PRIVATE ${PARSED_ARGS_LINK_LIBS_ENCLAVE}
# These oe libraries must be linked in correct order, so they are
# re-declared here
openenclave::oeenclave
openenclave::oecore
openenclave::oesyscall
ccf.enclave
)
set_property(TARGET ${enc_name} PROPERTY POSITION_INDEPENDENT_CODE ON)
@ -123,21 +133,18 @@ function(add_ccf_app name)
add_dependencies(${name} ${enc_name})
endif()
if ("virtual" IN_LIST TARGET)
## Build a virtual enclave, loaded as a shared library without OE
if("virtual" IN_LIST TARGET)
# Build a virtual enclave, loaded as a shared library without OE
set(virt_name ${name}.virtual)
add_library(${virt_name} SHARED
${PARSED_ARGS_SRCS}
add_library(${virt_name} SHARED ${PARSED_ARGS_SRCS})
target_include_directories(
${virt_name} SYSTEM PRIVATE ${PARSED_ARGS_INCLUDE_DIRS}
)
target_include_directories(${virt_name} SYSTEM PRIVATE
${PARSED_ARGS_INCLUDE_DIRS}
)
target_link_libraries(${virt_name} PRIVATE
${PARSED_ARGS_LINK_LIBS_VIRTUAL}
ccf.virtual
target_link_libraries(
${virt_name} PRIVATE ${PARSED_ARGS_LINK_LIBS_VIRTUAL} ccf.virtual
)
set_property(TARGET ${virt_name} PROPERTY POSITION_INDEPENDENT_CODE ON)
@ -148,4 +155,4 @@ function(add_ccf_app name)
add_dependencies(${name} ${virt_name})
endif()
endfunction()
endfunction()

Просмотреть файл

@ -4,10 +4,19 @@
set(CMAKE_MODULE_PATH "${CCF_DIR}/cmake;${CMAKE_MODULE_PATH}")
set(default_build_type "RelWithDebInfo")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(
STATUS
"Setting build type to '${default_build_type}' as none was specified."
)
set(CMAKE_BUILD_TYPE
"${default_build_type}"
CACHE STRING "Choose the type of build." FORCE
)
set_property(
CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel"
"RelWithDebInfo"
)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
@ -16,50 +25,60 @@ find_package(Threads REQUIRED)
set(PYTHON unbuffer python3)
set(SERVICE_IDENTITY_CURVE_CHOICE "secp384r1" CACHE STRING "One of secp384r1, ed25519, secp256k1_mbedtls, secp256k1_bitcoin")
if (${SERVICE_IDENTITY_CURVE_CHOICE} STREQUAL "secp384r1")
set(SERVICE_IDENTITY_CURVE_CHOICE
"secp384r1"
CACHE STRING
"One of secp384r1, ed25519, secp256k1_mbedtls, secp256k1_bitcoin"
)
if(${SERVICE_IDENTITY_CURVE_CHOICE} STREQUAL "secp384r1")
add_definitions(-DSERVICE_IDENTITY_CURVE_CHOICE_SECP384R1)
set(DEFAULT_PARTICIPANTS_CURVE "secp384r1")
elseif (${SERVICE_IDENTITY_CURVE_CHOICE} STREQUAL "ed25519")
elseif(${SERVICE_IDENTITY_CURVE_CHOICE} STREQUAL "ed25519")
add_definitions(-DSERVICE_IDENTITY_CURVE_CHOICE_ED25519)
set(DEFAULT_PARTICIPANTS_CURVE "ed25519")
elseif (${SERVICE_IDENTITY_CURVE_CHOICE} STREQUAL "secp256k1_mbedtls")
elseif(${SERVICE_IDENTITY_CURVE_CHOICE} STREQUAL "secp256k1_mbedtls")
add_definitions(-DSERVICE_IDENTITY_CURVE_CHOICE_SECP256K1_MBEDTLS)
set(DEFAULT_PARTICIPANTS_CURVE "secp256k1")
elseif (${SERVICE_IDENTITY_CURVE_CHOICE} STREQUAL "secp256k1_bitcoin")
elseif(${SERVICE_IDENTITY_CURVE_CHOICE} STREQUAL "secp256k1_bitcoin")
add_definitions(-DSERVICE_IDENTITY_CURVE_CHOICE_SECP256K1_BITCOIN)
set(DEFAULT_PARTICIPANTS_CURVE "secp256k1")
else()
message(FATAL_ERROR "Unsupported curve choice ${SERVICE_IDENTITY_CURVE_CHOICE}")
message(
FATAL_ERROR "Unsupported curve choice ${SERVICE_IDENTITY_CURVE_CHOICE}"
)
endif()
option (COLORED_OUTPUT "Always produce ANSI-colored output (Clang only)." TRUE)
option(COLORED_OUTPUT "Always produce ANSI-colored output (Clang only)." TRUE)
if (${COLORED_OUTPUT})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif()
if(${COLORED_OUTPUT})
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif()
endif()
option(VERBOSE_LOGGING "Enable verbose logging" OFF)
set(TEST_HOST_LOGGING_LEVEL "info")
if (VERBOSE_LOGGING)
if(VERBOSE_LOGGING)
add_definitions(-DVERBOSE_LOGGING)
set(TEST_HOST_LOGGING_LEVEL "debug")
endif()
option(NO_STRICT_TLS_CIPHERSUITES "Disable strict list of valid TLS ciphersuites" OFF)
if (NO_STRICT_TLS_CIPHERSUITES)
option(NO_STRICT_TLS_CIPHERSUITES
"Disable strict list of valid TLS ciphersuites" OFF
)
if(NO_STRICT_TLS_CIPHERSUITES)
add_definitions(-DNO_STRICT_TLS_CIPHERSUITES)
endif()
option(USE_NULL_ENCRYPTOR "Turn off encryption of ledger updates - debug only" OFF)
if (USE_NULL_ENCRYPTOR)
option(USE_NULL_ENCRYPTOR "Turn off encryption of ledger updates - debug only"
OFF
)
if(USE_NULL_ENCRYPTOR)
add_definitions(-DUSE_NULL_ENCRYPTOR)
endif()
option(HTTP "Enable HTTP Support" OFF)
if (HTTP)
if(HTTP)
add_definitions(-DHTTP)
endif()
@ -69,21 +88,26 @@ option(BUILD_END_TO_END_TESTS "Build end to end tests" ON)
option(COVERAGE "Enable coverage mapping" OFF)
option(PBFT "Enable PBFT" OFF)
if (PBFT)
if(PBFT)
add_definitions(-DPBFT)
add_definitions(-DUSE_NULL_ENCRYPTOR) # for now do not encrypt the ledger as the current implementation does not work for PBFT
add_definitions(
-DUSE_NULL_ENCRYPTOR
) # for now do not encrypt the ledger as the current implementation does not
# work for PBFT
set(PBFT_BUILD_ENCLAVE TRUE)
set(PBFT_BUILD_HOST TRUE)
set(PBFT_USE_LIBC TRUE)
endif()
option(DEBUG_CONFIG "Enable non-production options options to aid debugging" OFF)
if (DEBUG_CONFIG)
option(DEBUG_CONFIG "Enable non-production options options to aid debugging"
OFF
)
if(DEBUG_CONFIG)
add_definitions(-DDEBUG_CONFIG)
endif()
option(USE_NLJSON_KV_SERIALISER "Use nlohmann JSON as the KV serialiser" OFF)
if (USE_NLJSON_KV_SERIALISER)
if(USE_NLJSON_KV_SERIALISER)
add_definitions(-DUSE_NLJSON_KV_SERIALISER)
endif()
@ -92,78 +116,72 @@ enable_language(ASM)
set(CCF_GENERATED_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
add_custom_command(
OUTPUT ${CCF_GENERATED_DIR}/frame_generated.h
COMMAND flatc -o "${CCF_GENERATED_DIR}" --cpp ${CCF_DIR}/src/kv/frame.fbs
COMMAND flatc -o "${CCF_GENERATED_DIR}" --python ${CCF_DIR}/src/kv/frame.fbs
DEPENDS ${CCF_DIR}/src/kv/frame.fbs
OUTPUT ${CCF_GENERATED_DIR}/frame_generated.h
COMMAND flatc -o "${CCF_GENERATED_DIR}" --cpp ${CCF_DIR}/src/kv/frame.fbs
COMMAND flatc -o "${CCF_GENERATED_DIR}" --python ${CCF_DIR}/src/kv/frame.fbs
DEPENDS ${CCF_DIR}/src/kv/frame.fbs
)
install(
FILES
${CCF_GENERATED_DIR}/frame_generated.h
DESTINATION generated
)
install(FILES ${CCF_GENERATED_DIR}/frame_generated.h DESTINATION generated)
include_directories(${CCF_DIR}/src ${CCF_GENERATED_DIR})
include_directories(
${CCF_DIR}/src
${CCF_GENERATED_DIR}
SYSTEM ${CCF_DIR}/3rdparty ${CCF_DIR}/3rdparty/hacl-star
${CCF_DIR}/3rdparty/msgpack-c ${CCF_DIR}/3rdparty/flatbuffers/include
)
include_directories(
SYSTEM
${CCF_DIR}/3rdparty
${CCF_DIR}/3rdparty/hacl-star
${CCF_DIR}/3rdparty/msgpack-c
${CCF_DIR}/3rdparty/flatbuffers/include
set(TARGET
"sgx;virtual"
CACHE STRING "One of sgx, virtual, or 'sgx;virtual'"
)
set(TARGET "sgx;virtual" CACHE STRING "One of sgx, virtual, or 'sgx;virtual'")
find_package(MbedTLS REQUIRED)
set(CLIENT_MBEDTLS_INCLUDE_DIR "${MBEDTLS_INCLUDE_DIRS}")
set(CLIENT_MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARIES}")
find_package(OpenEnclave CONFIG REQUIRED)
# As well as pulling in openenclave:: targets, this sets variables which can be used
# for our edge cases (eg - for virtual libraries). These do not follow the standard
# naming patterns, for example use OE_INCLUDEDIR rather than OpenEnclave_INCLUDE_DIRS
# As well as pulling in openenclave:: targets, this sets variables which can be
# used for our edge cases (eg - for virtual libraries). These do not follow the
# standard naming patterns, for example use OE_INCLUDEDIR rather than
# OpenEnclave_INCLUDE_DIRS
add_custom_command(
COMMAND openenclave::oeedger8r ${CCF_DIR}/edl/ccf.edl --trusted --trusted-dir ${CCF_GENERATED_DIR} --untrusted --untrusted-dir ${CCF_GENERATED_DIR}
COMMAND mv ${CCF_GENERATED_DIR}/ccf_t.c ${CCF_GENERATED_DIR}/ccf_t.cpp
COMMAND mv ${CCF_GENERATED_DIR}/ccf_u.c ${CCF_GENERATED_DIR}/ccf_u.cpp
DEPENDS ${CCF_DIR}/edl/ccf.edl
OUTPUT ${CCF_GENERATED_DIR}/ccf_t.cpp ${CCF_GENERATED_DIR}/ccf_u.cpp
COMMENT "Generating code from EDL, and renaming to .cpp"
COMMAND openenclave::oeedger8r ${CCF_DIR}/edl/ccf.edl --trusted --trusted-dir
${CCF_GENERATED_DIR} --untrusted --untrusted-dir ${CCF_GENERATED_DIR}
COMMAND mv ${CCF_GENERATED_DIR}/ccf_t.c ${CCF_GENERATED_DIR}/ccf_t.cpp
COMMAND mv ${CCF_GENERATED_DIR}/ccf_u.c ${CCF_GENERATED_DIR}/ccf_u.cpp
DEPENDS ${CCF_DIR}/edl/ccf.edl
OUTPUT ${CCF_GENERATED_DIR}/ccf_t.cpp ${CCF_GENERATED_DIR}/ccf_u.cpp
COMMENT "Generating code from EDL, and renaming to .cpp"
)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ccf.cmake)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ccf.cmake DESTINATION cmake)
# Copy utilities from tests directory
set(CCF_UTILITIES tests.sh keygenerator.sh cimetrics_env.sh upload_pico_metrics.py scurl.sh)
set(CCF_UTILITIES tests.sh keygenerator.sh cimetrics_env.sh
upload_pico_metrics.py scurl.sh
)
foreach(UTILITY ${CCF_UTILITIES})
configure_file(${CCF_DIR}/tests/${UTILITY} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
configure_file(
${CCF_DIR}/tests/${UTILITY} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY
)
endforeach()
# Install specific utilities
install(
PROGRAMS ${CCF_DIR}/tests/scurl.sh ${CCF_DIR}/tests/keygenerator.sh
DESTINATION bin
install(PROGRAMS ${CCF_DIR}/tests/scurl.sh ${CCF_DIR}/tests/keygenerator.sh
DESTINATION bin
)
if ("sgx" IN_LIST TARGET)
if("sgx" IN_LIST TARGET)
# If OE was built with LINK_SGX=1, then we also need to link SGX
if (OE_SGX)
if(OE_SGX)
message(STATUS "Linking SGX")
set(SGX_LIBS
sgx_enclave_common
sgx_dcap_ql
sgx_urts
)
set(SGX_LIBS sgx_enclave_common sgx_dcap_ql sgx_urts)
if (NOT DISABLE_QUOTE_VERIFICATION)
if(NOT DISABLE_QUOTE_VERIFICATION)
set(QUOTES_ENABLED ON)
else()
set(TEST_IGNORE_QUOTE "--ignore-quote")
@ -172,68 +190,57 @@ if ("sgx" IN_LIST TARGET)
set(TEST_IGNORE_QUOTE "--ignore-quote")
endif()
else()
set(TEST_ENCLAVE_TYPE
-e virtual)
set(TEST_ENCLAVE_TYPE -e virtual)
endif()
# Test-only option to enable extensive tests
option(EXTENSIVE_TESTS "Enable extensive tests" OFF)
if (EXTENSIVE_TESTS)
set(RECOVERY_ARGS
--recovery 5
--msgs-per-recovery 10)
if(EXTENSIVE_TESTS)
set(RECOVERY_ARGS --recovery 5 --msgs-per-recovery 10)
else()
set(RECOVERY_ARGS
--recovery 2
--msgs-per-recovery 5)
set(RECOVERY_ARGS --recovery 2 --msgs-per-recovery 5)
endif()
# Lua module
set(LUA_DIR
${CCF_DIR}/3rdparty/lua)
set(LUA_DIR ${CCF_DIR}/3rdparty/lua)
set(LUA_SOURCES
${LUA_DIR}/lapi.c
${LUA_DIR}/lauxlib.c
${LUA_DIR}/lbaselib.c
${LUA_DIR}/lcode.c
${LUA_DIR}/lcorolib.c
${LUA_DIR}/lctype.c
${LUA_DIR}/ldebug.c
${LUA_DIR}/ldo.c
${LUA_DIR}/ldump.c
${LUA_DIR}/lfunc.c
${LUA_DIR}/lgc.c
${LUA_DIR}/llex.c
${LUA_DIR}/lmathlib.c
${LUA_DIR}/lmem.c
${LUA_DIR}/lobject.c
${LUA_DIR}/lopcodes.c
${LUA_DIR}/lparser.c
${LUA_DIR}/lstate.c
${LUA_DIR}/lstring.c
${LUA_DIR}/lstrlib.c
${LUA_DIR}/ltable.c
${LUA_DIR}/ltablib.c
${LUA_DIR}/ltm.c
${LUA_DIR}/lundump.c
${LUA_DIR}/lutf8lib.c
${LUA_DIR}/lvm.c
${LUA_DIR}/lzio.c)
${LUA_DIR}/lapi.c
${LUA_DIR}/lauxlib.c
${LUA_DIR}/lbaselib.c
${LUA_DIR}/lcode.c
${LUA_DIR}/lcorolib.c
${LUA_DIR}/lctype.c
${LUA_DIR}/ldebug.c
${LUA_DIR}/ldo.c
${LUA_DIR}/ldump.c
${LUA_DIR}/lfunc.c
${LUA_DIR}/lgc.c
${LUA_DIR}/llex.c
${LUA_DIR}/lmathlib.c
${LUA_DIR}/lmem.c
${LUA_DIR}/lobject.c
${LUA_DIR}/lopcodes.c
${LUA_DIR}/lparser.c
${LUA_DIR}/lstate.c
${LUA_DIR}/lstring.c
${LUA_DIR}/lstrlib.c
${LUA_DIR}/ltable.c
${LUA_DIR}/ltablib.c
${LUA_DIR}/ltm.c
${LUA_DIR}/lundump.c
${LUA_DIR}/lutf8lib.c
${LUA_DIR}/lvm.c
${LUA_DIR}/lzio.c
)
set(HTTP_PARSER_SOURCES
${CCF_DIR}/3rdparty/http-parser/http_parser.c)
set(HTTP_PARSER_SOURCES ${CCF_DIR}/3rdparty/http-parser/http_parser.c)
find_library(CRYPTO_LIBRARY crypto)
function(add_enclave_library_c name files)
add_library(${name} STATIC
${files})
target_compile_options(${name} PRIVATE
-nostdinc
)
target_link_libraries(${name} PRIVATE
openenclave::oelibc
)
add_library(${name} STATIC ${files})
target_compile_options(${name} PRIVATE -nostdinc)
target_link_libraries(${name} PRIVATE openenclave::oelibc)
set_property(TARGET ${name} PROPERTY POSITION_INDEPENDENT_CODE ON)
endfunction()
@ -243,120 +250,95 @@ include(${CCF_DIR}/cmake/quickjs.cmake)
find_package(CURL REQUIRED)
## Unit test wrapper
# Unit test wrapper
function(add_unit_test name)
add_executable(${name}
${CCF_DIR}/src/enclave/thread_local.cpp
${ARGN})
target_compile_options(${name} PRIVATE -stdlib=libc++)
target_include_directories(${name} PRIVATE
src
${CCFCRYPTO_INC})
add_executable(${name} ${CCF_DIR}/src/enclave/thread_local.cpp ${ARGN})
target_compile_options(${name} PRIVATE -stdlib=libc++)
target_include_directories(${name} PRIVATE src ${CCFCRYPTO_INC})
enable_coverage(${name})
target_link_libraries(${name} PRIVATE
-stdlib=libc++
-lc++
-lc++abi
ccfcrypto.host)
target_link_libraries(
${name} PRIVATE -stdlib=libc++ -lc++ -lc++abi ccfcrypto.host
)
add_dependencies(${name} flatbuffers)
use_client_mbedtls(${name})
add_san(${name})
add_test(
NAME ${name}
COMMAND ${CCF_DIR}/tests/unit_test_wrapper.sh ${name}
)
set_property(
TEST ${name}
APPEND
PROPERTY
LABELS unit_test
)
add_test(NAME ${name} COMMAND ${CCF_DIR}/tests/unit_test_wrapper.sh ${name})
set_property(TEST ${name} APPEND PROPERTY LABELS unit_test)
endfunction()
if ("sgx" IN_LIST TARGET)
if("sgx" IN_LIST TARGET)
# Host Executable
add_executable(cchost
${CCF_DIR}/src/host/main.cpp
${CCF_GENERATED_DIR}/ccf_u.cpp)
use_client_mbedtls(cchost)
target_include_directories(cchost PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
add_executable(
cchost ${CCF_DIR}/src/host/main.cpp ${CCF_GENERATED_DIR}/ccf_u.cpp
)
use_client_mbedtls(cchost)
target_include_directories(cchost PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
add_san(cchost)
target_link_libraries(cchost PRIVATE
uv
${SGX_LIBS}
${CRYPTO_LIBRARY}
${CMAKE_DL_LIBS}
${CMAKE_THREAD_LIBS_INIT}
openenclave::oehostapp
ccfcrypto.host
evercrypt.host
CURL::libcurl
target_link_libraries(
cchost
PRIVATE uv
${SGX_LIBS}
${CRYPTO_LIBRARY}
${CMAKE_DL_LIBS}
${CMAKE_THREAD_LIBS_INIT}
openenclave::oehostapp
ccfcrypto.host
evercrypt.host
CURL::libcurl
)
add_dependencies(cchost flatbuffers)
enable_quote_code(cchost)
install(
TARGETS cchost
DESTINATION bin
)
install(TARGETS cchost DESTINATION bin)
endif()
if ("virtual" IN_LIST TARGET)
if("virtual" IN_LIST TARGET)
# Virtual Host Executable
add_executable(cchost.virtual
${CCF_DIR}/src/host/main.cpp)
add_executable(cchost.virtual ${CCF_DIR}/src/host/main.cpp)
use_client_mbedtls(cchost.virtual)
target_compile_definitions(cchost.virtual PRIVATE -DVIRTUAL_ENCLAVE)
target_compile_options(cchost.virtual PRIVATE -stdlib=libc++)
target_include_directories(cchost.virtual PRIVATE
${CMAKE_CURRENT_BINARY_DIR}
${OE_INCLUDEDIR}
target_include_directories(
cchost.virtual PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${OE_INCLUDEDIR}
)
add_san(cchost.virtual)
enable_coverage(cchost.virtual)
target_link_libraries(cchost.virtual PRIVATE
uv
${CRYPTO_LIBRARY}
${CMAKE_DL_LIBS}
${CMAKE_THREAD_LIBS_INIT}
-lc++
-lc++abi
-stdlib=libc++
ccfcrypto.host
evercrypt.host
CURL::libcurl
target_link_libraries(
cchost.virtual
PRIVATE uv
${CRYPTO_LIBRARY}
${CMAKE_DL_LIBS}
${CMAKE_THREAD_LIBS_INIT}
-lc++
-lc++abi
-stdlib=libc++
ccfcrypto.host
evercrypt.host
CURL::libcurl
)
add_dependencies(cchost.virtual flatbuffers)
install(
TARGETS cchost.virtual
DESTINATION bin
)
install(TARGETS cchost.virtual DESTINATION bin)
endif()
# Client executable
add_executable(client ${CCF_DIR}/src/clients/client.cpp)
use_client_mbedtls(client)
target_link_libraries(client PRIVATE
${CMAKE_THREAD_LIBS_INIT}
secp256k1.host
http_parser.host
target_link_libraries(
client PRIVATE ${CMAKE_THREAD_LIBS_INIT} secp256k1.host http_parser.host
)
add_dependencies(client flatbuffers)
# Perf scenario executable
add_executable(scenario_perf_client
${CCF_DIR}/samples/perf_client/scenario_perf_client.cpp
add_executable(
scenario_perf_client ${CCF_DIR}/samples/perf_client/scenario_perf_client.cpp
)
use_client_mbedtls(scenario_perf_client)
target_link_libraries(scenario_perf_client PRIVATE
${CMAKE_THREAD_LIBS_INIT}
secp256k1.host
http_parser.host
target_link_libraries(
scenario_perf_client PRIVATE ${CMAKE_THREAD_LIBS_INIT} secp256k1.host
http_parser.host
)
add_dependencies(scenario_perf_client flatbuffers)
@ -376,7 +358,7 @@ add_library(http_parser.host "${HTTP_PARSER_SOURCES}")
set_property(TARGET http_parser.host PROPERTY POSITION_INDEPENDENT_CODE ON)
# Common test args for Python scripts starting up CCF networks
if (PBFT)
if(PBFT)
set(CONSENSUS_ARG "pbft")
else()
set(CONSENSUS_ARG "raft")
@ -385,142 +367,116 @@ endif()
set(WORKER_THREADS 0)
set(CCF_NETWORK_TEST_ARGS
${TEST_IGNORE_QUOTE}
${TEST_ENCLAVE_TYPE}
-l ${TEST_HOST_LOGGING_LEVEL}
-g ${CCF_DIR}/src/runtime_config/gov.lua
--consensus ${CONSENSUS_ARG}
--worker_threads ${WORKER_THREADS}
--default-curve ${DEFAULT_PARTICIPANTS_CURVE}
${TEST_IGNORE_QUOTE}
${TEST_ENCLAVE_TYPE}
-l
${TEST_HOST_LOGGING_LEVEL}
-g
${CCF_DIR}/src/runtime_config/gov.lua
--consensus
${CONSENSUS_ARG}
--worker_threads
${WORKER_THREADS}
--default-curve
${DEFAULT_PARTICIPANTS_CURVE}
)
# SNIPPET_START: Lua generic application
add_ccf_app(luageneric
SRCS ${CCF_DIR}/src/apps/luageneric/luageneric.cpp
)
sign_app_library(luageneric.enclave
${CCF_DIR}/src/apps/luageneric/oe_sign.conf
add_ccf_app(luageneric SRCS ${CCF_DIR}/src/apps/luageneric/luageneric.cpp)
sign_app_library(
luageneric.enclave ${CCF_DIR}/src/apps/luageneric/oe_sign.conf
${CCF_DIR}/src/apps/sample_key.pem
)
# SNIPPET_END: Lua generic application
add_ccf_app(jsgeneric
add_ccf_app(
jsgeneric
SRCS ${CCF_DIR}/src/apps/jsgeneric/jsgeneric.cpp
LINK_LIBS_ENCLAVE
quickjs.enclave
-lgcc
LINK_LIBS_VIRTUAL
quickjs.host
LINK_LIBS_ENCLAVE quickjs.enclave -lgcc
LINK_LIBS_VIRTUAL quickjs.host
)
sign_app_library(jsgeneric.enclave
${CCF_DIR}/src/apps/jsgeneric/oe_sign.conf
sign_app_library(
jsgeneric.enclave ${CCF_DIR}/src/apps/jsgeneric/oe_sign.conf
${CCF_DIR}/src/apps/sample_key.pem
)
# Samples
## Helper for building clients inheriting from perf_client
# Helper for building clients inheriting from perf_client
function(add_client_exe name)
cmake_parse_arguments(PARSE_ARGV 1 PARSED_ARGS
""
""
"SRCS;INCLUDE_DIRS;LINK_LIBS"
cmake_parse_arguments(
PARSE_ARGV 1 PARSED_ARGS "" "" "SRCS;INCLUDE_DIRS;LINK_LIBS"
)
add_executable(${name}
${PARSED_ARGS_SRCS}
)
add_executable(${name} ${PARSED_ARGS_SRCS})
target_link_libraries(${name} PRIVATE
${CMAKE_THREAD_LIBS_INIT}
)
target_link_libraries(${name} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
add_dependencies(${name} flatbuffers)
target_include_directories(${name} PRIVATE
${CCF_DIR}/samples/perf_client
${PARSED_ARGS_INCLUDE_DIRS}
target_include_directories(
${name} PRIVATE ${CCF_DIR}/samples/perf_client ${PARSED_ARGS_INCLUDE_DIRS}
)
use_client_mbedtls(${name})
endfunction()
## Helper for building end-to-end function tests using the python infrastructure
# Helper for building end-to-end function tests using the python infrastructure
function(add_e2e_test)
cmake_parse_arguments(PARSE_ARGV 0 PARSED_ARGS
""
"NAME;PYTHON_SCRIPT;IS_SUITE;CURL_CLIENT"
cmake_parse_arguments(
PARSE_ARGV 0 PARSED_ARGS "" "NAME;PYTHON_SCRIPT;IS_SUITE;CURL_CLIENT"
"ADDITIONAL_ARGS"
)
if (BUILD_END_TO_END_TESTS)
if(BUILD_END_TO_END_TESTS)
add_test(
NAME ${PARSED_ARGS_NAME}
COMMAND ${PYTHON} ${PARSED_ARGS_PYTHON_SCRIPT}
-b .
--label ${PARSED_ARGS_NAME}
${CCF_NETWORK_TEST_ARGS}
${PARSED_ARGS_ADDITIONAL_ARGS}
COMMAND
${PYTHON} ${PARSED_ARGS_PYTHON_SCRIPT} -b . --label ${PARSED_ARGS_NAME}
${CCF_NETWORK_TEST_ARGS} ${PARSED_ARGS_ADDITIONAL_ARGS}
)
## Make python test client framework importable
# Make python test client framework importable
set_property(
TEST ${PARSED_ARGS_NAME}
APPEND
TEST ${PARSED_ARGS_NAME} APPEND
PROPERTY
ENVIRONMENT "PYTHONPATH=${CCF_DIR}/tests:${CCF_GENERATED_DIR}:$ENV{PYTHONPATH}"
ENVIRONMENT
"PYTHONPATH=${CCF_DIR}/tests:${CCF_GENERATED_DIR}:$ENV{PYTHONPATH}"
)
if (${PARSED_ARGS_IS_SUITE})
set_property(
TEST ${PARSED_ARGS_NAME}
APPEND
PROPERTY
LABELS suite
)
if(${PARSED_ARGS_IS_SUITE})
set_property(TEST ${PARSED_ARGS_NAME} APPEND PROPERTY LABELS suite)
else()
set_property(
TEST ${PARSED_ARGS_NAME}
APPEND
PROPERTY
LABELS end_to_end
)
set_property(TEST ${PARSED_ARGS_NAME} APPEND PROPERTY LABELS end_to_end)
endif()
if (HTTP)
if(HTTP)
set_property(
TEST ${PARSED_ARGS_NAME}
APPEND
PROPERTY
ENVIRONMENT "HTTP=ON"
TEST ${PARSED_ARGS_NAME} APPEND PROPERTY ENVIRONMENT "HTTP=ON"
)
if (${PARSED_ARGS_CURL_CLIENT})
if(${PARSED_ARGS_CURL_CLIENT})
set_property(
TEST ${PARSED_ARGS_NAME}
APPEND
PROPERTY
ENVIRONMENT "CURL_CLIENT=ON"
TEST ${PARSED_ARGS_NAME} APPEND PROPERTY ENVIRONMENT "CURL_CLIENT=ON"
)
endif()
endif()
endif()
endfunction()
## Helper for building end-to-end perf tests using the python infrastucture
# Helper for building end-to-end perf tests using the python infrastucture
function(add_perf_test)
cmake_parse_arguments(PARSE_ARGV 0 PARSED_ARGS
""
"NAME;PYTHON_SCRIPT;CLIENT_BIN;VERIFICATION_FILE;LABEL;"
"ADDITIONAL_ARGS"
cmake_parse_arguments(
PARSE_ARGV 0 PARSED_ARGS ""
"NAME;PYTHON_SCRIPT;CLIENT_BIN;VERIFICATION_FILE;LABEL;" "ADDITIONAL_ARGS"
)
if (PARSED_ARGS_VERIFICATION_FILE)
if(PARSED_ARGS_VERIFICATION_FILE)
set(VERIFICATION_ARG "--verify ${PARSED_ARGS_VERIFICATION_FILE}")
else()
unset(VERIFICATION_ARG)
endif()
if (PARSED_ARGS_LABEL)
if(PARSED_ARGS_LABEL)
set(LABEL_ARG "${PARSED_ARGS_LABEL}_${TESTS_SUFFIX}^")
else()
set(LABEL_ARG "${PARSED_ARGS_NAME}_${TESTS_SUFFIX}^")
@ -528,73 +484,52 @@ function(add_perf_test)
add_test(
NAME ${PARSED_ARGS_NAME}
COMMAND ${PYTHON} ${PARSED_ARGS_PYTHON_SCRIPT}
-b .
-c ${PARSED_ARGS_CLIENT_BIN}
${CCF_NETWORK_TEST_ARGS}
--write-tx-times
${VERIFICATION_ARG}
--label ${LABEL_ARG}
${PARSED_ARGS_ADDITIONAL_ARGS}
${RELAX_COMMIT_TARGET}
COMMAND
${PYTHON} ${PARSED_ARGS_PYTHON_SCRIPT} -b . -c ${PARSED_ARGS_CLIENT_BIN}
${CCF_NETWORK_TEST_ARGS} --write-tx-times ${VERIFICATION_ARG} --label
${LABEL_ARG} ${PARSED_ARGS_ADDITIONAL_ARGS} ${RELAX_COMMIT_TARGET}
)
## Make python test client framework importable
# Make python test client framework importable
set_property(
TEST ${PARSED_ARGS_NAME}
APPEND
TEST ${PARSED_ARGS_NAME} APPEND
PROPERTY
ENVIRONMENT "PYTHONPATH=${CCF_DIR}/tests:${CMAKE_CURRENT_BINARY_DIR}:$ENV{PYTHONPATH}"
ENVIRONMENT
"PYTHONPATH=${CCF_DIR}/tests:${CMAKE_CURRENT_BINARY_DIR}:$ENV{PYTHONPATH}"
)
set_property(
TEST ${PARSED_ARGS_NAME}
APPEND
PROPERTY
LABELS perf
)
if (HTTP)
set_property(
TEST ${PARSED_ARGS_NAME}
APPEND
PROPERTY
ENVIRONMENT "HTTP=ON"
)
set_property(TEST ${PARSED_ARGS_NAME} APPEND PROPERTY LABELS perf)
if(HTTP)
set_property(TEST ${PARSED_ARGS_NAME} APPEND PROPERTY ENVIRONMENT "HTTP=ON")
endif()
endfunction()
## Picobench wrapper
function(add_picobench name)
cmake_parse_arguments(PARSE_ARGV 1 PARSED_ARGS
""
""
"SRCS;INCLUDE_DIRS;LINK_LIBS"
)
# Picobench wrapper
function(add_picobench name)
cmake_parse_arguments(
PARSE_ARGV 1 PARSED_ARGS "" "" "SRCS;INCLUDE_DIRS;LINK_LIBS"
)
add_executable(${name}
${PARSED_ARGS_SRCS}
)
add_executable(${name} ${PARSED_ARGS_SRCS})
target_include_directories(${name} PRIVATE
src
${PARSED_ARGS_INCLUDE_DIRS}
)
target_include_directories(${name} PRIVATE src ${PARSED_ARGS_INCLUDE_DIRS})
add_dependencies(${name} flatbuffers)
add_dependencies(${name} flatbuffers)
target_link_libraries(${name} PRIVATE
${CMAKE_THREAD_LIBS_INIT}
${PARSED_ARGS_LINK_LIBS}
)
target_link_libraries(
${name} PRIVATE ${CMAKE_THREAD_LIBS_INIT} ${PARSED_ARGS_LINK_LIBS}
)
# -Wall -Werror catches a number of warnings in picobench
target_include_directories(${name} SYSTEM PRIVATE 3rdparty)
# -Wall -Werror catches a number of warnings in picobench
target_include_directories(${name} SYSTEM PRIVATE 3rdparty)
add_test(
NAME ${name}
COMMAND bash -c "$<TARGET_FILE:${name}> --samples=1000 --out-fmt=csv --output=${name}.csv && cat ${name}.csv"
)
add_test(
NAME ${name}
COMMAND
bash -c
"$<TARGET_FILE:${name}> --samples=1000 --out-fmt=csv --output=${name}.csv && cat ${name}.csv"
)
use_client_mbedtls(${name})
use_client_mbedtls(${name})
set_property(TEST ${name} PROPERTY LABELS benchmark)
endfunction()
set_property(TEST ${name} PROPERTY LABELS benchmark)
endfunction()

Просмотреть файл

@ -2,38 +2,33 @@
# Licensed under the Apache 2.0 License.
# EverCrypt
set(EVERCRYPT_PREFIX ${CCF_DIR}/3rdparty/hacl-star/evercrypt CACHE PATH "Prefix to the EverCrypt library")
set(EVERCRYPT_PREFIX
${CCF_DIR}/3rdparty/hacl-star/evercrypt
CACHE PATH "Prefix to the EverCrypt library"
)
message(STATUS "Using EverCrypt at ${EVERCRYPT_PREFIX}")
set(EVERCRYPT_INC
${EVERCRYPT_PREFIX}
${EVERCRYPT_PREFIX}/kremlin
${EVERCRYPT_PREFIX}/kremlin/kremlib
set(EVERCRYPT_INC ${EVERCRYPT_PREFIX} ${EVERCRYPT_PREFIX}/kremlin
${EVERCRYPT_PREFIX}/kremlin/kremlib
)
file(GLOB_RECURSE EVERCRYPT_SRC "${EVERCRYPT_PREFIX}/*.[cS]")
# We need two versions of EverCrypt, because it depends on libc
if ("sgx" IN_LIST TARGET)
if("sgx" IN_LIST TARGET)
add_library(evercrypt.enclave STATIC ${EVERCRYPT_SRC})
target_compile_options(evercrypt.enclave PRIVATE
-Wno-implicit-function-declaration
-Wno-return-type
target_compile_options(
evercrypt.enclave PRIVATE -Wno-implicit-function-declaration
-Wno-return-type
)
target_compile_definitions(evercrypt.enclave PRIVATE
INSIDE_ENCLAVE KRML_HOST_PRINTF=oe_printf
KRML_HOST_EXIT=oe_abort
)
target_link_libraries(evercrypt.enclave PRIVATE
openenclave::oelibc
)
set_property(TARGET evercrypt.enclave
PROPERTY POSITION_INDEPENDENT_CODE ON
)
target_include_directories(evercrypt.enclave PRIVATE
${EVERCRYPT_INC}
target_compile_definitions(
evercrypt.enclave PRIVATE INSIDE_ENCLAVE KRML_HOST_PRINTF=oe_printf
KRML_HOST_EXIT=oe_abort
)
target_link_libraries(evercrypt.enclave PRIVATE openenclave::oelibc)
set_property(TARGET evercrypt.enclave PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(evercrypt.enclave PRIVATE ${EVERCRYPT_INC})
endif()
add_library(evercrypt.host STATIC ${EVERCRYPT_SRC})
@ -42,48 +37,36 @@ target_include_directories(evercrypt.host PRIVATE ${EVERCRYPT_INC})
# CCFCrypto, again two versions.
set(CCFCRYPTO_SRC
${CCF_DIR}/src/crypto/hash.cpp
${CCF_DIR}/src/crypto/symmkey.cpp
set(CCFCRYPTO_SRC ${CCF_DIR}/src/crypto/hash.cpp
${CCF_DIR}/src/crypto/symmkey.cpp
)
set(CCFCRYPTO_INC ${CCF_DIR}/src/crypto/ ${EVERCRYPT_INC})
if ("sgx" IN_LIST TARGET)
if("sgx" IN_LIST TARGET)
add_library(ccfcrypto.enclave STATIC ${CCFCRYPTO_SRC})
target_compile_definitions(ccfcrypto.enclave PRIVATE
INSIDE_ENCLAVE
_LIBCPP_HAS_THREAD_API_PTHREAD
target_compile_definitions(
ccfcrypto.enclave PRIVATE INSIDE_ENCLAVE _LIBCPP_HAS_THREAD_API_PTHREAD
)
target_compile_options(ccfcrypto.enclave PRIVATE -nostdinc++)
target_include_directories(ccfcrypto.enclave PRIVATE
${EVERCRYPT_INC}
)
target_link_libraries(ccfcrypto.enclave PRIVATE
-nostdlib -nodefaultlibs -nostartfiles
-Wl,--no-undefined
-Wl,-Bstatic,-Bsymbolic,--export-dynamic,-pie
evercrypt.enclave
target_include_directories(ccfcrypto.enclave PRIVATE ${EVERCRYPT_INC})
target_link_libraries(
ccfcrypto.enclave
PRIVATE -nostdlib -nodefaultlibs -nostartfiles -Wl,--no-undefined
-Wl,-Bstatic,-Bsymbolic,--export-dynamic,-pie evercrypt.enclave
)
use_oe_mbedtls(ccfcrypto.enclave)
set_property(TARGET ccfcrypto.enclave PROPERTY POSITION_INDEPENDENT_CODE ON)
install(
TARGETS ccfcrypto.enclave
DESTINATION lib
)
install(TARGETS ccfcrypto.enclave DESTINATION lib)
endif()
add_library(ccfcrypto.host STATIC
${CCFCRYPTO_SRC})
target_compile_definitions(ccfcrypto.host PRIVATE )
add_library(ccfcrypto.host STATIC ${CCFCRYPTO_SRC})
target_compile_definitions(ccfcrypto.host PRIVATE)
target_compile_options(ccfcrypto.host PRIVATE -stdlib=libc++)
target_include_directories(ccfcrypto.host PRIVATE ${EVERCRYPT_INC})
target_link_libraries(ccfcrypto.host PRIVATE evercrypt.host)
use_client_mbedtls(ccfcrypto.host)
set_property(TARGET ccfcrypto.host PROPERTY POSITION_INDEPENDENT_CODE ON)
install(
TARGETS ccfcrypto.host
DESTINATION lib
)
install(TARGETS ccfcrypto.host DESTINATION lib)

Просмотреть файл

@ -6,61 +6,60 @@ add_definitions(-DSIGN_BATCH)
set(SIGN_BATCH ON)
set(PBFT_SRC
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/globalstate.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Client.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Replica.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Commit.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Message.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Reply.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Digest.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Node.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Request.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Checkpoint.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Pre_prepare.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Req_queue.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Prepare.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Status.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Prepared_cert.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Principal.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Log_allocator.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Meta_data.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Data.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Fetch.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Meta_data_cert.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/State.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/libbyz.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/View_change.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/New_view.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/View_change_ack.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/View_info.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/NV_info.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Rep_info.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Rep_info_exactly_once.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Meta_data_d.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Query_stable.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Reply_stable.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Stable_estimator.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Big_req_table.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Pre_prepare_info.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/LedgerWriter.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/key_format.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/request_id_gen.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/New_principal.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Network_open.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/globalstate.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Client.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Replica.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Commit.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Message.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Reply.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Digest.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Node.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Request.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Checkpoint.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Pre_prepare.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Req_queue.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Prepare.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Status.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Prepared_cert.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Principal.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Log_allocator.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Meta_data.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Data.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Fetch.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Meta_data_cert.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/State.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/libbyz.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/View_change.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/New_view.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/View_change_ack.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/View_info.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/NV_info.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Rep_info.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Rep_info_exactly_once.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Meta_data_d.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Query_stable.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Reply_stable.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Stable_estimator.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Big_req_table.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Pre_prepare_info.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/LedgerWriter.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/key_format.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/request_id_gen.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/New_principal.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/Network_open.cpp
)
if ("sgx" IN_LIST TARGET)
if("sgx" IN_LIST TARGET)
add_library(libbyz.enclave STATIC ${PBFT_SRC})
target_compile_options(libbyz.enclave PRIVATE
-nostdinc
target_compile_options(libbyz.enclave PRIVATE -nostdinc)
target_compile_definitions(
libbyz.enclave PRIVATE INSIDE_ENCLAVE _LIBCPP_HAS_THREAD_API_PTHREAD
__USE_SYSTEM_ENDIAN_H__
)
target_compile_definitions(libbyz.enclave PRIVATE INSIDE_ENCLAVE _LIBCPP_HAS_THREAD_API_PTHREAD __USE_SYSTEM_ENDIAN_H__ )
set_property(TARGET libbyz.enclave PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(libbyz.enclave PRIVATE
${CCF_DIR}/src/ds
openenclave::oelibc
${PARSED_ARGS_INCLUDE_DIRS}
${EVERCRYPT_INC}
target_include_directories(
libbyz.enclave PRIVATE ${CCF_DIR}/src/ds openenclave::oelibc
${PARSED_ARGS_INCLUDE_DIRS} ${EVERCRYPT_INC}
)
use_oe_mbedtls(libbyz.enclave)
add_dependencies(libbyz.enclave flatbuffers)
@ -68,7 +67,7 @@ endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if ("virtual" IN_LIST TARGET)
if("virtual" IN_LIST TARGET)
add_library(libbyz.host STATIC ${PBFT_SRC})
target_compile_options(libbyz.host PRIVATE -stdlib=libc++)
@ -78,7 +77,8 @@ if ("virtual" IN_LIST TARGET)
use_client_mbedtls(libbyz.host)
add_dependencies(libbyz.host flatbuffers)
add_library(libcommontest STATIC
add_library(
libcommontest STATIC
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/network_udp.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/network_udp_mt.cpp
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/ITimer.cpp
@ -88,100 +88,119 @@ if ("virtual" IN_LIST TARGET)
target_compile_options(libcommontest PRIVATE -stdlib=libc++)
add_dependencies(libcommontest flatbuffers)
target_include_directories(libcommontest PRIVATE
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz
${CMAKE_SOURCE_DIR}/3rdparty
${EVERCRYPT_INC}
target_include_directories(
libcommontest PRIVATE ${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz
${CMAKE_SOURCE_DIR}/3rdparty ${EVERCRYPT_INC}
)
target_compile_options(libcommontest PRIVATE -stdlib=libc++)
add_library(libcommontest.mock STATIC
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/mocks/network_mock.cpp)
target_include_directories(libcommontest.mock PRIVATE
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test
${EVERCRYPT_INC}
add_library(
libcommontest.mock STATIC
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/mocks/network_mock.cpp
)
target_include_directories(
libcommontest.mock
PRIVATE ${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test ${EVERCRYPT_INC}
)
target_compile_options(libcommontest.mock PRIVATE -stdlib=libc++)
function(use_libbyz name)
target_include_directories(${name} PRIVATE
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz
${CMAKE_SOURCE_DIR}/src/pbft/crypto
${EVERCRYPT_INC}
target_include_directories(
${name}
PRIVATE ${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz
${CMAKE_SOURCE_DIR}/src/pbft/crypto ${EVERCRYPT_INC}
)
target_link_libraries(
${name} PRIVATE libbyz.host libcommontest evercrypt.host
${PLATFORM_SPECIFIC_TEST_LIBS}
)
target_link_libraries(${name} PRIVATE libbyz.host libcommontest evercrypt.host ${PLATFORM_SPECIFIC_TEST_LIBS})
endfunction()
enable_testing()
function(pbft_add_executable name)
target_link_libraries(${name} PRIVATE ${CMAKE_THREAD_LIBS_INIT} secp256k1.host)
target_link_libraries(
${name} PRIVATE ${CMAKE_THREAD_LIBS_INIT} secp256k1.host
)
use_libbyz(${name})
add_san(${name})
target_compile_options(${name} PRIVATE -stdlib=libc++)
target_link_libraries(${name} PRIVATE
-stdlib=libc++
-lc++
-lc++abi
secp256k1.host)
target_link_libraries(
${name} PRIVATE -stdlib=libc++ -lc++ -lc++abi secp256k1.host
)
endfunction()
add_executable(simple-server
add_executable(
simple-server
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/replica_main.cpp
${CCF_DIR}/src/enclave/thread_local.cpp
)
pbft_add_executable(simple-server)
add_executable(replica-test
add_executable(
replica-test
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/replica_test.cpp
${CCF_DIR}/src/enclave/thread_local.cpp
)
pbft_add_executable(replica-test)
add_executable(test-controller
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/test_controller_main.cpp
${CCF_DIR}/src/enclave/thread_local.cpp
add_executable(
test-controller
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/test_controller_main.cpp
${CCF_DIR}/src/enclave/thread_local.cpp
)
pbft_add_executable(test-controller)
add_executable(client-test
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/client_test.cpp
${CCF_DIR}/src/enclave/thread_local.cpp
add_executable(
client-test
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/client_test.cpp
${CCF_DIR}/src/enclave/thread_local.cpp
)
pbft_add_executable(client-test)
## Unit tests
add_unit_test(test_ledger_replay
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/test_ledger_replay.cpp)
target_include_directories(test_ledger_replay PRIVATE ${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/mocks)
# Unit tests
add_unit_test(
test_ledger_replay
${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/test_ledger_replay.cpp
)
target_include_directories(
test_ledger_replay
PRIVATE ${CMAKE_SOURCE_DIR}/src/consensus/pbft/libbyz/test/mocks
)
target_link_libraries(test_ledger_replay PRIVATE libcommontest.mock)
use_libbyz(test_ledger_replay)
add_san(test_ledger_replay)
## end to end tests
# end to end tests
add_test(
NAME test_UDP
COMMAND
python3 ${CMAKE_SOURCE_DIR}/tests/infra/libbyz/e2e_test.py --ip 127.0.0.1 --servers 4 --clients 2 --test-config ${CMAKE_SOURCE_DIR}/tests/infra/libbyz/test_config --run-time 30
python3 ${CMAKE_SOURCE_DIR}/tests/infra/libbyz/e2e_test.py --ip 127.0.0.1
--servers 4 --clients 2 --test-config
${CMAKE_SOURCE_DIR}/tests/infra/libbyz/test_config --run-time 30
)
add_test(
NAME test_client_proxy
COMMAND
python3 ${CMAKE_SOURCE_DIR}/tests/infra/libbyz/e2e_test.py --ip 127.0.0.1 --servers 4 --clients 0 --test-config ${CMAKE_SOURCE_DIR}/tests/infra/libbyz/test_config --test-client-proxy
python3 ${CMAKE_SOURCE_DIR}/tests/infra/libbyz/e2e_test.py --ip 127.0.0.1
--servers 4 --clients 0 --test-config
${CMAKE_SOURCE_DIR}/tests/infra/libbyz/test_config --test-client-proxy
--run-time 30
)
add_test(
NAME test_UDP_with_delay
COMMAND
python3 ${CMAKE_SOURCE_DIR}/tests/infra/libbyz/e2e_test.py --ip 127.0.0.1 --servers 4 --clients 2 --test-config ${CMAKE_SOURCE_DIR}/tests/infra/libbyz/test_config --with-delays
python3 ${CMAKE_SOURCE_DIR}/tests/infra/libbyz/e2e_test.py --ip 127.0.0.1
--servers 4 --clients 2 --test-config
${CMAKE_SOURCE_DIR}/tests/infra/libbyz/test_config --with-delays
)
endif()
endif()

Просмотреть файл

@ -1,31 +1,39 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.
# Note: this needs to be done before project(), otherwise CMAKE_*_COMPILER is already set by CMake
# If the user has not expressed any choice, we attempt to default to Clang >= 7
# If they have expressed even a partial choice, the usual CMake selection logic applies
# If we cannot find both a suitable clang and a suitable clang++, the usual CMake selection logic applies
if ((NOT CMAKE_C_COMPILER) AND (NOT CMAKE_CXX_COMPILER)
AND "$ENV{CC}" STREQUAL "" AND "$ENV{CXX}" STREQUAL "")
# Note: this needs to be done before project(), otherwise CMAKE_*_COMPILER is
# already set by CMake If the user has not expressed any choice, we attempt to
# default to Clang >= 7 If they have expressed even a partial choice, the usual
# CMake selection logic applies If we cannot find both a suitable clang and a
# suitable clang++, the usual CMake selection logic applies
if((NOT CMAKE_C_COMPILER)
AND (NOT CMAKE_CXX_COMPILER)
AND "$ENV{CC}" STREQUAL ""
AND "$ENV{CXX}" STREQUAL ""
)
find_program(FOUND_CMAKE_C_COMPILER NAMES clang-8 clang-7.0 clang-7)
find_program(FOUND_CMAKE_CXX_COMPILER NAMES clang++-8 clang++-7.0 clang++-7)
if (NOT (FOUND_CMAKE_C_COMPILER AND FOUND_CMAKE_CXX_COMPILER))
message(WARNING "Clang >= 7 not found, will use default compiler. "
"Override the compiler by setting CC and CXX environment variables.")
if(NOT (FOUND_CMAKE_C_COMPILER AND FOUND_CMAKE_CXX_COMPILER))
message(
WARNING
"Clang >= 7 not found, will use default compiler. "
"Override the compiler by setting CC and CXX environment variables."
)
else()
# CMAKE_*_COMPILER can only be set once, and cannot be unset, we either
# want both, or none at all.
# CMAKE_*_COMPILER can only be set once, and cannot be unset, we either want
# both, or none at all.
set(CMAKE_C_COMPILER "${FOUND_CMAKE_C_COMPILER}")
set(CMAKE_CXX_COMPILER "${FOUND_CMAKE_CXX_COMPILER}")
endif()
endif()
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
if (CMAKE_C_COMPILER_VERSION VERSION_LESS 7)
message(WARNING "CCF officially supports Clang >= 7 only, "
"but your Clang version (${CMAKE_C_COMPILER_VERSION}) "
"is older than that. Build problems may occur.")
endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_VERSION VERSION_LESS 7)
message(WARNING "CCF officially supports Clang >= 7 only, "
"but your Clang version (${CMAKE_C_COMPILER_VERSION}) "
"is older than that. Build problems may occur."
)
endif()
endif()
set(CMAKE_CXX_STANDARD 17)

Просмотреть файл

@ -1,65 +1,48 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.
set(QUICKJS_PREFIX ${CCF_DIR}/3rdparty/quickjs CACHE PATH "Prefix to the QuickJS library")
set(QUICKJS_INC
${QUICKJS_PREFIX}
set(QUICKJS_PREFIX
${CCF_DIR}/3rdparty/quickjs
CACHE PATH "Prefix to the QuickJS library"
)
set(QUICKJS_INC ${QUICKJS_PREFIX})
set(QUICKJS_SRC
${QUICKJS_PREFIX}/cutils.c
${QUICKJS_PREFIX}/libbf.c
${QUICKJS_PREFIX}/libunicode.c
${QUICKJS_PREFIX}/libregexp.c
${QUICKJS_PREFIX}/quickjs.c
${QUICKJS_PREFIX}/cutils.c ${QUICKJS_PREFIX}/libbf.c
${QUICKJS_PREFIX}/libunicode.c ${QUICKJS_PREFIX}/libregexp.c
${QUICKJS_PREFIX}/quickjs.c
)
execute_process(COMMAND cat "${QUICKJS_PREFIX}/VERSION" OUTPUT_VARIABLE QUICKJS_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
COMMAND cat "${QUICKJS_PREFIX}/VERSION"
OUTPUT_VARIABLE QUICKJS_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "QuickJS prefix: ${QUICKJS_PREFIX} version: ${QUICKJS_VERSION}")
# We need two versions of libquickjs, because it depends on libc
if ("sgx" IN_LIST TARGET)
add_library(quickjs.enclave STATIC
${QUICKJS_SRC}
${CCF_DIR}/3rdparty/stub/stub.c
if("sgx" IN_LIST TARGET)
add_library(
quickjs.enclave STATIC ${QUICKJS_SRC} ${CCF_DIR}/3rdparty/stub/stub.c
)
target_compile_options(quickjs.enclave PUBLIC
-nostdinc
-DCONFIG_VERSION="${QUICKJS_VERSION}"
-DEMSCRIPTEN
)
target_link_libraries(quickjs.enclave PUBLIC
openenclave::oelibc
)
set_property(TARGET quickjs.enclave
PROPERTY POSITION_INDEPENDENT_CODE ON
)
target_include_directories(quickjs.enclave PUBLIC
${QUICKJS_INC}
target_compile_options(
quickjs.enclave PUBLIC -nostdinc -DCONFIG_VERSION="${QUICKJS_VERSION}"
-DEMSCRIPTEN
)
target_link_libraries(quickjs.enclave PUBLIC openenclave::oelibc)
set_property(TARGET quickjs.enclave PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(quickjs.enclave PUBLIC ${QUICKJS_INC})
install(
TARGETS quickjs.enclave
DESTINATION lib
)
install(TARGETS quickjs.enclave DESTINATION lib)
endif()
add_library(quickjs.host STATIC
${QUICKJS_SRC}
)
target_compile_options(quickjs.host PUBLIC
-DCONFIG_VERSION="${QUICKJS_VERSION}"
)
set_property(TARGET quickjs.host
PROPERTY POSITION_INDEPENDENT_CODE ON
)
target_include_directories(quickjs.host PUBLIC
${QUICKJS_INC}
add_library(quickjs.host STATIC ${QUICKJS_SRC})
target_compile_options(
quickjs.host PUBLIC -DCONFIG_VERSION="${QUICKJS_VERSION}"
)
set_property(TARGET quickjs.host PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(quickjs.host PUBLIC ${QUICKJS_INC})
install(
TARGETS quickjs.host
DESTINATION lib
)
install(TARGETS quickjs.host DESTINATION lib)

Просмотреть файл

@ -1,40 +1,25 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.
if ("sgx" IN_LIST TARGET)
add_library(secp256k1.enclave STATIC
${CCF_DIR}/3rdparty/secp256k1/src/secp256k1.c
)
target_include_directories(secp256k1.enclave PUBLIC
${CCF_DIR}/3rdparty/secp256k1
)
target_compile_options(secp256k1.enclave PRIVATE
-fvisibility=hidden -nostdinc
)
target_compile_definitions(secp256k1.enclave PRIVATE
HAVE_CONFIG_H
SECP256K1_BUILD
)
target_link_libraries(secp256k1.enclave PRIVATE
openenclave::oelibc
)
set_property(TARGET secp256k1.enclave
PROPERTY POSITION_INDEPENDENT_CODE ON
)
if("sgx" IN_LIST TARGET)
add_library(
secp256k1.enclave STATIC ${CCF_DIR}/3rdparty/secp256k1/src/secp256k1.c
)
target_include_directories(
secp256k1.enclave PUBLIC ${CCF_DIR}/3rdparty/secp256k1
)
target_compile_options(
secp256k1.enclave PRIVATE -fvisibility=hidden -nostdinc
)
target_compile_definitions(
secp256k1.enclave PRIVATE HAVE_CONFIG_H SECP256K1_BUILD
)
target_link_libraries(secp256k1.enclave PRIVATE openenclave::oelibc)
set_property(TARGET secp256k1.enclave PROPERTY POSITION_INDEPENDENT_CODE ON)
endif()
add_library(secp256k1.host STATIC
${CCF_DIR}/3rdparty/secp256k1/src/secp256k1.c
)
target_include_directories(secp256k1.host PUBLIC
${CCF_DIR}/3rdparty/secp256k1
)
target_compile_options(secp256k1.host PRIVATE
-fvisibility=hidden
)
target_compile_definitions(secp256k1.host PRIVATE
HAVE_CONFIG_H SECP256K1_BUILD
)
set_property(TARGET secp256k1.host
PROPERTY POSITION_INDEPENDENT_CODE ON
)
add_library(secp256k1.host STATIC ${CCF_DIR}/3rdparty/secp256k1/src/secp256k1.c)
target_include_directories(secp256k1.host PUBLIC ${CCF_DIR}/3rdparty/secp256k1)
target_compile_options(secp256k1.host PRIVATE -fvisibility=hidden)
target_compile_definitions(secp256k1.host PRIVATE HAVE_CONFIG_H SECP256K1_BUILD)
set_property(TARGET secp256k1.host PROPERTY POSITION_INDEPENDENT_CODE ON)

Просмотреть файл

@ -1,34 +1,34 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the Apache 2.0 License.
# Small Bank Client executable
add_client_exe(small_bank_client
add_client_exe(
small_bank_client
SRCS ${CMAKE_CURRENT_LIST_DIR}/clients/small_bank_client.cpp
)
target_link_libraries(small_bank_client PRIVATE
secp256k1.host
http_parser.host
)
target_link_libraries(small_bank_client PRIVATE secp256k1.host http_parser.host)
# SmallBank application
add_ccf_app(smallbank
SRCS ${CMAKE_CURRENT_LIST_DIR}/app/smallbank.cpp
)
sign_app_library(smallbank.enclave
${CMAKE_CURRENT_LIST_DIR}/app/oe_sign.conf
add_ccf_app(smallbank SRCS ${CMAKE_CURRENT_LIST_DIR}/app/smallbank.cpp)
sign_app_library(
smallbank.enclave ${CMAKE_CURRENT_LIST_DIR}/app/oe_sign.conf
${CCF_DIR}/src/apps/sample_key.pem
)
if (BUILD_TESTS)
## Small Bank end to end and performance test
if (PBFT)
set(SMALL_BANK_VERIFICATION_FILE ${CMAKE_CURRENT_LIST_DIR}/tests/verify_small_bank_50k.json)
if(BUILD_TESTS)
# Small Bank end to end and performance test
if(PBFT)
set(SMALL_BANK_VERIFICATION_FILE
${CMAKE_CURRENT_LIST_DIR}/tests/verify_small_bank_50k.json
)
set(SMALL_BANK_ITERATIONS 50000)
else()
set(SMALL_BANK_VERIFICATION_FILE ${CMAKE_CURRENT_LIST_DIR}/tests/verify_small_bank.json)
set(SMALL_BANK_VERIFICATION_FILE
${CMAKE_CURRENT_LIST_DIR}/tests/verify_small_bank.json
)
set(SMALL_BANK_ITERATIONS 200000)
endif()
# TODO: Fix signed HTTP RPCs with PBFT
if (NOT (PBFT AND HTTP))
if(NOT (PBFT AND HTTP))
add_perf_test(
NAME small_bank_client_test
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/small_bank_client.py
@ -36,27 +36,31 @@ if (BUILD_TESTS)
VERIFICATION_FILE ${SMALL_BANK_VERIFICATION_FILE}
LABEL SB
ADDITIONAL_ARGS
--transactions ${SMALL_BANK_ITERATIONS}
--max-writes-ahead 1000
--transactions ${SMALL_BANK_ITERATIONS} --max-writes-ahead 1000
--metrics-file small_bank_metrics.json
)
endif()
if (PBFT)
set(SMALL_BANK_SIGNED_VERIFICATION_FILE ${CMAKE_CURRENT_LIST_DIR}/tests/verify_small_bank_20k.json)
if(PBFT)
set(SMALL_BANK_SIGNED_VERIFICATION_FILE
${CMAKE_CURRENT_LIST_DIR}/tests/verify_small_bank_20k.json
)
set(SMALL_BANK_SIGNED_ITERATIONS 20000)
elseif (${SERVICE_IDENTITY_CURVE_CHOICE} STREQUAL "secp256k1_bitcoin")
set(SMALL_BANK_SIGNED_VERIFICATION_FILE ${CMAKE_CURRENT_LIST_DIR}/tests/verify_small_bank_50k.json)
elseif(${SERVICE_IDENTITY_CURVE_CHOICE} STREQUAL "secp256k1_bitcoin")
set(SMALL_BANK_SIGNED_VERIFICATION_FILE
${CMAKE_CURRENT_LIST_DIR}/tests/verify_small_bank_50k.json
)
set(SMALL_BANK_SIGNED_ITERATIONS 50000)
else()
set(SMALL_BANK_SIGNED_VERIFICATION_FILE ${CMAKE_CURRENT_LIST_DIR}/tests/verify_small_bank_2k.json)
set(SMALL_BANK_SIGNED_VERIFICATION_FILE
${CMAKE_CURRENT_LIST_DIR}/tests/verify_small_bank_2k.json
)
set(SMALL_BANK_SIGNED_ITERATIONS 2000)
endif()
# These tests require client-signed signatures:
# - PBFT doesn't yet verify these correctly
# - HTTP C++ perf clients don't currently sign correctly
if (NOT PBFT AND NOT HTTP)
# These tests require client-signed signatures: - PBFT doesn't yet verify
# these correctly - HTTP C++ perf clients don't currently sign correctly
if(NOT PBFT AND NOT HTTP)
add_perf_test(
NAME small_bank_sigs_client_test
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/small_bank_client.py
@ -64,26 +68,37 @@ if (BUILD_TESTS)
VERIFICATION_FILE ${SMALL_BANK_SIGNED_VERIFICATION_FILE}
LABEL "SB_sig"
ADDITIONAL_ARGS
--transactions ${SMALL_BANK_SIGNED_ITERATIONS}
--max-writes-ahead 1000
--transactions
${SMALL_BANK_SIGNED_ITERATIONS}
--max-writes-ahead
1000
--sign
--metrics-file small_bank_sigs_metrics.json
--metrics-file
small_bank_sigs_metrics.json
)
# It is better to run performance tests with forwarding on different machines
# (i.e. nodes and clients)
# It is better to run performance tests with forwarding on different
# machines (i.e. nodes and clients)
add_perf_test(
NAME small_bank_sigs_forwarding
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/small_bank_client.py
CLIENT_BIN ./small_bank_client
LABEL "SB_sig_fwd"
ADDITIONAL_ARGS
--transactions ${SMALL_BANK_SIGNED_ITERATIONS}
--max-writes-ahead 1000
--metrics-file small_bank_fwd_metrics.json
-n localhost -n localhost
-cn localhost
--send-tx-to backups
--transactions
${SMALL_BANK_SIGNED_ITERATIONS}
--max-writes-ahead
1000
--metrics-file
small_bank_fwd_metrics.json
-n
localhost
-n
localhost
-cn
localhost
--send-tx-to
backups
--sign
)
endif()