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

[refactor] Remove BlockAssembler m_mempool member #28843

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TheCharlatan
Copy link
Contributor

Instead, pass the mempool pointer as an argument to CreateNewBlock and pass that on to addPackageTxs. Before, addPackageTxs had access to both the m_mempool member and the passed in mempool, which could be confusing. This was noticed in this PR review: #25223 (comment).

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 10, 2023

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 stickies-v
Stale ACK dergoegge

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:

  • #30157 (Fee Estimation via Fee rate Forecasters by ismaelsadeeq)

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
Member

@maflcko maflcko left a comment

Choose a reason for hiding this comment

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

lgtm

@TheCharlatan TheCharlatan marked this pull request as ready for review November 10, 2023 11:33
Copy link
Member

@dergoegge dergoegge 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 ed71a7b

@@ -138,9 +137,9 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc

int nPackagesSelected = 0;
int nDescendantsUpdated = 0;
if (m_mempool) {
LOCK(m_mempool->cs);
addPackageTxs(*m_mempool, nPackagesSelected, nDescendantsUpdated);
Copy link
Contributor

@ajtowns ajtowns Nov 11, 2023

Choose a reason for hiding this comment

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

Why aren't you just changing addPackageTxs to use m_mempool directly? Seems simpler, and doesn't change the public api. Something like ajtowns@944d8bc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the review discussion in #25223 introducing a check in the function and using the arrow operator feels like a step back in code quality. I also feel like having raw pointers as class members is something we should try to avoid, since its ownership semantics are ambiguous. Relying on the member variable precludes this later comment on the one I linked in the PR description by making a refactor into fully static functions harder.

Copy link
Contributor

Choose a reason for hiding this comment

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

I could see that being an argument for doing away with BlockAssembler entirely (at least as a public interface), and replacing BlockAssembler(chainstate, mempool, options).CreateNewBlock(scriptPubKeyIn) it with a function: CreateNewBlock(chainstate, mempool, scriptPubKeyIn, options) (effectively reverting #7598).

But if you're keeping BlockAssembler around, the entire point of that class is to assemble a block with txs from the mempool -- that's why most of its private functions require CTxMemPool::setEntries references, eg -- so it seems pretty strange to make it clumsier at doing that by pulling data it needs to do its job out of the class itself.

(Unrelated, but also seems a bit bogus to call the m_last_block_* things "members" when they're really globals...)

Instead, pass the mempool pointer as an argument to CreateNewBlock and
pass that on to addPackageTxs. Before, addPackageTxs had access to both
the m_mempool member and the passed in mempool, which could be
confusing.
@TheCharlatan
Copy link
Contributor Author

@stickies-v
Copy link
Contributor

Concept ACK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready for Review PRs
Development

Successfully merging this pull request may close these issues.

None yet

6 participants