Skip to content

Conversation

instagibbs
Copy link
Member

A few more places where genesis blocks are being tested for validity and would pop up when tested chainparam configurations. Genesis block should be treated as a consensus rule.

@instagibbs
Copy link
Member Author

instagibbs commented Nov 8, 2016

Moving the CheckBlock in ConnectBlock seems to cause p2p-compactblocks.py to stall out when run in batch. Perhaps seeing patterns that do not exist.

@jtimon
Copy link
Contributor

jtimon commented Nov 8, 2016

tested ACK 6e18ae4

EDIT: walletbackup.py doesn't really pass locally, only when I run it individually, the failure seems to start at 50e8a9c

EDIT2: I would test ACK master...jtimon:0.13-instagibbs-dontvalidategenesis though (based on e984730 works for me)

@@ -199,7 +199,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts(boost::function<CBlockIndex*(const uint256
pindexNew->nStatus = diskindex.nStatus;
pindexNew->nTx = diskindex.nTx;

if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus()))
if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus()) && pindexNew->GetBlockHash() != Params().GetConsensus().hashGenesisBlock)
Copy link
Contributor

Choose a reason for hiding this comment

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

style nit: perhaps new line after && here?

@laanwj
Copy link
Member

laanwj commented Nov 8, 2016

I wonder how many times we've purportedly fixed this.

Can you please add a test to make sure that the genesis block is really, really not validated and to prevent this from regressing again?

@instagibbs
Copy link
Member Author

@laanwj Until we have a method of loading up our own test networks via json/whatever I'm not sure how to test this. We need to create an invalid genesis block and has it pass, right?

@jtimon
Copy link
Contributor

jtimon commented Nov 8, 2016

@laanwj You may be remembering some of my previous attempts at doing this (like #6597 or #6230 ), but they didn't get merged. It is true that the only way to make sure it is and remains complete is to test it though.
But I'm afraid the only way to test this is from rpc and with a new chain whose genesis block is actually invalid (and not only in pow but other things like bip34).
We could more easily write such a test with something like #8994 which contains this and other things to make testchains more easily.

@paveljanik
Copy link
Contributor

Needs rebase.

@instagibbs
Copy link
Member Author

rebased

@jtimon
Copy link
Contributor

jtimon commented Feb 24, 2017

As a reminder, #8994 tests this commit with all python tests except for p2p-segwit.py and p2p-compactblocks.py.
@laanwj would that be sufficient testing?
Is there a simpler way to test it and have tests that prevent this from breaking again than create a new regtest-like testchain whose genesis block doesn't satisfy pow?

@instagibbs
Copy link
Member Author

Closing as it needs tests, and #8994 provides those, so they should be packaged together.

@instagibbs instagibbs closed this May 18, 2017
@jtimon jtimon mentioned this pull request Sep 10, 2019
3 tasks
kallewoof pushed a commit to kallewoof/bitcoin that referenced this pull request Oct 4, 2019
kallewoof pushed a commit to kallewoof/bitcoin that referenced this pull request Oct 4, 2019
…gen block

d97920c add functional test for coinbase connection to db (Gregory Sanders)
e532664 allow grabbing genesis transaction(s) when connected (Gregory Sanders)
c7e5549 [bitcoin#9102] really don't validate genesis block (Gregory Sanders)
ccf40db connect genesis block transaction outputs to coin db (Gregory Sanders)

Pull request description:

  Tests should now be working.

Tree-SHA512: aa2af6637c534d7f9185e969118b52519fe0609ae79fa8f4d5213f939f9a5915f958cf93d02aa6f4a47795c87cc23c93daff3807347cb1b12a426326e6dea60e
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants