From 6742fad5c6c305ed458fd84913c7c242ed40cee4 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 22 Jul 2018 09:09:04 -0400 Subject: [PATCH 01/31] Merge #13722: trivial: Replace CPubKey::operator[] with CPubKey::vch where possible 6755569840 trivial: Replace CPubKey::operator[] with CPubKey::vch where possible (Nikolay Mitev) Pull request description: Use variable name instead of calling operator[] through &(*this)[0] Tree-SHA512: 7054ffda0fa33fb45d4d9f3b29698643f02fd1421d78d5197a0881f2c368dc410647fd2e1a6feb8048e30f8ab8bc2fa8749bf42b9ccbe42c30de8ff80ac45274 --- src/pubkey.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pubkey.cpp b/src/pubkey.cpp index ec3a10941ebf..f50246310681 100644 --- a/src/pubkey.cpp +++ b/src/pubkey.cpp @@ -171,7 +171,7 @@ bool CPubKey::Verify(const uint256 &hash, const std::vector& vchS return false; secp256k1_pubkey pubkey; secp256k1_ecdsa_signature sig; - if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size())) { + if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size())) { return false; } if (!ecdsa_signature_parse_der_lax(secp256k1_context_verify, &sig, vchSig.data(), vchSig.size())) { @@ -207,14 +207,14 @@ bool CPubKey::IsFullyValid() const { if (!IsValid()) return false; secp256k1_pubkey pubkey; - return secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size()); + return secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size()); } bool CPubKey::Decompress() { if (!IsValid()) return false; secp256k1_pubkey pubkey; - if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size())) { + if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size())) { return false; } unsigned char pub[PUBLIC_KEY_SIZE]; @@ -232,7 +232,7 @@ bool CPubKey::Derive(CPubKey& pubkeyChild, ChainCode &ccChild, unsigned int nChi BIP32Hash(cc, nChild, *begin(), begin()+1, out); memcpy(ccChild.begin(), out+32, 32); secp256k1_pubkey pubkey; - if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, &(*this)[0], size())) { + if (!secp256k1_ec_pubkey_parse(secp256k1_context_verify, &pubkey, vch, size())) { return false; } if (!secp256k1_ec_pubkey_tweak_add(secp256k1_context_verify, &pubkey, out)) { From cbfd59ad1f9c28977f8bca6bba71b1d25ea781e1 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 22 Jul 2018 09:41:34 -0400 Subject: [PATCH 02/31] 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 --- src/txmempool.cpp | 2 +- src/txmempool.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index f38290fb7779..49073b95ba26 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -793,7 +793,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem void CTxMemPool::removeConflicts(const CTransaction &tx) { // Remove transactions which depend on inputs of tx, recursively - LOCK(cs); + AssertLockHeld(cs); for (const CTxIn &txin : tx.vin) { auto it = mapNextTx.find(txin.prevout); if (it != mapNextTx.end()) { diff --git a/src/txmempool.h b/src/txmempool.h index 683bd388f737..c88b7ade349c 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -576,7 +576,7 @@ class CTxMemPool void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN); void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags); - void removeConflicts(const CTransaction &tx); + void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs); void removeProTxPubKeyConflicts(const CTransaction &tx, const CKeyID &keyId); void removeProTxPubKeyConflicts(const CTransaction &tx, const CBLSPublicKey &pubKey); void removeProTxCollateralConflicts(const CTransaction &tx, const COutPoint &collateralOutpoint); From a744c5668298894508d98ca6817cca85b0a63b5c Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 22 Jul 2018 11:11:56 -0400 Subject: [PATCH 03/31] Merge #13740: trivial: remove unneeded include 0454b56d8a trivial: remove unneeded include (Nikolay Mitev) Pull request description: Remove dead include Tree-SHA512: 66380fe25259d37a19f955142ad53da24d4927064a84249989f54bebc21d9d688236fb60979acc79f219b05692c4c73b3ebab0872b8d03ab2447b0b44a06c8ed --- src/dashd.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/dashd.cpp b/src/dashd.cpp index eb8abd21c35e..887b6ebaeab7 100644 --- a/src/dashd.cpp +++ b/src/dashd.cpp @@ -22,8 +22,6 @@ #include #include -#include - #include /* Introduction text for doxygen: */ From c49e50617687f7f4c4fd03caa57807756a9086b0 Mon Sep 17 00:00:00 2001 From: pasta Date: Tue, 28 Jul 2020 20:23:12 -0500 Subject: [PATCH 04/31] scripted-diff: Merge #13753: 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- Signed-off-by: pasta --- src/addrman.cpp | 2 +- src/addrman.h | 2 +- src/bloom.cpp | 2 +- src/bloom.h | 4 +- src/checkqueue.h | 4 +- src/clientversion.cpp | 4 +- src/coins.h | 4 +- src/consensus/tx_verify.h | 2 +- src/crypto/aes_helper.c | 6 +- src/crypto/cubehash.c | 6 +- src/crypto/echo.c | 6 +- src/crypto/groestl.c | 6 +- src/crypto/jh.c | 6 +- src/crypto/keccak.c | 8 +- src/crypto/luffa.c | 6 +- src/crypto/shavite.c | 8 +- src/crypto/simd.c | 6 +- src/crypto/skein.c | 6 +- src/crypto/sph_blake.h | 6 +- src/crypto/sph_bmw.h | 6 +- src/crypto/sph_cubehash.h | 6 +- src/crypto/sph_echo.h | 8 +- src/crypto/sph_groestl.h | 6 +- src/crypto/sph_jh.h | 6 +- src/crypto/sph_keccak.h | 6 +- src/crypto/sph_luffa.h | 10 +- src/crypto/sph_shavite.h | 12 +-- src/crypto/sph_simd.h | 6 +- src/crypto/sph_skein.h | 6 +- src/crypto/sph_types.h | 6 +- src/ctpl.h | 2 +- src/flat-database.h | 2 +- src/governance/governance.cpp | 4 +- src/httprpc.cpp | 2 +- src/immer/detail/arrays/no_capacity.hpp | 2 +- src/immer/detail/type_traits.hpp | 6 +- src/qt/bitcoingui.h | 2 +- src/qt/guiutil.h | 4 +- src/qt/macnotificationhandler.mm | 2 +- src/qt/modaloverlay.cpp | 2 +- src/qt/optionsdialog.h | 2 +- src/qt/optionsmodel.cpp | 2 +- src/qt/qvalidatedlineedit.h | 2 +- src/qt/sendcoinsentry.cpp | 2 +- src/qt/trafficgraphwidget.cpp | 2 +- src/reverse_iterator.h | 10 +- src/rpc/governance.cpp | 2 +- src/script/interpreter.cpp | 6 +- src/serialize.h | 10 +- src/streams.h | 2 +- src/test/README.md | 10 +- src/test/data/base58_keys_invalid.json | 98 ++++++++++---------- src/test/data/script_tests.json | 2 +- src/test/dbwrapper_tests.cpp | 12 +-- src/test/governance_validators_tests.cpp | 2 +- src/test/limitedmap_tests.cpp | 4 +- src/test/mempool_tests.cpp | 2 +- src/test/net_tests.cpp | 2 +- src/test/prevector_tests.cpp | 2 +- src/test/raii_event_tests.cpp | 8 +- src/test/script_tests.cpp | 2 +- src/test/serialize_tests.cpp | 4 +- src/test/streams_tests.cpp | 20 ++-- src/timedata.h | 2 +- src/txdb.cpp | 2 +- src/txmempool.cpp | 2 +- src/txmempool.h | 2 +- src/validation.h | 4 +- test/README.md | 4 +- test/functional/feature_bip68_sequence.py | 2 +- test/functional/feature_maxuploadtarget.py | 2 +- test/functional/feature_multikeysporks.py | 4 +- test/functional/feature_proxy.py | 6 +- test/functional/test_framework/blocktools.py | 2 +- test/functional/wallet_txn_clone.py | 6 +- 75 files changed, 223 insertions(+), 223 deletions(-) diff --git a/src/addrman.cpp b/src/addrman.cpp index 705cc1a08dd1..ac37931ddefa 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -371,7 +371,7 @@ CAddrInfo CAddrMan::Select_(bool newOnly) // Use a 50% chance for choosing between tried and new table entries. if (!newOnly && - (nTried > 0 && (nNew == 0 || RandomInt(2) == 0))) { + (nTried > 0 && (nNew == 0 || RandomInt(2) == 0))) { // use a tried node double fChanceFactor = 1.0; while (1) { diff --git a/src/addrman.h b/src/addrman.h index d9615d6ca91b..e41d99831384 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -183,7 +183,7 @@ class CAddrInfo : public CAddress #define ADDRMAN_SET_TRIED_COLLISION_SIZE 10 /** - * Stochastical (IP) address manager + * Stochastical (IP) address manager */ class CAddrMan { diff --git a/src/bloom.cpp b/src/bloom.cpp index 545c75cb938e..fbf03133885f 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -251,7 +251,7 @@ bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx) const CTxOut& txout = tx.vout[i]; // Match if the filter contains any arbitrary script data element in any scriptPubKey in tx // If this matches, also add the specific output that was matched. - // This means clients don't have to update the filter themselves when a new relevant tx + // This means clients don't have to update the filter themselves when a new relevant tx // is discovered in order to find spending transactions, which avoids round-tripping and race conditions. if(CheckScript(txout.scriptPubKey)) { fFound = true; diff --git a/src/bloom.h b/src/bloom.h index e82b593c0d8c..33c7d7227a38 100644 --- a/src/bloom.h +++ b/src/bloom.h @@ -35,9 +35,9 @@ enum bloomflags /** * BloomFilter is a probabilistic filter which SPV clients provide * so that we can filter the transactions we send them. - * + * * This allows for significantly more efficient transaction and block downloads. - * + * * Because bloom filters are probabilistic, a SPV node can increase the false- * positive rate, making us send it transactions which aren't actually its, * allowing clients to trade more bandwidth for more privacy by obfuscating which diff --git a/src/checkqueue.h b/src/checkqueue.h index 657912ff6aa6..1061796bc32f 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -16,7 +16,7 @@ template class CCheckQueueControl; -/** +/** * Queue for verifications that have to be performed. * The verifications are represented by a type T, which must provide an * operator(), returning a bool. @@ -163,7 +163,7 @@ class CCheckQueue }; -/** +/** * RAII-style controller object for a CCheckQueue that guarantees the passed * queue is finished before continuing. */ diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 7d4eaf5693e0..3dd174980bb6 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -81,8 +81,8 @@ std::string FormatFullVersion() return CLIENT_BUILD; } -/** - * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) +/** + * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) */ std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments) { diff --git a/src/coins.h b/src/coins.h index 45ff73b452f1..1885d6ae7ae7 100644 --- a/src/coins.h +++ b/src/coins.h @@ -203,7 +203,7 @@ class CCoinsViewCache : public CCoinsViewBacked protected: /** * Make mutable so that we can "fill the cache" even from Get-methods - * declared as "const". + * declared as "const". */ mutable uint256 hashBlock; mutable CCoinsMap cacheCoins; @@ -280,7 +280,7 @@ class CCoinsViewCache : public CCoinsViewBacked //! Calculate the size of the cache (in bytes) size_t DynamicMemoryUsage() const; - /** + /** * Amount of dash coming in to a transaction * Note that lightweight clients may not know anything besides the hash of previous transactions, * so may not be able to calculate this. diff --git a/src/consensus/tx_verify.h b/src/consensus/tx_verify.h index 49f33a10bddf..720491d8d0bb 100644 --- a/src/consensus/tx_verify.h +++ b/src/consensus/tx_verify.h @@ -41,7 +41,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx); /** * Count ECDSA signature operations in pay-to-script-hash inputs. - * + * * @param[in] mapInputs Map of previous transactions that have outputs we're spending * @return maximum number of sigops required to validate this transaction's inputs * @see CTransaction::FetchInputs diff --git a/src/crypto/aes_helper.c b/src/crypto/aes_helper.c index 75b7cc69d057..7a33a491b8ad 100644 --- a/src/crypto/aes_helper.c +++ b/src/crypto/aes_helper.c @@ -18,7 +18,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -26,10 +26,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/cubehash.c b/src/crypto/cubehash.c index 9322fe14e055..9e71cf388c0f 100644 --- a/src/crypto/cubehash.c +++ b/src/crypto/cubehash.c @@ -5,7 +5,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -13,10 +13,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/echo.c b/src/crypto/echo.c index 667e3f357afa..3adf47f45264 100644 --- a/src/crypto/echo.c +++ b/src/crypto/echo.c @@ -5,7 +5,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -13,10 +13,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/groestl.c b/src/crypto/groestl.c index 928bc41efab9..4bc792b72a1a 100644 --- a/src/crypto/groestl.c +++ b/src/crypto/groestl.c @@ -5,7 +5,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -13,10 +13,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/jh.c b/src/crypto/jh.c index 41487a5306be..11fbff2e4c2f 100644 --- a/src/crypto/jh.c +++ b/src/crypto/jh.c @@ -5,7 +5,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -13,10 +13,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/keccak.c b/src/crypto/keccak.c index cff9f87dae68..f9cebadfd29c 100644 --- a/src/crypto/keccak.c +++ b/src/crypto/keccak.c @@ -5,7 +5,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -13,10 +13,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -46,7 +46,7 @@ extern "C"{ * SPH_KECCAK_UNROLL number of loops to unroll (0/undef for full unroll) * SPH_KECCAK_INTERLEAVE use bit-interleaving (32-bit type only) * SPH_KECCAK_NOCOPY do not copy the state into local variables - * + * * If there is no usable 64-bit type, the code automatically switches * back to the 32-bit implementation. * diff --git a/src/crypto/luffa.c b/src/crypto/luffa.c index a761bea0ad4c..471651157fcf 100644 --- a/src/crypto/luffa.c +++ b/src/crypto/luffa.c @@ -5,7 +5,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -13,10 +13,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/shavite.c b/src/crypto/shavite.c index 85074f334008..efa1e4604596 100644 --- a/src/crypto/shavite.c +++ b/src/crypto/shavite.c @@ -5,7 +5,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -13,10 +13,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -99,7 +99,7 @@ static const sph_u32 IV512[] = { /* * This is the code needed to match the "reference implementation" as * published on Nov 23rd, 2009, instead of the published specification. - * + * #define AES_BIG_ENDIAN 1 #include "aes_helper.c" diff --git a/src/crypto/simd.c b/src/crypto/simd.c index 2c80626173ec..f7fb8a719343 100644 --- a/src/crypto/simd.c +++ b/src/crypto/simd.c @@ -5,7 +5,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -13,10 +13,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/skein.c b/src/crypto/skein.c index 7e47e352211b..949079f38b50 100644 --- a/src/crypto/skein.c +++ b/src/crypto/skein.c @@ -5,7 +5,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -13,10 +13,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/sph_blake.h b/src/crypto/sph_blake.h index 386642df77e2..0957417cf4b3 100644 --- a/src/crypto/sph_blake.h +++ b/src/crypto/sph_blake.h @@ -8,7 +8,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -16,10 +16,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/sph_bmw.h b/src/crypto/sph_bmw.h index 8941cd5c910e..f958f7719930 100644 --- a/src/crypto/sph_bmw.h +++ b/src/crypto/sph_bmw.h @@ -7,7 +7,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -15,10 +15,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/sph_cubehash.h b/src/crypto/sph_cubehash.h index 10d87a9275fc..5480052d6c8a 100644 --- a/src/crypto/sph_cubehash.h +++ b/src/crypto/sph_cubehash.h @@ -8,7 +8,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -16,10 +16,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/sph_echo.h b/src/crypto/sph_echo.h index 41975b005876..f298c495f410 100644 --- a/src/crypto/sph_echo.h +++ b/src/crypto/sph_echo.h @@ -7,7 +7,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -15,10 +15,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -312,7 +312,7 @@ void sph_echo512_close(void *cc, void *dst); */ void sph_echo512_addbits_and_close( void *cc, unsigned ub, unsigned n, void *dst); - + #ifdef __cplusplus } #endif diff --git a/src/crypto/sph_groestl.h b/src/crypto/sph_groestl.h index 78afda8fbcf4..21948cee924a 100644 --- a/src/crypto/sph_groestl.h +++ b/src/crypto/sph_groestl.h @@ -6,7 +6,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -14,10 +14,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/sph_jh.h b/src/crypto/sph_jh.h index 5ce37c6fde4d..f8812b448f92 100644 --- a/src/crypto/sph_jh.h +++ b/src/crypto/sph_jh.h @@ -7,7 +7,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -15,10 +15,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/sph_keccak.h b/src/crypto/sph_keccak.h index 716f18c6b9f6..1f37a79c215a 100644 --- a/src/crypto/sph_keccak.h +++ b/src/crypto/sph_keccak.h @@ -7,7 +7,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -15,10 +15,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/sph_luffa.h b/src/crypto/sph_luffa.h index 6738ccb40d82..5132477482e7 100644 --- a/src/crypto/sph_luffa.h +++ b/src/crypto/sph_luffa.h @@ -7,7 +7,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -15,10 +15,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -288,9 +288,9 @@ void sph_luffa512_close(void *cc, void *dst); */ void sph_luffa512_addbits_and_close( void *cc, unsigned ub, unsigned n, void *dst); - + #ifdef __cplusplus } #endif - + #endif diff --git a/src/crypto/sph_shavite.h b/src/crypto/sph_shavite.h index 58d3489a157b..9a76f971ccce 100644 --- a/src/crypto/sph_shavite.h +++ b/src/crypto/sph_shavite.h @@ -9,7 +9,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -17,10 +17,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. @@ -306,9 +306,9 @@ void sph_shavite512_close(void *cc, void *dst); */ void sph_shavite512_addbits_and_close( void *cc, unsigned ub, unsigned n, void *dst); - + #ifdef __cplusplus } -#endif - +#endif + #endif diff --git a/src/crypto/sph_simd.h b/src/crypto/sph_simd.h index 6f6f8d7bb584..27e106b03c42 100644 --- a/src/crypto/sph_simd.h +++ b/src/crypto/sph_simd.h @@ -7,7 +7,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -15,10 +15,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/sph_skein.h b/src/crypto/sph_skein.h index 29ff1cabe38f..d159a9d5c019 100644 --- a/src/crypto/sph_skein.h +++ b/src/crypto/sph_skein.h @@ -12,7 +12,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -20,10 +20,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/crypto/sph_types.h b/src/crypto/sph_types.h index 7295b0b37097..e74e4da8489d 100644 --- a/src/crypto/sph_types.h +++ b/src/crypto/sph_types.h @@ -18,7 +18,7 @@ * ==========================(LICENSE BEGIN)============================ * * Copyright (c) 2007-2010 Projet RNRT SAPHIR - * + * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -26,10 +26,10 @@ * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: - * + * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/src/ctpl.h b/src/ctpl.h index 64f650d3e83b..07c9a00be147 100644 --- a/src/ctpl.h +++ b/src/ctpl.h @@ -107,7 +107,7 @@ namespace ctpl { std::function * _f = nullptr; this->q.pop(_f); std::unique_ptr> func(_f); // at return, delete the function even if an exception occurred - + std::function f; if (_f) f = *_f; diff --git a/src/flat-database.h b/src/flat-database.h index 5b6db21356c6..ffc0b615599f 100644 --- a/src/flat-database.h +++ b/src/flat-database.h @@ -12,7 +12,7 @@ #include #include -/** +/** * Generic Dumping and Loading * --------------------------- */ diff --git a/src/governance/governance.cpp b/src/governance/governance.cpp index 03ecc12ef0d2..2e0eed93f7a0 100644 --- a/src/governance/governance.cpp +++ b/src/governance/governance.cpp @@ -573,14 +573,14 @@ bool CGovernanceManager::ConfirmInventoryRequest(const CInv& inv) return false; } break; - } + } case MSG_GOVERNANCE_OBJECT_VOTE: { if (cmapVoteToObject.HasKey(inv.hash)) { LogPrint(BCLog::GOBJECT, "CGovernanceManager::ConfirmInventoryRequest already have governance vote, returning false\n"); return false; } break; - } + } default: LogPrint(BCLog::GOBJECT, "CGovernanceManager::ConfirmInventoryRequest unknown type, returning false\n"); return false; diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 9ad0adee8519..106df8de8560 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -86,7 +86,7 @@ static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const Uni //This function checks username and password against -rpcauth //entries from config file. static bool multiUserAuthorized(std::string strUserPass) -{ +{ if (strUserPass.find(':') == std::string::npos) { return false; } diff --git a/src/immer/detail/arrays/no_capacity.hpp b/src/immer/detail/arrays/no_capacity.hpp index 33135d0cc37e..3a39b12cbdf2 100644 --- a/src/immer/detail/arrays/no_capacity.hpp +++ b/src/immer/detail/arrays/no_capacity.hpp @@ -93,7 +93,7 @@ struct no_capacity template + && compatible_sentinel_v, bool> = true> static no_capacity from_range(Iter first, Sent last) { diff --git a/src/immer/detail/type_traits.hpp b/src/immer/detail/type_traits.hpp index 7820e75d7a56..51371562666d 100644 --- a/src/immer/detail/type_traits.hpp +++ b/src/immer/detail/type_traits.hpp @@ -167,7 +167,7 @@ struct std_distance_supports : std::false_type {}; template struct std_distance_supports -(), std::declval()))>> : +(), std::declval()))>> : std::true_type {}; template @@ -180,11 +180,11 @@ template struct std_uninitialized_copy_supports (), std::declval(), - std::declval()))>> : + std::declval()))>> : std::true_type {}; template -constexpr bool std_uninitialized_copy_supports_v = +constexpr bool std_uninitialized_copy_supports_v = std_uninitialized_copy_supports::value; } diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 3ecfb732fea7..fbbaa0f71cf7 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -307,7 +307,7 @@ private Q_SLOTS: /** Show progress dialog e.g. for verifychain */ void showProgress(const QString &title, int nProgress); - + /** When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly. */ void setTrayIconVisible(bool); diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 1784f77f8a1f..c0ed04d196f3 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -171,9 +171,9 @@ namespace GUIUtil // Open debug.log void openDebugLogfile(); - + // Open dash.conf - void openConfigfile(); + void openConfigfile(); // Browse backup folder void showBackups(); diff --git a/src/qt/macnotificationhandler.mm b/src/qt/macnotificationhandler.mm index fd15586630d1..769282305a55 100644 --- a/src/qt/macnotificationhandler.mm +++ b/src/qt/macnotificationhandler.mm @@ -64,7 +64,7 @@ - (NSString *)__bundleIdentifier static MacNotificationHandler *s_instance = nullptr; if (!s_instance) { s_instance = new MacNotificationHandler(); - + Class aPossibleClass = objc_getClass("NSBundle"); if (aPossibleClass) { // change NSBundle -bundleIdentifier method to return a correct bundle identifier diff --git a/src/qt/modaloverlay.cpp b/src/qt/modaloverlay.cpp index 0aa60d56eb59..e5b31491ee4a 100644 --- a/src/qt/modaloverlay.cpp +++ b/src/qt/modaloverlay.cpp @@ -114,7 +114,7 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri ui->progressIncreasePerH->setText(QString::number(progressPerHour * 100, 'f', 2)+"%"); // show expected remaining time - if(remainingMSecs >= 0) { + if(remainingMSecs >= 0) { ui->expectedTimeLeft->setText(GUIUtil::formatNiceTimeOffset(remainingMSecs / 1000.0)); } else { ui->expectedTimeLeft->setText(QObject::tr("unknown")); diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index cc0bfdb00b93..6ca5d246e569 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -53,7 +53,7 @@ private Q_SLOTS: void on_resetButton_clicked(); void on_okButton_clicked(); void on_cancelButton_clicked(); - + void on_hideTrayIcon_stateChanged(int fState); void showRestartWarning(bool fPersistent = false); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 89e39837ddd3..6acea84c5235 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -64,7 +64,7 @@ void OptionsModel::Init(bool resetSettings) settings.setValue("fHideTrayIcon", false); fHideTrayIcon = settings.value("fHideTrayIcon").toBool(); Q_EMIT hideTrayIconChanged(fHideTrayIcon); - + if (!settings.contains("fMinimizeToTray")) settings.setValue("fMinimizeToTray", false); fMinimizeToTray = settings.value("fMinimizeToTray").toBool() && !fHideTrayIcon; diff --git a/src/qt/qvalidatedlineedit.h b/src/qt/qvalidatedlineedit.h index 66734cc9d4f9..9ad9e66ae25c 100644 --- a/src/qt/qvalidatedlineedit.h +++ b/src/qt/qvalidatedlineedit.h @@ -34,7 +34,7 @@ public Q_SLOTS: Q_SIGNALS: void validationDidChange(QValidatedLineEdit *validatedLineEdit); - + private Q_SLOTS: void markValid(); void checkValidity(); diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 3bef035d12b4..27596601c707 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -32,7 +32,7 @@ SendCoinsEntry::SendCoinsEntry(QWidget* parent) : ui->deleteButton->setIcon(QIcon(":/icons/remove")); ui->deleteButton_is->setIcon(QIcon(":/icons/remove")); ui->deleteButton_s->setIcon(QIcon(":/icons/remove")); - + // normal dash address field GUIUtil::setupAddressWidget(ui->payTo, this, true); // just a label for displaying dash address(es) diff --git a/src/qt/trafficgraphwidget.cpp b/src/qt/trafficgraphwidget.cpp index c371e5800a0f..a89d353e2a2a 100644 --- a/src/qt/trafficgraphwidget.cpp +++ b/src/qt/trafficgraphwidget.cpp @@ -99,7 +99,7 @@ void TrafficGraphWidget::paintEvent(QPaintEvent *) const QString units = tr("KB/s"); const float yMarginText = 2.0; - + // draw lines painter.setPen(axisCol); for(float y = val; y < fMax; y += val) { diff --git a/src/reverse_iterator.h b/src/reverse_iterator.h index ab467f07c98d..729d8c11ccfe 100644 --- a/src/reverse_iterator.h +++ b/src/reverse_iterator.h @@ -5,7 +5,7 @@ /** * Template used for reverse iteration in C++11 range-based for loops. - * + * * std::vector v = {1, 2, 3, 4, 5}; * for (auto x : reverse_iterate(v)) * std::cout << x << " "; @@ -15,21 +15,21 @@ template class reverse_range { T &m_x; - + public: explicit reverse_range(T &x) : m_x(x) {} - + auto begin() const -> decltype(this->m_x.rbegin()) { return m_x.rbegin(); } - + auto end() const -> decltype(this->m_x.rend()) { return m_x.rend(); } }; - + template reverse_range reverse_iterate(T &x) { diff --git a/src/rpc/governance.cpp b/src/rpc/governance.cpp index d6c925af8cfb..833a77a82f91 100644 --- a/src/rpc/governance.cpp +++ b/src/rpc/governance.cpp @@ -138,7 +138,7 @@ void gobject_prepare_help(CWallet* const pwallet) UniValue gobject_prepare(const JSONRPCRequest& request) { CWallet* const pwallet = GetWalletForJSONRPCRequest(request); - if (request.fHelp || (request.params.size() != 5 && request.params.size() != 6 && request.params.size() != 8)) + if (request.fHelp || (request.params.size() != 5 && request.params.size() != 6 && request.params.size() != 8)) gobject_prepare_help(pwallet); if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index f696ef27cea7..8a7b75f909a3 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -87,7 +87,7 @@ bool static IsCompressedOrUncompressedPubKey(const valtype &vchPubKey) { * Where R and S are not negative (their first byte has its highest bit not set), and not * excessively padded (do not start with a 0 byte, unless an otherwise negative number follows, * in which case a single 0 byte is necessary and even required). - * + * * See https://bitcointalk.org/index.php?topic=8392.msg127623#msg127623 * * This function is consensus-critical since BIP66. @@ -127,7 +127,7 @@ bool static IsValidSignatureEncoding(const std::vector &sig) { // Verify that the length of the signature matches the sum of the length // of the elements. if ((size_t)(lenR + lenS + 7) != sig.size()) return false; - + // Check whether the R element is an integer. if (sig[2] != 0x02) return false; @@ -843,7 +843,7 @@ bool EvalScript(std::vector >& stack, const CScript& popstack(stack); stack.push_back(vchHash); } - break; + break; case OP_CODESEPARATOR: { diff --git a/src/serialize.h b/src/serialize.h index 26bc5b319bbf..0b4835af1f36 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -170,11 +170,11 @@ template const X& ReadWriteAsHelper(const X& x) { return x; } #define READWRITEMANY(...) (::SerReadWriteMany(s, ser_action, __VA_ARGS__)) #define READWRITEAS(type, obj) (::SerReadWriteMany(s, ser_action, ReadWriteAsHelper(obj))) -/** +/** * Implement three methods for serializable objects. These are actually wrappers over * "SerializationOp" template, which implements the body of each class' serialization * code. Adding "ADD_SERIALIZE_METHODS" in the body of the class causes these wrappers to be - * added as members. + * added as members. */ #define ADD_SERIALIZE_METHODS \ template \ @@ -304,16 +304,16 @@ uint64_t ReadCompactSize(Stream& is) * sure the encoding is one-to-one, one is subtracted from all but the last digit. * Thus, the byte sequence a[] with length len, where all but the last byte * has bit 128 set, encodes the number: - * + * * (a[len-1] & 0x7F) + sum(i=1..len-1, 128^i*((a[len-i-1] & 0x7F)+1)) - * + * * Properties: * * Very small (0-127: 1 byte, 128-16511: 2 bytes, 16512-2113663: 3 bytes) * * Every integer has exactly one encoding * * Encoding does not depend on size of original integer type * * No redundancy: every (infinite) byte sequence corresponds to a list * of encoded integers. - * + * * 0: [0x00] 256: [0x81 0x00] * 1: [0x01] 16383: [0xFE 0x7F] * 127: [0x7F] 16384: [0xFF 0x00] diff --git a/src/streams.h b/src/streams.h index 446bb0ec873a..69c9747f82ce 100644 --- a/src/streams.h +++ b/src/streams.h @@ -580,7 +580,7 @@ class CAutoFile const int nType; const int nVersion; - FILE* file; + FILE* file; public: CAutoFile(FILE* filenew, int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) diff --git a/src/test/README.md b/src/test/README.md index f279f25e6c27..ce215b56a332 100644 --- a/src/test/README.md +++ b/src/test/README.md @@ -43,11 +43,11 @@ unit tests as possible). The build system is setup to compile an executable called `test_dash` that runs all of the unit tests. The main source file is called test_dash.cpp. To add a new unit test file to our test suite you need -to add the file to `src/Makefile.test.include`. The pattern is to create -one test file for each class or source file for which you want to create -unit tests. The file naming convention is `_tests.cpp` -and such files should wrap their tests in a test suite -called `_tests`. For an example of this pattern, +to add the file to `src/Makefile.test.include`. The pattern is to create +one test file for each class or source file for which you want to create +unit tests. The file naming convention is `_tests.cpp` +and such files should wrap their tests in a test suite +called `_tests`. For an example of this pattern, examine `uint256_tests.cpp`. For further reading, I found the following website to be helpful in diff --git a/src/test/data/base58_keys_invalid.json b/src/test/data/base58_keys_invalid.json index e04a1106cdb3..500f11cf8ba2 100644 --- a/src/test/data/base58_keys_invalid.json +++ b/src/test/data/base58_keys_invalid.json @@ -1,151 +1,151 @@ [ [ "" - ], + ], [ "x" - ], + ], [ "8212abd8rrzcJmBG9n7VmSpaMfPRXhyHkQtNXFAMPCUqQTF9Kmsk5VF3b81x1qt9tRsQ2REKQ6j" - ], + ], [ "5CPYCiRk7LjiYQc45GQTgqNjYw5tWeCZd1NWvevf6SQfJvDm9vK" - ], + ], [ "2UB8YkLAsoJWEsw6daxKvo5W4NVjLSB8Bsko6UCWMrLnoFKgETXdKa2XcvoWdjeeLbKqRcaWwGvq" - ], + ], [ "9sW9vnbLHfdcqhU2n5bLAFUksSgCiMBVmdn6Pae3iTYo49aSqZeS" - ], + ], [ "2FeLT8g7q25cvVmUjQnXvTt7rpWDtRjq2oi9F9zj3rLWxNKSoKcPLob6TEB2RAeumauRzj5Em5uL" - ], + ], [ "7Vbg3REusN6tagLwHkz4P71VZtp8oTTtETmaTFJfypdX4J7vBmp6CMzWpNV3RUdv7TST2nigUz2oU" - ], + ], [ "7obK6DhucEuvCinKLAUNYMPXNEFCHcErXa61wi2sMi66owinM4E8YD4rkgHVvxpv3ZGxFNXUyCA" - ], + ], [ "3FPe28dxJDhEmkAbGVgsT5XFpBwyM48FK4veyiQVgAKvQLTea2U" - ], + ], [ "2ULU3PB7u3rxfUXKVb5mZ4ijXbj85LN99s7zess5XPZEX1DJvanHoY6dLvYnkLtQDWQ2qCq1GWSA" - ], + ], [ "7VBmPmJMUFwYhgktivvqBZcPzqdKPy4S4RRTACdwTiV6wNpkpXEmp3tvDhzkqdyFhXdJ88Q5T9mka" - ], + ], [ "2Zx1G5CMrEC4Y8EBVxvepmM1aiXv7CenqUR1dZBxC4PFUv9jAAm8TUxD4SKC2ArwKawA3Y4rhC2v" - ], + ], [ "yaWZmeqWr5Mea62ECoMPzVkXxHGDF6LtCfc" - ], + ], [ "7VPs36WGcbdFsCBsMXExgBoMeme8T7eJ4g3UMqQrhrA2Lyys5vi3dgH43nbz1AV4YFz3ZRKLdFsnu" - ], + ], [ "2DS5LTr3AgrTGoBD3nqXWDPtCMd98mkop4wxaVfRWwPFYvmpXP5hG5bKzVVzvsKzP89THiiRd3Pr" - ], + ], [ "DeRXybcZve86XXanvmLG9XwFadEh8GjH2Y" - ], + ], [ "7pejnWw1qHjCfAmzXoStxFZYMJ6hu1gixoJD8irtyrki5A9PHDWV798YMaH3teBadyatmdV2YvT" - ], + ], [ "4Yi2yBokcAj6acLZhiNwmmA1DSzuKnz8vfJ1FHE2yJLSTab6FUi" - ], + ], [ "2U65F6JTxDP2YJ5XV6FiYxpWMCjwCRbEN9ygEXZ3KkbLUMjSbvKbPyCMLf6ke9kMPg9CLQcJ7aN9" - ], + ], [ "7UgNNEAfdinxDG38ByGmVwbRJp7b4q8BEznm2GXbSJFVSTyS3jiByNLU8ckDprYkqvi5bcf61SUkw" - ], + ], [ "6wzMif8TRzrnyQYAbRZShWcZo3dqKYkBVpi2JR15DFMCLzxAkVTUpsuwdTUWnkx9j1kGDyukh1Go" - ], + ], [ "6YKZfgYJSh9ivzFX1oNqTiiWwhCGrZbnDCigU6N5oyiBeVUKio5ww3Zu4N6K6NHsqaR8djSh9dLfX" - ], + ], [ "92sWK7QesAPWS12srisHmc9q8Fz8Z5ERJcAaVwkjVKENJmL45bBM" - ], + ], [ "2Ua8heeYCTTsr5qgi7vorTpDAWVRGRAJKZ7" - ], + ], [ "2A6BvvmZ86GG7TRwXyCaCvhiM5FsVFvs42x" - ], + ], [ "R5uiBq2rzVGhxDsq3MeGU3QKeZz8wLywaB" - ], + ], [ "279AcBMDWxh5hnfEm5kptwnfn7rEWschhdxkEzLYzEj2K3wSHfEaqV2moec6wP5w3jVy5cFhoVXk" - ], + ], [ "7VMRsPVwoj7vZATKQGj2yVEX55f2qNKDxNiw7YNJv1zjfFFzyWR1WS67tefp7fV1MpXrUhNh86e8Y" - ], + ], [ "2V95nNKY2YtDuxyQ6K4unrkKQTmhRpVcUiXdYKxfJSrQG22tHmNojaXc5gUy1ZY6cAByCBMZZsas" - ], + ], [ "2D79xmaAZxTf2fMRsTGgkNfMrUErj5CqXNY" - ], + ], [ "7nwQ595A7nXdySFQ2pHx71xJsVLhJAeoj68MSSDHhPMxhBQDynYa5KDXEfhW8jZdZeAkraFMy7b" - ], + ], [ "7rLMRn8VSmsGV1QUfZf5xro5gejEST4fuXpokKSvqPPX8wmMabe" - ], + ], [ "J3JtSQiZ46yXNEXpuzjmA7R366BBKMD7id5PZ7cX3V5K5DcP3M9L" - ], + ], [ "21WFTGZEpLyGHqVmb7a5skPDN5oD7ocR7r6t2osiqDQf6Xa84mkh3odE1cbZ2ocTFMZbHSrLXyJr" - ], + ], [ "7oShSMyZqoK69tWvUEwLBGWHzZFvuVV5SESa4rBe3TmNzfJXBJBP528XMMMiQxoX7fSAzhF2bYL" - ], + ], [ "KqarYQ2A4jimBefL5i1SRpbz8xn3y3P2UX1tafCgf48LXTDrKCcf" - ], + ], [ "gSzq4StFrs2i8gTZ84pw9x68aPQ3XFe5b3oK669aSd68yfFmxH" - ], + ], [ "7UdhV95GSa6CY2XjVYfrqrwwyCScmeksu6TCqcpRSeeMbEmDydSMB4E2CCHFZ4gLoXXB7z1iWsGws" - ], + ], [ "2msvzdVt86YVXqkWQBJG136u11REi8cXpn1" - ], + ], [ "ryMiy7TSV4LfnJWeXdvT9sZgiLj6ebNg2ac6eLdSAE1N66u1SHwASam7njVBMLYuzr8ntySNoUT" - ], + ], [ "6YnxQpwLv2PWVRw8cf5JVm1HmLP3UrQyyUMufDLzuYRg1vbut9he27XAzmLp7m4WxTz7vsriEwQcX" - ], + ], [ "92g6icyL3H2XCqLiukqquX15fwBR5kFE744En5cd3X61cpANrjqY" - ], + ], [ "2XCxe9EpeGVMkfZqFgtAKmU2GNBpwnmukDs" - ], + ], [ "6YdrW3VDyE96kBFvKghrZ6fkwVngGgJybFnrFHXfexSorcQPxzbHLqNWTSMZHkrdmeQ2ZsLCnFhe3" - ], + ], [ "PsfkAxuhDQKQCwvuwfiVo1vdcYc4fLLr7oZ98XrMyp7SAsLAyQorF" - ], + ], [ "2k2HeazZ1apwsF3VQHHCbooreJ2anjumTTU" - ], + ], [ "724Fw3TFoSoXsZK77FC8NfrgN2scVC8pq7SntoNgCY3oosmEZHJLcrZVKiFagFm5TLcbfuhKm8ewM" - ], + ], [ "7VrbcSqCJndcp187BT68T5eLXF3TQaH7vN57nAhNhbCyUjtvuX6rtDJYNLmXhPTSrE5dkWqifSsRG" - ], + ], [ "8SHxzARcUKM6NdLyM4JDSMoSkA99SgZ3zP85JAEaiipxnUXuMBtV7dtx6cN1wP5df4bQ8G6MsMv" ] diff --git a/src/test/data/script_tests.json b/src/test/data/script_tests.json index 0ebd66c55857..a63a25881b85 100644 --- a/src/test/data/script_tests.json +++ b/src/test/data/script_tests.json @@ -712,7 +712,7 @@ ["0x17 0x3014020002107777777777777777777777777777777701", "0 CHECKSIG NOT", "", "OK", "Zero-length R is correctly encoded"], ["0x17 0x3014021077777777777777777777777777777777020001", "0 CHECKSIG NOT", "", "OK", "Zero-length S is correctly encoded for DERSIG"], ["0x27 0x302402107777777777777777777777777777777702108777777777777777777777777777777701", "0 CHECKSIG NOT", "", "OK", "Negative S is correctly encoded"], - + ["2147483648", "CHECKSEQUENCEVERIFY", "CHECKSEQUENCEVERIFY", "OK", "CSV passes if stack top bit 1 << 31 is set"], ["", "DEPTH", "P2SH,STRICTENC", "EVAL_FALSE", "Test the test: we should have an empty stack after scriptSig evaluation"], diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp index 251648a46d22..753e2fb45a7e 100644 --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -20,9 +20,9 @@ bool is_null_key(const std::vector& key) { return isnull; } - + BOOST_FIXTURE_TEST_SUITE(dbwrapper_tests, BasicTestingSetup) - + BOOST_AUTO_TEST_CASE(dbwrapper) { // Perform tests both obfuscated and non-obfuscated. @@ -142,7 +142,7 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate) // Now, set up another wrapper that wants to obfuscate the same directory CDBWrapper odbw(ph, (1 << 10), false, false, true); - // Check that the key/val we wrote with unobfuscated wrapper exists and + // Check that the key/val we wrote with unobfuscated wrapper exists and // is readable. uint256 res2; BOOST_CHECK(odbw.Read(key, res2)); @@ -153,13 +153,13 @@ BOOST_AUTO_TEST_CASE(existing_data_no_obfuscate) uint256 in2 = InsecureRand256(); uint256 res3; - + // Check that we can write successfully BOOST_CHECK(odbw.Write(key, in2)); BOOST_CHECK(odbw.Read(key, res3)); BOOST_CHECK_EQUAL(res3.ToString(), in2.ToString()); } - + // Ensure that we start obfuscating during a reindex. BOOST_AUTO_TEST_CASE(existing_data_reindex) { @@ -190,7 +190,7 @@ BOOST_AUTO_TEST_CASE(existing_data_reindex) uint256 in2 = InsecureRand256(); uint256 res3; - + // Check that we can write successfully BOOST_CHECK(odbw.Write(key, in2)); BOOST_CHECK(odbw.Read(key, res3)); diff --git a/src/test/governance_validators_tests.cpp b/src/test/governance_validators_tests.cpp index 7dca3252c8fe..7338f739de5e 100644 --- a/src/test/governance_validators_tests.cpp +++ b/src/test/governance_validators_tests.cpp @@ -28,7 +28,7 @@ std::string CreateEncodedProposalObject(const UniValue& objJSON) UniValue outerArray(UniValue::VARR); outerArray.push_back(innerArray); - + std::string strData = outerArray.write(); std::string strHex = HexStr(strData); return strHex; diff --git a/src/test/limitedmap_tests.cpp b/src/test/limitedmap_tests.cpp index 05feee3fa0d5..52e12abf0544 100644 --- a/src/test/limitedmap_tests.cpp +++ b/src/test/limitedmap_tests.cpp @@ -50,10 +50,10 @@ BOOST_AUTO_TEST_CASE(limitedmap_test) // use the iterator to check for the expected key and value //BOOST_CHECK(it->first == i); //BOOST_CHECK(it->second == i + 1); - + // use find to check for the value BOOST_CHECK(map.find(i)->second == i + 1); - + // update and recheck auto jt = map.find(i); map.update(jt, i + 2); diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index 57db8df1523c..7babf45cd210 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -65,7 +65,7 @@ BOOST_AUTO_TEST_CASE(MempoolRemoveTest) poolSize = testPool.size(); testPool.removeRecursive(txParent); BOOST_CHECK_EQUAL(testPool.size(), poolSize - 1); - + // Parent, children, grandchildren: testPool.addUnchecked(txParent.GetHash(), entry.FromTx(txParent)); for (int i = 0; i < 3; i++) diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index db740a07c218..ccf765149272 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -171,7 +171,7 @@ BOOST_AUTO_TEST_CASE(cnode_simple_test) in_addr ipv4Addr; ipv4Addr.s_addr = 0xa0b0c001; - + CAddress addr = CAddress(CService(ipv4Addr, 7777), NODE_NETWORK); std::string pszDest; bool fInboundIn = false; diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index 6eeb537ae4f3..b16f90779dd7 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -36,7 +36,7 @@ class prevector_tester { { local_check(a == b); } - void local_check(bool b) + void local_check(bool b) { passed &= b; } diff --git a/src/test/raii_event_tests.cpp b/src/test/raii_event_tests.cpp index 0db67dac64bf..6a6055fb5271 100644 --- a/src/test/raii_event_tests.cpp +++ b/src/test/raii_event_tests.cpp @@ -41,7 +41,7 @@ BOOST_FIXTURE_TEST_SUITE(raii_event_tests, BasicTestingSetup) BOOST_AUTO_TEST_CASE(raii_event_creation) { event_set_mem_functions(tag_malloc, realloc, tag_free); - + void* base_ptr = nullptr; { auto base = obtain_event_base(); @@ -49,7 +49,7 @@ BOOST_AUTO_TEST_CASE(raii_event_creation) BOOST_CHECK(tags[base_ptr] == 1); } BOOST_CHECK(tags[base_ptr] == 0); - + void* event_ptr = nullptr; { auto base = obtain_event_base(); @@ -63,14 +63,14 @@ BOOST_AUTO_TEST_CASE(raii_event_creation) } BOOST_CHECK(tags[base_ptr] == 0); BOOST_CHECK(tags[event_ptr] == 0); - + event_set_mem_functions(malloc, realloc, free); } BOOST_AUTO_TEST_CASE(raii_event_order) { event_set_mem_functions(tag_malloc, realloc, tag_free); - + void* base_ptr = nullptr; void* event_ptr = nullptr; { diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index a38404c7d2f4..8bd829f5ffc3 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -439,7 +439,7 @@ BOOST_AUTO_TEST_CASE(script_build) tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C) << OP_CHECKSIG, "P2SH(P2PK), bad redeemscript", SCRIPT_VERIFY_P2SH, true ).PushSig(keys.key0).PushRedeem().DamagePush(10).ScriptError(SCRIPT_ERR_EVAL_FALSE)); - + tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.pubkey0.GetID()) << OP_EQUALVERIFY << OP_CHECKSIG, "P2SH(P2PKH)", SCRIPT_VERIFY_P2SH, true ).PushSig(keys.key0).Push(keys.pubkey0).PushRedeem()); diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index 351ea2a26523..ccd06428a301 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -248,8 +248,8 @@ static bool isCanonicalException(const std::ios_base::failure& ex) // The string returned by what() can be different for different platforms. // Instead of directly comparing the ex.what() with an expected string, - // create an instance of exception to see if ex.what() matches - // the expected explanatory string returned by the exception instance. + // create an instance of exception to see if ex.what() matches + // the expected explanatory string returned by the exception instance. return strcmp(expectedException.what(), ex.what()) == 0; } diff --git a/src/test/streams_tests.cpp b/src/test/streams_tests.cpp index 42828556d1c1..f071c116095a 100644 --- a/src/test/streams_tests.cpp +++ b/src/test/streams_tests.cpp @@ -156,19 +156,19 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) CDataStream ds(in, 0, 0); // Degenerate case - + key.push_back('\x00'); key.push_back('\x00'); ds.Xor(key); BOOST_CHECK_EQUAL( - std::string(expected_xor.begin(), expected_xor.end()), + std::string(expected_xor.begin(), expected_xor.end()), std::string(ds.begin(), ds.end())); in.push_back('\x0f'); in.push_back('\xf0'); expected_xor.push_back('\xf0'); expected_xor.push_back('\x0f'); - + // Single character key ds.clear(); @@ -178,9 +178,9 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) key.push_back('\xff'); ds.Xor(key); BOOST_CHECK_EQUAL( - std::string(expected_xor.begin(), expected_xor.end()), - std::string(ds.begin(), ds.end())); - + std::string(expected_xor.begin(), expected_xor.end()), + std::string(ds.begin(), ds.end())); + // Multi character key in.clear(); @@ -189,7 +189,7 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) in.push_back('\x0f'); expected_xor.push_back('\x0f'); expected_xor.push_back('\x00'); - + ds.clear(); ds.insert(ds.begin(), in.begin(), in.end()); @@ -199,8 +199,8 @@ BOOST_AUTO_TEST_CASE(streams_serializedata_xor) ds.Xor(key); BOOST_CHECK_EQUAL( - std::string(expected_xor.begin(), expected_xor.end()), - std::string(ds.begin(), ds.end())); -} + std::string(expected_xor.begin(), expected_xor.end()), + std::string(ds.begin(), ds.end())); +} BOOST_AUTO_TEST_SUITE_END() diff --git a/src/timedata.h b/src/timedata.h index 111b9e0ebd01..bc281942a22f 100644 --- a/src/timedata.h +++ b/src/timedata.h @@ -14,7 +14,7 @@ static const int64_t DEFAULT_MAX_TIME_ADJUSTMENT = 70 * 60; class CNetAddr; -/** +/** * Median filter over a stream of values. * Returns the median of the last N numbers */ diff --git a/src/txdb.cpp b/src/txdb.cpp index d2ab2362d3fb..1672d34ff2f0 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -58,7 +58,7 @@ struct CoinEntry { } -CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe, true) +CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe, true) { } diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 49073b95ba26..f627da19f1d0 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -285,7 +285,7 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b // should be a bit faster. // However, if we happen to be in the middle of processing a reorg, then // the mempool can be in an inconsistent state. In this case, the set - // of ancestors reachable via mapLinks will be the same as the set of + // of ancestors reachable via mapLinks will be the same as the set of // ancestors whose packages include this transaction, because when we // add a new transaction to the mempool in addUnchecked(), we assume it // has no children, and in the case of a reorg where that assumption is diff --git a/src/txmempool.h b/src/txmempool.h index c88b7ade349c..c89069154b57 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -729,7 +729,7 @@ class CTxMemPool void removeUnchecked(txiter entry, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN) EXCLUSIVE_LOCKS_REQUIRED(cs); }; -/** +/** * CCoinsView that brings transactions from a mempool into view. * It does not check for spendings by memory pool transactions. * Instead, it provides access to all Coins which are either unspent in the diff --git a/src/validation.h b/src/validation.h index 6e0ba4561d7d..580be95353d7 100644 --- a/src/validation.h +++ b/src/validation.h @@ -221,7 +221,7 @@ static const unsigned int DEFAULT_CHECKLEVEL = 3; // Setting the target to > than 945MB will make it likely we can respect the target. static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 945 * 1024 * 1024; -/** +/** * Process an incoming block. This only returns after the best known valid * block is made active. Note that it does not, however, guarantee that the * specific block passed to it has been checked for validity! @@ -373,7 +373,7 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp = null /** * Closure representing one script verification - * Note that this stores references to the spending transaction + * Note that this stores references to the spending transaction */ class CScriptCheck { diff --git a/test/README.md b/test/README.md index 9006ccc8485b..83a8b245ba8e 100644 --- a/test/README.md +++ b/test/README.md @@ -5,7 +5,7 @@ etc. There are currently two sets of tests in this directory: -- [functional](/test/functional) which test the functionality of +- [functional](/test/functional) which test the functionality of dashd and dash-qt by interacting with them through the RPC and P2P interfaces. - [util](/test/util) which tests the dash utilities, currently only @@ -188,5 +188,5 @@ Use the `-v` option for verbose output. # Writing functional tests You are encouraged to write functional tests for new or existing features. -Further information about the functional test framework and individual +Further information about the functional test framework and individual tests is found in [test/functional](/test/functional). diff --git a/test/functional/feature_bip68_sequence.py b/test/functional/feature_bip68_sequence.py index bfca0af681fd..724526b7b54a 100755 --- a/test/functional/feature_bip68_sequence.py +++ b/test/functional/feature_bip68_sequence.py @@ -67,7 +67,7 @@ def test_disable_flag(self): # If sequence locks were used, this would require 1 block for the # input to mature. sequence_value = SEQUENCE_LOCKTIME_DISABLE_FLAG | 1 - tx1.vin = [CTxIn(COutPoint(int(utxo["txid"], 16), utxo["vout"]), nSequence=sequence_value)] + tx1.vin = [CTxIn(COutPoint(int(utxo["txid"], 16), utxo["vout"]), nSequence=sequence_value)] tx1.vout = [CTxOut(value, CScript([b'a']))] tx1_signed = self.nodes[0].signrawtransaction(ToHex(tx1))["hex"] diff --git a/test/functional/feature_maxuploadtarget.py b/test/functional/feature_maxuploadtarget.py index e095faa423b9..0aea5201e689 100755 --- a/test/functional/feature_maxuploadtarget.py +++ b/test/functional/feature_maxuploadtarget.py @@ -104,7 +104,7 @@ def run_test(self): assert_equal(p2p_conns[0].block_receive_map[big_old_block], i+1) assert_equal(len(self.nodes[0].getpeerinfo()), 3) - # At most a couple more tries should succeed (depending on how long + # At most a couple more tries should succeed (depending on how long # the test has been running so far). for i in range(3): p2p_conns[0].send_message(getdata_request) diff --git a/test/functional/feature_multikeysporks.py b/test/functional/feature_multikeysporks.py index a229f00f3d42..695c08a007cb 100755 --- a/test/functional/feature_multikeysporks.py +++ b/test/functional/feature_multikeysporks.py @@ -12,8 +12,8 @@ Test logic for several signer keys usage for spork broadcast. -We set 5 possible keys for sporks signing and set minimum -required signers to 3. We check 1 and 2 signers can't set the spork +We set 5 possible keys for sporks signing and set minimum +required signers to 3. We check 1 and 2 signers can't set the spork value, any 3 signers can change spork value and other 3 signers can change it again. ''' diff --git a/test/functional/feature_proxy.py b/test/functional/feature_proxy.py index 166ee3372543..707f4fc7f39c 100755 --- a/test/functional/feature_proxy.py +++ b/test/functional/feature_proxy.py @@ -79,9 +79,9 @@ def setup_nodes(self): # Note: proxies are not used to connect to local nodes # this is because the proxy to use is based on CService.GetNetwork(), which return NET_UNROUTABLE for localhost args = [ - ['-listen', '-proxy=%s:%i' % (self.conf1.addr),'-proxyrandomize=1'], - ['-listen', '-proxy=%s:%i' % (self.conf1.addr),'-onion=%s:%i' % (self.conf2.addr),'-proxyrandomize=0'], - ['-listen', '-proxy=%s:%i' % (self.conf2.addr),'-proxyrandomize=1'], + ['-listen', '-proxy=%s:%i' % (self.conf1.addr),'-proxyrandomize=1'], + ['-listen', '-proxy=%s:%i' % (self.conf1.addr),'-onion=%s:%i' % (self.conf2.addr),'-proxyrandomize=0'], + ['-listen', '-proxy=%s:%i' % (self.conf2.addr),'-proxyrandomize=1'], [] ] if self.have_ipv6: diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py index 67a632824135..f6730063f227 100644 --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -42,7 +42,7 @@ def serialize_script_num(value): # otherwise an anyone-can-spend output. def create_coinbase(height, pubkey = None, dip4_activated=False): coinbase = CTransaction() - coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff), + coinbase.vin.append(CTxIn(COutPoint(0, 0xffffffff), ser_string(serialize_script_num(height)), 0xffffffff)) coinbaseoutput = CTxOut() coinbaseoutput.nValue = 500 * COIN diff --git a/test/functional/wallet_txn_clone.py b/test/functional/wallet_txn_clone.py index b0d1d374aa59..eeb871ccf640 100755 --- a/test/functional/wallet_txn_clone.py +++ b/test/functional/wallet_txn_clone.py @@ -45,11 +45,11 @@ def run_test(self): # Coins are sent to node1_address node1_address = self.nodes[1].getnewaddress("from0") - # Send tx1, and another transaction tx2 that won't be cloned + # Send tx1, and another transaction tx2 that won't be cloned txid1 = self.nodes[0].sendfrom("foo", node1_address, 400, 0) txid2 = self.nodes[0].sendfrom("bar", node1_address, 200, 0) - # Construct a clone of tx1, to be malleated + # Construct a clone of tx1, to be malleated rawtx1 = self.nodes[0].getrawtransaction(txid1,1) clone_inputs = [{"txid":rawtx1["vin"][0]["txid"],"vout":rawtx1["vin"][0]["vout"]}] clone_outputs = {rawtx1["vout"][0]["scriptPubKey"]["addresses"][0]:rawtx1["vout"][0]["value"], @@ -130,7 +130,7 @@ def run_test(self): # Check node0's total balance; should be same as before the clone, + 1000 DASH for 2 matured, # less possible orphaned matured subsidy expected += 1000 - if (self.options.mine_block): + if (self.options.mine_block): expected -= 500 assert_equal(self.nodes[0].getbalance(), expected) assert_equal(self.nodes[0].getbalance("*", 0), expected) From e1e303b179a80ce33cc00a71c0334eb99441b6e2 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 26 Jul 2018 08:54:57 -0400 Subject: [PATCH 05/31] Merge #13095: build: update ax_boost_chrono/unit_test_framework aa85dcf472 build: sync ax_boost_chrono/unit_test (fanquake) Pull request description: [ax_boost_chrono](https://github.com/bitcoin/bitcoin/blob/master/build-aux/m4/ax_boost_chrono.m4) and [ax_boost_unit_test_framework](https://github.com/bitcoin/bitcoin/blob/master/build-aux/m4/ax_boost_unit_test_framework.m4) were updated from upstream in #12678. However some minor upstream changes were missed. Pull those changes in here so these files actually reflect their upstream serial. Tree-SHA512: 71d9ee7a1616d9d36e6f63dedb6687918c3662bde724cdda1fdf3eb039c8973acd166273876a9b2671a7e087149fcf956552f9f2b946e5ee1835d12944c0065d --- build-aux/m4/ax_boost_chrono.m4 | 3 +-- build-aux/m4/ax_boost_unit_test_framework.m4 | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/build-aux/m4/ax_boost_chrono.m4 b/build-aux/m4/ax_boost_chrono.m4 index 318ecea17fab..9b3958ec74d2 100644 --- a/build-aux/m4/ax_boost_chrono.m4 +++ b/build-aux/m4/ax_boost_chrono.m4 @@ -81,7 +81,6 @@ AC_DEFUN([AX_BOOST_CHRONO], LDFLAGS_SAVE=$LDFLAGS if test "x$ax_boost_user_chrono_lib" = "x"; then - ax_lib= for libextension in `ls $BOOSTLIBDIR/libboost_chrono*.so* $BOOSTLIBDIR/libboost_chrono*.dylib* $BOOSTLIBDIR/libboost_chrono*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_chrono.*\)\.so.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.a.*$;\1;'` ; do ax_lib=${libextension} AC_CHECK_LIB($ax_lib, exit, @@ -106,7 +105,7 @@ AC_DEFUN([AX_BOOST_CHRONO], fi if test "x$ax_lib" = "x"; then - AC_MSG_ERROR(Could not find a version of the boost_chrono library!) + AC_MSG_ERROR(Could not find a version of the library!) fi if test "x$link_chrono" = "xno"; then AC_MSG_ERROR(Could not link against $ax_lib !) diff --git a/build-aux/m4/ax_boost_unit_test_framework.m4 b/build-aux/m4/ax_boost_unit_test_framework.m4 index 4efd1e2f18be..1115f551212a 100644 --- a/build-aux/m4/ax_boost_unit_test_framework.m4 +++ b/build-aux/m4/ax_boost_unit_test_framework.m4 @@ -76,7 +76,6 @@ AC_DEFUN([AX_BOOST_UNIT_TEST_FRAMEWORK], if test "x$ax_boost_user_unit_test_framework_lib" = "x"; then saved_ldflags="${LDFLAGS}" - ax_lib= for monitor_library in `ls $BOOSTLIBDIR/libboost_unit_test_framework*.so* $BOOSTLIBDIR/libboost_unit_test_framework*.dylib* $BOOSTLIBDIR/libboost_unit_test_framework*.a* 2>/dev/null` ; do if test -r $monitor_library ; then libextension=`echo $monitor_library | sed 's,.*/,,' | sed -e 's;^lib\(boost_unit_test_framework.*\)\.so.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.a.*$;\1;'` @@ -125,7 +124,7 @@ AC_DEFUN([AX_BOOST_UNIT_TEST_FRAMEWORK], done fi if test "x$ax_lib" = "x"; then - AC_MSG_ERROR(Could not find a version of the boost_unit_test_framework library!) + AC_MSG_ERROR(Could not find a version of the library!) fi if test "x$link_unit_test_framework" != "xyes"; then AC_MSG_ERROR(Could not link against $ax_lib !) From c59dcbba599d91d240869c992b51c5d2a09529fd Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Fri, 27 Jul 2018 11:43:58 -0400 Subject: [PATCH 06/31] Merge #13711: [bench] Add benchmark for unserialize prevector 46340b3337 [bench] Add benchmark for unserialize prevector (Akio Nakamura) Pull request description: This PR adds benchmarks for the unserialization of the prevector. Note: Separated from #12324. Tree-SHA512: c055a283328cc2634c01eb60f26604a8665939bbf77d367b6ba6b4e01e77d4511fab69cc3ddb1e62969adb3c48752ed870f45ceba153eee192302601341e18a7 --- src/bench/prevector.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/bench/prevector.cpp b/src/bench/prevector.cpp index 286669bfad34..18ca9fb29856 100644 --- a/src/bench/prevector.cpp +++ b/src/bench/prevector.cpp @@ -4,12 +4,17 @@ #include #include +#include +#include #include struct nontrivial_t { int x; nontrivial_t() :x(-1) {} + ADD_SERIALIZE_METHODS + template + inline void SerializationOp(Stream& s, Operation ser_action) {READWRITE(x);} }; static_assert(!IS_TRIVIALLY_CONSTRUCTIBLE::value, "expected nontrivial_t to not be trivially constructible"); @@ -55,6 +60,28 @@ void PrevectorResize(benchmark::State& state) } } +template +static void PrevectorDeserialize(benchmark::State& state) +{ + CDataStream s0(SER_NETWORK, 0); + prevector<28, T> t0; + t0.resize(28); + for (auto x = 0; x < 900; ++x) { + s0 << t0; + } + t0.resize(100); + for (auto x = 0; x < 101; ++x) { + s0 << t0; + } + while (state.KeepRunning()) { + prevector<28, T> t1; + for (auto x = 0; x < 1000; ++x) { + s0 >> t1; + } + s0.Init(SER_NETWORK, 0); + } +} + #define PREVECTOR_TEST(name, nontrivops, trivops) \ static void Prevector ## name ## Nontrivial(benchmark::State& state) { \ Prevector ## name(state); \ @@ -68,6 +95,7 @@ void PrevectorResize(benchmark::State& state) PREVECTOR_TEST(Clear, 80 * 1000 * 1000, 70 * 1000 * 1000) PREVECTOR_TEST(Destructor, 800 * 1000 * 1000, 800 * 1000 * 1000) PREVECTOR_TEST(Resize, 80 * 1000 * 1000, 70 * 1000 * 1000) +PREVECTOR_TEST(Deserialize, 6800, 52000) #include From f0b1c562a12fce02aaa871089abcce37d46ea819 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Mon, 30 Jul 2018 16:01:58 +0200 Subject: [PATCH 07/31] Merge #13764: contrib: Fix test-security-check fail in Ubuntu 18.04 1e60713a68296a0ff221befb48b2958fbf019ebf contrib: Fix test-security-check fail in Ubuntu 18.04 (Chun Kuan Lee) Pull request description: - Fix test-security-check fail in Ubuntu 18.04. Those flags are enabled by default, so we must specify `-no` to make the executable does 'not' have those attributes. - Drop HIGH_ENTROPY_VA. After update our gitian system to Bionic, the compiler should support HIGH_ENTROPY_VA Tree-SHA512: 78c1f2aae1253ddd52faa1af569b7151a503a217c7ccbe21b8004d8910c45d8a27ff04695eacbdadd7192d2c91c0d59941ca20c651dd2d5052b9999163a11ae4 --- contrib/devtools/security-check.py | 2 +- contrib/devtools/test-security-check.py | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py index ba6e15a3a81f..9b9698ba4e22 100755 --- a/contrib/devtools/security-check.py +++ b/contrib/devtools/security-check.py @@ -14,7 +14,7 @@ READELF_CMD = os.getenv('READELF', '/usr/bin/readelf') OBJDUMP_CMD = os.getenv('OBJDUMP', '/usr/bin/objdump') -NONFATAL = {'HIGH_ENTROPY_VA'} # checks which are non-fatal for now but only generate a warning +NONFATAL = {} # checks which are non-fatal for now but only generate a warning def check_ELF_PIE(executable): ''' diff --git a/contrib/devtools/test-security-check.py b/contrib/devtools/test-security-check.py index bf53256db94f..bb1910415ee0 100755 --- a/contrib/devtools/test-security-check.py +++ b/contrib/devtools/test-security-check.py @@ -32,15 +32,15 @@ def test_ELF(self): cc = 'gcc' write_testcode(source) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-zexecstack','-fno-stack-protector','-Wl,-znorelro']), + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-zexecstack','-fno-stack-protector','-Wl,-znorelro','-no-pie','-fno-PIE']), (1, executable+': failed PIE NX RELRO Canary')) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fno-stack-protector','-Wl,-znorelro']), + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fno-stack-protector','-Wl,-znorelro','-no-pie','-fno-PIE']), (1, executable+': failed PIE RELRO Canary')) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-znorelro']), + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-znorelro','-no-pie','-fno-PIE']), (1, executable+': failed PIE RELRO')) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-znorelro','-pie','-fPIE']), + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-znorelro','-pie','-fPIE']), (1, executable+': failed RELRO')) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-zrelro','-Wl,-z,now','-pie','-fPIE']), + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,-znoexecstack','-fstack-protector-all','-Wl,-zrelro','-Wl,-z,now','-pie','-fPIE']), (0, '')) def test_32bit_PE(self): @@ -49,11 +49,11 @@ def test_32bit_PE(self): cc = 'i686-w64-mingw32-gcc' write_testcode(source) - self.assertEqual(call_security_check(cc, source, executable, []), + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--no-nxcompat','-Wl,--no-dynamicbase']), (1, executable+': failed DYNAMIC_BASE NX')) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat']), + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--no-dynamicbase']), (1, executable+': failed DYNAMIC_BASE')) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase']), + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase']), (0, '')) def test_64bit_PE(self): source = 'test1.c' @@ -61,9 +61,9 @@ def test_64bit_PE(self): cc = 'x86_64-w64-mingw32-gcc' write_testcode(source) - self.assertEqual(call_security_check(cc, source, executable, []), (1, executable+': failed DYNAMIC_BASE NX\n'+executable+': warning HIGH_ENTROPY_VA')) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat']), (1, executable+': failed DYNAMIC_BASE\n'+executable+': warning HIGH_ENTROPY_VA')) - self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase']), (0, executable+': warning HIGH_ENTROPY_VA')) + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--no-nxcompat','-Wl,--no-dynamicbase','-Wl,--no-high-entropy-va']), (1, executable+': failed DYNAMIC_BASE HIGH_ENTROPY_VA NX')) + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--no-dynamicbase','-Wl,--no-high-entropy-va']), (1, executable+': failed DYNAMIC_BASE HIGH_ENTROPY_VA')) + self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase','-Wl,--no-high-entropy-va']), (1, executable+': failed HIGH_ENTROPY_VA')) self.assertEqual(call_security_check(cc, source, executable, ['-Wl,--nxcompat','-Wl,--dynamicbase','-Wl,--high-entropy-va']), (0, '')) if __name__ == '__main__': From 619f7fb862c196b22e4b222b5bc2ff1f56411c12 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 30 Jul 2018 13:10:54 -0400 Subject: [PATCH 08/31] Merge #13782: Fix osslsigncode compile issue in gitian-build 284f424d5a Fix osslsigncode compile issue in gitian-build (Chun Kuan Lee) Pull request description: Install libssl1.0-dev that is compatible with osslsigncode. Fixes #13762 Verifed that this gitian descriptor file can sign 0.16.2rc2. Tree-SHA512: 3029b86e77567a4e033b5ad95826e60df12a0486ac3c4afcac48218f5c76ba49e7f1c1307ce93ffc465ca2f24e12c401e4542929263688e4bd6521aeca3ff73b --- contrib/gitian-descriptors/gitian-win-signer.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/gitian-descriptors/gitian-win-signer.yml b/contrib/gitian-descriptors/gitian-win-signer.yml index f068c6464a27..b607005549ea 100644 --- a/contrib/gitian-descriptors/gitian-win-signer.yml +++ b/contrib/gitian-descriptors/gitian-win-signer.yml @@ -5,7 +5,8 @@ suites: architectures: - "amd64" packages: -- "libssl-dev" +# Once osslsigncode supports openssl 1.1, we can change this back to libssl-dev +- "libssl1.0-dev" - "autoconf" - "automake" - "libtool" From dc914a32bc50e4ef7a610b1acbbd82c82278aa73 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 2 Aug 2018 12:45:15 +0200 Subject: [PATCH 09/31] Merge #13791: gui: Reject dialogs if key escape is pressed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 7bf22bf0c21d13557ec46a67413819ebcabc3df0 gui: Reject options dialog when key escape is pressed (João Barbosa) 4a43306a4f643cf0d356d5d5e16913541f1bc893 gui: Reject edit address dialog when key escape is pressed (João Barbosa) f7a553177d4b969956bc04a0140fce34958971f5 gui: Add GUIUtil::ItemDelegate with keyEscapePressed signal (João Barbosa) Pull request description: Currently `EditAddressDialog` and `OptionsDialog` don't close when the escape key is pressed. The `QDataWidgetMapper` instances prevents closing the dialogs because the escape key is used to reset the widgets values. More details and workarounds in https://stackoverflow.com/a/51487847 and http://qtramblings.blogspot.com/2010/10/qdatawidgetmapper-annoyances.html. The adopted solution is different from the above references. It turns out that `QDataWidgetMapper::setItemDelegate` sets the event filter for all mapped widgets. So in this PR the mapper's delegate are changed to a custom `GUIUtil::ItemDelegate` that offers the signal `keyEscapePressed`, which is connected to the `QDialog::reject` slot. Note that the installed event filter lets all events pass, so the current behaviour isn't changed, meaning that widgets values are reset in addition to closing the dialog. Tree-SHA512: 9c961d488480b4ccc3880a11a8f1824b65f77570ee8918c7302c62775a1a73e52ae988a31a55ffff87b4170ddbecf833c2f09b66095c00eb6854a4d43f030f1f --- src/qt/editaddressdialog.cpp | 4 ++++ src/qt/guiutil.cpp | 10 ++++++++++ src/qt/guiutil.h | 13 +++++++++++++ src/qt/optionsdialog.cpp | 4 ++++ 4 files changed, 31 insertions(+) diff --git a/src/qt/editaddressdialog.cpp b/src/qt/editaddressdialog.cpp index 4528adc1c915..d2f18ebfe082 100644 --- a/src/qt/editaddressdialog.cpp +++ b/src/qt/editaddressdialog.cpp @@ -41,6 +41,10 @@ EditAddressDialog::EditAddressDialog(Mode _mode, QWidget *parent) : mapper = new QDataWidgetMapper(this); mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); + + GUIUtil::ItemDelegate* delegate = new GUIUtil::ItemDelegate(mapper); + connect(delegate, &GUIUtil::ItemDelegate::keyEscapePressed, this, &EditAddressDialog::reject); + mapper->setItemDelegate(delegate); } EditAddressDialog::~EditAddressDialog() diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index e53c4c8cad1d..5768d8df668b 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -1880,4 +1880,14 @@ void ClickableProgressBar::mouseReleaseEvent(QMouseEvent *event) Q_EMIT clicked(event->pos()); } +bool ItemDelegate::eventFilter(QObject *object, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + if (static_cast(event)->key() == Qt::Key_Escape) { + Q_EMIT keyEscapePressed(); + } + } + return QItemDelegate::eventFilter(object, event); +} + } // namespace GUIUtil diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index c0ed04d196f3..89f5c2792b8c 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -424,6 +425,18 @@ namespace GUIUtil typedef ClickableProgressBar ProgressBar; #endif + class ItemDelegate : public QItemDelegate + { + Q_OBJECT + public: + ItemDelegate(QObject* parent) : QItemDelegate(parent) {} + + Q_SIGNALS: + void keyEscapePressed(); + + private: + bool eventFilter(QObject *object, QEvent *event); + }; } // namespace GUIUtil #endif // BITCOIN_QT_GUIUTIL_H diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index b28919aecec5..46484aa141ff 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -136,6 +136,10 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); mapper->setOrientation(Qt::Vertical); + GUIUtil::ItemDelegate* delegate = new GUIUtil::ItemDelegate(mapper); + connect(delegate, &GUIUtil::ItemDelegate::keyEscapePressed, this, &OptionsDialog::reject); + mapper->setItemDelegate(delegate); + /* setup/change UI elements when proxy IPs are invalid/valid */ ui->proxyIp->setCheckValidator(new ProxyAddressValidator(parent)); ui->proxyIpTor->setCheckValidator(new ProxyAddressValidator(parent)); From 4a5dd0d80f88b2c88eb124ddd83ab3b4476510c8 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 11 Apr 2018 10:01:39 -0400 Subject: [PATCH 10/31] Merge #12871: Add shell script linting: Check for shellcheck warnings in shell scripts 1499fdc350 Add shell script linting: Check for shellcheck warnings in shell scripts (practicalswift) Pull request description: Add shell script linting: Check for `shellcheck` warnings in shell scripts. Tree-SHA512: c7f3f5ed9933415666d2a02f5658cdc62b959ce8112f46b6327ff5f77bb5a66710704c0cde5fd8e719d1fa1fc4f0375a0c115faced166b78e81b75dfb862f08e Signed-off-by: pasta --- ci/Dockerfile.builder | 1 + contrib/devtools/lint-shell.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100755 contrib/devtools/lint-shell.sh diff --git a/ci/Dockerfile.builder b/ci/Dockerfile.builder index 0a943960bb99..c80eb64f7fb0 100644 --- a/ci/Dockerfile.builder +++ b/ci/Dockerfile.builder @@ -38,6 +38,7 @@ RUN apt-get update && apt-get install $APT_ARGS g++-mingw-w64-i686 && rm -rf /va RUN apt-get update && apt-get install $APT_ARGS g++-mingw-w64-x86-64 && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install $APT_ARGS wine-stable wine32 wine64 bc nsis && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install $APT_ARGS python3-zmq && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install $APT_ARGS shellcheck && rm -rf /var/lib/apt/lists/* RUN apt-get update && apt-get install $APT_ARGS imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools && rm -rf /var/lib/apt/lists/* # This is a hack. It is needed because gcc-multilib and g++-multilib are conflicting with g++-arm-linux-gnueabihf. This is diff --git a/contrib/devtools/lint-shell.sh b/contrib/devtools/lint-shell.sh new file mode 100755 index 000000000000..5f5fa9a925db --- /dev/null +++ b/contrib/devtools/lint-shell.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# +# Copyright (c) 2018 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# +# Check for shellcheck warnings in shell scripts. + +# Disabled warnings: +# SC2001: See if you can use ${variable//search/replace} instead. +# SC2004: $/${} is unnecessary on arithmetic variables. +# SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. +# SC2006: Use $(..) instead of legacy `..`. +# SC2016: Expressions don't expand in single quotes, use double quotes for that. +# SC2028: echo won't expand escape sequences. Consider printf. +# SC2046: Quote this to prevent word splitting. +# SC2048: Use "$@" (with quotes) to prevent whitespace problems. +# SC2066: Since you double quoted this, it will not word split, and the loop will only run once. +# SC2086: Double quote to prevent globbing and word splitting. +# SC2116: Useless echo? Instead of 'cmd $(echo foo)', just use 'cmd foo'. +# SC2148: Tips depend on target shell and yours is unknown. Add a shebang. +# SC2162: read without -r will mangle backslashes. +# SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. +# SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. +# SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. +shellcheck -e SC2001,SC2004,SC2005,SC2006,SC2016,SC2028,SC2046,SC2048,SC2066,SC2086,SC2116,SC2148,SC2162,SC2166,SC2181 \ + $(git ls-files -- "*.sh" | grep -vE 'src/(secp256k1|univalue)/') From cb5d0d8b996e93aec62bdf5494c22292e022dfe1 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Mon, 18 Jun 2018 13:12:07 +0200 Subject: [PATCH 11/31] Merge #13454: Make sure LC_ALL=C is set in all shell scripts 47776a958b08382d76d69b5df7beed807af168b3 Add linter: Make sure all shell scripts opt out of locale dependence using "export LC_ALL=C" (practicalswift) 3352da8da1243c03fc83ba678d2f5d193bd5a0c2 Add "export LC_ALL=C" to all shell scripts (practicalswift) Pull request description: ~~Make sure `LC_ALL=C` is set when using `grep` range expressions.~~ Make sure `LC_ALL=C` is set in all shell scripts. From the `grep(1)` documentation: > Within a bracket expression, a range expression consists of two characters separated by a hyphen. It matches any single character that sorts between the two characters, inclusive, using the locale's collating sequence and character set. For example, in the default C locale, `[a-d]` is equivalent to `[abcd]`. Many locales sort characters in dictionary order, and in these locales `[a-d]` is typically not equivalent to `[abcd]`; it might be equivalent to `[aBbCcDd]`, for example. To obtain the traditional interpretation of bracket expressions, you can use the C locale by setting the `LC_ALL` environment variable to the value C. Context: [Locale issue found when reviewing #13450](https://github.com/bitcoin/bitcoin/pull/13450/files#r194877736) Tree-SHA512: fd74d2612998f9b49ef9be24410e505d8c842716f84d085157fc7f9799d40e8a7b4969de783afcf99b7fae4f91bbb4559651f7dd6578a6a081a50bdea29f0909 --- autogen.sh | 1 + contrib/devtools/commit-script-check.sh | 1 + contrib/devtools/gen-manpages.sh | 1 + contrib/devtools/git-subtree-check.sh | 1 + contrib/devtools/lint-all.sh | 4 ++++ contrib/devtools/lint-include-guards.sh | 1 + contrib/devtools/lint-includes.sh | 1 + contrib/devtools/lint-logs.sh | 2 +- contrib/devtools/lint-python-shebang.sh | 2 ++ contrib/devtools/lint-python.sh | 2 ++ contrib/devtools/lint-shell.sh | 4 ++++ contrib/devtools/lint-tests.sh | 1 + contrib/devtools/lint-whitespace.sh | 1 + contrib/macdeploy/detached-sig-apply.sh | 1 + contrib/macdeploy/detached-sig-create.sh | 1 + contrib/macdeploy/extract-osx-sdk.sh | 1 + contrib/qos/tc.sh | 1 + contrib/verify-commits/gpg.sh | 1 + contrib/verify-commits/pre-push-hook.sh | 1 + contrib/verifybinaries/verify.sh | 1 + contrib/windeploy/detached-sig-create.sh | 1 + share/genbuild.sh | 1 + src/qt/res/movies/makespinner.sh | 1 + test/lint/lint-locale-dependence.sh | 1 + test/lint/lint-shell-locale.sh | 24 ++++++++++++++++++++++++ 25 files changed, 56 insertions(+), 1 deletion(-) create mode 100755 test/lint/lint-shell-locale.sh diff --git a/autogen.sh b/autogen.sh index 27417daf7691..0c05626ccce5 100755 --- a/autogen.sh +++ b/autogen.sh @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C set -e srcdir="$(dirname $0)" cd "$srcdir" diff --git a/contrib/devtools/commit-script-check.sh b/contrib/devtools/commit-script-check.sh index 1c9dbc7f68ff..f1327469f3d8 100755 --- a/contrib/devtools/commit-script-check.sh +++ b/contrib/devtools/commit-script-check.sh @@ -11,6 +11,7 @@ # The resulting script should exactly transform the previous commit into the current # one. Any remaining diff signals an error. +export LC_ALL=C if test "x$1" = "x"; then echo "Usage: $0 ..." exit 1 diff --git a/contrib/devtools/gen-manpages.sh b/contrib/devtools/gen-manpages.sh index d09748249ce2..9cc2af74ea5f 100755 --- a/contrib/devtools/gen-manpages.sh +++ b/contrib/devtools/gen-manpages.sh @@ -1,5 +1,6 @@ #!/bin/bash +export LC_ALL=C TOPDIR=${TOPDIR:-$(git rev-parse --show-toplevel)} BUILDDIR=${BUILDDIR:-$TOPDIR} diff --git a/contrib/devtools/git-subtree-check.sh b/contrib/devtools/git-subtree-check.sh index 2384d66cad2a..d487c1d9bd19 100755 --- a/contrib/devtools/git-subtree-check.sh +++ b/contrib/devtools/git-subtree-check.sh @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C DIR="$1" COMMIT="$2" if [ -z "$COMMIT" ]; then diff --git a/contrib/devtools/lint-all.sh b/contrib/devtools/lint-all.sh index b6d86959c669..c9d4ec7199fd 100755 --- a/contrib/devtools/lint-all.sh +++ b/contrib/devtools/lint-all.sh @@ -7,6 +7,10 @@ # This script runs all contrib/devtools/lint-*.sh files, and fails if any exit # with a non-zero status code. +# This script is intentionally locale dependent by not setting "export LC_ALL=C" +# in order to allow for the executed lint scripts to opt in or opt out of locale +# dependence themselves. + set -u SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") diff --git a/contrib/devtools/lint-include-guards.sh b/contrib/devtools/lint-include-guards.sh index 50677ae71277..4e5dac7b2f88 100755 --- a/contrib/devtools/lint-include-guards.sh +++ b/contrib/devtools/lint-include-guards.sh @@ -6,6 +6,7 @@ # # Check include guards. +export LC_ALL=C HEADER_ID_PREFIX="BITCOIN_" HEADER_ID_SUFFIX="_H" diff --git a/contrib/devtools/lint-includes.sh b/contrib/devtools/lint-includes.sh index 4f794d8146e7..8e89446c4dea 100755 --- a/contrib/devtools/lint-includes.sh +++ b/contrib/devtools/lint-includes.sh @@ -8,6 +8,7 @@ # Guard against accidental introduction of new Boost dependencies. # Check includes: Check for duplicate includes. Enforce bracket syntax includes. +export LC_ALL=C IGNORE_REGEXP="/(leveldb|secp256k1|univalue)/" filter_suffix() { diff --git a/contrib/devtools/lint-logs.sh b/contrib/devtools/lint-logs.sh index 3bb54359a87b..103471e7bac1 100755 --- a/contrib/devtools/lint-logs.sh +++ b/contrib/devtools/lint-logs.sh @@ -12,7 +12,7 @@ # There are some instances of LogPrintf() in comments. Those can be # ignored - +export LC_ALL=C UNTERMINATED_LOGS=$(git grep "LogPrintf(" -- "*.cpp" | \ grep -v '\\n"' | \ grep -v "/\* Continued \*/" | \ diff --git a/contrib/devtools/lint-python-shebang.sh b/contrib/devtools/lint-python-shebang.sh index f5c5971c0379..031487a91af4 100755 --- a/contrib/devtools/lint-python-shebang.sh +++ b/contrib/devtools/lint-python-shebang.sh @@ -1,5 +1,7 @@ #!/bin/bash # Shebang must use python3 (not python or python2) + +export LC_ALL=C EXIT_CODE=0 for PYTHON_FILE in $(git ls-files -- "*.py"); do if [[ $(head -c 2 "${PYTHON_FILE}") == "#!" && diff --git a/contrib/devtools/lint-python.sh b/contrib/devtools/lint-python.sh index ad19679b466b..e1178c4aaa4d 100755 --- a/contrib/devtools/lint-python.sh +++ b/contrib/devtools/lint-python.sh @@ -6,6 +6,8 @@ # # Check for specified flake8 warnings in python files. +export LC_ALL=C + # E112 expected an indented block # E113 unexpected indentation # E115 expected an indented block (comment) diff --git a/contrib/devtools/lint-shell.sh b/contrib/devtools/lint-shell.sh index 5f5fa9a925db..bf56db90c605 100755 --- a/contrib/devtools/lint-shell.sh +++ b/contrib/devtools/lint-shell.sh @@ -6,6 +6,10 @@ # # Check for shellcheck warnings in shell scripts. +# This script is intentionally locale dependent by not setting "export LC_ALL=C" +# to allow running certain versions of shellcheck that core dump when LC_ALL=C +# is set. + # Disabled warnings: # SC2001: See if you can use ${variable//search/replace} instead. # SC2004: $/${} is unnecessary on arithmetic variables. diff --git a/contrib/devtools/lint-tests.sh b/contrib/devtools/lint-tests.sh index ffc0660551e8..9d83547df473 100755 --- a/contrib/devtools/lint-tests.sh +++ b/contrib/devtools/lint-tests.sh @@ -6,6 +6,7 @@ # # Check the test suite naming conventions +export LC_ALL=C EXIT_CODE=0 NAMING_INCONSISTENCIES=$(git grep -E '^BOOST_FIXTURE_TEST_SUITE\(' -- \ diff --git a/contrib/devtools/lint-whitespace.sh b/contrib/devtools/lint-whitespace.sh index fd4b5c2fd1a9..d5f3ca1cf461 100755 --- a/contrib/devtools/lint-whitespace.sh +++ b/contrib/devtools/lint-whitespace.sh @@ -8,6 +8,7 @@ # We can't run this check unless we know the commit range for the PR. +export LC_ALL=C while getopts "?" opt; do case $opt in ?) diff --git a/contrib/macdeploy/detached-sig-apply.sh b/contrib/macdeploy/detached-sig-apply.sh index 91674a92e6fa..f8503e4de8c5 100755 --- a/contrib/macdeploy/detached-sig-apply.sh +++ b/contrib/macdeploy/detached-sig-apply.sh @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C set -e UNSIGNED="$1" diff --git a/contrib/macdeploy/detached-sig-create.sh b/contrib/macdeploy/detached-sig-create.sh index ae72b10312f5..d95095d46b8a 100755 --- a/contrib/macdeploy/detached-sig-create.sh +++ b/contrib/macdeploy/detached-sig-create.sh @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C set -e ROOTDIR=dist diff --git a/contrib/macdeploy/extract-osx-sdk.sh b/contrib/macdeploy/extract-osx-sdk.sh index ff9fbd58df07..94122b56fc59 100755 --- a/contrib/macdeploy/extract-osx-sdk.sh +++ b/contrib/macdeploy/extract-osx-sdk.sh @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C set -e INPUTFILE="Xcode_7.3.1.dmg" diff --git a/contrib/qos/tc.sh b/contrib/qos/tc.sh index c3eb64d280a4..109e546f0e42 100644 --- a/contrib/qos/tc.sh +++ b/contrib/qos/tc.sh @@ -2,6 +2,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C #network interface on which to limit traffic IF="eth0" #limit of the network interface in question diff --git a/contrib/verify-commits/gpg.sh b/contrib/verify-commits/gpg.sh index 16d41d726981..7a10ba7d7d53 100755 --- a/contrib/verify-commits/gpg.sh +++ b/contrib/verify-commits/gpg.sh @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C INPUT=$(cat /dev/stdin) VALID=false REVSIG=false diff --git a/contrib/verify-commits/pre-push-hook.sh b/contrib/verify-commits/pre-push-hook.sh index 20e13e8480cf..45b54150f56b 100755 --- a/contrib/verify-commits/pre-push-hook.sh +++ b/contrib/verify-commits/pre-push-hook.sh @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C if ! [[ "$2" =~ ^(git@)?(www.)?github.com(:|/)dashpay/dash(.git)?$ ]]; then exit 0 fi diff --git a/contrib/verifybinaries/verify.sh b/contrib/verifybinaries/verify.sh index e0266bf08afb..42d9ffb75205 100755 --- a/contrib/verifybinaries/verify.sh +++ b/contrib/verifybinaries/verify.sh @@ -11,6 +11,7 @@ ### The script returns 0 if everything passes the checks. It returns 1 if either the ### signature check or the hash check doesn't pass. If an error occurs the return value is 2 +export LC_ALL=C function clean_up { for file in $* do diff --git a/contrib/windeploy/detached-sig-create.sh b/contrib/windeploy/detached-sig-create.sh index bf4978d14301..15f8108cf011 100755 --- a/contrib/windeploy/detached-sig-create.sh +++ b/contrib/windeploy/detached-sig-create.sh @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C if [ -z "$OSSLSIGNCODE" ]; then OSSLSIGNCODE=osslsigncode fi diff --git a/share/genbuild.sh b/share/genbuild.sh index 419e0da0fd7a..38c9ba176cf8 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -3,6 +3,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C if [ $# -gt 1 ]; then cd "$2" || exit 1 fi diff --git a/src/qt/res/movies/makespinner.sh b/src/qt/res/movies/makespinner.sh index d0deb1238c2b..76e36e4f3140 100755 --- a/src/qt/res/movies/makespinner.sh +++ b/src/qt/res/movies/makespinner.sh @@ -2,6 +2,7 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C FRAMEDIR=$(dirname $0) for i in {0..35} do diff --git a/test/lint/lint-locale-dependence.sh b/test/lint/lint-locale-dependence.sh index 3144f2c841cf..98814ce4b98a 100755 --- a/test/lint/lint-locale-dependence.sh +++ b/test/lint/lint-locale-dependence.sh @@ -1,5 +1,6 @@ #!/bin/bash +export LC_ALL=C KNOWN_VIOLATIONS=( "src/base58.cpp:.*isspace" "src/bitcoin-tx.cpp.*stoul" diff --git a/test/lint/lint-shell-locale.sh b/test/lint/lint-shell-locale.sh new file mode 100755 index 000000000000..d78bac2d474f --- /dev/null +++ b/test/lint/lint-shell-locale.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Copyright (c) 2018 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# +# Make sure all shell scripts: +# a.) explicitly opt out of locale dependence using "export LC_ALL=C", or +# b.) explicitly opt in to locale dependence using the annotation below. + +export LC_ALL=C + +EXIT_CODE=0 +for SHELL_SCRIPT in $(git ls-files -- "*.sh" | grep -vE "src/(secp256k1|univalue)/"); do + if grep -q "# This script is intentionally locale dependent by not setting \"export LC_ALL=C\"" "${SHELL_SCRIPT}"; then + continue + fi + FIRST_NON_COMMENT_LINE=$(grep -vE '^(#.*|)$' "${SHELL_SCRIPT}" | head -1) + if [[ ${FIRST_NON_COMMENT_LINE} != "export LC_ALL=C" ]]; then + echo "Missing \"export LC_ALL=C\" (to avoid locale dependence) as first non-comment non-empty line in ${SHELL_SCRIPT}" + EXIT_CODE=1 + fi +done +exit ${EXIT_CODE} From 9a6c8277b6c58152cceea9ee9ae3680edde11d8f Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 18 Jun 2018 08:32:53 -0400 Subject: [PATCH 12/31] Merge #13494: Follow-up to #13454: Fix broken build by exporting LC_ALL=C 7b23e6e13f Follow-up to #13454: Fix broken build by exporting LC_ALL=C (practicalswift) Pull request description: Follow-up to #13454: Fix broken build by exporting `LC_ALL=C`. Tree-SHA512: 5cca3182ba034dce28a0df5f4a4b343de6c2526048f17fee30e2f8d946e976b39d9cc54faae6c31bfe89022f9f4c360e9ec8e163a1690bc0656410a48bb81dbf --- test/lint/lint-python-utf8-encoding.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test/lint/lint-python-utf8-encoding.sh b/test/lint/lint-python-utf8-encoding.sh index ce973e710a4a..d0ff38ea0a00 100755 --- a/test/lint/lint-python-utf8-encoding.sh +++ b/test/lint/lint-python-utf8-encoding.sh @@ -7,6 +7,7 @@ # Make sure we explicitly open all text files using UTF-8 (or ASCII) encoding to # avoid potential issues on the BSDs where the locale is not always set. +export LC_ALL=C EXIT_CODE=0 OUTPUT=$(git grep " open(" -- "*.py" | grep -vE "encoding=.(ascii|utf8|utf-8)." | grep -vE "open\([^,]*, ['\"][^'\"]*b[^'\"]*['\"]") if [[ ${OUTPUT} != "" ]]; then From a859ea12a9c3af5fbce65ba9c55faf6da354a683 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 2 Aug 2018 09:08:38 -0400 Subject: [PATCH 13/31] Merge #13851: fix locale for lint-shell 83c48d9a1f fix locale for lint-shell (Julian Fleischer) Pull request description: A piece of code from https://github.com/bitcoin/bitcoin/pull/13816 which I am hereby splitting into smaller PRs. The `shellcheck` executable shipped with travis's trusty linux environment (contains shellcheck `0.3.1` in `/usr/local/bin` as opposed to the distros `0.3.3` in `/usr/bin`) segfaults when `LC_ALL=C`. This makes sure that in travis, no matter from where the script is called, `LC_ALL` is left unset. Comment changed accordingly. Tree-SHA512: 86afa9247f2adbeefa75bf3d56a94766f8e8e1839f40b73763ff7b893a09c848ee64648fc06ce3e6bd0f650127365f508b37fdefb48d61e49f5d551c074cb16e --- contrib/devtools/lint-shell.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/contrib/devtools/lint-shell.sh b/contrib/devtools/lint-shell.sh index bf56db90c605..5ac1752ff7c9 100755 --- a/contrib/devtools/lint-shell.sh +++ b/contrib/devtools/lint-shell.sh @@ -6,9 +6,15 @@ # # Check for shellcheck warnings in shell scripts. -# This script is intentionally locale dependent by not setting "export LC_ALL=C" -# to allow running certain versions of shellcheck that core dump when LC_ALL=C -# is set. +export LC_ALL=C + +# The shellcheck binary segfault/coredumps in Travis with LC_ALL=C +# It does not do so in Ubuntu 14.04, 16.04, 18.04 in versions 0.3.3, 0.3.7, 0.4.6 +# respectively. So export LC_ALL=C is set as required by lint-shell-locale.sh +# but unset here in case of running in Travis. +if [ "$TRAVIS" = "true" ]; then + unset LC_ALL +fi # Disabled warnings: # SC2001: See if you can use ${variable//search/replace} instead. From bd8f48820e30cedf306b09952cbc8e2fbe5a02b7 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 5 Aug 2018 13:22:11 -0400 Subject: [PATCH 14/31] Merge #13696: Add aarch64 qt depends support for cross compiling bitcoin-qt 00db418176 Add aarch64 qt depends support for cross compiling bitcoin-qt (TheCharlatan) Pull request description: This also adds a generic qt linux target in packages.mk . I am a bit confused by the existing docs for the RISC addition. Are there boards that would support running bitcoin-qt, or at the very least forwarding X over ssh? Is everybody building depends with `NO_QT=1` when targeting RISC? If not, I will revert the change for a generic qt linux package definition back to the piecemeal solution. This pull request should close #13495 Tree-SHA512: 519b951bf50f214ad725e5330094582a212333cd85b0ae442c67f9afec5629995dfad130258c7706a61f7b7cccbfa49bce69b9931f7e30cf12b382cd9a0a4749 --- depends/packages/packages.mk | 4 +--- depends/packages/qt.mk | 1 + depends/packages/xextproto.mk | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 6b5fe024132a..24557c68ca85 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -3,9 +3,7 @@ packages:=boost openssl libevent zeromq gmp chia_bls backtrace qt_native_packages = native_protobuf qt_packages = qrencode protobuf zlib -qt_x86_64_linux_packages:=qt expat dbus libxcb xcb_proto libXau xproto freetype fontconfig libX11 xextproto libXext xtrans -qt_i686_linux_packages:=$(qt_x86_64_linux_packages) -qt_arm_linux_packages:=$(qt_x86_64_linux_packages) +qt_linux_packages:=qt expat dbus libxcb xcb_proto libXau xproto freetype fontconfig libX11 xextproto libXext xtrans qt_darwin_packages=qt qt_mingw32_packages=qt diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk index 8eca3109713c..db39e0e5e29d 100644 --- a/depends/packages/qt.mk +++ b/depends/packages/qt.mk @@ -103,6 +103,7 @@ $(package)_config_opts_linux += -fontconfig $(package)_config_opts_linux += -no-opengl $(package)_config_opts_arm_linux += -platform linux-g++ -xplatform bitcoin-linux-g++ $(package)_config_opts_i686_linux = -xplatform linux-g++-32 +$(package)_config_opts_aarch64_linux = -xplatform linux-aarch64-gnu-g++ $(package)_config_opts_mingw32 = -no-opengl -xplatform win32-g++ -device-option CROSS_COMPILE="$(host)-" $(package)_build_env = QT_RCC_TEST=1 endef diff --git a/depends/packages/xextproto.mk b/depends/packages/xextproto.mk index 98a11eb4974f..7065237bd562 100644 --- a/depends/packages/xextproto.mk +++ b/depends/packages/xextproto.mk @@ -4,6 +4,10 @@ $(package)_download_path=http://xorg.freedesktop.org/releases/individual/proto $(package)_file_name=$(package)-$($(package)_version).tar.bz2 $(package)_sha256_hash=f3f4b23ac8db9c3a9e0d8edb591713f3d70ef9c3b175970dd8823dfc92aa5bb0 +define $(package)_preprocess_cmds + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub . +endef + define $(package)_set_vars $(package)_config_opts=--disable-shared endef From 036125c9a58604eede3f1e15be69ef9cecae508d Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 7 Aug 2018 15:26:19 +0200 Subject: [PATCH 15/31] Merge #13705: build: Add format string linter bcd4b0f5cdde2a1b562a612c78ec1ef1fe47d3dd Add linting of WalletLogPrintf(...) format strings (practicalswift) a3e455694901a887e0feef69bd63e3aa122ea44b build: Add format string linter (practicalswift) Pull request description: Add format string linter. This linter checks that the number of arguments passed to each variadic format string function matches the number of format specifiers in the format string. Example output: ``` $ test/lint/lint-format-strings.sh src/init.cpp: Expected 2 argument(s) after format string but found 1 argument(s): LogPrintf("We have a mismatch here: foo=%s bar=%d\n", foo) src/init.cpp: Expected 1 argument(s) after format string but found 2 argument(s): LogPrint(BCLog::RPC, "RPC stopped. This is a mismatch: %s\n", s1, s2) $ echo $? 1 ``` Tree-SHA512: 19ab844a63f04bf193d66682ca42745a1c7d6c454b30222491b9fe8dc047054c4a6d3ee7921ec0676fb9ca2e7f6f93bd6c97996fb09667269bd491cb875349f3 --- test/lint/lint-format-strings.py | 254 +++++++++++++++++++++++++++++++ test/lint/lint-format-strings.sh | 41 +++++ 2 files changed, 295 insertions(+) create mode 100755 test/lint/lint-format-strings.py create mode 100755 test/lint/lint-format-strings.sh diff --git a/test/lint/lint-format-strings.py b/test/lint/lint-format-strings.py new file mode 100755 index 000000000000..c07dfe317b5f --- /dev/null +++ b/test/lint/lint-format-strings.py @@ -0,0 +1,254 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2018 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# +# Lint format strings: This program checks that the number of arguments passed +# to a variadic format string function matches the number of format specifiers +# in the format string. + +import argparse +import re +import sys + +FALSE_POSITIVES = [ + ("src/dbwrapper.cpp", "vsnprintf(p, limit - p, format, backup_ap)"), + ("src/index/base.cpp", "FatalError(const char* fmt, const Args&... args)"), + ("src/netbase.cpp", "LogConnectFailure(bool manual_connection, const char* fmt, const Args&... args)"), + ("src/util.cpp", "strprintf(_(COPYRIGHT_HOLDERS), _(COPYRIGHT_HOLDERS_SUBSTITUTION))"), + ("src/util.cpp", "strprintf(COPYRIGHT_HOLDERS, COPYRIGHT_HOLDERS_SUBSTITUTION)"), + ("src/wallet/wallet.h", "WalletLogPrintf(std::string fmt, Params... parameters)"), + ("src/wallet/wallet.h", "LogPrintf((\"%s \" + fmt).c_str(), GetDisplayName(), parameters...)"), +] + + +def parse_function_calls(function_name, source_code): + """Return an array with all calls to function function_name in string source_code. + Preprocessor directives and C++ style comments ("//") in source_code are removed. + + >>> len(parse_function_calls("foo", "foo();bar();foo();bar();")) + 2 + >>> parse_function_calls("foo", "foo(1);bar(1);foo(2);bar(2);")[0].startswith("foo(1);") + True + >>> parse_function_calls("foo", "foo(1);bar(1);foo(2);bar(2);")[1].startswith("foo(2);") + True + >>> len(parse_function_calls("foo", "foo();bar();// foo();bar();")) + 1 + >>> len(parse_function_calls("foo", "#define FOO foo();")) + 0 + """ + assert(type(function_name) is str and type(source_code) is str and function_name) + lines = [re.sub("// .*", " ", line).strip() + for line in source_code.split("\n") + if not line.strip().startswith("#")] + return re.findall(r"[^a-zA-Z_](?=({}\(.*).*)".format(function_name), " " + " ".join(lines)) + + +def normalize(s): + """Return a normalized version of string s with newlines, tabs and C style comments ("/* ... */") + replaced with spaces. Multiple spaces are replaced with a single space. + + >>> normalize(" /* nothing */ foo\tfoo /* bar */ foo ") + 'foo foo foo' + """ + assert(type(s) is str) + s = s.replace("\n", " ") + s = s.replace("\t", " ") + s = re.sub("/\*.*?\*/", " ", s) + s = re.sub(" {2,}", " ", s) + return s.strip() + + +ESCAPE_MAP = { + r"\n": "[escaped-newline]", + r"\t": "[escaped-tab]", + r'\"': "[escaped-quote]", +} + + +def escape(s): + """Return the escaped version of string s with "\\\"", "\\n" and "\\t" escaped as + "[escaped-backslash]", "[escaped-newline]" and "[escaped-tab]". + + >>> unescape(escape("foo")) == "foo" + True + >>> escape(r'foo \\t foo \\n foo \\\\ foo \\ foo \\"bar\\"') + 'foo [escaped-tab] foo [escaped-newline] foo \\\\\\\\ foo \\\\ foo [escaped-quote]bar[escaped-quote]' + """ + assert(type(s) is str) + for raw_value, escaped_value in ESCAPE_MAP.items(): + s = s.replace(raw_value, escaped_value) + return s + + +def unescape(s): + """Return the unescaped version of escaped string s. + Reverses the replacements made in function escape(s). + + >>> unescape(escape("bar")) + 'bar' + >>> unescape("foo [escaped-tab] foo [escaped-newline] foo \\\\\\\\ foo \\\\ foo [escaped-quote]bar[escaped-quote]") + 'foo \\\\t foo \\\\n foo \\\\\\\\ foo \\\\ foo \\\\"bar\\\\"' + """ + assert(type(s) is str) + for raw_value, escaped_value in ESCAPE_MAP.items(): + s = s.replace(escaped_value, raw_value) + return s + + +def parse_function_call_and_arguments(function_name, function_call): + """Split string function_call into an array of strings consisting of: + * the string function_call followed by "(" + * the function call argument #1 + * ... + * the function call argument #n + * a trailing ");" + + The strings returned are in escaped form. See escape(...). + + >>> parse_function_call_and_arguments("foo", 'foo("%s", "foo");') + ['foo(', '"%s",', ' "foo"', ')'] + >>> parse_function_call_and_arguments("foo", 'foo("%s", "foo");') + ['foo(', '"%s",', ' "foo"', ')'] + >>> parse_function_call_and_arguments("foo", 'foo("%s %s", "foo", "bar");') + ['foo(', '"%s %s",', ' "foo",', ' "bar"', ')'] + >>> parse_function_call_and_arguments("fooprintf", 'fooprintf("%050d", i);') + ['fooprintf(', '"%050d",', ' i', ')'] + >>> parse_function_call_and_arguments("foo", 'foo(bar(foobar(barfoo("foo"))), foobar); barfoo') + ['foo(', 'bar(foobar(barfoo("foo"))),', ' foobar', ')'] + >>> parse_function_call_and_arguments("foo", "foo()") + ['foo(', '', ')'] + >>> parse_function_call_and_arguments("foo", "foo(123)") + ['foo(', '123', ')'] + >>> parse_function_call_and_arguments("foo", 'foo("foo")') + ['foo(', '"foo"', ')'] + """ + assert(type(function_name) is str and type(function_call) is str and function_name) + remaining = normalize(escape(function_call)) + expected_function_call = "{}(".format(function_name) + assert(remaining.startswith(expected_function_call)) + parts = [expected_function_call] + remaining = remaining[len(expected_function_call):] + open_parentheses = 1 + in_string = False + parts.append("") + for char in remaining: + parts.append(parts.pop() + char) + if char == "\"": + in_string = not in_string + continue + if in_string: + continue + if char == "(": + open_parentheses += 1 + continue + if char == ")": + open_parentheses -= 1 + if open_parentheses > 1: + continue + if open_parentheses == 0: + parts.append(parts.pop()[:-1]) + parts.append(char) + break + if char == ",": + parts.append("") + return parts + + +def parse_string_content(argument): + """Return the text within quotes in string argument. + + >>> parse_string_content('1 "foo %d bar" 2') + 'foo %d bar' + >>> parse_string_content('1 foobar 2') + '' + >>> parse_string_content('1 "bar" 2') + 'bar' + >>> parse_string_content('1 "foo" 2 "bar" 3') + 'foobar' + >>> parse_string_content('1 "foo" 2 " " "bar" 3') + 'foo bar' + >>> parse_string_content('""') + '' + >>> parse_string_content('') + '' + >>> parse_string_content('1 2 3') + '' + """ + assert(type(argument) is str) + string_content = "" + in_string = False + for char in normalize(escape(argument)): + if char == "\"": + in_string = not in_string + elif in_string: + string_content += char + return string_content + + +def count_format_specifiers(format_string): + """Return the number of format specifiers in string format_string. + + >>> count_format_specifiers("foo bar foo") + 0 + >>> count_format_specifiers("foo %d bar foo") + 1 + >>> count_format_specifiers("foo %d bar %i foo") + 2 + >>> count_format_specifiers("foo %d bar %i foo %% foo") + 2 + >>> count_format_specifiers("foo %d bar %i foo %% foo %d foo") + 3 + >>> count_format_specifiers("foo %d bar %i foo %% foo %*d foo") + 4 + """ + assert(type(format_string) is str) + n = 0 + in_specifier = False + for i, char in enumerate(format_string): + if format_string[i - 1:i + 1] == "%%" or format_string[i:i + 2] == "%%": + pass + elif char == "%": + in_specifier = True + n += 1 + elif char in "aAcdeEfFgGinopsuxX": + in_specifier = False + elif in_specifier and char == "*": + n += 1 + return n + + +def main(): + parser = argparse.ArgumentParser(description="This program checks that the number of arguments passed " + "to a variadic format string function matches the number of format " + "specifiers in the format string.") + parser.add_argument("--skip-arguments", type=int, help="number of arguments before the format string " + "argument (e.g. 1 in the case of fprintf)", default=0) + parser.add_argument("function_name", help="function name (e.g. fprintf)", default=None) + parser.add_argument("file", type=argparse.FileType("r", encoding="utf-8"), nargs="*", help="C++ source code file (e.g. foo.cpp)") + args = parser.parse_args() + + exit_code = 0 + for f in args.file: + for function_call_str in parse_function_calls(args.function_name, f.read()): + parts = parse_function_call_and_arguments(args.function_name, function_call_str) + relevant_function_call_str = unescape("".join(parts))[:512] + if (f.name, relevant_function_call_str) in FALSE_POSITIVES: + continue + if len(parts) < 3 + args.skip_arguments: + exit_code = 1 + print("{}: Could not parse function call string \"{}(...)\": {}".format(f.name, args.function_name, relevant_function_call_str)) + continue + argument_count = len(parts) - 3 - args.skip_arguments + format_str = parse_string_content(parts[1 + args.skip_arguments]) + format_specifier_count = count_format_specifiers(format_str) + if format_specifier_count != argument_count: + exit_code = 1 + print("{}: Expected {} argument(s) after format string but found {} argument(s): {}".format(f.name, format_specifier_count, argument_count, relevant_function_call_str)) + continue + sys.exit(exit_code) + + +if __name__ == "__main__": + main() diff --git a/test/lint/lint-format-strings.sh b/test/lint/lint-format-strings.sh new file mode 100755 index 000000000000..17f846d29b57 --- /dev/null +++ b/test/lint/lint-format-strings.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2018 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# +# Lint format strings: This program checks that the number of arguments passed +# to a variadic format string function matches the number of format specifiers +# in the format string. + +export LC_ALL=C + +FUNCTION_NAMES_AND_NUMBER_OF_LEADING_ARGUMENTS=( + FatalError,0 + fprintf,1 + LogConnectFailure,1 + LogPrint,1 + LogPrintf,0 + printf,0 + snprintf,2 + sprintf,1 + strprintf,0 + vfprintf,1 + vprintf,1 + vsnprintf,1 + vsprintf,1 + WalletLogPrintf,0 +) + +EXIT_CODE=0 +if ! python3 -m doctest test/lint/lint-format-strings.py; then + EXIT_CODE=1 +fi +for S in "${FUNCTION_NAMES_AND_NUMBER_OF_LEADING_ARGUMENTS[@]}"; do + IFS="," read -r FUNCTION_NAME SKIP_ARGUMENTS <<< "${S}" + mapfile -t MATCHING_FILES < <(git grep --full-name -l "${FUNCTION_NAME}" -- "*.c" "*.cpp" "*.h" | sort | grep -vE "^src/(leveldb|secp256k1|tinyformat|univalue)") + if ! test/lint/lint-format-strings.py --skip-arguments "${SKIP_ARGUMENTS}" "${FUNCTION_NAME}" "${MATCHING_FILES[@]}"; then + EXIT_CODE=1 + fi +done +exit ${EXIT_CODE} From 2af1c8d6e79ff36ce74191d53103a5ee4200a845 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Wed, 2 May 2018 15:56:30 +0200 Subject: [PATCH 16/31] Merge #13153: Add missing newlines to debug logging 4b75dcf devtools: Make linter check LogPrint calls (MarcoFalke) ff2ad2d Add missing newlines to LogPrint debug logging (Wladimir J. van der Laan) Pull request description: ~~Don't we have a linter that should catch these?~~ Tree-SHA512: 1a58eca01ded9c1719e943c09447deeb59bb06dba00528cf460eefe857fdf95b42671fbdebc87cdd2f51e931e86942d06587ffd097cbb0d8dd9eb7a0ba17a8f0 --- contrib/devtools/lint-logs.sh | 6 ++++-- src/net.cpp | 2 +- src/net_processing.cpp | 2 +- src/rpc/blockchain.cpp | 2 +- src/timedata.cpp | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/contrib/devtools/lint-logs.sh b/contrib/devtools/lint-logs.sh index 103471e7bac1..8b9aaff426b6 100755 --- a/contrib/devtools/lint-logs.sh +++ b/contrib/devtools/lint-logs.sh @@ -13,12 +13,14 @@ # ignored export LC_ALL=C -UNTERMINATED_LOGS=$(git grep "LogPrintf(" -- "*.cpp" | \ + +UNTERMINATED_LOGS=$(git grep --extended-regexp "LogPrintf?\(" -- "*.cpp" | \ grep -v '\\n"' | \ grep -v "/\* Continued \*/" | \ + grep -v "LogPrint()" | \ grep -v "LogPrintf()") if [[ ${UNTERMINATED_LOGS} != "" ]]; then - echo "All calls to LogPrintf() should be terminated with \\n" + echo "All calls to LogPrintf() and LogPrint() should be terminated with \\n" echo echo "${UNTERMINATED_LOGS}" exit 1 diff --git a/src/net.cpp b/src/net.cpp index 329775381e7e..e6dc5b36b5cb 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -442,7 +442,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo if (Lookup(pszDest, resolved, default_port, fNameLookup && !HaveNameProxy(), 256) && !resolved.empty()) { addrConnect = CAddress(resolved[GetRand(resolved.size())], NODE_NONE); if (!addrConnect.IsValid()) { - LogPrint(BCLog::NET, "Resolver returned invalid address %s for %s", addrConnect.ToString(), pszDest); + LogPrint(BCLog::NET, "Resolver returned invalid address %s for %s\n", addrConnect.ToString(), pszDest); return nullptr; } // It is possible that we already have a connection to the IP/port pszDest resolved to. diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 5a9756863c15..c695b799bc7c 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2678,7 +2678,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr // might maliciously send lots of getblocktxn requests to trigger // expensive disk reads, because it will require the peer to // actually receive all the data read from disk over the network. - LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block > %i deep", pfrom->GetId(), MAX_BLOCKTXN_DEPTH); + LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block > %i deep\n", pfrom->GetId(), MAX_BLOCKTXN_DEPTH); CInv inv; inv.type = MSG_BLOCK; inv.hash = req.blockhash; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 821e03c2554a..4a7d33e20b59 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1189,7 +1189,7 @@ UniValue pruneblockchain(const JSONRPCRequest& request) else if (height > chainHeight) throw JSONRPCError(RPC_INVALID_PARAMETER, "Blockchain is shorter than the attempted prune height."); else if (height > chainHeight - MIN_BLOCKS_TO_KEEP) { - LogPrint(BCLog::RPC, "Attempt to prune blocks close to the tip. Retaining the minimum number of blocks."); + LogPrint(BCLog::RPC, "Attempt to prune blocks close to the tip. Retaining the minimum number of blocks.\n"); height = chainHeight - MIN_BLOCKS_TO_KEEP; } diff --git a/src/timedata.cpp b/src/timedata.cpp index c829300ca25b..f3c38b72276a 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -110,9 +110,9 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) if (LogAcceptCategory(BCLog::NET)) { for (int64_t n : vSorted) { - LogPrint(BCLog::NET, "%+d ", n); + LogPrint(BCLog::NET, "%+d ", n); /* Continued */ } - LogPrint(BCLog::NET, "| "); + LogPrint(BCLog::NET, "| "); /* Continued */ LogPrint(BCLog::NET, "nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60); } From d514668f5e47c91c99bcd6ca85451ed9f88c7db5 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 29 Jul 2020 14:50:36 +0300 Subject: [PATCH 17/31] More of 13153 ("Continued") --- contrib/devtools/lint-logs.sh | 2 +- src/llmq/quorums_utils.cpp | 4 ++-- src/masternode/masternode-payments.cpp | 6 +++--- src/privatesend/privatesend-client.cpp | 22 +++++++++++----------- src/privatesend/privatesend-server.cpp | 14 +++++++------- src/privatesend/privatesend.cpp | 8 ++++---- src/txmempool.cpp | 16 ++++++++-------- src/wallet/wallet.cpp | 2 +- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/contrib/devtools/lint-logs.sh b/contrib/devtools/lint-logs.sh index 8b9aaff426b6..e3cf49e1eda0 100755 --- a/contrib/devtools/lint-logs.sh +++ b/contrib/devtools/lint-logs.sh @@ -7,7 +7,7 @@ # Check that all logs are terminated with '\n' # # Some logs are continued over multiple lines. They should be explicitly -# commented with \* Continued *\ +# commented with /* Continued */ # # There are some instances of LogPrintf() in comments. Those can be # ignored diff --git a/src/llmq/quorums_utils.cpp b/src/llmq/quorums_utils.cpp index d50353dd910d..80245acb5acc 100644 --- a/src/llmq/quorums_utils.cpp +++ b/src/llmq/quorums_utils.cpp @@ -196,7 +196,7 @@ void CLLMQUtils::EnsureQuorumConnections(Consensus::LLMQType llmqType, const CBl debugMsg += strprintf(" %s (%s)\n", c.ToString(), dmn->pdmnState->addr.ToString(false)); } } - LogPrint(BCLog::NET_NETCONN, debugMsg.c_str()); + LogPrint(BCLog::NET_NETCONN, debugMsg.c_str()); /* Continued */ } g_connman->SetMasternodeQuorumNodes(llmqType, pindexQuorum->GetBlockHash(), connections); } @@ -232,7 +232,7 @@ void CLLMQUtils::AddQuorumProbeConnections(Consensus::LLMQType llmqType, const C debugMsg += strprintf(" %s (%s)\n", c.ToString(), dmn->pdmnState->addr.ToString(false)); } } - LogPrint(BCLog::NET_NETCONN, debugMsg.c_str()); + LogPrint(BCLog::NET_NETCONN, debugMsg.c_str()); /* Continued */ } g_connman->AddPendingProbeConnections(probeConnections); } diff --git a/src/masternode/masternode-payments.cpp b/src/masternode/masternode-payments.cpp index 62e4548fe165..e2b625a893cd 100644 --- a/src/masternode/masternode-payments.cpp +++ b/src/masternode/masternode-payments.cpp @@ -183,7 +183,7 @@ bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight, CAmount bloc if(sporkManager.IsSporkActive(SPORK_9_SUPERBLOCKS_ENABLED)) { if(CSuperblockManager::IsSuperblockTriggered(nBlockHeight)) { if(CSuperblockManager::IsValid(txNew, nBlockHeight, blockReward)) { - LogPrint(BCLog::GOBJECT, "%s -- Valid superblock at height %d: %s", __func__, nBlockHeight, txNew.ToString()); + LogPrint(BCLog::GOBJECT, "%s -- Valid superblock at height %d: %s", __func__, nBlockHeight, txNew.ToString()); /* Continued */ // continue validation, should also pay MN } else { LogPrintf("%s -- ERROR: Invalid superblock detected at height %d: %s", __func__, nBlockHeight, txNew.ToString()); /* Continued */ @@ -200,7 +200,7 @@ bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight, CAmount bloc // Check for correct masternode payment if(mnpayments.IsTransactionValid(txNew, nBlockHeight, blockReward)) { - LogPrint(BCLog::MNPAYMENTS, "%s -- Valid masternode payment at height %d: %s", __func__, nBlockHeight, txNew.ToString()); + LogPrint(BCLog::MNPAYMENTS, "%s -- Valid masternode payment at height %d: %s", __func__, nBlockHeight, txNew.ToString()); /* Continued */ return true; } @@ -234,7 +234,7 @@ void FillBlockPayments(CMutableTransaction& txNew, int nBlockHeight, CAmount blo voutMasternodeStr += txout.ToString(); } - LogPrint(BCLog::MNPAYMENTS, "%s -- nBlockHeight %d blockReward %lld voutMasternodePaymentsRet \"%s\" txNew %s", __func__, + LogPrint(BCLog::MNPAYMENTS, "%s -- nBlockHeight %d blockReward %lld voutMasternodePaymentsRet \"%s\" txNew %s", __func__, /* Continued */ nBlockHeight, blockReward, voutMasternodeStr, txNew.ToString()); } diff --git a/src/privatesend/privatesend-client.cpp b/src/privatesend/privatesend-client.cpp index fe4cc044eac7..0465e2c66c14 100644 --- a/src/privatesend/privatesend-client.cpp +++ b/src/privatesend/privatesend-client.cpp @@ -196,7 +196,7 @@ void CPrivateSendClientSession::ProcessMessage(CNode* pfrom, const std::string& return; } - LogPrint(BCLog::PRIVATESEND, "DSFINALTX -- txNew %s", txNew.ToString()); + LogPrint(BCLog::PRIVATESEND, "DSFINALTX -- txNew %s", txNew.ToString()); /* Continued */ // check to see if input is spent already? (and probably not confirmed) SignFinalTransaction(txNew, pfrom, connman); @@ -488,7 +488,7 @@ bool CPrivateSendClientSession::SendDenominate(const std::vectorGetSendVersion()); connman.PushMessage(pnode, msgMaker.Make(NetMsgType::DSSIGNFINALTX, sigs)); SetState(POOL_STATE_SIGNING); @@ -1139,7 +1139,7 @@ bool CPrivateSendClientSession::StartNewQueue(CAmount nBalanceNeedsAnonymized, C int64_t nLastDsq = mmetaman.GetMetaInfo(dmn->proTxHash)->GetLastDsq(); int64_t nDsqThreshold = mmetaman.GetDsqThreshold(dmn->proTxHash, nMnCount); if (nLastDsq != 0 && nDsqThreshold > mmetaman.GetDsqCount()) { - LogPrint(BCLog::PRIVATESEND, "CPrivateSendClientSession::StartNewQueue -- Too early to mix on this masternode!" + LogPrint(BCLog::PRIVATESEND, "CPrivateSendClientSession::StartNewQueue -- Too early to mix on this masternode!" /* Continued */ " masternode=%s addr=%s nLastDsq=%d nDsqThreshold=%d nDsqCount=%d\n", dmn->proTxHash.ToString(), dmn->pdmnState->addr.ToString(), nLastDsq, nDsqThreshold, mmetaman.GetDsqCount()); @@ -1616,7 +1616,7 @@ bool CPrivateSendClientSession::CreateDenominated(CAmount nBalanceToDenominate, && nBalanceToDenominate < nDenomValue); if (fFinal) { fAddFinal = false; // add final denom only once, only the smalest possible one - LogPrint(BCLog::PRIVATESEND, + LogPrint(BCLog::PRIVATESEND, /* Continued */ "CPrivateSendClientSession::CreateDenominated -- 1 - FINAL - nDenomValue: %f, nValueLeft: %f, nBalanceToDenominate: %f\n", (float) nDenomValue / COIN, (float) nValueLeft / COIN, (float) nBalanceToDenominate / COIN); } @@ -1635,7 +1635,7 @@ bool CPrivateSendClientSession::CreateDenominated(CAmount nBalanceToDenominate, currentDenomIt->second++; nValueLeft -= nDenomValue + nOutputFee; nBalanceToDenominate -= nDenomValue; - LogPrint(BCLog::PRIVATESEND, + LogPrint(BCLog::PRIVATESEND, /* Continued */ "CPrivateSendClientSession::CreateDenominated -- 1 - nDenomValue: %f, totalOutputs: %d, nOutputsTotal: %d, nOutputs: %d, nValueLeft: %f, nBalanceToDenominate: %f\n", (float) nDenomValue / COIN, nOutputsTotal + nOutputs, nOutputsTotal, nOutputs, (float) nValueLeft / COIN, (float) nBalanceToDenominate / COIN); } @@ -1650,12 +1650,12 @@ bool CPrivateSendClientSession::CreateDenominated(CAmount nBalanceToDenominate, // denom and that our nValueLeft/nBalanceToDenominate is enough to create one of these denoms, if so, loop again. if (it.second < CPrivateSendClientOptions::GetDenomsGoal() && (nValueLeft >= it.first + nOutputFee) && nBalanceToDenominate > 0) { finished = false; - LogPrint(BCLog::PRIVATESEND, + LogPrint(BCLog::PRIVATESEND, /* Continued */ "CPrivateSendClientSession::CreateDenominated -- 1 - NOT finished - nDenomValue: %f, count: %d, nValueLeft: %f, nBalanceToDenominate: %f\n", (float) it.first / COIN, it.second, (float) nValueLeft / COIN, (float) nBalanceToDenominate / COIN); break; } - LogPrint(BCLog::PRIVATESEND, + LogPrint(BCLog::PRIVATESEND, /* Continued */ "CPrivateSendClientSession::CreateDenominated -- 1 - FINSHED - nDenomValue: %f, count: %d, nValueLeft: %f, nBalanceToDenominate: %f\n", (float) it.first / COIN, it.second, (float) nValueLeft / COIN, (float) nBalanceToDenominate / COIN); } @@ -1698,7 +1698,7 @@ bool CPrivateSendClientSession::CreateDenominated(CAmount nBalanceToDenominate, it->second++; nValueLeft -= nDenomValue + nOutputFee; nBalanceToDenominate -= nDenomValue; - LogPrint(BCLog::PRIVATESEND, + LogPrint(BCLog::PRIVATESEND, /* Continued */ "CPrivateSendClientSession::CreateDenominated -- 2 - nDenomValue: %f, totalOutputs: %d, nOutputsTotal: %d, nOutputs: %d, nValueLeft: %f, nBalanceToDenominate: %f\n", (float) nDenomValue / COIN, nOutputsTotal + nOutputs, nOutputsTotal, nOutputs, (float) nValueLeft / COIN, (float) nBalanceToDenominate / COIN); if (nOutputs + nOutputsTotal >= PRIVATESEND_DENOM_OUTPUTS_THRESHOLD) break; @@ -1712,7 +1712,7 @@ bool CPrivateSendClientSession::CreateDenominated(CAmount nBalanceToDenominate, nOutputsTotal, (float)nValueLeft / COIN, (float)nBalanceToDenominate / COIN); for (const auto it : mapDenomCount) { - LogPrint(BCLog::PRIVATESEND, + LogPrint(BCLog::PRIVATESEND, /* Continued */ "CPrivateSendClientSession::CreateDenominated -- 3 - DONE - nDenomValue: %f, count: %d\n", (float) it.first / COIN, it.second); } diff --git a/src/privatesend/privatesend-server.cpp b/src/privatesend/privatesend-server.cpp index 5213b8b40c3c..bae3e45c62cb 100644 --- a/src/privatesend/privatesend-server.cpp +++ b/src/privatesend/privatesend-server.cpp @@ -51,7 +51,7 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm CPrivateSendAccept dsa; vRecv >> dsa; - LogPrint(BCLog::PRIVATESEND, "DSACCEPT -- nDenom %d (%s) txCollateral %s", dsa.nDenom, CPrivateSend::DenominationToString(dsa.nDenom), dsa.txCollateral.ToString()); + LogPrint(BCLog::PRIVATESEND, "DSACCEPT -- nDenom %d (%s) txCollateral %s", dsa.nDenom, CPrivateSend::DenominationToString(dsa.nDenom), dsa.txCollateral.ToString()); /* Continued */ auto mnList = deterministicMNManager->GetListAtChainTip(); auto dmn = mnList.GetValidMNByCollateral(activeMasternodeInfo.outpoint); @@ -188,7 +188,7 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, const std::string& strComm CPrivateSendEntry entry; vRecv >> entry; - LogPrint(BCLog::PRIVATESEND, "DSVIN -- txCollateral %s", entry.txCollateral->ToString()); + LogPrint(BCLog::PRIVATESEND, "DSVIN -- txCollateral %s", entry.txCollateral->ToString()); /* Continued */ PoolMessage nMessageID = MSG_NOERR; @@ -298,7 +298,7 @@ void CPrivateSendServer::CreateFinalTransaction(CConnman& connman) sort(txNew.vout.begin(), txNew.vout.end(), CompareOutputBIP69()); finalMutableTransaction = txNew; - LogPrint(BCLog::PRIVATESEND, "CPrivateSendServer::CreateFinalTransaction -- finalMutableTransaction=%s", txNew.ToString()); + LogPrint(BCLog::PRIVATESEND, "CPrivateSendServer::CreateFinalTransaction -- finalMutableTransaction=%s", txNew.ToString()); /* Continued */ // request signatures from clients SetState(POOL_STATE_SIGNING); @@ -312,7 +312,7 @@ void CPrivateSendServer::CommitFinalTransaction(CConnman& connman) CTransactionRef finalTransaction = MakeTransactionRef(finalMutableTransaction); uint256 hashTx = finalTransaction->GetHash(); - LogPrint(BCLog::PRIVATESEND, "CPrivateSendServer::CommitFinalTransaction -- finalTransaction=%s", finalTransaction->ToString()); + LogPrint(BCLog::PRIVATESEND, "CPrivateSendServer::CommitFinalTransaction -- finalTransaction=%s", finalTransaction->ToString()); /* Continued */ { // See if the transaction is valid @@ -417,7 +417,7 @@ void CPrivateSendServer::ChargeFees(CConnman& connman) std::random_shuffle(vecOffendersCollaterals.begin(), vecOffendersCollaterals.end()); if (nState == POOL_STATE_ACCEPTING_ENTRIES || nState == POOL_STATE_SIGNING) { - LogPrint(BCLog::PRIVATESEND, "CPrivateSendServer::ChargeFees -- found uncooperative node (didn't %s transaction), charging fees: %s", + LogPrint(BCLog::PRIVATESEND, "CPrivateSendServer::ChargeFees -- found uncooperative node (didn't %s transaction), charging fees: %s", /* Continued */ (nState == POOL_STATE_SIGNING) ? "sign" : "send", vecOffendersCollaterals[0]->ToString()); ConsumeCollateral(connman, vecOffendersCollaterals[0]); } @@ -441,7 +441,7 @@ void CPrivateSendServer::ChargeRandomFees(CConnman& connman) for (const auto& txCollateral : vecSessionCollaterals) { if (GetRandInt(100) > 10) return; - LogPrint(BCLog::PRIVATESEND, "CPrivateSendServer::ChargeRandomFees -- charging random fees, txCollateral=%s", txCollateral->ToString()); + LogPrint(BCLog::PRIVATESEND, "CPrivateSendServer::ChargeRandomFees -- charging random fees, txCollateral=%s", txCollateral->ToString()); /* Continued */ ConsumeCollateral(connman, txCollateral); } } @@ -500,7 +500,7 @@ void CPrivateSendServer::CheckForCompleteQueue(CConnman& connman) SetState(POOL_STATE_ACCEPTING_ENTRIES); CPrivateSendQueue dsq(nSessionDenom, activeMasternodeInfo.outpoint, GetAdjustedTime(), true); - LogPrint(BCLog::PRIVATESEND, "CPrivateSendServer::CheckForCompleteQueue -- queue is ready, signing and relaying (%s) " + LogPrint(BCLog::PRIVATESEND, "CPrivateSendServer::CheckForCompleteQueue -- queue is ready, signing and relaying (%s) " /* Continued */ "with %d participants\n", dsq.ToString(), vecSessionCollaterals.size()); dsq.Sign(); dsq.Relay(connman); diff --git a/src/privatesend/privatesend.cpp b/src/privatesend/privatesend.cpp index 434ebd4dcec2..594e5309eb37 100644 --- a/src/privatesend/privatesend.cpp +++ b/src/privatesend/privatesend.cpp @@ -348,7 +348,7 @@ bool CPrivateSend::IsCollateralValid(const CTransaction& txCollateral) nValueOut += txout.nValue; if (!txout.scriptPubKey.IsPayToPublicKeyHash() && !txout.scriptPubKey.IsUnspendable()) { - LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- Invalid Script, txCollateral=%s", txCollateral.ToString()); + LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- Invalid Script, txCollateral=%s", txCollateral.ToString()); /* Continued */ return false; } } @@ -365,18 +365,18 @@ bool CPrivateSend::IsCollateralValid(const CTransaction& txCollateral) } else if (GetUTXOCoin(txin.prevout, coin)) { nValueIn += coin.out.nValue; } else { - LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- Unknown inputs in collateral transaction, txCollateral=%s", txCollateral.ToString()); + LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- Unknown inputs in collateral transaction, txCollateral=%s", txCollateral.ToString()); /* Continued */ return false; } } //collateral transactions are required to pay out a small fee to the miners if (nValueIn - nValueOut < GetCollateralAmount()) { - LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- did not include enough fees in transaction: fees: %d, txCollateral=%s", nValueOut - nValueIn, txCollateral.ToString()); + LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- did not include enough fees in transaction: fees: %d, txCollateral=%s", nValueOut - nValueIn, txCollateral.ToString()); /* Continued */ return false; } - LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- %s", txCollateral.ToString()); + LogPrint(BCLog::PRIVATESEND, "CPrivateSend::IsCollateralValid -- %s", txCollateral.ToString()); /* Continued */ { LOCK(cs_main); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index f627da19f1d0..32e723a8a662 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -898,7 +898,7 @@ void CTxMemPool::removeProTxConflicts(const CTransaction &tx) if (tx.nType == TRANSACTION_PROVIDER_REGISTER) { CProRegTx proTx; if (!GetTxPayload(tx, proTx)) { - LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); + LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); /* Continued */ return; } @@ -916,7 +916,7 @@ void CTxMemPool::removeProTxConflicts(const CTransaction &tx) } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) { CProUpServTx proTx; if (!GetTxPayload(tx, proTx)) { - LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); + LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); /* Continued */ return; } @@ -929,7 +929,7 @@ void CTxMemPool::removeProTxConflicts(const CTransaction &tx) } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) { CProUpRegTx proTx; if (!GetTxPayload(tx, proTx)) { - LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); + LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); /* Continued */ return; } @@ -938,7 +938,7 @@ void CTxMemPool::removeProTxConflicts(const CTransaction &tx) } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) { CProUpRevTx proTx; if (!GetTxPayload(tx, proTx)) { - LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); + LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); /* Continued */ return; } @@ -1244,7 +1244,7 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const { if (tx.nType == TRANSACTION_PROVIDER_REGISTER) { CProRegTx proTx; if (!GetTxPayload(tx, proTx)) { - LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); + LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); /* Continued */ return true; // i.e. can't decode payload == conflict } if (mapProTxAddresses.count(proTx.addr) || mapProTxPubKeyIDs.count(proTx.keyIDOwner) || mapProTxBlsPubKeyHashes.count(proTx.pubKeyOperator.GetHash())) @@ -1263,7 +1263,7 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const { } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) { CProUpServTx proTx; if (!GetTxPayload(tx, proTx)) { - LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); + LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); /* Continued */ return true; // i.e. can't decode payload == conflict } auto it = mapProTxAddresses.find(proTx.addr); @@ -1271,7 +1271,7 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const { } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REGISTRAR) { CProUpRegTx proTx; if (!GetTxPayload(tx, proTx)) { - LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); + LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); /* Continued */ return true; // i.e. can't decode payload == conflict } @@ -1293,7 +1293,7 @@ bool CTxMemPool::existsProviderTxConflict(const CTransaction &tx) const { } else if (tx.nType == TRANSACTION_PROVIDER_UPDATE_REVOKE) { CProUpRevTx proTx; if (!GetTxPayload(tx, proTx)) { - LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); + LogPrint(BCLog::MEMPOOL, "%s: ERROR: Invalid transaction payload, tx: %s", __func__, tx.ToString()); /* Continued */ return true; // i.e. can't decode payload == conflict } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3fb22e935a5c..81ba4a4658a5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3457,7 +3457,7 @@ bool CWallet::SelectCoinsGroupedByAddresses(std::vector& vecTa std::string strMessage = "SelectCoinsGroupedByAddresses - vecTallyRet:\n"; for (const auto& item : vecTallyRet) strMessage += strprintf(" %s %f\n", EncodeDestination(item.txdest).c_str(), float(item.nAmount)/COIN); - LogPrint(BCLog::SELECTCOINS, "%s", strMessage); + LogPrint(BCLog::SELECTCOINS, "%s", strMessage); /* Continued */ } return vecTallyRet.size() > 0; From ffc38301f79209136a5231bb212201b32f7e4672 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 29 Jul 2020 16:27:45 +0300 Subject: [PATCH 18/31] More of 13153 (fix LogPrintf-s) -- TODO: backport to 0.16 --- src/evo/specialtx.cpp | 2 +- src/init.cpp | 7 ++++--- src/llmq/quorums.cpp | 2 +- src/llmq/quorums_signing_shares.cpp | 2 +- src/net_processing.cpp | 2 +- src/privatesend/privatesend-client.cpp | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/evo/specialtx.cpp b/src/evo/specialtx.cpp index f1bbb3d9c39e..a50cc369340a 100644 --- a/src/evo/specialtx.cpp +++ b/src/evo/specialtx.cpp @@ -139,7 +139,7 @@ bool ProcessSpecialTxsInBlock(const CBlock& block, const CBlockIndex* pindex, CV int64_t nTime5 = GetTimeMicros(); nTimeMerkle += nTime5 - nTime4; LogPrint(BCLog::BENCHMARK, " - CheckCbTxMerkleRoots: %.2fms [%.2fs]\n", 0.001 * (nTime5 - nTime4), nTimeMerkle * 0.000001); } catch (const std::exception& e) { - LogPrintf(strprintf("%s -- failed: %s\n", __func__, e.what()).c_str()); + LogPrintf("%s -- failed: %s\n", __func__, e.what()); return state.DoS(100, false, REJECT_INVALID, "failed-procspectxsinblock"); } diff --git a/src/init.cpp b/src/init.cpp index 8a90241b23d4..30f75ca6614f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -979,12 +979,13 @@ void InitParameterInteraction() } } - if (gArgs.GetArg("-prune", 0) > 0) { + int64_t nPruneArg = gArgs.GetArg("-prune", 0); + if (nPruneArg > 0) { if (gArgs.SoftSetBoolArg("-disablegovernance", true)) { - LogPrintf("%s: parameter interaction: -prune=%d -> setting -disablegovernance=true\n", __func__); + LogPrintf("%s: parameter interaction: -prune=%d -> setting -disablegovernance=true\n", __func__, nPruneArg); } if (gArgs.SoftSetBoolArg("-txindex", false)) { - LogPrintf("%s: parameter interaction: -prune=%d -> setting -txindex=false\n", __func__); + LogPrintf("%s: parameter interaction: -prune=%d -> setting -txindex=false\n", __func__, nPruneArg); } } diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp index fe6c07f3cc21..e8bbbb91a4c7 100644 --- a/src/llmq/quorums.cpp +++ b/src/llmq/quorums.cpp @@ -341,7 +341,7 @@ CQuorumCPtr CQuorumManager::GetQuorum(Consensus::LLMQType llmqType, const uint25 auto quorumIt = mapBlockIndex.find(quorumHash); if (quorumIt == mapBlockIndex.end()) { - LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- block %s not found", __func__, quorumHash.ToString()); + LogPrint(BCLog::LLMQ, "CQuorumManager::%s -- block %s not found\n", __func__, quorumHash.ToString()); return nullptr; } pindexQuorum = quorumIt->second; diff --git a/src/llmq/quorums_signing_shares.cpp b/src/llmq/quorums_signing_shares.cpp index cd3f4061ba6e..5d42a1422156 100644 --- a/src/llmq/quorums_signing_shares.cpp +++ b/src/llmq/quorums_signing_shares.cpp @@ -677,7 +677,7 @@ bool CSigSharesManager::ProcessPendingSigShares(CConnman& connman) if (!pubKeyShare.IsValid()) { // this should really not happen (we already ensured we have the quorum vvec, // so we should also be able to create all pubkey shares) - LogPrintf("CSigSharesManager::%s -- pubKeyShare is invalid, which should not be possible here\n"); + LogPrintf("CSigSharesManager::%s -- pubKeyShare is invalid, which should not be possible here\n", __func__); assert(false); } diff --git a/src/net_processing.cpp b/src/net_processing.cpp index c695b799bc7c..cb4340be122e 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -2380,7 +2380,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr // Note: do not break the flow here if (pfrom->fMasternodeProbe && !pfrom->fFirstMessageIsMNAUTH) { - LogPrint(BCLog::NET, "connection is a masternode probe but first received message is not MNAUTH, peer=%d", pfrom->GetId()); + LogPrint(BCLog::NET, "connection is a masternode probe but first received message is not MNAUTH, peer=%d\n", pfrom->GetId()); pfrom->fDisconnect = true; return false; } diff --git a/src/privatesend/privatesend-client.cpp b/src/privatesend/privatesend-client.cpp index 0465e2c66c14..775db8b1bc9a 100644 --- a/src/privatesend/privatesend-client.cpp +++ b/src/privatesend/privatesend-client.cpp @@ -602,7 +602,7 @@ bool CPrivateSendClientSession::SignFinalTransaction(const CTransaction& finalTr if (!fFound) { // Something went wrong and we'll refuse to sign. It's possible we'll be charged collateral. But that's // better than signing if the transaction doesn't look like what we wanted. - LogPrint(BCLog::PRIVATESEND, "CPrivateSendClientSession::%s -- an output is missing, refusing to sign! txout=%s\n", txout.ToString()); + LogPrint(BCLog::PRIVATESEND, "CPrivateSendClientSession::%s -- an output is missing, refusing to sign! txout=%s\n", __func__, txout.ToString()); UnlockCoins(); keyHolderStorage.ReturnAll(); SetNull(); From 18eebe5251b447bab2806cbf58cc46339c0ad973 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 10 May 2018 20:59:36 -0400 Subject: [PATCH 19/31] Merge #13210: Enable W191 indentation contains tabs and W291 trailing whitespace flake8 checks for Python files 0d31ef4762 Enable W191 and W291 flake8 checks. Remove trailing whitespace from Python files. Convert tabs to spaces. (John Bampton) Pull request description: Tree-SHA512: d062434310d6232469d7ca8e5f2ddb7db7e85cb2a299e609d98bacc318368e43e0777c9f4966df03d50f526bbe27207faa87a7464e62e14671194459a06ad969 --- contrib/devtools/copyright_header.py | 4 ++-- contrib/devtools/lint-python.sh | 4 +++- contrib/devtools/security-check.py | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/devtools/copyright_header.py b/contrib/devtools/copyright_header.py index c81dcddf91d1..2893b4e82589 100755 --- a/contrib/devtools/copyright_header.py +++ b/contrib/devtools/copyright_header.py @@ -508,7 +508,7 @@ def file_has_hashbang(file_lines): def insert_python_header(filename, file_lines, start_year, end_year): if file_has_hashbang(file_lines): - insert_idx = 1 + insert_idx = 1 else: insert_idx = 0 header_lines = get_python_header_lines_to_insert(start_year, end_year) @@ -573,7 +573,7 @@ def insert_cmd(argv): if extension not in ['.h', '.cpp', '.cc', '.c', '.py']: sys.exit("*** cannot insert for file extension %s" % extension) - if extension == '.py': + if extension == '.py': style = 'python' else: style = 'cpp' diff --git a/contrib/devtools/lint-python.sh b/contrib/devtools/lint-python.sh index e1178c4aaa4d..a24d27b97ca5 100755 --- a/contrib/devtools/lint-python.sh +++ b/contrib/devtools/lint-python.sh @@ -62,6 +62,8 @@ export LC_ALL=C # F822 undefined name name in __all__ # F823 local variable name … referenced before assignment # F831 duplicate argument name in function definition +# W191 indentation contains tabs +# W291 trailing whitespace # W292 no newline at end of file # W293 blank line contains whitespace # W504 line break after binary operator # disabled @@ -72,4 +74,4 @@ export LC_ALL=C # W605 invalid escape sequence "x" # disabled # W606 'async' and 'await' are reserved keywords starting with Python 3.7 -git ls-files "*.py" | xargs flake8 --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,W292,W293,W601,W602,W603,W604,W606 #,E741,W504,W605 +git ls-files "*.py" | xargs flake8 --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,W191,W291,W292,W601,W602,W603,W604,W606 #,E741,W504,W605 diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py index 9b9698ba4e22..1ef360d6ee65 100755 --- a/contrib/devtools/security-check.py +++ b/contrib/devtools/security-check.py @@ -150,7 +150,7 @@ def check_PE_DYNAMIC_BASE(executable): def check_PE_HIGH_ENTROPY_VA(executable): '''PIE: DllCharacteristics bit 0x20 signifies high-entropy ASLR''' (arch,bits) = get_PE_dll_characteristics(executable) - if arch == 'i386:x86-64': + if arch == 'i386:x86-64': reqbits = IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA else: # Unnecessary on 32-bit assert(arch == 'i386') From 79999469e43736c08fdefcf33a1509ba06b7e1fd Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Sun, 13 May 2018 23:17:47 -0400 Subject: [PATCH 20/31] Merge #13214: Enable Travis checking for two Python linting rules we are currently not violating 506c5785fb Enable Travis checking for two Python linting rules we are currently not violating (practicalswift) Pull request description: Enable Travis checking for two Python linting rules we are currently not violating: * E101: indentation contains mixed spaces and tabs * E129: visually indented line with same indent as next logical line Tree-SHA512: 955ea5ce4576a5bdd561f9d2bbcfaa82f66a23391c84ddb806830ed15e321e4742457ccc801f457819f626d4a66a1ffcaecee28c3b9f3f907ab8401323743485 --- contrib/devtools/lint-python.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/contrib/devtools/lint-python.sh b/contrib/devtools/lint-python.sh index a24d27b97ca5..edcbfa9d59cc 100755 --- a/contrib/devtools/lint-python.sh +++ b/contrib/devtools/lint-python.sh @@ -8,11 +8,13 @@ export LC_ALL=C +# E101 indentation contains mixed spaces and tabs # E112 expected an indented block # E113 unexpected indentation # E115 expected an indented block (comment) # E116 unexpected indentation (comment) # E125 continuation line with same indent as next logical line +# E129 visually indented line with same indent as next logical line # E131 continuation line unaligned for hanging indent # E133 closing bracket is missing indentation # E223 tab before operator @@ -74,4 +76,4 @@ export LC_ALL=C # W605 invalid escape sequence "x" # disabled # W606 'async' and 'await' are reserved keywords starting with Python 3.7 -git ls-files "*.py" | xargs flake8 --ignore=B,C,E,F,I,N,W --select=E112,E113,E115,E116,E125,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,W191,W291,W292,W601,W602,W603,W604,W606 #,E741,W504,W605 +git ls-files "*.py" | xargs flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,W191,W291,W292,W601,W602,W603,W604,W606 #,E741,W504,W605 From a4fa69a264cf48d5cebac9edc149fe79c6a9601e Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 29 Jul 2020 15:04:03 +0300 Subject: [PATCH 21/31] Fix after 13214 --- test/functional/wallet_txn_clone.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/functional/wallet_txn_clone.py b/test/functional/wallet_txn_clone.py index eeb871ccf640..b7dd5814ed4f 100755 --- a/test/functional/wallet_txn_clone.py +++ b/test/functional/wallet_txn_clone.py @@ -63,8 +63,7 @@ def run_test(self): pos0 = 2*(4+1+36+1+4+1) hex400 = "00902f5009000000" output_len = 16 + 2 + 2 * int("0x" + clone_raw[pos0 + 16 : pos0 + 16 + 2], 0) - if (rawtx1["vout"][0]["value"] == 400 and clone_raw[pos0 : pos0 + 16] != hex400 or - rawtx1["vout"][0]["value"] != 400 and clone_raw[pos0 : pos0 + 16] == hex400): + if (rawtx1["vout"][0]["value"] == 400 and clone_raw[pos0 : pos0 + 16] != hex400 or rawtx1["vout"][0]["value"] != 400 and clone_raw[pos0 : pos0 + 16] == hex400): output0 = clone_raw[pos0 : pos0 + output_len] output1 = clone_raw[pos0 + output_len : pos0 + 2 * output_len] clone_raw = clone_raw[:pos0] + output1 + output0 + clone_raw[pos0 + 2 * output_len:] From 7be2b2456acac4ad677fdd13f4b83dc7f63c202b Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 29 May 2018 15:35:01 +0200 Subject: [PATCH 22/31] Merge #13281: test: Move linters to test/lint, add readme fa3c910bfeab00703c947c5200a64c21225b50ef test: Move linters to test/lint, add readme (MarcoFalke) Pull request description: This moves the checks and linters from `devtools` to a subfolder in `test`. (Motivated by my opinion that the dev tools are mostly for generating code and updating the repo whereas the linters are read-only checks.) Also, adds a readme to clarify that checks and linters are only meant to prevent bugs and user facing issues, not merely stylistic preference or inconsistencies. (This is motivated by the diversity in developers and work flows as well as existing code styles. It would be too disruptive to change all existing code to a single style or too burdensome to force all developers to adhere to a single style. Also note that our style guide is changing, so locking in at the wrong style "too early" would only waste resources.) Tree-SHA512: 9b10e89f2aeaf0c8a9ae248aa891d74e0abf0569f8e5dfd266446efa8bfaf19f0ea0980abf0b0b22f0d8416ee90d7435d21a9f9285b66df43f370b7979173406 --- .travis.yml | 3 ++ ci/build_src.sh | 20 +++++++++---- contrib/devtools/README.md | 17 ----------- doc/developer-notes.md | 4 +-- test/functional/README.md | 2 ++ test/lint/README.md | 29 +++++++++++++++++++ {contrib/devtools => test/lint}/check-doc.py | 0 .../lint}/check-rpc-mappings.py | 0 .../lint}/commit-script-check.sh | 0 .../lint}/git-subtree-check.sh | 0 {contrib/devtools => test/lint}/lint-all.sh | 0 .../lint}/lint-include-guards.sh | 0 .../devtools => test/lint}/lint-includes.sh | 0 {contrib/devtools => test/lint}/lint-logs.sh | 0 .../lint}/lint-python-shebang.sh | 0 .../devtools => test/lint}/lint-python.sh | 0 {contrib/devtools => test/lint}/lint-shell.sh | 0 {contrib/devtools => test/lint}/lint-tests.sh | 0 .../devtools => test/lint}/lint-whitespace.sh | 0 19 files changed, 51 insertions(+), 24 deletions(-) create mode 100644 test/lint/README.md rename {contrib/devtools => test/lint}/check-doc.py (100%) rename {contrib/devtools => test/lint}/check-rpc-mappings.py (100%) rename {contrib/devtools => test/lint}/commit-script-check.sh (100%) rename {contrib/devtools => test/lint}/git-subtree-check.sh (100%) rename {contrib/devtools => test/lint}/lint-all.sh (100%) rename {contrib/devtools => test/lint}/lint-include-guards.sh (100%) rename {contrib/devtools => test/lint}/lint-includes.sh (100%) rename {contrib/devtools => test/lint}/lint-logs.sh (100%) rename {contrib/devtools => test/lint}/lint-python-shebang.sh (100%) rename {contrib/devtools => test/lint}/lint-python.sh (100%) rename {contrib/devtools => test/lint}/lint-shell.sh (100%) rename {contrib/devtools => test/lint}/lint-tests.sh (100%) rename {contrib/devtools => test/lint}/lint-whitespace.sh (100%) diff --git a/.travis.yml b/.travis.yml index 4820ff8c2bb1..bf53804f151b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -137,6 +137,9 @@ before_script: - python3 -c 'import os,sys,fcntl; flags = fcntl.fcntl(sys.stdout, fcntl.F_GETFL); fcntl.fcntl(sys.stdout, fcntl.F_SETFL, flags&~os.O_NONBLOCK);' # Build docker image only for develop branch of the main repo - if [ "$TRAVIS_REPO_SLUG" != "dashpay/dash" -o "$TRAVIS_BRANCH" != "develop" -o "$TRAVIS_PULL_REQUEST" != "false" ]; then export DOCKER_BUILD="false"; echo DOCKER_BUILD=$DOCKER_BUILD; fi + # TODO: Check keys and signed commits + #- if [ "$TRAVIS_REPO_SLUG" = "dashpay/dash" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then while read LINE; do travis_retry gpg --keyserver hkp://subset.pool.sks-keyservers.net --recv-keys $LINE; done < contrib/verify-commits/trusted-keys; fi + #- if [ "$TRAVIS_REPO_SLUG" = "dashpay/dash" -a "$TRAVIS_EVENT_TYPE" = "cron" ]; then travis_wait 30 contrib/verify-commits/verify-commits.sh; fi after_script: - echo $TRAVIS_COMMIT_RANGE - echo $TRAVIS_COMMIT_LOG diff --git a/ci/build_src.sh b/ci/build_src.sh index b60f14a86659..17c51d038750 100755 --- a/ci/build_src.sh +++ b/ci/build_src.sh @@ -12,11 +12,21 @@ unset DISPLAY export CCACHE_COMPRESS=${CCACHE_COMPRESS:-1} export CCACHE_SIZE=${CCACHE_SIZE:-400M} -if [ "$PULL_REQUEST" != "false" ]; then contrib/devtools/commit-script-check.sh $COMMIT_RANGE; fi - -#if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/check-doc.py; fi TODO reenable after all Bitcoin PRs have been merged and docs fully fixed -if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/check-rpc-mappings.py .; fi -if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/lint-all.sh; fi +if [ "$PULL_REQUEST" != "false" ]; then test/lint/commit-script-check.sh $COMMIT_RANGE; fi + +if [ "$CHECK_DOC" = 1 ]; then + # TODO: Verify subtrees + #test/lint/git-subtree-check.sh src/crypto/ctaes + #test/lint/git-subtree-check.sh src/secp256k1 + #test/lint/git-subtree-check.sh src/univalue + #test/lint/git-subtree-check.sh src/leveldb + # TODO: Check docs (reenable after all Bitcoin PRs have been merged and docs fully fixed) + #test/lint/check-doc.py + # Check rpc consistency + test/lint/check-rpc-mappings.py . + # Run all linters + test/lint/lint-all.sh +fi ccache --max-size=$CCACHE_SIZE diff --git a/contrib/devtools/README.md b/contrib/devtools/README.md index 343e3c8d7267..535f2906e523 100644 --- a/contrib/devtools/README.md +++ b/contrib/devtools/README.md @@ -87,23 +87,6 @@ example: BUILDDIR=$PWD/build contrib/devtools/gen-manpages.sh ``` -git-subtree-check.sh -==================== - -Run this script from the root of the repository to verify that a subtree matches the contents of -the commit it claims to have been updated to. - -To use, make sure that you have fetched the upstream repository branch in which the subtree is -maintained: -* for `src/secp256k1`: https://github.com/bitcoin-core/secp256k1.git (branch master) -* for `src/leveldb`: https://github.com/bitcoin-core/leveldb.git (branch bitcoin-fork) -* for `src/univalue`: https://github.com/bitcoin-core/univalue.git (branch master) -* for `src/crypto/ctaes`: https://github.com/bitcoin-core/ctaes.git (branch master) - -Usage: `git-subtree-check.sh DIR (COMMIT)` - -`COMMIT` may be omitted, in which case `HEAD` is used. - github-merge.py =============== diff --git a/doc/developer-notes.md b/doc/developer-notes.md index 47e0532342ec..21fc360bbf91 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -592,7 +592,7 @@ Others are external projects without a tight relationship with our project. Cha be sent upstream but bugfixes may also be prudent to PR against Dash Core so that they can be integrated quickly. Cosmetic changes should be purely taken upstream. -There is a tool in contrib/devtools/git-subtree-check.sh to check a subtree directory for consistency with +There is a tool in `test/lint/git-subtree-check.sh` to check a subtree directory for consistency with its upstream repository. Current subtrees include: @@ -674,7 +674,7 @@ To create a scripted-diff: - `-BEGIN VERIFY SCRIPT-` - `-END VERIFY SCRIPT-` -The scripted-diff is verified by the tool `contrib/devtools/commit-script-check.sh` +The scripted-diff is verified by the tool `test/lint/commit-script-check.sh` Commit [`bb81e173`](https://github.com/bitcoin/bitcoin/commit/bb81e173) is an example of a scripted-diff. diff --git a/test/functional/README.md b/test/functional/README.md index 85600cdc8884..ac1aa64d807d 100644 --- a/test/functional/README.md +++ b/test/functional/README.md @@ -20,6 +20,8 @@ don't have test cases for. - Where possible, try to adhere to [PEP-8 guidelines](https://www.python.org/dev/peps/pep-0008/) - Use a python linter like flake8 before submitting PRs to catch common style nits (eg trailing whitespace, unused imports, etc) +- See [the python lint script](/test/lint/lint-python.sh) that checks for violations that + could lead to bugs and issues in the test code. - Avoid wildcard imports where possible - Use a module-level docstring to describe what the test is testing, and how it is testing it. diff --git a/test/lint/README.md b/test/lint/README.md new file mode 100644 index 000000000000..15974a359820 --- /dev/null +++ b/test/lint/README.md @@ -0,0 +1,29 @@ +This folder contains lint scripts. + +check-doc.py +============ +Check for missing documentation of command line options. + +commit-script-check.sh +====================== +Verification of [scripted diffs](/doc/developer-notes.md#scripted-diffs). + +git-subtree-check.sh +==================== +Run this script from the root of the repository to verify that a subtree matches the contents of +the commit it claims to have been updated to. + +To use, make sure that you have fetched the upstream repository branch in which the subtree is +maintained: +* for `src/secp256k1`: https://github.com/bitcoin-core/secp256k1.git (branch master) +* for `src/leveldb`: https://github.com/bitcoin-core/leveldb.git (branch bitcoin-fork) +* for `src/univalue`: https://github.com/bitcoin-core/univalue.git (branch master) +* for `src/crypto/ctaes`: https://github.com/bitcoin-core/ctaes.git (branch master) + +Usage: `git-subtree-check.sh DIR (COMMIT)` + +`COMMIT` may be omitted, in which case `HEAD` is used. + +lint-all.sh +=========== +Calls other scripts with the `lint-` prefix. diff --git a/contrib/devtools/check-doc.py b/test/lint/check-doc.py similarity index 100% rename from contrib/devtools/check-doc.py rename to test/lint/check-doc.py diff --git a/contrib/devtools/check-rpc-mappings.py b/test/lint/check-rpc-mappings.py similarity index 100% rename from contrib/devtools/check-rpc-mappings.py rename to test/lint/check-rpc-mappings.py diff --git a/contrib/devtools/commit-script-check.sh b/test/lint/commit-script-check.sh similarity index 100% rename from contrib/devtools/commit-script-check.sh rename to test/lint/commit-script-check.sh diff --git a/contrib/devtools/git-subtree-check.sh b/test/lint/git-subtree-check.sh similarity index 100% rename from contrib/devtools/git-subtree-check.sh rename to test/lint/git-subtree-check.sh diff --git a/contrib/devtools/lint-all.sh b/test/lint/lint-all.sh similarity index 100% rename from contrib/devtools/lint-all.sh rename to test/lint/lint-all.sh diff --git a/contrib/devtools/lint-include-guards.sh b/test/lint/lint-include-guards.sh similarity index 100% rename from contrib/devtools/lint-include-guards.sh rename to test/lint/lint-include-guards.sh diff --git a/contrib/devtools/lint-includes.sh b/test/lint/lint-includes.sh similarity index 100% rename from contrib/devtools/lint-includes.sh rename to test/lint/lint-includes.sh diff --git a/contrib/devtools/lint-logs.sh b/test/lint/lint-logs.sh similarity index 100% rename from contrib/devtools/lint-logs.sh rename to test/lint/lint-logs.sh diff --git a/contrib/devtools/lint-python-shebang.sh b/test/lint/lint-python-shebang.sh similarity index 100% rename from contrib/devtools/lint-python-shebang.sh rename to test/lint/lint-python-shebang.sh diff --git a/contrib/devtools/lint-python.sh b/test/lint/lint-python.sh similarity index 100% rename from contrib/devtools/lint-python.sh rename to test/lint/lint-python.sh diff --git a/contrib/devtools/lint-shell.sh b/test/lint/lint-shell.sh similarity index 100% rename from contrib/devtools/lint-shell.sh rename to test/lint/lint-shell.sh diff --git a/contrib/devtools/lint-tests.sh b/test/lint/lint-tests.sh similarity index 100% rename from contrib/devtools/lint-tests.sh rename to test/lint/lint-tests.sh diff --git a/contrib/devtools/lint-whitespace.sh b/test/lint/lint-whitespace.sh similarity index 100% rename from contrib/devtools/lint-whitespace.sh rename to test/lint/lint-whitespace.sh From 481254c86da830e52aeb17b74fdff1cd79a672bf Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 5 Sep 2018 09:21:26 -0400 Subject: [PATCH 23/31] Merge #14115: lint: Make all linters work under the default macOS dev environment (build-osx.md) 341f7c7b0e macOS fix: Check for correct version of flake8 to avoid spurious warnings. The brew installed flake8 version is Python 2 based and does not work. (practicalswift) 908a559f33 macOS fix: Add excludes for checks added in the newer shellcheck version installed by brew (practicalswift) ec4d57bbb3 macOS fix: Work around empty (sub)expression error when using BSD grep (practicalswift) b57d7d92fe macOS fix: Avoid mapfile due to ancient version of bash shipped with macOS (practicalswift) Pull request description: The linters are thoroughly tested under Ubuntu which is what we use in Travis. When reading #14041 I understood that some developers were experiencing problems when running the linters on their local machines. Assuming these local machines were running macOS I installed a fresh macOS VM, followed the instructions in `build-osx.md` and ran the linters. This PR contains the changes needed to make `lint-all.sh` run as expected. Ideally the linters would continuously run also under a Travis macOS environment to make sure we catch these kind of issues before merge. Tree-SHA512: b39c9a970d14d27db1fb592539923c0bc676b5217f415d02fda3f17bf54d46faa172376e8a3ecab07ca68a3acba9aebe00b2b1b2161b2a36b85fbb672e7efb5c --- test/lint/lint-format-strings.sh | 4 +++- test/lint/lint-locale-dependence.sh | 4 ++-- test/lint/lint-python.sh | 10 +++++++++- test/lint/lint-shell-locale.sh | 2 +- test/lint/lint-shell.sh | 12 +++++++++++- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/test/lint/lint-format-strings.sh b/test/lint/lint-format-strings.sh index 17f846d29b57..2c443abf6b03 100755 --- a/test/lint/lint-format-strings.sh +++ b/test/lint/lint-format-strings.sh @@ -33,7 +33,9 @@ if ! python3 -m doctest test/lint/lint-format-strings.py; then fi for S in "${FUNCTION_NAMES_AND_NUMBER_OF_LEADING_ARGUMENTS[@]}"; do IFS="," read -r FUNCTION_NAME SKIP_ARGUMENTS <<< "${S}" - mapfile -t MATCHING_FILES < <(git grep --full-name -l "${FUNCTION_NAME}" -- "*.c" "*.cpp" "*.h" | sort | grep -vE "^src/(leveldb|secp256k1|tinyformat|univalue)") + for MATCHING_FILE in $(git grep --full-name -l "${FUNCTION_NAME}" -- "*.c" "*.cpp" "*.h" | sort | grep -vE "^src/(leveldb|secp256k1|tinyformat|univalue)"); do + MATCHING_FILES+=("${MATCHING_FILE}") + done if ! test/lint/lint-format-strings.py --skip-arguments "${SKIP_ARGUMENTS}" "${FUNCTION_NAME}" "${MATCHING_FILES[@]}"; then EXIT_CODE=1 fi diff --git a/test/lint/lint-locale-dependence.sh b/test/lint/lint-locale-dependence.sh index 98814ce4b98a..93de43f00455 100755 --- a/test/lint/lint-locale-dependence.sh +++ b/test/lint/lint-locale-dependence.sh @@ -199,11 +199,11 @@ REGEXP_IGNORE_KNOWN_VIOLATIONS=$(join_array "|" "${KNOWN_VIOLATIONS[@]}") # Invoke "git grep" only once in order to minimize run-time REGEXP_LOCALE_DEPENDENT_FUNCTIONS=$(join_array "|" "${LOCALE_DEPENDENT_FUNCTIONS[@]}") -GIT_GREP_OUTPUT=$(git grep -E "[^a-zA-Z0-9_\`'\"<>](${REGEXP_LOCALE_DEPENDENT_FUNCTIONS}(|_r|_s))[^a-zA-Z0-9_\`'\"<>]" -- "*.cpp" "*.h") +GIT_GREP_OUTPUT=$(git grep -E "[^a-zA-Z0-9_\`'\"<>](${REGEXP_LOCALE_DEPENDENT_FUNCTIONS}(_r|_s)?)[^a-zA-Z0-9_\`'\"<>]" -- "*.cpp" "*.h") EXIT_CODE=0 for LOCALE_DEPENDENT_FUNCTION in "${LOCALE_DEPENDENT_FUNCTIONS[@]}"; do - MATCHES=$(grep -E "[^a-zA-Z0-9_\`'\"<>]${LOCALE_DEPENDENT_FUNCTION}(|_r|_s)[^a-zA-Z0-9_\`'\"<>]" <<< "${GIT_GREP_OUTPUT}" | \ + MATCHES=$(grep -E "[^a-zA-Z0-9_\`'\"<>]${LOCALE_DEPENDENT_FUNCTION}(_r|_s)?[^a-zA-Z0-9_\`'\"<>]" <<< "${GIT_GREP_OUTPUT}" | \ grep -vE "\.(c|cpp|h):\s*(//|\*|/\*|\").*${LOCALE_DEPENDENT_FUNCTION}" | \ grep -vE 'fprintf\(.*(stdout|stderr)') if [[ ${REGEXP_IGNORE_EXTERNAL_DEPENDENCIES} != "" ]]; then diff --git a/test/lint/lint-python.sh b/test/lint/lint-python.sh index edcbfa9d59cc..213accf2bb2a 100755 --- a/test/lint/lint-python.sh +++ b/test/lint/lint-python.sh @@ -76,4 +76,12 @@ export LC_ALL=C # W605 invalid escape sequence "x" # disabled # W606 'async' and 'await' are reserved keywords starting with Python 3.7 -git ls-files "*.py" | xargs flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,W191,W291,W292,W601,W602,W603,W604,W606 #,E741,W504,W605 +if ! command -v flake8 > /dev/null; then + echo "Skipping Python linting since flake8 is not installed. Install by running \"pip3 install flake8\"" + exit 0 +elif PYTHONWARNINGS="ignore" flake8 --version | grep -q "Python 2"; then + echo "Skipping Python linting since flake8 is running under Python 2. Install the Python 3 version of flake8 by running \"pip3 install flake8\"" + exit 0 +fi + +PYTHONWARNINGS="ignore" git ls-files "*.py" | xargs flake8 --ignore=B,C,E,F,I,N,W --select=E101,E112,E113,E115,E116,E125,E129,E131,E133,E223,E224,E242,E266,E271,E272,E273,E274,E275,E304,E306,E401,E402,E502,E701,E702,E703,E714,E721,E742,E743,F401,E901,E902,F402,F404,F406,F407,F601,F602,F621,F622,F631,F701,F702,F703,F704,F705,F706,F707,F811,F812,F821,F822,F823,F831,W191,W291,W292,W601,W602,W603,W604,W606 #,E741,W504,W605 diff --git a/test/lint/lint-shell-locale.sh b/test/lint/lint-shell-locale.sh index d78bac2d474f..729942b00516 100755 --- a/test/lint/lint-shell-locale.sh +++ b/test/lint/lint-shell-locale.sh @@ -15,7 +15,7 @@ for SHELL_SCRIPT in $(git ls-files -- "*.sh" | grep -vE "src/(secp256k1|univalue if grep -q "# This script is intentionally locale dependent by not setting \"export LC_ALL=C\"" "${SHELL_SCRIPT}"; then continue fi - FIRST_NON_COMMENT_LINE=$(grep -vE '^(#.*|)$' "${SHELL_SCRIPT}" | head -1) + FIRST_NON_COMMENT_LINE=$(grep -vE '^(#.*)?$' "${SHELL_SCRIPT}" | head -1) if [[ ${FIRST_NON_COMMENT_LINE} != "export LC_ALL=C" ]]; then echo "Missing \"export LC_ALL=C\" (to avoid locale dependence) as first non-comment non-empty line in ${SHELL_SCRIPT}" EXIT_CODE=1 diff --git a/test/lint/lint-shell.sh b/test/lint/lint-shell.sh index 5ac1752ff7c9..e5dcc7afdb63 100755 --- a/test/lint/lint-shell.sh +++ b/test/lint/lint-shell.sh @@ -16,7 +16,14 @@ if [ "$TRAVIS" = "true" ]; then unset LC_ALL fi +if ! command -v shellcheck > /dev/null; then + echo "Skipping shell linting since shellcheck is not installed." + exit 0 +fi + # Disabled warnings: +# SC1087: Use braces when expanding arrays, e.g. ${array[idx]} (or ${var}[.. to quiet). +# SC1117: Backslash is literal in "\.". Prefer explicit escaping: "\\.". # SC2001: See if you can use ${variable//search/replace} instead. # SC2004: $/${} is unnecessary on arithmetic variables. # SC2005: Useless echo? Instead of 'echo $(cmd)', just use 'cmd'. @@ -33,5 +40,8 @@ fi # SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. # SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. # SC2181: Check exit code directly with e.g. 'if mycmd;', not indirectly with $?. -shellcheck -e SC2001,SC2004,SC2005,SC2006,SC2016,SC2028,SC2046,SC2048,SC2066,SC2086,SC2116,SC2148,SC2162,SC2166,SC2181 \ +# SC2206: Quote to prevent word splitting, or split robustly with mapfile or read -a. +# SC2207: Prefer mapfile or read -a to split command output (or quote to avoid splitting). +# SC2230: which is non-standard. Use builtin 'command -v' instead. +shellcheck -e SC1087,SC1117,SC2001,SC2004,SC2005,SC2006,SC2016,SC2028,SC2046,SC2048,SC2066,SC2086,SC2116,SC2148,SC2162,SC2166,SC2181,SC2206,SC2207,SC2230 \ $(git ls-files -- "*.sh" | grep -vE 'src/(secp256k1|univalue)/') From 27aef400915d4a31c54be695d659392f1bfefcdb Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 5 Mar 2019 09:40:19 -0500 Subject: [PATCH 24/31] Merge #15534: [test] lint-format-strings: open files sequentially (fix for OS X) 21be609b49 In lint-format-strings, open files sequentially (Glenn Willen) Pull request description: In lint-format-strings, we use python argparse to read our file arguments. In this mode, argparse opens all the files simultaneously. On OS X, where the default filehandle limit is 128, this causes the lint to fail. Instead, ask argparse for our filename arguments as strings, and open them one at a time using 'with open'. Tree-SHA512: 4c7dabf98818a7c5d83ab10c61b89a26957fe399e39e933e30c561cb45c5e8ba6f6aedcde8343da0c32ee340289a8897db6a33708e35ee381334ee27e3f4d356 --- test/lint/lint-format-strings.py | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/test/lint/lint-format-strings.py b/test/lint/lint-format-strings.py index c07dfe317b5f..d60dbe454d8d 100755 --- a/test/lint/lint-format-strings.py +++ b/test/lint/lint-format-strings.py @@ -226,27 +226,27 @@ def main(): parser.add_argument("--skip-arguments", type=int, help="number of arguments before the format string " "argument (e.g. 1 in the case of fprintf)", default=0) parser.add_argument("function_name", help="function name (e.g. fprintf)", default=None) - parser.add_argument("file", type=argparse.FileType("r", encoding="utf-8"), nargs="*", help="C++ source code file (e.g. foo.cpp)") + parser.add_argument("file", nargs="*", help="C++ source code file (e.g. foo.cpp)") args = parser.parse_args() - exit_code = 0 - for f in args.file: - for function_call_str in parse_function_calls(args.function_name, f.read()): - parts = parse_function_call_and_arguments(args.function_name, function_call_str) - relevant_function_call_str = unescape("".join(parts))[:512] - if (f.name, relevant_function_call_str) in FALSE_POSITIVES: - continue - if len(parts) < 3 + args.skip_arguments: - exit_code = 1 - print("{}: Could not parse function call string \"{}(...)\": {}".format(f.name, args.function_name, relevant_function_call_str)) - continue - argument_count = len(parts) - 3 - args.skip_arguments - format_str = parse_string_content(parts[1 + args.skip_arguments]) - format_specifier_count = count_format_specifiers(format_str) - if format_specifier_count != argument_count: - exit_code = 1 - print("{}: Expected {} argument(s) after format string but found {} argument(s): {}".format(f.name, format_specifier_count, argument_count, relevant_function_call_str)) - continue + for filename in args.file: + with open(filename, "r", encoding="utf-8") as f: + for function_call_str in parse_function_calls(args.function_name, f.read()): + parts = parse_function_call_and_arguments(args.function_name, function_call_str) + relevant_function_call_str = unescape("".join(parts))[:512] + if (f.name, relevant_function_call_str) in FALSE_POSITIVES: + continue + if len(parts) < 3 + args.skip_arguments: + exit_code = 1 + print("{}: Could not parse function call string \"{}(...)\": {}".format(f.name, args.function_name, relevant_function_call_str)) + continue + argument_count = len(parts) - 3 - args.skip_arguments + format_str = parse_string_content(parts[1 + args.skip_arguments]) + format_specifier_count = count_format_specifiers(format_str) + if format_specifier_count != argument_count: + exit_code = 1 + print("{}: Expected {} argument(s) after format string but found {} argument(s): {}".format(f.name, format_specifier_count, argument_count, relevant_function_call_str)) + continue sys.exit(exit_code) From 2e7f07ebebd1b1f98e67d0f9ac122a49ca5d7638 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Wed, 16 Jan 2019 15:24:32 +0100 Subject: [PATCH 25/31] Fix warnings introduced in shellcheck v0.6.0 (Partial Merge: #15166) --- test/lint/lint-format-strings.sh | 28 ++++++++++++++-------------- test/lint/lint-whitespace.sh | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/test/lint/lint-format-strings.sh b/test/lint/lint-format-strings.sh index 2c443abf6b03..c994ae3f4de7 100755 --- a/test/lint/lint-format-strings.sh +++ b/test/lint/lint-format-strings.sh @@ -11,20 +11,20 @@ export LC_ALL=C FUNCTION_NAMES_AND_NUMBER_OF_LEADING_ARGUMENTS=( - FatalError,0 - fprintf,1 - LogConnectFailure,1 - LogPrint,1 - LogPrintf,0 - printf,0 - snprintf,2 - sprintf,1 - strprintf,0 - vfprintf,1 - vprintf,1 - vsnprintf,1 - vsprintf,1 - WalletLogPrintf,0 + "FatalError,0" + "fprintf,1" + "LogConnectFailure,1" + "LogPrint,1" + "LogPrintf,0" + "printf,0" + "snprintf,2" + "sprintf,1" + "strprintf,0" + "vfprintf,1" + "vprintf,1" + "vsnprintf,1" + "vsprintf,1" + "WalletLogPrintf,0" ) EXIT_CODE=0 diff --git a/test/lint/lint-whitespace.sh b/test/lint/lint-whitespace.sh index d5f3ca1cf461..98591719c646 100755 --- a/test/lint/lint-whitespace.sh +++ b/test/lint/lint-whitespace.sh @@ -23,7 +23,7 @@ while getopts "?" opt; do done if [ -z "${COMMIT_RANGE}" ]; then - if [ "$1" ]; then + if [ -n "$1" ]; then COMMIT_RANGE="HEAD~$1...HEAD" else COMMIT_RANGE="HEAD" From 35fbb5992fbca89a55ce4cb6b00aa4d48bfa37c5 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 29 Jul 2020 16:24:36 +0300 Subject: [PATCH 26/31] More of "export LC_ALL=C" --- ci/build_depends.sh | 4 +++- ci/build_src.sh | 4 +++- ci/matrix.sh | 4 +++- ci/test_integrationtests.sh | 4 +++- ci/test_unittests.sh | 4 +++- contrib/auto_gdb/dash_dbg.sh | 2 ++ contrib/verify-commits/verify-commits.sh | 2 ++ docker/build-docker.sh | 2 ++ docker/push-docker.sh | 2 ++ 9 files changed, 23 insertions(+), 5 deletions(-) diff --git a/ci/build_depends.sh b/ci/build_depends.sh index d4e7cd0e59ca..fec2cad4de0f 100755 --- a/ci/build_depends.sh +++ b/ci/build_depends.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash - +# # This script is executed inside the builder image +export LC_ALL=C + set -e source ./ci/matrix.sh diff --git a/ci/build_src.sh b/ci/build_src.sh index 17c51d038750..5881c6ed14d4 100755 --- a/ci/build_src.sh +++ b/ci/build_src.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash - +# # This script is executed inside the builder image +export LC_ALL=C + set -e source ./ci/matrix.sh diff --git a/ci/matrix.sh b/ci/matrix.sh index 5203850c7ce8..b74b2e01b5b2 100755 --- a/ci/matrix.sh +++ b/ci/matrix.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash - +# # This script is meant to be sourced into the actual build script. It contains the build matrix and will set all # necessary environment variables for the request build target +export LC_ALL=C + export BUILD_TARGET=${BUILD_TARGET:-linux64} export PULL_REQUEST=${PULL_REQUEST:-false} export JOB_NUMBER=${JOB_NUMBER:-1} diff --git a/ci/test_integrationtests.sh b/ci/test_integrationtests.sh index aed4c629a3a6..8d04335b7872 100755 --- a/ci/test_integrationtests.sh +++ b/ci/test_integrationtests.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash - +# # This script is executed inside the builder image +export LC_ALL=C + set -e PASS_ARGS="$@" diff --git a/ci/test_unittests.sh b/ci/test_unittests.sh index 1a6aecd2909e..0848fc5b5023 100755 --- a/ci/test_unittests.sh +++ b/ci/test_unittests.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash - +# # This script is executed inside the builder image +export LC_ALL=C + set -e source ./ci/matrix.sh diff --git a/contrib/auto_gdb/dash_dbg.sh b/contrib/auto_gdb/dash_dbg.sh index ebe3ed54ec9c..b1e1b2fd9c1d 100755 --- a/contrib/auto_gdb/dash_dbg.sh +++ b/contrib/auto_gdb/dash_dbg.sh @@ -1,4 +1,6 @@ #!/bin/bash # use testnet settings, if you need mainnet, use ~/.dashcore/dashd.pid file instead +export LC_ALL=C + dash_pid=$(<~/.dashcore/testnet3/dashd.pid) sudo gdb -batch -ex "source debug.gdb" dashd ${dash_pid} diff --git a/contrib/verify-commits/verify-commits.sh b/contrib/verify-commits/verify-commits.sh index 78320a4ce3c0..7e401ac3a3ab 100755 --- a/contrib/verify-commits/verify-commits.sh +++ b/contrib/verify-commits/verify-commits.sh @@ -3,6 +3,8 @@ # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. +export LC_ALL=C + DIR=$(dirname "$0") [ "/${DIR#/}" != "$DIR" ] && DIR=$(dirname "$(pwd)/$0") diff --git a/docker/build-docker.sh b/docker/build-docker.sh index 51aff468b3bf..c006e85f0992 100755 --- a/docker/build-docker.sh +++ b/docker/build-docker.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +export LC_ALL=C + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR/.. diff --git a/docker/push-docker.sh b/docker/push-docker.sh index e4bace009f6e..3f05255046c6 100755 --- a/docker/push-docker.sh +++ b/docker/push-docker.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +export LC_ALL=C + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR/.. From 6029f290b85c378c9113a6c8953674aae3292600 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 29 Jul 2020 16:26:06 +0300 Subject: [PATCH 27/31] Add missing `encoding="utf8"` --- contrib/devtools/circular-dependencies.py | 2 +- test/util/rpcauth-test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/devtools/circular-dependencies.py b/contrib/devtools/circular-dependencies.py index d544d5c37134..abfa5ed5ae7b 100755 --- a/contrib/devtools/circular-dependencies.py +++ b/contrib/devtools/circular-dependencies.py @@ -37,7 +37,7 @@ def module_name(path): # TODO: implement support for multiple include directories for arg in sorted(files.keys()): module = files[arg] - with open(arg, 'r') as f: + with open(arg, 'r', encoding="utf8") as f: for line in f: match = RE.match(line) if match: diff --git a/test/util/rpcauth-test.py b/test/util/rpcauth-test.py index bd9a24fe6797..53058dc394af 100755 --- a/test/util/rpcauth-test.py +++ b/test/util/rpcauth-test.py @@ -18,7 +18,7 @@ def setUp(self): config_path = os.path.abspath( os.path.join(os.sep, os.path.abspath(os.path.dirname(__file__)), "../config.ini")) - with open(config_path) as config_file: + with open(config_path, encoding="utf8") as config_file: config.read_file(config_file) sys.path.insert(0, os.path.dirname(config['environment']['RPCAUTH'])) self.rpcauth = importlib.import_module('rpcauth') From 2910bf0d494f571d5c51ea211b16e54dce779cda Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 29 Jul 2020 16:29:43 +0300 Subject: [PATCH 28/31] Update lint-format-strings.py --- test/lint/lint-format-strings.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/lint/lint-format-strings.py b/test/lint/lint-format-strings.py index d60dbe454d8d..bcf10b21c0a2 100755 --- a/test/lint/lint-format-strings.py +++ b/test/lint/lint-format-strings.py @@ -13,16 +13,20 @@ import sys FALSE_POSITIVES = [ + ("src/batchedlogger.h", "strprintf(fmt, args...)"), ("src/dbwrapper.cpp", "vsnprintf(p, limit - p, format, backup_ap)"), ("src/index/base.cpp", "FatalError(const char* fmt, const Args&... args)"), ("src/netbase.cpp", "LogConnectFailure(bool manual_connection, const char* fmt, const Args&... args)"), + ("src/qt/networkstyle.cpp", "strprintf(appName, gArgs.GetDevNetName())"), + ("src/qt/networkstyle.cpp", "strprintf(titleAddText, gArgs.GetDevNetName())"), + ("src/rpc/rpcevo.cpp", "strprintf(it->second, nParamNum)"), + ("src/stacktraces.cpp", "strprintf(fmtStr, i, si.pc, lstr, fstr)"), ("src/util.cpp", "strprintf(_(COPYRIGHT_HOLDERS), _(COPYRIGHT_HOLDERS_SUBSTITUTION))"), ("src/util.cpp", "strprintf(COPYRIGHT_HOLDERS, COPYRIGHT_HOLDERS_SUBSTITUTION)"), ("src/wallet/wallet.h", "WalletLogPrintf(std::string fmt, Params... parameters)"), ("src/wallet/wallet.h", "LogPrintf((\"%s \" + fmt).c_str(), GetDisplayName(), parameters...)"), ] - def parse_function_calls(function_name, source_code): """Return an array with all calls to function function_name in string source_code. Preprocessor directives and C++ style comments ("//") in source_code are removed. From bdb479db4bd152e9f8d11a0c311f0a19f3a2f2fb Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 29 Jul 2020 16:29:56 +0300 Subject: [PATCH 29/31] Update lint-locale-dependence.sh --- test/lint/lint-locale-dependence.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/lint/lint-locale-dependence.sh b/test/lint/lint-locale-dependence.sh index 93de43f00455..7531c2fa31ab 100755 --- a/test/lint/lint-locale-dependence.sh +++ b/test/lint/lint-locale-dependence.sh @@ -1,14 +1,18 @@ #!/bin/bash export LC_ALL=C + KNOWN_VIOLATIONS=( "src/base58.cpp:.*isspace" - "src/bitcoin-tx.cpp.*stoul" - "src/bitcoin-tx.cpp.*trim_right" - "src/bitcoin-tx.cpp:.*atoi" + "src/bench/string_cast.cpp.*atoi" + "src/dash-tx.cpp.*stoul" + "src/dash-tx.cpp.*trim_right" + "src/dash-tx.cpp:.*atoi" "src/core_read.cpp.*is_digit" "src/dbwrapper.cpp.*stoul" "src/dbwrapper.cpp:.*vsnprintf" + "src/governance/governance-validators.cpp.*isspace" + "src/governance/governance-validators.cpp.*tolower" "src/httprpc.cpp.*trim" "src/init.cpp:.*atoi" "src/netbase.cpp.*to_lower" @@ -16,6 +20,11 @@ KNOWN_VIOLATIONS=( "src/qt/rpcconsole.cpp:.*isdigit" "src/rest.cpp:.*strtol" "src/rpc/server.cpp.*to_upper" + "src/rpc/blockchain.cpp.*atoi" + "src/rpc/governance.cpp.*atoi" + "src/rpc/masternode.cpp.*atoi" + "src/rpc/masternode.cpp.*tolower" + "src/rpc/server.cpp.*tolower" "src/test/dbwrapper_tests.cpp:.*snprintf" "src/test/getarg_tests.cpp.*split" "src/torcontrol.cpp:.*atoi" @@ -34,6 +43,7 @@ KNOWN_VIOLATIONS=( "src/utilstrencodings.cpp:.*strtoul" "src/utilstrencodings.cpp:.*strtoull" "src/utilstrencodings.h:.*atoi" + "src/wallet/wallet.cpp:.*atoi" ) REGEXP_IGNORE_EXTERNAL_DEPENDENCIES="^src/(crypto/ctaes/|leveldb/|secp256k1/|tinyformat.h|univalue/)" From f7218d18997716c4abddf16aed2e21d8b9d185c1 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 29 Jul 2020 16:42:12 +0300 Subject: [PATCH 30/31] Make shellcheck happy --- ci/build_src.sh | 2 +- ci/test_integrationtests.sh | 6 ++++-- contrib/macdeploy/detached-sig-create.sh | 2 +- contrib/qos/tc.sh | 4 ++-- contrib/verify-commits/verify-commits.sh | 4 ++-- contrib/windeploy/detached-sig-create.sh | 2 +- docker/build-docker.sh | 2 +- docker/push-docker.sh | 2 +- test/lint/git-subtree-check.sh | 4 ++-- 9 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ci/build_src.sh b/ci/build_src.sh index 5881c6ed14d4..4fa3e9de37af 100755 --- a/ci/build_src.sh +++ b/ci/build_src.sh @@ -38,7 +38,7 @@ fi BITCOIN_CONFIG_ALL="--disable-dependency-tracking --prefix=$BUILD_DIR/depends/$HOST --bindir=$OUT_DIR/bin --libdir=$OUT_DIR/lib" -test -n "$USE_SHELL" && eval '"$USE_SHELL" -c "./autogen.sh"' || ./autogen.sh +( test -n "$USE_SHELL" && eval '"$USE_SHELL" -c "./autogen.sh"' ) || ./autogen.sh rm -rf build-ci mkdir build-ci diff --git a/ci/test_integrationtests.sh b/ci/test_integrationtests.sh index 8d04335b7872..cdf18d741b57 100755 --- a/ci/test_integrationtests.sh +++ b/ci/test_integrationtests.sh @@ -6,7 +6,7 @@ export LC_ALL=C set -e -PASS_ARGS="$@" +PASS_ARGS="$*" source ./ci/matrix.sh @@ -42,7 +42,9 @@ echo "Collecting logs..." BASEDIR=$(ls testdatadirs) if [ "$BASEDIR" != "" ]; then mkdir testlogs - for d in $(ls testdatadirs/$BASEDIR | grep -v '^cache$'); do + for d in testdatadirs/$BASEDIR; do + [[ -e "$d" ]] || break # found nothing + [[ "$d" == "cache" ]] && continue # skip cache dir mkdir testlogs/$d ./test/functional/combine_logs.py -c ./testdatadirs/$BASEDIR/$d > ./testlogs/$d/combined.log ./test/functional/combine_logs.py --html ./testdatadirs/$BASEDIR/$d > ./testlogs/$d/combined.html diff --git a/contrib/macdeploy/detached-sig-create.sh b/contrib/macdeploy/detached-sig-create.sh index d95095d46b8a..44e6c7d66c42 100755 --- a/contrib/macdeploy/detached-sig-create.sh +++ b/contrib/macdeploy/detached-sig-create.sh @@ -14,7 +14,7 @@ TEMPLIST=${TEMPDIR}/signatures.txt OUT=signature-osx.tar.gz OUTROOT=osx -if [ ! -n "$1" ]; then +if [ -z "$1" ]; then echo "usage: $0 " echo "example: $0 -s MyIdentity" exit 1 diff --git a/contrib/qos/tc.sh b/contrib/qos/tc.sh index 109e546f0e42..145a5fd06f50 100644 --- a/contrib/qos/tc.sh +++ b/contrib/qos/tc.sh @@ -31,7 +31,7 @@ tc class add dev ${IF} parent 1:1 classid 1:11 htb rate ${LIMIT} ceil ${LIMIT} p tc filter add dev ${IF} parent 1: protocol ip prio 1 handle 1 fw classid 1:10 tc filter add dev ${IF} parent 1: protocol ip prio 2 handle 2 fw classid 1:11 -if [ ! -z "${LOCALNET_V6}" ] ; then +if [ -n "${LOCALNET_V6}" ] ; then # v6 cannot have the same priority value as v4 tc filter add dev ${IF} parent 1: protocol ipv6 prio 3 handle 1 fw classid 1:10 tc filter add dev ${IF} parent 1: protocol ipv6 prio 4 handle 2 fw classid 1:11 @@ -54,7 +54,7 @@ fi iptables -t mangle -A OUTPUT -p tcp -m tcp --dport 9999 ! -d ${LOCALNET_V4} -j MARK --set-mark 0x2 iptables -t mangle -A OUTPUT -p tcp -m tcp --sport 9999 ! -d ${LOCALNET_V4} -j MARK --set-mark 0x2 -if [ ! -z "${LOCALNET_V6}" ] ; then +if [ -n "${LOCALNET_V6}" ] ; then ip6tables -t mangle -A OUTPUT -p tcp -m tcp --dport 9999 ! -d ${LOCALNET_V6} -j MARK --set-mark 0x4 ip6tables -t mangle -A OUTPUT -p tcp -m tcp --sport 9999 ! -d ${LOCALNET_V6} -j MARK --set-mark 0x4 fi diff --git a/contrib/verify-commits/verify-commits.sh b/contrib/verify-commits/verify-commits.sh index 7e401ac3a3ab..1bd1d51e42fb 100755 --- a/contrib/verify-commits/verify-commits.sh +++ b/contrib/verify-commits/verify-commits.sh @@ -96,9 +96,9 @@ while true; do FILE_HASHES="" for FILE in $(git ls-tree --full-tree -r --name-only "$CURRENT_COMMIT" | LC_ALL=C sort); do if [ "$HAVE_GNU_SHA512" = 1 ]; then - HASH=$(git cat-file blob "$CURRENT_COMMIT":"$FILE" | sha512sum | { read FIRST OTHER; echo $FIRST; } ) + HASH=$(git cat-file blob "$CURRENT_COMMIT":"$FILE" | sha512sum | { read FIRST _; echo $FIRST; } ) else - HASH=$(git cat-file blob "$CURRENT_COMMIT":"$FILE" | shasum -a 512 | { read FIRST OTHER; echo $FIRST; } ) + HASH=$(git cat-file blob "$CURRENT_COMMIT":"$FILE" | shasum -a 512 | { read FIRST _; echo $FIRST; } ) fi [ "$FILE_HASHES" != "" ] && FILE_HASHES="$FILE_HASHES"' ' diff --git a/contrib/windeploy/detached-sig-create.sh b/contrib/windeploy/detached-sig-create.sh index 15f8108cf011..0cafc8558e63 100755 --- a/contrib/windeploy/detached-sig-create.sh +++ b/contrib/windeploy/detached-sig-create.sh @@ -8,7 +8,7 @@ if [ -z "$OSSLSIGNCODE" ]; then OSSLSIGNCODE=osslsigncode fi -if [ ! -n "$1" ]; then +if [ -z "$1" ]; then echo "usage: $0 " echo "example: $0 -key codesign.key" exit 1 diff --git a/docker/build-docker.sh b/docker/build-docker.sh index c006e85f0992..2fc34b2d0cc8 100755 --- a/docker/build-docker.sh +++ b/docker/build-docker.sh @@ -3,7 +3,7 @@ export LC_ALL=C DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $DIR/.. +cd $DIR/.. || exit DOCKER_IMAGE=${DOCKER_IMAGE:-dashpay/dashd-develop} DOCKER_TAG=${DOCKER_TAG:-latest} diff --git a/docker/push-docker.sh b/docker/push-docker.sh index 3f05255046c6..88ba8448001b 100755 --- a/docker/push-docker.sh +++ b/docker/push-docker.sh @@ -3,7 +3,7 @@ export LC_ALL=C DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -cd $DIR/.. +cd $DIR/.. || exit DOCKER_IMAGE=${DOCKER_IMAGE:-dashpay/dashd-develop} DOCKER_TAG=${DOCKER_TAG:-latest} diff --git a/test/lint/git-subtree-check.sh b/test/lint/git-subtree-check.sh index d487c1d9bd19..f765e64b1630 100755 --- a/test/lint/git-subtree-check.sh +++ b/test/lint/git-subtree-check.sh @@ -19,7 +19,7 @@ find_latest_squash() sub= git log --grep="^git-subtree-dir: $dir/*\$" \ --pretty=format:'START %H%n%s%n%n%b%nEND%n' "$COMMIT" | - while read a b junk; do + while read a b _; do case "$a" in START) sq="$b" ;; git-subtree-mainline:) main="$b" ;; @@ -49,7 +49,7 @@ if [ -z "$latest_squash" ]; then fi set $latest_squash -old=$1 +# old=$1 rev=$2 if [ "d$(git cat-file -t $rev 2>/dev/null)" != dcommit ]; then echo "ERROR: subtree commit $rev unavailable. Fetch/update the subtree repository" >&2 From db206a0e7cce08da12e63669fc0b834ed6d91a7d Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 30 Jul 2020 03:11:35 +0300 Subject: [PATCH 31/31] Fix test_integrationtests.sh --- ci/test_integrationtests.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ci/test_integrationtests.sh b/ci/test_integrationtests.sh index cdf18d741b57..9aca412c35c1 100755 --- a/ci/test_integrationtests.sh +++ b/ci/test_integrationtests.sh @@ -42,9 +42,10 @@ echo "Collecting logs..." BASEDIR=$(ls testdatadirs) if [ "$BASEDIR" != "" ]; then mkdir testlogs - for d in testdatadirs/$BASEDIR; do - [[ -e "$d" ]] || break # found nothing - [[ "$d" == "cache" ]] && continue # skip cache dir + TESTDATADIRS=$(ls testdatadirs/$BASEDIR) + for d in $TESTDATADIRS; do + [[ "$d" ]] || break # found nothing + [[ "$d" != "cache" ]] || continue # skip cache dir mkdir testlogs/$d ./test/functional/combine_logs.py -c ./testdatadirs/$BASEDIR/$d > ./testlogs/$d/combined.log ./test/functional/combine_logs.py --html ./testdatadirs/$BASEDIR/$d > ./testlogs/$d/combined.html