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(cbdc-bridging-app): implementation of CBDC bridging example #2185

Merged

Conversation

AndreAugusto11
Copy link
Contributor

@AndreAugusto11 AndreAugusto11 commented Nov 2, 2022

This PR presents a new example to demonstrate the capabilities of Cactus. This application demonstrates a CBDC bridging between a Fabric and a Besu network using the ODAP business logic plugin, a protocol under standardization for cross-chain operations in the IETF.

The goal is to demonstrate the use of npm packages of Cactus so that anyone can build a solution such as this. (Some dependencies are not using npm packages and the Dockerfile is not functional yet since some npm packages are not available yet – an example is the ODAP plugin).

Summary of the contributions:

  • CBDC application backend (setting up and interacting with the underlying ledgers through smart contracts)
  • Add support for multiple organizations in some operations in the FabricTestLedger
  • Add support for minting some Ether to a given address in the BesuTestLedger

Future Work:

  • CBDC application frontend (UI demonstrating the use of the app). It is already built, but there are problems with the dependencies clashing with the ones of the whole project. For now, I will leave a note for the docker image (aaugusto11/cactus-example-cbdc-bridging-frontend) so that one can run the entire app and play with it.
  • A Dockerfile for the backend will be created as soon as this package is published to npm
  • More documentation will be added in the next weeks.

Depends on #2205
Depends on #2251
Depends on #2249

Signed-off-by: André Augusto andre.augusto@tecnico.ulisboa.pt

@AndreAugusto11 AndreAugusto11 force-pushed the feat-cbdc-bridging-example branch 12 times, most recently from 165607d to ecbc579 Compare November 4, 2022 12:32
@AndreAugusto11 AndreAugusto11 force-pushed the feat-cbdc-bridging-example branch 8 times, most recently from d30be9f to b87ed02 Compare November 13, 2022 18:34
@petermetz
Copy link
Contributor

depends on #2251 and #2249

@AndreAugusto11 I think the bot needs the dependencies declared in the PR description (e.g. the topmost comment) otherwise it won't parse it as such.
FYI: I'm updating the PR description accordingly.

@github-actions
Copy link

This PR/issue depends on:

  • hyperledger/cacti#2205
  • hyperledger/cacti#2251
  • hyperledger/cacti#2249
    By Dependent Issues (🤖). Happy coding!

@petermetz petermetz self-requested a review August 16, 2023 01:35
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.

@AndreAugusto11 I've just rebased onto upstream/main and fixed some of the minor bugs that were blocking the testing the basic functionality.
There is one issue remaining that happens when I use the "bridge out" functionality but other than that it seems to work fine through the GUI.

Could you please take a look into the logs and make a fix?

Backend Logs (Complete)

2023-08-15-cacti-cbdc-example-crash.log

The Failing Request from the GUI

http://localhost:4000/api/v1/@hyperledger/cactus-plugin-odap-hermes/clientrequest

Request Payload

{
  "clientGatewayConfiguration": { "apiHost": "http://localhost:4000" },
  "serverGatewayConfiguration": { "apiHost": "http://localhost:4100" },
  "version": "0.0.0",
  "loggingProfile": "dummyLoggingProfile",
  "accessControlProfile": "dummyAccessControlProfile",
  "applicationProfile": "dummyApplicationProfile",
  "payloadProfile": {
    "assetProfile": {
      "expirationDate": "Fri Dec 24 2060 00:00:00 GMT-0800 (Pacific Standard Time)",
      "issuer": "CB1",
      "assetCode": "CBDC1",
      "keyInformationLink": [
        "5",
        "x509::/OU=client/OU=org1/OU=department1/CN=userB::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com",
        "0xB264c626D7D09789AbfD2a431A28a054366e7b63"
      ]
    },
    "capabilities": ""
  },
  "assetProfile": {
    "expirationDate": "Fri Dec 24 2060 00:00:00 GMT-0800 (Pacific Standard Time)",
    "issuer": "CB1",
    "assetCode": "CBDC1",
    "keyInformationLink": [
      "5",
      "x509::/OU=client/OU=org1/OU=department1/CN=userB::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com",
      "0xB264c626D7D09789AbfD2a431A28a054366e7b63"
    ]
  },
  "assetControlProfile": "dummyAssetControlProfile",
  "beneficiaryPubkey": "dummyPubKey",
  "clientDltSystem": "DLT1",
  "originatorPubkey": "dummyPubKey",
  "recipientGatewayDltSystem": "DLT2",
  "recipientGatewayPubkey": "02309ff54e58748616aa81245c1a4457f11fab47dcdb45b107dbcde24ee772b609",
  "serverDltSystem": "DLT2",
  "sourceGatewayDltSystem": "DLT1",
  "clientIdentityPubkey": "",
  "serverIdentityPubkey": "",
  "maxRetries": 5,
  "maxTimeout": 5000,
  "sourceLedgerAssetID": "id",
  "recipientLedgerAssetID": "FABRIC_ASSET_ID"
}

Response Payload

{
    "message": "Internal Server Error",
    "error": "Error: OdapGateway#makeRequest(), TransferInitializationRequest message failed. 
Error: Request failed with status code 500\n    
at /home/peter/a/cacti/packages/cactus-plugin-odap-hermes/src/main/typescript/gateway/plugin-odap-gateway.ts:1216:19\n    
at runMicrotasks (<anonymous>)\n    
at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    
at async FabricOdapGateway.makeRequest (/home/peter/a/cacti/packages/cactus-plugin-odap-hermes/src/main/typescript/gateway/plugin-odap-gateway.ts:1212:18)\n    
at async ClientHelper.sendTransferInitializationRequest (/home/peter/a/cacti/examples/cactus-example-cbdc-bridging-backend/src/main/typescript/odap-extension/client-helper.ts:133:5)\n    
at async FabricOdapGateway.runOdap (/home/peter/a/cacti/packages/cactus-plugin-odap-hermes/src/main/typescript/gateway/plugin-odap-gateway.ts:1115:5)\n   
at async ClientRequestEndpointV1.handleRequest (/home/peter/a/cacti/packages/cactus-plugin-odap-hermes/src/main/typescript/web-services/client-side/client-request-endpoint.ts:89:7)"
}

cc: @RafaelAPB

@AndreAugusto11 AndreAugusto11 force-pushed the feat-cbdc-bridging-example branch 3 times, most recently from 80945ae to d941445 Compare August 16, 2023 13:13
@AndreAugusto11
Copy link
Contributor Author

@petermetz thank you for your help in all the PRs. The bug is fixed!!

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.

@AndreAugusto11 You seem to have broken the build ;-(

Error: examples/cactus-example-cbdc-bridging-backend/src/main/typescript/odap-extension/server-helper.ts(55,48): error TS2339: Property 'TransferInitialization' does not exist on type 'typeof OdapMessageType'.

@petermetz
Copy link
Contributor

@AndreAugusto11 OK, I figured it out, it was the enum property that I renamed originally, put it back how it was!

@AndreAugusto11
Copy link
Contributor Author

@petermetz yes, that's right, sorry

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.

@AndreAugusto11 No worries, glad we figured it out finally!
I retested it now and it works on my machine!
The only small bug I saw (for future reference) is that the bridge's balance is unchanged on the left after I do a bridge out to send money to the right (I assumed the balance of it should be decreased on the UI)

@petermetz petermetz enabled auto-merge (rebase) August 17, 2023 01:29
This application demonstrates a CBDC bridging between a Fabric and a Besu network
using the ODAP business logic plugin, a protocol under standardization for cross-chain
asset transfers in the IETF.

The goal is to demonstrate the use of npm packages of Cactus so that anyone can
build a solution on top of Cacti.

Summary:
* CBDC application backend (set up underlying ledgers and deployment of smart contracts)
* Add support for multiple organizations in some operations in the FabricTestLedger
* Add support for minting some Ether to a given address in the BesuTestLedger

Future Work:
* CBDC app UI demonstrating the use of the app is, for now, only available as docker image
* A Dockerfile for the backend will be created as soon as this package is published to npm
* More documentation will be added in the next weeks

Depends on: hyperledger-cacti#2205

Co-authored-by: Peter Somogyvari <peter.somogyvari@accenture.com>

Signed-off-by: André Augusto <andre.augusto@tecnico.ulisboa.pt>
Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
@petermetz petermetz merged commit ca1b3be into hyperledger-cacti:main Aug 17, 2023
107 of 117 checks passed
@AndreAugusto11
Copy link
Contributor Author

@AndreAugusto11 No worries, glad we figured it out finally! I retested it now and it works on my machine! The only small bug I saw (for future reference) is that the bridge's balance is unchanged on the left after I do a bridge out to send money to the right (I assumed the balance of it should be decreased on the UI)

@petermetz The balance is only updated when we refresh the page (the GET request is done once every page load). That's certainly something to improve. I'm not sure if that's the case you're referring to, but I'll take a look anyway 😀

@petermetz
Copy link
Contributor

@AndreAugusto11 No worries, glad we figured it out finally! I retested it now and it works on my machine! The only small bug I saw (for future reference) is that the bridge's balance is unchanged on the left after I do a bridge out to send money to the right (I assumed the balance of it should be decreased on the UI)

@petermetz The balance is only updated when we refresh the page (the GET request is done once every page load). That's certainly something to improve. I'm not sure if that's the case you're referring to, but I'll take a look anyway 😀

@AndreAugusto11 It stayed that way after page refresh as well :-(
Let me know if you can't reproduce it and I'll look into it some more (extract logs, etc.)

@AndreAugusto11
Copy link
Contributor Author

AndreAugusto11 commented Aug 28, 2023

@AndreAugusto11 No worries, glad we figured it out finally! I retested it now and it works on my machine! The only small bug I saw (for future reference) is that the bridge's balance is unchanged on the left after I do a bridge out to send money to the right (I assumed the balance of it should be decreased on the UI)

@petermetz The balance is only updated when we refresh the page (the GET request is done once every page load). That's certainly something to improve. I'm not sure if that's the case you're referring to, but I'll take a look anyway 😀

@AndreAugusto11 It stayed that way after page refresh as well :-( Let me know if you can't reproduce it and I'll look into it some more (extract logs, etc.)

@petermetz I have tested it again, I think I got it! So, when doing a bridge out the bridge contract in the source chain still has funds because it functions as an escrow. The funds are kept locked in the source chain and a representation is minted in the target chain. This is actually a good indicator that we need some documentation to go along with the implementation.

If you believe it is useful, I can also write a small section talking about the example in the whitepaper. What do you think?

@petermetz
Copy link
Contributor

If you believe it is useful, I can also write a small section talking about the example in the whitepaper. What do you think?

@AndreAugusto11 I like the idea but the whitepaper is currently out of commission until we have time to renovate/update it properly. What I'd recommend is extending the README.md file of the example itself with this information and once the whitepaper is back online we can add the same info there as well!

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