Commit Graph

231 Commits

Author SHA1 Message Date
Jon Layton 2a63c34936 Merge remote-tracking branch 'btc/master' into upstream-merge 2018-10-16 22:27:53 -05:00
MarcoFalke faa1a74942
tx pool: Use class methods to hide raw map iterator impl details 2018-09-07 13:04:02 -04:00
Wladimir J. van der Laan 5c24d3b98c
Merge #13249: Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations.
f34c8c466a Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations. (practicalswift)

Pull request description:

  Make objects in range declarations immutable by default.

  Rationale:
  * Immutable objects are easier to reason about.
  * Prevents accidental or hard-to-notice change of value.

Tree-SHA512: cad69d35f0cf8a938b848e65dd537c621d96fe3369be306b65ef0cd1baf6cc0a9f28bc230e1e383d810c555a6743d08cb6b2b0bd51856d4611f537a12e5abb8b
2018-09-04 15:50:08 +02:00
Wladimir J. van der Laan 888acefa5e
Merge #13792: tx pool: Avoid passing redundant hash into addUnchecked (scripted-diff)
fa587773e5 scripted-diff: Remove unused first argument to addUnchecked (MarcoFalke)
fe5c49766c tx pool: Use the entry's hash instead of the one passed to addUnchecked (MarcoFalke)
ddd395f968 Mark CTxMemPoolEntry members that should not be modified const (MarcoFalke)

Pull request description:

  Several years ago the transaction hash was not cached. For optimization the hash was instead passed into `addUnchecked` to avoid re-calculating it. See f77654a0e9

  Passing in the hash is now redundant and the argument can safely be removed.

Tree-SHA512: 0206b65c7a014295f67574120e8c5397bf1b1bd70c918ae1360ab093676f7f89a6f084fd2c7000a141baebfe63fe6f515559e38c4ac71810ba64f949f9c0467f
2018-08-29 16:30:58 +02:00
MarcoFalke fea4e9eca5
Merge #13767: Remove redundant assignments (dead stores)
dd777f3e12 Remove unused variable (practicalswift)
cdf4089457 Remove redundant assignments (dead stores) (practicalswift)

Pull request description:

  Remove redundant assignments (dead stores).

Tree-SHA512: e852059b22a161c34a0f18a6a6ed798e2b35e6d2b9f23c526af0ec33e01f6a5bb1fa5ada6671ba183d7b02393ff0d397be5aa4b4e2edbd5e604c9a76ac48d249
2018-08-27 13:39:46 -04:00
practicalswift f34c8c466a Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations. 2018-08-27 18:19:33 +02:00
practicalswift 9e2de6b9d0 Move cs_main locking annotations from .cpp to .h 2018-08-26 11:15:17 +02:00
practicalswift 9e0a514112 Add compile time checking for all cs_main runtime locking assertions 2018-08-26 00:25:28 +02:00
Wladimir J. van der Laan 78dae8cacc
Merge #13780: 0.17: Pre-branch maintenance
3fc20632a3 qt: Set BLOCK_CHAIN_SIZE = 220 (DrahtBot)
2b6a2f4a28 Regenerate manpages (DrahtBot)
eb7daf4d60 Update copyright headers to 2018 (DrahtBot)

Pull request description:

  Some trivial maintenance to avoid having to do it again after the 0.17 branch off.

  (The scripts to do this are in `./contrib/`)

