Proposal: Improving Godwoken Block time to Optimize User Experience

Abstract

The current Godwoken block interval is ~30 - 40 seconds. This block time is longer than that of Ethereum and other layer-2 chains.

The long block interval causes Metamask and some other Ethereum tools to take a longer time to display transaction results, which causes a poor user experience. The proposed changes will speed up the Godwoken block time and improve the user experience.

This proposal also discusses a new strategy to improve the syncing and submission of layer-2 blocks.

Motivation

In the early version of Godwoken, we kept the long layer-2 block interval for two reasons:

  1. Longer block interval ensured the reduction of transaction frequency submission to CKB, which saved more Layer-1 block space.

  2. Longer block interval allowed for a simple syncing strategy: The Godwoken nodes subscribe to the CKB chain where it reads Layer-2 related transactions and then applies layer-2 blocks to the local state.

Metamask only starts to update a transaction’s status after the latest block number of the chain is bumped. Thus, since Godwoken has a long block interval (~30 - 40 seconds), Metamask won’t try to query the transaction result even if the transaction is already processed. Ethereum tools don’t exactly behave the same, and this causes some problems for transactions on Godwoken.

In the v0 version of Godwoken, we offered an instant finality feature to improve user experience. Users could get the result immediately after sending a transaction. Unfortunately, users cannot have this experience in the v1 version of Godwoken. To improve compatibility with the EVM, we removed the web3-provider plugin in v1 to support RPC level compatibility. Users can use Metamask or tools to directly talk to the Godwoken chain.

To solve this problem, we decided to speed up the block time. To speed up the block time, we can lower the interval; This ensures that the user can see transactions as they are updated in Metamask. Besides this, there is an increase in the number of Layer-2 transactions per second (TPS).

Thus, we believe that speeding up the block time interval production of Godwoken can improve the user experience, increase compatibility with the Ethereum toolchain, and speed up the Layer-2 TPS.

Overview

In the current implementation, we use a simple syncing and submitting strategy:

  1. Godwoken node subscribes to rollup related layer-1 transactions from CKB, then extracts the layer-2 block from these transactions.
  2. Node applies a new layer-2 block to the local state.
  3. If the node is a block producer, it produces a new layer-2 block and submits it to CKB.

This current process has a bottleneck. After the node sends a layer-2 block to CKB, it stops producing new blocks until the transaction is submitted on CKB, and it usually takes 3 ~ 4 CKB blocks (at least 24s ~ 32s). Since CKB has its unique proposal mechanism (CKB consensus protocol), the 3 ~ 4 CKB blocks to submit are almost the best we can do.

We propose a more sophisticated strategy to separate the block syncing, producing, and submitting process.

Syncing:

  1. The node subscribes to CKB and extracts layer-2 block from CKB transactions.
  2. If the node is read-only, it receives new blocks from the block producer node via a P2P protocol.
  3. Then, the node applies the Layer-2 block to the local state.

Producing:

  1. The block producer node produces new blocks every few seconds.
  2. The block producer node applies the new block into the local state before sending it to CKB.
  3. The node also sends the new block to read-only nodes via P2P protocol.
  4. Then, the node pushes the new block into a local submitting queue.

Submitting:

  • The block producer node fetches Layer-2 blocks from the local submitting queue and submits them to CKB.

This strategy can decouple the Layer-2 block syncing, production, and submitting, removing CKB block time dependency. The submission of Layer-2 transactions is constrained by CKB block space. If Layer-2 produces new blocks fast enough, it will occupy more block space than CKB can supply, and the submission queue will grow, reaching its limit. The node stopped submitting and waited for CKB to package transactions.

The submission, therefore, is this: We can choose a block time that can support a good user experience and does not occupy too much CKB block space.

  • CKB block supply is 597K every 8s in the best situation (see consensus.rs)
  • An ERC-20 transaction represented in a layer-2 block is 253 bytes

If we reduce the block time to ~8s, in the best condition, we can easily reach 200 TPS (let’s ignore other factors for now).

Compatibility

This change may affect some contracts, especially Defi contracts which use block numbers to calculate interests. To fix this problem, developers need to upgrade their contracts and use block timestamps to calculate interests. Fortunately, many developers already have this implemented.

Summary

We have suggested changes above that we believe will improve the user experience, bring us more inline with ethereum compatibility and increase Godwoken TPS. Please feel free to share your feedback below on the suggested changes.

7 Likes

This is an awesome post!

We should also bring this kind of discussion on twitter to make more people aware of.

2 Likes