Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc: Do not wait for headers inside loadtxoutset #29345

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

maflcko
Copy link
Member

@maflcko maflcko commented Jan 29, 2024

While the loadtxoutset default 10 minute timeout is convenient when it is sufficient, it may cause hassle where it is not. For example:

  • When P2P connections are missing, it seems better to abort early than wait for the timeout.
  • When the 10 minute timeout is not sufficient, the RPC will have to be called again, so a check or loop is needed outside the RPC either way. So might as well remove the loop inside the RPC.

@DrahtBot
Copy link
Contributor

DrahtBot commented Jan 29, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK fjahr, theStack, pablomartin4btc, TheCharlatan

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

Conflicts

No conflicts as of last run.

@theStack
Copy link
Contributor

Concept ACK

I tend to agree that it's best to remove the waiting loop and have instant feedback about missing headers instead, as I think that avoids frustration and/or confusion for users. Curious about reasonable arguments to keep it though (maybe I'm missing something).

Copy link
Member

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

Concept ACK

I agree with this change and @theStack's comment; one case I can think of would be a "ready to go" installation package or something like that? But as @maflcko said in the description, the procedure/ RPC call would need to be re-executed again, so not too sure about it really.

edit: I found here in the original PR #27596 a discussion about the waiting/ timeout.

@maflcko
Copy link
Member Author

maflcko commented Jan 30, 2024

Curious about reasonable arguments to keep it though

The only reason I can see to keep it, is when it is made infinite, and the RPC is made async.

@pablomartin4btc
Copy link
Member

Curious about reasonable arguments to keep it though

The only reason I can see to keep it, is when it is made infinite, and the RPC is made async.

You might consider this coming then #28620 (make loadtxoutset async), the linked fix could be updated soon I think.

@jamesob
Copy link
Member

jamesob commented Feb 1, 2024

Looks fine to me.

@fjahr
Copy link
Contributor

fjahr commented Feb 19, 2024

ACK faa30a4

Thanks, as @pablomartin4btc found, I had a slight preference for this simpler solution when reviewing the original PR already.

I wrote a test for this (and also removed a sync_block call that seemed unnecessary in the process), can be pulled in here or I can open it as a follow-up: https://github.com/fjahr/bitcoin/commits/pr29345/

Copy link
Contributor

@theStack theStack left a comment

Choose a reason for hiding this comment

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

Code-review ACK faa30a4

@fjahr
Copy link
Contributor

fjahr commented Feb 25, 2024

I wrote a test for this (and also removed a sync_block call that seemed unnecessary in the process), can be pulled in here or I can open it as a follow-up: https://github.com/fjahr/bitcoin/commits/pr29345/

I have opened a separate PR since this already has multiple ACKs and I might forget to open it later: #29478

Copy link
Member

@pablomartin4btc pablomartin4btc left a comment

Choose a reason for hiding this comment

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

tACK faa30a4

Testing the script on both master and this PR, it seems the execution gets stuck (at least for me) at the last validation - snapshot chain reloads -, independently from this change, and the following line would need to be removed, so the client node can be started:

client_sleep_til_boot

I think when the watch command sub-process gets stopped with CTRL+C (as instructed to the user when validation gets completed), both bitcoind server and client get shutdown (I can see in their debug logs on the other 2 terminals I open following the script instructions during its execution).

I tested the script removing the above line #L199 and validated that works fine. Also, the finish() function would not kill the server node which got shutdown during the CTRL+C, unless we still need to provide blocks to the client node, we need to start it up again as well.

diff --git a/contrib/devtools/test_utxo_snapshots.sh b/contrib/devtools/test_utxo_snapshots.sh
index 93a4cd1683..cd34197cf5 100755
--- a/contrib/devtools/test_utxo_snapshots.sh
+++ b/contrib/devtools/test_utxo_snapshots.sh
@@ -196,7 +196,12 @@ echo "   Press CTRL+C after you're satisfied to exit the demo"
 echo
 read -p "Press [enter] to continue"
 
-client_sleep_til_boot
+# shellcheck disable=SC2086
+./src/bitcoind $SERVER_PORTS -logthreadnames=1 -debug=net -datadir="$SERVER_DATADIR" \
+    $EARLY_IBD_FLAGS -connect=0 -listen=1 >/dev/null &
+SERVER_PID="$!"
+server_sleep_til_boot
+
 # shellcheck disable=SC2086
 ./src/bitcoind $CLIENT_PORTS $ALL_INDEXES -logthreadnames=1 -datadir="$CLIENT_DATADIR" -connect=0 \
     -addnode=127.0.0.1:$SERVER_PORT "$EARLY_IBD_FLAGS" >/dev/null &

Copy link
Contributor

@TheCharlatan TheCharlatan left a comment

Choose a reason for hiding this comment

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

ACK faa30a4

@fanquake fanquake merged commit ba90b05 into bitcoin:master Feb 26, 2024
16 checks passed
@maflcko maflcko deleted the 2401-rpc-loadtxoutset- branch February 26, 2024 11:24
@maflcko
Copy link
Member Author

maflcko commented Feb 27, 2024

Testing the script on both master and this PR, it seems the execution gets stuck (at least for me) at the last validation - snapshot chain reloads -, independently from this change, and the following line would need to be removed, so the client node can be started:

I wonder if there is a need to have a bash script to serve as documentation on how to create and load snapshots. Maybe the existing python tests are enough, or a shorter markdown document can be written, with the important key settings and steps highlighted?

@pablomartin4btc
Copy link
Member

I wonder if there is a need to have a bash script to serve as documentation on how to create and load snapshots.

Well, IMPO since it's already there I would keep it updated, it's a different exercise, you need to touch de code and re-compile in order the snapshot to work, you could hit different issues perhaps.

or a shorter markdown document can be written, with the important key settings and steps highlighted?

I think, and looking at the current state of the doc, it could be improved adding some command output references and perhaps to some parts of this bash script.

achow101 added a commit that referenced this pull request Mar 13, 2024
1ec6684 test: Add test for loadtxoutset when headers are not synced (Fabian Jahr)
2bc1ecf test: Remove unnecessary sync_blocks in assumeutxo tests (Fabian Jahr)

Pull request description:

  It adds a test for the change to `loadtxoutset` made in #29345.  Before that change the test doesn't fail right away but times out after 10 minutes.

  Also removes a `sync_blocks` call that didn't seem to do anything valuable.

ACKs for top commit:
  achow101:
    ACK 1ec6684
  pablomartin4btc:
    tACK 1ec6684
  BrandonOdiwuor:
    ACK 1ec6684
  theStack:
    ACK 1ec6684

Tree-SHA512: 1337decdf91e4a4f7213fcf8ace1d705e5c1422e0ac3872a59b5be9c33e743850cb8f5f7474750a534952eefd5cfe43fe85a54efb9bc0e47515136a2903676e5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants