Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to ccf-5.0.0 #25

Merged
merged 1 commit into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM mcr.microsoft.com/ccf/app/dev:4.0.14-virtual
FROM ghcr.io/microsoft/ccf/app/dev/virtual:ccf-5.0.0

RUN curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash - && sudo apt-get install -y nodejs
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
jobs:
build-cpp-app-sgx:
runs-on: ubuntu-20.04
container: mcr.microsoft.com/ccf/app/dev:4.0.14-sgx
container: ghcr.io/microsoft/ccf/app/dev/sgx:ccf-5.0.0

steps:
- name: Checkout repository
Expand All @@ -21,7 +21,7 @@ jobs:

build-cpp-app-virtual:
runs-on: ubuntu-20.04
container: mcr.microsoft.com/ccf/app/dev:4.0.14-virtual
container: ghcr.io/microsoft/ccf/app/dev/virtual:ccf-5.0.0

steps:
- name: Checkout repository
Expand All @@ -33,7 +33,7 @@ jobs:

build-containers:
runs-on: ubuntu-20.04
container: mcr.microsoft.com/ccf/app/dev:4.0.14-sgx
container: ghcr.io/microsoft/ccf/app/dev/sgx:ccf-5.0.0

steps:
- name: Checkout repository
Expand Down
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

Template repository for JavaScript and C++ CCF applications.

Note: For complete sample apps, see https://github.com/microsoft/ccf-app-samples.
Note: For complete sample apps, see https://github.com/microsoft/ccf-app-samples.

## Quickstart

The quickest way to build and run this sample CCF app is to checkout this repository locally in its development container by clicking:
The quickest way to build and run this sample CCF app is to checkout this repository locally in its development container by clicking:
[![Open in VSCode](https://img.shields.io/static/v1?label=Open+in&message=VSCode&logo=visualstudiocode&color=007ACC&logoColor=007ACC&labelColor=2C2C32)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/microsoft/ccf-app-template)

All dependencies will be automatically installed (takes ~2 mins on first checkout).
Expand Down Expand Up @@ -85,29 +85,28 @@ To start a test CCF network on a Linux environment, it requires [CCF to be intal
# Start the CCF network using the cchost in

# Enclave mode
/opt/ccf/bin/cchost --config ./config/cchost_config_enclave_js.json
/opt/ccf_sgx/bin/cchost --config ./config/cchost_config_enclave_js.json

# Or Virtual mode
/opt/ccf/bin/cchost --config ./config/cchost_config_virtual_js.json
/opt/ccf_virtual/bin/cchost --config ./config/cchost_config_virtual_js.json
...

# Now the CCF network is started and further initialization needed before the interaction with the service
```

The CCF network is started with one node and one member, please follow the [same governance steps as Docker](#network-governance) to initialize the network and check [CCF node config file documentation](https://microsoft.github.io/CCF/main/operations/configuration.html)


### Managed CCF

The application can be tested using [Azure Managed CCF](https://techcommunity.microsoft.com/t5/azure-confidential-computing/microsoft-introduces-preview-of-azure-managed-confidential/ba-p/3648986) ``(Pre-release phase)``, you can create Azure Managed CCF service on your subscription, that will give you a ready CCF network
The application can be tested using [Azure Managed CCF](https://techcommunity.microsoft.com/t5/azure-confidential-computing/microsoft-introduces-preview-of-azure-managed-confidential/ba-p/3648986) `(Pre-release phase)`, you can create Azure Managed CCF service on your subscription, that will give you a ready CCF network

- First, create the network's initial member certificate, please check [Certificates generation](https://microsoft.github.io/CCF/main/governance/adding_member.html)
- Create a new Azure Managed CCF service (the initial member certificate required as input)
- Build the application and [create a deployment proposal](https://microsoft.github.io/CCF/main/build_apps/js_app_bundle.html#deployment)
- Deploy the application proposal, [using governance calls](https://microsoft.github.io/CCF/main/governance/proposals.html#creating-a-proposal)
- Create and submit [an add users proposal](https://microsoft.github.io/CCF/main/governance/proposals.html#creating-a-proposal)

## <img src="https://user-images.githubusercontent.com/42961061/191275172-24269bf0-bb9c-402d-8900-2d589582a781.png" height=50px></img> C++
## <img src="https://user-images.githubusercontent.com/42961061/191275172-24269bf0-bb9c-402d-8900-2d589582a781.png" height=50px></img> C++

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.

Expand Down Expand Up @@ -175,13 +174,15 @@ $ docker run ccf-app-template:cpp-virtual
If this repository is checked out on a bare VM (e.g. [for SGX deployments](https://docs.microsoft.com/en-us/azure/confidential-computing/quick-create-portal)), the dependencies required to build and run the C++ app can be installed as follows:

```bash
$ wget https://github.com/microsoft/CCF/releases/download/ccf-4.0.14/ccf_virtual_4.0.14_amd64.deb
$ sudo dpkg -i ccf_virtual_4.0.14_amd64.deb # Install CCF under /opt/ccf
$ cat /opt/ccf_virtual/share/VERSION_LONG
ccf-4.0.14
$ /opt/ccf/getting_started/setup_vm/run.sh /opt/ccf/getting_started/setup_vm/app-dev.yml # Install dependencies
$ wget https://github.com/microsoft/CCF/releases/download/ccf-5.0.0/ccf_sgx_5.0.0_amd64.deb
$ sudo dpkg -i ccf_sgx_5.0.0_amd64.deb # Install CCF under /opt/ccf_sgx
$ cat /opt/ccf_sgx/share/VERSION_LONG
ccf-5.0.0
$ /opt/ccf_sgx/getting_started/setup_vm/run.sh /opt/ccf_sgx/getting_started/setup_vm/app-dev.yml # Install dependencies
```

For a non-SGX VM, replace `ccf_sgx` in all the commands above with `ccf_virtual`.

See the [CCF official docs](https://microsoft.github.io/CCF/main/build_apps/install_bin.html#install-ccf) for more info and [Modern JavaScript application development](https://microsoft.github.io/CCF/main/build_apps/js_app_bundle.html).

## Code Tour
Expand Down
18 changes: 9 additions & 9 deletions cpp/app/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace app
{
// Key-value store types
using Map = kv::Map<size_t, std::string>;
using Map = ccf::kv::Map<size_t, std::string>;
static constexpr auto RECORDS = "records";

// API types
Expand All @@ -31,7 +31,7 @@ namespace app
class AppHandlers : public ccf::UserEndpointRegistry
{
public:
AppHandlers(ccfapp::AbstractNodeContext& context) :
AppHandlers(ccf::AbstractNodeContext& context) :
ccf::UserEndpointRegistry(context)
{
openapi_info.title = "CCF Sample C++ App";
Expand All @@ -42,11 +42,11 @@ namespace app

auto write = [this](auto& ctx, nlohmann::json&& params) {
const auto parsed_query =
http::parse_query(ctx.rpc_ctx->get_request_query());
ccf::http::parse_query(ctx.rpc_ctx->get_request_query());

std::string error_reason;
size_t id = 0;
if (!http::get_query_value(parsed_query, "id", id, error_reason))
if (!ccf::http::get_query_value(parsed_query, "id", id, error_reason))
{
return ccf::make_error(
HTTP_STATUS_BAD_REQUEST,
Expand Down Expand Up @@ -76,11 +76,11 @@ namespace app

auto read = [this](auto& ctx, nlohmann::json&& params) {
const auto parsed_query =
http::parse_query(ctx.rpc_ctx->get_request_query());
ccf::http::parse_query(ctx.rpc_ctx->get_request_query());

std::string error_reason;
size_t id = 0;
if (!http::get_query_value(parsed_query, "id", id, error_reason))
if (!ccf::http::get_query_value(parsed_query, "id", id, error_reason))
{
return ccf::make_error(
HTTP_STATUS_BAD_REQUEST,
Expand Down Expand Up @@ -112,11 +112,11 @@ namespace app
};
} // namespace app

namespace ccfapp
namespace ccf
{
std::unique_ptr<ccf::endpoints::EndpointRegistry> make_user_endpoints(
ccfapp::AbstractNodeContext& context)
ccf::AbstractNodeContext& context)
{
return std::make_unique<app::AppHandlers>(context);
}
} // namespace ccfapp
} // namespace ccf
4 changes: 2 additions & 2 deletions docker/ccf_app_cpp.enclave
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Build
FROM mcr.microsoft.com/ccf/app/dev:4.0.14-sgx as builder
FROM ghcr.io/microsoft/ccf/app/dev/sgx:ccf-5.0.0 as builder
COPY ./cpp /cpp
RUN mkdir -p /build/
WORKDIR /build/
RUN CC="clang-11" CXX="clang++-11" cmake -DCOMPILE_TARGET=sgx -GNinja /cpp && ninja

# Run
FROM mcr.microsoft.com/ccf/app/run:4.0.14-sgx
FROM ghcr.io/microsoft/ccf/app/run/sgx:ccf-5.0.0

COPY --from=builder /build/libccf_app.enclave.so.signed /app/
COPY --from=builder /opt/ccf_sgx/bin/*.js /app/
Expand Down
4 changes: 2 additions & 2 deletions docker/ccf_app_cpp.virtual
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Build
FROM mcr.microsoft.com/ccf/app/dev:4.0.14-virtual as builder
FROM ghcr.io/microsoft/ccf/app/dev/virtual:ccf-5.0.0 as builder
COPY ./cpp /cpp
RUN mkdir -p /build/
WORKDIR /build/
RUN CC="clang-15" CXX="clang++-15" cmake -GNinja -DCOMPILE_TARGET=virtual /cpp && ninja

# Run
FROM mcr.microsoft.com/ccf/app/run:4.0.14-virtual
FROM ghcr.io/microsoft/ccf/app/run/virtual:ccf-5.0.0

COPY --from=builder /build/libccf_app.virtual.so /app/
COPY --from=builder /opt/ccf_virtual/bin/*.js /app/
Expand Down
4 changes: 2 additions & 2 deletions docker/ccf_app_js.enclave
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Build
FROM mcr.microsoft.com/ccf/app/dev:4.0.14-sgx as builder
FROM ghcr.io/microsoft/ccf/app/dev/sgx:ccf-5.0.0 as builder

# Run
FROM mcr.microsoft.com/ccf/app/run-js:4.0.14-sgx
FROM ghcr.io/microsoft/ccf/app/run-js/sgx:ccf-5.0.0

COPY --from=builder /opt/ccf_sgx/bin/*.js /app/
COPY --from=builder /opt/ccf_sgx/bin/keygenerator.sh /app/
Expand Down
4 changes: 2 additions & 2 deletions docker/ccf_app_js.virtual
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Build
FROM mcr.microsoft.com/ccf/app/dev:4.0.14-virtual as builder
FROM ghcr.io/microsoft/ccf/app/dev/virtual:ccf-5.0.0 as builder

# Run
FROM mcr.microsoft.com/ccf/app/run-js:4.0.14-virtual
FROM ghcr.io/microsoft/ccf/app/run-js/virtual:ccf-5.0.0

# Note: libjs_generic.virtual is not included in run-js container
COPY --from=builder /opt/ccf_virtual/lib/libjs_generic.virtual.so /usr/lib/ccf
Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"node": ">=14"
},
"dependencies": {
"@microsoft/ccf-app": "^4.0.14"
"@microsoft/ccf-app": "^5.0.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^17.1.0",
Expand Down