Skip to content

Conversation

l2a5b1
Copy link
Contributor

@l2a5b1 l2a5b1 commented Oct 3, 2018

This pull request fires TransactionRemovedFromMempool callbacks from the mempool and cleans up a bunch of code.

It also resolves the txmempool -> validation -> validationinterface -> txmempool circular dependency.

Ideally, validationinterface is a dumb component that doesn't have any knowledge of the sub-systems it sends its notifications to. The commit that aims to resolve this circular dependency by moving txmempool specific code out of validationinterface to txmempool where it belongs.

@l2a5b1 l2a5b1 force-pushed the patch/validationinterface-resolve-circular-dependencies branch 2 times, most recently from c22e3aa to 249df58 Compare October 3, 2018 21:09
@DrahtBot
Copy link
Contributor

DrahtBot commented Oct 3, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16688 (log: Add validation interface logging by jkczyz)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@practicalswift
Copy link
Contributor

Concept ACK

Let's get rid of these ugly circular dependencies! :-)

@l2a5b1 l2a5b1 force-pushed the patch/validationinterface-resolve-circular-dependencies branch 6 times, most recently from 48d4bb2 to 1c2b458 Compare October 4, 2018 20:23
@l2a5b1 l2a5b1 force-pushed the patch/validationinterface-resolve-circular-dependencies branch from 1c2b458 to e729c6f Compare November 5, 2018 17:11
@l2a5b1 l2a5b1 force-pushed the patch/validationinterface-resolve-circular-dependencies branch from e729c6f to 1ac729f Compare November 5, 2018 21:36
@l2a5b1 l2a5b1 force-pushed the patch/validationinterface-resolve-circular-dependencies branch from 1ac729f to e72cd85 Compare November 13, 2018 16:17
@l2a5b1 l2a5b1 force-pushed the patch/validationinterface-resolve-circular-dependencies branch from e72cd85 to b58bbc9 Compare November 13, 2018 18:28
@jamesob
Copy link
Contributor

jamesob commented Nov 18, 2019

ACK 37fd92b

This is basically some helpful code-shuffling; the change removes unneeded code to absorb the TransactionRemovedFromMempool signal into the existing CValidationInterface callback registration code, and avoids including mempool-specific header files into the more general validationinterface.

@jonatack
Copy link
Member

Concept ACK, kudos @l2a5b1 for staying with this.

Built 37fd92b rebased onto current master at 3052130, tests pass, bitcoind running.

Now reviewing the code.

Copy link
Member

@jonatack jonatack left a comment

Choose a reason for hiding this comment

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

ACK 37fd92b

Nice cleanup that improves separation of concerns and enables removing MempoolEntryRemoved, RegisterWithMempoolSignals, and UnregisterWithMempoolSignals.

@TheBlueMatt
Copy link
Contributor

This isn't strictly worse, but its still super awkward....CTxMemPool is (mostly) a "dumb datastructure", with all the adding/removing happening in validation.cpp. Currently its double awkward cause they're signals that go back to validation so that validation can fire appropriate events, but just firing the events inside a datastructure is also really awkward. Is there an equally-easy way to move the event-firing back into validation.cpp?

@jnewbery
Copy link
Contributor

Is there an equally-easy way to move the event-firing back into validation.cpp?

I don't think there is. That would require that every site that validation calls a CTxMemPool method that could result in transactions being removed would need to be passed back a vector of transactions that it should fire the events for. A quick search shows at least the following sites would need to be updated:

  • validation's UpdateMempoolForReorg() calling into mempool.removeRecursive()
  • validation's LimitMempoolSize() calling into pool.Expire()
  • validation's LimitMempoolSize() calling into pool.TrimToSize()

There are probably more. I don't think those call sites have ever handled firing the events, and adding that functionality would be new data structures, function signatures and logic.

This seems to be a strict improvement to me. The events are being fired from exactly the same place as before, except that there's no weird indirection in the validation interface.

@maflcko
Copy link
Member

maflcko commented Nov 19, 2019

Re-run ci

@maflcko maflcko closed this Nov 19, 2019
@maflcko maflcko reopened this Nov 19, 2019
@TheBlueMatt
Copy link
Contributor

Right, certainly don't interpret my comment as a NACK, then. Longer-term it would be nice, indeed, to move the event-firing into those callsites, cause the responsibility right now is very awkwardly split (hence why we're checking the reason in the first place - validation fires some similar things), but this isn't worse than master and if other PR's need this, do it!

@laanwj
Copy link
Member

laanwj commented Nov 21, 2019

argh, needs trivial rebase for the linter test/lint/lint-circular-dependencies.sh

This commit fires TransactionRemovedFromMempool callbacks from the
mempool and cleans up a bunch of code.
@l2a5b1 l2a5b1 force-pushed the patch/validationinterface-resolve-circular-dependencies branch from 37fd92b to e20c72f Compare November 21, 2019 20:30
@l2a5b1
Copy link
Contributor Author

l2a5b1 commented Nov 22, 2019

argh

@laanwj lol, no worries, rebased e20c72f

@jnewbery
Copy link
Contributor

ACK e20c72f

laanwj added a commit that referenced this pull request Nov 22, 2019
e20c72f Fire TransactionRemovedFromMempool from mempool (251)

