2127-Replace epoch table with maintained finalized + live current views#2130
Open
Cmdv wants to merge 3 commits into
Open
2127-Replace epoch table with maintained finalized + live current views#2130Cmdv wants to merge 3 commits into
Cmdv wants to merge 3 commits into
Conversation
0001cda to
2de367d
Compare
2de367d to
7f25aa6
Compare
kderme
requested changes
May 28, 2026
Contributor
kderme
left a comment
There was a problem hiding this comment.
I added a test that shows a bug with rollbacks on epoch boundaries.
kderme
requested changes
May 28, 2026
| next_version int ; | ||
| BEGIN | ||
| SELECT stage_two + 1 INTO next_version FROM schema_version ; | ||
| IF next_version = 48 THEN |
| @@ -3,22 +3,25 @@ | |||
| module Test.Cardano.Db.Mock.Unit.Conway.CommandLineArg.EpochDisabled ( | |||
Contributor
There was a problem hiding this comment.
Could rename to Test.Cardano.Db.Mock.Unit.Conway.Epoch
| rollbackCache cache blockId | ||
| rollbackCache cache | ||
| -- The surviving block's epoch is no longer finalised; drop its (now stale) row so epoch_current takes over. | ||
| when (soptEpochViewEnabled (envOptions syncEnv)) $ |
Contributor
There was a problem hiding this comment.
put inside queryBlockNoAndEpoch
kderme
reviewed
May 28, 2026
| nBlocks <- lift $ DB.queryBlockCountAfterBlockNo (unBlockNo blkNo) True | ||
| mres <- lift $ DB.queryBlockNoAndEpoch (unBlockNo blkNo) | ||
| -- Use whenJust to silently skip if block not found | ||
| whenJust mres $ \(blockId, epochNo) -> do |
Contributor
There was a problem hiding this comment.
Add a test that this correctly rollbacks for blocks that are first or last of an epoch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
Drop the epoch table and its in-memory cache layer. The public epoch name is preserved as a
UNION ALLview ofepoch_finalized(table, appended per boundary, rolled back viaDELETE WHERE no > $epoch) andepoch_current(live view of the unfinalised epoch).A one-time backfill from block/tx runs on the first start after upgrade. Replaces the
--disable-epochCLI flag with thedisable_epochoption ininsert_options. Epoch true by default usingdisable_epochwill disable all epoch table related logic.This fixes #2127
Checklist
fourmoluon version 0.17.0.0 (which can be run withscripts/fourmolize.sh)Migrations
If there is a breaking change, especially a big one, please add a justification here. Please elaborate
more what the migration achieves, what it cannot achieve or why a migration is not possible.