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

docs(examples/cbdc): fix successful minting on chaincode results in balance 0 #2739

Closed
Anusha-Padmanabhan opened this issue Oct 4, 2023 · 10 comments · Fixed by #2802
Closed
Assignees
Labels
bug Something isn't working Developer_Experience documentation Improvements or additions to documentation P2 Priority 2: High question Further information is requested
Milestone

Comments

@Anusha-Padmanabhan
Copy link

Anusha-Padmanabhan commented Oct 4, 2023

Describe the bug

Started the app of CBDC example and front end using the commands as per the given readme.
https://github.com/hyperledger/cacti/tree/main/examples/cactus-example-cbdc-bridging-backend
I am getting the below UI,

cdbc_output

I can able to mint and see the transaction logs but after minting where I can view those tokens and what is the next step to do transfer, escrow, bridge out and in.

To Reproduce

clone the repository
cd cactus
from the root of the repository run the below commands:
npm run enable-corepack
npm run configure
npm run start:example-cbdc-bridging-app

Expected behavior

Minted token should reflect somewhere or enable the other buttons of transfer, escrow
Steps to understand the workflow of CBDC example is missing

Logs/Stack traces

Can help maintainers identify root causes

Screenshots

docker run -p 2000:2000 aaugusto11/cactus-example-cbdc-bridging-frontend

CDBC_frontend_2

npm run start:example-cbdc-bridging-app

CBDC_backend

Hyperledger Cactus release version or commit (git rev-parse --short HEAD):

Either a semantic version of the release you are using such as 1.0.0 or a git
commit hash if you are directly working with code from the git repository.

Hyperledger Cactus Plugins/Connectors Used

  • Which DLT connectors are you using (Fabric, Quorum, Corda, Besu, etc.)

Additional context

Add any other context about the problem here.

@Anusha-Padmanabhan Anusha-Padmanabhan added the bug Something isn't working label Oct 4, 2023
@Anusha-Padmanabhan Anusha-Padmanabhan changed the title Issue: CDBC example - Running the Example Application Locally Issue: CBDC example - Running the Example Application Locally Oct 4, 2023
@petermetz
Copy link
Contributor

@Anusha-Padmanabhan I'll try to answer, but @RafaelAPB and @AndreAugusto11 might have a more up to date picture on this.

I can able to mint and see the transaction logs but after minting where I can view those tokens

If you've set up the example as per the steps, then the ledgers are running on your machine, so you could observe the ledger state by querying those containers in your preferred way.

and what is the next step to do transfer, escrow, bridge out and in.

If I remember correctly you unlock those options on the UI by putting the tokes into escrow first. Let me know if this helps, in the meantime I'm closing the question as answered, but of course feel free to re-open as needed.

@petermetz petermetz closed this as not planned Won't fix, can't repro, duplicate, stale Oct 4, 2023
@petermetz petermetz added question Further information is requested and removed bug Something isn't working labels Oct 4, 2023
@petermetz petermetz self-assigned this Oct 4, 2023
@Anusha-Padmanabhan
Copy link
Author

@petermetz Thanks for the response, But the escrow button is not enabled after minting and token balance is also not reflecting in the screen.
Attaching the screenshot after minting.
token_reflection

I believe, once after minting escrow and transfer buttons should get enabled and minted token balance also should be visible in the screen.

@petermetz
Copy link
Contributor

petermetz commented Oct 5, 2023

@Anusha-Padmanabhan I went ahead and re-did the steps as well, it won't re-enable.
The minting seems to succeed but then as the UI calls the balanceOf method of the contract, that returns 0 after the successful minting anyway. Looks like this got broken somewhere along the way so I'm re-opening this as a bug.

cc: @RafaelAPB @AndreAugusto11

Also closing the other one you opened as a duplicate.

@petermetz petermetz reopened this Oct 5, 2023
@petermetz petermetz changed the title Issue: CBDC example - Running the Example Application Locally docs(examples/cbdc): fix successful minting on chaincode results in balance 0 Oct 5, 2023
@petermetz petermetz added bug Something isn't working documentation Improvements or additions to documentation Developer_Experience P2 Priority 2: High labels Oct 5, 2023
@petermetz petermetz added this to the v2.0.0 milestone Oct 5, 2023
@AndreAugusto11
Copy link
Contributor

