Skip to content
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

blockstorage: Separate reindexing from saving new blocks #29975

Merged
merged 6 commits into from May 16, 2024

Commits on May 8, 2024

  1. blockstorage: Add Assume for fKnown / snapshot chainstate

    fKnown is true during reindex (and only then), which deletes
    any existing snapshot chainstate. As a result, this function can never
    be called wth fKnown set and a snapshot chainstate.
    Add an Assume for this, and make the code initializing a blockfile cursor
    for the snapshot conditional on !fKnown.
    
    This is a preparation for splitting the reindex logic out of
    FindBlockPos in the following commits.
    mzumsande committed May 8, 2024
    Configuration menu
    Copy the full SHA
    0d114e3 View commit details
    Browse the repository at this point in the history

Commits on May 14, 2024

  1. doc: Improve doc for functions involved in saving blocks to disk

    In particular, document the flat file positions expected and
    returned by functions better.
    
    Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
    mzumsande and ryanofsky committed May 14, 2024
    Configuration menu
    Copy the full SHA
    fdae638 View commit details
    Browse the repository at this point in the history
  2. blockstorage: split up FindBlockPos function

    FindBlockPos does different things depending on whether the block is known
    or not, as shown by the fact that much of the existing code is conditional on fKnown set or not.
    
    If the block position is known (during reindex) the function only updates the block info
    statistics. It doesn't actually find a block position in this case.
    
    This commit removes fKnown and splits up these two code paths by introducing a separate function
    for the reindex case when the block position is known.
    It doesn't change behavior.
    mzumsande committed May 14, 2024
    Configuration menu
    Copy the full SHA
    064859b View commit details
    Browse the repository at this point in the history
  3. validation, blockstorage: Separate code paths for reindex and saving …

    …new blocks
    
    By calling SaveBlockToDisk only when we actually want to save a new
    block to disk. In the reindex case, we now call UpdateBlockInfo
    directly from validation.
    
    This commit doesn't change behavior.
    mzumsande committed May 14, 2024
    Configuration menu
    Copy the full SHA
    d9e477c View commit details
    Browse the repository at this point in the history
  4. blockstorage: Rename FindBlockPos and have it return a FlatFilePos

    The new name reflects that it is no longer called with existing blocks
    for which the position is already known.
    
    Returning a FlatFilePos directly simplifies the interface.
    mzumsande committed May 14, 2024
    Configuration menu
    Copy the full SHA
    1710363 View commit details
    Browse the repository at this point in the history
  5. blockstorage: Don't move cursor backwards in UpdateBlockInfo

    Previously, it was possible to move the cursor back to an older file
    during reindex if blocks are enocuntered out of order during reindex.
    This would mean that MaxBlockfileNum() would be incorrect, and
    a wrong DB_LAST_BLOCK could be written to disk.
    
    This improves the logic by only ever moving the cursor forward (if possible)
    but not backwards.
    
    Co-authored-by: Martin Zumsande <mzumsande@gmail.com>
    ryanofsky and mzumsande committed May 14, 2024
    Configuration menu
    Copy the full SHA
    e41667b View commit details
    Browse the repository at this point in the history