Skip to content

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Feb 26, 2024

This LogPrint(BCLog::RAND, ...) is never logged because the SeedStartup function is called at a very early stage, such as during the instantiation of the static CSignatureCache object, before any log categories are added. This PR fixes this behavior.

This `LogPrint(BCLog::RAND, ...)` is never logged because the
`SeedStartup` function is called at a very early stage, such as during
the instantiation of the static `CSignatureCache` object, before any log
categories are added. This change addresses this behavior.
@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 26, 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 hernanmarino, maflcko

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #29641 (scripted-diff: Use LogInfo/LogDebug over LogPrintf/LogPrint by maflcko)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

luke-jr added a commit to bitcoinknots/bitcoin that referenced this pull request Mar 5, 2024
This `LogPrint(BCLog::RAND, ...)` is never logged because the
`SeedStartup` function is called at a very early stage, such as during
the instantiation of the static `CSignatureCache` object, before any log
categories are added. This change addresses this behavior.

Github-Pull: bitcoin#29480 (rewritten)
Copy link
Contributor

@hernanmarino hernanmarino left a comment

Choose a reason for hiding this comment

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

ACK 88468a8

@DrahtBot DrahtBot mentioned this pull request Jun 25, 2024
@maflcko
Copy link
Member

maflcko commented Aug 8, 2024

This LogPrint(BCLog::RAND, ...) is never logged because the SeedStartup function is called at a very early stage, such as during the instantiation of the static CSignatureCache object, before any log categories are added. This PR fixes this behavior.

This is outdated and the steps to reproduce no longer work. Currently, it needs something like:

diff --git a/src/init.cpp b/src/init.cpp
index faaf3353d0..164f624b4e 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -194,6 +194,11 @@ static void RemovePidFile(const ArgsManager& args)
         LogPrintf("Unable to remove PID file (%s): %s\n", fs::PathToString(pid_path), msg);
     }
 }
+static bool once_flag{[] {
+    auto v{std::vector<uint8_t>(3)};
+    GetStrongRandBytes(v);
+    return true;
+}()};
 
 static std::optional<util::SignalInterrupt> g_shutdown;
 

and: ./bld/src/qt/bitcoin-qt -datadir=/tmp -regtest -asmap=/tmp/no_file -printtoconsole -debug=rand -logthreadnames=1 -logsourcelocations=1 (or similar).

@maflcko
Copy link
Member

maflcko commented Aug 8, 2024

review ACK 88468a8

but it would be good to update the context here, given my previous reply.

Also, it may be good to use LogDebug in the only remaining RAND-debug-log call:

$ git grep '::RAND'
src/logging.cpp:    {"rand", BCLog::RAND},
src/random.cpp:    LogPrint(BCLog::RAND, "Feeding %i bytes of dynamic environment data into RNG\n", hasher.Size() - old_size);

This also clarifies that the this is the only remaining call, which seems like useful context for reviewers.

@hebasto
Copy link
Member Author

hebasto commented Aug 12, 2024

I won’t be working on this PR in the near future. So, closing it and labeling it "Up for grabs".

@danielabrozzoni
Copy link
Member

Hey! I found this PR while looking at the up for grabs, but I noticed that #30750 replaced LogPrint with LogDebug, and currently on master the log line is printed. As far as I understand, this PR shouldn't be needed anymore, and the "Up for grabs" label can be removed :)

❯ ./build/bin/bitcoind -debug=rand
2025-05-22T15:16:52Z [rand] Feeding 133269 bytes of environment data into RNG

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.

5 participants