util: improves error messages on get_previous_releases script #22442

pull NelsonGaldeman wants to merge 1 commits into bitcoin:master from NelsonGaldeman:improves-error-message-on-utils changing 1 files +5 −1
  1. NelsonGaldeman commented at 9:20 AM on July 14, 2021: contributor

    When previous releases are fetched and the specified version wasn't added to the checksum list we used to get a "Checksum did not match" which isn't true (https://github.com/bitcoin-core/bitcoincore.org/issues/753#issuecomment-879546719).

    If the specified version number is not on the list, it now logs cannot do the comparison instead.

  2. fanquake added the label Tests on Jul 14, 2021
  3. TheBlueMatt approved
  4. theStack commented at 11:34 AM on July 19, 2021: member

    Concept ACK, will test later

  5. in test/get_previous_releases.py:111 in 179f1b4bc8 outdated
     103 | @@ -104,7 +104,12 @@ def download_binary(tag, args) -> int:
     104 |      tarballHash = hasher.hexdigest()
     105 |  
     106 |      if tarballHash not in SHA256_SUMS or SHA256_SUMS[tarballHash] != tarball:
     107 | -        print("Checksum did not match")
     108 | +        if sum_exists(tag[1:]):
     109 | +            print("Checksum did not match")
     110 | +            return 1
     111 | +
     112 | +        print("Cannot compare checksum for version {version}".format(
    


    rajarshimaitra commented at 11:59 AM on July 19, 2021:

    To me it seems like the new message isn't explaining the failure reason clearly.

    Maybe a "Checksum for given version doesn't exist" or something like that could help more?


    NelsonGaldeman commented at 12:21 PM on July 19, 2021:

    Agree, my wording wasn't the best! Thank you for the suggestion. Updated.

  6. rajarshimaitra commented at 12:00 PM on July 19, 2021: contributor

    Concept ACK with an error message comment.

  7. NelsonGaldeman force-pushed on Jul 19, 2021
  8. in test/get_previous_releases.py:130 in e217dca88e outdated
     122 | @@ -119,6 +123,13 @@ def download_binary(tag, args) -> int:
     123 |      return 0
     124 |  
     125 |  
     126 | +def checksum_exists(version) -> bool:
     127 | +    for sum in SHA256_SUMS:
     128 | +        if "bitcoin-" + version in SHA256_SUMS[sum]:
     129 | +            return True
     130 | +    return False
    


    theStack commented at 8:06 PM on July 19, 2021:

    I think this could be simplified to a one-liner (maybe it could directly be used above then instead of introducing an extra function):

        return "bitcoin-" + version in SHA256_SUMS.values()
    

    theStack commented at 8:34 PM on July 19, 2021:

    Looking a second time at it, that was too simple-thought; it should be more like

        return any("bitcoin-" + version in str for str in SHA256_SUMS.values())
    

    NelsonGaldeman commented at 8:21 AM on July 20, 2021:

    Yes absolutely! My python is a little bit rusty it's been a while. I didn't know I could do that, it looks cleaner. Thank you!

  9. in test/get_previous_releases.py:107 in e217dca88e outdated
     103 | @@ -104,7 +104,11 @@ def download_binary(tag, args) -> int:
     104 |      tarballHash = hasher.hexdigest()
     105 |  
     106 |      if tarballHash not in SHA256_SUMS or SHA256_SUMS[tarballHash] != tarball:
     107 | -        print("Checksum did not match")
     108 | +        if checksum_exists(tag[1:]):
    


    theStack commented at 8:12 PM on July 19, 2021:

    nit: could also pass the full filename (tarball) here, then the function checksum_exists below wouldn't need to add the "bitcoin-" prefix and is more specific?


    NelsonGaldeman commented at 8:18 AM on July 20, 2021:

    I purposely avoided passing the full name in case the naming convention changes it will still work. Thinking more about it would be helpful to check the full name as it will throw the checksum doesn't exist if we are missing a specific OS/arch on the list even if we included some for that same version.

  10. theStack commented at 8:14 PM on July 19, 2021: member

    Left two possible improvements that came up while reviewing the code. Couldn't test yet (the machine I am using right now is running OpenBSD, where the script doesn't work; even if the platform is overrided to e.g. 'x86_64-linux-gnu', the tar command fails), but will do tomorrow on a Linux machine.

  11. fanquake commented at 2:54 AM on July 20, 2021: member

    even if the platform is overrided to e.g. 'x86_64-linux-gnu', the tar command fails),

    That sounds like something we should be able to fixup.

  12. util: improves error messages on get_previous_releases script
    If a requested version doesn't exist on our list of checksums it says it cannot do a checksum comparision instead of saying it did not match
    179a051704
  13. NelsonGaldeman force-pushed on Jul 20, 2021
  14. theStack approved
  15. theStack commented at 9:54 AM on July 20, 2021: member

    tACK 179a051704321ba40277a5855d6ac0dbb45689dd, tested on Debian bullseye/sid

    master branch:

    $ ./test/get_previous_releases.py -b v0.21.0
    Releases directory: releases
    Fetching: https://bitcoincore.org/bin/bitcoin-core-0.21.0/bitcoin-0.21.0-x86_64-linux-gnu.tar.gz
    [ ... ]
    Checksum did not match
    $ echo $?
    1
    

    PR branch:

    $ ./test/get_previous_releases.py -b v0.21.0
    Releases directory: releases
    Fetching: https://bitcoincore.org/bin/bitcoin-core-0.21.0/bitcoin-0.21.0-x86_64-linux-gnu.tar.gz
    [ ... ]
    Checksum for given version doesn't exist
    $ echo $?
    1
    

    By the way, welcome as a new contributor NelsonGaldeman! 🎉

    even if the platform is overrided to e.g. 'x86_64-linux-gnu', the tar command fails),

    That sounds like something we should be able to fixup.

    Yes, will take a look into that.

  16. practicalswift commented at 8:03 PM on July 24, 2021: contributor

    cr ACK 179a051704321ba40277a5855d6ac0dbb45689dd

    Warm welcome as a new contributor @NelsonGaldeman! 🥇

  17. MarcoFalke merged this on Jul 25, 2021
  18. MarcoFalke closed this on Jul 25, 2021

  19. sidhujag referenced this in commit f0ef8d6a9b on Jul 28, 2021
  20. DrahtBot locked this on Aug 18, 2022

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: 2026-04-29 12:14 UTC

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