refactor: add LIFETIMEBOUND to blockfilter where needed #25967

pull stickies-v wants to merge 1 commits into bitcoin:master from stickies-v:blockfilter-add-lifetimebound changing 2 files +9 −7
  1. stickies-v commented at 1:56 pm on August 31, 2022: contributor

    Noticed from #25637 (comment) that BlockFilter::GetFilter() returns a reference to a member variable. Added LIFETIMEBOUND to all blockfilter-related code to ensure that the return values do not have a lifetime that exceeds the lifetime of what it is bound to. See https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#lifetimebound or #25060 for a similar example.

    I used grep -E '[a-zA-Z>0-9][&*] ([a-zA-Z]*)\((.*)\)' src/**/blockfilter* to grep all possible occurrences (not all of them require LIFETIMEBOUND)

  2. in src/index/blockfilterindex.h:55 in 60063f1564 outdated
    49@@ -49,9 +50,9 @@ class BlockFilterIndex final : public BaseIndex
    50 
    51     bool Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_tip) override;
    52 
    53-    BaseIndex::DB& GetDB() const override { return *m_db; }
    54+    BaseIndex::DB& GetDB() const LIFETIMEBOUND override { return *m_db; }
    55 
    56-    const char* GetName() const override { return m_name.c_str(); }
    57+    const char* GetName() const LIFETIMEBOUND override { return m_name.c_str(); }
    


    MarcoFalke commented at 2:10 pm on August 31, 2022:
    unrelated, as it requires a ton of changes, but it would be nice to change this to return a const std::string&

    stickies-v commented at 3:54 pm on August 31, 2022:
    Agreed, I did a quick draft and it doesn’t seem like a big lift actually. Will follow up with PR shortly.

    stickies-v commented at 11:27 am on September 1, 2022:
  3. MarcoFalke approved
  4. MarcoFalke commented at 2:11 pm on August 31, 2022: member
    ACK. Seems unlikely that this would ever be used in a way to violate lifetimes, but adding the attribute can’t hurt.
  5. DrahtBot added the label Refactoring on Aug 31, 2022
  6. refactor: add LIFETIMEBOUND to blockfilter where needed
    Ensure that the return values do not have a lifetime that exceeds
    the lifetime of what it is bound to.
    See https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#lifetimebound
    89576ccc57
  7. stickies-v force-pushed on Aug 31, 2022
  8. stickies-v commented at 3:53 pm on August 31, 2022: contributor
    Rebase to fix CI failure - no other changes.
  9. brunoerg approved
  10. brunoerg commented at 4:35 pm on August 31, 2022: contributor

    crACK 89576ccc572fcaf9fb7117ad6124482cc95fbd9f

    Coincidentally I was studying about LIFETIMEBOUND this morning. Nice catch!

  11. MarcoFalke merged this on Sep 1, 2022
  12. MarcoFalke closed this on Sep 1, 2022

  13. stickies-v deleted the branch on Sep 1, 2022
  14. sidhujag referenced this in commit 502389d546 on Sep 1, 2022
  15. MarcoFalke referenced this in commit 5eb9781763 on Sep 16, 2022
  16. bitcoin locked this on Sep 1, 2023

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-12-04 18:12 UTC

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