Commit graph

76 commits

Author SHA1 Message Date
Suhas Daftuar 88c35491ab Fix compact block handling to not ban if block is invalid 2016-11-03 13:07:12 -04:00
Pieter Wuille 51f278329d Make removed and conflicted arguments optional to remove 2016-10-21 19:22:43 -07:00
Wladimir J. van der Laan 05998da5a7
Merge #8865: Decouple peer-processing-logic from block-connection-logic
a9aec5c Use BlockChecked signal to send reject messages from mapBlockSource (Matt Corallo)
7565e03 Remove SyncWithWallets wrapper function (Matt Corallo)
12ee1fe Always call UpdatedBlockTip, even if blocks were only disconnected (Matt Corallo)
f5efa28 Remove CConnman parameter from ProcessNewBlock/ActivateBestChain (Matt Corallo)
fef1010 Use CValidationInterface from chain logic to notify peer logic (Matt Corallo)
aefcb7b Move net-processing logic definitions together in main.h (Matt Corallo)
0278fb5 Remove duplicate nBlocksEstimate cmp (we already checked IsIBD()) (Matt Corallo)
87e7d72 Make validationinterface.UpdatedBlockTip more verbose (Matt Corallo)
2016-10-18 22:48:51 +02:00
Wladimir J. van der Laan 744d2652dd
Merge #8223: [c++11] Use std::unique_ptr for block creation.
9fce062 [c++11] Use std::unique_ptr for block creation. (Daniel Kraft)
2016-10-18 21:16:08 +02:00
Matt Corallo f5efa28393 Remove CConnman parameter from ProcessNewBlock/ActivateBestChain 2016-10-04 13:51:32 -04:00
Cory Fields 8d58c4d81f net: Pass CConnman around as needed 2016-09-08 12:04:35 -04:00
Suhas Daftuar 8bfd70817b Enable size accounting in mining unit tests 2016-07-28 14:27:19 -04:00
Pieter Wuille 2b1f6f9ccf BIP141: Other consensus critical limits, and BIP145
Includes changes by Suhas Daftuar, Luke-jr, and mruddy.
2016-06-22 15:43:00 +02:00
Daniel Kraft 9fce0629b4 [c++11] Use std::unique_ptr for block creation.
CreateNewBlock returns a pointer for which the caller takes ownership.
Use std::unique_ptr to make this explicit and simplify handling of these
objects in getblocktemplate.
2016-06-18 19:38:28 +02:00
Suhas Daftuar 29fac19c93 Add unit tests for ancestor feerate mining 2016-06-16 12:35:37 -04:00
Wladimir J. van der Laan e1486eb95c
Merge #7598: Refactor CreateNewBlock to be a method of the BlockAssembler class
c2dd5a3 FIX: correctly measure size of priority block (Alex Morcos)
a278764 FIX: Account for txs already added to block in addPriorityTxs (Alex Morcos)
4dc94d1 Refactor CreateNewBlock to be a method of the BlockAssembler class (Alex Morcos)
2016-06-13 11:35:55 +02:00
Pavel Janík c2715d3ab8 Do not shadow local variables 2016-06-07 21:22:48 +02:00
Alex Morcos 4dc94d1036 Refactor CreateNewBlock to be a method of the BlockAssembler class 2016-05-18 14:11:12 -04:00
instagibbs f8536a62c3 Corrected values 2016-04-07 10:14:49 -04:00
instagibbs 617deeb06e Gave miner test values constants for less error-prone values. 2016-04-07 10:14:44 -04:00
Pieter Wuille 6851107b3a BIP9 Implementation
Inspired by former implementations by Eric Lombrozo and Rusty Russell, and
based on code by Jorge Timon.
2016-03-15 16:54:38 +01:00
Wladimir J. van der Laan 80d1f2e483
Merge #7184: Implement SequenceLocks functions for BIP 68
b043c4b fix sdaftuar's nits again (Alex Morcos)
a51c79b Bug fix to RPC test (Alex Morcos)
da6ad5f Add RPC test exercising BIP68 (mempool only) (Suhas Daftuar)
c6c2f0f Implement SequenceLocks functions (Alex Morcos)
2016-02-12 17:03:46 +01:00
Alex Morcos c6c2f0fd78 Implement SequenceLocks functions
SequenceLocks functions are used to evaluate sequence lock times or heights per BIP 68.

The majority of this code is copied from maaku in #6312
Further credit: btcdrak, sipa, NicolasDorier
2016-02-10 15:35:33 -05:00
MarcoFalke fa24439ff3 Bump copyright headers to 2015 2015-12-13 18:08:39 +01:00
Alex Morcos 553cad94e2 Rewrite CreateNewBlock
Use the score index on the mempool to only add sorted txs in order.  Remove much of the validation while building the block, relying on mempool to be consistent and only contain txs that can be mined.
The mempool is assumed to be consistent as far as not containing txs which spend non-existent outputs or double spends, and scripts are valid.  Finality of txs is still checked (except not coinbase maturity, assumed in mempool).
Still TestBlockValidity in case mempool consistency breaks and return error state if an invalid block was created.
Unit tests are modified to realize that invalid blocks can now be constructed if the mempool breaks its consistency assumptions and also updated to have the right fees, since the cached value is now used for block construction.

