# What are modular blockchains and how is modularity achieved?
### Author: Rashmi V Abbigeri, Twitter: @rashmivabbigeri
Consensus, execution, data availability, and settlement are said to be the four primary functions of a blockchain network.
When a blockchain network executes all four of these functionalities in its base layer, it’s called a monolithic blockchain.
A modular blockchain decentralizes one of its three core components (execution, consensus, and data availability) by entrusting it to an external and autonomous chain.
This division of functions enhances the flexibility and scalability of a modular blockchain, setting it apart from traditional monolithic blockchains.
Examples of a modular blockchains are Celestia, Cosmos, and Fuel.
### **The Blockchain Scalability Trilemma**
![Source: Vitalik.ca](https://hackmd.io/_uploads/SJua9-N7a.png)
First, let's explore the necessity for diverse blockchain architectures, including modular and monolithic. This narrative unfolds from the challenges posed by the blockchain scalability trilemma.:
**1. Security**
Security refers to the capacity of the network to survive an attack. This precept is a middle tenet of blockchains (no chain would advertise itself as unsafe!) and ought to in no way be compromised, so the real tradeoff is usually between scalability and decentralization.
**2. Decentralization**
Decentralization in the context of blockchain systems points to the level to which a single user (or entity, or group) can take over the network and enforce their will. For a blockchain to achieve true decentralization, it should ensure that hardware requirements do not pose barriers to participation, and the resource demands for network verification need to be kept at a minimum.
**3. Scalability**
Scalability in the context of blockchain pertains to the blockchain's ability to process a growing number of transactions while maintaining low resource requirements for verification. Increasing block sizes to accommodate more transactions can inadvertently lead to centralization as it escalates the hardware demands on full node operators to meet higher computational needs. Scalability is typically assessed by a blockchain's capacity to handle transaction data efficiently while ensuring affordability and speed.
The challenge of scalability has been a significant hurdle for blockchain systems. In practice, it's nearly impossible to optimize a single-layer monolithic blockchain to excel in all three fundamental aspects. To address this, the concept of employing multiple layers, rather than relying on a single base layer for all functions (consensus, execution, data availability, and settlement), emerged.
Instead of attempting to optimize all three aspects within a single layer, some proposed a design that optimized one or two properties on one layer and the third on another. This gave rise to the differentiation between modular and monolithic blockchains.
### Let's understand monolithic blockchains before we move on to modular blockchains
In monolithic blockchain architecture, all essential functions, such as data availablity,settlement, execution and consensus are handled in a single block.
Bitcoin and Ethereum are two popular examples of monolithic blockchains.
Key features include:
**Data Availability:**
Monolithic blockchains often pack multiple transactions into the same block for high throughput. If node service providers lack sufficient storage space to store the data, they may be excluded from the network.
**Execution:** Transactions on a monolithic blockchain can easily bypass nodes with fewer validators when consensus is reached, rather than routing them to various nodes.
**Consensus:**
Consensus in monolithic chains is achieved by nodes agreeing on which transactions to process and their order, establishing a common network state.
**Settlement:** Monolithic blockchains ensure the commitment of transactions to the chain's history, maintaining block integrity, typically through mining (proof-of-work) or validator participation (proof-of-stake).
The benefits of monolithic chains include security and ease of use. They can validate transactions on their nodes, improving security and data integrity. However, drawbacks include occasional re-execution of transactions, limited node resources, inflexibility compared to modular blockchains, and potential centralization concerns due to large block sizes and growing blockchain size over time.
Monolithic blockchains handle all functions within a single block, providing security and simplicity but also posing scalability and centralization challenges
### Modular Blockchains
We previously established, attempting to consolidate all four essential functionalities (consensus, execution, data availability, and settlement) at a blockchain's base layer can ultimately constrain the system's capacity and, consequently, its overall throughput. A modular blockchain architecture dissects the system into multiple potential components or modules that can be developed independently.
Within a modular blockchain structure, the execution layer operates independently from the underlying data availability and consensus layers. This setup allows nodes to process transactions individually, instead of collectively validating all transactions within a confined space or block. The mainchain is designated as the settlement layer, given its high level of security and decentralization. Prominent examples of this type of blockchain architecture include Cosmos, Fuel, and the Celestia blockchain.
### How is Modularity achieved?
Modularity in blockchain can be achieved through various means, and here are some key aspects of how it is accomplished:
**Separation of Layers:** Modular blockchains typically divide the blockchain system into distinct layers or modules, each responsible for specific functions. Common layers in a modular blockchain architecture include the consensus layer, networking layer, smart contract layer, storage layer, and application layer. This separation allows for the independent development, maintenance, and upgrade of each layer.
**Plug-and-Play Components:** Modularity is often achieved by breaking down the blockchain into components that can be replaced or upgraded independently. These components are designed to be interoperable and easily swapped out for alternative implementations when necessary. For example, you have interchangeable consensus algorithms or storage solutions.
**Standardized Interfaces:** To ensure compatibility and interoperability between modules, modular blockchains define standardized interfaces or APIs (Application Programming Interfaces) for communication between different components. These interfaces enable developers to build and integrate new modules without disrupting the entire system.
**Smart Contracts:** Smart contracts, which are self-executing code on the blockchain, are often designed with modularity in mind. Smart contract platforms like Ethereum enable developers to create and deploy their custom smart contracts, making it possible to extend the blockchain's functionality with new features and applications.
**Interoperability:** Modular blockchains often prioritize interoperability with other blockchains and external systems. Interoperability allows data and assets to move between different blockchains or networks seamlessly, essential for decentralized applications (DApps) and cross-chain functionality.
**Scalability:** Modular architectures can enhance scalability by allowing individual components to be scaled independently. For instance, you can scale the consensus layer separately from the storage layer, depending on the specific demands of the blockchain network.
**Upgradability:** One of the key advantages of modularity is the ability to upgrade the blockchain more easily. When new features or improvements are needed, individual modules or components can be updated without disrupting the entire system. This helps in avoiding hard forks and network splits.
**Governance:** Modular blockchains often implement governance mechanisms that allow network participants to make decisions about the addition or removal of modules, upgrades, and other changes to the blockchain's architecture. Decentralized governance models ensure that decisions are made collectively and transparently.
By achieving modularity in a blockchain architecture, developers and blockchain stakeholders can build more versatile and adaptable systems, making it easier to cater to a wide range of use cases, from finance and supply chain management to identity verification and more.