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

[WIP] Implement a UTXO cache #1373

Closed
wants to merge 21 commits into from
Closed

Commits on Jan 17, 2019

  1. blockchain: Add UTXO cache

    stevenroose authored and Roasbeef committed Jan 17, 2019
    Configuration menu
    Copy the full SHA
    c43a440 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    993ad95 View commit details
    Browse the repository at this point in the history
  3. Add cache size to netsync logger

    stevenroose authored and Roasbeef committed Jan 17, 2019
    Configuration menu
    Copy the full SHA
    435335a View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4a24053 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    ee0b302 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    aca65b9 View commit details
    Browse the repository at this point in the history
  7. blockchain: rollback blocks anytime utxo state is inconsistent

    Ideally we would only rollback the state when we had a hard shutdown in
    the middle of a flush but since the underlying db also has a cache that
    might not write our flushing state if there's a hard shutdown, we might
    not be able to detect that we shutdown in the middle of a flush. So to
    make sure we always restore properly we will always rollback the
    blockchain when the state is inconsistent.
    cpacia authored and Roasbeef committed Jan 17, 2019
    Configuration menu
    Copy the full SHA
    86fb6ef View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    e8f2a71 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    313755a View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    59a61a2 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    fc1ce97 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    fc976ee View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    054f12c View commit details
    Browse the repository at this point in the history
  14. blockchain: fix utxo reorg bug

    We hit a bug with the following setup. Block 559307(a) was mined
    creating a new utxo (u). An alternate block 559307(b) was mined which
    did not create u. Subsequently 559308 was mined on top of b which did
    create u again. So during the reorg u needed to go from unspent to
    spent(removed) when block a was disconnected, then
    back to unspent again when block 559308 was connected. However, the
    utxocache commit() function did not have the ability to override a utxo
    previously marked as spent back into an unspent state and thus u was
    left marked as spent. When 559309 was mined spending u, it failed to
    validate because u was erroneously marked as spent already.
    
    This commit patches the commit() function to allow overriding from spent
    to unspent.
    cpacia authored and Roasbeef committed Jan 17, 2019
    Configuration menu
    Copy the full SHA
    58a9b73 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    ef8bddd View commit details
    Browse the repository at this point in the history
  16. blockchain: fix bugs in UTXO rollback

    This fixes a couple bugs in the UTXO set reconstruction code.
    Specifically the roll forward starts one block too early resulting in a
    UTXO missing error.
    
    Also it was missing a break from the final rollforward loop which caused
    it to remain stuck forever.
    cpacia authored and Roasbeef committed Jan 17, 2019
    Configuration menu
    Copy the full SHA
    cef1899 View commit details
    Browse the repository at this point in the history

Commits on Jan 18, 2019

  1. utxocache: pre-size cache to max element size

    In this commit, we pre-allocate our cache to hold the maximum number of
    entries possible. We do this for two reasons:
    
      1. Go maps do not shrink when items are deleted from there, so we'll
      end up with a map of this size anyway.
    
      2. By doing our large allocation, we avoid doing many smaller
      allocations causing more GC pressure as we ramp up to our max cache
      size.
    
    To estimate the max size of the cache, we use the length of a p2pkh
    script since they're larger than p2wkh scripts, and p2wkh isn't as
    widespread yet.
    Roasbeef committed Jan 18, 2019
    Configuration menu
    Copy the full SHA
    18bd81f View commit details
    Browse the repository at this point in the history

Commits on Jan 21, 2019

  1. Configuration menu
    Copy the full SHA
    d33fb0f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    cd51c42 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    1357d0e View commit details
    Browse the repository at this point in the history

Commits on Feb 9, 2019

  1. Configuration menu
    Copy the full SHA
    836503d View commit details
    Browse the repository at this point in the history