Introducing BSC State Expiry Column

Background

As one of the most active blockchains at present, BSC still has a transaction volume of about 4m per day despite the deep bear market, see.

While more and more transactions bring ecological prosperity, it also increases the storage burden of the chain. The following table shows the changes in storage in recent years:

Jan 2022 Dec 2022 Jul 2023
Snapshot Size ~110GB ~182GB ~230GB
Trie Size ~205GB ~361GB ~422GB
KV Pair Size 1,556,469,670 2,537,724,945 3,275,945,602

It can be seen that the state of BSC is constantly growing, which is often referred to as the state bloat problem.

State Bloat Problem

Storage presents a significant challenge for many blockchains, the large storage size can cause several side effects on the chain:

  • higher hardware requirements;
  • increased network resources required for downloading & Sync;
  • performance degradation due to MPT write amplification;
  • centralization trend;

Perpetual Storage

The current mainstream blockchain system adopts the mode of one-time payment for perpetual storage, which is the main reason for the state explosion, especially those contracts with extremely low access frequency, which is an unnecessary burden. For example, the following contract:

The contract is the very popular NFT contract CryptoMines Worker (CMW) in the second half of 21, with 95 M slots, but in the past year/365 days, there only have 1050 txs, avg 2.8 tx/day. Less than 0.1% of the slots are in been visited in the past year.

What if there was some new mechanism to expire these burdens, while the chain promised that the state would still be available in the future?

Solution

In order to solve the above problems, the state expiry scheme is introduced, which changes the one-time payment for permanent storage. The simple workflow is as follows:

  1. If the state is not accessed for a certain period of time, such as one year, it will be marked as expired;
  2. Any expired state can be deleted from the MPT, but the cryptographic proof is still reserved for future revival;
  3. If the user needs to use the state in the future, it needs to generate a witness in the transaction and revive the state on the chain.

For specific scheme design and practice, refer to the state expiry column below.

State Expiry Column

The State Expiry Column is a collection of research and practice documents about the current BSC State Expiry, including BEP design, industry research, program comparison, POC verification, discussion of future feasible programs, etc. You can also find it in the Future Developments/State Expiry directory at docs.bnbchain.org.

The basic directory structure is as follows, please jump here for details:

Current Progress

At present, the design of design v0.3 version and the implementation of POC have been completed. For specific scheme design, please refer to BEP-206 and BEP-215.

You can try to run a POC version of the state expiry client through the Run State Expiry DevNet. Storage and Witness Analysis is a report on storage changes under the POC client, especially for contracts with extremely low access frequency, most of the storage will be saved. The characteristics of Partial Revive will keep the witness size at a low level.

Future

The team is still perfecting the program design, constantly studying the industry’s progress on state management and community feedback. Potential research topics are as follows:

  1. Application of verkle tree in state expiry scheme;
  2. How to design a more efficient state elimination mechanism, such as introducing state rent?
  3. The development of statelessness, the impact on state expiry, and the compatibility of future upgrades;
  4. How to promote ecological co-construction? How to promote the changes that affect the ecology? Or keep optimizing to reduce the impact?

Conclusion

Solving the state explosion problem of the blockchain is a common challenge faced by the entire industry. The current team is working hard to design and implement a state expiry POC, but this plan is expected to affect part of the ecology and requires continuous improvement and advancement by the community.

Welcome to join the state expiry discussion~

Here is the discussion about state expiry design, welcome to review & comment on it.

1 Like