Pull request description:

  This pull request fires TransactionRemovedFromMempool callbacks from the mempool and cleans up a bunch of code.

  It also resolves the `txmempool -> validation -> validationinterface -> txmempool` circular dependency.

  Ideally, `validationinterface` is a dumb component that doesn't have any knowledge of the sub-systems it sends its notifications to. The commit that aims to resolve this circular dependency by moving `txmempool` specific code out of `validationinterface` to `txmempool` where it belongs.

ACKs for top commit:
  jnewbery:
    ACK e20c72f

Tree-SHA512: 354c3ff1113b21a0b511d80d604edfe3846dddae3355e43d1387f68906e54bf5dc01e7c029edc0b8e635b500b2ab97ee50362e2486eb4319f7347ee9a9e6cef3
@laanwj laanwj merged commit e20c72f into bitcoin:master Nov 22, 2019
@ariard
Copy link

ariard commented Nov 22, 2019

ACK e20c72f, only rebased.

@jonatack
Copy link
Member

Posthumous ACK e20c72f

sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 22, 2019
…m mempool

e20c72f Fire TransactionRemovedFromMempool from mempool (251)

Pull request description:

  This pull request fires TransactionRemovedFromMempool callbacks from the mempool and cleans up a bunch of code.

  It also resolves the `txmempool -> validation -> validationinterface -> txmempool` circular dependency.

  Ideally, `validationinterface` is a dumb component that doesn't have any knowledge of the sub-systems it sends its notifications to. The commit that aims to resolve this circular dependency by moving `txmempool` specific code out of `validationinterface` to `txmempool` where it belongs.

ACKs for top commit:
  jnewbery:
    ACK e20c72f

Tree-SHA512: 354c3ff1113b21a0b511d80d604edfe3846dddae3355e43d1387f68906e54bf5dc01e7c029edc0b8e635b500b2ab97ee50362e2486eb4319f7347ee9a9e6cef3
jkczyz added a commit to jkczyz/bitcoin that referenced this pull request Nov 22, 2019
The reason parameter was removed in bitcoin#14384 as part of a clean-up but
the reason would be useful to log according to comments on the PR.
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jun 8, 2020
Summary:
This commit fires TransactionRemovedFromMempool callbacks from the
mempool and cleans up a bunch of code.

This is a backport of Core [[bitcoin/bitcoin#14384 | PR14384]]

policyestimator_tests was modified to use TestingSetup because it uses the `CTxMemPool::TrimToSize` function which now may trigger the signal, but the signals handlers are not setup properly to do so using `BasicTestingSetup`.

Test Plan:
  ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D6451
sidhujag pushed a commit to syscoin-core/syscoin that referenced this pull request Nov 10, 2020
…m mempool

e20c72f Fire TransactionRemovedFromMempool from mempool (251)

Pull request description:

  This pull request fires TransactionRemovedFromMempool callbacks from the mempool and cleans up a bunch of code.

  It also resolves the `txmempool -> validation -> validationinterface -> txmempool` circular dependency.

  Ideally, `validationinterface` is a dumb component that doesn't have any knowledge of the sub-systems it sends its notifications to. The commit that aims to resolve this circular dependency by moving `txmempool` specific code out of `validationinterface` to `txmempool` where it belongs.

ACKs for top commit:
  jnewbery:
    ACK e20c72f

Tree-SHA512: 354c3ff1113b21a0b511d80d604edfe3846dddae3355e43d1387f68906e54bf5dc01e7c029edc0b8e635b500b2ab97ee50362e2486eb4319f7347ee9a9e6cef3
random-zebra added a commit to PIVX-Project/PIVX that referenced this pull request Apr 14, 2021
…fication fix

f2734f0 [Tests] Fix policyestimator and validation_block tests (random-zebra)
3448bc8 wallet: Minimal fix to restore conflicted transaction notifications (Antoine Riard)
ba9d84d feature_notifications.py mimic upstream is_wallet_compiled() function to make future back ports easier. (furszy)
37c9944 [mempool] Remove NotifyEntryAdded and NotifyEntryRemoved callbacks (John Newbery)
5cc619f [validation] Remove pool member from ConnectTrace (John Newbery)
1e453b7 [validation] Remove NotifyEntryRemoved callback from ConnectTrace (John Newbery)
e774bfd [validation] Remove conflictedTxs from PerBlockConnectTrace (John Newbery)
389680a [validation interface] Remove vtxConflicted from BlockConnected (furszy)
19c9383 [wallet] Notify conflicted transactions in TransactionRemovedFromMempool (John Newbery)
139882d Fire TransactionRemovedFromMempool from mempool  This commit fires TransactionRemovedFromMempool callbacks from the mempool and cleans up a bunch of code. (furszy)

Pull request description:

  PR built on top of #2209, #2235 and #2240 (don't get scared by the amount of commits, most of them are coming from 2209. Will disappear as soon as that one gets merged).

  Based on the brief talk originated in #2209 (comment) .

  Solving the conflicted transactions external listeners notification. Adapting the following PRs: bitcoin#14384, bitcoin#17477 and bitcoin#18982. Without functional test support, for the time being, for the lack of RBF functionality.

ACKs for top commit:
  Fuzzbawls:
    ACK f2734f0
  random-zebra:
    re-utACK f2734f0 and merging...

Tree-SHA512: 07d437e0d5e5d9798b16d982b6f58585d1f0dcd82251c5ac06f47e44233433831243d451ce43068e33c6002a64b76fa4d165167a2cbaeeedc28cde2019853565
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.