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 <[email protected]>
  • Loading branch information
Jennifer Bell committed Nov 22, 2024
1 parent 5e3d9d7 commit 83c3521
Show file tree
Hide file tree
Showing 135 changed files with 4,895 additions and 1,243 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,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/[email protected]
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/[email protected]
# PROTOS
- name: Build local weaver dependencies
run: make setup --trace
- name: Set up JDK 17
uses: actions/[email protected]
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/[email protected]
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/[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/**/
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/[email protected]
- 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/[email protected]
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/[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/**/
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/[email protected]
- 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/[email protected]
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
61 changes: 32 additions & 29 deletions packages/cacti-copm-core/src/main/json/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,31 @@
"asset_id": "ref203"
}
},
"owner": {
"source": {
"type": "object",
"$ref": "#/components/schemas/AssetAccountV1",
"x-protobuf-index": 2
},
"dest": {
"type": "object",
"$ref": "#/components/schemas/AssetAccountV1",
"x-protobuf-index": 3
},
"hash_info": {
"type": "object",
"$ref": "#/components/schemas/HashInfoV1",
"x-protobuf-index": 3
"x-protobuf-index": 4
},
"destination_certificate": {
"x-protobuf-index": 4,
"x-protobuf-index": 5,
"type": "string"
},
"source_certificate": {
"x-protobuf-index": 5,
"x-protobuf-index": 6,
"type": "string"
},
"expiry_secs": {
"x-protobuf-index": 6,
"x-protobuf-index": 7,
"type": "integer",
"format": "int64",
"default": 3600
Expand All @@ -160,28 +165,16 @@
},
"AssetLockClaimV1": {
"description": "Claim a previously locked asset on the same network.\n\"lock_id\" is required for fungible assets, \"asset\" is required for non-fungible assets.\nhttps://github.com/hyperledger-cacti/cacti/blob/main/weaver/rfcs/protocols/asset-exchange/generic-htlc.md",
"required": [
"lock_id",
"source",
"destination",
"asset",
"source_certificate",
"hash_info"
],
"required": ["lock_id", "destination", "asset", "hash_info"],
"properties": {
"lock_id": {
"x-protobuf-index": 1,
"type": "string"
},
"source": {
"type": "object",
"$ref": "#/components/schemas/AssetAccountV1",
"x-protobuf-index": 2
},
"destination": {
"type": "object",
"$ref": "#/components/schemas/AssetAccountV1",
"x-protobuf-index": 3,
"x-protobuf-index": 2,
"example": {
"network": "network2.org",
"user_id": "Bob"
Expand All @@ -190,7 +183,7 @@
"asset": {
"type": "object",
"$ref": "#/components/schemas/TransferrableAssetV1",
"x-protobuf-index": 4,
"x-protobuf-index": 3,
"example": {
"type": "bond",
"asset_id": "ref203"
Expand All @@ -199,15 +192,7 @@
"hash_info": {
"type": "object",
"$ref": "#/components/schemas/HashInfoV1",
"x-protobuf-index": 5
},
"source_certificate": {
"x-protobuf-index": 6,
"type": "string"
},
"dest_certificate": {
"x-protobuf-index": 7,
"type": "string"
"x-protobuf-index": 4
}
}
},
Expand Down Expand Up @@ -301,6 +286,24 @@
}
},
"paths": {
"/api/v1/plugins/@hyperledger/cacti-plugin-copm/no-op": {
"post": {
"x-hyperledger-cacti": {
"http": {
"path": "/api/v1/plugins/@hyperledger/cacti-plugin-copm/no-op",
"verbLowerCase": "post"
}
},
"operationId": "noopV1",
"summary": "A no-op operation. May be used as a heath check",
"parameters": [],
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/api/v1/plugins/@hyperledger/cacti-plugin-copm/pledge-asset": {
"post": {
"x-hyperledger-cacti": {
Expand Down
Loading

0 comments on commit 83c3521

Please sign in to comment.