WIP: Encapsulate consensus and policy code #5768

pull jtimon wants to merge 74 commits into bitcoin:master from jtimon:consensus_policy changing 89 files +2631 −2105
  1. jtimon commented at 2:11 AM on February 8, 2015: contributor

    This is a work in progress. I'm trying to isolate consensus and policy code and this is my longest branch on that. I will open other PRs extracting subsets of this, but people interested in this work can see a unified thing here and hopefully I will e able to get some feedback. Please don't comment on individual commits as this will be rebased very often (or do it, just be aware that your comments will probably disappear soon). So far this contains:

    *** WAIT_REVIEW MOVEONLY-ish: Preparations to not include main.h from any other header #5681 [main_includes] *** WAIT_REVIEW Cleanup: Don't include main.h from any other header #5697 [main_includes2] *** WAIT_REVIEW MOVEONLY: Move constants and globals to consensus.h and policy.o #5696 [consensus_policy0] *** WAIT_REVIEW Consensus: Move CheckTransaction() from main to consensus/consensus #5669 [consensus](on main_includes) *** WAIT_REVIEW Refactor: Create CCoinsViewEfficient interface for CCoinsViewCache #5747 *** WAIT_REVIEW Policy: Create CPolicy interface and CStandardPolicy class implementing it #5595 [policy] *** WAIT_REVIEW Change: Refactor: inline main:GetMinRelayFee() in main:AcceptToMemoryPool() #5709 [getminrelayfee] *** WAIT_REVIEW TRIVIAL: Refactor: inline CTxIn::IsFinal() [ only used in main::IsFinalTx() ] #5769 [isfinal]

  2. jtimon force-pushed on Feb 8, 2015
  3. jtimon force-pushed on Feb 8, 2015
  4. jtimon force-pushed on Feb 8, 2015
  5. jtimon cross-referenced this on Feb 13, 2015 from issue Policy: Create CPolicy interface and CStandardPolicy class implementing it by jtimon
  6. jtimon force-pushed on Feb 15, 2015
  7. jtimon force-pushed on Feb 15, 2015
  8. laanwj added the label Improvement on Feb 19, 2015
  9. jtimon force-pushed on Feb 21, 2015
  10. jtimon force-pushed on Feb 23, 2015
  11. jtimon force-pushed on Feb 24, 2015
  12. jtimon force-pushed on Mar 3, 2015
  13. jtimon force-pushed on Mar 5, 2015
  14. gavinandresen force-pushed the base branch on Mar 5, 2015
  15. jtimon force-pushed on Mar 10, 2015
  16. jtimon force-pushed on Mar 10, 2015
  17. jtimon force-pushed on Mar 10, 2015
  18. jtimon force-pushed on Mar 19, 2015
  19. jtimon force-pushed on Mar 25, 2015
  20. jtimon force-pushed on Mar 26, 2015
  21. Consensus: Create consensus/consensus.h with some constants f48d61ca85
  22. Consensus: Refactor: Decouple CValidationState from main::AbortNode() 49fd398fa9
  23. Consensus: MOVEONLY: Move CValidationState from main consensus/validation b746d48478
  24. Consensus: Refactor: turn main::GetBlockValue() into GetBlockSubsidy(Consensus::Params) 809373969f
  25. Consensus: Refactor: Decouple IsSuperMajority from Params() 52d1b8c291
  26. Consensus: SQUASHME: Cleanup: remove Consensus::Params getters from CChainParams bc7a24024d
  27. Consensus: Cleanup: remove Consensus::Params getters from CChainParams
    s/Params().HashGenesisBlock()/params.hashGenesisBlock
    9f175cc737
  28. Consensus: Refactor: Decouple from CChainParams: CheckBlockHeader,
    CheckBlock, ContextualCheckBlockHeader and ContextualCheckBlock
    15610220a4
  29. Consensus: Tests: Correct pow tests 46d3ce3eb1
  30. Consensus: Move Params().GetConsensus() up 42a3f650bf
  31. Consensus: Refactor: Consensus version of CheckBlockHeader() 39fd953ca5
  32. Consensus: Separate CheckIndexAgainstCheckpoint() from ContextualCheckBlockHeader 18a0234e08
  33. Consensus: Refactor: Consensus version of ContextualCheckBlockHeader() 73fd4854ff
  34. Policy: Create policy.o with some constants and globals a6b9dac987
  35. Consensus: MOVEONLY: Move CheckBlockHeader, IsSuperMajority and ContextualCheckBlockHeader() to consensus.o ce4d1a621a
  36. Consensus: MOVEONLY: move pow.o to consensus dir cac7f88462
  37. Consensus: Introduce Consensus::VerifyBlockHeader() 14f1c4c9a1
  38. Consensus: Refactor: CheckTransaction() -> Consensus::CheckTx()
    Decouple it from util.h [bool error(char*)] and BOOST_FOREACH
    5862fb1c7c
  39. Consensus: MOVEONLY-ish: Move GetLegacySigOpCount() from main to consensus ea9760918a
  40. Consensus: Refactor: Turn main::CheckBlock() into Consensus::CheckBlock() 5b4fd0cdf7
  41. Consensus: MOVEONLY: Move CheckTx and CheckBlock from main to consensus f79543aa18
  42. Includes: fix hidden dependencies 23d448b244
  43. Coins: Refactor: Separate CCoinsViewEfficient abstract class from CCoinsViewCache (make parent its class) f0ee3f0b0c
  44. Coins: MOVEONLY: Move CCoinsViewCache and CCoinsModifier to coinscache.o d2ca5ae820
  45. move Consensus::GetBlockSubsidy fb7bf06798
  46. Consensus: MOVEONLY: GetP2SHSigOpCount() from main to consensus 219904943e
  47. Consensus: Introduce Consensus::GetSigOpCount(CTransaction, CCoinsViewEfficient) f848147e9f
  48. Consensus: Refactor: Separate Consensus::CheckTxInputs from CheckInputs 4d14fa3970
  49. Consensus: Refactor: Move CTransaction::GetValueOut() to Consensus b11d3eea2e
  50. Consensus: MOVEONLY-ish: Move MAX_MONEY and MoneyRange() [renamed VerifyAmount] from amount.h to consensus.h a7fa2e37b6
  51. Consensus: Refactor: Introduce GetSpendHeight() 1431ccb379
  52. Consensus: Refactor: Safely remove !tx.IsCoinBase() check from main::CheckInputs() 0d8182daed
  53. Consensus: MOVEONLY: Consensus::CheckTxInputs() from main to consensus d5b606dd86
  54. Consensus: Refactor: Separate CheckInputs() into CheckInputsScripts and Consensus::CheckTxInputs() 3cef0c3093
  55. fix Consensus::GetValueOut 808fd8a9ee
  56. Consensus: Refactor: Decouple CheckInputsScripts() from global nScriptCheckThreads (remove pvChecks param) d97d8a57af
  57. Consensus: Introduce Consensus::CheckTxInputsScripts() and use it instead of CheckInputsScripts() when possible 0715b2387e
  58. Consensus: Refactor: Introduce Consensus::GetFlags
    and use it instead of MANDATORY_SCRIPT_VERIFY_FLAGS in miner::CreateNewBlock()
    0f8d996645
  59. Consensus: Refactor: Separate consensus version of IsFinalTx() 658bd6f61b
  60. Consensus: Refactor: Consensus version of Consensus::ContextualCheckBlock() d183008475
  61. Consensus: MOVEONLY: Move IsFinalTx and ContextualCheckBlock to consensus.o and hide IsSuperMajority() 7f61727b72
  62. Consensus: Introduce Consensus::VerifyTx() 48a2a4fc3c
  63. Consensus: Refactor: Introduce Consensus::EnforceBIP30 4c0e3014f3
  64. Consensus: Introduce Consensus::VerifyBlock() 19da7dd1cc
  65. Policy: Prepare utils for policy aa77acdc00
  66. Policy: Create CPolicy interface and CStandardPolicy implementation ee7c6e743c
  67. Policy: MOVEONLY: script/standard.o::IsStandard() -> CPolicy::ApproveScript() 551c742036
  68. Policy: Refactor: CTxOut::IsDust(CFeeRate) -> CPolicy::ApproveOutput(CTxOut)
    Decouples CTxOut from CFeeRate
    Simplifies IsDust() interface encapsulating the access to global minRelayTxFee
    Also move the new GetDustThreshold() from CTxOut to Policy
    ed7c1d5130
  69. Policy: Refactor: Create CPolicy::ApproveTx(tx, state) from main::IsStandardTx(tx, reason) 981a922e14
  70. Policy: MOVEONLY: main::AreInputsStandard() -> CPolicy::ApproveTxInputs() db55bc7333
  71. Includes: Cleanup includes ca8a76b79f
  72. LOCAL: notes on include main.h 563fadbb8f
  73. Policy: Replace STANDARD script flags with ALL (which adds SCRIPT_VERIFY_LOW_S) for signing
    The new ALL_SCRIPT_VERIFY_FLAGS in script/interpreter is independent from policy
    630a594f98
  74. Policy: MOVEONLY: Move CFeeRate to policy 59b7145c90
  75. Policy: MOVEONLY-ish: Move CMinerPolicyEstimator out of txmempool.o (CTxMemPoolEntry has to be separated temporarily as well) afe977f0c1
  76. Policy: Refactor: Don't pass a CTxMemPool param to CWallet::GetMinimumFee() 8714d8e08e
  77. Policy: Refactor: Decouple CTxMemPool from CMinerPolicyEstimator and policy::minRelayTxFee ba88aa1419
  78. Policy: Refactor: SQUASHED: inline GetMinRelayFee() in AcceptToMemoryPool() db84bc13a9
  79. Policy: Refactor: Simplify CheckInputsScripts 0c93f9b003
  80. Policy: SQUASHME: Refactor: Simplify CheckInputsScripts 1a94c8e5a4
  81. Policy: MOVEONLY: CPolicy::ApproveTxInputsScripts from main::CheckInputsScripts b50257bcaa
  82. Policy: Refactor: Move datacarrier policy logic to policy.o d994d6b1a6
  83. Policy: MOVEONLY: Turn fIsBareMultisigStd global into a CStandardPolicy attribute e0ff0d2bf2
  84. Policy: Introduce CPolicy attribute in CWallet 3b9614c593
  85. Policy: Encapsulate policy script verify flags as CStandardPolicy parameters 8c11a398b5
  86. Policy: MOVEONLY: initialize global minRelayTxFee in InitPolicyFromArgs()) a4f5995236
  87. Refactor: int nHeight = chainActive.Height() 48ade71903
  88. Policy: Separate CPolicy::ValidateTxFee() from main::AcceptToMemoryPool() 41ddb0568a
  89. Policy: Separate Standard and test policies to select them independently of the network 143d17ce79
  90. Policy: Replace CChainParams::fRequireStandard with CChainParams::strDefaultPolicy 3b88a863cf
  91. Policy: Introduce CPolicy::ValidateFee(CAmount, size_t) 3a7b66da4f
  92. Policy: Introduce CPolicy::ValidateFeeRate(CFeeRate) 04b651ba3a
  93. Policy: Pass policy as parameter in many main and miner functions b9fb65776b
  94. Policy: Introduce CPolicy::GetMinRelayFeeRate() 61145b4817
  95. jtimon force-pushed on Apr 2, 2015
  96. jtimon commented at 7:17 PM on April 13, 2015: contributor

    Closing for now

  97. jtimon closed this on Apr 13, 2015

  98. 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-19 06:55 UTC