Skip to content

plugins/bcli: use -rpcwait to simplify waiting for bitcoind to warm up#7967

Merged
rustyrussell merged 1 commit intoElementsProject:masterfrom
NishantBansal2003:cleanup-wait
Sep 4, 2025
Merged

plugins/bcli: use -rpcwait to simplify waiting for bitcoind to warm up#7967
rustyrussell merged 1 commit intoElementsProject:masterfrom
NishantBansal2003:cleanup-wait

Conversation

@NishantBansal2003
Copy link
Contributor

Replaced custom wait logic with the -rpcwait flag in bitcoin-cli to handle waiting for bitcoind to warm up. Added a timer to print the warm-up message only if bitcoind doesn't start serving RPC calls within 30 seconds.
This simplifies the code and ensures that errors unrelated to warmup are passed up directly without additional checks.

Fixes: #3505

Checklist

Before submitting the PR, ensure the following tasks are completed. If an item is not applicable to your PR, please mark it as checked:

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.

Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea! 🧡 The timeout needs work though...

plugins/bcli.c Outdated
tal_free(output);
struct timers *timer = tal(cmd, struct timers);
timers_init(timer, time_mono());
new_reltimer(timer, timer, time_from_sec(BITCOIND_WARMUP_TIMER),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work, unfortunately. We'll be stuck in the waitpid call, not in the ioloop.

But the correct way to do this is to also use rpcwaittimeout, so it will fail, and we can log a message and retry.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(note: rpcwait was supported since bitcoin 0.9, and rpcwaittimeout since 22.0, so we're good here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for my understanding, does the timer run synchronously with the event loop, blocking the program until it expires? Or does it run in the background (in a non-blocking manner), calling the function asynchronously, if timer expires or get cleaned up by tal_free?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The core event loop (io_loop) exits when a timer goes off; normally the timer is then called, and the io_loop() reentered.

@NishantBansal2003
Copy link
Contributor Author

Hey @rustyrussell, just checking in to see if there’s any further feedback on this PR?

@NishantBansal2003
Copy link
Contributor Author

Hi @rustyrussell, I wanted to kindly follow up on this PR to check if there’s anything else I should address or any additional feedback you're waiting on. Please let me know if I can assist in moving this forward. Thank you!

Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and sorry for the delay!

Replaced custom wait logic with the -rpcwait flag in bitcoin-cli to handle waiting for bitcoind to warm up. This simplifies the code and ensures that errors unrelated to warmup are passed up directly without additional checks.
Changelog-None

Signed-off-by: Nishant Bansal <[email protected]>
@rustyrussell rustyrussell enabled auto-merge (rebase) July 14, 2025 04:05
@rustyrussell rustyrussell merged commit 74489b5 into ElementsProject:master Sep 4, 2025
38 of 40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cleanup: Use the -rpcwait when waiting for bitcoind to warm up

2 participants