Skip to content

Conversation

@NicolasDorier
Copy link
Contributor

@NicolasDorier NicolasDorier commented Jul 14, 2016

It is a work in progress, I manage to remove the CBlockIndex dependency from consensus block by adding two new types: CConsensusFlags and CConsensusContextualInfo (last block, last block mtp, now, last block height). Both of them can be trivial calculated in main() with pIndex, then passed to consensus method.
The code change is minimal and easy to review.

BlockVerify/TransactionVerify will require the user to pass the CConsensusFlags as well CConsensusContextualInfo.

A GetFlags method without too much code is difficult as it relies heavily on CBlockIndex. It is also fairly easy enough to port into other languages.
As such it is considered out of scope of this PR.

Alternatively, @jtimon is also working on https://github.com/jtimon/bitcoin/commits/jt .

@NicolasDorier NicolasDorier changed the title Consensuslib: Block Verify / Transaction Verify [Work in progress] Consensuslib: Block Verify / Transaction Verify [Do not merge, work in progress] Jul 14, 2016
@NicolasDorier NicolasDorier force-pushed the blkconsensus branch 7 times, most recently from bd83e46 to 49c22c5 Compare July 14, 2016 11:15
@jtimon
Copy link
Contributor

jtimon commented Jul 14, 2016

Actually I'm copying/re-writing things from that branch to https://github.com/jtimon/bitcoin/tree/0.12.99-consensus (which contains #8328 #8329 and #8337 ).
I really think we should try to work on a common base...

src/main.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you plan to move GetContextInfo() to libconsensus ? If not, please don't move consensus critical code out of consensus critical functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed that the consensus code only depends on the current majorityVersion. So I'm calculating the majorityVersion outside consensus, and I make the check inside. I've not found a better solution for now.

@NicolasDorier
Copy link
Contributor Author

NicolasDorier commented Jul 14, 2016

Thanks @jtimon, it is actually moving very fast now, I'll try to consolidate with the same base a you when the dust in my code will settle. For now I'll fix the pow you just told. How did you do for the logging ? with CValidationState I see you just remove the "error" methods ? (I really don't like the "Logger" abstraction, but I don't want to remove features either :()

Also I broke the consensus somewhere :p

@jtimon
Copy link
Contributor

jtimon commented Jul 14, 2016

How did you do for the logging ?

#8339 (comment)

with CValidationState I see you just remove the "error" methods ?

Look again to the PR I link you, the messages aren't lost.

Also I broke the consensus somewhere :p

Maybe in #8339 (comment) ?

@NicolasDorier
Copy link
Contributor Author

NicolasDorier commented Jul 14, 2016

Awesome I'll cherry pick your commit and remove my logger.

EDIT: ho I need to do it for the new methods :(

@NicolasDorier
Copy link
Contributor Author

NicolasDorier commented Jul 14, 2016

the consensus break in the time-too-old rule. (block too early)

EDIT: Found the culprit, in TestValidityBlock I was not using prevIndex for calculating the context.

@NicolasDorier
Copy link
Contributor Author

@jtimon if I understand well https://github.com/bitcoin/bitcoin/pull/7287/files actually I only need to remove error and pass "false" to DoS/Invalid ValidationState methods right? Since you are already printing out stuff in the caller ?

@jtimon
Copy link
Contributor

jtimon commented Jul 14, 2016

You need to make sure you print from all callers, yes.
You replace the error("my message") with false, yes, but also, at the end, you add ''', false, "my message""" so that you don't lose the longer message.

@NicolasDorier NicolasDorier force-pushed the blkconsensus branch 6 times, most recently from 2d70454 to 1059bc8 Compare July 14, 2016 16:29
@NicolasDorier
Copy link
Contributor Author

@jtimon NicolasDorier@53f677b might be useful (independant commit which remove error from contextualcheckblockheader)

@NicolasDorier
Copy link
Contributor Author

Yes, I just created #8341 with the reference of the two callers. (they already have error calls)

@NicolasDorier NicolasDorier force-pushed the blkconsensus branch 2 times, most recently from d86e85d to 28a6030 Compare July 15, 2016 05:52
@NicolasDorier NicolasDorier force-pushed the blkconsensus branch 6 times, most recently from 7cc5844 to 786e831 Compare July 16, 2016 07:34
@fanquake
Copy link
Member

Closing this for now due to inactivity. @NicolasDorier feel free to reopen if your continuing this work.

@fanquake fanquake closed this Jan 12, 2017
@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.

4 participants