hiero-ledger / hiero-ledger/hiero-consensus-node
VirtualMapStateLifecycleManager may create redundant virtual maps and MerkleDb databases
- Dominant language
- Java
- Stars
- 406
- Forks
- 226
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 210
Description
While working on https://github.com/hiero-ledger/hiero-consensus-node/issues/25937, I noticed a few sub-optimal things about `VirtualMapStateLifecycleManager`. For example, when a lifecycle manager is created, it builds a new `VirtualMapState` (including a new MerkleDb instance) right in the constructor. This happens regardless of how the lifecycle manager will be used later. If it loads a state from a snapshot, the initially created state will be just thrown away. Creating a MerkleDb instance and throwing it away is costly and may increase node startup time noticeably.
Besides that, some tests may be more complicated than needed. One of the tests (updated in 25937) is `StateFileManagerTests`. It creates a new lifecycle manager before every test case, then it gets destroyed and re-created. The underlying MerkleDb data sources are a total mess, a number of them are created and deleted, it happens asynchronously, and sometimes makes the tests fail in a weird way.
Contributor guide
Assessment
This issue has not been assessed yet.