HomePhabricator

[Chronik] Emit WS messages in a more deterministic order

Description

[Chronik] Emit WS messages in a more deterministic order

Summary:
Currently, since we're using unbiased tokio::select! in recv_action, it randomly selects between blocks, scripts, token_ids and ping to poll first. If there's both a block and script msg pending (as would be usually after a block connected), it might select to poll the script future first and return a TX_CONFIRMED msg before BLK_CONNECTED.

However, by switching to biased; mode, tokio will always poll blocks first. This guarantees that BLK_CONNECTED msgs come before corresponding TX_CONFIRMED msgs.

We tried making the tx order of TX_CONFIRMED msgs deterministic as well, however, since there are many unsynchronized channels at play here, it's not possible to guarantee an order here, at least not without slowing down the indexer. See the comment in chronik_ws_ordering.py for an explanation.

Test Plan: ninja && ./test/functional/test_runner.py chronik_ws_ordering

Reviewers: Fabien, #bitcoin_abc

Reviewed By: Fabien, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D15452

Details

Provenance
tobias_ruckAuthored on Feb 14 2024, 21:15
tobias_ruckPushed on Feb 15 2024, 08:34
Reviewer
Restricted Project
Differential Revision
D15452: [Chronik] Emit WS messages in a more deterministic order
Parents
rABC449dbe5ff499: [e.cash] Update strapi scorecard data
Branches
Unknown
Tags
Unknown