Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport: bitcoin#15934, #15864, #19188, #18338, #19413, #18571, #18575 (deglobalization part 3) #4844

Merged
merged 12 commits into from
Jun 7, 2022

Conversation

kwvg
Copy link
Collaborator

@kwvg kwvg commented May 21, 2022

Additional Notes

  • Depends on merge bitcoin#16240...21526: assumeutxo project backports (part 2) #4703

  • During the backporting process, efforts to backport refactor: Remove confusing BlockIndex global bitcoin/bitcoin#19413 resulted in failures in the test suite

     dash@a623f8e4c33f:/dash-src$ ./src/test/test_dash -t wallet_tests
     Running 10 test cases...
     unknown location(0): fatal error: in "wallet_tests/ComputeTimeSmart": memory access violation at address: 0x00000028: no mapping at fault address
     wallet/test/wallet_tests.cpp(334): last checkpoint
    
     *** 1 failure is detected in the test module "Dash Core Test Suite"
     test_dash: ./checkqueue.h:202: CCheckQueue<T>::~CCheckQueue() [with T = CScriptCheck]: Assertion `m_worker_threads.empty()' failed.
     Aborted (core dumped)
    
    • In an attempt to debug this, it was discovered that in setup_common.cpp (source), m_node.peer_logic accepted *m_node.chainman as an argument before its initialisation, resulting in a dereferenced null pointer, that wasn't being used anywhere (yet).
    • The cause was later discovered to be m_node being overridden by every inherited class and that resulted in TestingSetup::TestingSetup's initialisation logic being rendered pointless (which included defining m_node.chainman). This was resolved by backporting test: Avoid overwriting the NodeContext member of the testing setup [-Wshadow-field] bitcoin/bitcoin#19188 (which in turn relies on the backport below)
  • Efforts to backport fuzz: Disable debug log file bitcoin/bitcoin#18571 (which plays a part in the backport mentioned above as its responsible for moving the definition of m_node from TestingSetup to its parent, BasicTestingSetup) resulted in failures in the test suite

    dash@a623f8e4c33f:/dash-src$ ./src/test/test_dash  -t wallet_tests
    Running 10 test cases...
    unknown location(0): fatal error: in "wallet_tests/importwallet_rescan": unknown type
    wallet/test/wallet_tests.cpp(203): last checkpoint: "importwallet_rescan" test entry
    
    dash@a623f8e4c33f:/dash-src$ ./src/test/test_dash -t flatfile_tests
    Running 4 test cases...
    test/flatfile_tests.cpp(97): error: in "flatfile_tests/flatfile_allocate": check fs::file_size(seq.FileName(FlatFilePos(0, 0))) == 100 has failed [321 != 100]
    test/flatfile_tests.cpp(101): error: in "flatfile_tests/flatfile_allocate": check fs::file_size(seq.FileName(FlatFilePos(0, 99))) == 100 has failed [321 != 100]
    test/flatfile_tests.cpp(105): error: in "flatfile_tests/flatfile_allocate": check fs::file_size(seq.FileName(FlatFilePos(0, 99))) == 200 has failed [321 != 200]
    test/flatfile_tests.cpp(119): error: in "flatfile_tests/flatfile_flush": check fs::file_size(seq.FileName(FlatFilePos(0, 1))) == 100 has failed [321 != 100]
    
    *** 4 failures are detected in the test module "Dash Core Test Suite"
    
    • Initial suspicion was placed on potential gArgs/m_node.args shenanigans, which resulted in debug and troubleshoot efforts similar to the previous backport. This turned out not to be the case.

    • The next step involved looking for backports done around that time period and through git blame-ing our way through pull requests, Fix wallet unload race condition bitcoin/bitcoin#18338 was backported. This unfortunately, didn't solve the problem either.

    • I decided to focus on the importwallet_rescan failure first and stepped through each line of the test case and the error was triggered when calling dumpwallet. We still didn't know the nature of the error and so I attempted to ask Boost.Test to politely stop catching exceptions and hand over control to the debugger using BOOST_TEST_IGNORE_NON_ZERO_CHILD_CODE (source). That did not help, at all.

      • To add insult to injury, to maximise debug information, I built it with the thread sanitiser enabled and it made stepping through using the debugger much more painful, it was faster to make clean and re-build everything than to step through with TSan enabled.
    • Finally, I decided to set a breakpoint within rpcdump.cpp (where dumpwallet is defined) and stepped through the routine, finally finding the reason why the test failure happened. A JSONRPCError exception (source) which seemed to indicate shenanigans with GetDataDir() was why.

      • git blame-ing through util/system.cpp resulted in backporting Fix datadir handling bitcoin/bitcoin#15864, which didn't help either.

        • Sidenote, this pull request addresses what dash#1494 addresses but as this solution is from upstream and conflicts with our current implementation, we have opted to prefer the upstream variant. This requires a revert.
      • Adding a std::cout print revealed that GetDataDir() was giving us /dash/.dashcore/regtest/wallet.backup instead of something like /tmp/test_common_Dash Core/dc97848d42956a1f35b76515f8b54088a89a8bbc87943435722a16b49197f151/regtest/wallet.backup violating defined behaviour (source), which took me down the gArgs/m_node.args rabbithole again which proved to not help.

      • Reading through the changes made in backport itself, out of curiosity I decided to check every function called by any additions and ParseParameters proved to be the source of our woes.

        Turns out, calling ForceSetArg before ParseParameters means exactly squat as ParseParameters will erase all overrides before parsing its argument (source). Searching through, the source tree of the original bitcoin backport, Merge settings one place instead of five places bitcoin/bitcoin#15934 was discovered. Did it help? Yes. Did it just get backported easily? Nope!

    • Backporting Merge settings one place instead of five places bitcoin/bitcoin#15934 required dealing with some Dash-isms.

      • It required reversal of qt: Fix Repair tab #4715 due to the logic it introduced. Of course, only the implementation of the fix can be reversed, not the fix itself, so while backporting, GetCommandLineArgs needed to be re-worked around the backport.

      • ForceRemoveArg is a Dash-ism that, upon removal, will cause multiple test failures and so removal of it entirely seemed out of the question, thus requiring it to be re-adapted around the backport

        Note, this does result in behaviour change. ForceRemoveArg can no longer remove a network flag, unlike the pre-backport variant. This is due to underlying changes in ArgsManager. Luckily, I saw no such invocations and so continued further.

      • This alone did not solve test failures, which can be attributed to the backport removing the foremost hyphen of the argument key from its internal maps, this was remedied by a scripted change that removed all prefixed hyphens from ForceRemoveArg calls.

@kwvg kwvg marked this pull request as draft May 21, 2022 10:05
@kwvg kwvg force-pushed the deglobalization3 branch from 5cdebef to c5f3016 Compare May 21, 2022 10:08
@github-actions
Copy link

This pull request has conflicts, please rebase.

@kwvg kwvg force-pushed the deglobalization3 branch from c5f3016 to 423c081 Compare May 29, 2022 20:03
@kwvg kwvg force-pushed the deglobalization3 branch 2 times, most recently from e615bd6 to 191718e Compare June 2, 2022 18:48
@github-actions
Copy link

github-actions bot commented Jun 2, 2022

This pull request has conflicts, please rebase.

@kwvg kwvg force-pushed the deglobalization3 branch from 191718e to acb12bb Compare June 2, 2022 18:52
@kwvg kwvg changed the title merge bitcoin#15358...19779: deglobalization backports (part 3) backports: bitcoin#15358, 15934, 15384, 19188, 18338, 19413, 18571 Jun 2, 2022
@kwvg kwvg changed the title backports: bitcoin#15358, 15934, 15384, 19188, 18338, 19413, 18571 backports: bitcoin#15358, #15934, #15384, #19188, #18338, #19413, #18571 Jun 2, 2022
@kwvg kwvg changed the title backports: bitcoin#15358, #15934, #15384, #19188, #18338, #19413, #18571 backports: bitcoin#15358, #15934, #15384, #19188, #18338, #19413, #18571 (deglobalization part 3) Jun 2, 2022
@kwvg kwvg force-pushed the deglobalization3 branch from acb12bb to 632d49c Compare June 2, 2022 20:25
@kwvg kwvg requested review from UdjinM6 and PastaPastaPasta June 2, 2022 20:27
@UdjinM6
Copy link

UdjinM6 commented Jun 3, 2022

me reading PR description 😮

pls see https://github.com/UdjinM6/dash/commits/pr4844

@kwvg kwvg force-pushed the deglobalization3 branch from 632d49c to 62c15a3 Compare June 3, 2022 12:56
@kwvg kwvg changed the title backports: bitcoin#15358, #15934, #15384, #19188, #18338, #19413, #18571 (deglobalization part 3) backports: bitcoin#15934, #15864, #19188, #18338, #19413, #18571 (deglobalization part 3) Jun 3, 2022
@UdjinM6
Copy link

UdjinM6 commented Jun 3, 2022

dash_bench is broken... LGTM otherwise

@kwvg kwvg force-pushed the deglobalization3 branch from 62c15a3 to 9f23974 Compare June 3, 2022 15:21
@kwvg kwvg changed the title backports: bitcoin#15934, #15864, #19188, #18338, #19413, #18571 (deglobalization part 3) backports: bitcoin#15934, #15864, #19188, #18338, #19413, #18571, #18575 (deglobalization part 3) Jun 3, 2022
@kwvg kwvg force-pushed the deglobalization3 branch from 9f23974 to 104d4d6 Compare June 3, 2022 15:26
@kwvg
Copy link
Collaborator Author

kwvg commented Jun 3, 2022

New changes have been pushed that should fix dash_bench's assertion failure.

@kwvg kwvg marked this pull request as ready for review June 3, 2022 16:57
@UdjinM6 UdjinM6 added this to the 18.1 milestone Jun 3, 2022
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one nit (see inline comment). ready for review? ;)

Comment on lines +60 to +70
const TestingSetup* g_setup;
} // namespace

void initialize()
{
static RegTestingSetup setup{};
static TestingSetup setup{
CBaseChainParams::REGTEST,
{
"-nodebuglogfile",
},
};
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

18571: should is partial for now I guess. same changes should be applied to src/test/fuzz/process_messages.cpp which we don't have yet (18521 is a part of #4829)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or just remember to apply this patch to 18521.

Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 👍

@kwvg kwvg changed the title backports: bitcoin#15934, #15864, #19188, #18338, #19413, #18571, #18575 (deglobalization part 3) backport: bitcoin#15934, #15864, #19188, #18338, #19413, #18571, #18575 (deglobalization part 3) Jun 4, 2022
Copy link
Member

@PastaPastaPasta PastaPastaPasta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK for merging via merge commit

@PastaPastaPasta PastaPastaPasta merged commit 398c0bc into dashpay:develop Jun 7, 2022
@kwvg kwvg deleted the deglobalization3 branch July 18, 2023 11:41
PastaPastaPasta added a commit that referenced this pull request Sep 4, 2024
, bitcoin#22872, bitcoin#23477, bitcoin#23492, bitcoin#23713, bitcoin#23780, bitcoin#23826, bitcoin#23373, bitcoin#24201, bitcoin#24665, bitcoin#22910, partial bitcoin#23025 (addrman backports: part 3)

f032119 merge bitcoin#22910: Encapsulate asmap in NetGroupManager (Kittywhiskers Van Gogh)
8020bfa merge bitcoin#24665: document clang tidy named args (Kittywhiskers Van Gogh)
40a22e4 merge bitcoin#24201: Avoid InitError when downgrading peers.dat (Kittywhiskers Van Gogh)
cdcaf22 merge bitcoin#23373: Parse command line arguments from unit and fuzz tests, make addrman consistency check ratio easier to change (Kittywhiskers Van Gogh)
b30f0fa test: remove `connman` local from `BasicTestingSetup` (Kittywhiskers Van Gogh)
df43565 merge bitcoin#23826: Make AddrMan unit tests use public interface, extend coverage (Kittywhiskers Van Gogh)
c14a540 merge bitcoin#23780: update `addrman_tests.cpp` to use output from `AddrMan::Good()` (Kittywhiskers Van Gogh)
8b2db6b merge bitcoin#23713: refactor addrman_tried_collisions test to directly check for collisions (Kittywhiskers Van Gogh)
5b5dd39 merge bitcoin#23492: tidy up addrman unit tests (Kittywhiskers Van Gogh)
aba0ebd merge bitcoin#23477: tidy up unit tests (Kittywhiskers Van Gogh)
cdc8321 merge bitcoin#22872: improve checkaddrman logging with duration in milliseconds (Kittywhiskers Van Gogh)
8d22fe9 merge bitcoin#23084: avoid non-determinism in asmap-addrman test (Kittywhiskers Van Gogh)
ba46967 partial bitcoin#23025: update nanobench add `-min_time` (Kittywhiskers Van Gogh)
c28b05c merge bitcoin#22831: add addpeeraddress "tried", test addrman checks on restart with asmap (Kittywhiskers Van Gogh)
c4fe608 merge bitcoin#22226: add unittest core dump instructions (Kittywhiskers Van Gogh)

Pull request description:

  ## Additional Information

  * In [bitcoin#22831](bitcoin#22831), when restarting the node in `rpc_net.py`'s `test_addpeeraddress()`, existing commands need to be appended to `extra_args` to ensure they're retained when the node is restarted (default behavior is to overwrite the argument list with `extra_args`) to prevent the test from hanging and then failing due to missing fast DIP3 activation params from the arguments list.

    Missing arguments result in a block database sanity check failure on restart due to `bad-qc-premature` arising from the activation height being higher than the height of a block with a quorum commitment.

  * `NodeContext` was moved from `TestingSetup` to `BasicTestingSetup` in [bitcoin#18571](bitcoin#18571) ([dash#4844](#4844)) but `connman` as a `BasicTestingSetup` variable still stuck around (despite `NodeContext`'s presence making this unnecessary).

    To prepare for [bitcoin#22910](bitcoin#22910), the remnant variable has been replaced with `m_node.connman` and adjustments have been made to that effect.

  ## Breaking Changes

  None observed.

  ## Checklist:

  - [x] I have performed a self-review of my own code
  - [x] I have commented my code, particularly in hard-to-understand areas **(note: N/A)**
  - [x] I have added or updated relevant unit/integration/functional/e2e tests
  - [x] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_

ACKs for top commit:
  UdjinM6:
    utACK f032119
  PastaPastaPasta:
    utACK f032119

Tree-SHA512: b29c292ecda54cda8301ea804b433f80476a1cdbb72bd48740cc9b2e885a4ff52350e5e42f112426856282bd6d961f0e37f1b23020c52f07238413070bbc504a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants