Giter Club home page Giter Club logo

ccf-app-samples's Introduction

CCF App Samples Open in VSCode

CCF App Samples CI

Sample applications for the Confidential Consortium Framework (CCF).

Quickstart

The quickest way to build and run sample applications is to checkout this repository locally in its development container by clicking:

Open in VSCode

All dependencies will be automatically installed (takes ~2 mins on first checkout).

Alternatively, if your organisation supports it, you can checkout this repository in a Github codespace:

Open in GitHub Codespaces

Please choose a sample to learn more.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

ccf-app-samples's People

Contributors

achamayou avatar aymalla avatar eddyashton avatar julioalex-rezende avatar kusweta avatar macromania avatar martinpeck avatar microsoft-github-operations[bot] avatar microsoftopensource avatar mkcomer avatar msftsettiy avatar ross-p-smith avatar takuro-sato avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ccf-app-samples's Issues

Document Getting Started Application Development using CCF

Document get started repository for building CCF applications using (JavaScript and C++).

Steps to build network, open network, activate members, deploy app, etc.

"You would skip these steps if you use mCCF"

  • Main Repo for CCF (Build apps/sub-section)

Next Steps (Nov 9th):

  • Submit PR to Amaury and Takouro
  • Async review PR and determine best place to put documentation (but realistically in CCF main repo)

I will create a PR on the samples repo, and after revision and acceptance we can extract the generic parts and push it to the main CCF docs.

When building js app create set_js_app.json document for governance

There may be another place in CCF that creates a set_app_js governance proposal document for us to be able to register an application in the network. So this may be unnecessary, so happy to remove this. As mentioned here, https://microsoft.github.io/CCF/main/build_apps/js_app_bundle.html#deployment we need to create set_js_app proposal.

If this is worthwhile addition I can also amend the documentation in the main CCF repository

Investigate and demo regulatory change to application

Per demo requirements, we will need to demonstrate governance actions = a code change.

https://github.com/microsoft/ccf-app-samples/blob/main/data-reconciliation-app/demo/demo-guidance.md

[SPIKE] - Proof that version 1 of the application is still running whilst there is a active proposal (version 2)

Create a script to

  1. Propose code change to network - add another field to summary object. Total Votes.
  2. Members vote and approve
  3. Run E2E test (ingest and report apis) - you should see the new field in the data reporting returned json

Acceptance Critera:

  1. We assume that this code change will be a non-breaking change to the application

Provide PG with Neutrino Collaboration Model (Git Project + Issues)

The PG have several other groups that are collaborating with CCF in the same capacity as Crew Neutrino. They are currently using AzDO, duplicating issues, over-complex collaboration model. Amaury really likes how we set up our collaboration model: separate, self-managed project, triage --> issues, and how our issues flow into their backlog.

They asked if we could document how we set up this collaboration model.

Acceptance Criteria:

  1. Document and provide resources/links/demo to PG on how we set up this collaboration model within Git.

CI should run test target

When the CI is triggered it should build the devcontainer and use that to run the tests - this way we know that the devcontainer always works

Context from PG/Amaury:

  • Takuro will be adding 3 applications to the ccf-app-samples repository (banking app, logging app, contact discovery app)
  • Build make in an extensible way for future sample applications being added
  • We want to make this repo easier to use from DX example; thus, introducing make files to build + test code pointing to one app.
  • Only focus on JS Samples (as C++ will be phased out)
  • Keep in mind: the sample applications will ultimately be sample containerized applications with many different languages (make + docker? -- keep this in mind in make design decisions)

Upgrade to latest CCF dev container

I have a change that I have made to the sandbox.sh in the main CCF repository. In order to get this we will have to upgrade the samples dev container. This could cause some issues as we move from 3 to 3.1.

Fix test-docker-virtual in codespace

Describe the bug
make test-docker-virtual doesn't finish if it's run in codespace.

Steps to reproduce

  1. Open the repo with codespace
  2. cd banking-app
  3. make test-docker-virtual

Implement and unit test data ingest APIs

Based on data ingest ADR, implement and unit test data ingest APIs:

  • Add a single record
  • Batch add a N records
  1. Code checked into ccf-app-samples

Dependent on #83

Reference these files: -

Acceptance Criteria

  • Define an app.json for the ingestion of the data reconciliation
  • Implement the API endpoint to ingest the data from CSV
  • Unit Test (make unit-test)

Move dockerfile and cchost config into each sample

In the samples repo we have a config and docker folder in the root. These should be in each sample so that each sample can move at its own release cadence.

Acceptance Criteria

  • All existing samples to be updated so that we have a standard across the repo

Add make target to run test

After cloning the repository, there should be a one line command to test the sample application(s)

Context from PG/Amaury:

  • Takuro will be adding 3 applications to the ccf-app-samples repository (banking app, logging app, contact discovery app)
  • Build make in an extensible way for future sample applications being added
  • We want to make this repo easier to use from DX example; thus, introducing make files to build + test code pointing to one app.
  • Only focus on JS Samples (as C++ will be phased out)
  • Keep in mind: the sample applications will ultimately be sample containerized applications with many different languages (make + docker? -- keep this in mind in make design decisions)

Update banking sample to use its own constitution

Initial Idea:
Fix up --no-default-constitution within prepare_demo.sh
As part of the Banking Application Sample we copy over the constitution/resolve.js so that the sandbox.sh works - is this correct - what is the correct model here?

Next Steps (Nov 9th):

  • Set up knowledge transfer/brainstorming session about constitution/correct models surrounding constitutions
  • It is likely this model will change (pattern will be created) based on N number of sample applications

Update after talking to Takuro
When the Banking Sample was originally created it used the constitution of the Sandbox and overrode the resolve.js. We are going to amend the Banking Sample to run the network in docker and not use sandbox.sh. We will also demonstrate the Governance stage and therefore should define the constitution. This would mean we would not use the sandbox files, but rather include all 4 js files in the Banking Sample.

Update 16th November
Q: How do we update a constitution?
A: There is an api that allows you to update the constitution. Just be aware that any outstanding proposals will be closed when a new constitution is approved.

Add CI

Short term goal

  • Run tests with the virtual TEE environment.

Long term goal

  • Run tests with actual SGX or SEV-SNP

Tool

GitHub Actions should be enough.

Deploy SGX VM via IaC and run sample app

We should have a simple way of building a VM in Azure and deploy the sample application to it so we can show customers how to deploy it to Azure

Feedback/Context from PG:

There is some value in this story.

  • This may be useful for a developer to understand how to get a single node, CCF network app to run on Infrastructure; however, this is not how most will set up their networks in production environments

  • This may also be useful to run performance testing on deployed/running sample app.

  • Useful to get someone started

  • In reality, SGX is not the easiest VM for any dev to create (limited to certain regions, very expensive). Suggested that we leverage any D.C Intel VM for this story.

  • What may be "More Useful"and provide more value is taking a sample app CCF app here and deploying it to Azure leveraging mCCF ARM templates + documenting that workflow for a developer (more realistic use case than VM)

  • Recommend we get access to mCCF first, as this ticket can provide more value once we have an idea of ARM templates/mCCF world

Configure GH Board

  • Feature labels

  • Bug labels

  • Check in with MK so that we can slice a view by Feature/Story/Task

Add make target to build sample

After cloning the repository, there should be a one line command to build the sample application(s)z

Context from PG/Amaury:

  • Takuro will be adding 3 applications to the ccf-app-samples repository (banking app, logging app, contact discovery app)
  • Build make in an extensible way for future sample applications being added
  • We want to make this repo easier to use from DX example; thus, introducing make files to build + test code pointing to one app.
  • Only focus on JS Samples (as C++ will be phased out)
  • Keep in mind: the sample applications will ultimately be sample containerized applications with many different languages (make + docker? -- keep this in mind in make design decisions)

Remove all history in ccf-app-samples repo

