Skip to content

Commit 2ad0bf6

Browse files
authored
Remove cchost binary - each library becomes an executable (#7128)
1 parent be4a782 commit 2ad0bf6

88 files changed

Lines changed: 1320 additions & 1769 deletions

File tree

Some content is hidden

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

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [7.0.0-dev2]
9+
10+
[7.0.0-dev2]: https://github.com/microsoft/CCF/releases/tag/ccf-7.0.0-dev2
11+
12+
### Changed
13+
14+
- `cchost` is removed, and each application now provides its own executable:
15+
- CCF nodes no longer contain a separate `cchost` executable and enclave library (`.so`) file. Each former enclave library is now its own executable, currently sharing the same set configuration format as the previous `cchost`.
16+
- The `js_generic` sample app is no longer a library installed at `/ccf/lib/libjs_generic.so`, it is now an executable installed at `/ccf/bin/js_generic`.
17+
- The `add_ccf_app` function in CMake now builds an executable rather than a library. The caller should provide a `main` function, and call `ccf::run()` from `include/ccf/run.h` to start the node (see `samples/apps/main.cpp` for a minimal example).
18+
- Application logging no longer traverses the ringbuffer. As current target platforms do not require distinct enclave and host components, what was previously "in-enclave" logging that was deferred via the ringbuffer can now be immediately sent to stdout.
19+
820
## [7.0.0-dev1]
921

1022
[7.0.0-dev1]: https://github.com/microsoft/CCF/releases/tag/ccf-7.0.0-dev1

CMakeLists.txt

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ else()
243243
list(APPEND CCHOST_SOURCES src/host/snmalloc.cpp)
244244
endif()
245245

246-
list(APPEND CCHOST_SOURCES ${CCF_DIR}/src/host/main.cpp
246+
list(APPEND CCHOST_SOURCES ${CCF_DIR}/src/host/run.cpp
247247
${CCF_DIR}/src/host/env.cpp
248248
)
249249

250-
add_executable(cchost ${CCHOST_SOURCES})
250+
add_library(cchost STATIC ${CCHOST_SOURCES})
251251

252252
add_san(cchost)
253253
add_tidy(cchost)
@@ -272,8 +272,13 @@ target_link_libraries(
272272
http_parser
273273
)
274274
target_compile_definitions(cchost PRIVATE CCF_LOGGER_NO_DEPRECATE)
275+
set_property(TARGET cchost PROPERTY POSITION_INDEPENDENT_CODE ON)
275276

276-
install(TARGETS cchost DESTINATION bin)
277+
install(
278+
TARGETS cchost
279+
EXPORT ccf
280+
DESTINATION lib
281+
)
277282

278283
# HTTP parser
279284
add_library(http_parser "${HTTP_PARSER_SOURCES}")
@@ -388,8 +393,8 @@ set(CCF_NETWORK_TEST_ARGS --log-level ${TEST_LOGGING_LEVEL} --worker-threads
388393

389394
# SNIPPET_START: JS generic application
390395
add_ccf_app(
391-
js_generic SRCS ${CCF_DIR}/src/apps/js_generic/js_generic.cpp INSTALL_LIBS
392-
${CCF_DEVEL}
396+
js_generic SRCS ${CCF_DIR}/src/apps/js_generic/js_generic.cpp
397+
${CCF_DIR}/samples/apps/main.cpp INSTALL_LIBS ${CCF_DEVEL}
393398
)
394399
# SNIPPET_END: JS generic application
395400

@@ -467,8 +472,6 @@ set(CCF_IMPL_SOURCE
467472

468473
add_library(ccf STATIC ${CCF_IMPL_SOURCE})
469474

470-
target_compile_definitions(ccf PUBLIC INSIDE_ENCLAVE VIRTUAL_ENCLAVE)
471-
472475
target_compile_options(ccf PUBLIC ${COMPILE_LIBCXX})
473476
target_compile_definitions(ccf PRIVATE CCF_LOGGER_NO_DEPRECATE)
474477

@@ -821,7 +824,10 @@ if(BUILD_TESTS)
821824
)
822825

823826
# Merkle Tree memory test
824-
add_executable(merkle_mem src/node/test/merkle_mem.cpp)
827+
add_executable(
828+
merkle_mem src/node/test/merkle_mem.cpp
829+
${CCF_DIR}/src/enclave/thread_local.cpp
830+
)
825831
target_compile_options(merkle_mem PRIVATE ${COMPILE_LIBCXX})
826832
target_link_libraries(
827833
merkle_mem PRIVATE ${CMAKE_THREAD_LIBS_INIT} ${LINK_LIBCXX} ccfcrypto
@@ -980,18 +986,16 @@ if(BUILD_TESTS)
980986
NAME modules_test
981987
PYTHON_SCRIPT ${CMAKE_SOURCE_DIR}/tests/js-modules/modules.py
982988
ADDITIONAL_ARGS
983-
--package
984-
libjs_generic
985-
--election-timeout-ms
986-
10000 # Larger election timeout as recording
989+
--package js_generic --election-timeout-ms 10000 # Larger election
990+
# timeout as recording
987991
# large JS applications may trigger leadership changes
988992
)
989993

990994
add_e2e_test(
991995
NAME auth
992996
PYTHON_SCRIPT
993997
${CMAKE_SOURCE_DIR}/tests/js-custom-authorization/custom_authorization.py
994-
ADDITIONAL_ARGS --package libjs_generic --js-app-bundle
998+
ADDITIONAL_ARGS --package js_generic --js-app-bundle
995999
${CMAKE_SOURCE_DIR}/tests
9961000
)
9971001

@@ -1240,15 +1244,15 @@ if(BUILD_TESTS)
12401244
NAME pi_ls
12411245
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/infra/piccolo_driver.py
12421246
CLIENT_BIN ./submit PERF_LABEL "Logging"
1243-
ADDITIONAL_ARGS --package "samples/apps/logging/liblogging"
1247+
ADDITIONAL_ARGS --package "samples/apps/logging/logging"
12441248
--max-writes-ahead 1000 --repetitions 10000
12451249
)
12461250

12471251
add_piccolo_test(
12481252
NAME pi_basic
12491253
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/infra/basicperf.py
12501254
CLIENT_BIN ./submit PERF_LABEL "Basic"
1251-
ADDITIONAL_ARGS --package "samples/apps/basic/libbasic" --client-def
1255+
ADDITIONAL_ARGS --package "samples/apps/basic/basic" --client-def
12521256
"1,write,100000,primary"
12531257
)
12541258

@@ -1265,7 +1269,7 @@ if(BUILD_TESTS)
12651269
NAME pi_basic_mt
12661270
PYTHON_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/tests/infra/basicperf.py
12671271
CLIENT_BIN ./submit PERF_LABEL "Basic Multi-Threaded"
1268-
ADDITIONAL_ARGS --package "samples/apps/basic/libbasic" --client-def
1272+
ADDITIONAL_ARGS --package "samples/apps/basic/basic" --client-def
12691273
"${WORKER_THREADS},write,100000,primary"
12701274
)
12711275
endif()
@@ -1276,7 +1280,7 @@ if(BUILD_TESTS)
12761280
CLIENT_BIN ./submit PERF_LABEL "Logging JWT"
12771281
ADDITIONAL_ARGS
12781282
--package
1279-
"samples/apps/logging/liblogging"
1283+
"samples/apps/logging/logging"
12801284
--max-writes-ahead
12811285
1000
12821286
--repetitions

cmake/ccf_app.cmake

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ function(add_ccf_app name)
2121
"SRCS;INCLUDE_DIRS;SYSTEM_INCLUDE_DIRS;LINK_LIBS;DEPS;INSTALL_LIBS"
2222
)
2323

24-
# Build app "enclave", loaded as a shared library
25-
add_library(${name} SHARED ${PARSED_ARGS_SRCS})
24+
# Build app executable
25+
add_executable(${name} ${PARSED_ARGS_SRCS})
2626

2727
target_include_directories(${name} PRIVATE ${PARSED_ARGS_INCLUDE_DIRS})
2828
target_include_directories(
2929
${name} SYSTEM PRIVATE ${PARSED_ARGS_SYSTEM_INCLUDE_DIRS}
3030
)
3131
add_warning_checks(${name})
3232

33-
target_link_libraries(${name} PRIVATE ${PARSED_ARGS_LINK_LIBS} ccf)
33+
target_link_libraries(${name} PRIVATE ${PARSED_ARGS_LINK_LIBS} ccf cchost)
3434

3535
if(NOT (SAN OR TSAN))
3636
target_link_options(${name} PRIVATE LINKER:--no-undefined)
@@ -52,9 +52,8 @@ function(add_ccf_app name)
5252
endif()
5353

5454
if(${PARSED_ARGS_INSTALL_LIBS})
55-
install(TARGETS ${name} DESTINATION lib)
55+
install(TARGETS ${name} DESTINATION bin)
5656
endif()
57-
5857
endfunction()
5958

6059
function(add_host_library name)

cmake/common.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ function(add_picobench name)
226226
PARSE_ARGV 1 PARSED_ARGS "" "" "SRCS;INCLUDE_DIRS;LINK_LIBS"
227227
)
228228

229-
add_executable(${name} ${PARSED_ARGS_SRCS})
229+
add_executable(
230+
${name} ${PARSED_ARGS_SRCS} ${CCF_DIR}/src/enclave/thread_local.cpp
231+
)
230232

231233
target_include_directories(${name} PRIVATE src ${PARSED_ARGS_INCLUDE_DIRS})
232234

doc/architecture/request_flow.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ For deployments where nodes are not directly accessible, redirections can still
187187
P->>P: Execute request
188188
P-->>U: 200 OK "Copied {a} from {A} to {B}"
189189

190-
To use redirection behaviour, and choose whether to redirect to a node or a load balancer, set the ``redirections`` field in the :doc:`cchost launch configuration </operations/configuration>`.
190+
To use redirection behaviour, and choose whether to redirect to a node or a load balancer, set the ``redirections`` field in the :doc:`launch configuration </operations/configuration>`.
191191

192192
External executor flow
193193
----------------------

doc/architecture/threading.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Implementation
1717
Configuration
1818
~~~~~~~~~~~~~
1919

20-
To enable multiple worker threads, the ``worker_threads`` configuration option can be used along with the number of desired threads to ``cchost`` when starting a CCF node.
20+
To enable multiple worker threads, the ``worker_threads`` configuration option can be set to the number of desired threads when starting a CCF node.
2121

2222
It is strongly recommended that all CCF nodes run the same number of worker threads.
2323
The number of worker threads must be at least 1 less than the value of ``NumTCS`` in the oe_sign.conf file.

doc/build_apps/get_started.rst

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ CCF apps can be written in JavaScript/Typescript. To test a JS/TS CCF applicatio
3232
Build Application
3333
~~~~~~~~~~~~~~~~~
3434

35-
The application building prerequisites [:doc:`CCF </build_apps/install_bin>`, `NodeJS <https://nodejs.org>`__ and `NPM <https://www.npmjs.com>`__] must be installed, all will be preinstalled if you are using the devcontainer environment, otherwise you need to install them manually.
35+
The application building prerequisites (:doc:`CCF </build_apps/install_bin>`, `NodeJS <https://nodejs.org>`__ and `NPM <https://www.npmjs.com>`__) must be installed, all will be preinstalled if you are using the devcontainer environment, otherwise you need to install them manually.
3636

3737
Please follow `ccf-app-template build process <https://github.com/microsoft/ccf-app-template#run-js-app>`__
3838

@@ -43,22 +43,18 @@ There are several approaches to run and test your application.
4343

4444
.. tab:: CCF sandbox
4545

46-
- Running the `sandbox.sh` script automatically starts a CCF network and deploys your application on it. The app is up and ready to receive calls and the initial governance steps are done for you
47-
- Support both ccf network types [virtual - enclave (TEE hardware)]
48-
- No initial governance steps required
46+
- Running the `sandbox.sh` script automatically starts a CCF network and deploys your application on it. This will create appropriate configuration files and directory structures, and can be made to print each command for further detail. Once the network is initialised, this will print the node addresses you can use to interact with the service.
47+
- No manual governance steps required
4948

5049
- :doc:`/build_apps/run_app`
5150
- `CCF Application template repository <https://github.com/microsoft/ccf-app-template#run-js-app>`__
5251

53-
.. tab:: VM
52+
.. tab:: Direct launch
5453

