Upcoming Fantom protocol upgrades

Upcoming Fantom protocol upgrades

1. Introduction

Fantom is a permissionless smart contract platform, which hosts thousands of applications on the Fantom mainnet. Fantom is EVM compatible, but Fantom was designed and implemented quite differently from Ethereum.

Key differences include:

  • Fantom is PoS, making it more secure and more energy-efficient than Ethereum’s PoW.
  • Fantom’s DAG-based consensus guarantees a consistent topological ordering of events across the network.
  • Fantom processes transactions asynchronously.
  • Fantom needs only 1 confirmation.

Asynchronous transactions

Let’s imagine you arrive at a train station and then line up in a single line. A train arrives on average every 16 seconds, and one by one, passengers enter. You can get in if you are lucky enough, but you may have to wait for the next train.

Now imagine arriving at a different train station, at which there is always a train waiting there for you. All other passengers who arrive around the same time can board the train. If the current train is full, you can immediately board another train on another platform.

Obviously, in the second scenario, many more passengers can board at a faster rate, with minimal waiting.

This is the difference between a synchronous Proof of Work system like Ethereum, illustrated by the first example, and an asynchronous platform like Fantom, as in the second example.

On Fantom, users can submit transactions to the network asynchronously without waiting for blocks to be confirmed. Transactions are processed by validator nodes simultaneously with other transactions that arrive at the same time.

The results on Fantom are fast, low cost, and secure transactions.

One block confirmation

Furthermore, while Ethereum requires multiple block confirmations to ensure your transaction is secure, Fantom only requires one confirmation. In technical terms, this means that finality ‒ how long it takes to confirm a transaction on the network ‒ is done deterministically, with complete certainty.

2. Upcoming Upgrades

Fantom has processed more daily transactions than Ethereum over an extended period, at a fraction of the cost.

Fantom’s team has further plans to increase scalability on the platform to meet the needs of even larger numbers of users.

Our immediate roadmap includes three important upgrades:

2.1. Snapsync

Fantom’s “Snapsync” will allow nodes to download blocks from the network quickly by only requesting data needed to order future transactions.

Unlike Ethereum, Fantom is asynchronous, and so our core development team had to build a new variation of the consensus algorithm called the “Lachesis Light Repeater (LLR),” which stores minimal information from the chain. Lachesis remains the main consensus protocol to confirm transactions.

This also allows nodes to keep up-to-date with one another and thus speed up consensus.

Combined with auto-pruning, which allows nodes to reduce their data size, nodes running Snapsync on testnet have been able to download required blocks in just 7 minutes vs. 40hrs for a full sync, while achieving a ~90% reduction in total data storage.

This means that the entire Fantom mainnet could be stored in just 270GB vs. ~2.7TB.

Snapsync release is available for both testnet and mainnet.

Further information on how Snapsync works is also available on Github.

The mainnet upgrade will start with a few nodes on 14 March onwards. We’ll announce specific timelines and assist the node operators worldwide with this upgrade as we did in previous releases.

2.2. Implementation of PebbleDB and RAID on RPC nodes

Dealing with billions of requests per day is a challenge, as our RPC API nodes have to send and receive a massive amount of data flowing between the blockchain and Dapps. This consumes a lot of server resources and requires significant hardware and software to maintain.

A special thanks to Kasper Neist, an active member of our community, who has a key role in handling these requests via rpc.ftm.tools.

To further scale the API service, the Foundation developed and is rolling out new RPC software to increase efficiencies by several magnitudes.

Using PebbleDB instead of LevelDB to handle requests in memory, combined with RAID servers, we have reduced the memory consumption by inputs and outputs (I/Os) by over 90%, from 90mb/s to just 7mb/s.

Fantom engineers are expanding this solution to validator nodes to further increase speeds while reducing memory requirements and power consumption. This technology can potentially help process transactions faster with much smaller memory consumption, thereby improving the network performance.

We are also releasing a Golang RPC load balancer (beta) available at https://rpcapi.fantom.network. The new gateway will allow us to balance, filter, cache, and analyze network traffic.

2.3. Implementation of Flat Storage for faster execution of smart contracts

Based on our prior research, one of the major issues for blockchain performance is the slowness of the Ethereum technology stack.Reading and writing data from the Ethereum Virtual Machine (EVM) and the blockchain is very slow via what is technically called the “Merkle Patricia Trie” (MPT). As the network grows, it becomes progressively slower to execute smart contracts.Our solution is to use a “flat storage” data structure that indexes all data to allow nodes to quickly access storage, regardless of the size of the chain.

Based upon a simple implementation of a flat storage data structure, in parallel to the MPT, Fantom achieved a 41% improvement in memory performance and up to 5x faster reads from the blockchain by nodes.

These results are a positive indication that we are on the right track. Our efforts now focus on securing flat storage.

All code is public and accessible via Github.