Auto merge of #4826 - str4d:4823-static-assert, r=daira
Replace BOOST_STATIC_ASSERT with static_assert Closes zcash/zcash#4823.
This commit is contained in:
commit
d6012677ea
|
@ -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");
|
||||
|
|
|
@ -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<WIDTH>::StepRow(const unsigned char* hashIn, size_t hInLen,
|
|||
template<size_t WIDTH> template<size_t W>
|
||||
StepRow<WIDTH>::StepRow(const StepRow<W>& a)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(W <= WIDTH);
|
||||
static_assert(W <= WIDTH);
|
||||
std::copy(a.hash, a.hash+W, hash);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ void EhIndexToArray(const eh_index i, unsigned char* array);
|
|||
#include <functional>
|
||||
#include <set>
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <rust/blake2b.h>
|
||||
|
||||
struct eh_HashState {
|
||||
|
@ -195,9 +194,9 @@ template<unsigned int N, unsigned int K>
|
|||
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 };
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/math/distributions/poisson.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
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");
|
||||
|
|
|
@ -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);
|
||||
/**
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <array>
|
||||
#include <deque>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include "uint256.h"
|
||||
#include "serialize.h"
|
||||
|
@ -83,7 +82,7 @@ class IncrementalMerkleTree {
|
|||
friend class IncrementalWitness<Depth, Hash>;
|
||||
|
||||
public:
|
||||
BOOST_STATIC_ASSERT(Depth >= 1);
|
||||
static_assert(Depth >= 1);
|
||||
|
||||
IncrementalMerkleTree() { }
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#include <stdexcept>
|
||||
#include "sodium.h"
|
||||
#include <boost/static_assert.hpp>
|
||||
#include "prf.h"
|
||||
#include "librustzcash.h"
|
||||
|
||||
|
@ -282,9 +281,9 @@ NoteEncryption<MLEN>::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();
|
||||
|
|
Loading…
Reference in New Issue