Skip to content

Commit

Permalink
feat(copm): add fabric COPM implementation
Browse files Browse the repository at this point in the history
Primary Change:
- add connectRPC cactus plugin for copm primitives

Secondary Changes:
- add common COPM prototypes
- add common weaver protos-js directory to enable
building under ci.yaml, which requires all local
dependencies to be present at build time
- remove incorrect 'main' declaration in protos-js
package file
- add separate tsconfig file to
/weaver/sdks/fabric/interoperation-node-sdk to
allow it to be built by ci.yaml
- update weaver fabric network makefile 'clean'
target to continue if some target files
were not generated by the make process

Signed-off-by: Jennifer Bell <[email protected]>
  • Loading branch information
Jennifer Bell committed Sep 19, 2024
1 parent 299af74 commit c50865d
Show file tree
Hide file tree
Showing 163 changed files with 37,608 additions and 28 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"commenceack",
"configtx",
"connectrpc",
"Copm",
"Corda",
"Cordapp",
"couchdb",
Expand Down
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ weaver/common/policy-dsl/parser/PolicyListener.js
weaver/common/policy-dsl/parser/PolicyParser.js
weaver/common/policy-dsl/test/MyErrorListener.js
weaver/common/policy-dsl/test/MyParseTreeVisitor.js
weaver/common/protos-js/driver/driver_grpc_pb.js
weaver/core/drivers/fabric-driver/server/dbConnector.ts
weaver/core/drivers/fabric-driver/server/events.ts
weaver/core/drivers/fabric-driver/server/fabric-code.ts
Expand Down
36 changes: 36 additions & 0 deletions .github/actions/copm_test/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: 'Copm Test'
description: "common setup steps for the weaver network needed to run copm tests"
runs:
using: "composite"
steps:
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/[email protected]
with:
node-version: ${{ env.NODEJS_VERSION }}
- id: yarn-cache
name: Restore Yarn Cache
uses: actions/[email protected]
with:
key: ${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
path: ./.yarn/
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('./yarn.lock') }}
- name: Get Latest Relay Dependencies
shell: bash
run: |
make protos-local
cargo update -p nom
cargo update -p lexical-core
working-directory: weaver/core/relay
- name: Use Protoc 3.15
shell: bash
run: |
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v3.15.6/protoc-3.15.6-linux-x86_64.zip
unzip protoc-3.15.6-linux-x86_64.zip -d protoc
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/[email protected]
# PROTOS
- name: Build local weaver dependencies
run: make setup --trace
shell: bash
working-directory: packages/cacti-plugin-copm-fabric
13 changes: 13 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ jobs:
plugin-htlc-coordinator-besu-changed: ${{ steps.changes.outputs.plugin-htlc-coordinator-besu-changed }}
test-tooling-changed: ${{ steps.changes.outputs.test-tooling-changed }}
ghcr-dev-container-vscode-changed: ${{ steps.changes.outputs.ghcr-dev-container-vscode-changed }}
plugin-copm-fabric-changed: ${{ steps.changes.outputs.plugin-copm-fabric-changed }}
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
Expand Down Expand Up @@ -163,6 +164,10 @@ jobs:
- './packages/cactus-plugin-keychain-memory/**'
# - './.github/workflows/ci.yaml'
plugin-copm-fabric-changed:
- './packages/cacti-copm-common/**'
- './packages/cacti-plugin-copm-fabric/**'
build-dev:
continue-on-error: false
env:
Expand Down Expand Up @@ -1450,6 +1455,14 @@ jobs:
name: coverage-reports-27
path: ./code-coverage-ts/**/

copm-tests:
needs:
- build-dev
- compute_changed_packages
if: needs.compute_changed_packages.outputs.plugin-copm-fabric-changed == 'true'
uses: ./.github/workflows/test_copm.yaml


plc-fabric-0:
needs:
- build-dev
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/test_copm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
on:
# Triggers the workflow on push or pull request events but only for the main branch
workflow_call:

env:
NODEJS_VERSION: v18.18.2
RUN_TRIVY_SCAN: true
RUN_CODE_COVERAGE: true

jobs:
copm-fabric-fabric-pledge-and-provestate:
continue-on-error: false
env:
CACTI_NPM_PACKAGE_NAME: "@hyperledger/cacti-plugin-copm-fabric"
HFC_LOGGING: '{"debug":"console","info":"console","warn": "console","error":"console"}'
FULL_BUILD_DISABLED: true
FREE_UP_GITHUB_RUNNER_DISK_SPACE_DISABLED: false
JEST_TEST_PATTERN: packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-pledge-claim.test.ts packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-provestate.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/plc-copm-fabric-fabric-pledge
JEST_TEST_CODE_COVERAGE_ENABLED: true
TAPE_TEST_PATTERN: ""
TAPE_TEST_RUNNER_DISABLED: true
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/copm_test/
- name: Make the fabric network
run: make pledge-network --trace
working-directory: packages/cacti-plugin-copm-fabric
- name: show the running network
run: docker container ls
- run: ./tools/ci.sh
- name: Upload coverage reports as artifacts
if: ${{ env.RUN_CODE_COVERAGE == 'true' }}
uses: actions/[email protected]
with:
name: coverage-reports-copm-fabric
path: ./code-coverage-ts/**/

