-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Create Proof(OfWork) class #4506
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
Conversation
|
I got some feedback on #4377 and other places, I'm closing since this is not acceptable for bitcoind and people have already seen it. I will reopen it with new version still uses a class but without polymorphism. |
|
It is not completely encapsulated because the attributes are public. |
|
In general cleaning things up is pretty nice, and POW class seems to do that. Specific comments:
|
|
Updated removing a bunch of unnecessary #include "pow.h" |
src/core.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use "return SerializeHash(*this);" here, and have its IMPLEMENT_SERIALIZE contain a "READWRITE(proof);".
src/pow.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe GetWork() is a better name?
|
CBlockIndex could gain a CheckWork() method that just calls proof.CheckWork(GetBlockHash()). |
|
I created the CheckProof() method for CBlockHeader and CBlockIndex. |
|
Commits reordered so that the PR is easier to read (by creating the Proof class early on and then slowly encapsulating things). |
d6cfd1a to
5292172
Compare
|
I have left the last two commits with multiple small changes for later, after I know what's the most acceptable way to encapsulate the pow around miner. I will continue that discussion in #4423. But the "final touches" will depend on that, so there's no reason to include them before or stop this PR until that is resolved. Also the last commit was quite noisy. |
|
mhmm, I wonder if nBits and nNonce should be uint32_t instead of unsigned int... |
|
Yes, I believe all integers being serialized anywhere should eventually be turned into (u)intN_t's, but let's do that separately. There may already have been some PR for (part of) that. |
|
It needed rebase because #4180 was merged so I just changed unsigned int to unit32_t too. |
de0a919 to
9ac423e
Compare
|
Rebased |
|
I like the changes, I did have a thought that maybe CProof is at slight risk of ambiguity (E.g. SPV proof vs block proof). |
|
I think CProof should be split in its core data structure (which can go in core, or be included by it), and validation functions that take a CProof and perform the various checks on them (which can be in server). Not doing that will for example result in libscript contain block PoW validation... |
|
Having the class in core with only the serialization and using it with the functions is incompatible with making the fields private/protected, which is the final goal of this series of PRs. |
|
"Not doing that will for example result in libscript contain block PoW validation" |
|
I'm fine with splitting core into a transaction and a block part, and that would indeed suffice for now, but it would still mean that anything that uses block headers will depend on its validation code to. I don't like it, but I can't immediately come up with an example of something that would use headers parsing, but not need the ability to verify proofs. |
a91484d to
570e63b
Compare
proof.nBits to pow)
|
Rebased to make it more readable. |
|
Closing in favor of #5171, without a class. |
Continues #4377
The goal of this PR is to make easier to experiment on alternative proofs and at the same time improve bitcoind's modularity. IT is very possible that this will never make it into master, and that's fine, but ideally it would be very easy to maintain the branch by continuously rebasing on top of bitcoin/master.
I open this as a PR to get some feedback on what's acceptable for master and what is not, and maybe also to improve the code (specially the ugly hack for the serialization, which apparently doesn't work anyway).
It should also help understand #4377 better.
@jaromil is going to work on an alternative using function pointers.