Skip to content

Conversation

amesgen
Copy link
Member

@amesgen amesgen commented Jul 3, 2025

Peras staging ground, only used for running CI

@amesgen amesgen marked this pull request as draft July 3, 2025 14:00
@amesgen amesgen force-pushed the peras-staging branch 3 times, most recently from 4c69d1c to 1390449 Compare July 24, 2025 14:12
@amesgen amesgen changed the base branch from main to amesgen/minor-chaindb-stuff July 24, 2025 14:12
Base automatically changed from amesgen/minor-chaindb-stuff to main July 28, 2025 09:38
amesgen added 12 commits August 13, 2025 16:39
It is not necessary to perform the garbage collection of the LedgerDB and the
map of invalid blocks in the same STM transaction. In the past, this was
important, but it is not anymore, see
#1507.
Primarily, this is an optimization to reduce the maximum memory usage (more
relevant with the in-memory backend) when pruning happens on garbage collection
instead of while adding new blocks to the LedgerDB, see the added commit and the
benchmark in the pull request. Previously, LedgerDB garbage collection happened
as part of VolatileDB garbage collection, which was intentionally rate-limited.

Also, it resolves the current (somewhat weird) behavior that we do not copy any
blocks to the ImmutableDB when we are taking a snapshot (which can take >2
minutes), and consequently also not garbage-collecting the VolatileDB.

It also synergizes with the planned feature to add a random delay when taking
snapshots.
Also make sure to account for the fact that the DbChangelog might have gotten
pruned between opening and committing the forker.
regarding the previous few commits
It was already superseded in the most important places due to
`LedgerDbPruneBeforeSlot`. Its remaining use cases are non-essential:

 - Replay on startup.

   In this case, we never roll back, so not maintaining k states is actually an
   optimization here. We can also remove the now-redundant `InitDB.pruneDb`
   function.

 - Internal functions used for db-analyser.

   Here, we can just as well use `LedgerDbPruneAll` (which is used by
   `pruneToImmTipOnly`) as we never need to roll back.

 - Testing.

   In particular, we remove some DbChangelog tests that previously ensured that
   only at most @k@ states are kept. This is now no longer true; that property
   is instead enforced by the LedgerDB built on top of the DbChangelog.

   A follow-up commit in this PR enriches the LedgerDB state machine test to
   make sure that the public API functions behave appropriately, ensuring that
   we don't lose test coverage (and also testing V2, which previously didn't
   have any such tests).
Make sure that we correctly fail when trying to roll back too far.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants