You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
p2p: block propagation is delayed by index and wallet sync #35023
When we connect a new block, we send two validation signals in ActivateBestChain(): First BlockConnected() (used by the indexes and wallet), then UpdateBlockTip() (adds to m_blocks_for_header_relay for p2p).
Since these are processed sequentially by one thread, this means that a node which has optional indexes activated (which involves some non-trivial work in particular for coinstatsindex and blockfilterindex) will first index the block before scheduling to send the header to peers in UpdateBlockTip(). Ditto for wallets.
This is not great, because fast block propagation is much more important than fast index or wallet sync.
Fortunately, hb compact block relay is not affected by this and most nodes don't have work-heavy indexes enabled.
Note that the current behavior, even if setting wrong priorities, is beneficial for the blockfilterindex (see #29655 (comment)) because it avoids races with BIP157-compliant clients. If we'd change the order we should also keep that in mind.
Opening this as a brainstorming issue what (if anything) should be done about this.
Reacted by b10c, Fabian Jahr, Bruno Garcia, David Gumberg and Gregory Sanders
An idea to address this is for the p2p thread to be a bit more async, that is when a block B comes from peer X on the msghand thread, we pass that block to a separate validation thread and pause peer X, while still continuing to do work for other peers. I think we could potentially extend that so that if peer Y sends a bip157 query related to pending block B, we also pause peer Y.
Right now we process block from msghand which takes cs_main. If we move validation into its own thread which takes cs_main and sometimes releases it, it would allow msghand to continue its work, thus we could introduce more contention points which eventually could lead to a slower block validation.
I mean right now msghand does not compete for cs_main with validation (as validation is inside msghand), but it would do so if there is a separate validation thread (for example from msghand's ProcessTransaction). I am not sure how significant is that and perhaps we could have some kind of prioritization of who takes the lock (validation instead of msghand).
Activity
MrSuddenJoy commentedon Apr 10, 2026
ajtowns commentedon Apr 28, 2026
An idea to address this is for the p2p thread to be a bit more async, that is when a block B comes from peer X on the
msghandthread, we pass that block to a separatevalidationthread and pause peer X, while still continuing to do work for other peers. I think we could potentially extend that so that if peer Y sends a bip157 query related to pending block B, we also pause peer Y.randomlogin commentedon Nov 27, 2026
Right now we process block from
msghandwhich takescs_main. If we move validation into its own thread which takescs_mainand sometimes releases it, it would allowmsghandto continue its work, thus we could introduce more contention points which eventually could lead to a slower block validation.I mean right now
msghanddoes not compete forcs_mainwith validation (as validation is insidemsghand), but it would do so if there is a separate validation thread (for example frommsghand'sProcessTransaction). I am not sure how significant is that and perhaps we could have some kind of prioritization of who takes the lock (validation instead of msghand).