-
Notifications
You must be signed in to change notification settings - Fork 265
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
Optimize watching for spending txs #1699
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1699 +/- ##
==========================================
+ Coverage 86.08% 86.17% +0.09%
==========================================
Files 151 151
Lines 11523 11527 +4
Branches 493 500 +7
==========================================
+ Hits 9919 9933 +14
+ Misses 1604 1594 -10
|
This is a pretty sensitive part of the code. This implementation first tries to get the txs provided in hints and verifies that one of them indeed spend the watched tx (there can only be one because we watch a single utxo). If (and only if) the spending tx checks out, then we bypass the resource-intensive blockchain scanning. Note: it still works if the hints are wrong.
LGTM from a functional point of view but we never test that we actually use the provided hints for find a spending txs. What about extracting the relevant methods from |
Indeed, I verified manually by running the tests with logging enabled. The point of those tests (when run automatically) is to prove non-regression (particularly with a wrong hint), they don't prove the optimization.
I don't know, WDYT @t-bast? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely an improvement, whenever we can avoid a call to getMempool
let's avoid it!
What about extracting the relevant methods from ZmqWatcher and adding them to ExtendedBitcoinClient?
I don't have a strong opinion here, it could make sense in ExtendedBitcoinClient
but if only ZmqWatcher
is using it, then it also makes sense to keep it in ZmqWatcher
...maybe leave it like that for now and after the re-architecting that will happen around ZmqWatcher
we'll see?
eclair-core/src/main/scala/fr/acinq/eclair/blockchain/WatcherTypes.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/blockchain/WatcherTypes.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/blockchain/bitcoind/ZmqWatcher.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/blockchain/WatcherTypes.scala
Outdated
Show resolved
Hide resolved
eclair-core/src/main/scala/fr/acinq/eclair/channel/Channel.scala
Outdated
Show resolved
Hide resolved
fa8ceac
to
86343d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Since we almost always know which transactions will spend the utxos that we are watching, we can optimize the watcher to look for those instead of starting from scratch.
Since we almost always know which transactions will spend the utxos that we are watching, we can optimize the watcher to look for those instead of starting from scratch.