2019 Summer Mentee Project Update: Running WebAssembly Smart Contracts in Fabric

I always wondered how it is like to be an open source contributor. I always wanted to work in an open source project, but I was hesitant about where to start. The Hyperledger Mentorship Program provided me with an opportunity to begin my journey in the open source world.

I had an enjoyable experience working with my mentors Swetha Repakula, Morgan Bauer and Jay Guo. They were really encouraging and very supportive throughout the period.  Although I was very new to the tech stack we used in this internship, my mentors helped a lot and were always there to resolve my doubts. 

Project goals

Hyperledger Fabric chaincode shims are only available in Golang, javascript, and java, which may limit developers around the world. For some, learning those languages and associated skill sets are a barrier to adoption of Hyperledger Fabric. 

My internship project Fabric Chaincode Wasm enables developers to use a wide variety of source languages for developing chaincodes by introducing a WebAssembly run time to Fabric users. WebAssembly exposes lots of languages for development, including C, Rust, and many more, because they can directly compile to WebAssembly.

You can find more information, reports and demo video here: https://wiki.hyperledger.org/display/INTERN/Running+Web+Assembly+Smart+Contracts+in+Fabric

Quick Technical Summary

As part of the project, we focused on creating an integration layer for deploying WebAssembly based chaincodes on Hyperledger Fabric without having none to minimal effect on Hyperledger Fabric core code. We achieved this by creating a Golang based chaincode named as wasmcc with an embedded WebAssembly Execution VM. This chaincode also exposes shim functions for WebAssembly chaincode developers to interact with Hyperledger Fabric networks and ledgers.

Here are some quick flow diagrams on how a WebAssembly chaincode is deployed and executed using this project.

Accomplishments

  • This project gave me a great chance to really learn WebAssembly and Golang.
  • My mentors guided me on various tools and best practices for open source community such as multiple Github features, which I never knew, the thinking process and creating CI/CD pipeline for open source projects. 
  • The most challenging part would be researching on WebAssembly and looking for a feasible WebAssembly based execution engine.

What comes next

This project has vast potential. It will allow people to quickly start adopting Hyperledger Fabric who were not able to due to technical language. Likewise, businesses can quickly start using Hyperledger Fabric without having to add to their teams’ existing available skill sets. By lowering these barriers to adoption, we’ve helped make Hyperledger Fabric an even more appealing choice as a blockchain platform. These features could also help in expanding the Hyperledger community.

Few of the technical improvement for future roadmaps:

  • Create minimal interfaces for languages that can be compiled to WebAssembly
  • Expose all other shim functions such as ACL for WebAssembly chaincodes
  • Try other WebAssembly execution engines as this area is evolving daily.
  • Create more examples using languages such as python, dotnet etc.

For all my fellow aspiring open source beginners, I only have one message for you: stop thinking and start engaging. You will find lots of encouraging people to guide you further. Take that Leap of Faith!

Lastly, I would like to thank the Linux Foundation committee for starting this mentorship program. I am sure it will be a life-turning experience for all my fellow mentees like me. I am also very thankful to Min Yu, my mentors and open source contributors for making this a smooth journey for me.

Please feel free to connect with me if you are interested in contributing to this project. You can find the repository under hyperledger labs, and you can always ping me at @shubham_aggarwal at rocketchat.