Realizing the Mina vision in Rust

Realizing the Mina vision in Rust

Authored by Ben Adar

Announcing a new grant from the Mina Foundation

ChainSafe is proud to announce we have been awarded a grant by the Mina Foundation to build an additional implementation of the Mina Protocol to improve the network's resilience and accessibility. The grant will serve as an extension to our already existent work with O(1) Labs to audit and optimize Mina's network layer.

This new implementation will be written in Rust and then compiled into Wasm (WebAssembly) to enable execution in browser environments. Wasm bytecode is compatible with most browsers (desktop or mobile) and enables high-performance applications to be embedded in web pages. The team decided on Rust as it is a multifaceted language with secure memory safety and high performance, and has great support for Wasm.

After completing the alternative Rust implementation, Mina will be more accessible than ever before. ChainSafe is looking forward to contributing to the re-implementation of the protocol and expanding the network!

But what is Mina?

Mina is the world's lightest blockchain that creates a private gateway between the real world and crypto. Mina does not rely on expensive hardware like many larger blockchains; instead, it uses an advanced cryptographic technique called recursive zk-SNARKs (Zero-Knowledge Succinct Non-Interactive Argument of Knowledge) to ensure scalability and privacy.

zk-SNARKS can be used to prove some piece of information without actually having to reveal what the information is. Every time Mina produces a block, it also generates a SNARK proof. The proof, which confirms the block's validity, is then the only thing stored by the nodes and can be used to prove the current state of the chain.

How the Mina protocol stays 22 kb

SNARKS provide the users with anonymity, and since only proof of the data is necessary to store on chain, the storage requirements are minimal. At 22 kb, Mina is the world's lightest blockchain needing only the single proof verification to sync a new Mina node. For scale, a new node attempting to sync up to the current state of the Bitcoin or Ethereum blockchains would have to download and verify over 300+ GB of historical blocks to ensure validity of the ledger.

Mina aims to provide a robust and accessible blockchain that anyone can access anywhere, including on smartphones, laptops, and in-browser. Standing apart from the data-heavy blockchains, Mina provides a global, scalable ecosystem by creating "a vibrant decentralized network and open, programmable currency - so we can all participate, build, exchange and thrive."

The Mina Networking Stack

Mina uses libp2p to implement its networking stack. libp2p is "a modular system of protocols, specifications and libraries that enable the development of peer-to-peer network applications." On a basic level, libp2p provides tools and infrastructure to construct trust-less systems. Mina's reference implementation is written in OCaml, while the networking layer is in Go. The daemon sends encoded messages to the libp2p helper detailing what it wants the helper to do. The helper can also send messages back to the daemon using upcalls. Through these processes, the network's OCaml and Go side can communicate with each other.

Our Other Work on Mina

Initially, the ChainSafe team was focused on auditing and improving the libp2p network component of the OCaml implementation. The team was then able to identify opportunities for optimization and further development relating to the usage of libp2p and communication between nodes.

Soon, ChainSafe will help upgrade the network to use Bitswap. Bitswap will further improve the networking capacity of Mina, improving the speed at which peers can request and receive information.

The Road to Mina

Moving forward the team has set out 5 overarching milestones to be completed for the new Mina implementation.

Mina rust implementation Road-map

1. Serialization

This will involve implementing the serialization primitives used in the current protocol with the ability to extend the functionality for custom types.

2. Block selection logic.

The team will then introduce logic to choose the canonical, most valid block, based on chain strength. This is so we can follow and track the best block on the chain.

3. Block validation

During this process, the team will also implement the block verification and the associated proof that comes with each block.

4. Ledgers and additional state.

After that, the team will enact the ability to store and update the account database so that all the data can be stored effectively and securely.

5. Libp2p support

Finally, in the last milestone, the team will implement a JavaScript component to request and receive blocks from all other nodes on the Mina network, using js-libp2p. The next step will be to support the submission of transactions via a gossip system, in order to increase communication efficiency and range. The last step involving libp2p will be to validate and support compatibility with browser environments so that Mina can be accessed from virtually anywhere.


Get to know more

To learn more about Mina, be sure to visit their website!

Want to work with ChainSafe? COME JOIN US!!! Check out the new Careers section of our website and our open positions, and get in touch with us at careers@chainsafe.io if you are interested!

Also, be sure to check out and follow ChainSafe's Twitter and YouTube Channel! If you would like to get in contact with one of the Mina implementation team members from ChainSafe, feel free to drop by on our Discord.

Finally, follow closely on our website and Github for the latest updates!


Thank you to Timothy Hao Chi Ho and Elizabeth for all the help writing this article!