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

implement protocol 2.0; change db schema #101

Open
wants to merge 31 commits into
base: master
Choose a base branch
from

Commits on Oct 20, 2021

  1. Configuration menu
    Copy the full SHA
    dc7eb24 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    1877119 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    81d8dd1 View commit details
    Browse the repository at this point in the history
  4. history db: sort key insertion order

    Supposedly it makes a difference (see e.g. [0]), and depending on how batching
    works it makes sense it would, but during a few full syncs of testnet I've done,
    it was within measurement error. Still, existing code was already doing this.
    
    [0]: https://stackoverflow.com/q/54941342
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    92cb55c View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    9c22323 View commit details
    Browse the repository at this point in the history
  6. db: rm upgrade logic

    with the pending db changes, an upgrade is ~as fast as a resync from genesis
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    6d38d0f View commit details
    Browse the repository at this point in the history
  7. session: blockchain.transaction.get_merkle: make "height" optional

    now that we have our own txindex
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    1853023 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    90561ef View commit details
    Browse the repository at this point in the history
  9. history db: store a (prev_txnum, prev_idx)->spender_txnum map

    This will allow looking up which tx spent an outpoint.
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    4ebda7a View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    64189cc View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    95c6ce6 View commit details
    Browse the repository at this point in the history
  12. db: change TXOUTIDX_LEN from 4 to 3, to save db storage size

    In Bitcoin consensus, a txout index is stored as a uint32_t.
    However, in practice, an output in a tx uses at least 10 bytes (for an OP_TRUE output), so
    - to exhaust a 2 byte namespace, a tx would need to have a size of at least 2 ** 16 * 10 = 655 KB,
    - to exhaust a 3 byte namespace, a tx would need to have a size of at least 2 ** 24 * 10 = 167 MB.
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    4326ae7 View commit details
    Browse the repository at this point in the history
  13. session: implement "blockchain.outpoint.subscribe" RPC

    notifications not implemented yet
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    3a41279 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    7c7612b View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    65a7dd3 View commit details
    Browse the repository at this point in the history
  16. "blockchain.outpoint.subscribe" RPC: distinguish heights "-1" and "0"

    Similar to scripthash statuses, the height of an unconfirmed tx is:
    - `-1` if it has any unconfirmed parents,
    - `0` otherwise.
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    b87a8ea View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    79e2690 View commit details
    Browse the repository at this point in the history
  18. session: wait for protocol ver negotiation to finish before other reqs

    We already enforce that server.version must be the first received message
    in a session, but we also need to ensure that the server finishes processing
    that message and sets up the correct protocol version before starting to
    process further messages.
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    8b7efde View commit details
    Browse the repository at this point in the history
  19. (bugfix) db: change tx_num endianness (LE->BE) to match db comparator

    History.get_txnums and History.backup depend on ordering of tx_nums,
    so we want the lexicographical order (used by leveldb comparator) to
    match the numerical order.
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    f410565 View commit details
    Browse the repository at this point in the history
  20. protocol change: define order of mempool txs in status of scripthash

    Note that this is a soft fork: the server can apply it even for past
    protocol versions.
    
    Previously, with the order being undefined, if an address had multiple
    mempool transactions touching it, switching between different servers
    could result in a change in address status simply as a result of these
    servers ordering mempool txs differently. This would result in the client
    re-requesting the whole history of the address.
    
    -----
    
    D/i | interface.[electrum.blockstream.info:60002] | <-- ('blockchain.scripthash.subscribe', ['660b44502503064f9d5feee48726287c0973e25bc531b4b8a072f57f143d5cd0']) {} (id: 12)
    D/i | interface.[electrum.blockstream.info:60002] | --> 9da27f9df91e3f860212f65b736fa20a539ba6e3d509f6370367ee7f10a4d5b0 (id: 12)
    D/i | interface.[electrum.blockstream.info:60002] | <-- ('blockchain.scripthash.get_history', ['660b44502503064f9d5feee48726287c0973e25bc531b4b8a072f57f143d5cd0']) {} (id: 13)
    D/i | interface.[electrum.blockstream.info:60002] | --> [
    {'fee': 200, 'height': 0, 'tx_hash': '3ee6d6e26291ce360127fe039b816470fce6eeea19b5c9d10829a1e4efc2d0c7'},
    {'fee': 239, 'height': 0, 'tx_hash': '9e050f09b676b9b0ee26aa02ccee623fae585a85d6a5e24ecedd6f8d6d2d3b1d'},
    {'fee': 178, 'height': 0, 'tx_hash': 'fb80adbf8274190418cb3fb0385d82fe9d47a844d9913684fa5fb3d48094b35a'},
    {'fee': 200, 'height': 0, 'tx_hash': '713933c50b7c43f606dad5749ea46e3bc6622657e9b13ace9d639697da266e8b'}
    ] (id: 13)
    
    D/i | interface.[testnet.hsmiths.com:53012] | <-- ('blockchain.scripthash.subscribe', ['660b44502503064f9d5feee48726287c0973e25bc531b4b8a072f57f143d5cd0']) {} (id: 12)
    D/i | interface.[testnet.hsmiths.com:53012] | --> f7ef7237d2d62a3280acae05616200b96ad9dd85fd0473c29152a4a41e05686c (id: 12)
    D/i | interface.[testnet.hsmiths.com:53012] | <-- ('blockchain.scripthash.get_history', ['660b44502503064f9d5feee48726287c0973e25bc531b4b8a072f57f143d5cd0']) {} (id: 13)
    D/i | interface.[testnet.hsmiths.com:53012] | --> [
    {'tx_hash': '9e050f09b676b9b0ee26aa02ccee623fae585a85d6a5e24ecedd6f8d6d2d3b1d', 'height': 0, 'fee': 239},
    {'tx_hash': 'fb80adbf8274190418cb3fb0385d82fe9d47a844d9913684fa5fb3d48094b35a', 'height': 0, 'fee': 178},
    {'tx_hash': '3ee6d6e26291ce360127fe039b816470fce6eeea19b5c9d10829a1e4efc2d0c7', 'height': 0, 'fee': 200},
    {'tx_hash': '713933c50b7c43f606dad5749ea46e3bc6622657e9b13ace9d639697da266e8b', 'height': 0, 'fee': 200}
    ] (id: 13)
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    df12667 View commit details
    Browse the repository at this point in the history
  21. DB storage: implement iterator.seek(key)

    in a way that works consistently between LevelDB and RocksDB.
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    0494caf View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    312e61d View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    660deec View commit details
    Browse the repository at this point in the history
  24. "scripthash.get_history": impl updates for proto 1.5; no client_* yet

    Handling of client_statushash and client_height is not yet implemented.
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    36202d3 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    3dcb9f1 View commit details
    Browse the repository at this point in the history
  26. session: rework statushash calculation.

    If a client requested the status of a very busy address (with cold cache:
    no precalc yet), we might have gotten a timeout before we stored any
    intermediate status calculated. Then, if the client reconnected and
    requested the same, we would get stuck in this loop and never make progress.
    
    With this change, we try to store intermediate hashes sooner, so that even if
    there is a timeout, if the client reconnects there is less work to be done.
    SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    09a15fb View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    cee2d3f View commit details
    Browse the repository at this point in the history
  28. Array headers: fix type error

    JeremyRand authored and SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    2bfbc5c View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    31f8427 View commit details
    Browse the repository at this point in the history
  30. Array headers: Refactor AuxPoW

    JeremyRand authored and SomberNight committed Oct 20, 2021
    Configuration menu
    Copy the full SHA
    264daec View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    ef830fd View commit details
    Browse the repository at this point in the history