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

feat(copm): add Corda COPM implementation #3625

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jenniferlianne
Copy link

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.

Pull Request Requirements

  • Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.

- name: free github runner disk space
shell: bash
run: |
sudo rm -rf /usr/share/dotnet
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenniferlianne Suggestion: Consider re-using the logic from ci.sh that does the same kind of space clearing. If it's not flexible enough and/or too heavy / too slow then please make a note in the comments here or open an issue on GH with suggestions (for exmaple we could pull the disk space freeing logic to a separate bash script that you can source and then re-use easily)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a few runs at this but:

  • the space must be cleared before building and deploying weaver, and
  • as is, the command in ci.sh does not clear up enough space.

I tried adding additional directories to the remove section, however that could impact other jobs -- and the copm_jobs failed regardless on the second call to ci.sh to run the tests. https://github.com/hyperledger-cacti/cacti/actions/runs/11838070296/job/32986450316

@@ -302,6 +291,24 @@
}
},
"paths": {
"/api/v1/plugins/@hyperledger/cacti-plugin-copm/no-op": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenniferlianne I'm totally fine with naming it no-op but it also sounds like from the description that it could also just be called healthcheck. Not a change request. Just saying.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our grand architecture diagram, the no-op function was meant to serve as a pass-through to the target ledger (Fabric, Corda, etc.) That way, when the COPM is integrated with the pipelines of all other packages (as envisioned in the architecture), it offers direct access to the ledger without performing any of the operations offered by the COPM (proof generation, locks, claims, etc.)

Currently, this function seems to be just returning without doing anything, which is fine. Later, when we integrate this module with other pipelines, we can change the logic to do a pass-through (we will need to design this in such a way that allows existing pipelines to work as intended with the COPM mediating interactions with the ledger.)

Copy link
Contributor

@petermetz petermetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenniferlianne Looking pretty high quality in general, but as usual I have some requests. On top of the comments I left inline, please make sure to include a test case which verifies the plugin being functional while used through the API server (you'll most likely need a separate package because this one cannot depend on the API server due to circular dependency issues)
If you need examples just let me know.

@@ -0,0 +1,314 @@
package org.hyperledger.cacti.plugin.cacti.plugin.copm.core.services.defaultservice
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenniferlianne If this is generated code then please make sure to have that represented somewhere along the directory path with a path element of .../generated/... so that it's always clearly distinguishable from hand-maintained code. It helps during reviews and also whenever we add more automation it's extremely helpful while constructing globs/regexes that find or exclude generated code from automation such as linting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was committed by mistake. Thanks.

@@ -0,0 +1 @@
{"O=PartyA, L=London, C=GB@Corda_Network":{"host":"127.0.0.1","username":"clientUser1","password":"test","port":10006},"O=PartyB, L=London, C=GB@Corda_Network":{"host":"127.0.0.1","username":"clientUser1","password":"test","port":10009},"O=PartyA, L=London, C=GB@Corda_Network2":{"host":"127.0.0.1","username":"clientUser1","password":"test","port":30006},"O=PartyB, L=London, C=GB@Corda_Network2":{"host":"127.0.0.1","username":"clientUser1","password":"test","port":30009}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenniferlianne Is this something that has to be shipped to production or just a testing aritfact? If it's only for testing then I'd recommend placing it somewhere under src/test/json/resources or similar like src/test/json/fixtures/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file has been moved to /src/test/json

# Without these we get crashes on JDK 17 an above since the introduction of the
# Java Modules system.

for i in 1 2 3; do java -jar ${APP}/kotlin-spring/build/libs/copm-corda-0.4.jar && break || sleep 5; done
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenniferlianne Please update the version to the current latest release if possible

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

copmKotlinServerBaseUrl: string;
}

export class PluginCopmCorda implements IPluginCrpcService {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenniferlianne Please also implement the ICactusPlugin interface

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

import net.corda.core.contracts.CommandData
import org.hyperledger.cacti.weaver.imodule.corda.states.AssetClaimParameters

class CordaAssetClaim(private var data: ValidatedClaimPledgedAssetV1Request,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenniferlianne This looks like it might also be generated code but I'm not sure. If it is, please move it under a directory path that contains generated as a path element so that it's easier to distinguish. There might be other pockets of generated code that I didn't find but please apply this change to all other generated code as well.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's actually not generated.

@jenniferlianne jenniferlianne force-pushed the copm_corda branch 6 times, most recently from e107eb5 to e04747c Compare November 14, 2024 13:21
Copy link
Contributor

@petermetz petermetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jenniferlianne LGTM, thank you!

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>
@jenniferlianne
Copy link
Author

@jenniferlianne Looking pretty high quality in general, but as usual I have some requests. On top of the comments I left inline, please make sure to include a test case which verifies the plugin being functional while used through the API server (you'll most likely need a separate package because this one cannot depend on the API server due to circular dependency issues) If you need examples just let me know.

As mentioned on the call, the plugin is brought up via the ApiServer in both fabric and corda cases. Please see:
packages/cacti-copm-test/src/main/typescript/corda/copm-tester-corda.ts line 118
packages/cacti-copm-test/src/main/typescript/fabric/copm-tester-fabric.ts line 122

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants