Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(connector-corda): enable Flow Database Access CorDapp
Browse files Browse the repository at this point in the history
Added new corda-all-in-one image for flow-database-access sample

Modified Corda main-server image to allow calls to invoke without
executing any transaction.

Modified Corda InvokeContractV1Response to add the new flowId
field to return the flow handle id instead of use the callOutput
field, which now is used for the data returned by the flow. The
transactionId is not required because we can call invoke without
executing any transaction.

Resolves hyperledger-cacti#1493

Signed-off-by: Elena Izaguirre <e.izaguirre.equiza@accenture.com>
elenaizaguirre committed Dec 13, 2021

Verified

This commit was signed with the committer’s verified signature.
Lord-Kamina Gregorio Litenstein
1 parent 5513848 commit cf59b18
Showing 33 changed files with 895 additions and 55 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@
"execa",
"faio",
"fidm",
"flowdb",
"fsouza",
"GETHKEYCHAINPASSWORD",
"ghcr",
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -178,6 +178,18 @@ jobs:
- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-corda-all-in-one-obligation
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/corda-all-in-one/ -f ./tools/docker/corda-all-in-one/corda-v4_8/Dockerfile

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

- name: ghcr.io/hyperledger/cactus-corda-all-in-one-flowdb
run: DOCKER_BUILDKIT=1 docker build ./tools/docker/corda-all-in-one/corda-v4_8-flowdb/

- name: Print Disk Usage Reports
run: df ; echo "" ; docker system df

# Skipping this one for now because it keeps making the CI fail most likely due to DockerHub rate limits.
# TODO: Recommend the Fabric maintainers that they publish their images to ghcr.io as well or ask how can the
# image registry be overridden in Fabric samples.
1 change: 1 addition & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -60,6 +60,7 @@ files:
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server-v4.8.test.ts
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes.test.ts
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes-v4.8.test.ts
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/flow-database-access-v4.8.test.ts
- ./packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server.test.ts
- ./packages/cactus-plugin-keychain-google-sm/src/test/typescript/integration/plugin-factory-keychain.test.ts
- ./packages/cactus-plugin-keychain-google-sm/src/test/typescript/integration/plugin-keychain-google-sm.test.ts
1 change: 1 addition & 0 deletions jest.config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -2,8 +2,8 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

val corda_release_group = "net.corda"
val corda_core_release_group = "net.corda"
val corda_release_version = "4.5"
val corda_core_release_version = "4.5"
val corda_release_version = "4.6"
val corda_core_release_version = "4.6"
val corda_platform_version = 5

