Skip to content

Conversation

@jtimon
Copy link
Contributor

@jtimon jtimon commented Jan 7, 2016

Based on #7287 to avoid consensus/consensus.cpp having to depend on FormatStateMessage() (static function in main.cpp) temporarily.
This moves most of the remaining consensus-critical code in main.cpp to the consensus directory.

Even if I haven't published the promised document explaining the libconsensus longer term plan, all that is needed to review this is being able to tell whether all the moved functions are consensus critical or not; and then make sure that the code is only being moved without changes.
As other times, I have introduced trivial non-functional changes that those who check "moveonlyness" should notice.

@dcousens
Copy link
Contributor

dcousens commented Jan 8, 2016

concept ACK, will review later

@dcousens
Copy link
Contributor

utACK df57ab7

@jtimon
Copy link
Contributor Author

jtimon commented Feb 1, 2016

Rebased after #7287 has been merged.

@jtimon
Copy link
Contributor Author

jtimon commented Feb 1, 2016

Also, in case it is useful to anyone, I have backported this with a few other merged consensus changes on top of 3cd836c (last-0.11.99) in 9877eb5 (on top of https://github.com/jtimon/bitcoin/commits/backports-0.12 ).

@dcousens
Copy link
Contributor

dcousens commented Feb 1, 2016

re-ACK 1c31e65 MOVE-ONLY (bar 1 comment)

@laanwj
Copy link
Member

laanwj commented Feb 2, 2016

So for TL; DR this moves the following functions to consensus:

  • IsSuperMajority
  • GetBlockSubsidy
  • IsFinalTx
  • GetLegacySigOpCount
  • GetP2SHSigOpCount
  • CheckTransaction
  • Consensus::CheckTxInputs
  • CheckBlockHeader
  • CheckBlock
  • ContextualCheckBlockHeader
  • ContextualCheckBlock

needed to review this is being able to tell whether all the moved functions are consensus critical or not

AFAIK, all these functions are consensus critical.
I have not checked move-onlyness.

@jtimon jtimon force-pushed the consensus-moveonly-0.13.99 branch from 1c31e65 to 7c7cca2 Compare February 14, 2016 01:37
@jtimon
Copy link
Contributor Author

jtimon commented Feb 14, 2016

EDIT:
Rebased after 0.12 fork (see the updated enumeration in https://github.com/jtimon/bitcoin/tree/backports-0.12):

Rebase (1): Report non-mandatory script failures correctly #7276
Rebase (2): Mark blocks with too many sigops as failed #7217
Rebase (3): Consensus: Remove calls to error() and FormatStateMessage() from some consensus code in main #7287
Rebase (4): MOVEONLY: non-consensus: from pow to chain: #7311
Rebase (5): Consensus build package #7091
6) Improve block validity/ConnectBlock() comments #7444
(don't confuse with 2f19905 petertodd "Improve block validity/ConnectBlock() comments")
7): tests: Remove May15 test #7490
8) Implement SequenceLocks functions for BIP 68 #7184

@jtimon jtimon force-pushed the consensus-moveonly-0.13.99 branch from 7c7cca2 to d0832f0 Compare February 14, 2016 02:46
@jtimon
Copy link
Contributor Author

jtimon commented Feb 14, 2016

Rebased(8) [after #7184]

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be part of a move only PR surely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In an older version I believe that allowed me to remove the main include, but since that's not the case anymore I guess I should leave this out.

@btcdrak
Copy link
Contributor

btcdrak commented Feb 14, 2016

Concept ACK.

@NicolasDorier
Copy link
Contributor

I always see the may15 tests

@laanwj
Copy link
Member

laanwj commented Feb 15, 2016

I always see the may15 tests

Good catch. They were removed in #7490, and appear to be readded here.

@jtimon jtimon force-pushed the consensus-moveonly-0.13.99 branch from d0832f0 to 8f67d21 Compare February 15, 2016 18:24
@jtimon
Copy link
Contributor Author

jtimon commented Feb 15, 2016

Oops, updated without nits. By the way, after #7184 I these two functions are moved as well:

std::pair<int, int64_t> CalculateSequenceLocks(const CTransaction &tx, int flags, std::vector<int>* prevHeights, const CBlockIndex& block);
bool EvaluateSequenceLocks(const CBlockIndex& block, std::pair<int, int64_t> lockPair);
bool SequenceLocks(const CTransaction &tx, int flags, std::vector<int>* prevHeights, const CBlockIndex& block)

@jtimon jtimon force-pushed the consensus-moveonly-0.13.99 branch 2 times, most recently from 72f84d3 to 3a3cd39 Compare February 15, 2016 18:37
@jtimon
Copy link
Contributor Author

jtimon commented Feb 19, 2016

Ping

@morcos
Copy link
Contributor

morcos commented Feb 19, 2016

utACK 3a3cd39

Copy link
Member

Choose a reason for hiding this comment

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

I fail to see how this additional comment is move only. You may as well just keep it the way it was, as this comment is not adding much information.

Also two lines below this you are changing the white space. CValidationState &state.

Still, Concept ACK

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's some other small documentation additions in consensus/consensus.h but they can all be postponed.
I'm happy to remove this extra doc line or any other as nit.

Regarding the withe space, the goal was to only change that kind of little style thing if it's to comply more with our style rules, but here I'm actually doing the opposite (https://github.com/bitcoin/bitcoin/blob/master/src/.clang-format#L41), so thank you for noticing on time. Probably lost in rebase at some point, I will change this.

Copy link
Member

Choose a reason for hiding this comment

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

@jtimon I am happy to review again, if you stick to what is mentioned in the commit message... I mean, it is great that you are adding documentation and fixing white space but it is a lot harder to verify MOVEONLY if there are random changes in between.

There is no rule that says you can only use one commit per pull request. Each goal which can be achieved in a separate commit, should indeed go into a separate atomic commit. (This is not meant specifically for you but also for others, including me.)

@jtimon jtimon force-pushed the consensus-moveonly-0.13.99 branch from 3a3cd39 to 9001c60 Compare February 25, 2016 19:19
@jtimon
Copy link
Contributor Author

jtimon commented Mar 3, 2016

@laanwj as predicted, people are afraid of doing this now to avoid "complicating backports" I keep thinking that just after branching is maybe the worse possible time for refactors. Closing for lack of interest (can reopen when there's more interest).

@jtimon jtimon closed this Mar 3, 2016
@laanwj
Copy link
Member

laanwj commented Mar 3, 2016

@jtimon Yes sorry for that. On the other hand there's always some reason to delay stuff like this, at some point we have to just do it, "complicate backports" or not.

@jtimon
Copy link
Contributor Author

jtimon commented Mar 3, 2016

Agreed, but apparently most potential reviewers disagree.

@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.

8 participants