How does Transformers work? Explaining the Raindrop consensus protocol and the chain structure
Transformers (TFSC) is a decentralized public chain that aims to provide fast, secure, scalable, and customizable solutions for various applications. It uses a novel consensus protocol called Raindrop, which allows multiple block producers to parallelize block production and achieve high transaction throughput. TFSC also supports smart contracts compatible with Ethereum Virtual Machine (EVM) and WebAssembly (WASM) virtual machine. In this article, we will explain how Raindrop works and how it differs from other consensus protocols. We will also describe the chain structure of TFSC and how it enables cross-chain interoperability.
What is Raindrop?
Raindrop is a consensus protocol that combines the advantages of Proof-of-Stake (PoS) and Delegated Proof-of-Stake (DPoS) to achieve high performance, security, and decentralization. Raindrop is inspired by the natural phenomenon of raindrops falling from the sky and forming streams and rivers. Similarly, in Raindrop, blocks are produced by multiple block producers in parallel and then merged into a single chain.
Raindrop consists of two layers: the Raindrop Layer and the Stream Layer. The Raindrop Layer is responsible for selecting block producers and validating blocks. The Stream Layer is responsible for merging blocks and finalizing the chain.
The Raindrop Layer
The Raindrop Layer is based on PoS, which means that anyone who holds TFSC tokens can stake them and become a validator. Validators are randomly selected to form committees that are responsible for validating blocks produced by block producers. The committees are shuffled every epoch (a fixed period of time) to ensure security and fairness.
Block producers are also selected from the pool of validators based on their stake and reputation. Block producers are divided into groups, each of which is assigned a different color. Each group can produce blocks in parallel without conflicting with each other. The color of a block indicates which group produced it.
Each block producer can produce one block per epoch, which contains transactions, state changes, and a hash of the previous block of the same color. The block producer broadcasts the block to the committee of the same color, which then validates the block and signs it. The signed block is then broadcasted to the entire network.
The Stream Layer
The Stream Layer is based on DPoS, which means that TFSC token holders can vote for delegates who act as streamers. Streamers are responsible for merging blocks of different colors into a single chain. Streamers are also divided into groups, each of which is assigned a different priority. The priority of a group determines the order in which it can merge blocks.
Each streamer can merge one block per epoch, which contains a hash of the previous merged block and a hash of a valid block of any color. The streamer broadcasts the merged block to the committee of the same priority, which then validates the merged block and signs it. The signed merged block is then broadcasted to the entire network.
The Stream Layer uses a weighted longest-chain rule to determine the finality of the chain. This means that the chain with the most cumulative stake behind it is considered the canonical chain. Conflicting chains are discarded and their transactions are re-executed on the canonical chain.
What are the advantages of Raindrop?
Raindrop has several advantages over other consensus protocols, such as:
High performance: Raindrop allows multiple block producers to produce blocks in parallel, which increases the transaction throughput and reduces the latency. Raindrop also uses a lightweight validation process that only requires signatures from committees, which reduces the communication overhead and bandwidth consumption.
Security: Raindrop uses PoS to select validators and committees, which ensures that they have a stake in the system and are incentivized to behave honestly. Raindrop also shuffles committees every epoch to prevent collusion and attacks. Raindrop also uses DPoS to select streamers and prioritize them, which ensures that they have the support of the token holders and are accountable for their actions.
Decentralization: Raindrop allows anyone who holds TFSC tokens to participate in the consensus process as a validator, block producer, or streamer. Raindrop also ensures that different groups have equal opportunities to produce and merge blocks, which prevents centralization and censorship.
Customization: Raindrop allows applications to customize their own consensus parameters, such as the number of block producers, committees, streamers, colors, priorities, epochs, etc. This enables applications to optimize their performance, security, and scalability according to their needs.
How does TFSC support cross-chain interoperability?
TFSC supports cross-chain interoperability by using a Rainbow Bridge mechanism that allows assets and data to be transferred between TFSC and other chains. The Rainbow Bridge consists of two components: Rainbow Relayers and Rainbow Contracts.
Rainbow Relayers are special nodes that monitor the events on both TFSC and other chains and relay them to the corresponding Rainbow Contracts. Rainbow Contracts are smart contracts that verify the events and execute the cross-chain transactions. Rainbow Contracts can be deployed on TFSC or other chains that support smart contracts.
For example, if Alice wants to transfer 100 TFSC tokens from TFSC to Ethereum, she can do the following steps:
Alice sends 100 TFSC tokens to a Rainbow Contract on TFSC, which locks them and emits an event.
A Rainbow Relayer on TFSC captures the event and relays it to a Rainbow Contract on Ethereum.
The Rainbow Contract on Ethereum verifies the event and mints 100 TFSC tokens on Ethereum for Alice.
Similarly, if Bob wants to transfer 100 ETH from Ethereum to TFSC, he can do the following steps:
Bob sends 100 ETH to a Rainbow Contract on Ethereum, which locks them and emits an event.
A Rainbow Relayer on Ethereum captures the event and relays it to a Rainbow Contract on TFSC.
The Rainbow Contract on TFSC verifies the event and mints 100 ETH on TFSC for Bob.
The Rainbow Bridge mechanism ensures that the total supply of assets is preserved across different chains and that the cross-chain transactions are secure and trustless.
Conclusion
Transformers (TFSC) is a decentralized public chain that uses a novel consensus protocol called Raindrop, which combines the advantages of PoS and DPoS to achieve high performance, security, and decentralization. TFSC also supports smart contracts compatible with EVM and WASM virtual machine. TFSC also supports cross-chain interoperability by using a Rainbow Bridge mechanism that allows assets and data to be transferred between TFSC and other chains. TFSC is a project that follows the principles of decentralization, autonomy, equality, and freedom.