tasks.named<Test>("test") {
Original file line number Diff line number Diff line change
@@ -78,6 +78,49 @@ class ApiPluginLedgerConnectorCordaServiceImpl(
val returnValue = flowHandle.returnValue.get(timeoutMs, TimeUnit.MILLISECONDS)
val id = flowHandle.id

// allow returnValue to be something different to SignedTransaction
var callOutput: kotlin.Any = ""
var transactionId: kotlin.String? = null

if (returnValue is SignedTransaction) {
logger.trace("returnValue is SignedTransaction - using returnValue.id.toString() ...");
transactionId = returnValue.id.toString();

callOutput = mapOf(
"tx" to mapOf(
"id" to returnValue.tx.id,
"notary" to returnValue.tx.notary,
"requiredSigningKeys" to returnValue.tx.requiredSigningKeys,
"merkleTree" to returnValue.tx.merkleTree,
"privacySalt" to returnValue.tx.privacySalt,
"attachments" to returnValue.tx.attachments,
"commands" to returnValue.tx.commands,
// "digestService" to returnValue.tx.digestService,
"inputs" to returnValue.tx.inputs,
"networkParametersHash" to returnValue.tx.networkParametersHash,
"references" to returnValue.tx.references,
"timeWindow" to returnValue.tx.timeWindow
),
"id" to returnValue.id,
"inputs" to returnValue.inputs,
"networkParametersHash" to returnValue.networkParametersHash,
"notary" to returnValue.notary,
"references" to returnValue.references,
"requiredSigningKeys" to returnValue.requiredSigningKeys,
"sigs" to returnValue.sigs
);

} else if (returnValue != null) {
callOutput = try {
val returnValueJson = writer.writeValueAsString(returnValue);
logger.trace("returnValue JSON serialized OK, using returnValue ...");
returnValueJson;
} catch (ex: Exception) {
logger.trace("returnValue JSON serialized failed, using returnValue.toString() ...");
returnValue.toString();
}
}

logger.info("Progress(${progress.size})={}", progress)
logger.info("ReturnValue={}", returnValue)
logger.info("Id=$id")
@@ -96,7 +139,7 @@ class ApiPluginLedgerConnectorCordaServiceImpl(
// org.hyperledger.cactus.plugin.ledger.connector.corda.server.model.InvokeContractV1Response["returnValue"]->
// net.corda.client.jackson.internal.StxJson["wire"]->net.corda.client.jackson.internal.WireTransactionJson["outputs"])]
// with root cause
return InvokeContractV1Response(true, id.toString(), (returnValue as SignedTransaction).id.toString(), progress)
return InvokeContractV1Response(true, callOutput, id.toString(), transactionId, progress)
}

// FIXME - make it clear in the documentation that this deployment endpoint is not recommended for production
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@ import javax.validation.Valid
/**
*
* @param success
* @param callOutput
* @param callOutput Data returned from the JVM when no transaction is running
* @param flowId The id for the flow handle
* @param transactionId The net.corda.core.flows.StateMachineRunId value returned by the flow execution.
* @param progress An array of strings representing the aggregated stream of progress updates provided by a *tracked* flow invocation. If the flow invocation was not tracked, this array is still returned, but as empty.
*/
@@ -25,8 +26,10 @@ data class InvokeContractV1Response(
@field:Valid
@field:JsonProperty("callOutput", required = true) val callOutput: kotlin.Any,

@field:JsonProperty("flowId", required = true) val flowId: kotlin.String,

@get:Size(min=1,max=1024)
@field:JsonProperty("transactionId", required = true) val transactionId: kotlin.String,
@field:JsonProperty("transactionId") val transactionId: kotlin.String? = null,

@field:JsonProperty("progress") val progress: kotlin.collections.List<kotlin.String>? = null
) {
Original file line number Diff line number Diff line change
@@ -455,16 +455,17 @@
"type": "object",
"required": [
"success",
"transactionId",
"callOutput"
"callOutput",
"flowId"
],
"properties": {
"success": {
"type": "boolean",
"nullable": false
},
"callOutput": {
"type": "object"
"type": "object",
"description": "Data returned from the JVM when no transaction is running"
},
"transactionId": {
"type": "string",
@@ -482,6 +483,10 @@
"maxItems": 10e6
},
"default": []
},
"flowId": {
"type": "string",
"description": "The id for the flow handle"
}
}
},
Original file line number Diff line number Diff line change
@@ -368,7 +368,7 @@ export interface InvokeContractV1Response {
*/
success: boolean;
/**
*
* Data returned from the JVM when no transaction is running
* @type {object}
* @memberof InvokeContractV1Response
*/
@@ -378,13 +378,19 @@ export interface InvokeContractV1Response {
* @type {string}
* @memberof InvokeContractV1Response
*/
transactionId: string;
transactionId?: string;
/**
* An array of strings representing the aggregated stream of progress updates provided by a *tracked* flow invocation. If the flow invocation was not tracked, this array is still returned, but as empty.
* @type {Array<string>}
* @memberof InvokeContractV1Response
*/
progress?: Array<string>;
/**
* The id for the flow handle
* @type {string}
* @memberof InvokeContractV1Response
*/
flowId: string;
}
/**
*
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ test.skip("Tests are passing on the JVM side", async (t: Test) => {
const connector = new CordaConnectorContainer({
logLevel,
imageName: "ghcr.io/hyperledger/cactus-connector-corda-server",
imageVersion: "2021-11-11",
imageVersion: "2021-11-23--feat-1493",
envVars: [envVarSpringAppJson],
});
t.ok(CordaConnectorContainer, "CordaConnectorContainer instantiated OK");
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ test.skip("Tests are passing on the JVM side", async (t: Test) => {
const connector = new CordaConnectorContainer({
logLevel,
imageName: "ghcr.io/hyperledger/cactus-connector-corda-server",
imageVersion: "2021-11-11",
imageVersion: "2021-11-23--feat-1493",
envVars: [envVarSpringAppJson],
});
t.ok(CordaConnectorContainer, "CordaConnectorContainer instantiated OK");
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ test.skip("Tests are passing on the JVM side", async (t: Test) => {
const connector = new CordaConnectorContainer({
logLevel,
imageName: "ghcr.io/hyperledger/cactus-connector-corda-server",
imageVersion: "2021-11-11",
imageVersion: "2021-11-23--feat-1493",
envVars: [envVarSpringAppJson],
});
t.ok(CordaConnectorContainer, "CordaConnectorContainer instantiated OK");
Original file line number Diff line number Diff line change
@@ -106,9 +106,7 @@ test.skip("Tests are passing on the JVM side", async (t: Test) => {
const connector = new CordaConnectorContainer({
logLevel,
imageName: "ghcr.io/hyperledger/cactus-connector-corda-server",
imageVersion: "2021-11-11",
// imageName: "cccs",
// imageVersion: "latest",
imageVersion: "2021-11-23--feat-1493",
envVars: [envVarSpringAppJson],
});
t.ok(CordaConnectorContainer, "CordaConnectorContainer instantiated OK");
Loading

0 comments on commit cf59b18

Please sign in to comment.