Conflicts:
	src/miner.cpp
2015-12-01 12:09:37 -05:00
Wladimir J. van der Laan 2ef5ffa59a
Merge pull request #6915
2d8860e Fix removeForReorg to use MedianTimePast (Suhas Daftuar)
b7fa4aa Don't call removeForReorg if DisconnectTip fails (Suhas Daftuar)
7e49f5f Track coinbase spends in CTxMemPoolEntry (Suhas Daftuar)
bb8ea1f removeForReorg calls once-per-disconnect-> once-per-reorg (Matt Corallo)
474b84a Make indentation in ActivateBestChainStep readable (Matt Corallo)
b0a064c Fix comment in removeForReorg (Matt Corallo)
9b060e5 Fix removal of time-locked transactions during reorg (Matt Corallo)
0c9959a Add failing test checking timelocked-txn removal during reorg (Matt Corallo)
2015-12-01 13:17:34 +01:00
Wladimir J. van der Laan 327291af02
Merge pull request #6914
114b581 Prevector type (Pieter Wuille)
2015-12-01 10:22:14 +01:00
Suhas Daftuar 7e49f5f8b4 Track coinbase spends in CTxMemPoolEntry
This allows us to optimize CTxMemPool::removeForReorg.
2015-11-30 13:12:53 -05:00
Pieter Wuille eece63fa72 Switch blocks to a constant-space Merkle root/branch algorithm.
This switches the Merkle tree logic for blocks to one that runs in constant (small) space.
The old code is moved to tests, and a new test is added that for various combinations of
block sizes, transaction positions to compute a branch for, and mutations:
 * Verifies that the old code and new code agree for the Merkle root.
 * Verifies that the old code and new code agree for the Merkle branch.
 * Verifies that the computed Merkle branch is valid.
 * Verifies that mutations don't change the Merkle root.
 * Verifies that mutations are correctly detected.
2015-11-27 15:36:52 +01:00
Alex Morcos e587bc3fd9 Implement helper class for CTxMemPoolEntry constructor
This is only for unit tests.
2015-11-16 20:41:32 -05:00
Pieter Wuille 114b5812f6 Prevector type 2015-11-13 18:15:20 +01:00
Jorge Timón 6bc9e4056b Chainparams: Explicit CChainParams arg for miner:
-BitcoinMiner
-CreateNewBlock
-GenerateBitcoins
-ProcessBlockFound
2015-11-11 13:21:17 +01:00
Jorge Timón 598e494587 Chainparams: Explicit CChainParams arg for main (pre miner):
-ProcessNewBlock
-TestBlockValidity
2015-11-11 13:21:17 +01:00
Gregory Maxwell d1c3762ae8 Revert "Revert "Enable policy enforcing GetMedianTimePast as the end point of lock-time constraints""
This reverts commit 8537ecdfc4.
2015-11-03 17:14:09 +00:00
Gregory Maxwell 8537ecdfc4 Revert "Enable policy enforcing GetMedianTimePast as the end point of lock-time constraints"
This reverts commit dea8d21fc6.
2015-11-01 20:05:16 +00:00
Mark Friedenbach dea8d21fc6 Enable policy enforcing GetMedianTimePast as the end point of lock-time constraints
Transactions are not allowed in the memory pool or selected for inclusion in a block until their lock times exceed chainActive.Tip()->GetMedianTimePast(). However blocks including transactions which are only mature under the old rules are still accepted; this is *not* the soft-fork required to actually rely on the new constraint in production.
2015-10-23 09:02:24 -07:00
Pieter Wuille 391dff16fe Do not store Merkle branches in the wallet.
Assume that when a wallet transaction has a valid block hash and transaction position
in it, the transaction is actually there. We're already trusting wallet data in a
much more fundamental way anyway.

To prevent backward compatibility issues, a new record is used for storing the
block locator in the wallet. Old wallets will see a wallet file synchronized up
to the genesis block, and rescan automatically.
2015-09-22 18:51:07 +02:00
Jorge Timón 9dd793f499 TRIVIAL: Missing includes 2015-07-23 21:10:22 +02:00
Wladimir J. van der Laan 9c93ee5ceb
Merge pull request #6222
efd4444 Explicitly set tx.nVersion for the genesis block and mining tests (Mark Friedenbach)
2015-06-10 09:48:00 +02:00
Mark Friedenbach efd44440d8 Explicitly set tx.nVersion for the genesis block and mining tests
If/when CTransaction::CURRENT_VERSION is incremented, this will break CChainParams and the miner tests. This fix sets the transaction version explicitly where we depend on the hash value (genesis block, proof of work checks).
2015-06-02 16:39:34 -07:00
Suhas Daftuar 9be0e6837b Be stricter in processing unrequested blocks
AcceptBlock will no longer process an unrequested block, unless it has not
been previously processed and has more work than chainActive.Tip()
2015-06-02 13:54:29 -04:00
Wladimir J. van der Laan 87550eefc1
Merge pull request #6183
28bf062 Fix off-by-one error w/ nLockTime in the wallet (Peter Todd)
2015-06-01 11:33:33 +02:00
Peter Todd 28bf06236d
Fix off-by-one error w/ nLockTime in the wallet
Previously due to an off-by-one error the wallet ignored
nLockTime-by-height transactions that would be valid in the next block
even though they are accepted into the mempool. The transactions
wouldn't show up until confirmed, nor would they be included in the
unconfirmed balance. Similar to the mempool behavior fix in 665bdd3b,
the wallet code was calling IsFinalTx() directly without taking into
account the fact that doing so tells you if the transaction could have
been mined in the *current* block, rather than the next block.

To fix this we strip IsFinalTx() of non-consensus-critical
functionality, removing the default arguments, and add CheckFinalTx() to
check if a transaction will be final in the next block.
2015-05-27 05:51:33 -04:00
jtimon da29ecbcc6 Consensus: MOVEONLY: Move CValidationState from main consensus/validation 2015-05-15 16:05:28 +02:00
Cory Fields a8cdaf5c96 checkpoints: move the checkpoints enable boolean into main
This pertains to app-state, so it doesn't make sense to handle inside the
checkpoint functions.
2015-04-30 23:14:48 -04:00
Wladimir J. van der Laan 48265f3cf4 Revert mining changes in #5957
This reverts commit e2edf95cd3 6b04508e37 0df67f1f7a,
except the changes to the RPC tests.

A `generate` RPC call is introduced based on the old code.
2015-04-10 07:51:27 +02:00
Pieter Wuille e2edf95cd3 Bugfix: make CreateNewBlock return pindexPrev 2015-04-01 11:47:10 -07:00
Pieter Wuille 51598b2631 Reinitialize state in between individual unit tests.
This changes the TestingSetup fixture to be per-unit-test rather than global.
Most tests don't need it, so it's only invoked in a few.
2015-03-03 09:01:46 -08:00
Michael Ford 78253fcbad Remove references to X11 licence 2014-12-16 15:56:50 +08:00
Wladimir J. van der Laan f24bcce2ac
Merge pull request #1816
b867e40 CreateNewBlock: Stick height in coinbase so we pass template sanity check (Luke Dashjr)
60755db submitblock: Check for duplicate submissions explicitly (Luke Dashjr)
bc6cb41 QA RPC tests: Add tests block block proposals (Luke Dashjr)
9765a50 Implement BIP 23 Block Proposal (Luke Dashjr)
3dcbb9b Abstract DecodeHexBlk and BIP22ValidationResult functions out of submitblock (Luke Dashjr)
132ea9b miner_tests: Disable checkpoints so they don't fail the subsidy-change test (Luke Dashjr)
df08a62 TestBlockValidity function for CBlock proposals (used by CreateNewBlock) (Luke Dashjr)
4ea1be7 CreateNewBlock and miner_tests: Also check generated template is valid by CheckBlockHeader, ContextualCheckBlockHeader, CheckBlock, and ContextualCheckBlock (Luke Dashjr)
a48f2d6 Abstract context-dependent block checking from acceptance (Luke Dashjr)
2014-11-24 14:43:10 +01:00
Luke Dashjr 132ea9b48f miner_tests: Disable checkpoints so they don't fail the subsidy-change test 2014-11-18 19:20:10 +00:00
Wladimir J. van der Laan 73b82a3089
Merge pull request #5162
d2e74c5 boost: moveonly: split CPubKey and friends to new files (Cory Fields)
78c228c boost: moveonly: move BIP32Hash to hash.h (Cory Fields)
900078a boost: moveonly: create eccryptoverify.h|cpp and move helper functions there (Cory Fields)
2014-11-04 09:26:45 +01:00
Wladimir J. van der Laan 84d26d3a36
Merge pull request #5106
1bea2bb Rename ProcessBlock to ProcessNewBlock to indicate change of behaviour, and document it (Luke Dashjr)
d29a291 Rename RPC_TRANSACTION_* errors to RPC_VERIFY_* and use RPC_VERIFY_ERROR for submitblock (Luke Dashjr)
f877aaa Bugfix: submitblock: Use a temporary CValidationState to determine accurately the outcome of ProcessBlock, now that it no longer does the full block validity check (Luke Dashjr)
24e8896 Add CValidationInterface::BlockChecked notification (Luke Dashjr)
2014-11-03 12:22:45 +01:00
Cory Fields d2e74c55bd boost: moveonly: split CPubKey and friends to new files 2014-10-31 01:19:37 -04:00
Luke Dashjr 1bea2bbddc Rename ProcessBlock to ProcessNewBlock to indicate change of behaviour, and document it 2014-10-28 08:15:14 +00:00