Technology

Spydra's Fabric Debugger: Developer's Mate in Blockchain Troubleshooting

JavaScript frameworks make development easy with extensive features and functionalities. Here are our top 10 to use in 2022.
Written by
Shivani Tripathi
Published on
December 27, 2023

Blockchain development, particularly with Hyperledger Fabric, can be a complex and time-consuming process. Setting up a Fabric environment, deploying Chaincode, and debugging it can involve various intricate steps. Enter Spydra's Fabric Debugger, a powerful open-source extension for Visual Studio Code, designed to simplify and streamline the development and debugging process for Hyperledger Fabric Chaincode.

Quick Start Guide

Before diving into the features of Spydra's Fabric Debugger, let's get started with a quick installation and setup:

Prerequisites:

  • Docker engine version 20.10.14 or higher and Docker compose version 2.3.4 or higher
  • Visual Studio Code version 1.80.0 or higher
  • For Go Chaincode debugging, install the Go for Visual Studio Code extension
  • Open the Chaincode project in VS Code (e.g., asset-transfer-ledger-queries Go sample project)
  • For Node.js Chaincode, run npm install first

Setting up Launch Configuration

Create a launch.json file in the .vscode directory with the following configuration:

For debugging Chaincode developed for the Fabric External Chaincode as a Service model, set "isCaas": true.

Setting Breakpoints:

Set breakpoints in the code you want to debug within VS Code.

Invoking Chaincode Methods:

Create a file with a .fabric extension and add JSON objects specifying the Chaincode methods to invoke:

Starting Debugging:Press F5 to start debugging or use the Run and Debug button from the Run view.

Also Watch: Hyperledger Fabric Debugger - Demo Presentation

Features of Spydra's Fabric Debugger

  1. Debugging Support: Debug Chaincodes written in Go and Node.js (Javascript/TypeScript).Customizable launch configuration for Go ("type": "hlf-go") and Node.js ("type": "hlf-node").Supports typical debugging functionalities like setting breakpoints, stepping in/stepping over, viewing variables, and stack trace.
  2. Manage Local Fabric Network: Automatically creates a local Fabric v2.5 network with one organization, one orderer, one peer with CouchDB, and one CA node.Actions: Remove Network, Stop Network, Start Network, Restart Network. Persists ledger data across VS Code or Docker/machine restarts.
  3. Manage Wallet Identities: Creates default users for testing: 'Org1Admin' with an Admin NodeOU role and 'User1' with a Client NodeOU role. Easily create additional identities for testing. Remove identities when no longer needed.
  4. Submit Transactions to Chaincode: Easily submit queries or invoke transactions directly from VS Code.Create .fabric files specifying Chaincode methods, arguments, and identities. View responses in a separate window.
  5. Stream Chaincode Events: Captures and displays chaincode level events during execution. Events are logged in the output console.
  6. Connect to CouchDB: Easily connect to CouchDB to view documents stored by the chaincode. Simple navigation through Hyperledger Debugger Explorer.
  7. Connect to the Network from Your Application: Use the Fabric Gateway Client API for Fabric versions 2.4 and 2.5.Easy configuration settings for connecting to the local network.
  8. Using the Older Fabric Network SDK: Supports connecting to legacy as well as Chaincode as a Service mode chaincode. Additional configuration settings for connecting to the network.

FAQs and Troubleshooting

1. Debugging Go Chaincode Issues:

Ensure the file with the main() function is selected or add a "program" field in launch.json.

2. Error: 'CORE_CHAINCODE_ID_NAME' must be set:

Make sure the launch.json file is created with the correct debug settings.

3. Debugging Node.js Chaincode:

Create the launch.json file with the correct debug settings.

4. Submitting Transactions Error:

Start the Chaincode in Debug mode by pressing F5 before submitting transactions.

5. Error: "ccid must be specified":

Set "isCaas": true in launch.json for External Chaincode as a Service model.

6. Extension for Debugging 'JSON with Comments' Missing:

Create the launch.json file and start debugging again.

7. Network Startup Issues:

Reset the network through Hyperledger Fabric Debugger Explorer if continuous startup issues occur.

Spydra's Fabric Debugger is a comprehensive tool for Hyperledger Fabric developers, offering a seamless debugging experience and facilitating various network management tasks. With its rich set of features and troubleshooting support, it stands as a valuable asset in the blockchain development toolkit.

Conclusion

Spydra's Fabric Debugger emerges as a robust and comprehensive tool for Hyperledger Fabric developers, providing a wide array of features to streamline the development and debugging process. With advanced capabilities, seamless network management, and extensive troubleshooting support, developers can focus more on building robust Chaincode and less on the complexities of the development environment.

As the blockchain development landscape evolves, this Fabric Debugger stands as a reliable companion, offering not only a developer-friendly debugging experience but also empowering developers to connect seamlessly with CouchDB, manage identities, and deploy and test Chaincode effortlessly. With its ongoing development and commitment to community support, this Fabric Debugger is poised to remain a vital asset in the Hyperledger Fabric toolkit.

Latest posts

Subscribe to Our Newsletter

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.