This article is the second of a 4-part article series that covers blockchain generations and why Cardano is considered a third generation blockchain. If you haven’t checked it out already, here’s the first article in the series, which introduces blockchain generations.
In this second part of this article series, we discuss the technical aspects of Cardano’s architecture and how each unit contributes to the network’s overall success. This will serve as an introduction and a good foundation if you want to delve into the network’s intricacies and later contribute to Cardano’s development.
Ouroboros Protocol
Cardano employs the proof-of-stake (PoS) consensus algorithm Ouroboros. These are the laws and parameters to which every participant in the network adheres to reach an agreement with everyone. Unlike Bitcoin’s proof of work (PoW), which requires solving complex mathematical equations (mining), PoS on Cardano picks out participants in stake pools to create new blocks according to the assets (stake) they control in the network. This makes Cardano energy-efficient and, by far, better than its predecessors.
On Cardano, Ouroboros divides time into epochs, further each epoch into slots, the period in which a block is created, and the collection of slots into epochs as leaders are reelected with changes in stake distribution. For each slot, a leader is elected to add a block to the chain before passing it to the next leader. To enhance the stability of the protocol, each new slot leader considers the last few blocks in a transitory period called settlement delay. A stakeholder can go offline and remain synchronized with the blockchain for no longer than this period. Additionally, each network node stores a copy of the primary transactions pool, where new transactions are added if they are consistent with the existing ones. This design ensures Ouroboros is secure in the presence of attacks. You can look into the research paper to delve deeply into how Ouroboros works.
That said, Ouroboros has evolved, with each version improving the network performance. Below is a list of how each implementation enhances Cardano.
- Ouroboros classic — The first implementation of PoS consensus mechanisms. It laid the development foundation and proved a better alternative to PoW. Its ability to select random leaders without bias has been a key to maintaining security, as antagonists have no patterns to exploit.
- Ouroboros Byzantine Fault Tolerance (BFT) — This version, which is next in line, upgraded many network components, including the Cardano Explorer and wallet backend. This simplified the consensus algorithm so that nodes didn’t have to be up all the time and required more honest parties than other versions.
- Ouroboros Praos — Operating similarly to Ouroboros classic, this variant improves security and scalability. It ensures that cyberattacks like distributed denial of service (DDOS) attacks cannot destabilize the network. It also provides private leader selection, evolving signatures, and better randomness in leader selection.
- Ouroboros Genesis — Improving on Ouroboros Praos, this model adds a novel chain rule for initialization from a genesis block without making assumptions or needing trusted checkpoints. As a result, Cardano is composable with other protocols in any configuration of real-world applications.
- Ouroboros Crypsinous — While on the plan, yet to be implemented on Cardano, it equips Genesis with privacy-preserving properties. Other chains building on Cardano can use it to enhance privacy settings.
- Ouroboros Chronos — A time synchronization technique that allows blockchain protocols to interact independently of external time services. It makes the network secure from time information targeted attacks. From an application standpoint, it enhances resilience in the telecommunications, IT, and transport sectors, where services must operate on a unified clock without failure.
As seen, each step above has been targeted toward making Cardano a more secure, fair, and sustainable ecosystem. You can unlock Cardano’s full innovative potential by gaining a comprehensive understanding of Ouroboros, whether user or developer.
Multi-layer Architecture
Besides the consensus algorithm we’ve dissected above, Cardano’s architecture has two other components: the Cardano Settlement Layer (CSL) and the Cardano Computational Layer (CCL), each serving a specific purpose. The need for having separate layers in the architecture arises because blockchains are databases that manage facts and events in the context of timestamps and immutability, bearing in mind that if successful, massive computation, network, and storage resources host millions of transactions. To expound on this, let us look at an example with a bias from Ethereum.
The deal is that blockchains manage asset ownership when handling money. This even gets complex once you add and execute programs. The question is whether you want to know the value transferred from user A to B or the story behind the transaction. For networks like Ethereum, the choice was to add the story behind the transaction. Not only does this make it challenging to choose which data to store on every transaction, but it also requires understanding an arbitrary number of events, scripting the arbitrary transactions, and handling arbitration in the event of fraud or the possibility of reversing transactions if new information is provided. Assessing private transactions, for instance, in a workplace setup, there’s a need to conceal payload for each employee, and publicizing this does more harm than good. In short, Ethereum violates the design principle of separation of concerns. On the other hand, Cardano borrows from transmission control protocol/internet protocol (TCP/IP). So, what’s the role of CSL and CCL?
As the base layer, the Cardano Settlement Layer (CSL) forms the foundation upon which transaction and monetary functionalities are built. It utilizes the Ouroboros algorithm to handle Cardano’s native currency (ADA) for reliable transactions. It could be a transfer of ADA from one account to another or registration of other native tokens. It also uses UTXO (mentioned in the security of Ouroboros) to provide escrow, treasury, and multi-party accounts. Additionally, it is the layer where technologies like off-chain scaling (Hydra), sharding, and sidechain network partitions improve Cardano’s throughput by operating in parallel with the parent chain. This layer commands all the functionalities of Cardano’s ecosystem. In other words, it commands the flow of tokens and records it.
On top of CSL is the Cardano Computational layer, the backbone that describes why tokens flow and the environment in which they flow. This translates to the ability to run programs and gas computations to evaluate economics. It allows the running of smart contracts and supports decentralized applications (dApps). Developers leverage this layer to implement logic and build applications on the Cardano network. It manages the metadata, such as human-readable labels, media, icons, and timestamps. Moreover, it expands the possibility for developers because they can be written in common programming languages (JavaScript, Python, and Rust) and facilitates fair on-chain governance through voting on Cardano Improvement Proposals (CIP).
A multi-layered architecture isolates the execution of smart contracts from potential vulnerabilities that may be birthed from transaction processing. This structure enhances security and facilitates smooth updates on either of the layers without disrupting each other.
Formal Specification and Verification
Cardano utilizes Haskel, a functional programming language, to ensure the technical specifications, as initialized and proven in the research papers, match the implementation. Haskell provides the right balance between theoretical and practical modeling, such that the specifications from research look a lot like the Haskel code. Because cryptographic methods and distributed system operation are technical, long, and complicated, Haskel is a good fit for the infrastructure to be machine-checked instead of human validation, which is tedious and error-prone.
As Cardano works to be a reliable financial operating system, the need for assured security and reliability cannot be overlooked. Haskell proves an excellent way to build robust systems. It validates code during the coding phase; hence, not many errors make it to compilation or quality assurance testing. Once a developer writes smart contracts, they are formally verified to work as intended before deployment, even in complex scenarios. It is also an easy programming language to maintain over time. Haskell is a good choice for a decentralized network with so much utility.
Smart Contracts with Plutus and Marlowe
We defined smart contracts as “self-executing” agreements that run without intermediary parties in a trustless and transparent operation model. Not only are they automated processes, but they also facilitate a seamless transfer of assets or trigger specific actions if specific conditions are met. In Cardano, smart contracts operate as two components: on-chain validators and off-chain transaction builder elements. The on-chain elements execute smart contracts directly on the blockchain and transfer assets or value. On the other hand, the off-chain component is a creation and interaction element for which users interact with the blockchain. This design offers a better approach to scalability, efficiency, security, and performance. By using this approach, Cardano asserts its scientific approach as a platform for launching DApps yet maintains robust on-chain execution.
Smart contracts in Cardano can be written in three distinct languages. Let’s look at each:
- Haskell — A purely functional programming language based on mathematical expression. It offers the security upon which large complex systems can be built in the financial world, among other domains. As the core language that has written the Cardano node and one that underpins its architecture and inner workings of the blockchain, developers looking to build dApps in this ecosystem require a strong understanding of Haskell, if not the basics.
- Plutus — A functional programming language that borrows from Haskell and Cardano’s primary tool for writing on-chain components of smart contracts. A basic understanding of Haskell reinforces the comprehension of Plutus. DApps use Plutus to define the business logic, which is public, immutable, and run by the Cardano node.
- Marlowe — Unlike the last two examples, which require programming skills, Marlowe is designed for both developers and non-developers alike. It uses a graphical user interface (GUI) where using “drag and drop” functionality, you can write smart contracts and deploy them to the network. Once you design any business logic on Marlowe, it is translated to native Haskell, allowing projects to deploy on the blockchain quickly.
Additionally, the Cardano ecosystem has evolved to offer more fundamental tools for developers. This means we have all sorts of tools that you can think of. First, you can write smart contracts in your native programming language, such as JavaScript or Solidity. There are abundant APIs and SDKs that provide high-level interfaces to interact with Cardano, stake pool operation tools for use on the command line, explorers to visualize data, data services for analysis, native token creation tools, wallets, and even blockchain integration tools to connect existing applications. Whether beginner or expert, frontend or backend developer, stake pool operator or wallets, there’s all possible tooling to support the applications you want to run on Cardano.