Consensus: Adapt declarations of most obviously consensus functions #6591

pull jtimon wants to merge 6 commits into bitcoin:master from jtimon:consensus-params-0.12.99 changing 22 files +202 −103
  1. jtimon commented at 11:28 PM on August 26, 2015: contributor

    Before the first step #5696 (after creating an initial libconsensus and without counting checkpoints and Consensus::Params changes) gets negated (see #6526), here's a little second step towards completing libconsensus. This is also part of #5970 process of explicitly passing chainparams around, and in that sense it replaces #6024.

    The function declarations are adapted and moved to consensus/consensus.h Since we're touching all declarations, it is diff-wise free to put them in the Consensus namespace at the same time. It also cherry picks one commit from #6526 (modified to rename CheckTransaction to Consensus::CheckTx [again, that rename is diff-wise free]).

    The function definitions are left in main.cpp for now, but some of them will have to be moved to consensus/consensus.cpp before exposing anything else in libconsensus (my preference would be to expose VerifyHeader next, but I haven't got much feedback in that reward).

    Blocked by:

    • Blocksize: Turn MAX_BLOCK_SIZE and MAX_BLOCK_SIGOPS into functions #6625
  2. jtimon cross-referenced this on Aug 26, 2015 from issue Move blocksize and related parameters to consensusparams by theuni
  3. dcousens commented at 11:33 PM on August 26, 2015: contributor

    concept ACK

  4. jtimon cross-referenced this on Aug 27, 2015 from issue DEPENDENT: Globals: Avoid calling Params() by jtimon
  5. jtimon cross-referenced this on Aug 27, 2015 from issue Chainparams: Explicit Consensus::Params arg for almost all remaining functions by jtimon
  6. jonasschnelli commented at 7:01 AM on August 27, 2015: contributor

    Concept ACK. Not sure if GetAdjustedTime() as param is required. After this PR there would be 5 more calls to GetAdjustedTime() (which is maybe not very time critical but at least it locks cs_nTimeOffset).

  7. jtimon commented at 9:30 PM on August 29, 2015: contributor

    @jonasschnelli GetAdjustedTime() is not welcomed in libconsensus. Maybe @theuni can give more details about why. A vague explanation would be that libconsensus has to be stateless. In main.cpp (full of global variables anyway) it's just fine, but these functions will be eventually moved to consensus.cpp to be built independently for libconsensus (or at least that's my plan).

  8. jtimon force-pushed on Sep 2, 2015
  9. jtimon force-pushed on Sep 4, 2015
  10. jtimon commented at 8:20 PM on September 4, 2015: contributor

    Rebased on top of modified #6625 and force-pushed.

  11. consensus: don't define MAX_STANDARD_TX_SIGOPS in terms of block size 18a33b3979
  12. consensus: teach ExtractMatches to check for an arbitrary max transaction number
    This is a no-op change. For now, everything passes MAX_BLOCK_SIZE / 60, so the
    result matches what it would've before.
    
    Tests use a number equal to the number of transactions where necessary,
    to ensure that they're never rejected when blocksizesize isn't being tested.
    5cb4d7e20e
  13. consensus: teach CheckTransaction to check for an arbitrary max tx size
    This is a no-op change. For now, everything passes MAX_BLOCK_SIZE, so the
    result matches what it would've before.
    
    Tests use a value of std::numeric_limits<uint64_t>::max() where necessary, to ensure that they're never
    rejected when size isn't being tested.
    660e072519
  14. consensus: Move consensus constants into Consensus::Params and consensus.h (as functions)
    The following are now tied to a chain rather than being defined as global
    constants. Their values have not changed.
    
    nMinTxSize
    nMaxBlockSize
    nMaxTxSize
    nMaxBlockSigops
    nCoinbaseMaturity
    
    Also, for free (diff-wise):
    
    Blocksize: Turn MAX_BLOCK_SIZE (nMaxBlockSize) and MAX_BLOCK_SIGOPS (nMaxBlockSigops) into functions
    
    ...which take Consensus::Params as parameter
    This will be convenient to reduce the diff of any proposal that changes the blocksize as a hardfork
    0cac6d221f
  15. Consensus: MOVEONLY: Most important consensus function declarations to consensus/consensus.h e07b3d71e2
  16. Consensus: Chainparams: Explicit Consensus::Params for consensus functions:
    -CheckBlockHeader
    -ContextualCheckBlockHeader
    -CheckBlock
    -ContextualCheckBlock
    
    Also add nTime parameter to CheckBlockHeader and CheckBlock.
    Also use the oportunity to rename the functions inside the Consensus namespace.
    be466dc9a5
  17. jtimon force-pushed on Sep 6, 2015
  18. laanwj added the label Consensus on Sep 8, 2015
  19. jtimon cross-referenced this on Sep 13, 2015 from issue Consensus: Turn CBlockIndex::GetMedianTimePast into independent function by jtimon
  20. jtimon cross-referenced this on Sep 14, 2015 from issue Consensus: Separate most consensus functions to consensus.cpp by jtimon
  21. jtimon commented at 8:10 PM on September 14, 2015: contributor

    Closing in favor of #6672.

  22. jtimon closed this on Sep 14, 2015

  23. bitcoin locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-20 06:55 UTC