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

[Miner] Rewrite miner code with proper encapsulation + test coverage #2155

Merged
merged 4 commits into from
Feb 3, 2021

Conversation

furszy
Copy link

@furszy furszy commented Jan 25, 2021

Have rewritten the miner code sources, dividing the miner thread from the block assembling process, encapsulating the block creation state inside a new BlockAssembler class (adapting bitcoin#7598).

Cleaned several mempool redundant checks inside the assembly process (adaptation of bitcoin#6898):

The mempool is explicitly assumed to be responsible for maintaining consistency of transactions with respect to not spending non-existent outputs, not double spending, script validity and coinbase maturity. Only finality of transactions is checked before assembling a block.

Another point added here is the rework of the previously non-functional miner_tests unit test. Which.. have essentially made it work, adding coverage for the miner process, updating it to a fairly recent point down upstream's path + adapting it to our blockchain and consensus rules.

The result is a large speed up in the block assembly process, a much better and cleaner code architecture and enable an easier add of new algorithms for block filling in the future.


A good work path on top of this would be to add unit test coverage for PoS, cold staking and Sapling block creation (among others). At the moment, most of the block creation tests are functional ones which are slow and require to setup entire nodes etc.

@furszy furszy self-assigned this Jan 25, 2021
@furszy furszy added the Block Generation Mining/Staking related issues label Jan 25, 2021
@furszy furszy force-pushed the 2020_revamp_miner branch 3 times, most recently from 4932fc5 to e59b572 Compare January 28, 2021 12:15
@random-zebra random-zebra added this to the 5.1.0 milestone Jan 28, 2021
Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

Nice stuff. First comments/nits...

src/blockassembler.cpp Outdated Show resolved Hide resolved
src/blockassembler.cpp Outdated Show resolved Hide resolved
src/blockassembler.cpp Outdated Show resolved Hide resolved
src/blockassembler.cpp Outdated Show resolved Hide resolved
@furszy
Copy link
Author

furszy commented Jan 29, 2021

Feedback tackled.

@random-zebra
Copy link

Mhm... I don't know why GitHub doesn't notify it, as it did in the past, but this PR has conflicts with the current master branch (due to #2105, which rearranged the position of the functions in rpc/mining.cpp).

Aside from this, tested ACK. Working as intended.

@furszy
Copy link
Author

furszy commented Feb 1, 2021

Just rebased it locally and there were no conflicts. Git is playing with your heart @random-zebra.
But.. in any case, pushed the rebased branch.

Copy link

@random-zebra random-zebra left a comment

Choose a reason for hiding this comment

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

utACK 0d55bcf after rebase

@furszy furszy requested review from Fuzzbawls and removed request for Fuzzbawls February 3, 2021 03:05
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

Been running this on testnet all day and looking great!

ACK 0d55bcf

@Fuzzbawls Fuzzbawls merged commit a88b6ea into PIVX-Project:master Feb 3, 2021
@furszy furszy deleted the 2020_revamp_miner branch November 29, 2022 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Block Generation Mining/Staking related issues Upstream
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants