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(connector-corda): support corda 5 RC via TS/HTTP (no JVM) #2814

Closed

Conversation

adrianbatuto
Copy link
Contributor

@adrianbatuto adrianbatuto commented Oct 19, 2023

Fixes #1480
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.

get: async () => ({
isProtected: true,
requiredRoles: [],
httpsAgent: new https.Agent({ rejectUnauthorized: false }),

Check failure

Code scanning / CodeQL

Disabling certificate validation High

Disabling certificate validation is strongly discouraged.

const customHttpsAgent = new https.Agent({
// Configure your custom settings here
rejectUnauthorized: false, // Example: Allow self-signed certificates (use with caution)

Check failure

Code scanning / CodeQL

Disabling certificate validation High test

Disabling certificate validation is strongly discouraged.
@adrianbatuto adrianbatuto force-pushed the r3cordav5 branch 3 times, most recently from 84236a3 to 5a30cba Compare October 20, 2023 07:15
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.

@adrianbatuto Preliminary change requests (I'll do a more thorough review after these initial points are addressed):

  1. Please migrate the test case onto Jest instead of tape (and also remove the tape imports).
  2. Please rename the test file corda-v5-flow-test.ts to end with .test.ts instead of -test.ts because that way VSCode will detect it as a test case instead of a code file that contains shippable code.
  3. When I ran the test file locally, it failed on the last test case, could you please verify if this works on your machine and if yes please attach the exact command you used to run it and the complete log output of the test case as a file attachment.
  4. Question: Does this change retain the v4 support in the connector or does it erase it? E.g., if we merged this diff, would it still be able to support v4.8 Corda ledgers as well as v5 ones or only v5?

@adrianbatuto
Copy link
Contributor Author

adrianbatuto commented Oct 25, 2023

@adrianbatuto Preliminary change requests (I'll do a more thorough review after these initial points are addressed):

  1. Please migrate the test case onto Jest instead of tape (and also remove the tape imports).
  2. Please rename the test file corda-v5-flow-test.ts to end with .test.ts instead of -test.ts because that way VSCode will detect it as a test case instead of a code file that contains shippable code.
  3. When I ran the test file locally, it failed on the last test case, could you please verify if this works on your machine and if yes please attach the exact command you used to run it and the complete log output of the test case as a file attachment.
  4. Question: Does this change retain the v4 support in the connector or does it erase it? E.g., if we merged this diff, would it still be able to support v4.8 Corda ledgers as well as v5 ones or only v5?

Hi @petermetz , I'll work on your requested changes for 1-2.

  1. The testing does work on my machine locally, however for it to work you need to change the endpoints on the openapi.json file and then do a yarn run codegen. This is an example of the endpoint that works
    image

The endpoints that I pushed here in this PR is using the corda connector.
image

Our expectation is that the test would pass after the connector has been published.

  1. It should still retain the support for v4.

curl -u earthling:password --insecure https://localhost:12112/api/v1/nodestatus/getnetworkreadinessstatus
curl -u plutonian:password --insecure https://localhost:12119/api/v1/nodestatus/getnetworkreadinessstatus
#Need to change since token is needed to check health status
#curl -u admin:admin --insecure https://localhost:8888/api/v1/swagger#
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have a better healthcheck here?
For example, running the listVNodes gradle task will list all the 5 nodes (4 nodes and notary server) and then parsing the output till it shows those 5 nodes up and running

fi
sleep 5;
done
touch 5vNodeSetupdone.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not required I suppose (I added it as I was testing the next part of the script i.e. deploying the cordapps)

cd /CSDE-cordapp-template-kotlin/
while true; do
echo "Waiting for startCorda to execute..."
if ./gradlew listVnodes | grep "X500"; then
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is listVNodes (not sure if gradle tasks are case sensitive or not)

"copy-yarn-lock": "cp -af ../../yarn.lock ./dist/yarn.lock",
"generate-sdk": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected"
"generate-sdk": "openapi-generator-cli generate -i ./src/main/json/openapi.json -g typescript-axios -o ./src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected",
"copy-sql": "cp -r ./src/main/sql ./dist/lib/main/",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this and the below copy-yarn-lock scripts?

cwd,
);

function extractShortHash(name: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have this function defined within the corda-v5-test-ledger.ts file? And then maybe return the shortHash of all the entities as a list (so that one can later write an equivalent function for production grade scenarios)

t.ok(startflow.status, "startFlowParameters endpoint OK");

await waitProcess(5);
await waitForStatusChange(shortHashCharlie, "test-1");
Copy link
Contributor

Choose a reason for hiding this comment

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

We can have this function also defined within the test ledgers (This helps in creating similar utilities for the production environment. For example, if the production environment is lets say Kubernetes, one can setup the corda network there and can simply look into our test-ledger class to create equivalent utilities for the kubernetes environment.)

@@ -0,0 +1,348 @@
import test, { Test } from "tape-promise/tape";
Copy link
Contributor

Choose a reason for hiding this comment

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

We will need additional code & test cases on deploying the cordapps itself (and if possible, such functions should be independent of the environment where the network is setup which in this case is docker. This helps in re-usability of same functions for production environments)

@@ -232,6 +253,35 @@ export class PluginLedgerConnectorCorda
endpoints.push(endpoint);
}

{
const opts: IListCPIEndpointV1Options = {
Copy link
Contributor

Choose a reason for hiding this comment

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

We will also need to enable/disable these endpoints based on the version specified by CordaVersion var type


try {
if (this.apiUrl === undefined) throw "apiUrl option is necessary";
const body = await this.callInternalContainer(req.body);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have connector class functions instead of calling internal container as all the nodes are exposed to the host network for now and then a single unified function within the connector class can handle GET/POST calls for all the flow related calls?

Copy link
Contributor

Choose a reason for hiding this comment

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

The same goes for all the endpoints for v5 and thus their implementation in the test case

};
const endpoint = new FlowStatusResponseEndpointV1(opts);
endpoints.push(endpoint);
}
this.log.info(`Instantiated endpoints of ${pkgName}`);
return endpoints;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Here we should have the function to call all the flow rpc calls GET/POST.. (instead of having another server client layer for the same)

@petermetz
Copy link
Contributor

@adrianbatuto How is this one going? Do you have an ETA?

@adrianbatuto
Copy link
Contributor Author

adrianbatuto commented Jan 25, 2024

@adrianbatuto How is this one going? Do you have an ETA?

Hi @petermetz, as I mentioned in the meeting earlier, I am done with the review points you have provided. I am now in progress with Jag's review points. I also think that there might be additional changes required since currently we are only able to run the test successfully using the endpoints that corda have provided, however when using the endpoints with the corda connector I am getting a 404 error. I am also expecting further review points since the reviews so far are only preliminary.

@petermetz
Copy link
Contributor

@adrianbatuto How is this one going? Do you have an ETA?

Hi @petermetz, as I mentioned in the meeting earlier, I am done with the review points you have provided. I am now in progress with Jag's review points. I also think that there might be additional changes required since currently we are only able to run the test successfully using the endpoints that corda have provided, however when using the endpoints with the corda connector I am getting a 404 error. I am also expecting further review points since the reviews so far are only preliminary.

@adrianbatuto Thank you for the updates!

@adrianbatuto
Copy link
Contributor Author

Closing this PR for now. As per discussions with @jagpreetsinghsasan there will be some significant changes to the code. Will reopen this PR or create a new one once those changes are ready for review.

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.

feat(connector-corda): support corda 5 RC via TS/HTTP (no JVM)
4 participants