Save client version to the settings file on shutdown #21171

pull jonatack wants to merge 2 commits into bitcoin:master from jonatack:persist-version-on-shutdown changing 2 files +29 −12
  1. jonatack commented at 8:05 PM on February 13, 2021: member

    Following an IRC conversation today, this patch proposes to persist CLIENT_VERSION as "lastrunversion" to the settings.json file on shutdown.

    This allows, for example, to detect if the user upgraded with code like

    if (CLIENT_VERSION > chain.getRwSetting("lastrunversion").get_int())
    

    so as to take various actions.

    Reviewers, this patch can be tested manually by opening <datadir>/signet/settings.json in your editor, starting and stopping signet, and watching the file be updated. One can also manually edit the setting and verify that the version is updated on shutdown.

    {
        "lastrunversion": 219900,
        "wallet": [
            ""
        ]
    }
    
  2. michaelfolkson commented at 8:15 PM on February 13, 2021: contributor

    Concept ACK (assuming no downsides)

    I think this could be useful for providing better logging around upgrades. Currently logging does not recognize when an upgrade is happening. Something like "First time running new version" "Successful upgrade to version x" etc

  3. DrahtBot added the label Tests on Feb 13, 2021
  4. Save client version to settings.json on shutdown b515b80779
  5. Add logging to test/functional/feature_settings.py 3a2f31ee90
  6. jonatack force-pushed on Feb 13, 2021
  7. jonatack commented at 10:23 PM on February 13, 2021: member

    Changed fieldname from "version" to "lastrunversion" per IRC suggestion by @luke-jr (thanks!)

  8. brunoerg commented at 12:34 AM on February 14, 2021: member

    Concept ACK

  9. ryanofsky commented at 4:08 AM on February 15, 2021: member

    I didn't read the IRC link, but this does not seem like a good idea. If you can't detect a new feature directly and need a flag to indicate when it's been enabled, you should probably set that flag at the time the feature is actually enabled (not shutdown) and choose a flag name and value clearly tied to the feature. This way behavior can be straightforward and reliable, not confusing and based on a flaky heuristic.

    (If in addition, the feature is backwards incompatible and you need to prevent bitcoin versions that don't support the feature from loading after it's enabled, implementing the -require=<feature> flag suggested #15935 (comment) could be a good approach.)

    In any case, would encourage opening an issue that clearly describes the problem so a good solution can be found.

  10. jonatack commented at 7:40 AM on February 15, 2021: member

    Thanks @ryanofsky. I learned more about the settings.json file doing this. Opened a patch for the specific case in #21181 instead.

  11. jonatack closed this on Feb 15, 2021

  12. curtcurt871 commented at 7:57 AM on February 15, 2021: none

    21171

  13. fanquake locked this on Feb 15, 2021

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-14 21:14 UTC

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