Blog > Authors > John Woods

Introducing pipelining: Cardano's consensus layer scaling solution

Pipelining is one of the key scaling improvements to be deployed in 2022. Here’s how it works and why it matters

1 February 2022 John Woods 4 mins read

Introducing pipelining: Cardano's consensus layer scaling solution

You’d be forgiven for thinking that pipelining sounds like a remodelling procedure a plumber might employ. In a way, this isn’t too far from the truth. Pipelining is, effectively, an evolution in Cardano’s ‘plumbing’. It is a key element in our scaling plan this year, one in the series of published steps covering our methodical approach to flex Cardano’s capacity as the ecosystem grows.

Scaling and throughput are crucial considerations for any blockchain, if growth and competitiveness are to be maintained. As Cardano enters the Basho phase of development, we're laser-focused on ensuring that Cardano scales to meet the growing needs of the ecosystem. In other words, we need to ensure that the underlying protocol – Ouroboros Praos – operates fast enough for the plethora of decentralized applications now deploying or lining up to launch on Cardano.

Cardano will continue to be steadily optimized in a series of measured steps, carefully & methodically scaling #Cardano for future growth as demand increases. The changes introduced by the release of node 1.33.0 in early January gave us additional headroom to modify some network parameters, including block size and memory units. Adjustments here have a direct bearing on how Cardano handles network traffic in volume and we continue to monitor network performance closely.

Continuing close observation of real world network performance and - importantly - the cumulative impact of parameter changes will be key throughout this process. Following each update, we carefully monitor and assess across at least one epoch (5 days) before continuing with further adjustments. As much as extensive research and engineering work has gone into designing and deploying the system, a decentralized network architecture needs to be scaled based on real world user behaviours and usage.

Introducing pipelining

Pipelining – or more precisely, diffusion pipelining – is an improvement to the consensus layer that facilitates faster block propagation. It enables even greater gains in headroom, which will enable further increases to Cardano's performance and competitiveness.

To understand how this technique achieves its intended goal, let's recap how blocks propagate at present.

Currently, a block goes through six steps as it moves across the chain:

  1. Block header transmission
  2. Block header validation
  3. Block body request and transmission
  4. Block body validation and local chain extension
  5. Block header transmission to downstream nodes
  6. Block body transmission to downstream nodes

A block’s journey is a very serialized one. All steps happen in the same sequence every time, at every node. Considering the volume of nodes and the ever-growing number of blocks, block transmission takes a considerable amount of time.

Diffusion pipelining overlays some of those steps on top of each other so they happen concurrently. This saves time and increases throughput.

The time saving afforded by this technique will lead to even more headroom to further scale Cardano, including changes to:

  • Block size - the bigger the block, the more transactions and scripts it can carry
  • Plutus memory limits - the amount of memory available for a Plutus script to run
  • Plutus CPU limits - more computational resources can be allocated for a script to run more efficiently

Implementing pipelining

One of the design principles behind diffusion pipelining was to achieve faster block propagation while avoiding ‘destructive’ changes to the chain. We did not want to remove any of the protocols, primitives, or interactions already happening in Cardano, because nodes rely on these established mechanisms. We wanted full backwards compatibility, so instead of changing the way things currently work, we're adding a new mini-protocol whose job is to pre-notify subscribed entities when a new desirable block is seen, prior to full validation.

The key change introduced by pipelining is the ability to pre-notify peers and give them a block before it is validated, which enables the downstream peer to pre-fetch the new block body. This saves a lot of time because we dramatically reduce the time it takes to validate a block across the multiple hops.

In conclusion

Pipelining is just one of the pillars supporting Cardano's scaling this year. Combined, all these changes will lead Cardano to a position where it is faster than its competitors, and a highly competitive platform for decentralized finance (DeFi) this year.

Key takeaways

Fernando Sanchez contributed to this article.

The beating heart of a fast-growing network

At the core of the Cardano network lies the node. Here’s how this integral technology will play its part as we scale Cardano during 2022

19 January 2022 John Woods 5 mins read

The beating heart of a fast-growing network

In a recent post, we discussed our methodical approach to preparing Cardano for its expected growth over the coming weeks and months. As more and more decentralized applications make Cardano their home, and as the decentralized finance (DeFi) and ‘RealFi’ ecosystem expands and evolves, the blockchain needs to be able to perform accordingly.

Cardano is entering the Basho phase with a focus on optimization, scaling, and network growth. We anticipate a significant increase in transactional traffic over the months ahead, and here’s where we start the process of flexing to meet this. Improvements to the core node are part of this and we have packed node v1.33.0 full of new features and improvements to existing elements, upping Cardano’s expressiveness and the chain’s ability to do more.

What's in a node?

Node v1.33.0 – released in early January and now running on circa 80% of SPO systems – has been designed with elegance and efficiency in mind. The improvements made are designed to reduce block propagation time, so we get greater headroom to make the changes we need to accommodate DApps, decentralized exchanges (DEXs), DeFi environments, and so on.

Following the implementation of the version of the node, blocks now propagate faster. This gives us extra time that we can use to implement other enhancements.

Technical improvements included in node v1.33.0 can be broadly categorized in RAM usage optimization and efficiency upgrades.

RAM usage optimization

The new node supports a significant drop in memory usage because of two factors: memory compaction and more efficient memory sharing (rather than multiple instances of the same object, now multiple flows within the system will use the same object.)

Specifically, there are memory improvements in Unspent Transaction Output (UTXO) handling, stake distribution, live stake distribution and pools, and hash representation.

These improvements are:

  • UTXO handling

Node v1.33.0 uses fewer words for transaction inputs.

  • Stake distribution

Stake distribution snapshots represent 35% of total live data. The new node achieves a reduction by a factor of eight by sharing and changing representation.

  • Live stake distribution

Live stake distribution accounts for 22% of total live data within the system.

Node v1.33.0 saves memory in two ways:

Sharing by combining multiple maps that are keyed on stake addresses (a saving of 11 words per stake address for each map combined), and sharing of stake pool IDs (5 words).

  • Hash representation

Hash representation now uses 5 words instead of 6. Since hashes are ubiquitous in the system, this change, while apparently insignificant, will lead to considerable improvements in efficiency.

Key facts about RAM memory usage optimization

The new node enables great savings in live data due to compaction and sharing.

Efficiency upgrades

Apart from making memory usage far more efficient than in previous versions, node v1.33.0 includes changes to the algorithms that Cardano uses to calculate rewards and stake distribution.

The rationale for these changes is to address the uneven network performance that occurred when calculating rewards, which led to spikes in network load. The new reward calculation algorithm is now in place, so these spikes will not happen anymore.

The algorithm to calculate the rewards has changed from “column-major” over 4,000 pools, to a “row-major” over ~1m stake addresses. This allows spreading the calculation over 3 days, instead of 1 day (4,000 blocks).

We have also made changes to make the calculation of stake distribution more efficient.

Pipelining

Later this year, we’ll make further significant improvements to the node. A node does a lot of work processing a block, then waits for another block to come along, etc. In between, the node is not so busy. This block propagation overhead (that is, the time interval where the node is relatively idle, often called 'dead space') can be reduced through certain techniques to make good use of that otherwise 'dead' time. This is where pipelining comes in.

This technique coalesces the validation and propagation of blocks. Now, instead of following the process of getting a header, validate it, then get its corresponding block, validate, and then send it to peer, now we get a header, validate, and send it to the peer, without validating the block. This streamlining will give the network even more headroom to make more changes.

Pipelining will significantly increase the scope/headroom we have to make further improvements to the network by reducing the block propagation overhead ('dead time').

Looking ahead

The Cardano project has always been committed to building out a secure, resilient and highly decentralized network that can meet the needs of the next decade and beyond. And taking a methodical, responsible long-term approach is central to this. As the saying goes, “Measure twice, cut once.”

With the launch of many exciting new projects on Cardano, the ecosystem will see explosive growth. Inevitably, short-term capacity will not always keep pace with demand and periods of heavy congestion will occur. This is a journey that every new chain goes through. But with careful monitoring throughout, we’ll continue to work to increase Cardano’s efficiency, throughput, and capability over the weeks and months ahead. While maintaining the considered, safe approach that has served us well to date.

Fernando Sanchez contributed to this article.

Slow and steady wins the race: network evolution for network growth

After a successful start to Cardano’s smart contract era, we’ll soon make the first in a program of network adjustments to support future growth

22 November 2021 John Woods 8 mins read

Slow and steady wins the race: network evolution for network growth

From its conception, Cardano has been architected as a platform to best balance the perennial trade-offs of security, scalability and decentralization. Therefore we have architected and built a solid and secure network layer, yet with the flexibility to grow and scale to support a global base of millions of users.

With a secure, highly decentralized proof of stake network now firmly established, and core smart contract capability deployed, we’re now heading into the Basho phase, focused on optimization, scaling and network growth.

As a decentralized permissionless blockchain, Cardano is open to anyone who wants to use it or build on it. Recent hard forks (adding native tokens and smart contract capability) have brought many new users into the Cardano ecosystem, and we have seen rapid growth (and spikes) in transaction volumes and network traffic.

As core components – including wallet connectors and the Plutus Application Backend (PAB) are finalized and integrated into mainnet, we anticipate significant growth in network activity. A constellation of projects building on Cardano will begin to launch, first on testnet then mainnet. These will only increase, with potentially hundreds of thousands of new users coming into Cardano over the coming months, from all sides of the blockchain spectrum.

Inevitably, we can expect significant traffic around the launch of new decentralized applications (DApps), especially in the early days and weeks. To accommodate this ongoing growth, and ensure that Cardano maintains its resilience and robustness, we’re now starting to make a series of adjustments to network parameters. These parameter changes will provide ongoing improvements and enhancements to Cardano's usability and experience across its entire range of users.

Architected for growth

Ouroboros is designed to handle a large volume of data as well as transactions and scripts of different complexity and size. At present, and with current parameters, the Cardano network is utilizing on average only around 25% of its capacity. This is sub-optimal because in fact, the most efficient scenario is that Cardano runs at or close to 100% of its capacity (i.e., the network is ‘saturated’).

While many networking solutions would suffer under such conditions, both Ouroboros and the Cardano network stack have been designed to be fair and highly resilient, even under heavy saturation.

Efficient systems are designed to minimize congestion while enabling effective management when it does happen. You can read more in this recent blog, but in short, the network uses backpressure to manage the overall system load. So while some individual users during a large NFT drop may experience longer wait times for their transactions, this does not mean that the network is ‘struggling’. It actually means the network is performing as intended. We call it ‘graceful degradation’ and you can study this in greater depth in the network design paper.

Adjusting parameters

Aside from the original architectural design, and significant benchmarking across a range of simulated situations, it is only in the real world that we can truly gauge demand and the effectiveness of any changes.

Following extensive benchmarking, and developer feedback, we’re now starting to make gradual adjustments and have today submitted two initial changes.These changes are planned to take effect on the testnet on Thursday 25th November. Once tested, we anticipate subsequently applying these to the mainnet, taking effect on epoch 306, on Wednesday December 1, 2021 at 21:45:00 UTC.

So what are we adjusting?

We’re increasing block size by 8KB to 72KB (12.5% increase)

There are now well over 2 million Cardano wallets in use and traffic has grown by over 20 times in a year (from less than 10,000 transactions per day in November 2020 to over 200,000 transactions per day. Because of the anticipated rise in traffic as developers roll out new DApps, the block size is quickly becoming a key consideration. Larger block sizes mean that more transactions can fit into a block, thus providing greater capacity for users. Being able to fit 12.5% more transactions into a block is significant, as it means that we’re processing more transactions per second or we argue – a more useful metric – greater data throughput.

We are taking a steady, methodical approach to changes in Cardano's parameterization. A 12.5% increase is sizable, but not too big. It leaves room for further expansion, and allows stake pool operators (SPOs) to adjust to the increased demands. We will take a 'slow and steady' approach to further block size changes so that we make the underlying network capacity available to end users, while ensuring that we can continue to operate successfully as a globally decentralized blockchain. The current generation of Ouroboros (named Praos) has specific requirements which must be satisfied in order to ensure its security goals are met, one of the most important parameters is block propagation time. Block propagation time is a measure of how long it takes for a freshly minted block to be propagated across nodes on the network representing 95% of the staked ada. For Praos to stay secure the network must propagate new blocks within 5 seconds.

We can consider this 5s limit a ‘budget’ we can ‘spend’ on things like increasing the block size. Changes such as increased block size will naturally increase the time needed to propagate blocks, so we must monitor carefully to ensure changes we make to increase performance don’t affect the security of the network. In future iterations of Ouroboros this budget will be increased. Meanwhile our focus will be on maintaining security while flexing the network to growing demand.

We’re also increasing of Plutus script memory units per transaction to 11.25 million (again, 12.5% increase)

This is a powerful change and one that we know DApp developers will very much appreciate. An increase in Plutus memory limits means that they can develop more sophisticated Plutus scripts, or that existing scripts will be able to process more data items, increase concurrency, or otherwise expand their capabilities. This will be the first of a series of changes to the memory unit settings that will greatly enhance the real-world capabilities of Plutus scripts. As with block sizes, we will roll out the changes gradually, but steadily, so that the network and SPOs adjust to the increased demand.

The changes described below (block size increase and Increase of Plutus script memory units per transaction) were requested by many app developers, for example. Both these changes go hand-in-hand. It’s not just about creating more complex scripts. It’s also about putting more data through.

Steady and sure

As the Cardano platform evolves, every change will be carefully considered and once actioned, subsequently monitored to gauge its impact on performance. All changes will be based on empirical data drawn from the network and based on real, sustained user demand. Critically, it is important not to make decisions with a long-tail impact around short-term surges in network usage. We won't make changes prematurely or make them at a pace that could potentially compromise Cardano's longer-term security, for example.

Cardano development is grounded in both fundamental and ongoing research. Further network enhancements in the mid-longer term will collectively deliver substantial capacity improvements, as well as tuning the network to deliver the best overall experience.

I’ll be joining the November Cardano360 to share further thoughts on this. But in short, this is about building new and capable blockchain infrastructure, built on advanced and fundamentally decentralized technologies. Initially, we will focus on a number of performance improvements that will enable us to exploit the limits of the Ouroboros Praos protocol. We will then focus on optimizing the size of Plutus scripts and the underlying performance of the Plutus interpreter and Cardano node implementations. This will allow us to process more useful work within the same protocol parameters. Related to this will be the use of compression techniques, to reduce the size of scripts and transactions, meaning that more transactions can be carried within the same sized block. All of this (and more) will improve layer 1 performance and capacity. Looking ahead, Hydra will then introduce a layer 2 solution, providing hugely increased scalability by allowing users to provision multiple chains that reuse the same ledger representation.

In conclusion

Cardano is, in a manner of speaking, a living entity that grows and adapts with every evolutionary step. It may sound like a contradiction in terms, yet while its foundations are formed from rock-solid fundamental research, flexibility (to change even entire protocol changes via the hard fork combinator (HFC) has been designed in from the beginning.

Parameterization changes are part of this transformative process. While inevitably there will be folks who want to move faster, our focus will remain on steady, secure evolution as Cardano grows in reach and adoption.

Thanks to Duncan Coutts, Kevin Hammond, and Fernando Sanchez for their contributions to this article.