stacks-network / sbtc

Repo containing sbtc
GNU General Public License v3.0
243 stars 5 forks source link

[Feature]: Eliminate race condition between event loops #588

Closed djordon closed 1 week ago

djordon commented 2 weeks ago

Feature - Eliminate race condition between event loops

1. Description

The block observer event loop notifies both the transaction-signer and the transaction-coordinator event loops whenever it observes a new bitcoin block. The transaction-signer event loop is the one that votes on the requests (as well as signing), while the transaction-coordinator is the one that constructs any bitcoin and stacks transactions. They both currently act in parallel, but the transaction-coordinator uses the output of the transaction-signer when it acts.

1.1 Context & Purpose

The problem is that the transaction-signer might not be done with gathering votes on a request before the transaction-coordinator starts looking for accepted requests to process. The effect is that the signers will wait an additional bitcoin block before acting on deposit requests.

2. Technical Details:

The simplest thing to do is to replace the channel between the block-observer and the transaction-coordinator with a channel between the transaction-signer and the transaction-coordinator. Then we just notify the transaction-coordinator at the end of TxSignerEventLoop::handle_new_requests.

2.1 Acceptance Criteria:

3. Related Issues and Pull Requests (optional):

cylewitruk commented 2 weeks ago

I'll grab this since I'm working in this area now (should be a tiny fix)