Skip to content

Commit

Permalink
feat(corda): add Corda ledger support
Browse files Browse the repository at this point in the history
Primary Changes
===============

1. Corda all-in-one image

Note: In this state of it it runs the full
sample with all the nodes and web servers
which ends up using 11GB of RAM so we will
have to thin this down eventually once the
Corda connector is otherwise passing the tests
with this container. Once we are at that
point we can start removing parts of the
AIO container to reduce RAM usage and verify
that the tests are still passing without
issues or not.

2. Corda ledger connector server as a JVM app
(uses the "kotlin-spring" generator template from OpenAPI)
The only file that is non-generated in that folder is the
service implementation called ApiPluginLedgerConnectorCordaServiceImpl.kt

TODO: make sure the generated folder can be cleaned and regenerated
without having to manually re-add the implementation file mentioned
above.

3. The Typescript interfaces necessary for the NodeJS API server to
be able to communicate with the JVM app in a transparent manner where
higher level plugins can talk to Corda through the connector in Typescript
without realizing that they are actually sending HTTP requests over the
network to the JVM app.

4. Home-grown, JSON-embedded DSL is used to define the flow params.

5. Lots of to-dos still, but there are end to end tests passing
and everything is working with containers.

6. Jar deployment is only partially supported for now: if the jar
is already present on the node, then calling the jar deploy endpoint
on the connector will make sure to add that jar to the classpath of
the connector as well. If however the jar is not deployed on the corda
node itself then it will no work just yet because the SSH connection
is not yet implemented in the corda connector.

Signed-off-by: Peter Somogyvari <[email protected]>
  • Loading branch information
petermetz committed Mar 5, 2021
1 parent d856f71 commit 5623369
Show file tree
Hide file tree
Showing 95 changed files with 6,727 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ cactus-openapi-spec.json
cactus-openapi-spec-*.json
.npmrc
*.log
build/
.gradle/
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"build:dev:plugin-consortium-manual": "lerna exec --stream --scope '*/*manual-consortium' -- 'del-cli dist/** && tsc --project ./tsconfig.json && webpack --env=dev --target=node --config ../../webpack.config.js'",
"build:dev:example-supply-chain-backend": "lerna exec --stream --scope '*/*example-supply-chain-b*' -- 'del-cli dist/** && tsc --project ./tsconfig.json && webpack --display-modules --env=dev --target=node --config ../../webpack.config.js'",
"build:dev:sdk": "lerna exec --stream --scope '*/*sdk' -- 'del-cli dist/** && tsc --project ./tsconfig.json && webpack --env=dev --target=node --config ../../webpack.config.js'",
"build:dev:plugin-ledger-connector-corda": "lerna exec --stream --scope '*/*connector-corda' -- 'del-cli dist/** && npm run tsc && webpack --env=dev --target=node --config ../../webpack.config.js'",
"test:plugin-ledger-connector-corda": "tap --jobs=1 --timeout=60 \"packages/cactus-*-corda/src/test/typescript/{unit,integration}/\"",
"webpack": "npm-run-all webpack:dev webpack:prod",
"webpack:dev": "lerna run webpack:dev",
"webpack:dev:web": "lerna run webpack:dev:web",
Expand Down
161 changes: 161 additions & 0 deletions packages/cactus-plugin-ledger-connector-corda/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# `@hyperledger/cactus-plugin-ledger-connector-corda`

> TODO: description
## Usage

Take a look at how the API client can be used to run transactions on a corda ledger:
`packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server.test.ts`


### Custom Configuration via Env Variables

```json
{
"cactus": {
"corda": {
"node": {
"host": "localhost"
},
"rpc": {
"port": 10006,
"username": "user1",
"password": "test"
}
}
}
}
```

```sh
SPRING_APPLICATION_JSON='{"cactus":{"corda":{"node": {"host": "localhost"}, "rpc":{"port": 10006, "username":"user1", "password": "test"}}}}' gradle test
```

```json
{
"flowFullClassName" : "net.corda.samples.example.flows.ExampleFlow${"$"}Initiator",
"flowInvocationType" : "FLOW_DYNAMIC",
"params" : [ {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.Integer"
},
"primitiveValue" : 42,
"jvmCtorArgs" : null
}, {
"jvmTypeKind" : "REFERENCE",
"jvmType" : {
"fqClassName" : "net.corda.core.identity.Party"
},
"primitiveValue" : null,
"jvmCtorArgs" : [ {
"jvmTypeKind" : "REFERENCE",
"jvmType" : {
"fqClassName" : "net.corda.core.identity.CordaX500Name"
},
"primitiveValue" : null,
"jvmCtorArgs" : [ {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "PartyB",
"jvmCtorArgs" : null
}, {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "New York",
"jvmCtorArgs" : null
}, {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "US",
"jvmCtorArgs" : null
} ]
}, {
"jvmTypeKind" : "REFERENCE",
"jvmType" : {
"fqClassName" : "org.hyperledger.cactus.plugin.ledger.connector.corda.server.impl.PublicKeyImpl"
},
"primitiveValue" : null,
"jvmCtorArgs" : [ {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "EdDSA",
"jvmCtorArgs" : null
}, {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "X.509",
"jvmCtorArgs" : null
}, {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "MCowBQYDK2VwAyEAoOv19eiCDJ7HzR9UrfwbFig7qcD1jkewKkkS4WF9kPA=",
"jvmCtorArgs" : null
} ]
} ]
} ],
"timeoutMs" : null
}
```

```json
I 16:51:01 1 Client.main - nodeDiagnosticInfo=
{
"version" : "4.6",
"revision" : "85e387ea730d9be7d6dc2b23caba1ee18305af74",
"platformVersion" : 8,
"vendor" : "Corda Open Source",
"cordapps" : [ {
"type" : "Workflow CorDapp",
"name" : "workflows-1.0",
"shortName" : "Example-Cordapp Flows",
"minimumPlatformVersion" : 8,
"targetPlatformVersion" : 8,
"version" : "1",
"vendor" : "Corda Open Source",
"licence" : "Apache License, Version 2.0",
"jarHash" : {
"offset" : 0,
"size" : 32,
"bytes" : "V7ssTw0etgg3nSGk1amArB+fBH8fQUyBwIFs0DhID+0="
}
}, {
"type" : "Contract CorDapp",
"name" : "contracts-1.0",
"shortName" : "Example-Cordapp Contracts",
"minimumPlatformVersion" : 8,
"targetPlatformVersion" : 8,
"version" : "1",
"vendor" : "Corda Open Source",
"licence" : "Apache License, Version 2.0",
"jarHash" : {
"offset" : 0,
"size" : 32,
"bytes" : "Xe0eoh4+T6fsq4u0QKqkVsVDMYSWhuspHqE0wlOlyqU="
}
} ]
}
```

## Building Docker Image Locally

The `cccs` tag used in the below example commands is a shorthand for the
full name of the container image otherwise referred to as `cactus-corda-connector-server`.

From the project root:

```sh
DOCKER_BUILDKIT=1 docker build ./packages/cactus-plugin-ledger-connector-corda/src/main-server/ -t cccs
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"flowFullClassName" : "net.corda.samples.example.flows.ExampleFlow$Initiator",
"flowInvocationType" : "FLOW_DYNAMIC",
"params" : [ {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.Integer"
},
"primitiveValue" : 42,
"jvmCtorArgs" : null
}, {
"jvmTypeKind" : "REFERENCE",
"jvmType" : {
"fqClassName" : "net.corda.core.identity.Party"
},
"primitiveValue" : null,
"jvmCtorArgs" : [ {
"jvmTypeKind" : "REFERENCE",
"jvmType" : {
"fqClassName" : "net.corda.core.identity.CordaX500Name"
},
"primitiveValue" : null,
"jvmCtorArgs" : [ {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "PartyB",
"jvmCtorArgs" : null
}, {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "New York",
"jvmCtorArgs" : null
}, {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "US",
"jvmCtorArgs" : null
} ]
}, {
"jvmTypeKind" : "REFERENCE",
"jvmType" : {
"fqClassName" : "net.corda.samples.example.PublicKeyImpl"
},
"primitiveValue" : null,
"jvmCtorArgs" : [ {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "EdDSA",
"jvmCtorArgs" : null
}, {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "java.lang.String"
},
"primitiveValue" : "X.509",
"jvmCtorArgs" : null
}, {
"jvmTypeKind" : "PRIMITIVE",
"jvmType" : {
"fqClassName" : "[B"
},
"primitiveValue" : "MCowBQYDK2VwAyEAoOv19eiCDJ7HzR9UrfwbFig7qcD1jkewKkkS4WF9kPA=",
"jvmCtorArgs" : null
} ]
} ]
} ],
"timeoutMs" : null
}
Loading

0 comments on commit 5623369

Please sign in to comment.