pruntime: Optional use RocksDB/redb as trie state backend #1265
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR moves the chain storage and phat contract storage onto Gramine's encrypted file system.
Prior to this, we used an in-memory
im::OrdMap
as the storage backend. However, with the growing amount of on-chain data and the number of phat contracts, memory storage would quickly become unsustainable. Therefore, we considered moving the data into the file system to solve the problem of memory explosion. In this PR, we use Gramine's encrypted file system to store RocksDB as the storage backend. The modification is based on the existing software architecture and is implemented by changing the internal implementation ofphala_trie_storage::TrieStorage
.In order to be compatible with the previous pruntime checkpoint, RocksDB is used only as a cache. That is to say, when pruntime takes snapshots, it will dump all the contents of RocksDB into the snapshot, and when pruntime starts, it will delete the RocksDB used last time and rebuild a new RocksDB instance from the snapshot.
To enable RocksDB, run pruntime with
--db=rocksdb
:What have been tested
After the modification, the following compatibility tests were made:
Overhead
I attempted to synchronize Khala blocks. It took twice as long compared to using a memory database
Merging
Because this PR may affect the stability of pRuntime, let's not merge it for the time being, we need a lot of testing on some test networks to ensure its stability.