Skip to content

Conversation

hmel
Copy link
Contributor

@hmel hmel commented Apr 26, 2016

Some more work on global Params() cleanup as part of #7829
Changed FlushStateToDisk(), CheckBlockHeader(), CheckBlock() and ContextualCheckBlockHeader() to accept relevant ChainParams instead of calling global Params()

@@ -3212,20 +3212,20 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
return true;
}

bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW)
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, int64_t nTime, bool fCheckPOW)
Copy link
Contributor

Choose a reason for hiding this comment

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

I have never been sure on whether int64_t was the most appropriate type here or not.

Copy link
Member

Choose a reason for hiding this comment

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

It is. Only "block time" is sometimes a 32-bit integer as we can't just change the block headers. Otherwise, always use int64_t for time.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, precisely for that (because CBlockHeader::nTime uses 32 bit) I thought that maybe it would make more sense to use 32 bit in the code that is intended to become part of libconsensus.
But if doesn't make sense passing it like this is fine, thanks for the fast answer.

@jtimon
Copy link
Contributor

jtimon commented Apr 26, 2016

utACK b9fb24f

@hmel
Copy link
Contributor Author

hmel commented Apr 26, 2016

Trivial: Added explicit CChainParams& to LoadBlockIndexDB() and LoadBlockIndex()

@maflcko
Copy link
Member

maflcko commented Apr 27, 2016

@hmel Does this compile and pass the test suites locally?

@jtimon
Copy link
Contributor

jtimon commented Apr 29, 2016

I haven't tested the rpc tests. In this branch, unittests start failing with the second commit 9fc71c5 . But I'm pretty sure that commit is correct, and if you put it before the "FlushStateToDisk()" one both pass the unitests, and then the next commit fails. After tweaking the order a little bit, it seems the commit that is causing the error is b9fb24f

Even if you put it the first (the rest of the commits pass unittests when alone and combined), you get:

test_bitcoin: main.cpp:1720: void InvalidChainFound(CBlockIndex*): Assertion `tip' failed.

I'm not really sure what is going on here, though.

@hmel Every commit in a PR should pass the unittests, one by one. One way to guarantee this is edit all the commits with an interactive and make check them one by one

Another slightly less complete option is running:

git bisect start HEAD base
git bisect run make [distcheck] check -j6
git bisect reset
(distcheck optional, assuming 6 cores/hyperthreads)

This will just binary search for the first commit that fails, assuming that once it fails it will fail in all the following commits too, that's what I mean by "less complete".

Apart from make check, you can run more tests locally with

python ./qa/pull-tester/rpc-tests.py
python ./qa/pull-tester/rpc-tests.py -extended (this is slow)
python ./qa/pull-tester/rpc-tests.py mempool_limit (if you just want to run a single rpc test like mempool_limit.py)

@@ -2461,8 +2461,7 @@ enum FlushStateMode {
* if they're too large, if it's been a while since the last write,
* or always and in all cases if we're in prune mode and are deleting files.
*/
bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
const CChainParams& chainparams = Params();
bool static FlushStateToDisk(CValidationState &state, const CChainParams& chainparams, FlushStateMode mode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Syle nit: If I remember correctly, https://github.com/bitcoin/bitcoin/blob/master/src/.clang-format says to break after function or method headers in definitions (ie, move the opening bracket to the next line), but I can't find the line that says so (may just default to true).

Copy link
Member

Choose a reason for hiding this comment

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

If you don't want to do that manually (or remember the exact "rules"), you can just do $ git diff HEAD~ -U0|cfd. Where cfd is an alias for ./contrib/devtools/clang-format-diff.py -p1 -i -v.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, we already have that? Awesome!

@dcousens
Copy link
Contributor

dcousens commented May 2, 2016

utACk b9fb24f, agreed with nits by @jtimon

Overlaps #7985

@maflcko
Copy link
Member

maflcko commented Jun 1, 2016

Closing due to inactivity.

@maflcko maflcko closed this Jun 1, 2016
@jtimon
Copy link
Contributor

jtimon commented Jun 1, 2016

@hmel Sorry that I didn't came back to you when you got travis erros. I got confused locally too.
In any case, #8077 has been merged which contained some of what this had. But you had more than that and I hope you're open to rebase that and keep merging things.

I just cared too much about those few lines to let @pstratem do something different from what I wanted without listening to me for a while first. I will update #7829 but please don't feel like you have to wait for it. Please feel free to rebase and reopen this, open another fresh new PR (probably that is preferable) or whatever. Ping me and I will try to help.

@sipa
Copy link
Member

sipa commented Jun 1, 2016

Feel free to pick this up again!

@jtimon
Copy link
Contributor

jtimon commented Jul 18, 2016

Now that 0.13 has branched, refactor changes are more likely to get merged for a while. Maybe this is a good time to pick this up again, or something else from #7829 (the list is now up to date).

@hmel
Copy link
Contributor Author

hmel commented Jul 19, 2016

Be glad to. I'll see what I can do in the coming weeks.

@hmel hmel deleted the global-params-cleanup branch March 27, 2018 22:38
@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.

5 participants