How Nomadic Labs Used Multicore Processing to Create a Faster Blockchainby Isabella Leandersson on Dec 20th, 2022
The technology that makes blockchain possible is complex, cutting-edge, and fascinating. Balancing efficiency and security on a knife's edge, it finds perfect harmony between high transaction speeds and safe, predictable results. Blockchain technology is constantly evolving, pushing the boundaries of what’s possible, and driving innovation and research. Discover how Tarides helped Nomadic Labs use OCaml 5 to boost blockchain performance with rollup technology.
In order to remain competitive with other major players in the blockchain market (including Bitcoin and Ethereum), the open-source blockchain Tezos invests in cutting-edge research and engineering. Another way Tezos has chosen to differentiate itself in a crowded market is by focusing on sustainability and scalable efficiency. Tezos is proof-of-stake (rather than proof-of-work) and is therefore more energy efficient than other blockchain technologies, with the annual energy consumption estimated at 0.001TWh, or “17 global citizens.” Furthermore, the Cambridge Centre for Carbon Credits (4C) is using the Tezos blockchain to create a trusted decentralised marketplace for carbon credits. The sheer amount of data needed to support verifiable carbon credits requires planetary-scale computations, coupled with the digital permanence needed to track projects over decades and even generations.
A growing number of users and companies are bringing their projects to the Tezos blockchain. To respond to increasing demand, the network is preparing for more activity and high-throughput applications. To that end, Nomadic Labs is working on implementing leading-edge rollup technology for the Tezos blockchain. Rollups are a way of increasing throughput and blockchain speeds without compromising on decentralisation, latency, stability, security, or its resistance to censorship.
To achieve their goal of offering a major scaling solution for Tezos, Nomadic Labs called in Tarides. By leveraging the multicore capabilities of OCaml 5, the team was able to achieve significant performance boosts, making it a viable solution for increasing both blockchain speeds and transactions per second (TPS).
Marco Stronati co-leads the cryptography team at Nomadic Labs with cryptographer Marc Beunardeau. Looking back on the decision to use an early version of OCaml 5, Marco said, “We knew OCaml 5 was not ready yet, but that backward compatibility was an explicit goal of the project, so we thought we would put that to the test.”
Nomadic Labs is one of the largest research and development centres within the open-source Tezos ecosystem. They work on the Tezos core technologies that run its distributive network as one of the largest research and development centres within the Tezos ecosystem.
Nomadic Labs handles software releases and amendments to the Tezos blockchain, focusing on the innovation, development, and implementation of new features. They help companies and institutions use Tezos to their advantage. At its core, the company values dependability, balancing cutting-edge innovation with reliable and consistent results.
Rollups settle transactions outside the network and then post data back into it. This is what’s called a Layer 2 solution, which avoids the main chain. By handling the process externally, they reduce the strain on the network. Rollups help blockchains like Tezos keep transaction speeds and throughput high without compromising the integrity of the blockchain. It is one of the many different scalability solutions a blockchain may employ to offer top-level performance. There are two main types of rollups: optimistic and zero-knowledge (zk).
Optimistic rollups assume that the transaction data they’re processing is correct, and any fraud or other problem with the transaction is handled separately. Zk-rollups on the other hand use zero-knowledge proofs to validate a transaction. Zk-rollups provide better security and confidentiality than optimistic rollups, but they come with their own sets of limitations.
The challenge Nomadic Labs faced was related to their proving system. In general, proving systems have to be very asymmetrical, with a prover doing most of the work off-chain and a lean verifier working on-chain. Whilst these rollup systems are great for blockchains, because of how quickly they can verify something, the proving stage is very CPU- and memory-intensive. This prevents the scalability of Epoxy, their zk-rollup solution, since its throughput and latency are directly limited by the speed of the prover. Most of the innovation in the field of zero-knowledge proving systems today is driven by lowering the complexity of the provers, thanks to novel cryptography but also to highly optimised implementations.
The team’s solution to the prover’s inefficiencies was to use the aPlonK proving system to power Epoxy. It enables the efficient aggregation of multiple proofs that can be executed in parallel. This is where OCaml 5 comes in! With its Multicore capabilities and strong safety features, it is the perfect candidate for speeding up the proving process.
With OCaml 5, the team could parallelise the proving process by utilising multiple cores on one machine. According to Marco, “OCaml 5 drastically improved performance with minimal effort.” Increased performance of the zk-rollup translates to high TPS and throughput for customers using digital currencies. Striving to be the fastest blockchain means constantly looking at opportunities to improve performance, from changing algorithms to workflows.
Furthermore, speaking as a seasoned developer, Marco emphasises the importance of OCaml 5 being easy to install and set up.
“The most important thing was not having to revolutionise what I do. People don’t want to waste a week on upgrading, and this was a seamless experience.”
Installing OCaml 5 proved to be easy for the team, and in the matter of a few hours, they were running Multicore on their machines. For people who don’t need Multicore, the upgrade is completely backwards compatible, and their sequential code will still work normally. It’s due to the precise balance OCaml 5 strikes between backwards compatibility and cutting-edge upgrades that Marco thinks there is literally “No reason not to upgrade.”
When using OCaml 5 before its official launch, the team faced some small compatibility issues they needed help with. They checked the state of compatibility on the helpful health check website, where more and more packages were ‘going green’ daily. Even before they could file a bug report, they would find that their problem had been resolved. Since set up was so smooth, the team needed very little help. Still, Marco commented that: “The moment we had a problem, we would get help immediately.”
The team is excited to continue using OCaml 5 in the future, as soon as Tezos begins using it in production after the full release. At the moment, the team has to parallelise using several machines to speed up the prover’s performance. With OCaml 5, they will be able to exploit multiple cores on several computers at the same time.
After successful experimentation with a prerelease of OCaml 5, the team at Nomadic Labs discovered that it gives their zk-rollup a significant performance boost. For the Tezos blockchain, this boost can result in higher TPS and throughput for customers who use their digital currency. Combined with Tezos’s other benefits, such as its energy efficiency (thanks to its proof-of-stake consensus mechanism), OCaml 5 definitively gives it a leg up with fast zk-rollups.
The technologies that make blockchains a reality are undeniably a driving force behind great innovation. Zk-rollups are just one example of technologies that aim to make complex processes like verifiers and provers lightning fast. Performance is vital in almost every field, and the use cases for this type of technology are endless.
Tarides offers its extensive expertise in OCaml to help businesses achieve their targets. Find out more about how OCaml 5 can help you transform your business!