feat: wait for bitcoind to accept RPC calls#76
Merged
theborakompanioni merged 2 commits intomasterfrom Nov 9, 2022
Merged
Conversation
e31f45a to
1353a76
Compare
1353a76 to
dcc08e8
Compare
Collaborator
Author
|
Converted to draft again: Does not handle if bitcoind is completely down yet. |
Collaborator
Author
Should be working as expected now. |
dergigi
approved these changes
Nov 9, 2022
Contributor
There was a problem hiding this comment.
Nice! Looks good to me. I tested everything as detailed in joinmarket-webui/jam#559
npm run regtest:up✔️npm run regtest:init✔️- Observe successful init ✔️
- See
getblockchaininfocalls fromjm_regtest_joinmarket2every 5 seconds ifMINE_BLOCKS < 99✔️
tACK ✅
Expand to **show test logs**
Test Run 1 (MINE_BLOCKS = 101)
jm_regtest_bitcoind | 2022-11-09T10:35:00.507818Z UpdateTip: new best=61d6c7fb76afef78a30edf3fe57f26d8dd98f82f44e3cab98a571d023c16636c height=101 version=0x20000000 log2_work=7.672425 tx=102 date='2022-11-09T10:35:18Z' progress=1.000000 cache=0.0MiB(101txo)
jm_regtest_bitcoind_initializer | Successfully mined 101 blocks to address bcrt1qrnz0thqslhxu86th069r9j6y7ldkgs2tzgf5wx.
jm_regtest_bitcoind_initializer | Waiting for bitcoind to report at least 101 blocks...
jm_regtest_bitcoind | 2022-11-09T10:35:00.514505Z ThreadRPCServer method=getblockchaininfo user=regtest
jm_regtest_bitcoind | 2022-11-09T10:35:00.515490Z Adding fixed seeds as -dnsseed=0, -addnode is not provided and all -seednode(s) attempted
jm_regtest_bitcoind_initializer | Successfully waited for 101 blocks to be reported.
jm_regtest_bitcoind_initializer | Creating /root/.regtest-initializer/btc_fully_synched...
jm_regtest_bitcoind_initializer | Created /root/.regtest-initializer/btc_fully_synched.
jm_regtest_bitcoind_initializer exited with code 0
jm_regtest_joinmarket3 | ........................................................................................................................................................................................................................++++
jm_regtest_joinmarket3 | writing new private key to 'key.pem'
jm_regtest_joinmarket3 | -----
jm_regtest_joinmarket3 | /src/scripts
jm_regtest_joinmarket3 | Waiting for file /root/.regtest-initializer/btc_fully_synched to be created...
jm_regtest_joinmarket3 | Successfully waited for file /root/.regtest-initializer/btc_fully_synched to be created.
jm_regtest_joinmarket3 | Creating wallet jm_tertiary if missing...
jm_regtest_bitcoind | 2022-11-09T10:35:00.820983Z ThreadRPCServer method=createwallet user=joinmarket3
jm_regtest_bitcoind | 2022-11-09T10:35:00.823014Z Using BerkeleyDB version Berkeley DB 4.8.30: (April 9, 2010)
jm_regtest_bitcoind | 2022-11-09T10:35:00.823030Z Using wallet /walletdata/regtest/jm_tertiary/wallet.dat
jm_regtest_bitcoind | 2022-11-09T10:35:00.823122Z BerkeleyEnvironment::Open: LogDir=/walletdata/regtest/jm_tertiary/database ErrorFile=/walletdata/regtest/jm_tertiary/db.log
jm_regtest_bitcoind | 2022-11-09T10:35:00.832304Z init message: Loading wallet…
jm_regtest_bitcoind | 2022-11-09T10:35:00.838134Z [jm_tertiary] Wallet File Version = 10500
jm_regtest_bitcoind | 2022-11-09T10:35:00.838151Z [jm_tertiary] Keys: 0 plaintext, 0 encrypted, 0 w/ metadata, 0 total. Unknown wallet records: 0
jm_regtest_joinmarket | The chain is fully synched
Test Run 2 (MINE_BLOCKS = 99)
jm_regtest_irc | 2022-11-09T10:46:41.646Z : info : connect : Client connected [J58suVvpzpmvYyXN] [u:~u] [r:None]
jm_regtest_joinmarket | 2022-11-09 10:46:41,673 INFO spawned: 'jmwalletd' with pid 37
jm_regtest_joinmarket | 2022-11-09 10:46:41,676 INFO spawned: 'ob-watcher' with pid 38
jm_regtest_joinmarket | 2022-11-09 10:46:41,688 INFO spawned: 'tor' with pid 39
jm_regtest_bitcoind | 2022-11-09T10:46:42.073941Z ThreadRPCServer method=getblockchaininfo user=joinmarket
jm_regtest_bitcoind | 2022-11-09T10:46:42.074108Z ThreadRPCServer method=getblockchaininfo user=joinmarket
jm_regtest_bitcoind | 2022-11-09T10:46:42.074669Z ThreadRPCServer method=listwallets user=joinmarket
jm_regtest_bitcoind | 2022-11-09T10:46:42.074934Z ThreadRPCServer method=listwallets user=joinmarket
jm_regtest_bitcoind | 2022-11-09T10:46:42.075106Z ThreadRPCServer method=getwalletinfo user=joinmarket
jm_regtest_bitcoind | 2022-11-09T10:46:42.075601Z ThreadRPCServer method=getwalletinfo user=joinmarket
jm_regtest_bitcoind | 2022-11-09T10:46:42.081518Z ThreadRPCServer method=getnewaddress user=joinmarket
jm_regtest_bitcoind | 2022-11-09T10:46:42.081551Z ThreadRPCServer method=getnewaddress user=joinmarket
jm_regtest_bitcoind | 2022-11-09T10:46:42.081637Z [jm_primary] keypool reserve 1
jm_regtest_bitcoind | 2022-11-09T10:46:42.084259Z [jm_primary] keypool keep 1
jm_regtest_bitcoind | 2022-11-09T10:46:42.085510Z [jm_primary] keypool added 1 keys (0 internal), size=2000 (1000 internal)
jm_regtest_bitcoind | 2022-11-09T10:46:42.086358Z [jm_primary] keypool reserve 2
jm_regtest_bitcoind | 2022-11-09T10:46:42.086998Z [jm_primary] keypool keep 2
jm_regtest_irc | 2022-11-09T10:46:42.094Z : info : connect-ip : Client connecting: real IP 172.19.0.8, proxied IP <nil>
jm_regtest_joinmarket | 2022-11-09 10:46:43,090 INFO success: jmwalletd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
jm_regtest_joinmarket | 2022-11-09 10:46:43,090 INFO success: ob-watcher entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
jm_regtest_joinmarket | 2022-11-09 10:46:43,090 INFO success: tor entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
jm_regtest_irc | 2022-11-09T10:46:43.397Z : info : connect : Client connected [J59gGSirLH6S3XBg] [u:~u] [r:None]
jm_regtest_bitcoind | 2022-11-09T10:46:43.332430Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:46:48.396127Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:46:53.470755Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:46:58.532004Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:03.614934Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:08.675009Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:13.745799Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:18.804808Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:23.865400Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:28.938202Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:34.005230Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:39.051904Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:44.105837Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:49.139792Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:54.179530Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
jm_regtest_bitcoind | 2022-11-09T10:47:59.234546Z ThreadRPCServer method=getblockchaininfo user=joinmarket2
This was referenced Nov 10, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #75.
This PR enables waiting for the backing Bitcoin Core instance to be ready and accept RPC requests.
This is done by making a
getblockchaininforequest before starting any services, as this is the first request JM will be performing during initialization. Also, as a by-product, the response is used to wait for>= 100blocks to be reported - thereby making the imageregtest-compatible without further adaptions.This behaviour can be disabled by setting env var
WAIT_FOR_BITCOINDtofalse. Default value istrue.Please see this as a quick bugfix and not the final solution. Ideally, only service s
jmwalletdandob-watcherare waiting. Other services (such asnginxandtor) could already be started.How to test?
Please see joinmarket-webui/jam#559 and follow the instructions.