1

I'm trying to debug a simple codechain that is created by default by the IBM blockchain platform plugin for VS Code.

Looks like I'm doing everything correctly but breakpoints are not working.

Steps to reproduce:

  1. Open .ts file and set brake points
  2. archive, deploy and instantiate code chain (BTW, based on the documentation you don't need to do this but, If I'm not doing this, I'm not getting a list of code chain methods on the next step)
  3. Run debugger, choose "pickup brakepoints" enter image description here
  4. in this step I see red light. (Looks like it's ok so far)
  5. click blockchain icon, "Submit Transaction" > select method > enter > enter (I don't need any arguments to execute this method)

Transaction successfully submitted. Brake points are not working. What I'm missing or doing wrong?

enter image description here

OS: MacOS Language: TypeScript IBM plugin version: 2.0.1 Docker image ibmcom/ibp-microfab:0.0.8

Hmm... is it just a bug?

P.S. If I'll choose "Manual" (Run until manually stopped) I guess I have to have "debugger" in my chain code right? anyway it's not working.

Any help?

Lasharela
  • 1,307
  • 1
  • 11
  • 23
  • Use of a debugger is not possible in the 2.0.1 extension. It's called out in the release notes in the `notes` section. https://github.com/IBM-Blockchain/blockchain-vscode-extension/releases/tag/v2.0.1 – david_k Feb 21 '21 at 22:26
  • Thanks... It supposes to work for 1.4 but it's not. Maybe there is any way to debug anyhow? (Without IBM plugin?) – Lasharela Feb 22 '21 at 22:58
  • Debug should work in the 1.0 version of the extension (which uses fabric 1.4 as the internal provided fabric). AFAIK fabric 2.2 didn't support dev mode which is required in order to be able to use a debugger with chaincode. It re-appeared in fabric 2.3 https://hyperledger-fabric.readthedocs.io/en/release-2.3/peer-chaincode-devmode.html so you could setup your own fabric environment with 2.3 to be able to use a debugger. – david_k Feb 23 '21 at 13:07
  • Thanks. This was helpful. === The benefit of running the peer in DevMode is that you can now iteratively make updates to your smart contract, save your changes, build the chaincode, and then start it again using the steps above. You do not need to run the peer lifecycle commands to update the chaincode every time you make a change. === That's grate that you can run code with just save but is there any way to use brakepoints? – Lasharela Feb 24 '21 at 16:36
  • As you are running node chaincode by running node yourself, you can look at https://code.visualstudio.com/docs/nodejs/nodejs-debugging to see how to debug a node process – david_k Feb 24 '21 at 18:28
  • Is there any update on this thread? I would like to debug my chaincode but it seems it is not possible – Riki95 Jan 22 '22 at 18:01

1 Answers1

1

Please check out the Hyperledger Fabric Debugger which supports both Go and Node.js chaincode debugging at this time.