copm-fabric-fabric-lock:
continue-on-error: false
env:
CACTI_NPM_PACKAGE_NAME: "@hyperledger/cacti-plugin-copm-fabric"
HFC_LOGGING: '{"debug":"console","info":"console","warn": "console","error":"console"}'
FULL_BUILD_DISABLED: true
FREE_UP_GITHUB_RUNNER_DISK_SPACE_DISABLED: false
JEST_TEST_PATTERN: packages/cacti-plugin-copm-fabric/src/test/typescript/integration/test-copm-lock-claim.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/plc-copm-fabric-fabric-lock
JEST_TEST_CODE_COVERAGE_ENABLED: true
TAPE_TEST_PATTERN: ""
TAPE_TEST_RUNNER_DISABLED: true
runs-on: ubuntu-22.04
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/copm_test/
- name: Make the fabric network
run: make lock-network --trace
working-directory: packages/cacti-plugin-copm-fabric
- name: show the running network
run: docker container ls
- run: ./tools/ci.sh
- name: Upload coverage reports as artifacts
if: ${{ env.RUN_CODE_COVERAGE == 'true' }}
uses: actions/[email protected]
with:
name: coverage-reports-copm-fabric-lock
path: ./code-coverage-ts/**/
27 changes: 27 additions & 0 deletions packages/cacti-copm-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# @hyperledger/cacti-copm-core

This package defines the common types, interfaces, and endpoints for the
COPM module to be used by Digital Ledger-specific implementations.

These endpoints require specific chaincode and weaver relays to be deployed on the network.
Please see https://hyperledger.github.io/cacti/weaver/introduction/.

Endpoint documentation:
https://jenniferlianne.github.io/cacti/references/openapi/cacti-copm-core_openapi/

# Usage

## Installation

Yarn:

yarn add --exact @hyperledger/cacti-copm-core


# Development

When implementing a new distributed ledger, the following interfaces must be implemented:

- DLTransactionContext: Implements running a transaction on the local network
- DLRemoteTransactionContext: Uses the weaver relays to run a transaction on another network
- DLTransactionContextFactory: Factory to return either local or remote context for the specific DLT.
14 changes: 14 additions & 0 deletions packages/cacti-copm-core/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: v1
plugins:
# This will invoke protoc-gen-es and write output to src/gen
- plugin: es
out: src/main/typescript/generated
opt:
# Add more plugin options here
- target=ts
# This will invoke protoc-gen-connect-es
- plugin: connect-es
out: src/main/typescript/generated
opt:
# Add more plugin options here
- target=ts
7 changes: 7 additions & 0 deletions packages/cacti-copm-core/openapitools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "6.6.0"
}
}
42 changes: 42 additions & 0 deletions packages/cacti-copm-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@hyperledger/cacti-copm-core",
"version": "0.0.1",
"description": "Cacti Common Operators",
"homepage": "https://github.com/hyperledger/cacti#readme",
"bugs": {
"url": "https://github.com/hyperledger/cacti/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/hyperledger/cacti.git"
},
"license": "Apache-2.0",
"author": "Jennifer Bell",
"main": "dist/lib/main/typescript/index.js",
"module": "dist/lib/main/typescript/index.js",
"types": "dist/lib/main/typescript/index.d.ts",
"files": [
"dist/*"
],
"scripts": {
"bundleopenapi": "yarn run --top-level tools:bundle-open-api-tpl-files",
"codegen": "yarn run --top-level run-s 'codegen:*'",
"codegen:proto": "yarn run proto:openapi; yarn run proto:connectrpc",
"dev:redo": "yarn run bundleopenapi; yarn run codegen:proto",
"proto:connectrpc": "yarn run buf generate --template=./buf.gen.yaml ./src/main/proto/generated/openapi",
"proto:openapi": "yarn run --top-level openapi-generator-cli generate -i ./src/main/json/openapi.json -g protobuf-schema --model-name-suffix=PB --language-specific-primitives=google.protobuf.Any --type-mappings=AnyType=google.protobuf.Any --type-mappings=object=google.protobuf.Any --additional-properties=packageName=org.hyperledger.cacti.plugin.cacti.plugin.copm.core -o ./src/main/proto/generated/openapi/ -t=./src/main/mustache/openapi-generator/templates/protobuf-schema/ --ignore-file-override ../../openapi-generator-ignore"
},
"dependencies": {
"@bufbuild/buf": "1.30.0",
"@bufbuild/protobuf": "1.10.0",
"@connectrpc/connect": "1.4.0",
"@hyperledger/cacti-weaver-sdk-fabric": "2.0.0-rc.4",
"@hyperledger/cactus-common": "2.0.0-rc.4"
},
"devDependencies": {
"@bufbuild/protoc-gen-es": "1.8.0",
"@connectrpc/connect-node": "1.4.0",
"@connectrpc/protoc-gen-connect-es": "1.4.0",
"@openapitools/openapi-generator-cli": "2.13.4"
}
}
Loading

0 comments on commit c50865d

Please sign in to comment.