From 1fce4ba83b6bc15c83fbca616544da82c7637c42 Mon Sep 17 00:00:00 2001 From: levonpetrosyan93 Date: Wed, 20 Jul 2022 19:58:32 +0400 Subject: [PATCH 1/3] Run batch verify when shuttown --- src/init.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/init.cpp b/src/init.cpp index ae9fa59906..b8f7234ba7 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -256,6 +256,7 @@ void Shutdown() llmq::StopLLMQSystem(); BatchProofContainer::get_instance()->finalize(); + BatchProofContainer::get_instance()->verify(); #ifdef ENABLE_WALLET if (pwalletMain) From fd22a995f34c50efa58d917adad0495d2e70d630 Mon Sep 17 00:00:00 2001 From: levonpetrosyan93 Date: Wed, 20 Jul 2022 19:59:24 +0400 Subject: [PATCH 2/3] Small optimization when using coincontrol --- src/wallet/wallet.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c787d90757..7561c71084 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3015,6 +3015,22 @@ std::list CWallet::GetAvailableLelantusCoins(const CCoinControl if (coin.IsUsed) return true; + COutPoint outPoint; + lelantus::PublicCoin pubCoin(coin.value); + lelantus::GetOutPoint(outPoint, pubCoin); + + if(lockedCoins.count(outPoint) > 0){ + return true; + } + + if(coinControl != NULL){ + if(coinControl->HasSelected()){ + if(!coinControl->IsSelected(outPoint)){ + return true; + } + } + } + int coinHeight, coinId; std::tie(coinHeight, coinId) = state->GetMintedCoinHeightAndId(lelantus::PublicCoin(coin.value)); @@ -3046,22 +3062,6 @@ std::list CWallet::GetAvailableLelantusCoins(const CCoinControl return true; } - COutPoint outPoint; - lelantus::PublicCoin pubCoin(coin.value); - lelantus::GetOutPoint(outPoint, pubCoin); - - if(lockedCoins.count(outPoint) > 0){ - return true; - } - - if(coinControl != NULL){ - if(coinControl->HasSelected()){ - if(!coinControl->IsSelected(outPoint)){ - return true; - } - } - } - return false; }); From 9460a7df32fad389bc15564e6222ed560a02583c Mon Sep 17 00:00:00 2001 From: levonpetrosyan93 Date: Wed, 20 Jul 2022 20:00:08 +0400 Subject: [PATCH 3/3] Fixing anonymity set generation --- src/lelantus.cpp | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/lelantus.cpp b/src/lelantus.cpp index 7a973a7929..a211af75cd 100644 --- a/src/lelantus.cpp +++ b/src/lelantus.cpp @@ -53,6 +53,13 @@ static bool CheckLelantusSpendSerial( return true; } +/* + * Util funtions + */ +size_t CountCoinInBlock(CBlockIndex *index, int id) { + return index->lelantusMintedPubCoins.count(id) > 0 + ? index->lelantusMintedPubCoins[id].size() : 0; +} std::vector GetAnonymitySetHash(CBlockIndex *index, int group_id, bool generation = false) { std::vector out_hash; @@ -501,17 +508,25 @@ bool CheckLelantusJoinSplitTransaction( // This list of public coins is required by function "Verify" of JoinSplit. while (true) { - if(index->lelantusMintedPubCoins.count(idAndHash.first) > 0) { - BOOST_FOREACH( - const auto& pubCoinValue, - index->lelantusMintedPubCoins[idAndHash.first]) { - // skip mints from blacklist if nLelantusFixesStartBlock is passed - if (chainActive.Height() >= ::Params().GetConsensus().nLelantusFixesStartBlock) { - if (::Params().GetConsensus().lelantusBlacklist.count(pubCoinValue.first.getValue()) > 0) { - continue; + int id = 0; + if (CountCoinInBlock(index, idAndHash.first)) { + id = idAndHash.first; + } else if (CountCoinInBlock(index, idAndHash.first - 1)) { + id = idAndHash.first - 1; + } + if (id) { + if(index->lelantusMintedPubCoins.count(id) > 0) { + BOOST_FOREACH( + const auto& pubCoinValue, + index->lelantusMintedPubCoins[id]) { + // skip mints from blacklist if nLelantusFixesStartBlock is passed + if (chainActive.Height() >= ::Params().GetConsensus().nLelantusFixesStartBlock) { + if (::Params().GetConsensus().lelantusBlacklist.count(pubCoinValue.first.getValue()) > 0) { + continue; + } } + anonymity_set.push_back(pubCoinValue.first); } - anonymity_set.push_back(pubCoinValue.first); } } if (index == coinGroup.firstBlock) @@ -1046,14 +1061,6 @@ void CLelantusTxInfo::Complete() { fInfoIsComplete = true; } -/* - * Util funtions - */ -size_t CountCoinInBlock(CBlockIndex *index, int id) { - return index->lelantusMintedPubCoins.count(id) > 0 - ? index->lelantusMintedPubCoins[id].size() : 0; -} - /******************************************************************************/ // CLelantusState::Containers /******************************************************************************/