Lachesis: Scalable smart contract platform with aBFT DAG

Quan Nguyen
4 min readNov 14, 2022

If you’re new to the world of decentralization terminologies, and (tired of reading) a jungle of papers.
If you’re wondering about what Lachesis consensus algorithm, and what Fantom is working on.
If …

Here is a (brief) introduction to you about Fantom techs and the progress we’ve made so far.

Outline

  • Overview of blockchain
  • Fantom
    - Architecture
    - Lachesis Consensus Algorithm
    - Current status
  • Next challenges
    - Virtual Machine optimizations
    - Scaling methods, e.g., Sharding

Overview of blockchain

  • Blockchain systems
    - Moving from centralized systems to decentralized networks.
    - No single point of failure, no single point of control.
    - Fault tolerance
Shifting from private to permissioned to permissionless
  • Ecosystem and Applications
    - Finance: Cryptocurrency, DeFi, NFT, DEX
    - Entertainment: GameFi
    - MetaVerse
    - Web3
Blockchain ecosystem and applications

Limitations

Blockchains have been used successfully in many places.

However, there are some limitations in existing blockchain technologies. Proof of Work has long confirmation time and high power consumption, whereas existing Proof of Stake proposals does have some limitations related to security, scalability and fairness.

In Fantom, we’d like to solve these limitations.

Fantom — Opera network

The core technology of Fantom is our Lachesis consensus algorithm.

Lachesis consensus algorithm:
- Permissionless
- Leaderless
- Asynchronous Byzantine Fault Tolerance (aBFT)
- Proof of Stake
- DAG (for faster consensus computation)

Lachesis is built on Proof of Stake, and it’s a DAG — directed acyclic graph.

We use DAG to have a faster and more secure computation of consensus.

Our white paper v2.0 is publicly available.
Q. Nguyen, A. Cronje, M. Kong, E. Lysenko, A. Guzev, “Lachesis: Scalable Asynchronous BFT on DAG Streams”, 2021, 46 pages. [Online]. Available: “https://arxiv.org/pdf/2108.01900.pdf"

Architecture of Opera

Architecture of Opera network

There are several components: Web3 API at the top; the EVM engine; state is stored in a blockchain; the Lachesis consensus engine; and P2P.

Lachesis builds new DAG per epoch to save space and to retrieve the DAG info more effectively.

Code structure

Our code is structured as follows. The main repository is go-opera, and lachesis-base (the base for lachesis protocol). Opera-sfc contains the implementation of SFC smart contract.

We have On-chain governance on Opera network. It is implemented in fantom-govern.

Pipeline

The pipeline

Transactions are sent to txpool, and sorted by gas price. Lachesis Consensus Engine is the core of the pipeline. It processes the local DAG on each node and computes the Atropos event block and build new blocks. Once a new block is formed, it will be sent to the EVM processor for execution.

DAG

DAG of event blocks

Lachesis Consensus Algorithm

What is a DAG? In Fantom, a DAG is a weighted graph, events as graph vertices, parent hashes as graph edges. Each vertex has a weight.

What is stored in an event? Each event has the following fields: ID, the creator who made the event; parents of the event; self parent = parent event from the same validator; seq number; the frame number; Lamport timestamp; and the current epoch.

Lachesis will take a DAG and computes a Total Ordering of events.

Main chain

Opera’s Main chain

Lachesis takes as input a DAG stream of events.

DAG stream of Events. It then computes Root, and then computes Clotho. Next, it determines Atropos from Clotho event. It takes the median timestamp of Atropos from all nodes, and assigns this timestamp for the Atropos.

Once new Atropos is found, Lachesis will build a new block. It will take the subgraph under the new Atropos, and it only considers those events that are yet considered previously (when processed previous Atropos).

It then sort the events of the subgraph in a topological ordering. It will include txns of these events into the new block.

For the whole process, we will have a total ordering of events and transactions. The whole process is deterministic, and happens very quick.

Comparison with existing consensus protocols

  • Compared with existing PoS protocols:
    - Lachesis protocol is more deterministic and more secure.
  • Compared with existing DAG-based approaches:
    - Lachesis algorithm is more deterministic and more secure.
    - Lachesis algorithm for finding roots and Atropos is deterministic, and we don’t use coin round for consensus.
    - Lachesis leverages the notion of Happened-before relation, Lamport timestamp, and graph layering to reach consensus on the final ordering for Atropos blocks. Lachesis creates blocks for every newly decided Atropos.
    - Lachesis protocol is permissionless asynchronous BFT.
    - A formal semantics and proof for our Lachesis protocol.

Current status

  • Key features of Fantom network:
    - One of the fastest: TTF of 1–3s.
    - One of the most affordable
    - One of the most secure
    - One confirmation only.
  • Minimum self-stake requirement is 500,000 FTM to run a node

Next challenges

  • Optimization for more scalability

Keep building, stay strong!

--

--

Quan Nguyen

Quan Nguyen is interested in R&D on Blockchains and DLT. He is currently the CTO at Fantom Foundation. His background is Cloud, Web Apps, InfoVis, PL, VM.