When CZMQPublishRawBlockNotifier::NotifyBlock is called it calls ReadBlockFromDisk with the passed in block index. However, we will always have already read this block into memory during ActivateBestChain and use it to call BlockConnected. We can check for the tip block there and pass that into UpdatedBlockTip to avoid having the zmq notifier read the block. This also has the benefit of removing the node/blockstorage.h dependency entirely from the zmq code, so we can continue working to remove ReadBlockFromDisk out of global scope (https://github.com/bitcoin/bitcoin/pull/26316#discussion_r1000954807).
validation, zmq: pass block in UpdatedBlockTip to avoid duplicate read #26375
pull andrewtoth wants to merge 2 commits into bitcoin:master from andrewtoth:no-read-zmq changing 13 files +37 −45-
andrewtoth commented at 3:18 AM on October 24, 2022: contributor
-
validation, zmq: pass block in UpdatedBlockTip to avoid duplicate read 4a164160b6
-
DrahtBot commented at 10:28 AM on October 24, 2022: contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
- #26308 (rpc/rest/zmq: reduce LOCK(cs_main) scope: ~6 times as many requests per second by andrewtoth)
- #15606 (assumeutxo by jamesob)
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.
-
test: check for zmq block announcements with reorgs 7b631dc9b1
- andrewtoth force-pushed on Oct 24, 2022
- aureleoules approved
-
aureleoules commented at 1:37 PM on October 25, 2022: member
ACK 7b631dc9b1979afc99d9d1a3996492dcb415d3a3 - LGTM
- w0xlt approved
-
w0xlt commented at 1:47 PM on October 25, 2022: contributor
-
maflcko commented at 12:52 PM on November 14, 2022: member
This will increase the memory use even if not using zmq. I guess it is fine because the queue is limited?
-
andrewtoth commented at 2:51 AM on November 15, 2022: contributor
This will increase the memory use even if not using zmq. I guess it is fine because the queue is limited?
That sounds accurate. It seems
LimitValidationInterfaceQueuein the loop prevents this from blowing up. -
andrewtoth commented at 4:13 PM on November 18, 2022: contributor
- andrewtoth closed this on Nov 18, 2022
- luke-jr referenced this in commit 20bfdd263e on Jun 28, 2023
- luke-jr referenced this in commit bde7a7f9f2 on Jun 28, 2023
- luke-jr referenced this in commit 7ac46393a3 on Aug 16, 2023
- luke-jr referenced this in commit 2f99fc3629 on Aug 16, 2023
- bitcoin locked this on Nov 18, 2023