The https://github.com/microsoft/ccf-app-samples/ repository has previously had certificates stored inside it for the demo. These were replaced by dynamically creating the certificates as part of the demo.

However this means the certs are in the git history and this means it is problematic to fork this repository to Azure DevOps.

I think we should squash the commits before and after the certs being added now before we iterate further.

Split demo.sh into demo_governance.sh and demo_application.sh

The current demo.sh is a mixture of calling the governance APIs and then the actually Banking Application. Split this into 2 separate scripts so that it is easier to understand.

Also add comments in the bash scripts so dev understands what each line of code does.

Define repository structure for data-reconciliation sample

Define repository structure for /data-reconciliation-app in ccf-app-samples repo. Be sure to reference the banking-app and follow a similar structure for our app.

App structure
Reference template: https://github.com/microsoft/ccf-app-template/tree/main/js

  • logging
  • unit testing
  • NO TSOA
    ***minimum npm packages

CCF Stuff

Docs

  • design docs
  • Readme
  • etc

Acceptance Criteria:

  1. Design + Propose repo structure for our sample application

Generalize existing governance scripts for ccf-app-samples

We have existing scripts for the banking-app

  1. Create member + activate
  2. Create user and activate
  3. Submit proposal to deploy app to mCCF

Acceptance Criteria:

  1. Move AzDO scripts to ccf-app-samples
  2. Generalize & configure scripts - so they can be used for banking-app and data-reconciliation-app (Config file per sample app?)
  3. Test generalized governance scripts on banking-app in mCCF

Implement and unit test data reporting apis

Based on data reporting ADR, implement and unit test data data reporting APIs:

  • GET data summary on all records
  • GET data summary by unique ID
  • Implement reconciliation logic in this service. Returns summary object(s)

Domain Model according to this ADR

  • Design
  • Implement
  • Test

Reference these files:

  • Data reporting ADR: #85

Acceptance Criteria

  • Define an app.json for the data reporting
  • Implement the API endpoint to return the summary object(s) JSON
  • Unit Test (make unit-test)

Design API Contract for Data Ingest

ADR to define a generalised ingest API

  • REST definition with noun/verb of how we ingest the data
  • consider PartitionKey and attributes

Dependent on the LEI schema investigation

Design data reporting APIs

Design Data Reporting - API, Service & Repository Layers.

Requirements: https://github.com/microsoft/ccf-app-samples/blob/main/data-reconciliation-app/docs/data-schema-data-flow.md#data-reporting

Members will query for report summary. All data returned will be JSON. Voting Threshold should be configurable.

Design APIs:

  • by individual record (unique ID)
  • for ALL data

Design Service Layer

Repository Layer:

  • Query K-V store by ID
  • Query K-V store for ALL

Acceptance Criteria:

  1. ADR
  2. Review ADR with team (Sync or Async)

Scaffolding the Data Reconciliation app

After repository structure is defined, create a hello world skeleton app for our data-reconciliation scenario.

Includes:

  • domain model
  • API endpoint for hello world
  • Unit test

Acceptance Criteria

  1. Code checked into ccf-app-samples

Remove member0 certificates from Docker image

Current Docker Image builder generates member0 certificate and keys to be used by application. For security reasons, image must not hold that information.

Change build structure to generate member0 certificate in a previous stage, and create docker image only with the relevant information needed to open the network

Next Steps (Nov 9th):

  • Great idea, CCF team hasn't had time to do this yet.

Error when running app in docker virtual container

Describe the bug
I get an error of terminating with uncaught exception of type std::logic_error: SGX enclaves are not supported in current build - cannot launch /usr/lib/ccf/libjs_generic.virtual.so when trying to run an example with the docker virtual image

Steps to reproduce
I had to update the docker file to generate the member cert in the docker image since I can't install ccf locally but I don't think that would cause such an error.

  1. update banking-app/docker/ccf_app_js.virtual to generate member0 cert in docker file