55-
- The application can be tested using ``cchost`` and :doc:`CCF config file </operations/configuration>`,
56-
To Start a test CCF network on a Linux environment, it requires :doc:`CCF to be intalled </build_apps/install_bin>`.
57-
- Support both ccf network types [virtual - enclave (TEE hardware)]
58-
- Initial governance steps are required to initialize, deploy your app, and start the network. `check Network governance section <https://github.com/microsoft/ccf-app-template#network-governance>`__
54+
- The application can be run directly, given a :doc:`CCF config file </operations/configuration>`.
55+
Some runtime dependencies are required, so ensure that :doc:`CCF is installed </build_apps/install_bin>`.
56+
- Governance steps are required to :doc:`initialize state, configure your app, and start the network </operations/start_network>`.
5957

60-
- Start a CCF network using cchost and :doc:`CCF node config file </operations/configuration>`. please follow `ccf-app-template <https://github.com/microsoft/ccf-app-template#bare-vm>`__
61-
- The network is started with one node and one member, you need to execute the initial governance steps to initialize the network, `check Network governance section <https://github.com/microsoft/ccf-app-template#network-governance>`__
6258

6359
Testing: Application Endpoints
6460
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -73,7 +69,7 @@ C++ Applications
7369

7470
CCF apps can also be written in C++. This offers better performance than JavaScript apps but requires a compilation step and a restart of the CCF node for deployment. please check `ccf-app-template <https://github.com/microsoft/ccf-app-template>`__ repository.
7571

76-
The C++ sample app is located in the ```cpp/`` <cpp/>`__ directory.
72+
The C++ sample app is located in the `cpp/ <https://github.com/microsoft/ccf-app-template/tree/main/cpp>`__ directory.
7773

7874
Build C++ app
7975
~~~~~~~~~~~~~

doc/build_apps/install_bin.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The following commands can be run to verify that CCF was installed successfully:
2424

2525
.. code-block:: bash
2626
27-
$ /opt/ccf/bin/cchost --version
27+
$ /opt/ccf/bin/js_generic --version
2828
CCF host: ccf-<version>
2929
Platform: SNP
3030
@@ -45,7 +45,7 @@ The following commands can be run to verify that CCF was installed successfully:
4545

4646
The CCF install notably contains:
4747

48-
- The ``cchost`` binary required to spin up a CCF application
48+
- A sample ``js_generic`` application built with CCF, which may be used to host JS applications
4949
- The ``cmake`` files required to build CCF applications
5050
- Header files and libraries to build CCF applications (under ``include/`` and ``lib/``)
5151
- A limited set of Python utilities to start a basic CCF service for local testing

doc/build_apps/run_app.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ There are a large number of additional configuration options, documented by pass
1919
This script automates the steps described in :doc:`/operations/start_network`, in summary:
2020

2121
- generating new identities (private keys and certs) for the initial members and users
22-
- starting the initial ``cchost`` node
22+
- starting the initial node
2323
- starting multiple additional nodes, instructed to ``join`` the initial node
2424
- verifying that each node has successfully joined the new service
2525
- proposing and passing governance votes using the generated member identities

doc/contribute/onboarding.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ Walk through a sample application
2222

2323
The logging application is simple, but exercises most features of the framework, and is extensively used in the end to end tests.
2424

25-
To run a locally built copy of this application in a sandbox, see :doc:`/build_apps/run_app`. The package name will be ``samples/apps/logging/liblogging``:
25+
To run a locally built copy of this application in a sandbox, see :doc:`/build_apps/run_app`. The package name will be ``samples/apps/logging/logging``:
2626

2727
.. code-block:: bash
2828
29-
~/CCF/build$ ../tests/sandbox/sandbox.sh -p samples/apps/logging/liblogging
29+
~/CCF/build$ ../tests/sandbox/sandbox.sh -p samples/apps/logging/logging
3030
3131
Setting up Python environment...
3232
Python environment successfully setup
3333
[11:44:33.376] Starting 1 CCF node...
3434
[11:44:33.376] Virtual mode enabled
3535
[11:44:35.025] Started CCF network with the following nodes:
3636
[11:44:35.025] Node [0] = https://127.0.0.1:8000
37-
[11:44:35.025] You can now issue business transactions to the samples/apps/logging/liblogging application
37+
[11:44:35.025] You can now issue business transactions to the samples/apps/logging/logging application
3838
[11:44:35.025] Keys and certificates have been copied to the common folder: /home/$USER/CCF/build/workspace/sandbox_common
3939
[11:44:35.025] See https://microsoft.github.io/CCF/main/use_apps/issue_commands.html for more information
4040
[11:44:35.025] Press Ctrl+C to shutdown the network

0 commit comments

Comments
 (0)