Cache RootLists with KVCachedFile#435
Conversation
8d83aad to
348153b
Compare
There was a problem hiding this comment.
Pull request overview
This PR introduces a disk-backed caching layer for the MPT archive RootList using common.KVCachedFile to prevent unbounded in-memory growth, and adds migration logic to convert the legacy roots.dat format into the new key+value format.
Changes:
- Add a new
root_list.goimplementingrootListon top ofKVCachedFilewith a versioned header + legacy migration. - Update
ArchiveTrieto use the newrootListAPI (error-returningGet/Append) and adjust verification to read roots viaGetAll. - Add comprehensive tests for root list persistence, migration, and checkpoint/restore behavior; update archive trie tests accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| go/database/mpt/root_list.go | New KVCachedFile-backed root list, including on-disk format/versioning and migration + restore/truncate helpers. |
| go/database/mpt/root_list_test.go | New/ported tests covering header/version, read/write roundtrips, migration, checkpoint integration, and truncate/restore flows. |
| go/database/mpt/archive_trie.go | Switch archive trie root handling to the new rootList methods and update verification/root access paths. |
| go/database/mpt/archive_trie_test.go | Update tests to construct a real rootList and remove tests tied to the old in-memory slice behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
31e8f03 to
b8660df
Compare
398e739 to
5e52d3b
Compare
a3b5937 to
5fe7d90
Compare
5e52d3b to
229b751
Compare
715ebc4 to
d1cbdc2
Compare
b3bcaa4 to
a916eb7
Compare
d1cbdc2 to
2d08ed1
Compare
2d08ed1 to
302db22
Compare
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (60.13%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
f562035 to
762ea25
Compare
a7bcb7e to
c216905
Compare
762ea25 to
6a284ef
Compare
c216905 to
e408190
Compare
3d0da97 to
0b3d2ea
Compare
e408190 to
004bb79
Compare
a5fe4c8 to
64dbc96
Compare
eb0362f to
5605fe5
Compare
f2d0294 to
d2cf3ea
Compare
780309c to
beb39b7
Compare
1fe2fa3 to
3dca1e1
Compare
The
RootListin the MPT archive implementation keeps all the root hashes in memory and can grow indefinitely.Similarly to #434, this PR adds a caching layer to
RootListby using theKVCachedFile.A new
KVFilecalledOrderedFileis added, an array-like storage with a key-file offset mapping.Closes https://github.com/0xsoniclabs/sonic-admin/issues/845