Commit graph

149 commits

Author SHA1 Message Date
Karl-Johan Alm b7b48c8bbd Refactor: Remove using namespace <xxx> from src/*.cpp. 2017-01-27 18:13:20 +09:00
Wladimir J. van der Laan ff25c32392 mempool: add notification for added/removed entries
Add notification signals to make it possible to subscribe to mempool
changes:

- NotifyEntryAdded(CTransactionRef)>
- NotifyEntryRemoved(CTransactionRef, MemPoolRemovalReason)>

Also add a mempool removal reason enumeration, which is passed to the
removed notification based on why the transaction was removed from
the mempool.
2017-01-23 15:43:22 -05:00
Wladimir J. van der Laan dd98f04538
Merge #9380: Separate different uses of minimum fees
eb30d1a Introduce -dustrelayfee (Alex Morcos)
7b1add3 Introduce -incrementalrelayfee (Alex Morcos)
daec955 Introduce -blockmintxfee (Alex Morcos)
2017-01-16 19:33:08 +01:00
Alex Morcos 7b1add3c28 Introduce -incrementalrelayfee 2017-01-16 08:39:03 -05:00
Suhas Daftuar fe7e593b24 Fix use-after-free in CTxMemPool::removeConflicts() 2017-01-10 15:21:21 -05:00
Alex Morcos ebafdcabb1 Pass pointers to existing CTxMemPoolEntries to fee estimation 2017-01-04 12:09:34 -05:00
Alex Morcos d825838e64 Always update fee estimates on new blocks.
All decisions about whether the transactions are valid data points are made at the time the transaction arrives. Updating on blocks all the time will now cause stale fee estimates to decay quickly when we restart a node.
2017-01-04 12:09:34 -05:00
Alex Morcos 6f06b268c1 rename bool to validFeeEstimate 2017-01-04 12:09:33 -05:00
Alex Morcos 84f7ab08d2 Remove member variable hadNoDependencies from CTxMemPoolEntry
Fee estimation can just check its own mapMemPoolTxs to determine the same information.  Note that now fee estimation for block processing must happen before those transactions are removed, but this shoudl be a speedup.
2017-01-04 12:09:33 -05:00
Wladimir J. van der Laan 1ce7ede2a9
Merge #9288: Fix a bug if the min fee is 0 for FeeFilterRounder
f8d43b8 Avoid rollingMinimumFeeRate never being able to decay below half (Alex Morcos)
eab8e1b fix a bug if the min fee is 0 for FeeFilterRounder (Alex Morcos)
2017-01-04 12:33:56 +01:00
Wladimir J. van der Laan 869781c51c
Merge #9283: A few more CTransactionRef optimizations
91335ba Remove unused MakeTransactionRef overloads (Pieter Wuille)
6713f0f Make FillBlock consume txn_available to avoid shared_ptr copies (Pieter Wuille)
62607d7 Convert COrphanTx to keep a CTransactionRef (Pieter Wuille)
c44e4c4 Make AcceptToMemoryPool take CTransactionRef (Pieter Wuille)
2017-01-04 12:23:10 +01:00
isle2983 27765b6403 Increment MIT Licence copyright header year on files modified in 2016
Edited via:

$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Pieter Wuille c44e4c467c Make AcceptToMemoryPool take CTransactionRef 2016-12-21 18:18:23 -08:00
Wladimir J. van der Laan 5a70572049
Merge #9262: Prefer coins that have fewer ancestors, sanity check txn before ATMP
cee1612 reduce number of lookups in TransactionWithinChainLimit (Gregory Sanders)
af9bedb Test for fix of txn chaining in wallet (Gregory Sanders)
5882c09 CreateTransaction: Don't return success with too-many-ancestor txn (Gregory Sanders)
0b2294a SelectCoinsMinConf: Prefer coins with fewer ancestors (Gregory Sanders)
2016-12-20 13:27:08 +01:00
Gregory Sanders cee16123f5 reduce number of lookups in TransactionWithinChainLimit 2016-12-19 20:51:34 -05:00
Gregory Sanders 0b2294a980 SelectCoinsMinConf: Prefer coins with fewer ancestors 2016-12-13 09:41:04 -05:00
Alex Morcos f8d43b8081 Avoid rollingMinimumFeeRate never being able to decay below half 2016-12-08 15:40:14 -05:00
Alex Morcos a874ab5ccf remove internal tracking of mempool conflicts for reporting to wallet 2016-12-05 13:41:25 -05:00
Alex Morcos bf663f8e93 remove external usage of mempool conflict tracking 2016-12-05 13:41:25 -05:00
Matt Corallo 76faa3cdfe Rename the remaining main.{h,cpp} to validation.{h,cpp} 2016-12-02 09:42:51 -08:00
Pieter Wuille b4e4ba475a Introduce convenience type CTransactionRef 2016-11-19 17:53:23 -08:00
Pieter Wuille 1662b437b3 Make CBlock::vtx a vector of shared_ptr<CTransaction> 2016-11-19 17:51:09 -08:00
Alex Morcos b2322e0fc6 Remove priority estimation 2016-11-07 13:22:34 +01:00
Pieter Wuille c3efb58622 Add feedelta to TxMempoolInfo 2016-10-30 23:12:09 -07:00
Pieter Wuille 4100499db4 Return shared_ptr<CTransaction> from mempool removes 2016-10-21 19:22:43 -07:00
Pieter Wuille 51f278329d Make removed and conflicted arguments optional to remove 2016-10-21 19:22:43 -07:00
Pieter Wuille f48211b700 Bypass removeRecursive in removeForReorg 2016-10-21 19:22:43 -07:00
Wladimir J. van der Laan 5eaaa83ac1 Kill insecure_random and associated global state
There are only a few uses of `insecure_random` outside the tests.
This PR replaces uses of insecure_random (and its accompanying global
state) in the core code with an FastRandomContext that is automatically
seeded on creation.

This is meant to be used for inner loops. The FastRandomContext
can be in the outer scope, or the class itself, then rand32() is used
inside the loop. Useful e.g. for pushing addresses in CNode or the fee
rounding, or randomization for coin selection.

As a context is created per purpose, thus it gets rid of
cross-thread unprotected shared usage of a single set of globals, this
should also get rid of the potential race conditions.

- I'd say TxMempool::check is not called enough to warrant using a special
  fast random context, this is switched to GetRand() (open for
  discussion...)

- The use of `insecure_rand` in ConnectThroughProxy has been replaced by
  an atomic integer counter. The only goal here is to have a different
  credentials pair for each connection to go on a different Tor circuit,
  it does not need to be random nor unpredictable.

- To avoid having a FastRandomContext on every CNode, the context is
  passed into PushAddress as appropriate.

There remains an insecure_random for test usage in `test_random.h`.
2016-10-17 13:08:35 +02:00
Pieter Wuille 6aa28abf53 Use cmpctblock type 2 for segwit-enabled transfer
Contains version negotiation logic by Matt Corallo and bugfixes by
Suhas Daftuar.
2016-10-04 19:10:41 +02:00
Pavel Janík 4731cab8fb Do not shadow variables 2016-09-27 09:25:15 +02:00
MarcoFalke fa6dc9f0e5 Remove unused variables 2016-08-25 14:59:38 +02:00
Pieter Wuille f798b891bc
Merge #8346: Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs
a6cc299 Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs (Jorge Timón)
2016-08-01 00:09:14 +02:00
Jorge Timón a6cc299541 Mempool: Use Consensus::CheckTxInputs direclty over main::CheckInputs 2016-07-29 00:48:20 +02:00
Pieter Wuille ab942c15bd Treat high-sigop transactions as larger rather than rejecting them 2016-07-19 12:31:49 +02:00
Suhas Daftuar 2c06bae39e Rename "block cost" to "block weight" 2016-07-18 13:28:26 -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
Matt Corallo 811902649d Provide a flat list of txid/terators to txn in CTxMemPool 2016-06-19 23:06:55 -07:00
Pieter Wuille 96806c39f4 Stop trimming when mapTx is empty 2016-06-19 01:34:57 -07:00
Pieter Wuille 288d85ddf2 Get rid of CTxMempool::lookup() entirely 2016-06-07 13:44:56 +02:00
Pieter Wuille 8d39d7a2cf Switch CTransaction storage in mempool to std::shared_ptr 2016-06-05 00:31:43 +02:00
Pieter Wuille a82f03393a
Merge #7997: replace mapNextTx with slimmer setSpends
9805f4a mapNextTx: use pointer as key, simplify value (Kaz Wesley)
2016-06-03 01:26:50 +02:00
Kaz Wesley 9805f4af7e mapNextTx: use pointer as key, simplify value
Saves about 10% of application memory usage once the mempool warms up. Since the
mempool is DynamicUsage-regulated, this will translate to a larger mempool in
the same amount of space.

Map value type: eliminate the vin index; no users of the map need to know which
input of the transaction is spending the prevout.

Map key type: replace the COutPoint with a pointer to a COutPoint. A COutPoint
is 36 bytes, but each COutPoint is accessible from the same map entry's value.
A trivial DereferencingComparator functor allows indirect map keys, but the
resulting syntax is misleading: `map.find(&outpoint)`. Implement an indirectmap
that acts as a wrapper to a map that uses a DereferencingComparator, supporting
a syntax that accurately reflect the container's semantics: inserts and
iterators use pointers since they store pointers and need them to remain
constant and dereferenceable, but lookup functions take const references.
2016-06-02 12:31:51 -07:00
Gregory Maxwell 7e908c7b82 Do not use mempool for GETDATA for tx accepted after the last mempool req.
The ability to GETDATA a transaction which has not (yet) been relayed
 is a privacy loss vector.

The use of the mempool for this was added as part of the mempool p2p
 message and is only needed to fetch transactions returned by it.
2016-05-25 18:05:58 +00:00
Wladimir J. van der Laan e29cfc48fc
Merge #7976: Remove obsolete reference to CValidationState from UpdateCoins.
c8b9248 Remove obsolete reference to CValidationState from UpdateCoins. (21E14)
2016-05-09 11:59:03 +02:00
Wladimir J. van der Laan 3b9a0bf41f
Merge #7840: Several performance and privacy improvements to inv/mempool handling
b559914 Move bloom and feerate filtering to just prior to tx sending. (Gregory Maxwell)
4578215 Return mempool queries in dependency order (Pieter Wuille)
ed70683 Handle mempool requests in send loop, subject to trickle (Pieter Wuille)
dc13dcd Split up and optimize transaction and block inv queues (Pieter Wuille)
f2d3ba7 Eliminate TX trickle bypass, sort TX invs for privacy and priority. (Gregory Maxwell)
2016-05-05 13:14:40 +02:00
21E14 c8b92486c4 Remove obsolete reference to CValidationState from UpdateCoins. 2016-04-30 15:14:22 -04:00
Daniel Kraft f7c4f79f07 [trivial] Add missing const qualifiers.
Add some const qualifiers to references that are not modified and should
be marked as const.
2016-04-30 19:25:00 +02:00
Pieter Wuille 4578215e7f Return mempool queries in dependency order 2016-04-21 00:33:56 +02:00
Gregory Maxwell f2d3ba7386 Eliminate TX trickle bypass, sort TX invs for privacy and priority.
Previously Bitcoin would send 1/4 of transactions out to all peers
 instantly.  This causes high overhead because it makes >80% of
 INVs size 1.  Doing so harms privacy, because it limits the
 amount of source obscurity a transaction can receive.

These randomized broadcasts also disobeyed transaction dependencies
 and required use of the orphan pool.  Because the orphan pool is
 so small this leads to poor propagation for dependent transactions.

When the bypass wasn't in effect, transactions were sent in the
 order they were received.  This avoided creating orphans but
 undermines privacy fairly significantly.

This commit:
 Eliminates the bypass. The bypass is replaced by halving the
  average delay for outbound peers.

 Sorts candidate transactions for INV by their topological
  depth then by their feerate (then hash); removing the
  information leakage and providing priority service to
  higher fee transactions.

 Limits the amount of transactions sent in a single INV to
  7tx/sec (and twice that for outbound); this limits the
  harm of low fee transaction floods, gives faster relay
  service to higher fee transactions. The 7 sounds lower
  than it really is because received advertisements need
  not be sent, and because the aggregate rate is multipled
  by the number of peers.
2016-04-20 10:26:37 +02:00
Alex Morcos 9e072a6e66 Implement "feefilter" P2P message.
The "feefilter" p2p message is used to inform other nodes of your mempool min fee which is the feerate that any new transaction must meet to be accepted to your mempool.  This will allow them to filter invs to you according to this feerate.
2016-03-21 10:46:25 -04:00