diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 00c2e4c72bf..af361e0423a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,7 +7,7 @@ stages: ######################################################################################################################## variables: - VERSION: 1.1.2-1 + VERSION: 1.1.2-2 VERUS_CLI_ARM64_LINUX: Verus-CLI-Linux-v${VERSION}-arm64.tar.gz VERUS_CLI_LINUX_X86_64: Verus-CLI-Linux-v${VERSION}-x86_64.tar.gz diff --git a/README.md b/README.md index 6141a0eaf7e..6d744b555b0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -## VerusCoin version 1.1.2-1 +## VerusCoin version 1.1.2-2 Arguably the world's most advanced technology, zero knowledge privacy enabled, multi-chain blockchain protocol, Verus Public Blockchains as a Service (PBaaS) combines Sapling zero knowledge technology with an intelligent, multi-chain, provable protocol, using interchain smart transactions. Verus PBaaS also enables merge mining and cross-chain staking with a completely original, combined proof of stake/proof of work consensus algorithm, Proof of Power, that can be mined on CPUs and mobile phones, and also solves the nothing at stake problem. With this and its approach towards CPU mining and ASICs, Verus Coin strives to be one of the most naturally decentralizing and attack resistant blockchain networks in existence. diff --git a/doc/man/verus-cli/linux/README.txt b/doc/man/verus-cli/linux/README.txt index 08bb727eca2..76fece148fa 100644 --- a/doc/man/verus-cli/linux/README.txt +++ b/doc/man/verus-cli/linux/README.txt @@ -1,5 +1,5 @@ -VerusCoin Command Line Tools v1.1.2-1 +VerusCoin Command Line Tools v1.1.2-2 Contents: verusd - VerusCoin daemon diff --git a/doc/man/verus-cli/mac/README.txt b/doc/man/verus-cli/mac/README.txt index 32412b5ffe1..aed4e941f51 100644 --- a/doc/man/verus-cli/mac/README.txt +++ b/doc/man/verus-cli/mac/README.txt @@ -1,5 +1,5 @@ -VerusCoin Command Line Tools v1.1.2-1 +VerusCoin Command Line Tools v1.1.2-2 Contents: verusd - VerusCoin daemon. diff --git a/doc/man/verus-cli/windows/README.txt b/doc/man/verus-cli/windows/README.txt index 89bb1a6175c..49578c28b5f 100644 --- a/doc/man/verus-cli/windows/README.txt +++ b/doc/man/verus-cli/windows/README.txt @@ -1,5 +1,5 @@ -VerusCoin Command Line Tools v1.1.2-1 +VerusCoin Command Line Tools v1.1.2-2 Contents: verusd.exe - VerusCoin daemon diff --git a/src/deprecation.h b/src/deprecation.h index 76d305b82fa..36099a6f0a5 100644 --- a/src/deprecation.h +++ b/src/deprecation.h @@ -9,7 +9,7 @@ // * Shut down 52 weeks' worth of blocks after the estimated release block height. // * A warning is shown during the 2 months' worth of blocks prior to shut down. -static const int APPROX_RELEASE_HEIGHT = 2803000; +static const int APPROX_RELEASE_HEIGHT = 2811000; static const int WEEKS_UNTIL_DEPRECATION = 52; static const int DEPRECATION_HEIGHT = APPROX_RELEASE_HEIGHT + (WEEKS_UNTIL_DEPRECATION * 7 * 60 * 24); diff --git a/src/key_io.cpp b/src/key_io.cpp index f71fc88c856..d5a0ab840ae 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -812,6 +812,18 @@ CReserveTransfer::CReserveTransfer(const UniValue &uni) : CTokenOutput(uni), nFe destination = CTransferDestination(find_value(uni, "destination")); } +CReserveTransfer::CReserveTransfer(const CScript &script) : flags(0) +{ + COptCCParams p; + if (script.IsPayToCryptoCondition(p) && p.IsValid()) + { + if (p.evalCode == EVAL_RESERVE_TRANSFER && p.vData.size()) + { + FromVector(p.vData[0], *this); + } + } +} + CPrincipal::CPrincipal(const UniValue &uni) { nVersion = uni_get_int(find_value(uni, "version"), VERSION_VAULT); diff --git a/src/pbaas/crosschainrpc.cpp b/src/pbaas/crosschainrpc.cpp index b3759c1cb57..56d80aefd0c 100644 --- a/src/pbaas/crosschainrpc.cpp +++ b/src/pbaas/crosschainrpc.cpp @@ -58,6 +58,7 @@ uint32_t PBAAS_TESTFORK5_TIME = 1687042800; uint32_t PBAAS_TESTFORK6_TIME = 1687994100; uint32_t PBAAS_TESTFORK7_TIME = 1688799600; uint32_t PBAAS_TESTFORK8_TIME = 1690304400; +uint32_t PBAAS_TESTFORK9_TIME = 1701240000; uint32_t PBAAS_MAINDEFI3_HEIGHT = 2553500; uint32_t PBAAS_CLEARCONVERT_HEIGHT = 2588590; diff --git a/src/pbaas/pbaas.cpp b/src/pbaas/pbaas.cpp index f1fd9f8224d..f6531d8b102 100755 --- a/src/pbaas/pbaas.cpp +++ b/src/pbaas/pbaas.cpp @@ -3658,7 +3658,7 @@ CCurrencyDefinition::CCurrencyDefinition(const CScript &scriptPubKey) COptCCParams p; if (scriptPubKey.IsPayToCryptoCondition(p) && p.IsValid()) { - if (p.evalCode == EVAL_CURRENCY_DEFINITION) + if (p.evalCode == EVAL_CURRENCY_DEFINITION && p.vData.size()) { FromVector(p.vData[0], *this); } @@ -4579,7 +4579,8 @@ bool IsValidExportCurrency(const CCurrencyDefinition &systemDest, const uint160 return true; } - uint160 converterID = (!IsVerusActive && ConnectedChains.FirstNotaryChain().GetID() == sysID) ? ConnectedChains.ThisChain().GatewayConverterID() : systemDest.GatewayConverterID(); + int64_t thresholdTime = (height > 1 && chainActive.Height() >= height) ? chainActive[height]->nTime : chainActive.LastTip()->nTime; + uint160 converterID = ((!IsVerusActive() && thresholdTime > PBAAS_TESTFORK9_TIME) && ConnectedChains.FirstNotaryChain().GetID() == sysID) ? ConnectedChains.ThisChain().GatewayConverterID() : systemDest.GatewayConverterID(); if (!converterID.IsNull()) { CCurrencyDefinition converter = ConnectedChains.GetCachedCurrency(converterID); @@ -6692,7 +6693,7 @@ CCoinbaseCurrencyState CConnectedChains::AddPendingConversions(CCurrencyDefiniti // get chain transfers that should apply before the start block // until there is a post-start block notarization, we always consider the // currency state to be up to just before the start block - std::multimap unspentTransfers; + std::vector unspentTransfers; std::map currencyIndexes = currencyState.GetReserveMap(); if (GetUnspentChainTransfers(unspentTransfers, curDef.GetID()) && @@ -6701,10 +6702,7 @@ CCoinbaseCurrencyState CConnectedChains::AddPendingConversions(CCurrencyDefiniti std::vector transfers = extraConversions; for (auto &oneTransfer : unspentTransfers) { - if (std::get<0>(oneTransfer.second) < curDef.startBlock) - { - transfers.push_back(std::get<2>(oneTransfer.second)); - } + transfers.push_back(std::get<2>(oneTransfer)); } uint256 transferHash; CPBaaSNotarization newNotarization; diff --git a/src/pbaas/reserves.h b/src/pbaas/reserves.h index 8b21dc7663b..fc414483559 100644 --- a/src/pbaas/reserves.h +++ b/src/pbaas/reserves.h @@ -49,6 +49,7 @@ extern uint32_t PBAAS_TESTFORK5_TIME; extern uint32_t PBAAS_TESTFORK6_TIME; extern uint32_t PBAAS_TESTFORK7_TIME; extern uint32_t PBAAS_TESTFORK8_TIME; +extern uint32_t PBAAS_TESTFORK9_TIME; extern uint32_t PBAAS_MAINDEFI3_HEIGHT; extern uint32_t PBAAS_CLEARCONVERT_HEIGHT; extern uint32_t PBAAS_LASTKNOWNCLEARORACLE_HEIGHT; @@ -204,6 +205,7 @@ class CReserveTransfer : public CTokenOutput CReserveTransfer() : CTokenOutput(), flags(0), nFees(0) { } CReserveTransfer(const UniValue &uni); + CReserveTransfer(const CScript &script); CReserveTransfer(const std::vector &asVector) { diff --git a/src/rpc/pbaasrpc.cpp b/src/rpc/pbaasrpc.cpp index 5ae3ca8d00a..5c09007b6c3 100644 --- a/src/rpc/pbaasrpc.cpp +++ b/src/rpc/pbaasrpc.cpp @@ -2214,26 +2214,25 @@ UniValue getpendingtransfers(const UniValue& params, bool fHelp) if (GetCurrencyDefinition(chainID, chainDef, &defHeight)) { - // look for new exports - multimap inputDescriptors; + std::vector unspentOutputs; - if (GetUnspentChainTransfers(inputDescriptors, chainID)) + if (GetUnspentChainTransfers(unspentOutputs, chainID)) { UniValue ret(UniValue::VARR); - for (auto &desc : inputDescriptors) + for (auto &desc : unspentOutputs) { UniValue oneExport(UniValue::VOBJ); - uint32_t inpHeight = std::get<0>(desc.second); - CInputDescriptor inpDesc = std::get<1>(desc.second); - - oneExport.push_back(Pair("currencyid", EncodeDestination(CIdentityID(desc.first)))); - oneExport.push_back(Pair("height", (int64_t)inpHeight)); - oneExport.push_back(Pair("txid", inpDesc.txIn.prevout.hash.GetHex())); - oneExport.push_back(Pair("n", (int32_t)inpDesc.txIn.prevout.n)); - oneExport.push_back(Pair("valueout", inpDesc.nValue)); - oneExport.push_back(Pair("reservetransfer", std::get<2>(desc.second).ToUniValue())); - ret.push_back(oneExport); + if (std::get<2>(desc).IsValid()) + { + oneExport.push_back(Pair("currencyid", EncodeDestination(CIdentityID(chainID)))); + oneExport.push_back(Pair("height", (int64_t)std::get<0>(desc))); + oneExport.push_back(Pair("txid", std::get<1>(desc).txIn.prevout.hash.GetHex())); + oneExport.push_back(Pair("n", (int32_t)std::get<1>(desc).txIn.prevout.n)); + oneExport.push_back(Pair("valueout", std::get<1>(desc).nValue)); + oneExport.push_back(Pair("reservetransfer", std::get<2>(desc).ToUniValue())); + ret.push_back(oneExport); + } } if (ret.size()) { @@ -3378,6 +3377,67 @@ bool GetUnspentChainTransfers(std::multimap &inputDe } } +// returns all unspent chain transfer outputs, * including from the mempool * +bool GetUnspentChainTransfers(std::vector &inputDescriptors, uint160 chainID) +{ + std::vector> unspentOutputs; + + LOCK(cs_main); + LOCK2(smartTransactionCS, mempool.cs); + + if (!ConnectedChains.GetUnspentByIndex(CReserveTransfer::ReserveTransferKey(), unspentOutputs)) + { + return false; + } + else + { + CCoins coins; + CCoinsView dummy; + CCoinsViewCache view(&dummy); + + CCoinsViewMemPool viewMemPool(pcoinsTip, mempool); + view.SetBackend(viewMemPool); + + for (auto it = unspentOutputs.begin(); it != unspentOutputs.end(); it++) + { + CCoins coins; + + if (view.GetCoins(it->first.txIn.prevout.hash, coins)) + { + if (coins.IsAvailable(it->first.txIn.prevout.n)) + { + // if this is a transfer output, optionally to this chain, add it to the input vector + // chain filter was applied in index search + COptCCParams p; + COptCCParams m; + CReserveTransfer rt; + uint160 destCID; + if (coins.vout[it->first.txIn.prevout.n].scriptPubKey.IsPayToCryptoCondition(p) && + p.evalCode == EVAL_RESERVE_TRANSFER && + p.vData.size() && + p.version >= p.VERSION_V3 && + (m = COptCCParams(p.vData.back())).IsValid() && + (rt = CReserveTransfer(p.vData[0])).IsValid() && + !(destCID = rt.GetImportCurrency()).IsNull() && + destCID == chainID) + { + inputDescriptors.push_back(ChainTransferData(it->second, + CInputDescriptor(coins.vout[it->first.txIn.prevout.n].scriptPubKey, + coins.vout[it->first.txIn.prevout.n].nValue, + CTxIn(COutPoint(it->first.txIn.prevout.hash, it->first.txIn.prevout.n))), + rt)); + } + } + } + else + { + LogPrint("crosschainexports", "%s: cannot retrieve transaction %s from height %u\n", __func__, it->first.txIn.prevout.hash.GetHex().c_str(), coins.nHeight); + } + } + return true; + } +} + void CChainNotarizationData::SetBestChain(const CCurrencyDefinition &fromChainDef, const std::vector> &txesAndBlocks) { diff --git a/src/rpc/pbaasrpc.h b/src/rpc/pbaasrpc.h index 5785be6addc..90b41e93d28 100644 --- a/src/rpc/pbaasrpc.h +++ b/src/rpc/pbaasrpc.h @@ -36,6 +36,7 @@ bool GetChainTransfersUnspentBy(std::multimap, std: bool GetChainTransfersBetween(std::multimap, std::pair> &inputDescriptors, uint160 chainFilter, uint32_t start, uint32_t end, uint32_t flags=CReserveTransfer::VALID); bool GetUnspentChainTransfers(std::multimap &inputDescriptors, uint160 chainFilter = uint160()); +bool GetUnspentChainTransfers(std::vector &inputDescriptors, uint160 chainID); std::multimap, std::pair, std::pair>> GetOfferMap(const uint160 ¤cyOrId, bool isCurrency, bool acceptOnlyCurrency, bool acceptOnlyId, const std::set ¤cyOrIdFilter); diff --git a/src/version.h b/src/version.h index 2ed3ef13c48..1547927421e 100644 --- a/src/version.h +++ b/src/version.h @@ -35,6 +35,6 @@ static const int MEMPOOL_GD_VERSION = 60002; static const int NO_BLOOM_VERSION = 170004; #define KOMODO_VERSION "0.2.1" -#define VERUS_VERSION "1.1.2-1" +#define VERUS_VERSION "1.1.2-2" #endif // BITCOIN_VERSION_H