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

Fix node protection logic false positives #3314

Merged
merged 1 commit into from
Feb 1, 2020

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Jan 31, 2020

We could be reading multiple messages from a socket buffer at once without actually processing them yet which means that fSuccessfullyConnected might not be switched to true at the time we already parsed VERACK message and started to parse the next one. This is basically a false positive and we drop a legit node as a result even though the order of messages sent by this node was completely fine. To fix this I partially reverted #2790 (where the issue was initially introduced) and moved the logic for tracking the first message into ProcessMessage instead.

Note: had to apply the same logic as in 13162 and 13946 (see #3305 ) to make it work while keeping changes minimal. Alternatively, we could merge 13162 and 13946 into develop first and then apply the rest of this patch on top (and backport them all to v0.15.x).

@UdjinM6 UdjinM6 added this to the 15 milestone Jan 31, 2020
@PastaPastaPasta
Copy link
Member

I think I'd prefer merging 13162 and 13946 into develop (and 0.15) and then apply this patch. I can split those 2 into a separate PR if you'd like. (otherwise stuff is gonna conflict and the git history wouldn't show us backporting 13162)

@UdjinM6
Copy link
Author

UdjinM6 commented Jan 31, 2020

Yeah, probably better to do it the other/alternative way. Will rebase.

We could be reading multiple messages from a socket buffer at once _without actually processing them yet_ which means that `fSuccessfullyConnected` might not be switched to `true` at the time we already parsed `VERACK` message and started to parse the next one. This is basically a false positive and we drop a legit node as a result even though the order of messages sent by this node was completely fine. To fix this I partially reverted dashpay#2790 (where the issue was initially introduced) and moved the logic for tracking the first message into ProcessMessage instead.
@UdjinM6 UdjinM6 force-pushed the fixmnauthrotection branch from 60a5094 to 266e84b Compare January 31, 2020 10:59
@UdjinM6
Copy link
Author

UdjinM6 commented Jan 31, 2020

Rebased. Will require backporting 13162 and 13946 to v0.15.x.

Copy link

@codablock codablock left a comment

Choose a reason for hiding this comment

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

utACK 👍

@codablock
Copy link

fyi, test failures on Gitlab seem unrelated

@UdjinM6 UdjinM6 merged commit df73438 into dashpay:develop Feb 1, 2020
UdjinM6 added a commit to UdjinM6/dash that referenced this pull request Feb 3, 2020
We could be reading multiple messages from a socket buffer at once _without actually processing them yet_ which means that `fSuccessfullyConnected` might not be switched to `true` at the time we already parsed `VERACK` message and started to parse the next one. This is basically a false positive and we drop a legit node as a result even though the order of messages sent by this node was completely fine. To fix this I partially reverted dashpay#2790 (where the issue was initially introduced) and moved the logic for tracking the first message into ProcessMessage instead.
MIPPL pushed a commit to MIPPL/biblepay that referenced this pull request May 15, 2020
* commit '351fbf65efc9459cb69a3c843cc205a8b94c95b3': (987 commits)
  Update release-notes
  Bump nMinimumChainWork and defaultAssumeValid (dashpay#3336)
  Update release notes
  Try to actually accept newly created dstx-es into masternode's mempool (dashpay#3332)
  Switch CLIENT_VERSION_IS_RELEASE to `true` for v0.15 (dashpay#3306)
  Update release notes
  Bring back "about" menu icon (dashpay#3329)
  Add pubKeyOperator to `quorum info` rpc response (dashpay#3327)
  Update release-notes.md
  Update translations 2020-02-03 (dashpay#3322)
  Only sync mempool from v0.15+ (proto 70216+) nodes (dashpay#3321)
  Fix dark text on dark background in combobox dropdowns on windows (dashpay#3315)
  Fix node protection logic false positives (dashpay#3314)
  Merge bitcoin#13162: [net] Don't incorrectly log that REJECT messages are unknown.
  More of 13946
  Merge bitcoin#13946: p2p: Clarify control flow in ProcessMessage
  Add `automake` package to dash-win-signer's packages list (dashpay#3307)
  [Trivial] Release note update (dashpay#3308)
  Update release-notes.md
  Fix CActiveMasternodeManager::GetLocalAddress to prefer IPv4 if multiple local addresses are known (dashpay#3304)
  ...

# Conflicts:
#	.gitignore
#	.travis.yml
#	COPYING
#	Makefile.am
#	README.md
#	ci/test_unittests.sh
#	configure.ac
#	contrib/README.md
#	contrib/debian/control
#	contrib/devtools/optimize-pngs.py
#	contrib/gitian-build.py
#	contrib/gitian-descriptors/gitian-linux.yml
#	contrib/gitian-descriptors/gitian-osx.yml
#	contrib/gitian-descriptors/gitian-win-signer.yml
#	contrib/gitian-descriptors/gitian-win.yml
#	contrib/init/README.md
#	contrib/seeds/README.md
#	contrib/verifybinaries/verify.sh
#	doc/README.md
#	doc/README_windows.txt
#	doc/build-generic.md
#	doc/build-unix.md
#	doc/files.md
#	doc/man/biblepay-cli.1
#	doc/man/biblepay-qt.1
#	doc/man/biblepay-tx.1
#	doc/man/biblepayd.1
#	doc/release-notes.md
#	doc/release-process.md
#	qa/README.md
#	qa/rpc-tests/autois-mempool.py
#	qa/rpc-tests/maxblocksinflight.py
#	qa/rpc-tests/multikeysporks.py
#	qa/rpc-tests/p2p-acceptblock.py
#	qa/rpc-tests/p2p-autoinstantsend.py
#	share/pixmaps/dash128.png
#	share/pixmaps/dash16.png
#	share/pixmaps/dash32.png
#	share/pixmaps/dash64.png
#	src/Makefile.am
#	src/Makefile.qt.include
#	src/Makefile.qttest.include
#	src/Makefile.test.include
#	src/addrman.h
#	src/alert.cpp
#	src/alert.h
#	src/bench/bls.cpp
#	src/bench/crypto_hash.cpp
#	src/biblepay-cli.cpp
#	src/biblepayd.cpp
#	src/blockencodings.cpp
#	src/bls/bls.cpp
#	src/bls/bls.h
#	src/bls/bls_worker.cpp
#	src/bls/bls_worker.h
#	src/cachemap.h
#	src/cachemultimap.h
#	src/chain.h
#	src/chainparams.cpp
#	src/checkpoints.cpp
#	src/clientversion.h
#	src/evo/cbtx.cpp
#	src/evo/cbtx.h
#	src/evo/deterministicmns.h
#	src/evo/evodb.cpp
#	src/evo/evodb.h
#	src/evo/providertx.cpp
#	src/evo/providertx.h
#	src/evo/simplifiedmns.h
#	src/evo/specialtx.cpp
#	src/evo/specialtx.h
#	src/flat-database.h
#	src/governance/governance-classes.cpp
#	src/governance/governance-exceptions.h
#	src/governance/governance-object.cpp
#	src/governance/governance-object.h
#	src/governance/governance-validators.cpp
#	src/governance/governance-validators.h
#	src/governance/governance-vote.h
#	src/governance/governance-votedb.cpp
#	src/governance/governance-votedb.h
#	src/governance/governance.cpp
#	src/hash.h
#	src/hdchain.cpp
#	src/hdchain.h
#	src/httpserver.cpp
#	src/init.cpp
#	src/instantx.cpp
#	src/instantx.h
#	src/keepass.cpp
#	src/keepass.h
#	src/llmq/quorums_blockprocessor.h
#	src/llmq/quorums_commitment.h
#	src/masternode/activemasternode.cpp
#	src/masternode/masternode-payments.cpp
#	src/masternode/masternode-sync.cpp
#	src/messagesigner.cpp
#	src/messagesigner.h
#	src/miner.cpp
#	src/net.cpp
#	src/net.h
#	src/net_processing.cpp
#	src/netbase.cpp
#	src/netfulfilledman.cpp
#	src/netfulfilledman.h
#	src/policy/feerate.cpp
#	src/policy/fees.cpp
#	src/pow.cpp
#	src/primitives/transaction.h
#	src/privatesend/privatesend-client.cpp
#	src/privatesend/privatesend-client.h
#	src/privatesend/privatesend-server.cpp
#	src/privatesend/privatesend-server.h
#	src/privatesend/privatesend-util.cpp
#	src/privatesend/privatesend-util.h
#	src/privatesend/privatesend.cpp
#	src/privatesend/privatesend.h
#	src/protocol.cpp
#	src/qt/addressbookpage.cpp
#	src/qt/addresstablemodel.cpp
#	src/qt/askpassphrasedialog.cpp
#	src/qt/biblepay.cpp
#	src/qt/biblepay.qrc
#	src/qt/bitcoingui.cpp
#	src/qt/clientmodel.h
#	src/qt/dash_locale.qrc
#	src/qt/dashstrings.cpp
#	src/qt/forms/helpmessagedialog.ui
#	src/qt/forms/masternodelist.ui
#	src/qt/forms/optionsdialog.ui
#	src/qt/guiconstants.h
#	src/qt/guiutil.cpp
#	src/qt/guiutil.h
#	src/qt/locale/biblepay_ar.ts
#	src/qt/locale/biblepay_bg.ts
#	src/qt/locale/biblepay_de.ts
#	src/qt/locale/biblepay_en.ts
#	src/qt/locale/biblepay_es.ts
#	src/qt/locale/biblepay_fi.ts
#	src/qt/locale/biblepay_fr.ts
#	src/qt/locale/biblepay_it.ts
#	src/qt/locale/biblepay_ja.ts
#	src/qt/locale/biblepay_ko.ts
#	src/qt/locale/biblepay_nl.ts
#	src/qt/locale/biblepay_pl.ts
#	src/qt/locale/biblepay_pt.ts
#	src/qt/locale/biblepay_ru.ts
#	src/qt/locale/biblepay_sk.ts
#	src/qt/locale/biblepay_sv.ts
#	src/qt/locale/biblepay_th.ts
#	src/qt/locale/biblepay_tr.ts
#	src/qt/locale/biblepay_vi.ts
#	src/qt/locale/biblepay_zh_CN.ts
#	src/qt/locale/biblepay_zh_TW.ts
#	src/qt/networkstyle.cpp
#	src/qt/optionsdialog.cpp
#	src/qt/overviewpage.cpp
#	src/qt/paymentserver.cpp
#	src/qt/res/css/bezaleel.css
#	src/qt/res/css/dark.css
#	src/qt/res/css/drkblue.css
#	src/qt/res/css/light-hires-retro.css
#	src/qt/res/css/light-hires.css
#	src/qt/res/css/light.css
#	src/qt/res/icons/about.png
#	src/qt/res/icons/about_qt.png
#	src/qt/res/icons/bezaleel/drkblue_address-book.png
#	src/qt/res/icons/bezaleel/drkblue_editcopy.png
#	src/qt/res/icons/bezaleel/drkblue_editpaste.png
#	src/qt/res/icons/bezaleel/drkblue_remove.png
#	src/qt/res/icons/bezaleel/fontbigger.png
#	src/qt/res/icons/bezaleel/fontsmaller.png
#	src/qt/res/icons/bezaleel/hd_disabled.png
#	src/qt/res/icons/bezaleel/hd_enabled.png
#	src/qt/res/icons/bezaleel/network_disabled.png
#	src/qt/res/icons/bezaleel/transaction_abandoned.png
#	src/qt/res/icons/bitcoin_testnet.png
#	src/qt/res/icons/browse.png
#	src/qt/res/icons/configure.png
#	src/qt/res/icons/crownium/fontbigger.png
#	src/qt/res/icons/crownium/fontsmaller.png
#	src/qt/res/icons/crownium/hd_disabled.png
#	src/qt/res/icons/crownium/hd_enabled.png
#	src/qt/res/icons/crownium/network_disabled.png
#	src/qt/res/icons/crownium/transaction_abandoned.png
#	src/qt/res/icons/dacicons/drkblue_editcopy.png
#	src/qt/res/icons/dacicons/drkblue_remove.png
#	src/qt/res/icons/debugwindow.png
#	src/qt/res/icons/drkblue/about.png
#	src/qt/res/icons/drkblue/masternodes.png
#	src/qt/res/icons/drkblue/overview.png
#	src/qt/res/icons/drkblue/tx_mined.png
#	src/qt/res/icons/drkblue/tx_output.png
#	src/qt/res/icons/filesave.png
#	src/qt/res/icons/fontbigger.png
#	src/qt/res/icons/fontsmaller.png
#	src/qt/res/icons/hd_disabled.png
#	src/qt/res/icons/hd_enabled.png
#	src/qt/res/icons/key.png
#	src/qt/res/icons/light-retro/about.png
#	src/qt/res/icons/light-retro/masternodes.png
#	src/qt/res/icons/light-retro/overview.png
#	src/qt/res/icons/light-retro/tx_mined.png
#	src/qt/res/icons/light/about.png
#	src/qt/res/icons/light/masternodes.png
#	src/qt/res/icons/light/overview.png
#	src/qt/res/icons/light/tx_mined.png
#	src/qt/res/icons/network_disabled.png
#	src/qt/res/icons/notsynced.png
#	src/qt/res/icons/quit.png
#	src/qt/res/icons/trad/about.png
#	src/qt/res/icons/trad/masternodes.png
#	src/qt/res/icons/trad/overview.png
#	src/qt/res/icons/trad/receive.png
#	src/qt/res/icons/trad/send.png
#	src/qt/res/icons/trad/tx_inout.png
#	src/qt/res/icons/trad/tx_input.png
#	src/qt/res/icons/trad/tx_mined.png
#	src/qt/res/icons/trad/tx_output.png
#	src/qt/res/icons/transaction_abandoned.png
#	src/qt/res/images/drkblue/about.png
#	src/qt/res/images/drkblue/checked.png
#	src/qt/res/images/drkblue/drkblue_walletFrame_bg.png
#	src/qt/res/images/drkblue/splash.png
#	src/qt/res/images/drkblue/splash_testnet.png
#	src/qt/res/images/drkblue/unchecked.png
#	src/qt/res/images/light-retro/about.png
#	src/qt/res/images/light-retro/checked.png
#	src/qt/res/images/light-retro/drkblue_downArrow.png
#	src/qt/res/images/light-retro/drkblue_downArrow_small.png
#	src/qt/res/images/light-retro/drkblue_leftArrow_small.png
#	src/qt/res/images/light-retro/drkblue_qtreeview_selected.png
#	src/qt/res/images/light-retro/drkblue_rightArrow_small.png
#	src/qt/res/images/light-retro/drkblue_upArrow_small.png
#	src/qt/res/images/light-retro/drkblue_walletFrame_bg.png
#	src/qt/res/images/light-retro/splash.png
#	src/qt/res/images/light-retro/splash_testnet.png
#	src/qt/res/images/light-retro/unchecked.png
#	src/qt/res/images/light/about.png
#	src/qt/res/images/light/checked.png
#	src/qt/res/images/light/drkblue_downArrow.png
#	src/qt/res/images/light/drkblue_downArrow_small.png
#	src/qt/res/images/light/drkblue_leftArrow_small.png
#	src/qt/res/images/light/drkblue_qtreeview_selected.png
#	src/qt/res/images/light/drkblue_rightArrow_small.png
#	src/qt/res/images/light/drkblue_upArrow_small.png
#	src/qt/res/images/light/drkblue_walletFrame_bg.png
#	src/qt/res/images/light/splash_testnet.png
#	src/qt/res/images/light/unchecked.png
#	src/qt/res/images/trad/about.png
#	src/qt/res/images/trad/drkblue_downArrow.png
#	src/qt/res/images/trad/drkblue_downArrow_small.png
#	src/qt/res/images/trad/drkblue_leftArrow_small.png
#	src/qt/res/images/trad/drkblue_qtreeview_selected.png
#	src/qt/res/images/trad/drkblue_rightArrow_small.png
#	src/qt/res/images/trad/drkblue_upArrow_small.png
#	src/qt/res/images/trad/drkblue_walletFrame_bg.png
#	src/qt/res/images/trad/splash.png
#	src/qt/res/images/trad/splash_testnet.png
#	src/qt/res/src/spinner.png
#	src/qt/rpcconsole.cpp
#	src/qt/sendcoinsdialog.cpp
#	src/qt/signverifymessagedialog.cpp
#	src/qt/splashscreen.cpp
#	src/qt/test/rpcnestedtests.cpp
#	src/qt/test/test_main.cpp
#	src/qt/test/uritests.cpp
#	src/qt/transactiondesc.cpp
#	src/qt/transactionrecord.cpp
#	src/qt/transactiontablemodel.cpp
#	src/qt/walletmodel.cpp
#	src/rpc/blockchain.cpp
#	src/rpc/governance.cpp
#	src/rpc/masternode.cpp
#	src/rpc/mining.cpp
#	src/rpc/misc.cpp
#	src/rpc/net.cpp
#	src/rpc/protocol.cpp
#	src/rpc/rawtransaction.cpp
#	src/rpc/rpcevo.cpp
#	src/rpc/server.cpp
#	src/script/biblepayconsensus.cpp
#	src/script/dashconsensus.h
#	src/sendalert.cpp
#	src/spork.cpp
#	src/spork.h
#	src/test/README.md
#	src/test/addrman_tests.cpp
#	src/test/alert_tests.cpp
#	src/test/amount_tests.cpp
#	src/test/blockencodings_tests.cpp
#	src/test/coins_tests.cpp
#	src/test/crypto_tests.cpp
#	src/test/cuckoocache_tests.cpp
#	src/test/data/alertTests.raw
#	src/test/merkle_tests.cpp
#	src/test/miner_tests.cpp
#	src/test/netbase_tests.cpp
#	src/test/pmt_tests.cpp
#	src/test/prevector_tests.cpp
#	src/test/ratecheck_tests.cpp
#	src/test/script_tests.cpp
#	src/test/sighash_tests.cpp
#	src/test/skiplist_tests.cpp
#	src/test/test_coin.cpp
#	src/test/test_coin.h
#	src/test/txvalidationcache_tests.cpp
#	src/test/util_tests.cpp
#	src/test/versionbits_tests.cpp
#	src/torcontrol.cpp
#	src/txdb.cpp
#	src/uint256.h
#	src/util.cpp
#	src/util.h
#	src/validation.cpp
#	src/validation.h
#	src/version.h
#	src/wallet/crypter.cpp
#	src/wallet/db.cpp
#	src/wallet/rpcdump.cpp
#	src/wallet/rpcwallet.cpp
#	src/wallet/test/crypto_tests.cpp
#	src/wallet/wallet.cpp
#	src/wallet/wallet.h
#	src/wallet/walletdb.cpp
#	test/functional/fundrawtransaction.py
#	test/functional/import-rescan.py
#	test/functional/merkle_blocks.py
#	test/functional/multi_rpc.py
#	test/functional/p2p-instantsend.py
#	test/functional/sporks.py
#	test/functional/test_framework/comptool.py
#	test/functional/test_framework/mininode.py
#	test/functional/test_framework/util.py
#	test/functional/wallet-hd.py
#	test/functional/wallet.py
FornaxA pushed a commit to ioncoincore/ion that referenced this pull request Jul 6, 2020
We could be reading multiple messages from a socket buffer at once _without actually processing them yet_ which means that `fSuccessfullyConnected` might not be switched to `true` at the time we already parsed `VERACK` message and started to parse the next one. This is basically a false positive and we drop a legit node as a result even though the order of messages sent by this node was completely fine. To fix this I partially reverted dashpay#2790 (where the issue was initially introduced) and moved the logic for tracking the first message into ProcessMessage instead.

Signed-off-by: cevap <dev@i2pmail.org>
@UdjinM6 UdjinM6 deleted the fixmnauthrotection branch November 26, 2020 11:37
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