-
Notifications
You must be signed in to change notification settings - Fork 266
fix: persist last queried DA Height across full node restarts #2552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
c13c613
7e7a1af
f9e0333
73c6e4b
3258471
470ffc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,7 +47,13 @@ | |
| case blobsFoundCh <- struct{}{}: | ||
| default: | ||
| } | ||
| m.daHeight.Store(daHeight + 1) | ||
| newDAHeight := daHeight + 1 | ||
| m.daHeight.Store(newDAHeight) | ||
|
|
||
| // Persist the updated DA height in the state to survive restarts | ||
| if err := m.persistDAHeight(ctx, newDAHeight); err != nil { | ||
| m.logger.Error().Err(err).Uint64("newDAHeight", newDAHeight).Msg("failed to persist DA height") | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a potential race condition here. The in-memory atomic DA height ( This can lead to a situation where the node keeps processing new DA heights in-memory while failing to persist its progress. On a restart, it would revert to the last successfully persisted height, potentially causing it to re-process a large number of blocks. To ensure consistency, the atomic newDAHeight := daHeight + 1
// Persist the updated DA height in the state to survive restarts.
// Only advance the in-memory DA height after successful persistence
// to ensure that we retry the same height if persistence fails.
if err := m.persistDAHeight(ctx, newDAHeight); err != nil {
m.logger.Error().Err(err).Uint64("newDAHeight", newDAHeight).Msg("failed to persist DA height")
} else {
m.daHeight.Store(newDAHeight)
} |
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@claude this is a write per read, is there anyway you can optimise it, even if we write only every 50 or 100 blocks it should be fine since we are not going back thousands of blocks only 100
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Claude finished @tac0turtle's task —— View job
Optimizing DA Height Persistence ✅
I've successfully optimized the DA height persistence to reduce write frequency as requested. The current implementation was writing to disk on every DA query (write per read), but now it batches writes to reduce I/O while maintaining reasonable restart recovery.
Todo List:
Solution Summary:
🚀 Performance Optimization:
⚙️ Configuration:
rollkit.da.persist_intervalconfig option (default: 100)--rollkit.da.persist_intervalflag🔒 Safety Features:
lastPersistedDAHeightvscurrentDAHeightpersist_intervalblocks (100 by default)🧪 Testing:
The optimization addresses your performance concern while keeping the restart recovery within acceptable bounds (~100 blocks maximum rollback vs thousands previously).