refactor: Use NodeClock::time_point in more places #34882

pull maflcko wants to merge 7 commits into bitcoin:master from maflcko:2603-net-less-GetTime changing 18 files +132 −120
  1. maflcko commented at 3:28 pm on March 20, 2026: member

    It is a bit confusing to have some code use the deprecated GetTime, which returns a duration and not a time point, and other code to use NodeClock time points.

    Fix a few more places to properly use time_point types.

  2. refactor: Use NodeClock alias over deprecated GetTime
    GetTime returns a duration, but a time point is the correct type to use
    here.
    
    This refactor does not change any behavior.
    fa2575e650
  3. util: Add NodeClock::epoch alias
    A default constructed time_point is the epoch, by definition.
    
    Existing code uses a default constructed (or explicitly constructed with
    a zero duration) chrono type to mean epoch. New code can now use
    NodeClock::epoch as an alias.
    fad7818b29
  4. DrahtBot renamed this:
    refactor: Use NodeClock::time_point in more places
    refactor: Use NodeClock::time_point in more places
    on Mar 20, 2026
  5. DrahtBot added the label Refactoring on Mar 20, 2026
  6. DrahtBot commented at 3:29 pm on March 20, 2026: contributor

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

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    LLM Linter (✨ experimental)

    Possible typos and grammar issues:

    • “fails connection” -> “fails to connect” [The phrase is grammatically incorrect and slightly unclear; readers may wonder what “fails connection” means.]

    • “or display N/A, if 0” -> “or display N/A if it is 0” [The clause is grammatically awkward and can be misread; adding “it is” makes the condition clear.]

    2026-03-20 15:54:48

  7. doc: Fix typo "eviction criterium" -> "eviction criterion"
    Also, clarify round-trip time to mean round-trip duration.
    fa94d5ab97
  8. refactor: Use NodeClock::duration for m_last_ping_time/m_min_ping_time/m_ping_wait
    This refactor does not change any behavior and is needed for a future
    commit, to avoid having to add duration casts.
    
    It also improves the docs to better document that this is not a time
    point, but a duration.
    
    Also, it uses decltype to explain where the _::max() is coming from.
    
    Also, it allows to drop a confusing gui code to get milliseconds:
    >>  (int)(count_microseconds(ping_time) / 1000)
    fab307c22f
  9. refactor: Use NodeClock::time_point for CNetMessage::m_time
    The field is not a duration, but a time point.
    fa3b0a8cb6
  10. refactor: Use NodeClock::time_point for m_last_send/recv and m_ping_start
    The two fields represent a time point, not a duration. Also, it is
    unclear why they use second precision.
    
    Fix both issues by using NodeClock::time_point.
    
    This refactor should not change any behavior and has a few other
    benefits:
    
    * It removes some std::chrono::duration_cast<std::chrono::seconds>
    * It removes some deprecated GetTime<...>() calls
    
    However, it also requires adding some temporary casts. They are marked
    with the magic string /*temp cast*/ and will be removed in the next
    commits.
    fa2c546cbc
  11. maflcko force-pushed on Mar 20, 2026
  12. DrahtBot added the label CI failed on Mar 20, 2026
  13. DrahtBot commented at 3:46 pm on March 20, 2026: contributor

    🚧 At least one of the CI tasks failed. Task 32 bit ARM: https://github.com/bitcoin/bitcoin/actions/runs/23349904881/job/67925442030 LLM reason (✨ experimental): CI failed because the C++ build broke with a std::chrono::duration_cast/time conversion compile error in src/util/time.h (triggering net.cpp/bitcoin_node compilation to fail).

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

  14. refactor: Use NodeClock::time_point for m_connected fa6bebf1cd
  15. maflcko force-pushed on Mar 20, 2026
  16. fanquake commented at 7:01 am on March 23, 2026: member

    https://github.com/bitcoin/bitcoin/actions/runs/23350972073/job/67929332277?pr=34882#step:11:2765:

     0Run node_eviction with args ['/home/admin/actions-runner/_work/_temp/build/bin/fuzz', '-runs=1', PosixPath('/home/admin/actions-runner/_work/_temp/ci/scratch/qa-assets/fuzz_corpora/node_eviction')]INFO: Running with entropic power schedule (0xFF, 100).
     1INFO: Seed: 1814253240
     2INFO: Loaded 1 modules   (629291 inline 8-bit counters): 629291 [0x613d409b64f8, 0x613d40a4ff23), 
     3INFO: Loaded 1 PC tables (629291 PCs): 629291 [0x613d40a4ff28,0x613d413ea1d8), 
     4INFO:      281 files found in /home/admin/actions-runner/_work/_temp/ci/scratch/qa-assets/fuzz_corpora/node_eviction
     5INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 572950 bytes
     6INFO: seed corpus: files: 281 min: 1b max: 572950b total: 15456954b rss: 99Mb
     7/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/chrono.h:225:38: runtime error: signed integer overflow: -9223372036854775808 * 1000000000 cannot be represented in type 'long'
     8    [#0](/bitcoin-bitcoin/0/) 0x613d3da2fc9b in std::chrono::duration<long, std::ratio<1l, 1000000000l>> std::chrono::__duration_cast_impl<std::chrono::duration<long, std::ratio<1l, 1000000000l>>, std::ratio<1000000000l, 1l>, long, false, true>::__cast<long, std::ratio<1l, 1l>>(std::chrono::duration<long, std::ratio<1l, 1l>> const&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/chrono.h:225:38
     9    [#1](/bitcoin-bitcoin/1/) 0x613d3da2fc9b in std::enable_if<__is_duration<std::chrono::duration<long, std::ratio<1l, 1000000000l>>>::value, std::chrono::duration<long, std::ratio<1l, 1000000000l>>>::type std::chrono::duration_cast<std::chrono::duration<long, std::ratio<1l, 1000000000l>>, long, std::ratio<1l, 1l>>(std::chrono::duration<long, std::ratio<1l, 1l>> const&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/chrono.h:287:11
    10    [#2](/bitcoin-bitcoin/2/) 0x613d3da2fc9b in std::chrono::duration<long, std::ratio<1l, 1000000000l>>::duration<long, std::ratio<1l, 1l>, void>(std::chrono::duration<long, std::ratio<1l, 1l>> const&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/chrono.h:582:10
    11    [#3](/bitcoin-bitcoin/3/) 0x613d3da2fc9b in std::chrono::time_point<NodeClock, std::chrono::duration<long, std::ratio<1l, 1000000000l>>>::time_point<std::chrono::duration<long, std::ratio<1l, 1l>>, void>(std::chrono::time_point<NodeClock, std::chrono::duration<long, std::ratio<1l, 1l>>> const&) /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/chrono.h:944:6
    12    [#4](/bitcoin-bitcoin/4/) 0x613d3da2fc9b in node_eviction_fuzz_target(std::span<unsigned char const, 18446744073709551615ul>) /home/admin/actions-runner/_work/_temp/src/test/fuzz/node_eviction.cpp:25:29
    13    [#5](/bitcoin-bitcoin/5/) 0x613d3de6372b in std::function<void (std::span<unsigned char const, 18446744073709551615ul>)>::operator()(std::span<unsigned char const, 18446744073709551615ul>) const /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/std_function.h:591:9
    14    [#6](/bitcoin-bitcoin/6/) 0x613d3de6372b in test_one_input(std::span<unsigned char const, 18446744073709551615ul>) /home/admin/actions-runner/_work/_temp/src/test/fuzz/fuzz.cpp:88:5
    15    [#7](/bitcoin-bitcoin/7/) 0x613d3de6372b in LLVMFuzzerTestOneInput /home/admin/actions-runner/_work/_temp/src/test/fuzz/fuzz.cpp:216:5
    16    [#8](/bitcoin-bitcoin/8/) 0x613d3d40aa19 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/admin/actions-runner/_work/_temp/build/bin/fuzz+0x1b35a19) (BuildId: f2fdc24d7e3ad46fa0430c8bd8ff9f3177fcf93d)
    17    [#9](/bitcoin-bitcoin/9/) 0x613d3d40a029 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) (/home/admin/actions-runner/_work/_temp/build/bin/fuzz+0x1b35029) (BuildId: f2fdc24d7e3ad46fa0430c8bd8ff9f3177fcf93d)
    18    [#10](/bitcoin-bitcoin/10/) 0x613d3d40bda2 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/home/admin/actions-runner/_work/_temp/build/bin/fuzz+0x1b36da2) (BuildId: f2fdc24d7e3ad46fa0430c8bd8ff9f3177fcf93d)
    19    [#11](/bitcoin-bitcoin/11/) 0x613d3d40c2c0 in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/home/admin/actions-runner/_work/_temp/build/bin/fuzz+0x1b372c0) (BuildId: f2fdc24d7e3ad46fa0430c8bd8ff9f3177fcf93d)
    20    [#12](/bitcoin-bitcoin/12/) 0x613d3d3f8b3d in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/admin/actions-runner/_work/_temp/build/bin/fuzz+0x1b23b3d) (BuildId: f2fdc24d7e3ad46fa0430c8bd8ff9f3177fcf93d)
    21    [#13](/bitcoin-bitcoin/13/) 0x613d3d424d06 in main (/home/admin/actions-runner/_work/_temp/build/bin/fuzz+0x1b4fd06) (BuildId: f2fdc24d7e3ad46fa0430c8bd8ff9f3177fcf93d)
    22    [#14](/bitcoin-bitcoin/14/) 0x78751bbc81c9  (/lib/x86_64-linux-gnu/libc.so.6+0x2a1c9) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
    23    [#15](/bitcoin-bitcoin/15/) 0x78751bbc828a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28a) (BuildId: 8e9fd827446c24067541ac5390e6f527fb5947bb)
    24    [#16](/bitcoin-bitcoin/16/) 0x613d3d3ed124 in _start (/home/admin/actions-runner/_work/_temp/build/bin/fuzz+0x1b18124) (BuildId: f2fdc24d7e3ad46fa0430c8bd8ff9f3177fcf93d)
    25
    26SUMMARY: UndefinedBehaviorSanitizer: signed-integer-overflow /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/chrono.h:225:38 
    

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-03-24 03:12 UTC

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