Skip to content

Conversation

@luke-jr
Copy link
Member

@luke-jr luke-jr commented May 9, 2012

CreateNewBlock: Check that the produced CBlock is acceptable (except for proof-of-work and merkletree, since those need to be provided later)

This throws an exception from CreateNewBlock otherwise, which is not safe without #1245!

@luke-jr
Copy link
Member Author

luke-jr commented May 10, 2012

This is bugged. ConnectBlock requires the block to be on the disk already :(

@luke-jr luke-jr closed this May 10, 2012
@luke-jr
Copy link
Member Author

luke-jr commented May 10, 2012

In fact, this might even corrupt the blkindex.dat somehow, so if you tried it, I suggest rebuilding with -loadblock :/

@luke-jr luke-jr reopened this May 10, 2012
@luke-jr
Copy link
Member Author

luke-jr commented May 10, 2012

OK, this seems to work now.

@luke-jr
Copy link
Member Author

luke-jr commented May 19, 2012

Eligius has been running this from block 179513 (56 blocks found) and EclipseMC from 180573 (11 blocks), totalling 67 valid blocks with no problems found.

@luke-jr
Copy link
Member Author

luke-jr commented May 23, 2012

Now includes tests for CreateNewBlock

src/main.cpp Outdated
Copy link
Member

Choose a reason for hiding this comment

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

Why can't this formula be used in the justcheck case as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Position 1,1,1 is "magic" in FetchInputs to refer to the memory pool. Otherwise, it will try to find it on disk

Copy link
Member

Choose a reason for hiding this comment

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

Ok, can you add a comment to explain that?

…for proof-of-work and merkletree, since those need to be provided later)

This throws an exception from CreateNewBlock otherwise, which is not safe without bitcoin#1245!
@luke-jr
Copy link
Member Author

luke-jr commented May 27, 2012

Added comments per sipa's request, rebased on master, and fixed a bug in diskless BDB I found testing.

@luke-jr
Copy link
Member Author

luke-jr commented May 28, 2012

getmemorypool's caching mostly makes testing this impossible, but I did some vague performance testing by disabling it (so every call goes to CreateNewBlock):
git master: 1063 transactions/sec
checknewblock: 473 transactions/sec
checknewblock with signature checking skipped: 782 transactions/sec

IMO, even the worst-case scenario of 0.00321 seconds per transaction processed is worth the additional safety checking, especially when considering the extra caching getmemorypool and getwork both do to minimize CreateNewBlock calls.

@sipa
Copy link
Member

sipa commented May 30, 2012

ACK (together with #1245). I really like having unit tests that test blockchains.

@jgarzik
Copy link
Contributor

jgarzik commented Jun 27, 2012

ACK

@sipa
Copy link
Member

sipa commented Jun 27, 2012

@luke-jr Can you rebase #1245 and this? I'd like to merge.

@luke-jr
Copy link
Member Author

luke-jr commented Jun 27, 2012

Rebased. #1245 did not need rebasing.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a very un-C++-ish way of doing this. The C++ Way would be an abstract base CDBEnv class, with concrete subclasses for unit testing (CMockDbEnv or CMemoryDbEnv) and records-to-disk.

But the use of the global bitdb variable is also very un-c++-ish, and if Mike Hearn's experiments with LevelDB and Pieter's experiments with a new wallet storage format go well this whole subsystem might get junked anyway....

@gavinandresen
Copy link
Contributor

Does not compile 32 bit:

test/miner_tests.cpp:89: error: integer constant is too large for ‘long’ type
test/miner_tests.cpp:109: error: integer constant is too large for ‘long’ type
test/miner_tests.cpp:131: error: integer constant is too large for ‘long’ type
test/miner_tests.cpp:139: error: integer constant is too large for ‘long’ type
test/miner_tests.cpp:161: error: integer constant is too large for ‘long’ type
test/miner_tests.cpp:178: error: integer constant is too large for ‘long’ type

@luke-jr
Copy link
Member Author

luke-jr commented Jul 12, 2012

Explicitly made the literals long long. Apparently "long long" was not a standard type until C++11, and compilers implementing it as an extension did not support mere numeric literals bigger than long (the C++11 standard requires these literals be handled properly). GCC 4.5 works with both ways. In any case, being explicit doesn't seem like it hurts, so I've added that. Let me know if it still doesn't work.

@gavinandresen gavinandresen merged commit 639b61d into bitcoin:master Jul 26, 2012
@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.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants