From d476537d864c8fef7d0d314326a5c4d124da6e06 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 20 Oct 2020 19:54:44 +0100 Subject: [PATCH] scripted-diff: Remove BOOST_STATIC_ASSERT -BEGIN VERIFY SCRIPT- sed -i 's/BOOST_STATIC_ASSERT(/static_assert(/' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; sed -i ':a;N;$!ba;s/#include \n//' ./src/*.h ./src/*.cpp ./src/*/*.h* ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ; -END VERIFY SCRIPT- --- src/chainparams.cpp | 6 +++--- src/crypto/equihash.cpp | 8 ++++---- src/crypto/equihash.h | 7 +++---- src/main.cpp | 9 ++++----- src/policy/policy.h | 4 ++-- src/zcash/IncrementalMerkleTree.hpp | 3 +-- src/zcash/NoteEncryption.cpp | 7 +++---- 7 files changed, 20 insertions(+), 24 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 570327c8a..3c6b54dec 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -93,7 +93,7 @@ public: consensus.nMajorityRejectBlockOutdated = 950; consensus.nMajorityWindow = 4000; const size_t N = 200, K = 9; - BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K)); + static_assert(equihash_parameters_acceptable(N, K)); consensus.nEquihashN = N; consensus.nEquihashK = K; consensus.powLimit = uint256S("0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); @@ -370,7 +370,7 @@ public: consensus.nMajorityRejectBlockOutdated = 75; consensus.nMajorityWindow = 400; const size_t N = 200, K = 9; - BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K)); + static_assert(equihash_parameters_acceptable(N, K)); consensus.nEquihashN = N; consensus.nEquihashK = K; consensus.powLimit = uint256S("07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); @@ -613,7 +613,7 @@ public: consensus.nMajorityRejectBlockOutdated = 950; consensus.nMajorityWindow = 1000; const size_t N = 48, K = 5; - BOOST_STATIC_ASSERT(equihash_parameters_acceptable(N, K)); + static_assert(equihash_parameters_acceptable(N, K)); consensus.nEquihashN = N; consensus.nEquihashK = K; consensus.powLimit = uint256S("0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f"); diff --git a/src/crypto/equihash.cpp b/src/crypto/equihash.cpp index 39aafbfda..d4a4d3a56 100644 --- a/src/crypto/equihash.cpp +++ b/src/crypto/equihash.cpp @@ -119,7 +119,7 @@ void ExpandArray(const unsigned char* in, size_t in_len, // comparison void EhIndexToArray(const eh_index i, unsigned char* array) { - BOOST_STATIC_ASSERT(sizeof(eh_index) == 4); + static_assert(sizeof(eh_index) == 4); eh_index bei = htobe32(i); memcpy(array, &bei, sizeof(eh_index)); } @@ -177,7 +177,7 @@ void GenerateHash(const eh_HashState& base_state, eh_index g, // comparison eh_index ArrayToEhIndex(const unsigned char* array) { - BOOST_STATIC_ASSERT(sizeof(eh_index) == 4); + static_assert(sizeof(eh_index) == 4); eh_index bei; memcpy(&bei, array, sizeof(eh_index)); return be32toh(bei); @@ -186,7 +186,7 @@ eh_index ArrayToEhIndex(const unsigned char* array) eh_trunc TruncateIndex(const eh_index i, const unsigned int ilen) { // Truncate to 8 bits - BOOST_STATIC_ASSERT(sizeof(eh_trunc) == 1); + static_assert(sizeof(eh_trunc) == 1); return (i >> (ilen - 8)) & 0xff; } @@ -223,7 +223,7 @@ StepRow::StepRow(const unsigned char* hashIn, size_t hInLen, template template StepRow::StepRow(const StepRow& a) { - BOOST_STATIC_ASSERT(W <= WIDTH); + static_assert(W <= WIDTH); std::copy(a.hash, a.hash+W, hash); } diff --git a/src/crypto/equihash.h b/src/crypto/equihash.h index 8e30778a9..1fac1d648 100644 --- a/src/crypto/equihash.h +++ b/src/crypto/equihash.h @@ -38,7 +38,6 @@ void EhIndexToArray(const eh_index i, unsigned char* array); #include #include -#include #include struct eh_HashState { @@ -195,9 +194,9 @@ template class Equihash { private: - BOOST_STATIC_ASSERT(K < N); - BOOST_STATIC_ASSERT(N % 8 == 0); - BOOST_STATIC_ASSERT((N/(K+1)) + 1 < 8*sizeof(eh_index)); + static_assert(K < N); + static_assert(N % 8 == 0); + static_assert((N/(K+1)) + 1 < 8*sizeof(eh_index)); public: enum : size_t { IndicesPerHashOutput=512/N }; diff --git a/src/main.cpp b/src/main.cpp index a8c0a33e6..b86b59dfb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -44,7 +44,6 @@ #include #include #include -#include using namespace std; @@ -907,7 +906,7 @@ bool ContextualCheckTransaction( // after Sapling activation. // Reject transactions that exceed pre-sapling size limits - BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE > MAX_TX_SIZE_BEFORE_SAPLING); // sanity + static_assert(MAX_BLOCK_SIZE > MAX_TX_SIZE_BEFORE_SAPLING); // sanity if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE_BEFORE_SAPLING) return state.DoS( dosLevelPotentiallyRelaxing, @@ -1069,7 +1068,7 @@ bool ContextualCheckTransaction( if (!tx.vJoinSplit.empty()) { - BOOST_STATIC_ASSERT(crypto_sign_PUBLICKEYBYTES == 32); + static_assert(crypto_sign_PUBLICKEYBYTES == 32); // We rely on libsodium to check that the signature is canonical. // https://github.com/jedisct1/libsodium/commit/62911edb7ff2275cccd74bf1c8aefcc4d76924e0 @@ -1246,8 +1245,8 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio REJECT_INVALID, "bad-txns-vout-empty"); // Size limits - BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE >= MAX_TX_SIZE_AFTER_SAPLING); // sanity - BOOST_STATIC_ASSERT(MAX_TX_SIZE_AFTER_SAPLING > MAX_TX_SIZE_BEFORE_SAPLING); // sanity + static_assert(MAX_BLOCK_SIZE >= MAX_TX_SIZE_AFTER_SAPLING); // sanity + static_assert(MAX_TX_SIZE_AFTER_SAPLING > MAX_TX_SIZE_BEFORE_SAPLING); // sanity if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE_AFTER_SAPLING) return state.DoS(100, error("CheckTransaction(): size limits failed"), REJECT_INVALID, "bad-txns-oversize"); diff --git a/src/policy/policy.h b/src/policy/policy.h index 6f6bf092a..148647732 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -43,8 +43,8 @@ static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VERIFY static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS; // Sanity check the magic numbers when we change them -BOOST_STATIC_ASSERT(DEFAULT_BLOCK_MAX_SIZE <= MAX_BLOCK_SIZE); -BOOST_STATIC_ASSERT(DEFAULT_BLOCK_PRIORITY_SIZE <= DEFAULT_BLOCK_MAX_SIZE); +static_assert(DEFAULT_BLOCK_MAX_SIZE <= MAX_BLOCK_SIZE); +static_assert(DEFAULT_BLOCK_PRIORITY_SIZE <= DEFAULT_BLOCK_MAX_SIZE); bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType); /** diff --git a/src/zcash/IncrementalMerkleTree.hpp b/src/zcash/IncrementalMerkleTree.hpp index 1ebb2b499..805f456eb 100644 --- a/src/zcash/IncrementalMerkleTree.hpp +++ b/src/zcash/IncrementalMerkleTree.hpp @@ -4,7 +4,6 @@ #include #include #include -#include #include "uint256.h" #include "serialize.h" @@ -83,7 +82,7 @@ class IncrementalMerkleTree { friend class IncrementalWitness; public: - BOOST_STATIC_ASSERT(Depth >= 1); + static_assert(Depth >= 1); IncrementalMerkleTree() { } diff --git a/src/zcash/NoteEncryption.cpp b/src/zcash/NoteEncryption.cpp index b20259996..dd0c06215 100644 --- a/src/zcash/NoteEncryption.cpp +++ b/src/zcash/NoteEncryption.cpp @@ -4,7 +4,6 @@ #include #include "sodium.h" -#include #include "prf.h" #include "librustzcash.h" @@ -282,9 +281,9 @@ NoteEncryption::NoteEncryption(uint256 hSig) : nonce(0), hSig(hSig) { // All of this code assumes crypto_scalarmult_BYTES is 32 // There's no reason that will _ever_ change, but for // completeness purposes, let's check anyway. - BOOST_STATIC_ASSERT(32 == crypto_scalarmult_BYTES); - BOOST_STATIC_ASSERT(32 == crypto_scalarmult_SCALARBYTES); - BOOST_STATIC_ASSERT(NOTEENCRYPTION_AUTH_BYTES == crypto_aead_chacha20poly1305_ABYTES); + static_assert(32 == crypto_scalarmult_BYTES); + static_assert(32 == crypto_scalarmult_SCALARBYTES); + static_assert(NOTEENCRYPTION_AUTH_BYTES == crypto_aead_chacha20poly1305_ABYTES); // Create the ephemeral keypair esk = random_uint256();