Tree-SHA512: 16b2af45e0351b1c691c5311d48025dc6828079e98c2aa2e600dc5910ee8aa01858ca6c356538150dc46fe14c8819ed8ec8e4ec9a0f682b9950dd41bc50518fa
2018-08-08 13:55:27 +02:00
practicalswift cdf4089457 Remove redundant assignments (dead stores) 2018-08-02 14:30:53 +02:00
MarcoFalke fa587773e5
scripted-diff: Remove unused first argument to addUnchecked
-BEGIN VERIFY SCRIPT-
git grep -l addUnchecked | xargs sed --regexp-extended -i -e 's/addUnchecked\([^)][^,]+,\s*/addUnchecked(/g'
-END VERIFY SCRIPT-
2018-07-30 09:09:32 -04:00
MarcoFalke fe5c49766c tx pool: Use the entry's hash instead of the one passed to addUnchecked 2018-07-30 08:57:49 -04:00
MarcoFalke ddd395f968 Mark CTxMemPoolEntry members that should not be modified const 2018-07-30 08:57:49 -04:00
MarcoFalke fa5ed4f8d2
refactor: Avoid locking tx pool cs thrice 2018-07-29 08:04:06 -04:00
practicalswift d78a8dc3e8 Return void instead of bool for functions that cannot fail
* CBlockTreeDB::ReadReindexing(...)
* CChainState::ResetBlockFailureFlags(...)
* CTxMemPool::addUnchecked(...)
* CWallet::LoadDestData(...)
* CWallet::LoadKeyMetadata(...)
* CWallet::LoadScriptMetadata(...)
* CWallet::LoadToWallet(...)
* CWallet::SetHDChain(...)
* CWallet::SetHDSeed(...)
* RemoveLocal(...)
* SetMinVersion(...)
* StartHTTPServer(...)
* StartRPC(...)
* TorControlConnection::Disconnect(...)
2018-07-27 13:19:03 +02:00
DrahtBot eb7daf4d60 Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
João Barbosa 12dd101345 scripted-diff: Remove trailing whitespaces
-BEGIN VERIFY SCRIPT-

sed --in-place'' --regexp-extended 's/[[:space:]]+$//g' $(git grep -I --files-with-matches --extended-regexp '[[:space:]]+$' -- src test  ':!*.svg' ':!src/crypto/sha256_sse4*' ':!src/leveldb' ':!src/qt/locale' ':!src/secp256k1' ':!src/univalue')

-END VERIFY SCRIPT-
2018-07-24 20:46:23 +01:00
MarcoFalke 05714f96e4
Merge #11762: Avoid locking mutexes that are already held by the same thread
01a06d6686 Avoid locking mutexes that are already held by the same thread (practicalswift)

Pull request description:

  Avoid locking mutexes that are already held by the same thread. These are reentrant mutexes, but still no need to lock them more than once per thread :-)

Tree-SHA512: e2fb85882e8800892fd8e8170f3c13128d6acfeb14d7b69fb9555f2b7ad0884fb201cf945b8144ffaf6fb1253c28af7c8c6c435319a7ae30ca003f28aa645a98
2018-07-22 09:41:36 -04:00
practicalswift 01a06d6686 Avoid locking mutexes that are already held by the same thread 2018-07-21 19:46:04 +02:00
practicalswift 99be644966 Remove redundant unused variables 2018-07-18 09:39:31 +02:00
Cory Fields 466e16e0e8 cleanup: avoid hidden copies in range-for loops 2018-06-15 13:40:00 -04:00
Wladimir J. van der Laan 43ae5ee9e4
Merge #12634: [refactor] Make TransactionWithinChainLimit more flexible
f77e1d34fd test: Add MempoolAncestryTests (Karl-Johan Alm)
a08d76bcfe mempool: Calculate descendant maximum thoroughly (Karl-Johan Alm)
6d3568371e wallet: Switch to using ancestor/descendant limits (Karl-Johan Alm)
6888195b06 wallet: Strictly greater than for ancestor caps (Karl-Johan Alm)
322b12ac4e Remove deprecated TransactionWithinChainLimit (Karl-Johan Alm)
4784751547 Switch to GetTransactionAncestry() in OutputEligibleForSpending (Karl-Johan Alm)
475a385a80 Add GetTransactionAncestry to CTxMemPool for general purpose chain limit checking (Karl-Johan Alm)
46847d69d2 mempool: Fix max descendants check (Karl-Johan Alm)
b9ef21dd72 mempool: Add explicit max_descendants (Karl-Johan Alm)

Pull request description:

  Currently, `TransactionWithinChainLimit` is restricted to single-output use, and needs to be called every time for different limits. If it is replaced with a chain limit value calculator, that can be called once and reused, and is generally more flexible (see e.g. #12257).

  Update: this PR now corrects usage of max ancestors / max descendants, including calculating the correct max descendant value, as advertised for the two limits.

  ~~This change also makes `nMaxAncestors` signed, as the replacement method will return `-1` for "not in the mempool", which is different from "0", which means "no ancestors/descendants in mempool".~~

  ~~This is a subset of #12257.~~

Tree-SHA512: aa59c849360542362b3126c0e29d44d3d58f11898e277d38c034dc4b86a5b4500f77ac61767599ce878c876b5c446fec9c02699797eb2fa41e530ec863a00cf9
2018-06-11 16:25:46 +02:00
Karl-Johan Alm a08d76bcfe
mempool: Calculate descendant maximum thoroughly 2018-06-11 19:09:44 +09:00
Karl-Johan Alm 322b12ac4e
Remove deprecated TransactionWithinChainLimit 2018-06-11 19:04:56 +09:00
Karl-Johan Alm 475a385a80
Add GetTransactionAncestry to CTxMemPool for general purpose chain limit checking 2018-06-11 19:04:55 +09:00
Karl-Johan Alm 46847d69d2
mempool: Fix max descendants check
The chain limits check for max descendants would check the descendants of the transaction itself even though the description for -limitdescendantcount says 'any ancestor'. This commit corrects the descendant count check by finding the top parent transaction in the mempool and comparing against that.
2018-06-11 19:04:55 +09:00
Karl-Johan Alm b9ef21dd72
mempool: Add explicit max_descendants
TransactionWithinChainLimits would take a 'limit' and check it against ascendants and descendants. This is changed to take an explicit
max ancestors and max descendants value, and to test the corresponding value against its corresponding max.
2018-06-11 19:04:55 +09:00
practicalswift a426098572 Fix compiler warnings emitted when compiling under stock OpenBSD 6.3 2018-06-10 11:01:20 +02:00
jc 643ce1226c [validation] add Joinsplit related and zk specific checks 2018-06-04 07:22:35 -04:00
practicalswift 6bc5b7100b Fix missing locking in CTxMemPool::check(const CCoinsViewCache *pcoins)
* reading variable 'mapTx' requires holding mutex 'cs'
* reading variable 'mapNextTx' requires holding mutex 'cs'
* reading variable 'nCheckFrequency' requires holding mutex 'cs'
2018-05-05 16:50:58 +02:00
Wladimir J. van der Laan 18815b4bfb
Merge #11742: rpc: Add testmempoolaccept
b55555d rpc: Add testmempoolaccept (MarcoFalke)

Pull request description:

  To check if a single raw transaction makes it into the current transaction pool, one had to call `sendrawtransaction`. However, on success, this adds the transaction to the mempool with no easy way to undo.

  The call `testmempoolaccept` is introduced to provide a way to solely check the result without changing the mempool state.

Tree-SHA512: 5afd9311190135cee8fc1f229c7d39bf893f1028f29e28d34f70df820198ff97b4bf86b41cbbd6e6c36a5c30073cefa92d541c74a4939c7a2a6fa283dfd41b63
2018-04-02 16:02:33 +02:00
Roman Zeyde 1fdc7c41bb
Make CTxMemPool::isSpent() const 2018-03-25 11:32:41 +03:00
MarcoFalke b55555da3e
rpc: Add testmempoolaccept 2018-03-24 11:17:08 -04:00
Suhas Daftuar 8e617e3708 Remove unused mempool index 2018-01-09 08:59:21 -05:00
Akira Takizawa 595a7bab23 Increment MIT Licence copyright header year on files modified in 2017 2018-01-03 02:26:56 +09:00
MeshCollider 1a445343f6 scripted-diff: Replace #include "" with #include <> (ryanofsky)
-BEGIN VERIFY SCRIPT-
for f in \
  src/*.cpp \
  src/*.h \
  src/bench/*.cpp \
  src/bench/*.h \
  src/compat/*.cpp \
  src/compat/*.h \
  src/consensus/*.cpp \
  src/consensus/*.h \
  src/crypto/*.cpp \
  src/crypto/*.h \
  src/crypto/ctaes/*.h \
  src/policy/*.cpp \
  src/policy/*.h \
  src/primitives/*.cpp \
  src/primitives/*.h \
  src/qt/*.cpp \
  src/qt/*.h \
  src/qt/test/*.cpp \
  src/qt/test/*.h \
  src/rpc/*.cpp \
  src/rpc/*.h \
  src/script/*.cpp \
  src/script/*.h \
  src/support/*.cpp \
  src/support/*.h \
  src/support/allocators/*.h \
  src/test/*.cpp \
  src/test/*.h \
  src/wallet/*.cpp \
  src/wallet/*.h \
  src/wallet/test/*.cpp \
  src/wallet/test/*.h \
  src/zmq/*.cpp \
  src/zmq/*.h
do
  base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-
2017-11-16 08:23:01 +13:00
MarcoFalke 61fb80660f
Merge #11269: [Mempool] CTxMemPoolEntry::UpdateAncestorState: modifySiagOps param type
203a4aa31 Fix CTxMemPoolEntry::UpdateAncestorState: modifySigOps param type int -> int64_t (donaloconnor)

Pull request description:

  CTxMemPoolEntry::CTxMemPoolEntry's modifySigOps parameter is int while update_ancestor_state::modifySigOpsCost is int64_t. This issue was raised in #11165. It looks like the function paramaters were not changed in commit 72abd2c

  This will avoid unexpected truncation of int64_t -> int

Tree-SHA512: 314c703f217e104336456859066d18fb0d12c4f9f32835e17490a6f29eb05951184095039e4e57edacef8ad35dd75c6d97d9af656a52209dd0c3779b4ffa0914
2017-11-10 15:33:30 -05:00
Wladimir J. van der Laan 0e3a411351
Merge #8498: Near-Bugfix: Optimization: Minimize the number of times it is checked that no money...
4e955c5 Near-Bugfix: Reestablish consensus check removed in 8d7849b (Jorge Timón)
3e8c916 Introduce CheckInputsAndUpdateCoins static wrapper in txmempool.cpp (Jorge Timón)
832e074 Optimization: Minimize the number of times it is checked that no money is created (Jorge Timón)
3f0ee3e Proper indentation for CheckTxInputs and other minor fixes (Jorge Timón)

Pull request description:

  ...is created by individual transactions to 2 places (but call only once in each):

  - ConnectBlock ( before calculated fees per txs twice )
  - AcceptToMemoryPoolWorker ( before called CheckTxInputs 4 times and calculated
     fees per tx one extra time )

  Also call tx.GetValueOut() only once per call of CheckTxInputs (instead of 2)

  For more motivation:

  ~~https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1493~~
  https://github.com/jtimon/bitcoin/compare/0.13-consensus-inputs...jtimon:0.13-consensus-inputs-comments

  EDIT: partially replaces #6445

  Near-Bugfix as pointed out in https://github.com/bitcoin/bitcoin/pull/8498#discussion_r124346132

Tree-SHA512: c71188e7c7c2425c9170ed7b803896755a92fd22f43b136eedaa6e554106696f0b10271d0ef0d0127c1eaafbc31d12eb19143df4f1b6882feecedf6ef05ea346
2017-10-11 10:45:22 +02:00
Jorge Timón 3e8c91629e
Introduce CheckInputsAndUpdateCoins static wrapper in txmempool.cpp 2017-09-20 23:25:56 +02:00
Jorge Timón 832e0744cb
Optimization: Minimize the number of times it is checked that no money is created
by individual transactions to 2 places (but call only once in each):

- ConnectBlock ( before calculated fees per txs twice )
- AcceptToMemoryPoolWorker ( before called CheckTxInputs 4 times and calculated
   fees per tx one extra time )

Also call tx.GetValueOut() only once per call of CheckTxInputs (instead of 2)
2017-09-20 23:25:52 +02:00
Matt Corallo 1789e4675b Force explicit double -> int conversion for CFeeRate constructor
This resolves an issue where estimatesmartfee would return 999
sat/byte instead of 1000, due to floating point loss of precision

Thanks to sipa for suggesting is_integral.
2017-09-11 18:07:52 -04:00
donaloconnor 203a4aa31e Fix CTxMemPoolEntry::UpdateAncestorState: modifySigOps param type int -> int64_t 2017-09-07 19:13:01 +01:00
Dan Raviv b426e24678 Remove redundant explicitly defined copy ctors
CFeeRate and CTxMemPoolEntry have explicitly defined copy ctors which has the same functionality as the implicit default copy ctors which would have been generated otherwise.

Besides being redundant, it violates the rule of three (see https://en.wikipedia.org/wiki/Rule_of_three_(C%2B%2B_programming) ).
(Of course, the rule of three doesn't -really- cause a resource management issue here, but the reason for that is exactly that there is no need for an explicit copy ctor in the first place since no resources are being managed).
CFeeRate has an explicitly defined copy ctor which has the same functionality as the implicit default copy ctor which would h
ave been generated otherwise.
2017-08-28 01:29:48 +03:00
Wladimir J. van der Laan 6dbcc74a0e
Merge #10193: scripted-diff: Remove #include <boost/foreach.hpp>
b1268a1 clang-format: Delete ForEachMacros (Jorge Timón)
5995735 scripted-diff: Remove #include <boost/foreach.hpp> (Jorge Timón)
3eff827 scripted-diff: Remove BOOST_REVERSE_FOREACH (Jorge Timón)
33aed5b Fix const_reverse_iterator constructor (pass const ptr) (Jorge Timón)
300851e Introduce src/reverse_iterator.hpp and include it... (Jorge Timón)

Tree-SHA512: df3405328e9602d0a433ac134ba59a5c9a6202ef64188df2f94a59b2ce58dec7c988b25d0671c7937de516a96b2e6daeb9d04c82fa363b616ee4cf6e9cb0fac6
2017-07-04 18:05:18 +02:00
Pieter Wuille 21180ff734 Simplify return values of GetCoin/HaveCoin(InCache)
This removes the possibility for GetCoin/HaveCoin/HaveCoinInCache to return
true while the respective coin is spent. By doing it across all calls, some
extra checks can be eliminated.

coins_tests is modified to call HaveCoin sometimes before and sometimes
after AccessCoin. A further change is needed because the semantics for
GetCoin slightly changed, causing a pruned entry in the parent cache to not
be pulled into the child in FetchCoin.
2017-06-26 16:16:26 -07:00
Wladimir J. van der Laan f3f1e2e7d3
Merge #9544: [trivial] Add end of namespace comments. Improve consistency.
5a9b508 [trivial] Add end of namespace comments (practicalswift)

Tree-SHA512: 92b0fcae4d1d3f4da9e97569ae84ef2d6e09625a5815cd0e5f0eb6dd2ecba9852fa85c184c5ae9de5117050330ce995e9867b451fa8cd5512169025990541a2b
2017-06-26 13:40:26 +02:00
Wladimir J. van der Laan 6bef7ca8bc
Merge #10633: doc: Fix various typos
0a5a6b9 Fixed multiple typos (Dimitris Tsapakidis)

Tree-SHA512: 57748710bcbc03945b160db5e95bd686a2c64605f25d5e11d8ed9d0e1be3b3bf287a63588dc6eb33d0cef4ff17c765fda7c226d667a357acc539c8fcf2b9bb7e
2017-06-22 20:46:37 +02:00
Dimitris Tsapakidis 0a5a6b90bc Fixed multiple typos
A few "a->an" and "an->a".
"Shows, if the supplied default SOCKS5 proxy" -> "Shows if the supplied default SOCKS5 proxy". Change made on 3 occurrences.
"without fully understanding the ramification of a command" -> "without fully understanding the ramifications of a command".
Removed duplicate words such as "the the".
2017-06-22 19:18:10 +03:00
Jorge Timón 3eff827f89
scripted-diff: Remove BOOST_REVERSE_FOREACH
-BEGIN VERIFY SCRIPT-
sed -i 's/BOOST_REVERSE_FOREACH(\(.*\), \(.*\))/for (\1 : reverse_iterate(\2))/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ;
-END VERIFY SCRIPT-
2017-06-22 03:48:50 +02:00
Jorge Timón 300851ec16
Introduce src/reverse_iterator.hpp and include it...
...where it will be needed

Taken from https://gist.github.com/arvidsson/7231973 with small
modifications to fit the bitcoin core project
2017-06-22 03:48:42 +02:00