Skip to content

Refactor bcli Plugin from Asynchronous Multi-threaded to Synchronous Single-threaded Architecture #8738

@sangbida

Description

@sangbida

Description

Refactor the bcli plugin to use synchronous, blocking calls to bitcoin-cli instead of the current asynchronous, multi-threaded architecture with priority queuing.

Motivation

The current bcli plugin was designed when block fetching logic lived inside lightningd, where non-blocking behavior was essential to avoid stalling the main daemon. Now that this functionality is isolated in the bcli plugin (which runs as a separate process), synchronous calls to bitcoind are acceptable. Removing this complexity will make the code easier to understand, maintain, and debug.

What (probably) needs to go

  • priorities (enum bitcoind_prio)
  • per-prio queues
  • pending requests (high and low prio)
  • current in-flight list
  • parallel limiting (BITCOIND_MAX_PARALLEL)
  • async I/O callbacks (read_more(), output_init(), bcli_finished(), next_bcli())

What needs to be added

  • synchronous execution - bcli queries bitcoind when one of its rpcs is called, it should block until complete and then return the output

What should stay the same

  • APIs - The JSON-RPC method signatures and response format should stay the same. Some users disable the bcli plugin in preference for their own block fetching plugin and we would like to maintain compatibility with those users.
  • bitcoin configuration options - We should avoid adding an extra bitcoind configuration options so we don't break users existing setups.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions