devtools, utxo-snapshot: Fix block height out of range in script #30690

pull pablomartin4btc wants to merge 1 commits into bitcoin:master from pablomartin4btc:devtools-fix-utxo_snapshot.sh-block-out-of-range changing 1 files +10 −0
  1. pablomartin4btc commented at 5:30 pm on August 21, 2024: member
    0/contrib/devtools/utxo_snapshot.sh 840000 snapshot2.dat ./src/bitcoin-cli -datadir=${AU_DATADIR}
    1Do you want to disable network activity (setnetworkactive false) before running invalidateblock? (Y/n): 
    2Disabling network activity
    3false
    4error code: -8
    5error message:
    6Block height out of range
    

    And the user will see the following in the node and it would stay there if not reset:

    02024-08-21T14:44:13Z UpdateTip: new best=00000000000000afa0cd000a16e244f56032735d41acd32ac00337aceb2a5240 height=235382 version=0x00000002 log2_work=69.987697 tx=17492185 date='2013-05-09T23:54:32Z' progress=0.016219 cache=71.0MiB(571085txo)
    12024-08-21T14:44:13Z UpdateTip: new best=0000000000000087c5e0b820afff496b95ba44ad64640c73b234d3261d3f99d2 height=235383 version=0x00000002 log2_work=69.987750 tx=17492341 date='2013-05-09T23:54:47Z' progress=0.016219 cache=71.0MiB(571291txo)
    22024-08-21T14:44:13Z UpdateTip: new best=000000000000014a4b5fddf3c8abb6209247255ca9e8df786b271dd1b2ac82a6 height=235384 version=0x00000002 log2_work=69.987804 tx=17492344 date='2013-05-10T00:20:18Z' progress=0.016219 cache=71.0MiB(571297txo)
    32024-08-21T14:44:13Z SetNetworkActive: false
    

    This is a “temporary” fix until #29553 gets merged, which will remove the script entirely.

    Handle the “Block height out of range” error gracefully by checking if the node has synchronized to or beyond the required block height, otherwise without this validation the node would keep the network disabled if the user selected that option.

    0/contrib/devtools/utxo_snapshot.sh 840000 snapshot2.dat ./src/bitcoin-cli -datadir=${AU_DATADIR}
    1Error: The node has not yet synchronized to block height 840001.
    2Please wait until the node has synchronized past this block height and try again.
    
  2. devtools, utxo-snapshot: Fix block height out of range
    Handle the Block height out of range error gracefully by checking if
    the node has synchronized to or beyond the required block height,
    otherwise without this validation the node would keep the network
    disabled if the user selected that option.
    
    Provide a user-friendly message if the block height is out of range
    and exit the script cleanly.
    5b4f34006d
  3. DrahtBot commented at 5:30 pm on August 21, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK fjahr, achow101

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #29553 (assumeutxo: Add dumptxoutset height param, remove shell scripts by fjahr)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. fanquake requested review from fjahr on Aug 24, 2024
  5. in contrib/devtools/utxo_snapshot.sh:41 in 5b4f34006d
    35@@ -36,6 +36,16 @@ if (( GENERATE_AT_HEIGHT < PRUNED )); then
    36   exit 1
    37 fi
    38 
    39+# Check current block height to ensure the node has synchronized past the required block
    40+CURRENT_BLOCK_HEIGHT=$(${BITCOIN_CLI_CALL} getblockcount)
    41+PIVOT_BLOCK_HEIGHT=$(( GENERATE_AT_HEIGHT + 1 ))
    


    fjahr commented at 11:10 am on August 25, 2024:
    nit: Could reuse that below in the PIVOT_BLOCKHASH= line but only if you have to retouch.
  6. fjahr commented at 11:17 am on August 25, 2024: contributor

    tACK 5b4f34006dbd76223b55b156421f87d2241ac296

    Reviewed the code and did some light testing.

    It’s unclear when #29553 will get merged and since we may see some people come in and try out assumeutxo for the first time when v28 is released so I think it’s ok to keep improving the script until then.

    This could have also been fixed in a simpler way by moving the PIVOT_BLOCKHASH= line below the two trap lines but I guess it’s nice to give users an understandable error message so I am fine with the approach.

  7. fanquake added this to the milestone 28.0 on Aug 25, 2024
  8. achow101 commented at 6:54 pm on August 26, 2024: member
    ACK 5b4f34006dbd76223b55b156421f87d2241ac296
  9. achow101 merged this on Aug 26, 2024
  10. achow101 closed this on Aug 26, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 12:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me