bip68-sequence.py failing on master after recent net changes, due to mocktime interaction #9586

issue sdaftuar openend this issue on January 19, 2017
  1. sdaftuar commented at 6:59 pm on January 19, 2017: member

    Since 60befa399 in #9441, bip68-sequence.py (one of the extended rpc tests, not run by travis) has been failing:

     0Initializing test directory /var/folders/pw/k25spdv971g8xhccyx5t3yyr0000gn/T/test5y497icn/9191
     1Running test disable flag
     2Running test sequence-lock-confirmed-inputs
     3Running test sequence-lock-unconfirmed-inputs
     4Running test BIP68 not consensus before versionbits activation
     5Verifying nVersion=2 transactions aren't standard
     6Activating BIP68 (and 112/113)
     7Assertion failed: Block sync to height 432 timed out:
     8  {'hash': '05c02af44675851560cb13b1b59f2a7f08ff3bef4e3db19f6a08e79cb51cce62', 'height': 432}
     9  {'hash': '30f24ff219ac23291d1489710ad467726b7ab202f70923d4bd5707dacfb05051', 'height': 328}
    10  File "/Users/sdaftuar/projects/ccl-bitcoin/qa/rpc-tests/test_framework/test_framework.py", line 145, in main
    11    self.run_test()
    12  File "./bip68-sequence.py", line 58, in run_test
    13    self.activateCSV()
    14  File "./bip68-sequence.py", line 409, in activateCSV
    15    sync_blocks(self.nodes)
    16  File "/Users/sdaftuar/projects/ccl-bitcoin/qa/rpc-tests/test_framework/util.py", line 147, in sync_blocks
    17    maxheight, "".join("\n  {!r}".format(tip) for tip in tips)))
    18Stopping nodes
    19Not cleaning up dir /var/folders/pw/k25spdv971g8xhccyx5t3yyr0000gn/T/test5y497icn/9191
    20Failed
    

    I git bisected the problem back to the above commit; the issue seems to be that the inactivity checking at https://github.com/theuni/bitcoin/blob/60befa3997b98d3f913010f2621bec734f643526/src/net.cpp#L1298 is comparing times that are coming from two different places: GetTime() which can use mocktime, and GetTimeMicros() which does not, and the bip68-sequence.py test uses mocktime. (Using GetTimeMicros() for nLastRecv is newly introduced in the commit above.)

    Really, it’s sort of remarkable/lucky that we didn’t have test failures relating to how mocktime interacts with the networking code before. I’m not sure what the right way to fix this is – I started by trying to narrowly just fix this issue by changing nTimeConnected, nLastSend, and the starting nTime used in the inactivity check to all be based off system clock (eg GetTimeMicros()/1000000), but then that broke some of our other tests that I think must have been relying on mocktime having an effect on some of these things (maxuploadtarget.py, receivedby.py, and listtransactions.py all failed – I didn’t investigate exactly what happened so it’s possible my fix just had a simple mistake).

    Anyway I think we need a thoughtful approach to how to use GetTime() vs. GetTimeMicros() for the various times we have, especially in net.cpp/net_processing.cpp, and this is a bug that I think we need to fix for 0.14 so we’re not shipping broken tests.

  2. fanquake added the label Tests on Jan 20, 2017
  3. morcos commented at 3:09 pm on January 20, 2017: member

    @theuni Please tag 0.14

    I feel like issues sometimes get missed.

  4. theuni commented at 4:20 pm on January 20, 2017: member

    @sdaftuar Thanks for reporting. I’ve been wondering about this as well while working on #9566. The mocktime handling was quite inconsistent, and apparently moreso now :(. Will look into it in depth.

    What took me by surprise is that GetTimeMillis/Micros ignores mocktime in the first place.

  5. MarcoFalke added this to the milestone 0.14.0 on Jan 20, 2017
  6. laanwj closed this on Jan 26, 2017

  7. DrahtBot locked this on Sep 8, 2021


sdaftuar morcos theuni

Labels
Tests

Milestone
0.14.0


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

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