Hi @petermetz and @Anusha-Padmanabhan thank you for your feedback. I will have a look at this asap, and ping you here

@petermetz
Copy link
Contributor

Hi @petermetz and @Anusha-Padmanabhan thank you for your feedback. I will have a look at this asap, and ping you here

@AndreAugusto11 Nice, thank you very much for helping!!!

@AndreAugusto11
Copy link
Contributor

@petermetz this is definitely a strange one. I checked the chaincode container logs, and the tokens are being minted correctly. So, the problem is in the GET request, which is always returning 0. I haven't changed anything in the code, have there been any breaking changes that might be causing this (also in the Fabric all in one image)?

@petermetz
Copy link
Contributor

@petermetz this is definitely a strange one. I checked the chaincode container logs, and the tokens are being minted correctly. So, the problem is in the GET request, which is always returning 0. I haven't changed anything in the code, have there been any breaking changes that might be causing this (also in the Fabric all in one image)?

@AndreAugusto11 I also checked the chaincode container logs and the computed state keys are inconsistent so something is off with the minting configuration IMO.
If you log the keys in the contract then you'll see that the Mint and the BalanceOf methods generate different state keys such as shown below (observe the first 2 components being swapped)
They are technically identical identities, but the contract uses plain strings for the state keys so they end up being different anyway and that's why the BalanceOf can't find the tokens of the identity that were minted.

x509::/OU=org1/OU=client/OU=department1/CN=userA::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com
x509::/OU=client/OU=org1/OU=department1/CN=userA::/C=US/ST=North Carolina/L=Durham/O=org1.example.com/CN=ca.org1.example.com

@AndreAugusto11
Copy link
Contributor

AndreAugusto11 commented Oct 17, 2023

@petermetz thanks for providing those logs.

So, the Mint function calculates the clientID dynamically based on the request, and the BalanceOf function receives as an argument the clientID provided by the front end. For some reason, those identities got mismatched. I have updated the code such that the Mint function receives the identity just like the Balance function does.

I haven't tested because I'm having some issues with my GCP VM (and can't do it in my M1), can you do it @Anusha-Padmanabhan?

petermetz pushed a commit to AndreAugusto11/cacti that referenced this issue Oct 18, 2023
…equests

The state keys were not being generated correctly for some reason
It was working before without code changes so my best guess is that
the Fabric ledger/SDK versions were changed and that's what tripped it
up somehow.

Fixes hyperledger-cacti#2739

[skip ci]

Co-authored-by: Peter Somogyvari <[email protected]>

Signed-off-by: André Augusto <[email protected]>
Signed-off-by: Peter Somogyvari <[email protected]>
@Anusha-Padmanabhan
Copy link
Author

Sure @AndreAugusto11, I will test and let you know..

sandeepnRES pushed a commit to AndreAugusto11/cacti that referenced this issue Oct 18, 2023
…equests

The state keys were not being generated correctly for some reason
It was working before without code changes so my best guess is that
the Fabric ledger/SDK versions were changed and that's what tripped it
up somehow.

Fixes hyperledger-cacti#2739

[skip ci]

Co-authored-by: Peter Somogyvari <[email protected]>

Signed-off-by: André Augusto <[email protected]>
Signed-off-by: Peter Somogyvari <[email protected]>
sandeepnRES pushed a commit that referenced this issue Oct 18, 2023
…equests

The state keys were not being generated correctly for some reason
It was working before without code changes so my best guess is that
the Fabric ledger/SDK versions were changed and that's what tripped it
up somehow.

Fixes #2739

[skip ci]

Co-authored-by: Peter Somogyvari <[email protected]>

Signed-off-by: André Augusto <[email protected]>
Signed-off-by: Peter Somogyvari <[email protected]>
@Anusha-Padmanabhan
Copy link
Author

Hi @petermetz @AndreAugusto11
Could you please share the node and npm version you have used to test the cbdc app, Since I am getting the following error once after starting the app using the command "npm run start:example-cbdc-bridging-app".

Error_path_not found

AndreAugusto11 added a commit to AndreAugusto11/cacti that referenced this issue Dec 2, 2023
* What I believe has been an update to the Fabric SDK
has led the application to break due to having the Fabric
identities hardcoded (for the Fabric-Ethereum ID mapping).
This was first noted in hyperledger-cacti#2739

* An initial fix was deployed in hyperledger-cacti#2802 but only the Mint
was changed, which caused other functions to be breaking
at the moment (e.g., Escrow)

This commit changes the crypto material files and reverts
the workaround in PR hyperledger-cacti#2802

* The crypto material is only used for testing and to show
information in the frontend (e.g., requesting the balance
of a specific user based on the identity)

* For critical operations, access control is being
performed by the chaincode by using the call at the
begining of the relevant methods

Fixes hyperledger-cacti#2914
AndreAugusto11 pushed a commit to AndreAugusto11/cacti that referenced this issue Dec 2, 2023
* What I believe has been an update to the Fabric SDK
has led the application to break due to having the Fabric
identities hardcoded (for the Fabric-Ethereum ID mapping).
This was first noted in hyperledger-cacti#2739

* An initial fix was deployed in hyperledger-cacti#2802 but only the Mint
was changed, which caused other functions to be breaking
at the moment (e.g., Escrow)

* This commit changes the crypto material files and reverts
the workaround in PR hyperledger-cacti#2802

* The crypto material is only used for testing and to show
information in the frontend (e.g., requesting the balance
of a specific user based on the identity)

* For critical operations, access control is being
performed by the chaincode by using the call at the
begining of the relevant methods

Fixes hyperledger-cacti#2914
AndreAugusto11 pushed a commit to AndreAugusto11/cacti that referenced this issue Dec 2, 2023
* What I believe has been an update to the Fabric SDK
has led the application to break due to having the Fabric
identities hardcoded (for the Fabric-Ethereum ID mapping).
This was first noted in hyperledger-cacti#2739

* An initial fix was deployed in hyperledger-cacti#2802 but only the Mint
was changed, which caused other functions to be breaking
at the moment (e.g., Escrow)

* This commit changes the crypto material files and reverts
the workaround in PR hyperledger-cacti#2802

* The crypto material is only used for testing and to show
information in the frontend (e.g., requesting the balance
of a specific user based on the identity)

* For critical operations, access control is being
performed by the chaincode by using the call at the
begining of the relevant methods

Fixes hyperledger-cacti#2914

Signed-off-by: André Augusto <[email protected]>
AndreAugusto11 added a commit to AndreAugusto11/cacti that referenced this issue Dec 2, 2023
* What I believe has been an update to the Fabric SDK
has led the application to break due to having the Fabric
identities hardcoded (for the Fabric-Ethereum ID mapping).
This was first noted in hyperledger-cacti#2739

* An initial fix was deployed in hyperledger-cacti#2802 but only the Mint
was changed, which caused other functions to be breaking
at the moment (e.g., Escrow)

* This commit changes the crypto material files and reverts
the workaround in PR hyperledger-cacti#2802

* The crypto material is only used for testing and to show
information in the frontend (e.g., requesting the balance
of a specific user based on the identity)

* For critical operations, access control is being
performed by the chaincode by using the call at the
begining of the relevant methods

Fixes hyperledger-cacti#2914

Signed-off-by: André Augusto <[email protected]>
AndreAugusto11 added a commit to AndreAugusto11/cacti that referenced this issue Dec 3, 2023
* What I believe has been an update to the Fabric SDK
has led the application to break due to having the Fabric
identities hardcoded (for the Fabric-Ethereum ID mapping).
This was first noted in hyperledger-cacti#2739

* An initial fix was deployed in hyperledger-cacti#2802 but only the Mint
was changed, which caused other functions to be breaking
at the moment (e.g., Escrow)

* This commit changes the crypto material files and reverts
the workaround in PR hyperledger-cacti#2802

* The crypto material is only used for testing and to show
information in the frontend (e.g., requesting the balance
of a specific user based on the identity)

* For critical operations, access control is being
performed by the chaincode by using the call at the
begining of the relevant methods

Fixes hyperledger-cacti#2914

Signed-off-by: André Augusto <[email protected]>
AndreAugusto11 added a commit to AndreAugusto11/cacti that referenced this issue Dec 3, 2023
* What I believe has been an update to the Fabric SDK
has led the application to break due to having the Fabric
identities hardcoded (for the Fabric-Ethereum ID mapping).
This was first noted in hyperledger-cacti#2739

* An initial fix was deployed in hyperledger-cacti#2802 but only the Mint
was changed, which caused other functions to be breaking
at the moment (e.g., Escrow)

* This commit changes the crypto material files and reverts
the workaround in PR hyperledger-cacti#2802

* The crypto material is only used for testing and to show
information in the frontend (e.g., requesting the balance
of a specific user based on the identity)

* For critical operations, access control is being
performed by the chaincode by using the call at the
begining of the relevant methods

Fixes hyperledger-cacti#2914

Signed-off-by: André Augusto <[email protected]>
petermetz pushed a commit to AndreAugusto11/cacti that referenced this issue Dec 5, 2023
* What I believe has been an update to the Fabric SDK
has led the application to break due to having the Fabric
identities hardcoded (for the Fabric-Ethereum ID mapping).
This was first noted in hyperledger-cacti#2739

* An initial fix was deployed in hyperledger-cacti#2802 but only the Mint
was changed, which caused other functions to be breaking
at the moment (e.g., Escrow)

* This commit changes the crypto material files and reverts
the workaround in PR hyperledger-cacti#2802

* The crypto material is only used for testing and to show
information in the frontend (e.g., requesting the balance
of a specific user based on the identity)

* For critical operations, access control is being
performed by the chaincode by using the call at the
begining of the relevant methods

Fixes hyperledger-cacti#2914

Signed-off-by: André Augusto <[email protected]>
petermetz pushed a commit that referenced this issue Dec 5, 2023
* What I believe has been an update to the Fabric SDK
has led the application to break due to having the Fabric
identities hardcoded (for the Fabric-Ethereum ID mapping).
This was first noted in #2739

* An initial fix was deployed in #2802 but only the Mint
was changed, which caused other functions to be breaking
at the moment (e.g., Escrow)

* This commit changes the crypto material files and reverts
the workaround in PR #2802

* The crypto material is only used for testing and to show
information in the frontend (e.g., requesting the balance
of a specific user based on the identity)

* For critical operations, access control is being
performed by the chaincode by using the call at the
begining of the relevant methods

Fixes #2914

Signed-off-by: André Augusto <[email protected]>
sandeepnRES pushed a commit to sandeepnRES/cacti that referenced this issue Dec 21, 2023
…equests

The state keys were not being generated correctly for some reason
It was working before without code changes so my best guess is that
the Fabric ledger/SDK versions were changed and that's what tripped it
up somehow.

Fixes hyperledger-cacti#2739

[skip ci]

Co-authored-by: Peter Somogyvari <[email protected]>

Signed-off-by: André Augusto <[email protected]>
Signed-off-by: Peter Somogyvari <[email protected]>
sandeepnRES pushed a commit to sandeepnRES/cacti that referenced this issue Dec 21, 2023
* What I believe has been an update to the Fabric SDK
has led the application to break due to having the Fabric
identities hardcoded (for the Fabric-Ethereum ID mapping).
This was first noted in hyperledger-cacti#2739

* An initial fix was deployed in hyperledger-cacti#2802 but only the Mint
was changed, which caused other functions to be breaking
at the moment (e.g., Escrow)

* This commit changes the crypto material files and reverts
the workaround in PR hyperledger-cacti#2802

* The crypto material is only used for testing and to show
information in the frontend (e.g., requesting the balance
of a specific user based on the identity)

* For critical operations, access control is being
performed by the chaincode by using the call at the
begining of the relevant methods

Fixes hyperledger-cacti#2914

Signed-off-by: André Augusto <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Developer_Experience documentation Improvements or additions to documentation P2 Priority 2: High question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants