Gossamer: Into the Polkadot-verse Pt. 3

Gossamer: Into the Polkadot-verse Pt. 3

Authored by Dan Forbes

Exploring SCALE refactors in Go, chain sync algorithms, and peer scoring in Gossamer

For those who are unfamiliar, Gossamer 🕸 ️ is an implementation of the Polkadot Host, formerly known as the Polkadot Runtime Environment. To learn more about what exactly that is, watch our introductory talk from DotCon during Berlin Blockchain Week. Amer Ameen's blog post introducing Gossamer is also a neat summary of the vision behind our implementation. Dig into the code [here](https://github.com/ChainSafe/gossamer), read the docs here, and join in the conversation on the #Gossamer-general channel on our Discord.

It's been a few months since [the last Gossamer update](https://medium.com/chainsafe-systems/gossamer-into-the-polkdot-verse-pt-2-aeb83e2add74), and we're excited to be back again with more news about the development of the Go host for the Polkadot Network that we are building at ChainSafe 💪 Keep reading to learn more about the SCALE refactor that we mentioned in our last update, as well as the other enhancements we've been working on to prepare for full participation in the Polkadot Network 🚀

SCALE Codec Refactor

A codec is a protocol that can be used to encode and decode data for purposes like message-passing and serialization to disk. Polkadot specifies a purpose-built codec called SCALE: the Simple Concatenated Aggregate Little-Endian Codec. Because of the pervasiveness of SCALE in Polkadot Host implementations such as Gossamer, it's critical for Polkadot implementers to create SCALE libraries that are ergonomic and performance-preserving 🤸

Gossamer Team Lead Timothy Wu (@timwu20 on GitHub) recently led the design and implementation of an enhanced SCALE package for Gossamer that increases the package's ergonomics by relying on idiomatic Go practices like Marshal/Unmarshal interfaces, and struct tags. Tim worked with Gossamer Engineer @jimjbrettj to integrate the new SCALE package into the Gossamer codebase.

Check out the excellent documentation for Gossamer's SCALE package to learn more! The Gossamer team is keeping a close eye on the development of generics in Go to ensure that our SCALE implementation is making use of the most cutting-edge developments in the Go language in order to ensure the aforementioned values of ergonomics and performance 🤓

Chain Synchronization

The highlight of our last update was that Gossamer nodes were fully synchronized with the Polkadot Network 👯 In this update, we're happy to tell you about all the improvements we've been making to Gossamer's chain synchronization algorithms! The chain synchronization enhancements were designed and implemented by Elizabeth (AKA @noot on GitHub), Head of Protocol Engineering at ChainSafe.

The initial goals of these changes were to make the Gossamer code more modular and maintainable by decoupling the network and sync packages, as well as to address the issues that were discovered with the initial implementation. Check out the excellent design document 🔍 to learn more about the goals of the improvements and the decisions that were made in order to achieve them. In particular, the document encapsulates research into three existing blockchain synchronization algorithms: Substrate, Parity's Rust blockchain framework that is used for their production chains like Polkadot and Statemint; smoldot, a lightweight, alternative Rust implementation of a client for the Polkadot Network; and Lotus, the official, Go implementation of the Filecoin protocol for decentralized storage.

Peer Scoring

In a decentralized network like Polkadot, "peer scoring" refers to the process that a network participant uses to prioritize the other clients that it will work with to power the network; the criteria that go into such an algorithm may include factors like responsiveness and correctness ✅

Gossamer Software Engineer Arijit Das (@arjitAD on GitHub) designed Gossamer's peer scoring algorithms by modeling them after those of Substrate, the Rust blockchain development framework that Parity Technologies maintains and is using to implement the Polkadot Network and even parachains like Statemint.

The previous section described how Gossamer's networking and syncing concerns were recently decoupled; similarly, Gossamer's peer scoring capabilities were implemented in a new peerset package that interacts mostly with the capabilities of the network package - design decisions such as this help keep the Gossamer code base modular and maintainable 🛠 ️

Other Updates

In our last update, we were excited to announce that we had achieved a full sync with the Polkadot Network - so what's next? Our next goal is to enable Gossamer clients to participate in the Polkadot Network as authority nodes 👮 This goal requires implementation of the Polkadot Host and JSON-RPC APIs. The Host APIs are the native Go functions that are invoked by Polkadot's WebAssembly runtime, which provide capabilities like storage management 💾 The JSON-RPC APIs are the interfaces that are consumed by user-facing applications like the Polkadot-JS Apps UI. The implementation of Gossamer's host and runtime APIs are being implemented by Edward Mack (@edwardmack on GitHub) and Eclésio Melo (@EclesioMeloJunior on GitHub), respectively.

Get Involved

If you are interested in getting involved and contributing to the project, check out our GitHub repository. If you would like to get in contact with one of the Gossamer team members, feel free to drop by on ChainSafe's Discord or email info@chainsafe.io. We would love to know more about you, your team and your project!

For more details on Gossamer, please head to our documentation site.

Learn more about ChainSafe by visiting our website, through our Medium, via Twitter, or visiting the ChainSafe GitHub.