diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml index 3b030bb1a..65533d060 100644 --- a/contrib/gitian-descriptors/gitian-osx.yml +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -27,7 +27,7 @@ files: - "Xcode-11.3.1-11C505-extracted-SDK-with-libcxx-headers.tar.gz" script: | WRAP_DIR=$HOME/wrapped - HOSTS="x86_64-apple-darwin16" + HOSTS="x86_64-apple-darwin18" CONFIGFLAGS="--enable-reduce-exports --disable-bench GENISOIMAGE=$WRAP_DIR/genisoimage" FAKETIME_HOST_PROGS="" FAKETIME_PROGS="ar ranlib date dmg genisoimage" diff --git a/depends/README.md b/depends/README.md index df312aabd..cf88a425f 100644 --- a/depends/README.md +++ b/depends/README.md @@ -22,7 +22,7 @@ Common `host-platform-triplets` for cross compilation are: - `i686-w64-mingw32` for Win32 - `x86_64-w64-mingw32` for Win64 -- `x86_64-apple-darwin16` for macOS +- `x86_64-apple-darwin18` for macOS - `arm-linux-gnueabihf` for Linux ARM 32 bit - `aarch64-linux-gnu` for Linux ARM 64 bit - `riscv32-linux-gnu` for Linux RISC-V 32 bit diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk index 7c0ad99df..f461e65d9 100644 --- a/depends/hosts/darwin.mk +++ b/depends/hosts/darwin.mk @@ -1,5 +1,4 @@ -OSX_MIN_VERSION=10.12 -OSX_SDK_VERSION=10.15.1 +OSX_MIN_VERSION=10.14 XCODE_VERSION=11.3.1 XCODE_BUILD_ID=11C505 LD64_VERSION=530 diff --git a/src/chain.h b/src/chain.h index bedad61ee..01204fdc8 100644 --- a/src/chain.h +++ b/src/chain.h @@ -12,6 +12,7 @@ #include "tinyformat.h" #include "uint256.h" +#include #include static const int SPROUT_VALUE_VERSION = 1001400; @@ -228,7 +229,7 @@ public: //! Branch ID corresponding to the consensus rules used to validate this block. //! Only cached if block validity is BLOCK_VALID_CONSENSUS. //! Persisted at each activation height, memory-only for intervening blocks. - boost::optional nCachedBranchId; + std::optional nCachedBranchId; //! The anchor for the tree state up to the start of this block uint256 hashSproutAnchor; @@ -237,22 +238,22 @@ public: uint256 hashFinalSproutRoot; //! Change in value held by the Sprout circuit over this block. - //! Will be boost::none for older blocks on old nodes until a reindex has taken place. - boost::optional nSproutValue; + //! Will be std::nullopt for older blocks on old nodes until a reindex has taken place. + std::optional nSproutValue; //! (memory only) Total value held by the Sprout circuit up to and including this block. - //! Will be boost::none for on old nodes until a reindex has taken place. - //! Will be boost::none if nChainTx is zero. - boost::optional nChainSproutValue; + //! Will be std::nullopt for on old nodes until a reindex has taken place. + //! Will be std::nullopt if nChainTx is zero. + std::optional nChainSproutValue; //! Change in value held by the Sapling circuit over this block. - //! Not a boost::optional because this was added before Sapling activated, so we can + //! Not a std::optional because this was added before Sapling activated, so we can //! rely on the invariant that every block before this was added had nSaplingValue = 0. CAmount nSaplingValue; //! (memory only) Total value held by the Sapling circuit up to and including this block. - //! Will be boost::none if nChainTx is zero. - boost::optional nChainSaplingValue; + //! Will be std::nullopt if nChainTx is zero. + std::optional nChainSaplingValue; //! Root of the Sapling commitment tree as of the end of this block. //! @@ -295,14 +296,14 @@ public: nTx = 0; nChainTx = 0; nStatus = 0; - nCachedBranchId = boost::none; + nCachedBranchId = std::nullopt; hashSproutAnchor = uint256(); hashFinalSproutRoot = uint256(); nSequenceId = 0; - nSproutValue = boost::none; - nChainSproutValue = boost::none; + nSproutValue = std::nullopt; + nChainSproutValue = std::nullopt; nSaplingValue = 0; - nChainSaplingValue = boost::none; + nChainSaplingValue = std::nullopt; nVersion = 0; hashMerkleRoot = uint256(); diff --git a/src/chainparams.cpp b/src/chainparams.cpp index d8bebb862..4f4b81130 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -13,6 +13,8 @@ #include "utilstrencodings.h" #include +#include +#include #include @@ -103,7 +105,7 @@ public: consensus.nPowMaxAdjustUp = 16; // 16% adjustment up consensus.nPreBlossomPowTargetSpacing = Consensus::PRE_BLOSSOM_POW_TARGET_SPACING; consensus.nPostBlossomPowTargetSpacing = Consensus::POST_BLOSSOM_POW_TARGET_SPACING; - consensus.nPowAllowMinDifficultyBlocksAfterHeight = boost::none; + consensus.nPowAllowMinDifficultyBlocksAfterHeight = std::nullopt; consensus.fPowNoRetargeting = false; consensus.vUpgrades[Consensus::BASE_SPROUT].nProtocolVersion = 170002; consensus.vUpgrades[Consensus::BASE_SPROUT].nActivationHeight = @@ -812,7 +814,7 @@ CScript CChainParams::GetFoundersRewardScriptAtHeight(int nHeight) const { CTxDestination address = keyIO.DecodeDestination(GetFoundersRewardAddressAtHeight(nHeight).c_str()); assert(IsValidDestination(address)); assert(IsScriptDestination(address)); - CScriptID scriptID = boost::get(address); // address is a boost variant + CScriptID scriptID = std::get(address); // address is a variant CScript script = CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL; return script; } diff --git a/src/consensus/funding.cpp b/src/consensus/funding.cpp index 918deae8d..7cec13080 100644 --- a/src/consensus/funding.cpp +++ b/src/consensus/funding.cpp @@ -61,9 +61,9 @@ std::set GetActiveFundingStreamElements( // in the definition of vFundingStreams. auto fs = params.vFundingStreams[idx]; // Funding period is [startHeight, endHeight) - if (fs && nHeight >= fs.get().GetStartHeight() && nHeight < fs.get().GetEndHeight()) { + if (fs && nHeight >= fs.value().GetStartHeight() && nHeight < fs.value().GetEndHeight()) { requiredElements.insert(std::make_pair( - fs.get().RecipientAddress(params, nHeight), + fs.value().RecipientAddress(params, nHeight), FundingStreamInfo[idx].Value(blockSubsidy))); } } @@ -82,7 +82,7 @@ std::vector GetActiveFundingStreams( if (params.NetworkUpgradeActive(nHeight, Consensus::UPGRADE_CANOPY)) { for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) { auto fs = params.vFundingStreams[idx]; - if (fs && nHeight >= fs.get().GetStartHeight() && nHeight < fs.get().GetEndHeight()) { + if (fs && nHeight >= fs.value().GetStartHeight() && nHeight < fs.value().GetEndHeight()) { activeStreams.push_back(FundingStreamInfo[idx]); } } diff --git a/src/consensus/funding.h b/src/consensus/funding.h index b2dc1cd6c..91230db2b 100644 --- a/src/consensus/funding.h +++ b/src/consensus/funding.h @@ -8,7 +8,6 @@ #include #include -#include namespace Consensus { diff --git a/src/consensus/params.cpp b/src/consensus/params.cpp index a6525f4b7..cc519337b 100644 --- a/src/consensus/params.cpp +++ b/src/consensus/params.cpp @@ -102,7 +102,7 @@ namespace Consensus { return (nHeight - fundingStreamStartHeight + startPeriodOffset) / nFundingPeriodLength; } - boost::variant FundingStream::ValidateFundingStream( + std::variant FundingStream::ValidateFundingStream( const Consensus::Params& params, const int startHeight, const int endHeight, @@ -123,7 +123,7 @@ namespace Consensus { return FundingStream(startHeight, endHeight, addresses); }; - class GetFundingStreamOrThrow: public boost::static_visitor { + class GetFundingStreamOrThrow { public: FundingStream operator()(const FundingStream& fs) const { return fs; @@ -163,12 +163,12 @@ namespace Consensus { // If the string is not a valid transparent or Sapling address, we will // throw here. - addresses.push_back(boost::get(zaddr)); + addresses.push_back(std::get(zaddr)); } } auto validationResult = FundingStream::ValidateFundingStream(params, startHeight, endHeight, addresses); - return boost::apply_visitor(GetFundingStreamOrThrow(), validationResult); + return std::visit(GetFundingStreamOrThrow(), validationResult); }; void Params::AddZIP207FundingStream( diff --git a/src/consensus/params.h b/src/consensus/params.h index eb4874710..464ca0347 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -11,8 +11,9 @@ #include "key_constants.h" #include -#include -#include +#include +#include + namespace Consensus { @@ -79,10 +80,10 @@ struct NetworkUpgrade { * scrutiny than regular releases. nMinimumChainWork MUST be set to at least the chain * work of this block, otherwise this detection will have false positives. */ - boost::optional hashActivationBlock; + std::optional hashActivationBlock; }; -typedef boost::variant FundingStreamAddress; +typedef std::variant FundingStreamAddress; /** * Index into Params.vFundingStreams. @@ -116,7 +117,7 @@ public: FundingStream(const FundingStream& fs): startHeight(fs.startHeight), endHeight(fs.endHeight), addresses(fs.addresses) { } - static boost::variant ValidateFundingStream( + static std::variant ValidateFundingStream( const Consensus::Params& params, const int startHeight, const int endHeight, @@ -210,7 +211,7 @@ struct Params { NetworkUpgrade vUpgrades[MAX_NETWORK_UPGRADES]; int nFundingPeriodLength; - boost::optional vFundingStreams[MAX_FUNDING_STREAMS]; + std::optional vFundingStreams[MAX_FUNDING_STREAMS]; void AddZIP207FundingStream( const KeyConstants& keyConstants, FundingStreamIndex idx, @@ -262,7 +263,7 @@ struct Params { unsigned int nEquihashN = 0; unsigned int nEquihashK = 0; uint256 powLimit; - boost::optional nPowAllowMinDifficultyBlocksAfterHeight; + std::optional nPowAllowMinDifficultyBlocksAfterHeight; bool fPowNoRetargeting; int64_t nPowAveragingWindow; int64_t nPowMaxAdjustDown; diff --git a/src/consensus/upgrades.cpp b/src/consensus/upgrades.cpp index 1825e9f8a..29f8acce7 100644 --- a/src/consensus/upgrades.cpp +++ b/src/consensus/upgrades.cpp @@ -140,9 +140,9 @@ bool IsActivationHeightForAnyUpgrade( return false; } -boost::optional NextEpoch(int nHeight, const Consensus::Params& params) { +std::optional NextEpoch(int nHeight, const Consensus::Params& params) { if (nHeight < 0) { - return boost::none; + return std::nullopt; } // Sprout is never pending @@ -152,16 +152,16 @@ boost::optional NextEpoch(int nHeight, const Consensus::Params& params) { } } - return boost::none; + return std::nullopt; } -boost::optional NextActivationHeight( +std::optional NextActivationHeight( int nHeight, const Consensus::Params& params) { auto idx = NextEpoch(nHeight, params); if (idx) { - return params.vUpgrades[idx.get()].nActivationHeight; + return params.vUpgrades[idx.value()].nActivationHeight; } - return boost::none; + return std::nullopt; } diff --git a/src/consensus/upgrades.h b/src/consensus/upgrades.h index e8ed40daa..812c0ad18 100644 --- a/src/consensus/upgrades.h +++ b/src/consensus/upgrades.h @@ -7,7 +7,7 @@ #include "consensus/params.h" -#include +#include enum UpgradeState { UPGRADE_DISABLED, @@ -83,15 +83,15 @@ bool IsActivationHeightForAnyUpgrade( /** * Returns the index of the next upgrade after the given block height, or - * boost::none if there are no more known upgrades. + * std::nullopt if there are no more known upgrades. */ -boost::optional NextEpoch(int nHeight, const Consensus::Params& params); +std::optional NextEpoch(int nHeight, const Consensus::Params& params); /** * Returns the activation height for the next upgrade after the given block height, - * or boost::none if there are no more known upgrades. + * or std::nullopt if there are no more known upgrades. */ -boost::optional NextActivationHeight( +std::optional NextActivationHeight( int nHeight, const Consensus::Params& params); diff --git a/src/crypto/equihash.cpp b/src/crypto/equihash.cpp index d63d0f9d3..ad64a37fc 100644 --- a/src/crypto/equihash.cpp +++ b/src/crypto/equihash.cpp @@ -20,6 +20,8 @@ #include "crypto/equihash.h" #include "util.h" +#include + #ifdef ENABLE_MINING void eh_HashState::Update(const unsigned char *input, size_t inputLen) { @@ -149,7 +151,6 @@ std::vector GetMinimalFromIndices(std::vector indices, #include #include -#include static EhSolverCancelledException solver_cancelled; @@ -646,7 +647,7 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, size_t hashLen; size_t lenIndices; unsigned char tmpHash[HashOutput]; - std::vector>>> X; + std::vector>>> X; X.reserve(K+1); // 3) Repeat steps 1 and 2 for each partial index @@ -664,7 +665,7 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, N/8, HashLength, CollisionBitLength, newIndex); if (cancelled(PartialGeneration)) throw solver_cancelled; } - boost::optional>> ic = icv; + std::optional>> ic = icv; // 2a) For each pair of lists: hashLen = HashLength; @@ -689,7 +690,7 @@ bool Equihash::OptimisedSolve(const eh_HashState& base_state, if (ic->size() == 0) goto invalidsolution; - X[r] = boost::none; + X[r] = std::nullopt; hashLen -= CollisionByteLength; lenIndices *= 2; rti = lti; diff --git a/src/experimental_features.cpp b/src/experimental_features.cpp index 93a4fd2ed..67afbf7fc 100644 --- a/src/experimental_features.cpp +++ b/src/experimental_features.cpp @@ -12,7 +12,7 @@ bool fExperimentalPaymentDisclosure = false; bool fExperimentalInsightExplorer = false; bool fExperimentalLightWalletd = false; -boost::optional InitExperimentalMode() +std::optional InitExperimentalMode() { auto fExperimentalMode = GetBoolArg("-experimentalfeatures", false); fExperimentalDeveloperEncryptWallet = GetBoolArg("-developerencryptwallet", false); @@ -35,7 +35,7 @@ boost::optional InitExperimentalMode() return _("Light Walletd requires -experimentalfeatures."); } } - return boost::none; + return std::nullopt; } std::vector GetExperimentalFeatures() diff --git a/src/experimental_features.h b/src/experimental_features.h index 35333fbd4..d607f1d53 100644 --- a/src/experimental_features.h +++ b/src/experimental_features.h @@ -5,9 +5,9 @@ #ifndef ZCASH_EXPERIMENTAL_FEATURES_H #define ZCASH_EXPERIMENTAL_FEATURES_H +#include #include #include -#include extern bool fExperimentalDeveloperEncryptWallet; extern bool fExperimentalDeveloperSetPoolSizeZero; @@ -15,7 +15,7 @@ extern bool fExperimentalPaymentDisclosure; extern bool fExperimentalInsightExplorer; extern bool fExperimentalLightWalletd; -boost::optional InitExperimentalMode(); +std::optional InitExperimentalMode(); std::vector GetExperimentalFeatures(); #endif // ZCASH_EXPERIMENTAL_FEATURES_H diff --git a/src/gtest/test_checktransaction.cpp b/src/gtest/test_checktransaction.cpp index 7a15d2f76..ad27ea878 100644 --- a/src/gtest/test_checktransaction.cpp +++ b/src/gtest/test_checktransaction.cpp @@ -1134,7 +1134,7 @@ TEST(ChecktransactionTests, HeartwoodAcceptsShieldedCoinbase) { auto output = OutputDescriptionInfo(ovk, note, {{0xF6}}); auto ctx = librustzcash_sapling_proving_ctx_init(); - auto odesc = output.Build(ctx).get(); + auto odesc = output.Build(ctx).value(); librustzcash_sapling_proving_ctx_free(ctx); CMutableTransaction mtx = GetValidTransaction(); @@ -1240,7 +1240,7 @@ TEST(ChecktransactionTests, HeartwoodEnforcesSaplingRulesOnShieldedCoinbase) { // Add a Sapling output. auto ctx = librustzcash_sapling_proving_ctx_init(); - auto odesc = output.Build(ctx).get(); + auto odesc = output.Build(ctx).value(); librustzcash_sapling_proving_ctx_free(ctx); mtx.vShieldedOutput.push_back(odesc); diff --git a/src/gtest/test_foundersreward.cpp b/src/gtest/test_foundersreward.cpp index 585cdb7a7..c69fb8ebc 100644 --- a/src/gtest/test_foundersreward.cpp +++ b/src/gtest/test_foundersreward.cpp @@ -105,8 +105,8 @@ void checkNumberOfUniqueAddresses(int nUnique) { int GetMaxFundingStreamHeight(const Consensus::Params& params) { int result = 0; for (auto fs : params.vFundingStreams) { - if (fs && result < fs.get().GetEndHeight() - 1) { - result = fs.get().GetEndHeight() - 1; + if (fs && result < fs.value().GetEndHeight() - 1) { + result = fs.value().GetEndHeight() - 1; } } diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp index 65c452102..b89c3d6ad 100644 --- a/src/gtest/test_joinsplit.cpp +++ b/src/gtest/test_joinsplit.cpp @@ -2,7 +2,6 @@ #include "utilstrencodings.h" -#include #include "zcash/prf.h" #include "util.h" diff --git a/src/gtest/test_keys.cpp b/src/gtest/test_keys.cpp index eb2735a28..e31b6796a 100644 --- a/src/gtest/test_keys.cpp +++ b/src/gtest/test_keys.cpp @@ -4,6 +4,8 @@ #include "utiltest.h" +#include + #include TEST(Keys, EncodeAndDecodeSapling) @@ -24,8 +26,8 @@ TEST(Keys, EncodeAndDecodeSapling) auto spendingkey2 = keyIO.DecodeSpendingKey(sk_string); EXPECT_TRUE(IsValidSpendingKey(spendingkey2)); - ASSERT_TRUE(boost::get(&spendingkey2) != nullptr); - auto sk2 = boost::get(spendingkey2); + ASSERT_TRUE(std::get_if(&spendingkey2) != nullptr); + auto sk2 = std::get(spendingkey2); EXPECT_EQ(sk, sk2); } { @@ -38,8 +40,8 @@ TEST(Keys, EncodeAndDecodeSapling) auto viewingkey2 = keyIO.DecodeViewingKey(vk_string); EXPECT_TRUE(IsValidViewingKey(viewingkey2)); - ASSERT_TRUE(boost::get(&viewingkey2) != nullptr); - auto extfvk2 = boost::get(viewingkey2); + ASSERT_TRUE(std::get_if(&viewingkey2) != nullptr); + auto extfvk2 = std::get(viewingkey2); EXPECT_EQ(extfvk, extfvk2); } { @@ -53,8 +55,8 @@ TEST(Keys, EncodeAndDecodeSapling) auto paymentaddr2 = keyIO.DecodePaymentAddress(addr_string); EXPECT_TRUE(IsValidPaymentAddress(paymentaddr2)); - ASSERT_TRUE(boost::get(&paymentaddr2) != nullptr); - auto addr2 = boost::get(paymentaddr2); + ASSERT_TRUE(std::get_if(&paymentaddr2) != nullptr); + auto addr2 = std::get(paymentaddr2); EXPECT_EQ(addr, addr2); } } diff --git a/src/gtest/test_mempoollimit.cpp b/src/gtest/test_mempoollimit.cpp index 380bb3097..8869b27d7 100644 --- a/src/gtest/test_mempoollimit.cpp +++ b/src/gtest/test_mempoollimit.cpp @@ -94,13 +94,13 @@ TEST(MempoolLimitTests, WeightedTxTreeCheckSizeAfterDropping) tree.add(WeightedTxInfo(TX_ID2, TxWeight(MIN_TX_COST, MIN_TX_COST))); EXPECT_EQ(8000, tree.getTotalWeight().cost); EXPECT_EQ(8000, tree.getTotalWeight().evictionWeight); - EXPECT_FALSE(tree.maybeDropRandom().is_initialized()); + EXPECT_FALSE(tree.maybeDropRandom().has_value()); tree.add(WeightedTxInfo(TX_ID3, TxWeight(MIN_TX_COST, MIN_TX_COST + LOW_FEE_PENALTY))); EXPECT_EQ(12000, tree.getTotalWeight().cost); EXPECT_EQ(12000 + LOW_FEE_PENALTY, tree.getTotalWeight().evictionWeight); - boost::optional drop = tree.maybeDropRandom(); - ASSERT_TRUE(drop.is_initialized()); - uint256 txid = drop.get(); + std::optional drop = tree.maybeDropRandom(); + ASSERT_TRUE(drop.has_value()); + uint256 txid = drop.value(); testedDropping.insert(txid); // Do not continue to test if a particular trial fails ASSERT_EQ(8000, tree.getTotalWeight().cost); diff --git a/src/gtest/test_miner.cpp b/src/gtest/test_miner.cpp index c648a6750..61d454407 100644 --- a/src/gtest/test_miner.cpp +++ b/src/gtest/test_miner.cpp @@ -7,6 +7,8 @@ #include "miner.h" #include "util.h" +#include + TEST(Miner, GetMinerAddress) { SelectParams(CBaseChainParams::MAIN); @@ -52,8 +54,8 @@ TEST(Miner, GetMinerAddress) { MinerAddress minerAddress; GetMinerAddress(minerAddress); EXPECT_TRUE(IsValidMinerAddress(minerAddress)); - EXPECT_TRUE(boost::get>(&minerAddress) != nullptr); - auto coinbaseScript = boost::get>(minerAddress); + EXPECT_TRUE(std::get_if>(&minerAddress) != nullptr); + auto coinbaseScript = std::get>(minerAddress); EXPECT_EQ(expectedCoinbaseScript, coinbaseScript->reserveScript); } @@ -63,8 +65,8 @@ TEST(Miner, GetMinerAddress) { MinerAddress minerAddress; GetMinerAddress(minerAddress); EXPECT_TRUE(IsValidMinerAddress(minerAddress)); - EXPECT_TRUE(boost::get>(&minerAddress) != nullptr); - auto coinbaseScript = boost::get>(minerAddress); + EXPECT_TRUE(std::get_if>(&minerAddress) != nullptr); + auto coinbaseScript = std::get>(minerAddress); EXPECT_EQ(expectedCoinbaseScript, coinbaseScript->reserveScript); } @@ -74,8 +76,8 @@ TEST(Miner, GetMinerAddress) { MinerAddress minerAddress; GetMinerAddress(minerAddress); EXPECT_TRUE(IsValidMinerAddress(minerAddress)); - EXPECT_TRUE(boost::get>(&minerAddress) != nullptr); - auto coinbaseScript = boost::get>(minerAddress); + EXPECT_TRUE(std::get_if>(&minerAddress) != nullptr); + auto coinbaseScript = std::get>(minerAddress); EXPECT_EQ(expectedCoinbaseScript, coinbaseScript->reserveScript); } @@ -101,7 +103,7 @@ TEST(Miner, GetMinerAddress) { MinerAddress minerAddress; GetMinerAddress(minerAddress); EXPECT_TRUE(IsValidMinerAddress(minerAddress)); - EXPECT_TRUE(boost::get(&minerAddress) != nullptr); + EXPECT_TRUE(std::get_if(&minerAddress) != nullptr); } // Valid Sapling address with leading whitespace diff --git a/src/gtest/test_noteencryption.cpp b/src/gtest/test_noteencryption.cpp index 6dae057af..640dd64d6 100644 --- a/src/gtest/test_noteencryption.cpp +++ b/src/gtest/test_noteencryption.cpp @@ -2,6 +2,7 @@ #include "sodium.h" #include +#include #include #include "zcash/Note.hpp" @@ -50,7 +51,7 @@ TEST(NoteEncryption, NotePlaintext) if (!cmu_opt) { FAIL(); } - uint256 cmu = cmu_opt.get(); + uint256 cmu = cmu_opt.value(); SaplingNotePlaintext pt(note, memo); auto res = pt.encrypt(addr.pk_d); @@ -58,7 +59,7 @@ TEST(NoteEncryption, NotePlaintext) FAIL(); } - auto enc = res.get(); + auto enc = res.value(); auto ct = enc.first; auto encryptor = enc.second; @@ -88,7 +89,7 @@ TEST(NoteEncryption, NotePlaintext) FAIL(); } - auto bar = foo.get(); + auto bar = foo.value(); ASSERT_TRUE(bar.value() == pt.value()); ASSERT_TRUE(bar.memo() == pt.memo()); @@ -101,7 +102,7 @@ TEST(NoteEncryption, NotePlaintext) FAIL(); } - auto new_note = foobar.get(); + auto new_note = foobar.value(); ASSERT_TRUE(note.value() == new_note.value()); ASSERT_TRUE(note.d == new_note.d); @@ -136,7 +137,7 @@ TEST(NoteEncryption, NotePlaintext) FAIL(); } - auto decrypted_out_ct_unwrapped = decrypted_out_ct.get(); + auto decrypted_out_ct_unwrapped = decrypted_out_ct.value(); ASSERT_TRUE(decrypted_out_ct_unwrapped.pk_d == out_pt.pk_d); ASSERT_TRUE(decrypted_out_ct_unwrapped.esk == out_pt.esk); @@ -169,7 +170,7 @@ TEST(NoteEncryption, NotePlaintext) FAIL(); } - bar = foo.get(); + bar = foo.value(); ASSERT_TRUE(bar.value() == pt.value()); ASSERT_TRUE(bar.memo() == pt.memo()); @@ -210,7 +211,7 @@ TEST(NoteEncryption, RejectsInvalidNoteZip212Enabled) if (!cmu_opt) { FAIL(); } - uint256 cmu = cmu_opt.get(); + uint256 cmu = cmu_opt.value(); SaplingNotePlaintext pt(note, memo); auto res = pt.encrypt(addr.pk_d); @@ -218,7 +219,7 @@ TEST(NoteEncryption, RejectsInvalidNoteZip212Enabled) FAIL(); } - auto enc = res.get(); + auto enc = res.value(); auto ct = enc.first; auto encryptor = enc.second; @@ -241,7 +242,7 @@ TEST(NoteEncryption, RejectsInvalidNoteZip212Enabled) if (!cmu_opt) { FAIL(); } - uint256 cmu = cmu_opt.get(); + uint256 cmu = cmu_opt.value(); SaplingNotePlaintext pt(note, memo); auto res = pt.encrypt(addr.pk_d); @@ -249,7 +250,7 @@ TEST(NoteEncryption, RejectsInvalidNoteZip212Enabled) FAIL(); } - auto enc = res.get(); + auto enc = res.value(); auto ct = enc.first; auto encryptor = enc.second; @@ -301,7 +302,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled) if (!cmu_opt) { FAIL(); } - uint256 cmu = cmu_opt.get(); + uint256 cmu = cmu_opt.value(); SaplingNotePlaintext pt(note, memo); auto res = pt.encrypt(addr.pk_d); @@ -309,7 +310,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled) FAIL(); } - auto enc = res.get(); + auto enc = res.value(); auto ct = enc.first; auto encryptor = enc.second; @@ -343,7 +344,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled) if (!cmu_opt) { FAIL(); } - uint256 cmu = cmu_opt.get(); + uint256 cmu = cmu_opt.value(); SaplingNotePlaintext pt(note, memo); auto res = pt.encrypt(addr.pk_d); @@ -351,7 +352,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled) FAIL(); } - auto enc = res.get(); + auto enc = res.value(); auto ct = enc.first; auto encryptor = enc.second; @@ -380,7 +381,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled) if (!cmu_opt) { FAIL(); } - uint256 cmu = cmu_opt.get(); + uint256 cmu = cmu_opt.value(); SaplingNotePlaintext pt(note, memo); auto res = pt.encrypt(addr.pk_d); @@ -388,7 +389,7 @@ TEST(NoteEncryption, AcceptsValidNoteZip212Enabled) FAIL(); } - auto enc = res.get(); + auto enc = res.value(); auto ct = enc.first; auto encryptor = enc.second; @@ -442,7 +443,7 @@ TEST(NoteEncryption, SaplingApi) librustzcash_sapling_generate_r(esk.begin()); // Invalid diversifier - ASSERT_EQ(boost::none, SaplingNoteEncryption::FromDiversifier({1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, esk)); + ASSERT_EQ(std::nullopt, SaplingNoteEncryption::FromDiversifier({1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, esk)); // Encrypt to pk_1 auto enc = *SaplingNoteEncryption::FromDiversifier(pk_1.d, esk); diff --git a/src/gtest/test_pow.cpp b/src/gtest/test_pow.cpp index 505e7604b..7ee1bf3e4 100644 --- a/src/gtest/test_pow.cpp +++ b/src/gtest/test_pow.cpp @@ -93,7 +93,7 @@ TEST(PoW, MinDifficultyRules) { std::vector blocks(lastBlk+1); for (int i = 0; i <= lastBlk; i++) { blocks[i].pprev = i ? &blocks[i - 1] : nullptr; - blocks[i].nHeight = params.nPowAllowMinDifficultyBlocksAfterHeight.get() + i; + blocks[i].nHeight = params.nPowAllowMinDifficultyBlocksAfterHeight.value() + i; blocks[i].nTime = i ? blocks[i - 1].nTime + params.PoWTargetSpacing(i) : 1269211443; blocks[i].nBits = 0x1e7fffff; /* target 0x007fffff000... */ blocks[i].nChainWork = i ? blocks[i - 1].nChainWork + GetBlockProof(blocks[i - 1]) : arith_uint256(0); diff --git a/src/gtest/test_sapling_note.cpp b/src/gtest/test_sapling_note.cpp index ca1fece7c..5eeb2fa83 100644 --- a/src/gtest/test_sapling_note.cpp +++ b/src/gtest/test_sapling_note.cpp @@ -45,7 +45,7 @@ TEST(SaplingNote, TestVectors) // Test commitment SaplingNote note = SaplingNote(diversifier, pk_d, v, r, Zip212Enabled::BeforeZip212); - ASSERT_EQ(note.cmu().get(), cm); + ASSERT_EQ(note.cmu().value(), cm); // Test nullifier SaplingSpendingKey spendingKey(sk); diff --git a/src/gtest/test_upgrades.cpp b/src/gtest/test_upgrades.cpp index b33317288..d7ff0d791 100644 --- a/src/gtest/test_upgrades.cpp +++ b/src/gtest/test_upgrades.cpp @@ -3,7 +3,7 @@ #include "chainparams.h" #include "consensus/upgrades.h" -#include +#include class UpgradesTest : public ::testing::Test { protected: @@ -148,28 +148,28 @@ TEST_F(UpgradesTest, NextEpoch) { const Consensus::Params& params = Params().GetConsensus(); // Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT - EXPECT_EQ(NextEpoch(-1, params), boost::none); - EXPECT_EQ(NextEpoch(0, params), boost::none); - EXPECT_EQ(NextEpoch(1, params), boost::none); - EXPECT_EQ(NextEpoch(1000000, params), boost::none); + EXPECT_EQ(NextEpoch(-1, params), std::nullopt); + EXPECT_EQ(NextEpoch(0, params), std::nullopt); + EXPECT_EQ(NextEpoch(1, params), std::nullopt); + EXPECT_EQ(NextEpoch(1000000, params), std::nullopt); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); - EXPECT_EQ(NextEpoch(-1, params), boost::none); - EXPECT_EQ(NextEpoch(0, params), boost::none); - EXPECT_EQ(NextEpoch(1, params), boost::none); - EXPECT_EQ(NextEpoch(1000000, params), boost::none); + EXPECT_EQ(NextEpoch(-1, params), std::nullopt); + EXPECT_EQ(NextEpoch(0, params), std::nullopt); + EXPECT_EQ(NextEpoch(1, params), std::nullopt); + EXPECT_EQ(NextEpoch(1000000, params), std::nullopt); int nActivationHeight = 100; UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, nActivationHeight); - EXPECT_EQ(NextEpoch(-1, params), boost::none); + EXPECT_EQ(NextEpoch(-1, params), std::nullopt); EXPECT_EQ(NextEpoch(0, params), static_cast(Consensus::UPGRADE_TESTDUMMY)); EXPECT_EQ(NextEpoch(1, params), static_cast(Consensus::UPGRADE_TESTDUMMY)); EXPECT_EQ(NextEpoch(nActivationHeight - 1, params), static_cast(Consensus::UPGRADE_TESTDUMMY)); - EXPECT_EQ(NextEpoch(nActivationHeight, params), boost::none); - EXPECT_EQ(NextEpoch(nActivationHeight + 1, params), boost::none); - EXPECT_EQ(NextEpoch(1000000, params), boost::none); + EXPECT_EQ(NextEpoch(nActivationHeight, params), std::nullopt); + EXPECT_EQ(NextEpoch(nActivationHeight + 1, params), std::nullopt); + EXPECT_EQ(NextEpoch(1000000, params), std::nullopt); } TEST_F(UpgradesTest, NextActivationHeight) { @@ -177,26 +177,26 @@ TEST_F(UpgradesTest, NextActivationHeight) { const Consensus::Params& params = Params().GetConsensus(); // Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT - EXPECT_EQ(NextActivationHeight(-1, params), boost::none); - EXPECT_EQ(NextActivationHeight(0, params), boost::none); - EXPECT_EQ(NextActivationHeight(1, params), boost::none); - EXPECT_EQ(NextActivationHeight(1000000, params), boost::none); + EXPECT_EQ(NextActivationHeight(-1, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(0, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(1, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(1000000, params), std::nullopt); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); - EXPECT_EQ(NextActivationHeight(-1, params), boost::none); - EXPECT_EQ(NextActivationHeight(0, params), boost::none); - EXPECT_EQ(NextActivationHeight(1, params), boost::none); - EXPECT_EQ(NextActivationHeight(1000000, params), boost::none); + EXPECT_EQ(NextActivationHeight(-1, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(0, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(1, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(1000000, params), std::nullopt); int nActivationHeight = 100; UpdateNetworkUpgradeParameters(Consensus::UPGRADE_TESTDUMMY, nActivationHeight); - EXPECT_EQ(NextActivationHeight(-1, params), boost::none); + EXPECT_EQ(NextActivationHeight(-1, params), std::nullopt); EXPECT_EQ(NextActivationHeight(0, params), nActivationHeight); EXPECT_EQ(NextActivationHeight(1, params), nActivationHeight); EXPECT_EQ(NextActivationHeight(nActivationHeight - 1, params), nActivationHeight); - EXPECT_EQ(NextActivationHeight(nActivationHeight, params), boost::none); - EXPECT_EQ(NextActivationHeight(nActivationHeight + 1, params), boost::none); - EXPECT_EQ(NextActivationHeight(1000000, params), boost::none); + EXPECT_EQ(NextActivationHeight(nActivationHeight, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(nActivationHeight + 1, params), std::nullopt); + EXPECT_EQ(NextActivationHeight(1000000, params), std::nullopt); } diff --git a/src/gtest/test_validation.cpp b/src/gtest/test_validation.cpp index a411bfc2d..0710ae30d 100644 --- a/src/gtest/test_validation.cpp +++ b/src/gtest/test_validation.cpp @@ -7,6 +7,8 @@ #include "transaction_builder.h" #include "utiltest.h" +#include + extern bool ReceivedBlockTransactions( const CBlock &block, CValidationState& state, @@ -14,7 +16,7 @@ extern bool ReceivedBlockTransactions( CBlockIndex *pindexNew, const CDiskBlockPos& pos); -void ExpectOptionalAmount(CAmount expected, boost::optional actual) { +void ExpectOptionalAmount(CAmount expected, std::optional actual) { EXPECT_TRUE((bool)actual); if (actual) { EXPECT_EQ(expected, *actual); @@ -24,7 +26,7 @@ void ExpectOptionalAmount(CAmount expected, boost::optional actual) { // Fake a view that optionally contains a single coin. class ValidationFakeCoinsViewDB : public CCoinsView { public: - boost::optional, std::pair>> coin; + std::optional, std::pair>> coin; ValidationFakeCoinsViewDB() {} ValidationFakeCoinsViewDB(uint256 blockHash, uint256 txid, CTxOut txOut, int nHeight) : @@ -43,11 +45,11 @@ public: } bool GetCoins(const uint256 &txid, CCoins &coins) const { - if (coin && txid == coin.get().first.second) { + if (coin && txid == coin.value().first.second) { CCoins newCoins; newCoins.vout.resize(2); - newCoins.vout[0] = coin.get().second.first; - newCoins.nHeight = coin.get().second.second; + newCoins.vout[0] = coin.value().second.first; + newCoins.nHeight = coin.value().second.second; coins.swap(newCoins); return true; } else { @@ -56,7 +58,7 @@ public: } bool HaveCoins(const uint256 &txid) const { - if (coin && txid == coin.get().first.second) { + if (coin && txid == coin.value().first.second) { return true; } else { return false; @@ -65,7 +67,7 @@ public: uint256 GetBestBlock() const { if (coin) { - return coin.get().first.first; + return coin.value().first.first; } else { uint256 a; return a; diff --git a/src/gtest/test_zip32.cpp b/src/gtest/test_zip32.cpp index e7715fd03..c8ee5a335 100644 --- a/src/gtest/test_zip32.cpp +++ b/src/gtest/test_zip32.cpp @@ -109,7 +109,7 @@ TEST(ZIP32, TestVectors) { auto maybe_m_1_2hv_3 = m_1_2hv.Derive(3); EXPECT_TRUE(maybe_m_1_2hv_3); - auto m_1_2hv_3 = maybe_m_1_2hv_3.get(); + auto m_1_2hv_3 = maybe_m_1_2hv_3.value(); EXPECT_EQ(m_1_2hv_3.depth, 3); EXPECT_EQ(m_1_2hv_3.parentFVKTag, 0x7583c148); EXPECT_EQ(m_1_2hv_3.childIndex, 3); diff --git a/src/init.cpp b/src/init.cpp index 270273a8c..de7967995 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -899,7 +899,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Set this early so that experimental features are correctly enabled/disabled auto err = InitExperimentalMode(); if (err) { - return InitError(err.get()); + return InitError(err.value()); } // Make sure enough file descriptors are available @@ -1053,7 +1053,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) // Try a Sapling address auto zaddr = keyIO.DecodePaymentAddress(mapArgs["-mineraddress"]); if (!IsValidPaymentAddress(zaddr) || - boost::get(&zaddr) == nullptr) + std::get_if(&zaddr) == nullptr) { return InitError(strprintf( _("Invalid address for -mineraddress=: '%s' (must be a Sapling or transparent address)"), @@ -1574,11 +1574,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (pwalletMain) { CTxDestination addr = keyIO.DecodeDestination(mapArgs["-mineraddress"]); if (IsValidDestination(addr)) { - CKeyID keyID = boost::get(addr); + CKeyID keyID = std::get(addr); minerAddressInLocalWallet = pwalletMain->HaveKey(keyID); } else { auto zaddr = keyIO.DecodePaymentAddress(mapArgs["-mineraddress"]); - minerAddressInLocalWallet = boost::apply_visitor( + minerAddressInLocalWallet = std::visit( HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr); } } diff --git a/src/key_io.cpp b/src/key_io.cpp index 27a1b8a2e..8e049d874 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -10,16 +10,15 @@ #include