Skip to content
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

Limit how far we look into the blockchain #2731

Merged
merged 2 commits into from
Sep 21, 2023
Merged

Conversation

t-bast
Copy link
Member

@t-bast t-bast commented Aug 29, 2023

If we're unable to find the spending tx in the mempool, we start looking for it in the blockchain. Unfortunately, there are cases where we end up in that code path even though the spending tx is not confirmed:

  • a timeout on the getTransaction call
  • the spending tx gets dropped from our mempool for some reason
  • bitcoind is malicious or buggy

Fetching the whole blockchain isn't really useful: after enough time has passed, we can be pretty sure that a potential attacker would have claimed the transaction's outputs already and we can't punish them. We can limit that to the maximum amount of time we expect our node to be offline.

@t-bast t-bast requested review from sstone and pm47 August 29, 2023 07:44
@t-bast t-bast requested a review from sstone September 11, 2023 09:27
pm47
pm47 previously approved these changes Sep 19, 2023
sstone
sstone previously approved these changes Sep 21, 2023
If we're unable to find the spending tx in the mempool, we start looking
for it in the blockchain. Unfortunately, there are cases where we end up
in that code path even though the spending tx is not confirmed:

- a timeout on the `getTransaction` call
- the spending tx gets dropped from our mempool for some reason
- bitcoind is malicious or buggy

Fetching the whole blockchain isn't really useful: after enough time has
passed, we can be pretty sure that a potential attacker would have claimed
the transaction's outputs already and we can't punish them. We limit this
to the last month of blockchain data, which should be much larger than
our `to_delay`.
And add a unit test.
@t-bast t-bast dismissed stale reviews from sstone and pm47 via 3a75af7 September 21, 2023 14:57
@codecov-commenter
Copy link

Codecov Report

Merging #2731 (3a75af7) into master (148fc67) will decrease coverage by 0.09%.
Report is 1 commits behind head on master.
The diff coverage is 80.71%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##           master    #2731      +/-   ##
==========================================
- Coverage   85.89%   85.80%   -0.09%     
==========================================
  Files         215      216       +1     
  Lines       17854    18016     +162     
  Branches      756      787      +31     
==========================================
+ Hits        15335    15458     +123     
- Misses       2519     2558      +39     
Files Changed Coverage Δ
...r-core/src/main/scala/fr/acinq/eclair/Eclair.scala 55.69% <0.00%> (-2.98%) ⬇️
...chain/bitcoind/rpc/BasicBitcoinJsonRPCClient.scala 100.00% <ø> (ø)
...in/bitcoind/rpc/BatchingBitcoinJsonRPCClient.scala 75.00% <0.00%> (-25.00%) ⬇️
...in/scala/fr/acinq/eclair/channel/fsm/Channel.scala 85.28% <ø> (ø)
.../acinq/eclair/blockchain/bitcoind/ZmqWatcher.scala 86.61% <66.66%> (-0.59%) ⬇️
...ir/blockchain/bitcoind/rpc/BitcoinCoreClient.scala 88.23% <75.00%> (-10.23%) ⬇️
...q/eclair/channel/publish/ReplaceableTxFunder.scala 84.97% <84.00%> (-4.48%) ⬇️
...air/crypto/keymanager/LocalOnChainKeyManager.scala 87.64% <87.64%> (ø)
...re/src/main/scala/fr/acinq/eclair/NodeParams.scala 93.31% <100.00%> (+0.02%) ⬆️
...ir-core/src/main/scala/fr/acinq/eclair/Setup.scala 75.14% <100.00%> (+0.29%) ⬆️
... and 2 more

... and 5 files with indirect coverage changes

@t-bast t-bast merged commit 96ebbfe into master Sep 21, 2023
1 check passed
@t-bast t-bast deleted the limit-blockchain-speleology branch September 21, 2023 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants