The future of Polkadot in Golang: Gossamer

The future of Polkadot in Golang: Gossamer

Authored by Amer Ameen

The vision behind our implementation of the Polkadot Host.

It's hard to believe that it's been almost a year since we started working on Gossamer. As they say, time flies when you're having fun!

Building Gossamer has been a journey of significant learning & growth. Having the ever elusive goal of mastering a new protocol while striving for excellence under uncertain conditions has brought our team closer together and impacted ChainSafe profoundly. Honestly, we couldn't be more grateful for the opportunity the Web3 Foundation has given us to play a significant role in the Polkadot ecosystem.

As we work towards a complete implementation, our understanding of the Polkadot ecosystem matures and our vision for how Gossamer fits into it becomes much clearer.

For those who are unfamiliar, Gossamer is an implementation of the Polkadot Host, formerly know as the Polkadot Runtime Environment. To learn more about what exactly that is, watch our introductory talk from DotCon during Berlin Blockchain Week.

Gossamer's Vision

We see Gossamer contributing to the Polkadot & blockchain ecosystems in two important ways:

  1. Creating more secure networks by building additional Polkadot & Kusama node implementations and allowing others to do the same for blockchains built with Substrate.

  2. Making blockchain development more accessible by providing a Go framework to build blockchains, including parachains for Polkadot.

More Secure Blockchains

In their blog post announcing our grant, the Web3 Foundation highlights the importance of having multiple implementations:

"Multiple implementations of Polkadot improves network resilience and adds to the decentralization of the network. The governance of the network is more democratized when multiple teams build clients which run the nodes in the network. By building the next implementation of the Polkadot protocol, ChainSafe is helping develop a robust network - meaning that if there's an issue with one client, it won't impact network availability - thus ensuring a healthy, resilient Polkadot ecosystem."

As such, once Gossamer is complete, we will use it to build node implementations of Polkadot & Kusama. In addition, for any blockchain that is built using Substrate, building an additional node implementation using Gossamer is trivial; just take your existing runtime (a Wasm blob) and plug it into Gossamer.

Innovation Made More Accessible

In the Web 2.0 paradigm, web application frameworks, such as React or Angular, have lowered the barriers to innovation; the benefits of which we reap everyday. Gossamer is an equivalent for blockchains or, in other words, it is a blockchain development framework.

By using Gossamer, you can focus on building the state transition function (i.e the logic) of the blockchain, since the networking and consensus components are already built for you. These components will be modular and configurable. If significant customization is desired, any of the modules, including networking and consensus, can be modified or reimplemented directly in Go.

While the preliminary version of Gossamer will make blockchain development more accessible, we plan to develop some key libraries that will further this mission. These will include a runtime module library and a library to help manage a parachain's connection to the Polkadot Relay Chain.

A Runtime Module LibraryWith a Polkadot Host, such as Substrate or Gossamer, in order to build a blockchain all that must be provided is the runtime of the blockchain. This runtime describes the state transition function (i.e. the logic of the blockchain) by conforming to an interface called the Runtime API. The runtime is compiled to Wasm before being stored in the state of the blockchain; this means it can be written in any language that can compile to Wasm, such as Rust, C/C++, or Go.

While it is possible to write the Runtime from scratch, Substrate has the FRAME (Framework for Runtime Aggregation of Modularized Entities): __ a Rust library containing modules (called pallets) which provide commonly used functionality, such as accounts, balances, and smart contracts. With the FRAME, a Runtime can be composed configuring these pallets and adding additional pallets for custom logic. For those of you who are familiar with Substrate already, the FRAME was previously known as the Substrate Runtime Module Library (SRML).

In order to make blockchain development more accessible, we plan to develop an equivalent library in another programming language. While Go sounds like an obvious choice to complement Gossamer, we will do further research into efficient Wasm compilation and the needs of parachain developers to make an optimal decision.

A Library to Turn a Blockchain into a ParachainBoth completely sovereign blockchains and parachains (i.e. blockchains connected to Polkadot) can be built with Gossamer. In order to connect to Polkadot as a parachain, an additional component must be developed to manage the interactions with the Polkadot Relay Chain. Essentially, this component acts as the parachain's network card by performing two key functions:

  1. It connects the parachain's collators to Polkadot validators which have been assigned to that parachain for the current block.

  2. It facilitates the exchange of key data required to validate blocks and synchronize with the relay chain.

For details on these interactions and more, please see this informative blog post on how parachain blocks flow through Polkadot.

There is a library in Rust, Cumulus, that can be used to develop this functionality for blockchains built with Substrate. We plan to build an equivalent library in Go to help blockchains built with Gossamer become parachains on Polkadot.

Current State of Gossamer

Gossamer is a modular framework, including modules for encoding, peer-to-peer networking, managing state, block production (BABE), and block finalization (GRANDPA).

Status of Major Components

Encoding: Complete ✔
Networking: Complete ✔
State Service: Integration Testing 🔜 BABE: Integration Testing 🔜 GRANDPA: In Development 🚧

What's Next

With everything implemented from the latest specification other the block finalization, we have started integration (i.e. network) testing of syncing and interoperability in parallel to the development of GRANDPA.

The integration testing will happen in series of testnet phases of increasing complexity:

  • Presently, in our first phase, we have a testnet with a single node producing blocks and multiple nodes syncing the blockchain.

  • Following a successful first phase, we will have a testnet with multiple nodes producing blocks and syncing the blockchain.

  • The final phase is a fully functional testnet where multiple nodes are producing blocks, syncing the blockchain, and participating in block finalization.

Each of these phases is an iterative process where we (i) test with comprehensive set of inputs under a variety of network conditions, (ii) identify and fix bugs and inefficiencies, (iii) and repeat this process until Gossamer performs flawlessly in all test conditions.

Initial Release

An initial version of Gossamer (version 0.1.0) will be released by the end of the quarter with a node that is able to produce blocks and sync the blockchain with other Gossamer nodes.

We also plan to have a Gossamer testnet that will run dedicated nodes built from the latest released version of Gossamer (starting with Gossamer version 0.1.0).

Learn More & Get Involved

Thank you for your interest in Gossamer! If you'd like to learn more or get involved, join our Discord and take a look at the Gossamer repo. For ideas on how to contribute, check out the issues tagged ‘Good First Issue'.


Special thanks to Ryan Christoffersen for his help with this article.

ChainSafe Systems is a blockchain research & development firm, with a focus on building infrastructure for Web3. We are actively contributing to the Ethereum, Ethereum Classic, Cosmos, Polkadot, and Filecoin ecosystems and are open to contributing to other Web3 ecosystems where we see merit. Feel free to visit our website or email info@chainsafe.io with any inquiries.