diff --git a/banking-app/docker/ccf_app_js.virtual b/banking-app/docker/ccf_app_js.virtual
index 2b9d6e6..a115605 100644
--- a/banking-app/docker/ccf_app_js.virtual
+++ b/banking-app/docker/ccf_app_js.virtual
@@ -10,11 +10,12 @@ COPY --from=builder /opt/ccf_virtual/lib/libjs_generic.virtual.so /usr/lib/ccf
 # copy configuration into image
 COPY ./constitution/*.js /app/
 COPY ./config/cchost_config_virtual_js.json /app/
-COPY ./workspace/docker_certificates/member0_cert.pem /app/
-COPY ./workspace/docker_certificates/member0_enc_pubk.pem /app/
 
 WORKDIR /app/
 
+COPY --from=builder /opt/ccf_virtual/bin/keygenerator.sh /app/
+RUN /app/keygenerator.sh --name member0 --gen-enc-key
+
 EXPOSE 8080/tcp
 
 CMD ["/usr/bin/cchost", "--config", "/app/cchost_config_virtual_js.json"]
  1. remove certificate generation from build_image.sh
diff --git a/build_image.sh b/build_image.sh
index 9d9b9c9..51c7ca4 100755
--- a/build_image.sh
+++ b/build_image.sh
@@ -24,9 +24,9 @@ mkdir -p $app_path/workspace/docker_certificates
 
 echo "-- generating member0 certificates"
 # This is directly related to the member described in host config file 
-cd $app_path/workspace/docker_certificates
-$ccf_prefix/keygenerator.sh --name member0 --gen-enc-key
+#cd $app_path/workspace/docker_certificates
+#$ccf_prefix/keygenerator.sh --name member0 --gen-enc-key
  1. cd banking-app
  2. npm install
  3. make build-virtual
  4. docker run banking-app:virtual
2022-12-08T19:48:25.962404Z        100 [info ] ../src/host/main.cpp:125             | CCF version: ccf-3.0.1
2022-12-08T19:48:25.962602Z        100 [info ] ../src/host/main.cpp:133             | Configuration file /app/cchost_config_virtual_js.json:
{
  "enclave": {
    "file": "/usr/lib/ccf/libjs_generic.virtual.so",
    "type": "Virtual"
  },
  "network": {
    "node_to_node_interface": {
      "bind_address": "172.17.0.3:8081"
    },
    "rpc_interfaces": {
      "main_interface": {
        "bind_address": "172.17.0.3:8080"
      }
    }
  },
  "command": {
    "type": "Start",
    "service_certificate_file": "/app/service_cert.pem",
    "start": {
      "constitution_files": [
        "/app/validate.js",
        "/app/apply.js",
        "/app/resolve.js",
        "/app/actions.js"
      ],
      "members": [
        {
          "certificate_file": "/app/member0_cert.pem",
          "encryption_public_key_file": "/app/member0_enc_pubk.pem"
        }
      ]
    }
  }
}
2022-12-08T19:48:25.962649Z        100 [info ] ../src/host/main.cpp:164             | Recovery threshold unset. Defaulting to number of initial consortium members with a public encryption key (1).
terminating with uncaught exception of type std::logic_error: SGX enclaves are not supported in current build - cannot launch /usr/lib/ccf/libjs_generic.virtual.so```

Make test.sh idempotent

At the moment, running ./banking-app/test.sh only works the first time as it relies on a bank account balance which always increases.

Update the test so that you can run it multiple times.

(SPIKE) Investigate initial LEI Data Structure + sample data

Research LEI data structure + data flow. After investigating if possible, create a sample data set (1 excel spreadsheet).

Acceptance Criteria

  1. Design doc on data model for LEI data
  2. Create 1 set of sample data for 1 member

Dependent on conversation with Brent

Install Node in the DevContainer

Install the following features in the DevContainer for ease of development

  • Docker from Docker (this allows you to use the host docker engine from within the DevContainer)
  • Node 16.7

Deploy skeleton app to Azure mCCF

Investigate how we are going to deploy an application to the managed CCF in Azure

Investigate whether there is a bicep possibility with this (escape hatches)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.