Understanding Optimistic Rollups: Arbitrum, Optimism and Others
Ethereum Blockchain has been facing scalability issues for a long time due to high network congestion (heavy load on Ethereum Blockchain), leading to higher gas fees. As a result, we have seen a lot of scaling solutions both off-chain and on-chain, some of them have tried to solve this issue but they are still not efficient and that’s why Rollups were introduced. The goal is to increase the transaction throughput and decrease latency while maintaining low gas costs, without compromising the security of a decentralized network.
Rollups are layer-2 scaling solutions that settle transactions off-chain but post the transaction data (also referred to as calldata) on-chain, thus maintaining the security of Ethereum. There are other scaling solutions too, like Sidechains and State Channels but these scaling solutions have reduced decentralization compared to layer-1 they are trying to scale as these solutions are controlled by single or multiple parties and much less secure compared to Rollups.
Now, there are 2 types of rollups based on how they verify the validity of transactions on Ethereum: Optimistic Rollups which rely on the assumption of honest validators, and ZK Rollups that are dependent on cryptographic proofs for fast verification.
What are Optimistic Rollups?
Optimistic Rollups are managed by smart contracts deployed on blockchain and process transactions off-chain but post transactions off-chain to an on-chain rollup contract. They can offer up to 10-100x improvements in scalability. They operate on a two-layer architecture.
- On-Chain Contracts
Smart Contracts store roll-up blocks, monitor state updates, and track user deposits. It is the settlement layer where the final state is stored.
- Off-Chain Virtual Machine (VM)
Although the contracts managing the rollup run on Ethereum, the computation and transaction batching are done off-chain. Validators monitor the transactions and submit fraud proofs if inconsistencies are detected.
Why the name Optimistic?
They are named Optimistic because the transactions are considered valid by default, i.e. the layer-2 chain doesn’t verify or validate the transactions before submitting them to mainnet unless it is challenged. It relies on economic incentives and fraud-proof mechanisms to ensure the validity of transactions.
How Optimistic Rollups Work?
If a user wants to use optimistic rollup they need to deposit some funds to the rollup smart contract, which then sends the equivalent native tokens of the layer-2 chain to the user via the sequencer.
Whenever a user transacts on the network, the sequencer - a special layer 2 node collects all transactions, batches them, and executes them off-chain. Once the transactions have been processed, a proof called a state root is generated which is the merkle root of the state of the system after the transactions have been executed. It submits the state root and transaction data to the mainnet. They also need to deposit some collateral similar to the Proof-Of-Stake (POS) mechanism. This acts as a deterrent against malicious actions. If they post an invalid block, their deposit is slashed.
Validators are the other layer-2 nodes that monitor the submitted roots, if they detect a discrepancy a challenge period is initiated. During the challenge period the validator submits fraud proof which is the data demonstrating the incorrectness of the State root. If the fraud-proof is valid, the rollup state is reverted and the sequencer’s deposit is slashed.
If the user wants to exit the roll-up chain, they initiate an exit request on the layer-2 chain (roll-up chain) which reverts the initially deposited funds to the user’s account. However, there is a waiting period, before the withdrawal is finalized during which a challenge period can be initiated.
Benefits of Optimistic Rollups
- Lower Transaction costs
Since the computation of transactions is done off-chain and processing transactions in batches, they submit minimal data to the network, resulting in lower gas costs. As a result, the Ethereum network will have reduced congestion times and more stable gas fees.
- Higher Throughput and Low Latency
By Processing multiple transactions off-chain, they can provide 10-100x improvement in the scalability resulting in high transaction speed and lower latency. Overall this leads to an improved user experience.
- Security
As the rollups publish the data on the mainnet and have fraud-proof mechanisms to ensure the validity of the published data, the base layer security is still maintained.
Challenges With Optimistic Rollups
- Delay caused during the Challenge Period
If there arises any discrepancy in the root provided by the sequencer challenge period is initiated which can last for 7 days, during this period if there is a single invalid transaction the whole batch of multiple transactions (whose combined state root is calculated) goes through the challenge period. During this period the layer-2 chain will be inconsistent with the mainnet and the user will have to wait for the challenge period to expire before withdrawing funds, resulting in a bad user experience.
- Accessing Layer-2 Chain
The layer-2 chain needs to be accessible for everyone challenging the generated state root, but if the data is corrupted or unavailable on the layer-2 chain, the users won’t be able to verify the state of the network, resulting in compromised security.
- Centralized Sequencers
Centralization always carries risk. In this case, the Centralized Sequencers can influence the network by manipulating or reordering the transactions.
- Possibility of No Honest Nodes
This model works on the principle that at least 1 node will be honest. Although this condition is rare, there is still a possibility that all the nodes can be malicious, which can lead to stealing funds and posting invalid data on the mainnet.
Projects working on Optimistic Rollups
Arbitrum stands out by focusing on optimizing Ethereum's scalability and reducing costs without compromising on security. It achieves this by offloading transaction processing from the mainnet, while still maintaining Ethereum's security.
Optimism is another Ethereum-compatible Layer 2 scaling solution which aims to lower fees and increase throughput, all while maintaining compatibility with Ethereum's existing infrastructure and smart contracts.
- Base
Base is Coinbase's Layer 2 scaling solution built on Optimism. It aims to make it easier for people to build decentralized apps and scale the Ethereum ecosystem. Base maintains compatibility with Ethereum's developer environment, ensuring easy migration and deployment for developers.
- Metis
Metis emphasizes community governance and decentralized autonomous companies (DACs). It provides an infrastructure to facilitate decentralized applications and DACs, fostering an environment for building decentralized businesses and communities.
Currently, Bitquery provides support for Arbitrum but we will be adding querying support for Optimism too in near future. So let's see how we can access Arbitrum data with the help of Bitquery’s Query IDE.
Accessing Arbitrum Data
Arbitrum, developed by Offchain labs, is one of the leading protocols providing Optimistic rollup solutions with TVL (Total Value Locked) around 2.51b$.
Top Traded Tokens on Arbitrum
With the help of Bitquery, You can get the top traded tokens on a specific network. This is the query to get top traded tokens on Arbitrum :
{
EVM(dataset: combined, network: arbitrum) {
DEXTrades(
limit: {count: 10}
orderBy: {descendingByField: "count"}
where: {Block: {Date: {since: "2024-01-11"}}}
) {
count
Trade {
Buy {
Currency {
Name
Symbol
SmartContract
}
}
}
}
}
}
Arbitrum Gas Prices
You can fetch the latest gas prices on the arbitrum network over last with this query:
{
EVM(dataset: combined, network: arbitrum) {
Transactions(
where: {Block: {Date: {till: "2024-01-10", since: "2024-01-01"}}, Transaction: {GasPrice: {gt: "0"}}}
limit: {count: 10}
orderBy: {descending: Block_Date}
) {
min: Transaction {
GasPrice(minimum: Transaction_GasPrice)
}
max: Transaction {
GasPrice(maximum: Transaction_GasPrice)
}
median(of: Transaction_GasPrice)
ChainId
Block {
Date
}
}
}
}
Top transferred NFTs
In order to fetch the address, number of Transfers, Unique Senders, Unique Receivers and more data about a NFT transfers you can use this query:
query ($limit: Int!, $offset: Int!) {
EVM(dataset: combined, network: arbitrum) {
Transfers(
orderBy: {descendingByField: "count"}
limit: {offset: $offset, count: $limit}
where: {Block: {Date: {till: "2024-01-10"}}, Transfer: {Currency: {Fungible: false}}}
) {
Transfer {
Currency {
Symbol
SmartContract
}
}
count
senders: uniq(of: Transfer_Sender, method: approximate)
receivers: uniq(of: Transfer_Receiver, method: approximate)
ids: uniq(of: Transfer_Id, method: approximate)
ChainId
}
}
}
Smart Contracts Deployed
To view the number of smart contracts deployed daily on the Arbitrum network, use this query:
{
EVM(network: arbitrum, dataset: combined) {
Calls(where: {Call: {Create: true}}, orderBy: {descendingByField: "Block_Date"}) {
Block {
Date
}
count
}
}
}
Conclusion
While Optimistic Rollups come with their challenges, they offer a promising pathway towards a more scalable and user-friendly Ethereum ecosystem. As these solutions continue to mature and address their limitations, they hold the potential to play a pivotal role in blockchain adoption. It’s an exciting time to be a part of this rapidly evolving landscape, and it’ll be fascinating to witness how Optimistic Rollups shape the future of decentralized applications in the years to come.
About Bitquery
Bitquery is a set of software tools that parse, index, access, search, and use information across blockchain networks in a unified way. Our products are:
- Coinpath® APIs provide blockchain money flow analysis for more than 24 blockchains. With Coinpath’s APIs, you can monitor blockchain transactions, investigate crypto crimes such as bitcoin money laundering, and create crypto forensics tools. Read this to get started with Coinpath®.
- Digital Assets API provides index information related to all major cryptocurrencies, coins, and tokens.
- DEX API provides real-time deposits and transactions, trades, and other related data on different DEX protocols like Uniswap, Kyber Network, Airswap, Matching Network, etc.
If you have any questions about our products, ask them on our Telegram channel or email us at sales@bitquery.io. Also, subscribe to our newsletter below, we will keep you updated with the latest in the cryptocurrency world.
Subscribe to our newsletter
Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.