Repository navigation
Conversation
BlockChain saves a quick-start checkpoint every checkpoint_every blocks (or minutes). BerkeleyDB commits run with DB_TXN_NOSYNC, so their log records can still sit in the in-process log buffer when the checkpoint is written. When the process is killed (power cut, OOM killer, SIGKILL), the checkpoint survives but the last blocks do not, and the next start fails with "startSequence > last_seq_in_db + 1". - csdb::Database::flush() (default no-op) and Storage::flush() - DatabaseBerkeleyDB::flush() writes and syncs the log (DbEnv::log_flush), once per checkpoint - BlockChain::applyBlockToCaches flushes the storage before it saves a checkpoint Same change in the community fork: #47. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Why this PR
BlockChain::applyBlockToCachessaves a quick-start checkpoint everycheckpoint_everyblocks (or minutes). BerkeleyDB commits run withDB_TXN_NOSYNC, so their log records can still sit in the in-process log buffer when the checkpoint is written. If the process is killed (power cut, OOM killer, SIGKILL), the checkpoint survives but the last blocks do not, and the next start fails with "startSequence > last_seq_in_db + 1". (The PR "a quick-start checkpoint ahead of the stored blocks is set aside" lets the node recover from such a checkpoint; this one avoids creating it.)What changes
csdb::Database::flush()(new virtual, default no-op) andcsdb::Storage::flush().DatabaseBerkeleyDB::flush()writes and syncs the log (DbEnv::log_flush).BlockChain::applyBlockToCachesflushes the storage before it saves a checkpoint (a failure is logged; the checkpoint is still saved, as today).Effect on the network
None on the wire or in consensus. One log sync per checkpoint.
Tests
Built and run on 4a95aaa (GCC 13). In the fork, robustness scenarios kill nodes (SIGKILL, power cut) and check that they start again from their checkpoints.
Same change in the community fork: CreditsCommunity#47, running on mainnet community nodes.