Skip to content

[wallet] restore coinbase and confirmed/conflicted checks in SubmitMemoryPoolAndRelay() - #16557

Merged
maflcko merged 2 commits into
bitcoin:masterfrom
jnewbery:2019-08-restore-coinbase-check
Aug 12, 2019
Merged

maflcko merged 2 commits into
bitcoin:masterfrom
jnewbery:2019-08-restore-coinbase-check

Conversation

@jnewbery

@jnewbery jnewbery commented Aug 6, 2019 •

Copy link
Copy Markdown
Contributor

These checks don't change mempool acceptance/relay behaviour, but reduce log spam.

This check doesn't change mempool acceptance/relay behaviour, but reduces log spam.
@jnewbery

jnewbery commented Aug 6, 2019

Copy link
Copy Markdown
Contributor Author

Reported by @kallewoof

ping @MarcoFalke and @ariard for review.

@ariard ariard left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Once wallet rebroadcast logic get reworked, I think log spams due to massive rebroadcast of confirmed txn should disappear, but yes that's not a thing for now.

Comment thread src/wallet/wallet.cpp
if (isAbandoned()) return false;
// Don't try to submit coinbase transactions. These would fail anyway but would
// cause log spam.
if (IsCoinBase()) return false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sorry for that. You may need also to restore the GetDepthInMainChain, if you follow what @kallewoof was saying non-coinbase confirmed txn were also in log spams.

@kallewoof kallewoof Aug 7, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No, I don't believe non-coinbase confirmed txn were in log spams but there were thousands so I can't easily verify.

Edit: With patch it was easily verifiable that non-coinbase txs also appear.

@promag

promag commented Aug 7, 2019 •

Copy link
Copy Markdown
Contributor

@ariard

ariard commented Aug 7, 2019

Copy link
Copy Markdown
Contributor

ACK 214c4ec

@kallewoof

kallewoof commented Aug 7, 2019 •

Copy link
Copy Markdown
Contributor

I applied this patch to my node and restarted it.

  1. This does not only happen during reorgs, it seems to be happening regularly. I think the node has gotten in its head that it needs to rebroadcast all transactions.
  2. This is not only coinbase transactions. After applying the patch I see tons of txs. Picking two at random, both turned out to be regular txs. See e.g. https://explorer.bc-2.jp/tx/a2ba0e7b09474565c92ef495a35fd932691f3ee3468992cd6a7e5bce100a6b3a (2019-08-07T08:53:22Z [default wallet] Submitting wtx a2ba0e7b09474565c92ef495a35fd932691f3ee3468992cd6a7e5bce100a6b3a to mempool for relay)
  3. This did not happen in conjunction with a new block, either. It seems the wallet is doing this as part of its regular wallet tx resend. But these have thousands of confirmations.

The debug.log file is more or less dominated by these messages, although it may be less severe after the patch.

$ wc debug.log
   77751   776919 10791973 debug.log
$ grep -v "to mempool for relay" debug.log|wc
    300    2414   26399

@ariard

ariard commented Aug 7, 2019 •

Copy link
Copy Markdown
Contributor

Did you try to run without #15713 but with IsCoinBase and GetDepthInMainChain checks turn off ? I guess you should see the same logs than right now. Wallet is always trying to rebroadcast, even with thousands of confirmations, removing checks just make it apparent ?

@kallewoof

Copy link
Copy Markdown
Contributor

@ariard No. If I am the only one seeing these messages, however, this may be a problem with signet. No clue why signet would cause this, though, tbh.

@maflcko

maflcko commented Aug 7, 2019

Copy link
Copy Markdown
Member

#15713 also changed the logging, IIRC. So the bug can be fixed by either (or both):

  • Fixed logging
  • Restored checks

@ariard

ariard commented Aug 8, 2019

Copy link
Copy Markdown
Contributor

@kallewoof is not a problem with signet, it's a problem with my PR. I've played a bit with a regtest node on a commit before it. If I generate thousands of coinbase txn, every time we hit nNextResend (once in a 30min period), and 5min older than last block we are going to call RelayWalletTransaction for every one of them. You can see them in this method if you add a printer before IsCoinBase check. Previously printer was only triggered if they have been accepted by mempool. Now, with the new refactored SubmitMemoryPoolAndRelay we have removed these checks, because they are already performed in BroadcastTransaction or lower, and log print whatever their mempool acceptance/relay are. The resend logic has always been there for unconfirmed txn, it's just now we see it.

While waiting for this logic to be rationalized, to avoid spam we can move log print to BroadcastTransaction after inserting successfully in mempool or re-add both IsCoinBase and GetDepthInMainChain checks in SubmitMemoryPoolAndRelay.

Note: IMO, comment "only rebroadcast unconfirmed txes older than 5 minutes before the last block was found" in ResendWalletTransactions is ambiguous and suggests confirmation check has already been done at this step, but in fact it relies on the callee function to do so.

…Relay()

Restores the confirmed/conflicted tx check removed in
8753f56. There should be no external
behaviour change (these txs would not get accepted to the mempool
anyway), but not having the check in the wallet causes log spam.

Also adds a comment to ResentWalletTransactions() that
confirmed/conflicted tx check is done in SubmitMemoryPoolAndRelay().
@jnewbery

jnewbery commented Aug 9, 2019

Copy link
Copy Markdown
Contributor Author

I've restored the GetDepthInMainChain() check in SubmitMemoryPoolAndRelay(). That meant passing the locked_chain through to SubmitMemoryPoolAndRelay() (at least until #15931 is merged).

Also clarified comment in ResendWalletTransactions().

@jnewbery jnewbery changed the title [wallet] restore coinbase check in SubmitMemoryPoolAndRelay() [wallet] restore coinbase and confirmed/conflicted checks in SubmitMemoryPoolAndRelay() Aug 9, 2019
@DrahtBot

DrahtBot commented Aug 9, 2019

Copy link
Copy Markdown
Contributor

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #9381 (Remove CWalletTx merging logic from AddToWallet by ryanofsky)

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.

@maflcko

maflcko commented Aug 9, 2019

Copy link
Copy Markdown
Member

ACK c8b53c3 (non-doc changes are mostly a git revert 8753f56)

Show signature and timestamp

Signature:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

ACK c8b53c3beafa289dcdbd8c2ee9f957bdeca79cbc (non-doc changes are mostly a git revert 8753f5652b4710e66b50ce87788bf6f33619b75a)
-----BEGIN PGP SIGNATURE-----

iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUgQAQv/Z6Y5v5REeQFDBT4A4iyBncehSPa36ikjjvjE1SRHw8gMLoYffjC96s0n
aZ1vpEUrUPhnQhiOWmr68rEFoAkoW13FeMqdc7iN4UBcW71vX2vGVrDmQilqrkid
TcTdogmucTkRCXyrkU6fjSDgO9TAUoF4ANZNuwusWW9oxcQurt8/86PAGI3jAxmy
yEYTmjoWt55EcnzC57rlMQ7mCR+okiEtgV+pC5tXerJvjdCZRM4LqXhYbto1UtOm
i6Qxn6gp4Z1eRjM86KQ6D9YfsP1sxtdS1xVDLXH2JbCD1EB7kE1FzB/IveFyYg3x
56sBd9tenZ8F6UKbhbbnvfDB/AiZwEnkYyBxclB7fVJsH+2N80pGJMcqUwlKBP3y
bHBr+IJhekG70belcOTK02eoWC9OJR0Ga5cNGJwIKmWPScHItnhjC0lzjE4PO0yA
+aJAnuQpeySSfD9TvunAfPxqQ/4EvYk52WOtBxdqHPbNnr0I7Rhtbk0GKaZYWpn3
O4uPQ/hf
=TlR4
-----END PGP SIGNATURE-----

Timestamp of file with hash d299ae4192e52358020d1c810082e7d19625bf7a9adef077079a3e02624e9dd6 -

@ariard

ariard commented Aug 9, 2019

Copy link
Copy Markdown
Contributor

utACK c8b53c3

@kallewoof

kallewoof commented Aug 9, 2019 •

Copy link
Copy Markdown
Contributor

ACK

Applied this to my node.

Ran for awhile. No spam. Tried sending a tx. Message appeared as appropriately in log. I don't think I am able to test the CWallet::ResendWalletTransactions part easily as it depends on a new block without tx being mined. Did try restarting the node though, and the log message appeared as expected.

Comment thread src/wallet/wallet.cpp
// last block was found
// Attempt to rebroadcast all txes more than 5 minutes older than
// the last block. SubmitMemoryPoolAndRelay() will not rebroadcast
// any confirmed or conflicting txs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not move the coinbase check here then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree that would make sense - the other callers of SubmitMemoryPoolAndRelay() do checks before calling into SubmitMemoryPoolAndRelay(). However, this PR is just to restore previous behaviour. There are a few other PRs in progress on the node/wallet interface, so let's keep the existing behaviour and look for ways to tidy it up later.

@maflcko
maflcko merged commit c8b53c3 into bitcoin:master Aug 12, 2019
maflcko pushed a commit that referenced this pull request Aug 12, 2019
…ks in SubmitMemoryPoolAndRelay()

c8b53c3 [wallet] Restore confirmed/conflicted tx check in SubmitMemoryPoolAndRelay() (John Newbery)
214c4ec [wallet] restore coinbase check in SubmitMemoryPoolAndRelay() (John Newbery)

Pull request description:

  These checks don't change mempool acceptance/relay behaviour, but reduce log spam.

ACKs for top commit:
  MarcoFalke:
    ACK c8b53c3 (non-doc changes are mostly a git revert 8753f56)
  ariard:
    utACK c8b53c3

Tree-SHA512: f928573ad68d2f70ac69a84b57f352d255dccd1942097cc664f130fcbdcdd7364bc52c43b9157e65ebbaaebbe93586c6e8386f24361b27478e0a23a445677672
@jnewbery
jnewbery deleted the 2019-08-restore-coinbase-check branch August 12, 2019 18:11
deadalnix pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Jul 28, 2020
…hecks in SubmitMemoryPoolAndRelay()

Summary:
[wallet] Restore confirmed/conflicted tx check in SubmitMemoryPoolAndRelay() (John Newbery)
[wallet] restore coinbase check in SubmitMemoryPoolAndRelay() (John Newbery)

Pull request description:

  These checks don't change mempool acceptance/relay behaviour, but reduce log spam.

https://github.com/bitcoin/bitcoin/pull/16557/files

---

Backport of Core [[bitcoin/bitcoin#16557 | PR16557]]

Test Plan:
  ninja check check-functional

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7043
@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.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants