Skip to content

Conversation

@Fuzzbawls
Copy link
Collaborator

This is the finalization of the upstream PRs being tracked in #1374 to update much of our networking code to more closely follow upstream improvements. The following PRs are included here:

Additionally, during conflict resolution and backporting of 8085, the following additional upstream PR was included:

Still TODO in future PRs:

@Fuzzbawls Fuzzbawls added this to the 5.0.0 milestone Aug 19, 2020
@Fuzzbawls Fuzzbawls self-assigned this Aug 19, 2020
Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

Halfway through it. Looking pretty good so far. Few minor nits (feel free to ignore) and a couple questions (mostly around the masternode-sync area).

if (connman) {
connman->ForEachNode([nBlockEstimate, hashNewTip](CNode* pnode) {
if (chainActive.Height() > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) {
connman->ForEachNode([pindexNewTip, nBlockEstimate, hashNewTip](CNode* pnode) {
Copy link

Choose a reason for hiding this comment

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

nit:
would be good to standardize this and not input two different arguments from the same object. pindexNewTip arg, used to get the height, and hashNewTip are related to the same block.

We should pass only the primitive values or pass the block index pointer, not both. (I'm more inclined to pass both primitive values. We don't know how this will evolve in the future).
In other words, instead of passing pindexNewTip and removing nNewHeight from this function, input nNewHeight.

Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

Missed few ReleaseNodeVector in sneaky inlined if () return.

@furszy
Copy link

furszy commented Aug 25, 2020

would be nice to add a comment on top of the CopyNodeVector and ReleaseNodeVector methods to not forget to release them.

Something like:

// Creates a copy vector of vNodes adding a ref to each of them.
// Must call ReleaseNodeVector(vecNodes) when finish using it.
std::vector<CNode*> CopyNodeVector();

// Release the added references of nodes copied in CopyNodeVector().
void ReleaseNodeVector(const std::vector<CNode*>& vecNodes);

A further work would be to refactor CMasternodeSync::Process properly to be able to fit this flow into a function argument and pass it to a ForEachNodeCopy(Callable && func); and totally forget about copying & releasing the nodes vector.

theuni and others added 15 commits August 25, 2020 15:25
…rather than a std::function to eliminate std::function overhead
- Drop the interruption point directly after the pnode allocation. This would
    be leaky if hit.
- Rearrange thread creation so that the socket handler comes first
Also now that net threads are interruptible, switch them to use std
threads/binds/mutexes/condvars.
After bitcoin#8594 the addrFrom sent by a node is not used anymore at all,
so don't bother sending it.

Also mitigates the privacy issue in (bitcoin#8616). It doesn't completely solve
the issue as GetLocalAddress is also called in AdvertiseLocal, but at
least when advertising addresses it stands out less as *our* address.
Claims a peer makes about itself are inherently more credible.
@Fuzzbawls Fuzzbawls force-pushed the 2020_network-encapsulation branch from 1ac7d33 to f38c9f9 Compare August 25, 2020 22:59
Using ForEachNode ensures that we are still holding cs_vNodes when
dealing with a CNode* (as we should, for anything aside from existance
checking).
Using ForEachNodeContinueIf ensures that we are still holding cs_vNodes
when dealing with a CNode* (as we should, for anything aside from
existance checking).
@random-zebra random-zebra force-pushed the 2020_network-encapsulation branch from 973b9d7 to e733939 Compare August 25, 2020 23:59
@random-zebra
Copy link

Just pushed a few commits to properly lock cs_vNodes during mnsync and budget sync, removing the need for CopyNodeVector/ReleaseNodeVector. So my previous comment can be ignored.

Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

Code ACK. Really great backport. Will give it some live testing.

@furszy
Copy link

furszy commented Aug 26, 2020

same here, code ACK e733939. Nice work ☕ .

Copy link

@furszy furszy left a comment

Choose a reason for hiding this comment

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

Have been playing with the PR and all is looking good. Any other change can be done in a subsequent PR for me.
ACK e733939 .

Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

ACK e733939 and merging...

@random-zebra random-zebra merged commit 777638e into PIVX-Project:master Aug 27, 2020
@random-zebra random-zebra modified the milestones: 5.0.0, 4.3.0 Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants