Skip to content

Conversation

@furszy
Copy link

@furszy furszy commented Apr 8, 2021

Upgraded the orphan transactions management process, getting us much closer to upstream. Skipped several intermediate PRs because our code is way too far ahead of them in some areas like the validation interface and block processing after #2209. Plus added a net_processing zc cleanup.

Important changes:

  • The elimination of a leak in the orphan map, which was not connected to the block connection process, always growing to its maximum size.
  • Early detection and discard of zc txs received as single tx message.
  • Removal of the ATMP check of zc txs received as single tx message.
  • Removed the need of cs_main lock for accessing mapOrphanTransactions and mapOrphanTransactionsByPrev.

@furszy furszy self-assigned this Apr 8, 2021
@furszy furszy added this to the 6.0.0 milestone Apr 8, 2021
@furszy furszy added the Network label Apr 8, 2021
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.

Really nice PR (big thumb up for 94af4c9 and 0db5343).
Code review ACK, with only a minor concern over the maximum orphan size.

Would be good to cherry-pick another two simple commits from upstream (bitcoin#14626 and bitcoin/bitcoin@4c0731f from 19596), which are strictly related to these changes, but we can do it in a follow-up PR too.

@furszy
Copy link
Author

furszy commented Apr 12, 2021

Updated per zebra's feedback, adding bitcoin#14626 and bitcoin/bitcoin@4c0731f . Plus the max orphan tx size change to support large shield transactions.

sipa and others added 6 commits April 15, 2021 13:06
This prevents higher order orphans and other junk from
holding positions in the orphan map.  Parents delayed
twenty minutes are more are unlikely to ever arrive.

The freed space will improve the orphan matching success rate for
other transactions.
…ted.

An orphan whos parents were rejected is never going to connect, so there
is little utility in keeping it.

Orphans also helpfully tell us what we're missing, so go ahead and treat
it as INVed.
Although this increases node memory usage in the worst case by perhaps
30MB, the current behavior causes severe issues with dependent tx relay.
This is another violation of the one definition rule, as the type
for mapOrphanTransactionsByPrev did not match the one in
net_processing.cpp anymore. As it now depends on a custom Iterator,
it seems too much hassle to correctly expose it to the tests.
Instead, this commit just removes the one test it was referenced in.
@furszy furszy force-pushed the 2021_upgrade_orphan_tx_handling branch 2 times, most recently from add8c14 to 97c6a03 Compare April 15, 2021 16:13
@furszy
Copy link
Author

furszy commented Apr 15, 2021

Rebased on master due conflicts. Ready to go.

furszy and others added 8 commits April 15, 2021 17:38
… connected.

Eliminating a leak that causes the orphan map to always grow to its maximum size.

Extra information:
I have skipped several PRs from upstream, this was first inside ConnectBlock, then was moved to ActivateBestChain and finally ended up moving it to net_processing under the SyncTransaction slot that we don't have anymore because we are much more updated.
This should (marginally) speed up validationinterface queue draining by avoiding a cs_main lock in one client.
The previous code was biased towards evicting transactions whose txid has
a larger gap (lexicographically) with the previous txid in the orphan pool.
In the logic for requesting missing parents of orphan transactions, parent
transactions with multiple outputs being spent by the given orphan were being
processed multiple times. Fix this by deduplicating the set of missing parent
txids first.
Accepting them up to the max supported size.
@furszy furszy force-pushed the 2021_upgrade_orphan_tx_handling branch from 97c6a03 to 57221af Compare April 15, 2021 20:42
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.

utACK 57221af

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

ACK 57221af

The nit i mentioned i think would be better suited for a followup PR, as there are other log output lines around here that have similar leading whitespace.

if (ptx->ContainsZerocoins()) {
// Don't even try to check zerocoins at all.
Misbehaving(pfrom->GetId(), 100);
LogPrint(BCLog::NET, " misbehaving peer, received a zc transaction, peer: %s\n", pfrom->GetAddrName());
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: un-necessary whitespace in log output

@random-zebra random-zebra merged commit 56c2673 into PIVX-Project:master Apr 16, 2021
@furszy furszy deleted the 2021_upgrade_orphan_tx_handling branch May 27, 2023 01:56
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.

8 participants