This section describes the high-level architecture of Cardano, providing details on the core components and their interactions.
High level architecture of Cardano
The following diagram outlines the interaction between the system components of Cardano:
The current implementation of Cardano is highly modular. It includes the following components (different deployment use cases will use different combinations of components):
- Command line interface (CLI)
- Daedalus wallet
- Cardano db-sync
- GraphQL API server (Apollo)
- SMASH server
Nodes and remote nodes
A blockchain system consists of a set of nodes distributed across a network that communicate with each other to achieve consensus about the system’s state.
Nodes are responsible for:
- Executing the Ouroboros protocol
- Validating and relaying blocks
- Producing blocks (some nodes)
- Providing information about the state of the blockchain to other local clients
You can only trust nodes run by you or your organization. This is why Daedalus runs a node in the background.
The cardano-node is the top level for the node and consists of the other subsystems, of which the most significant are consensus, ledger and networking with ancillary configuration, CLI, logging, and monitoring.
Node-to-Node IPC protocol
The purpose of the node-to-node Inter-Process Communication (IPC) protocol is to allow for the exchange of blocks and transactions between nodes as part of the Ouroboros consensus algorithm.
The node-to-node protocol is a composite protocol, consisting of three ‘mini-protocols’:
- chain-sync: Used for following the chain and getting block headers.
- block-fetch: Used for getting block bodies.
- tx-submission: Used for forwarding transactions.
These mini-protocols are multiplexed on a single long-running Transmission Control Protocol (TCP) connection between nodes. They can be run in both directions on the same TCP connection to allow for peer-to-peer (P2P) settings.
The overall protocol -and each mini-protocol- is designed for a trustless setting where both sides need to guard against Denial-of-Service (DoS) attacks. For example, each mini-protocol uses consumer-driven control flow, so a node only requests more work when it is ready, rather than having work pushed upon it.
The protocol design is modular and evolvable: version negotiation is used to agree on the set of mini-protocols to use, which allows additional or updated mini-protocols to be added over time without causing compatibility issues.
The purpose of the node-to-client IPC protocol is to allow local applications to interact with the blockchain via the node. This includes applications such as wallet backends or blockchain explorers. The node-to-client protocol enables these applications to access the raw chain data and to query the current ledger state. It also provides the ability to submit new transactions to the system.
The node-to-client protocol uses the same design as the node-to-node protocol, but with a different set of mini-protocols, and using local pipes rather than TCP connections. As such, it is a relatively low-level narrow interface that exposes only what the node can provide natively. For example, the node provides access to all the raw chain data but does not provide a way to query data on the chain. The job of providing data services and more convenient higher level APIs is delegated to dedicated clients, such as cardano-db-sync and the wallet backend.
The node-to-client protocol consists of three mini-protocols:
- chain-sync: Used for following the chain and getting blocks
- local-tx-submission: Used for submitting transactions
- local-state-query: Used for querying the ledger state
The node-to-client version of chain sync uses full blocks, rather than just block headers. This is why no separate block-fetch protocol is needed. The local-tx-submission protocol is like the node-to-node tx-submission protocol but simpler, and it returns the details of transaction validation failures. The local state query protocol provides query access to the current ledger state, which contains a lot of interesting data that is not directly reflected on the chain itself.
Read more about the networking protocol design and Cardano node communication protocols.
Command line interface (CLI)
The node’s CLI tool is the “swiss army knife” of the system. It can do almost everything, but it is quite low level and not very convenient because it’s text-based and lacks a graphical user interface (GUI).
The CLI tool can:
- Query the node for information
- Submit transactions
- Build and sign transactions
- Manage cryptographic keys
Daedalus is a full node wallet that helps users to manage their ada, and can send and receive payments on the Cardano blockchain. Daedalus consists of a wallet frontend and a backend. The frontend is the graphical application that users see and interact with. The backend is a service process that monitors the state of the user’s wallet and does all the 'heavy lifting', such as coin selection, transaction construction, and submission. The backend interacts with a local node via the node-to-client IPC protocol, and interacts with the frontend via a HTTP API. The backend also provides a CLI that enables interaction with the wallet. The wallet backend can also be used on its own -without Daedalus- via its API. This is a convenient way for software developers to integrate Cardano with other applications and systems.
We advise that most advanced users intending to use Cardano start with Daedalus.
The cardano node stores only the blockchain itself and associated information needed to validate the blockchain. This design principle is about minimising code complexity, and reducing computational cost and resource use, to keep the node's local interfaces as minimal as possible and to use external clients to provide a variety of convenient interfaces and extra functionality. In particular, the node does not provide a convenient query interface for historical information on the blockchain. This data service is provided by a separate component using an Structured Query Language (SQL) database.
Read more about: