Skip to content

Commit

Permalink
feat(copm): add Corda COPM implementation
Browse files Browse the repository at this point in the history
Primary change:

Implements COPM primitives for Corda as a cacti
plugin.  The implementation follows the model of
the Corda ledger connector plugin, where a
typescript pass-through implementation is
registered on the plugin server, and commands are
implemented on a separate grpc server in the
Kotlin Spring framework.

Secondary changes:

- The lock claim protobuf structure was updated
to reduce the number of parameters.
- A no-op endpoint was added, per project
specification
- The format of the inter-network command for
requesting the status of a pledge varies by
remote network type and asset.  Adds a function to
the typescript interop configuration  interface to
supply the appropriate command given
the remote network and asset.
- Adds test package to test combinations of
network types
- Updates CI script to use new testing
framework
- Updates linter ignore to include weaver build
directories, allowing yarn lint to pass on
a system where weaver libraries have been built.
Also excludes docs directory to avoid linting
minified js from documentation packages.

Signed-off-by: Jennifer Bell <jenniferlianne@gmail.com>
  • Loading branch information
Jennifer Bell authored and petermetz committed Dec 4, 2024
1 parent fbe68c1 commit 6544a95
Show file tree
Hide file tree
Showing 172 changed files with 4,979 additions and 1,385 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"Hursley",
"HyperLedger",
"immalleable",
"imodule",
"ipaddress",
"ipfs",
"IPFSHTTP",
Expand Down
6 changes: 5 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**/node_modules/**
**/dist/**

**/build/**
docs/*
examples/cactus-example-carbon-accounting-frontend/www/
examples/cactus-example-supply-chain-frontend/www/
weaver/core/identity-management/iin-agent/out/
Expand Down Expand Up @@ -32,6 +33,8 @@ 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/common/protos-sol/solidity-protos/soltest/test/TestFixture.js
weaver/common/protos-sol/solidity-protos/soltest/migrations/1_deploy_contract.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 Expand Up @@ -106,3 +109,4 @@ weaver/sdks/fabric/interoperation-node-sdk/src/helpers.ts
weaver/sdks/fabric/interoperation-node-sdk/test/AssetManager.js
weaver/sdks/fabric/interoperation-node-sdk/test/InteroperableHelper.js
weaver/sdks/fabric/interoperation-node-sdk/test/Relay.js
weaver/sdks/fabric/interoperation-node-sdk/protos-js/driver/driver_grpc_pb.js
42 changes: 38 additions & 4 deletions .github/actions/copm_test/action.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
name: 'Copm Test'
description: "common setup steps for the weaver network needed to run copm tests"
inputs:
github-actor:
description: the github actor variable
required: true
github-token:
description: the github secret token variable
required: true
runs:
using: "composite"
steps:
- name: free github runner disk space
shell: bash
run: |
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Use Node.js ${{ env.NODEJS_VERSION }}
uses: actions/setup-node@v4.0.2
with:
Expand All @@ -22,15 +36,35 @@ runs:
cargo update -p nom
cargo update -p lexical-core
working-directory: weaver/core/relay
- uses: actions/setup-go@v4
with:
go-version: '1.20.2'
- 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/protoc-gen-go-grpc@v1.4.0
# PROTOS
- name: Build local weaver dependencies
run: make setup --trace
- name: Set up JDK 17
uses: actions/setup-java@v3.11.0
with:
java-version: '17'
distribution: 'adopt'
- name: Generate github.properties
shell: bash
working-directory: packages/cacti-plugin-copm-fabric
run: |
echo "Using ${{ inputs.github-actor }} user."
{
echo "username=${{ inputs.github-actor }}"
echo "password=${{ inputs.github-token }}"
echo "url=https://maven.pkg.github.com/hyperledger/cacti"
} >> github.properties
{
echo "username=${{ inputs.github-actor }}"
echo "password=${{ inputs.github-token }}"
echo "url=https://maven.pkg.github.com/hyperledger/cacti"
} >> github.main.properties
working-directory: weaver/tests/network-setups/corda


12 changes: 9 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,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 }}
copm-changed: ${{ steps.changes.outputs.copm-changed }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4.1.7
Expand Down Expand Up @@ -175,9 +175,15 @@ jobs:
- './packages/cactus-plugin-keychain-memory/**'
# - './.github/workflows/ci.yaml'
plugin-copm-fabric-changed:
copm-changed:
- './packages/cactus-common/**'
- './packages/cactus-core/**'
- './packages/cactus-core-api/**'
- './packages/cacti-copm-common/**'
- './packages/cacti-copm-test/**'
- './packages/cacti-plugin-copm-fabric/**'
- './packages/cacti-plugin-copm-corda/**'
- './weaver/**'
build-dev:
needs: check-ci-skip
Expand Down Expand Up @@ -1471,7 +1477,7 @@ jobs:
needs:
- build-dev
- compute_changed_packages
if: needs.compute_changed_packages.outputs.plugin-copm-fabric-changed == 'true'
if: needs.compute_changed_packages.outputs.copm-changed == 'true'
uses: ./.github/workflows/test_copm.yaml


Expand Down
138 changes: 80 additions & 58 deletions .github/workflows/test_copm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,84 @@ env:
RUN_CODE_COVERAGE: true

jobs:
copm-fabric-fabric-pledge-and-provestate:
continue-on-error: false
env:
CACTI_NPM_PACKAGE_NAME: "@hyperledger-cacti/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-getverifiedview.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/checkout@v4.1.1
- 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/upload-artifact@v4.3.3
with:
name: coverage-reports-copm-fabric
path: ./code-coverage-ts/**/
matrix-pledge-and-getview:
name: pledge-getview-${{ matrix.net1 }}-${{ matrix.net2 }}
strategy:
fail-fast: false
matrix:
net1: ["fabric", "corda"]
net2: ["fabric", "corda"]
env:
FULL_BUILD_DISABLED: true
FREE_UP_GITHUB_RUNNER_DISK_SPACE_DISABLED: false
JEST_TEST_PATTERN: packages/cacti-copm-test/src/test/typescript/integration/test-copm-getverifiedview.test.ts packages/cacti-copm-test/src/test/typescript/integration/test-copm-pledge-claim.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/copm-pledge-${{ matrix.net1 }}-${{ matrix.net2}}
JEST_TEST_CODE_COVERAGE_ENABLED: true
TAPE_TEST_PATTERN: ''
TAPE_TEST_RUNNER_DISABLED: true
COPM_NET_1: ${{ matrix.net1 }}
COPM_NET_2: ${{ matrix.net2 }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4.1.1
- uses: ./.github/actions/copm_test/
with:
github-actor: ${GITHUB_ACTOR}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Make the ${{matrix.net1}} network
run: |
make -f Makefile_${{matrix.net1}} setup pledge-network
working-directory: packages/cacti-copm-test
- name: Make the ${{matrix.net2}} network
run: |
make -f Makefile_${{matrix.net2}} setup pledge-network
working-directory: packages/cacti-copm-test
if: ${{ matrix.net1 != matrix.net2 }}
- 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/upload-artifact@v4.3.3
with:
name: copm-pledge-${{ matrix.net1 }}-${{ matrix.net2}}
path: ./code-coverage-ts/**/

copm-fabric-fabric-lock:
continue-on-error: false
env:
CACTI_NPM_PACKAGE_NAME: "@hyperledger-cacti/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/checkout@v4.1.1
- 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/upload-artifact@v4.3.3
with:
name: coverage-reports-copm-fabric-lock
path: ./code-coverage-ts/**/
matrix-lock:
name: lock-${{ matrix.net1 }}
strategy:
fail-fast: false
matrix:
net1: ["fabric", "corda"]
env:
FULL_BUILD_DISABLED: true
FREE_UP_GITHUB_RUNNER_DISK_SPACE_DISABLED: false
TAPE_TEST_PATTERN: ''
TAPE_TEST_RUNNER_DISABLED: true
JEST_TEST_PATTERN: packages/cacti-copm-test/src/test/typescript/integration/test-copm-lock-claim.test.ts
JEST_TEST_RUNNER_DISABLED: false
JEST_TEST_COVERAGE_PATH: ./code-coverage-ts/copm-lock-${{ matrix.net1 }}
JEST_TEST_CODE_COVERAGE_ENABLED: true
COPM_NET_1: ${{ matrix.net1 }}
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4.1.1
- uses: ./.github/actions/copm_test/
with:
github-actor: ${GITHUB_ACTOR}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Make the ${{matrix.net1}} network
run: |
make -f Makefile_${{matrix.net1}} setup lock-network
working-directory: packages/cacti-copm-test
- 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/upload-artifact@v4.3.3
with:
name: copm-lock-${{ matrix.net1 }}
path: ./code-coverage-ts/**/

1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
moduleNameMapper: {
"^(\\.\\.?\\/.+)\\.jsx?$": "$1",
},
modulePathIgnorePatterns: ["./weaver/core"],
maxWorkers: 1,
maxConcurrency: 1,
setupFilesAfterEnv: ["jest-extended/all", "./jest.setup.console.logs.js"],
Expand Down
2 changes: 1 addition & 1 deletion packages/cacti-copm-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"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"
"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.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",
Expand Down
Loading

0 comments on commit 6544a95

Please sign in to comment.