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

kernel: De-globalize validation caches #30141

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

TheCharlatan
Copy link
Contributor

The validation caches are currently setup independently from where the rest of the validation code is initialized. This makes their ownership semantics unclear. There is also no clear enforcement on when and in what order they need to be initialized. The caches are always initialized in the BasicTestingSetup although a number of tests don't actually need them.

Solve this by moving the caches from global scope into the ChainstateManager class. This simplifies the usage of the kernel library by no longer requiring manual setup of the caches prior to using the ChainstateManager. Tests that need to access the caches can instantiate them independently.


This pull request is part of the libbitcoinkernel project.

@DrahtBot
Copy link
Contributor

DrahtBot commented May 19, 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
Concept ACK ajtowns, theuni

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:

  • #30214 (refactor: Improve assumeutxo state representation by ryanofsky)
  • #30157 (Fee Estimation via Fee rate Forecasters by ismaelsadeeq)
  • #30058 (Encapsulate warnings in generalized node::Warnings and remove globals by stickies-v)
  • #29745 (bench: Adds a benchmark for CheckInputScripts by kevkevinpal)
  • #29641 (scripted-diff: Use LogInfo/LogDebug over LogPrintf/LogPrint by maflcko)
  • #29432 (Stratum v2 Template Provider (take 3) by Sjors)

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.

Copy link
Contributor

@ajtowns ajtowns 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

src/validation.h Outdated Show resolved Hide resolved
Copy link
Member

@theuni theuni 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. Nice.

src/script/sigcache.cpp Outdated Show resolved Hide resolved
Instead clamp it to uint32::max if it exceeds it.

Co-authored-by: Anthony Towns <aj@erisian.com.au>
@TheCharlatan
Copy link
Contributor Author

Updated 79c9c55 -> 4a1df97 (noGlobalScriptCache_0 -> noGlobalScriptCache_1, compare)

  • Addressed @theuni's comment, made CSignatureCache more RAII styled.
  • Addressed @ajtowns's comment, applied his suggestion of dropping the error handling if the cache size exceeds the uint32_t maximum value.

Move its ownership to the ChainstateManager class.

Next to simplifying usage of the kernel library by no longer requiring
manual setup of the cache prior to using validation code, it also slims
down the amount of memory allocated by BasicTestingSetup.
Move it to the ChainstateManager class.
This is done in preparation for the following commit.
Move its ownership to the ChainstateManager class.

Next to simplifying usage of the kernel library by no longer requiring
manual setup of the cache prior to using validation code, it also slims
down the amount of memory allocated by BasicTestingSetup.

Use this opportunity to make CSignatureCache RAII styled
@TheCharlatan
Copy link
Contributor Author

Updated 4a1df97 -> 5b1576b (noGlobalScriptCache_1 -> noGlobalScriptCache_2, compare)

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

4 participants