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

Make sure to clear setAskFor in Dash submodules #1730

Merged
merged 3 commits into from
Nov 22, 2017

Conversation

UdjinM6
Copy link

@UdjinM6 UdjinM6 commented Nov 19, 2017

Thanks @sidhujag for finding the bug

// TODO: clear setAskFor for MSG_MASTERNODE_PAYMENT_BLOCK too

if(pfrom->nVersion < GetMinMasternodePaymentsProto()) return;

Choose a reason for hiding this comment

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

not needed because if node is misbehaving by sending wrong peer version let setAskFor be not cleared to avoid DDOS .

Copy link
Author

Choose a reason for hiding this comment

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

Good point, fixed. As a side note, this should probably be moved to the top of CMasternodePayments::ProcessMessage to avoid serving outdated nodes completely but that's out of the scope for this PR.

@@ -909,6 +912,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData
CMasternodeVerification mnv;
vRecv >> mnv;

pfrom->setAskFor.erase(mnv.GetHash());

Choose a reason for hiding this comment

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

Did you mean mWeAskedForVerification? Where is MNVERIFY requested with an INV? Can you show how this MNVERIFY ended up calling setAskFor.insert() on the client side?

Copy link
Author

Choose a reason for hiding this comment

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

We relay mnv via inv in few places and like for all other cases, when the other node has no data yet, it asks us by sending inv back https://github.com/dashpay/dash/blob/master/src/net_processing.cpp#L1419 which updates setAskFor https://github.com/dashpay/dash/blob/master/src/net.cpp#L2761. So once we finally get data on the other node, we should clear setAskFor there. Or am I missing smth?

Choose a reason for hiding this comment

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

Ahh I see ok this one was a little convoluted and was a harder path to trace but found it's pushing INV here: https://github.com/dashpay/dash/blob/master/src/masternode.h#L405 so that relays PushInventory to all connected nodes which sets up setAskFor.insert later. That is a good catch and wasn't sure of it when I was implementing I did see it but was not sure. Thanks.

Copy link

@sidhujag sidhujag Nov 20, 2017

Choose a reason for hiding this comment

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

Do you think you need a

if(!masternodeSync.IsMasternodeListSynced()) return;

after line 915 where you added the setAskFor.erase()? I'm not sure if a MN message (case 2 & 3) can be verified if the list isn't synced?

Copy link
Author

Choose a reason for hiding this comment

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

Yep, makes sense not to process mnv until mn list is synced. Will fix, thanks! 👍

@@ -803,6 +804,8 @@ void CMasternodeMan::ProcessMessage(CNode* pfrom, std::string& strCommand, CData

pfrom->setAskFor.erase(nHash);

if(!masternodeSync.IsBlockchainSynced()) return;
Copy link

@sidhujag sidhujag Nov 20, 2017

Choose a reason for hiding this comment

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

Do you think this should be IsMasternodeListSynced instead of IsBlockchainSynced?, a MN ping should generally happen after you have the MN in question no? I do see that AskForMN is called at the end of this block of code if the MN is not found for some reason. Is it used for your created but not yet broadcast MN for some reason?

Copy link
Author

Choose a reason for hiding this comment

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

Processing pings while in mn list sync state is ok. DSEG actually sends last ping invs together with mnb invs and (in general) there should be not that much of an overhead here imo. I woudn't touch it (at least for now).

@sidhujag
Copy link

ACK

@UdjinM6 UdjinM6 added this to the 12.2.2 milestone Nov 22, 2017
@UdjinM6 UdjinM6 merged commit 5d58dd9 into dashpay:develop Nov 22, 2017
@UdjinM6 UdjinM6 added the bug label Dec 13, 2017
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Dec 26, 2018
* Make sure to clear setAskFor in Dash submodules

Thanks @sidhujag for finding the bug

* partially revert previous commit

* skip mnv until mn list is synced
@UdjinM6 UdjinM6 deleted the clearsetaskfor branch November 26, 2020 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants