- allows reducing of calls to main.cpp for getting the chaintip during transaction syncing
- potentially allows reducing of
cs_mainlocks
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-
jonasschnelli commented at 1:42 PM on July 27, 2015: contributor
-
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.
-
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 theCBlockIndextogether with theCBlockwould 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 forCBlockas well as forCBlockIndexaNULLvalue where the disconnect block only leavesCBlockto null.I think this could potentially decouple the wallet from the mempool.
-
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.
-
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.
-
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)? -
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).
-
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 thecs_mainlocking to a very minimum and later even to zero (interact over RPC/ZMQ). I need a way now to avoid deadlocking risks and therefore keepcs_mainaway from the wallet code. -
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.
-
jonasschnelli commented at 4:39 PM on July 27, 2015: contributor
Agreed. Added a commit which would add a
UpdateTip()signal. - 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 - laanwj added the label Refactoring on Jul 29, 2015
-
laanwj commented at 9:00 AM on October 6, 2015: member
Needs rebase
- jonasschnelli force-pushed on Oct 6, 2015
- jonasschnelli force-pushed on Oct 6, 2015
-
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. - jonasschnelli force-pushed on Oct 6, 2015
-
MarcoFalke commented at 4:01 PM on November 16, 2015: member
@jonasschnelli Needs travis kicked again. (Unrelated error, it seems)
-
sipa commented at 1:13 PM on November 28, 2015: member
Kicked.
-
sipa commented at 3:33 PM on November 28, 2015: member
Seems there is an actual bug here.
-
laanwj commented at 3:17 PM on December 3, 2015: member
Needs rebase
- jonasschnelli force-pushed on Dec 3, 2015
-
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_mainlocks (example: it would be possible for the wallet to keep track of the wax's height, etc.). -
7d0bf0bb46
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
- jonasschnelli force-pushed on Dec 4, 2015
-
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.
-
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?
-
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.
-
morcos commented at 4:35 PM on January 11, 2016: member
ok no objection
utACK
-
laanwj commented at 4:01 PM on February 4, 2016: member
ACK 7d0bf0b
- laanwj merged this on Feb 4, 2016
- laanwj closed this on Feb 4, 2016
- laanwj referenced this in commit d2228384de on Feb 4, 2016
- codablock referenced this in commit efda2adabc on Sep 16, 2017
- codablock referenced this in commit e653ce0eb4 on Sep 19, 2017
- codablock referenced this in commit e39049bcc4 on Dec 9, 2017
- codablock referenced this in commit 117afed433 on Dec 9, 2017
- codablock referenced this in commit 8874b2e0fd on Dec 11, 2017
- MarkLTZ referenced this in commit b7fe02b045 on Apr 27, 2019
- MarcoFalke locked this on Sep 8, 2021