include the chaintip blockindex in the SyncTransaction signal, add signal UpdateTip() #6480

pull jonasschnelli wants to merge 1 commits into bitcoin:master from jonasschnelli:2015/07/syncsignal_hight changing 7 files +16 −15
  1. jonasschnelli commented at 1:42 PM on July 27, 2015: contributor
    • allows reducing of calls to main.cpp for getting the chaintip during transaction syncing
    • potentially allows reducing of cs_main locks
  2. sipa commented at 2:34 PM on July 27, 2015: member

    No objection, but I think it would make more sense to have an UpdatedTip signal in ValidationInterface which passed this just once, and let CWallets cache this value.

  3. jonasschnelli commented at 2:41 PM on July 27, 2015: contributor

    I think the SetBestChain() is already there for a such case (tip was updated). Having the CBlockIndex together with the CBlock would make sure we get the data together with the transaction to avoid deltas. And this solution has one big plus: the wallet(s) can detect if the transaction is in the mempool or not because the mempool SyncTransaction gives for CBlock as well as for CBlockIndex a NULL value where the disconnect block only leaves CBlock to null.

    I think this could potentially decouple the wallet from the mempool.

  4. sipa commented at 2:46 PM on July 27, 2015: member

    SetBestChain is only called occasionally, and only when data is being flushed to disk.

  5. sipa commented at 2:47 PM on July 27, 2015: member

    Ah, I see, this passes the block index entry in which a transaction was found - which is not necessarily the current tip (for example during rescan).

    Untested ACK.

  6. jonasschnelli commented at 2:58 PM on July 27, 2015: contributor

    I see the problem with SetBestChain()... So it would make sense to have an UpdateTip() signal next to the conditional variable (https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1995)?

  7. sipa commented at 3:07 PM on July 27, 2015: member

    @jonasschnelli IMHO, yes. Note that that code position always has cs_main held, so listeners to such an UpdateTip signal couldn't do much (but updating a cached variable with the lastest best block is fine and useful).

  8. jonasschnelli commented at 4:12 PM on July 27, 2015: contributor

    @sipa: just detected that an additional UpdateTip() signal is unnecessary, because with this PR a wallet could keep track of the chaintip over the SyncTranscation() signal (connectTip and disconnectTip sends both a syncTransaction with the current chaintip), which a wallet could therefore compare and store locally. I try to reduce the cs_main locking to a very minimum and later even to zero (interact over RPC/ZMQ). I need a way now to avoid deadlocking risks and therefore keep cs_main away from the wallet code.

  9. sipa commented at 4:19 PM on July 27, 2015: member

    @jonasschnelli So a wallet that does not have any new transactions coming in won't know what the current tip is? The wallet needs that information to compute confirmations. Right now, those checks require a call to main (CMerkleTx::GetDepthInMainChainINTERNAL) with associated cs_main lock. If we'd keep CBlockIndex pointers for the wallet transactions, and keep a copy of the tip (via an UpdateTip) in the wallet, all of that could become independent.

    Also, it's probably better to issue such an UpdateTip signal in ActivateBestChain, near the uiInterface.NotifyBlockTip call (or replace it...). That has no locks held, and guarantees a stable tip (UpdateTip() may be called in the middle of reorganizations).

    EDIT: Sorry @jonasschnelli I skipped the part between brackets. You're right of course - I was somehow assuming that SyncTransaction would only be called when there were matching wallet transactions.

  10. jonasschnelli commented at 4:39 PM on July 27, 2015: contributor

    Agreed. Added a commit which would add a UpdateTip() signal.

  11. jonasschnelli renamed this:
    include the chaintip blockindex in the SyncTransaction signal
    include the chaintip blockindex in the SyncTransaction signal, add signal UpdateTip()
    on Jul 27, 2015
  12. laanwj added the label Refactoring on Jul 29, 2015
  13. laanwj commented at 9:00 AM on October 6, 2015: member

    Needs rebase

  14. jonasschnelli force-pushed on Oct 6, 2015
  15. jonasschnelli force-pushed on Oct 6, 2015
  16. jonasschnelli commented at 9:27 AM on October 6, 2015: contributor

    Rebased. Removed the UpdateTip() signal because it was already added during the ZMQ integration.

  17. jonasschnelli force-pushed on Oct 6, 2015
  18. MarcoFalke commented at 4:01 PM on November 16, 2015: member

    @jonasschnelli Needs travis kicked again. (Unrelated error, it seems)

  19. sipa commented at 1:13 PM on November 28, 2015: member

    Kicked.

  20. sipa commented at 3:33 PM on November 28, 2015: member

    Seems there is an actual bug here.

  21. laanwj commented at 3:17 PM on December 3, 2015: member

    Needs rebase

  22. jonasschnelli force-pushed on Dec 3, 2015
  23. jonasschnelli commented at 3:51 PM on December 3, 2015: contributor

    Rebased. I think this is useful because it allows to remove even more cs_main locks (example: it would be possible for the wallet to keep track of the wax's height, etc.).

  24. include the chaintip *blockIndex in the SyncTransaction signal
    - allows reducing of calls to main.cpp for getting the chaintip during transaction syncing
    - potentially allows reducing of cs_main locks
    7d0bf0bb46
  25. jonasschnelli force-pushed on Dec 4, 2015
  26. jonasschnelli commented at 12:21 PM on December 4, 2015: contributor

    Also adapted the zmq interface for the slightly changed signal. Travis is now happy.

  27. morcos commented at 3:46 PM on January 11, 2016: member

    Concept ACK.

    But unless I missed something this PR doesn't actually do anything yet right? Why not save the commit to be part of a PR that actually takes advantage of this information?

  28. jonasschnelli commented at 4:11 PM on January 11, 2016: contributor

    But unless I missed something this PR doesn't actually do anything yet right?

    It allows the wallet to keep track of the wtx heights independent of mempool and main (=step in wallet/core separation).

    Why not save the commit to be part of a PR that actually takes advantage of this information?

    I just try to avoid a big "this is a new wallet" PR. IMO all PRs that are understandable and have a benefit (maybe not directly as a feature) could go in in advance.

  29. morcos commented at 4:35 PM on January 11, 2016: member

    ok no objection

    utACK

  30. laanwj commented at 4:01 PM on February 4, 2016: member

    ACK 7d0bf0b

  31. laanwj merged this on Feb 4, 2016
  32. laanwj closed this on Feb 4, 2016

  33. laanwj referenced this in commit d2228384de on Feb 4, 2016
  34. codablock referenced this in commit efda2adabc on Sep 16, 2017
  35. codablock referenced this in commit e653ce0eb4 on Sep 19, 2017
  36. codablock referenced this in commit e39049bcc4 on Dec 9, 2017
  37. codablock referenced this in commit 117afed433 on Dec 9, 2017
  38. codablock referenced this in commit 8874b2e0fd on Dec 11, 2017
  39. MarkLTZ referenced this in commit b7fe02b045 on Apr 27, 2019
  40. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 06:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me