Defer inserting into maprelay until just before relaying. #8082

Merged
merged 1 commit into from Jun 1, 2016

Conversation

Projects
None yet
7 participants
Member

gmaxwell commented May 21, 2016 edited

This reduces the rate of not founds by better matching the far
end expectations, it also improves privacy by removing the
ability to use getdata to probe for a node having a txn before
it has been relayed.

@sipa sipa and 1 other commented on an outdated diff May 21, 2016

src/main.cpp
pto->filterInventoryKnown.insert(hash);
vInv.push_back(inv);
+ {
+ LOCK(cs_mapRelay);
+ if (mapRelay.find(inv.hash) == mapRelay.end()) {
@sipa

sipa May 21, 2016

Owner

More efficient:

auto ret = mapRelay.insert(std::make_pair(inv.hash, tx));
if (ret.second) {
    vRelayExpiration.push_back(std::make_pair(GetTime() + 16 * 60, inv.hash));
}
Member

MarcoFalke commented May 21, 2016

Looks like comparison tool triggers a POTENTIAL DEADLOCK DETECTED

laanwj added the P2P label May 21, 2016

Member

gmaxwell commented May 21, 2016

@MarcoFalke Yep. It was an actual inversion with the vSend lock, it's fixed.

Owner

laanwj commented May 22, 2016

Concept ACK

Nit: After this mapRelay is no longer used in net at all. It could become local to main.

Member

gmaxwell commented May 22, 2016 edited

@laanwj good catch with the nit, I've removed it from net.cpp/net.h.

Owner

sipa commented May 24, 2016

utACK d9d1f2e

sipa referenced this pull request May 24, 2016

Merged

p2p: Begin encapsulation #8085

Member

theuni commented May 24, 2016

ut ACK d9d1f2e

Contributor

paveljanik commented May 24, 2016

@gmaxwell Can you please be more explicit in the commit message? In "This reduces the rate of not founds", "This" means "this PR" or you mean the 15-> 16 minutes change (why not separate commit, BTW)?

What is the logic behind 15 -> 16 anyway?

Member

gmaxwell commented May 24, 2016

@paveljanik "better matching far end expectations"-- the far end retries on a two minute interval; 15 minutes is dead between counts-- starting the counter before the transaction has been offered to anyone also makes it more likely to time out first.

Contributor

arowser commented May 25, 2016

Can one of the admins verify this patch?

Owner

sipa commented May 25, 2016

@gmaxwell I guess that can use some comment in the code?

sipa referenced this pull request May 26, 2016

Merged

Addrman offline attempts #8065

Member

gmaxwell commented May 28, 2016

I changed it back to 15 minutes, -- I think the time there should be adjusted but it can be done in another pull that reworks the mapaskfor handling a bit.

@gmaxwell gmaxwell Defer inserting into maprelay until just before relaying.
This reduces the rate of not founds by better matching the far
 end expectations, it also improves privacy by removing the
 ability to use getdata to probe for a node having a txn before
 it has been relayed.
4d8993b
Member

gmaxwell commented May 31, 2016

Rebased.

Owner

sipa commented May 31, 2016

Lightly tested ACK. Setup: two mainnet full nodes with this patch (A publicly reachable, B -connect'ed to A) and a lightweight node C (connected to the public network). Tested block synchronization/relay of B from A, relay of transactions to from A to B, relay of newly created transactions by B and C through A. Nothing unusual.

@sipa sipa merged commit 4d8993b into bitcoin:master Jun 1, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@sipa sipa added a commit that referenced this pull request Jun 1, 2016

@sipa sipa Merge #8082: Defer inserting into maprelay until just before relaying.
4d8993b Defer inserting into maprelay until just before relaying. (Gregory Maxwell)
01d8359
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment