Error syncing wallet via RPC client on macOS system
Describe the bug
Unable to sync a regtest wallet with a local bitcoind node via the rpc client on a macOS system using bdk-cli.
To Reproduce
From the bdk-cli repo:
RUST_LOG=debug cargo test --features regtest-bitcoin -- --nocapture
Error is:
thread 'test::test_basic_wallet_op_bitcoind' panicked at 'called `Result::unwrap()` on an `Err` value: CmdExec("[2022-09-10T03:19:40Z ERROR bdk_cli] Rpc(JsonRpc(Transport(SocketError(Os { code: 35, kind: WouldBlock, message: \"Resource temporarily unavailable\" }))))\n")', tests/integration.rs:224:40
Expected behavior
The above test passes on GitHub CI action hosted on Ubuntu 20.04 and should also pass for a macOS system.
Build environment
- BDK tag/commit: v0.22.0
- OS+version: macOS 12.5.1, M1
- Rust/Cargo version: 1.63.0
- Rust/Cargo target: aarch64-apple-darwin
Additional context
I think this issue is related to https://github.com/apoelstra/rust-jsonrpc/issues/67.
Found this issue while testing https://github.com/bitcoindevkit/bdk-cli/pull/102.
I think the only workaround we have for this is to run the tests with fewer parallel threads, this generally tends to fix the issue.
I think it doesn't happen in the CI because the workers don't have that many cores available, so only a few tests at a time are run in parallel.
I tried rerunning cargo test with a single thread, but got the same error.
RUST_TEST_THREADS=1 cargo test --features regtest-bitcoin
My new theory is that we're running into an issue with bitcoind on macOS where the sqlite DB is very slow using the static linked lib, but runs fine with the MacOS system provided lib (For details see: https://github.com/bitcoin/bitcoin/issues/25724). I re-ran my broken test with a modified version of the utils::new_backend function that uses the env to find my homebrew install of bitcoind and the test is now passing.
BITCOIND_EXE=/opt/homebrew/bin/bitcoind cargo test --features regtest-bitcoin