diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 8097633d35bae8..3018e30549fa51 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -283,7 +283,6 @@ class CMainParams : public CChainParams { AddLLMQ(Consensus::LLMQType::LLMQ_400_85); AddLLMQ(Consensus::LLMQType::LLMQ_100_67); consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_400_60; - consensus.llmqTypeInstantSend = Consensus::LLMQType::LLMQ_50_60; consensus.llmqTypeDIP0024InstantSend = Consensus::LLMQType::LLMQ_60_75; consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_100_67; consensus.llmqTypeMnhf = Consensus::LLMQType::LLMQ_400_85; @@ -475,7 +474,6 @@ class CTestNetParams : public CChainParams { AddLLMQ(Consensus::LLMQType::LLMQ_100_67); AddLLMQ(Consensus::LLMQType::LLMQ_25_67); consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_50_60; - consensus.llmqTypeInstantSend = Consensus::LLMQType::LLMQ_50_60; consensus.llmqTypeDIP0024InstantSend = Consensus::LLMQType::LLMQ_60_75; consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_25_67; consensus.llmqTypeMnhf = Consensus::LLMQType::LLMQ_50_60; @@ -650,14 +648,12 @@ class CDevNetParams : public CChainParams { AddLLMQ(Consensus::LLMQType::LLMQ_DEVNET_DIP0024); AddLLMQ(Consensus::LLMQType::LLMQ_DEVNET_PLATFORM); consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_DEVNET; - consensus.llmqTypeInstantSend = Consensus::LLMQType::LLMQ_DEVNET; consensus.llmqTypeDIP0024InstantSend = Consensus::LLMQType::LLMQ_DEVNET_DIP0024; consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_DEVNET_PLATFORM; consensus.llmqTypeMnhf = Consensus::LLMQType::LLMQ_DEVNET; consensus.llmqTypeAssetLocks = consensus.llmqTypePlatform; UpdateDevnetLLMQChainLocksFromArgs(args); - UpdateDevnetLLMQInstantSendFromArgs(args); UpdateDevnetLLMQInstantSendDIP0024FromArgs(args); UpdateDevnetLLMQPlatformFromArgs(args); UpdateDevnetLLMQMnhfFromArgs(args); @@ -714,14 +710,6 @@ class CDevNetParams : public CChainParams { } void UpdateDevnetLLMQChainLocksFromArgs(const ArgsManager& args); - /** - * Allows modifying the LLMQ type for InstantSend. - */ - void UpdateDevnetLLMQInstantSend(Consensus::LLMQType llmqType) - { - consensus.llmqTypeInstantSend = llmqType; - } - /** * Allows modifying the LLMQ type for InstantSend (DIP0024). */ @@ -937,7 +925,6 @@ class CRegTestParams : public CChainParams { AddLLMQ(Consensus::LLMQType::LLMQ_TEST_DIP0024); AddLLMQ(Consensus::LLMQType::LLMQ_TEST_PLATFORM); consensus.llmqTypeChainLocks = Consensus::LLMQType::LLMQ_TEST; - consensus.llmqTypeInstantSend = Consensus::LLMQType::LLMQ_TEST_INSTANTSEND; consensus.llmqTypeDIP0024InstantSend = Consensus::LLMQType::LLMQ_TEST_DIP0024; consensus.llmqTypePlatform = Consensus::LLMQType::LLMQ_TEST_PLATFORM; consensus.llmqTypeMnhf = Consensus::LLMQType::LLMQ_TEST; @@ -945,7 +932,6 @@ class CRegTestParams : public CChainParams { UpdateLLMQTestParametersFromArgs(args, Consensus::LLMQType::LLMQ_TEST); UpdateLLMQTestParametersFromArgs(args, Consensus::LLMQType::LLMQ_TEST_INSTANTSEND); - UpdateLLMQInstantSendFromArgs(args); UpdateLLMQInstantSendDIP0024FromArgs(args); } @@ -1017,14 +1003,6 @@ class CRegTestParams : public CChainParams { params->dkgBadVotesThreshold = threshold; } - /** - * Allows modifying the LLMQ type for InstantSend. - */ - void UpdateLLMQInstantSend(Consensus::LLMQType llmqType) - { - consensus.llmqTypeInstantSend = llmqType; - } - /** * Allows modifying the LLMQ type for InstantSend (DIP0024). */ @@ -1034,7 +1012,6 @@ class CRegTestParams : public CChainParams { } void UpdateLLMQTestParametersFromArgs(const ArgsManager& args, const Consensus::LLMQType llmqType); - void UpdateLLMQInstantSendFromArgs(const ArgsManager& args); void UpdateLLMQInstantSendDIP0024FromArgs(const ArgsManager& args); }; @@ -1180,28 +1157,6 @@ void CRegTestParams::UpdateLLMQTestParametersFromArgs(const ArgsManager& args, c UpdateLLMQTestParameters(size, threshold, llmqType); } -void CRegTestParams::UpdateLLMQInstantSendFromArgs(const ArgsManager& args) -{ - if (!args.IsArgSet("-llmqtestinstantsend")) return; - - const auto& llmq_params_opt = GetLLMQ(consensus.llmqTypeInstantSend); - assert(llmq_params_opt.has_value()); - - std::string strLLMQType = gArgs.GetArg("-llmqtestinstantsend", std::string(llmq_params_opt->name)); - - Consensus::LLMQType llmqType = Consensus::LLMQType::LLMQ_NONE; - for (const auto& params : consensus.llmqs) { - if (params.name == strLLMQType) { - llmqType = params.type; - } - } - if (llmqType == Consensus::LLMQType::LLMQ_NONE) { - throw std::runtime_error("Invalid LLMQ type specified for -llmqtestinstantsend."); - } - LogPrintf("Setting llmqtestinstantsend to %ld\n", ToUnderlying(llmqType)); - UpdateLLMQInstantSend(llmqType); -} - void CRegTestParams::UpdateLLMQInstantSendDIP0024FromArgs(const ArgsManager& args) { if (!args.IsArgSet("-llmqtestinstantsenddip0024")) return; @@ -1260,31 +1215,6 @@ void CDevNetParams::UpdateDevnetLLMQChainLocksFromArgs(const ArgsManager& args) UpdateDevnetLLMQChainLocks(llmqType); } -void CDevNetParams::UpdateDevnetLLMQInstantSendFromArgs(const ArgsManager& args) -{ - if (!args.IsArgSet("-llmqinstantsend")) return; - - const auto& llmq_params_opt = GetLLMQ(consensus.llmqTypeInstantSend); - assert(llmq_params_opt.has_value()); - - std::string strLLMQType = gArgs.GetArg("-llmqinstantsend", std::string(llmq_params_opt->name)); - - Consensus::LLMQType llmqType = Consensus::LLMQType::LLMQ_NONE; - for (const auto& params : consensus.llmqs) { - if (params.name == strLLMQType) { - if (params.useRotation) { - throw std::runtime_error("LLMQ type specified for -llmqinstantsend must NOT use rotation"); - } - llmqType = params.type; - } - } - if (llmqType == Consensus::LLMQType::LLMQ_NONE) { - throw std::runtime_error("Invalid LLMQ type specified for -llmqinstantsend."); - } - LogPrintf("Setting llmqinstantsend to size=%ld\n", static_cast(llmqType)); - UpdateDevnetLLMQInstantSend(llmqType); -} - void CDevNetParams::UpdateDevnetLLMQInstantSendDIP0024FromArgs(const ArgsManager& args) { if (!args.IsArgSet("-llmqinstantsenddip0024")) return; diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index 5e99c2e8cdffdf..7e8eb03a0307d6 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -25,11 +25,9 @@ void SetupChainParamsBaseOptions(ArgsManager& argsman) argsman.AddArg("-highsubsidyfactor=", "The factor to multiply the normal block subsidy by while in the highsubsidyblocks window of a chain (default: 1, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-llmqchainlocks=", "Override the default LLMQ type used for ChainLocks. Allows using ChainLocks with smaller LLMQs. (default: llmq_devnet, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-llmqdevnetparams=:", "Override the default LLMQ size for the LLMQ_DEVNET quorum (default: 3:2, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); - argsman.AddArg("-llmqinstantsend=", "Override the default LLMQ type used for InstantSend. Allows using InstantSend with smaller LLMQs. (default: llmq_devnet, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-llmqinstantsenddip0024=", "Override the default LLMQ type used for InstantSendDIP0024. (default: llmq_devnet_dip0024, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-llmqplatform=", "Override the default LLMQ type used for Platform. (default: llmq_devnet_platform, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-llmqmnhf=", "Override the default LLMQ type used for EHF. (default: llmq_devnet, devnet-only)", ArgsManager::ALLOW_ANY, OptionsCategory::CHAINPARAMS); - argsman.AddArg("-llmqtestinstantsend=", "Override the default LLMQ type used for InstantSend. Used mainly to test Platform. (default: llmq_test_instantsend, regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-llmqtestinstantsenddip0024=", "Override the default LLMQ type used for InstantSendDIP0024. Used mainly to test Platform. (default: llmq_test_dip0024, regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-llmqtestinstantsendparams=:", "Override the default LLMQ size for the LLMQ_TEST_INSTANTSEND quorums (default: 3:2, regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); argsman.AddArg("-llmqtestparams=:", "Override the default LLMQ size for the LLMQ_TEST quorum (default: 3:2, regtest-only)", ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CHAINPARAMS); diff --git a/src/consensus/params.h b/src/consensus/params.h index 650133c6d2e1f4..ac0c8cbf1de41f 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -142,7 +142,6 @@ struct Params { std::vector llmqs; LLMQType llmqTypeChainLocks; - LLMQType llmqTypeInstantSend{LLMQType::LLMQ_NONE}; LLMQType llmqTypeDIP0024InstantSend{LLMQType::LLMQ_NONE}; LLMQType llmqTypePlatform{LLMQType::LLMQ_NONE}; LLMQType llmqTypeMnhf{LLMQType::LLMQ_NONE}; diff --git a/src/llmq/instantsend.cpp b/src/llmq/instantsend.cpp index 2006ca3b991698..bc4a6229134e3a 100644 --- a/src/llmq/instantsend.cpp +++ b/src/llmq/instantsend.cpp @@ -41,8 +41,7 @@ static const std::string DB_ARCHIVED_BY_HASH = "is_a2"; static const std::string DB_VERSION = "is_v"; const int CInstantSendDb::CURRENT_VERSION; -const uint8_t CInstantSendLock::islock_version; -const uint8_t CInstantSendLock::isdlock_version; +const uint8_t CInstantSendLock::CURRENT_VERSION; std::unique_ptr quorumInstantSendManager; @@ -327,7 +326,7 @@ CInstantSendLockPtr CInstantSendDb::GetInstantSendLockByHashInternal(const uint2 return ret; } - ret = std::make_shared(CInstantSendLock::isdlock_version); + ret = std::make_shared(); bool exists = db->Read(std::make_tuple(DB_ISLOCK_BY_HASH, hash), *ret); if (!exists || (::SerializeHash(*ret) != hash)) { ret = std::make_shared(); @@ -486,8 +485,7 @@ void CInstantSendManager::ProcessTx(const CTransaction& tx, bool fRetroactive, c return; } - if (params.llmqTypeInstantSend == Consensus::LLMQType::LLMQ_NONE || - params.llmqTypeDIP0024InstantSend == Consensus::LLMQType::LLMQ_NONE) { + if (params.llmqTypeDIP0024InstantSend == Consensus::LLMQType::LLMQ_NONE) { return; } @@ -511,7 +509,7 @@ void CInstantSendManager::ProcessTx(const CTransaction& tx, bool fRetroactive, c // block after we retroactively locked all transactions. if (!IsInstantSendMempoolSigningEnabled() && !fRetroactive) return; - if (!TrySignInputLocks(tx, fRetroactive, utils::GetInstantSendLLMQType(qman, WITH_LOCK(cs_main, return m_chainstate.m_chain.Tip())), params)) { + if (!TrySignInputLocks(tx, fRetroactive, params.llmqTypeDIP0024InstantSend, params)) { return; } @@ -532,8 +530,7 @@ bool CInstantSendManager::TrySignInputLocks(const CTransaction& tx, bool fRetroa uint256 otherTxHash; // TODO check that we didn't vote for the other IS type also - if (sigman.GetVoteForId(params.llmqTypeDIP0024InstantSend, id, otherTxHash) || - sigman.GetVoteForId(params.llmqTypeInstantSend, id, otherTxHash)) { + if (sigman.GetVoteForId(params.llmqTypeDIP0024InstantSend, id, otherTxHash)) { if (otherTxHash != tx.GetHash()) { LogPrintf("CInstantSendManager::%s -- txid=%s: input %s is conflicting with previous vote for tx %s\n", __func__, tx.GetHash().ToString(), in.prevout.ToStringShort(), otherTxHash.ToString()); @@ -543,10 +540,7 @@ bool CInstantSendManager::TrySignInputLocks(const CTransaction& tx, bool fRetroa } // don't even try the actual signing if any input is conflicting - if (auto llmqs = {params.llmqTypeDIP0024InstantSend, params.llmqTypeInstantSend}; - ranges::any_of(llmqs, [&id, &tx, this](const auto& llmqType){ - return sigman.IsConflicting(llmqType, id, tx.GetHash());}) - ) { + if (sigman.IsConflicting(params.llmqTypeDIP0024InstantSend, id, tx.GetHash())) { LogPrintf("CInstantSendManager::%s -- txid=%s: sigman.IsConflicting returned true. id=%s\n", __func__, tx.GetHash().ToString(), id.ToString()); return false; @@ -641,8 +635,7 @@ void CInstantSendManager::HandleNewRecoveredSig(const CRecoveredSig& recoveredSi return; } - if (Params().GetConsensus().llmqTypeInstantSend == Consensus::LLMQType::LLMQ_NONE || - Params().GetConsensus().llmqTypeDIP0024InstantSend == Consensus::LLMQType::LLMQ_NONE) { + if (Params().GetConsensus().llmqTypeDIP0024InstantSend == Consensus::LLMQType::LLMQ_NONE) { return; } @@ -685,7 +678,7 @@ void CInstantSendManager::HandleNewInputLockRecoveredSig(const CRecoveredSig& re void CInstantSendManager::TrySignInstantSendLock(const CTransaction& tx) { - const auto llmqType = utils::GetInstantSendLLMQType(qman, WITH_LOCK(cs_main, return m_chainstate.m_chain.Tip())); + const auto llmqType = Params().GetConsensus().llmqTypeDIP0024InstantSend; for (const auto& in : tx.vin) { auto id = ::SerializeHash(std::make_pair(INPUTLOCK_REQUESTID_PREFIX, in.prevout)); @@ -767,7 +760,7 @@ void CInstantSendManager::ProcessMessage(const CNode& pfrom, const std::string& } if (msg_type == NetMsgType::ISDLOCK) { - const auto islock = std::make_shared(CInstantSendLock::isdlock_version); + const auto islock = std::make_shared(); vRecv >> *islock; ProcessMessageInstantSendLock(pfrom, islock); } @@ -777,42 +770,28 @@ void CInstantSendManager::ProcessMessageInstantSendLock(const CNode& pfrom, cons { auto hash = ::SerializeHash(*islock); - bool fDIP0024IsActive = false; - { - LOCK(cs_main); - EraseObjectRequest(pfrom.GetId(), CInv(MSG_ISDLOCK, hash)); - fDIP0024IsActive = utils::IsDIP0024Active(m_chainstate.m_chain.Tip()); - } + WITH_LOCK(cs_main, EraseObjectRequest(pfrom.GetId(), CInv(MSG_ISDLOCK, hash))); if (!islock->TriviallyValid()) { m_peerman->Misbehaving(pfrom.GetId(), 100); return; } - // Deterministic ISLocks are only produced by rotation quorums, if we don't see DIP24 as active, then we won't be able to validate it anyway - if (fDIP0024IsActive) { - const auto blockIndex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(islock->cycleHash)); - if (blockIndex == nullptr) { - // Maybe we don't have the block yet or maybe some peer spams invalid values for cycleHash - m_peerman->Misbehaving(pfrom.GetId(), 1); - return; - } - - // Deterministic islocks MUST use rotation based llmq - auto llmqType = Params().GetConsensus().llmqTypeDIP0024InstantSend; - const auto& llmq_params_opt = GetLLMQParams(llmqType); - assert(llmq_params_opt); - if (blockIndex->nHeight % llmq_params_opt->dkgInterval != 0) { - m_peerman->Misbehaving(pfrom.GetId(), 100); - return; - } + const auto blockIndex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(islock->cycleHash)); + if (blockIndex == nullptr) { + // Maybe we don't have the block yet or maybe some peer spams invalid values for cycleHash + m_peerman->Misbehaving(pfrom.GetId(), 1); + return; } - // WE MUST STILL PROCESS OLD ISLOCKS? -// else if (utils::IsDIP0024Active(WITH_LOCK(cs_main, return m_chainstate.m_chain.Tip()))) { -// // Ignore non-deterministic islocks once rotation is active -// return; -// } + // Deterministic islocks MUST use rotation based llmq + auto llmqType = Params().GetConsensus().llmqTypeDIP0024InstantSend; + const auto& llmq_params_opt = GetLLMQParams(llmqType); + assert(llmq_params_opt); + if (blockIndex->nHeight % llmq_params_opt->dkgInterval != 0) { + m_peerman->Misbehaving(pfrom.GetId(), 100); + return; + } if (WITH_LOCK(cs_pendingLocks, return pendingInstantSendLocks.count(hash) || pendingNoTxInstantSendLocks.count(hash)) || db.KnownInstantSendLock(hash)) { @@ -940,20 +919,16 @@ std::unordered_set CInstantSendManager::ProcessPend continue; } - int nSignHeight{-1}; - { - LOCK(cs_main); - - const auto blockIndex = m_chainstate.m_blockman.LookupBlockIndex(islock->cycleHash); - if (blockIndex == nullptr) { - batchVerifier.badSources.emplace(nodeId); - continue; - } + const auto blockIndex = WITH_LOCK(cs_main, return m_chainstate.m_blockman.LookupBlockIndex(islock->cycleHash)); + if (blockIndex == nullptr) { + batchVerifier.badSources.emplace(nodeId); + continue; + } - const auto dkgInterval = llmq_params.dkgInterval; - if (blockIndex->nHeight + dkgInterval < m_chainstate.m_chain.Height()) { - nSignHeight = blockIndex->nHeight + dkgInterval - 1; - } + int nSignHeight{-1}; + const auto dkgInterval = llmq_params.dkgInterval; + if (blockIndex->nHeight + dkgInterval < m_chainstate.m_chain.Height()) { + nSignHeight = blockIndex->nHeight + dkgInterval - 1; } auto quorum = llmq::CSigningManager::SelectQuorumForSigning(llmq_params, qman, id, nSignHeight, signOffset); @@ -1274,7 +1249,7 @@ void CInstantSendManager::TruncateRecoveredSigsForInputs(const llmq::CInstantSen for (const auto& in : islock.inputs) { auto inputRequestId = ::SerializeHash(std::make_pair(INPUTLOCK_REQUESTID_PREFIX, in)); WITH_LOCK(cs_inputReqests, inputRequestIds.erase(inputRequestId)); - sigman.TruncateRecoveredSig(utils::GetInstantSendLLMQType(true), inputRequestId); + sigman.TruncateRecoveredSig(Params().GetConsensus().llmqTypeDIP0024InstantSend, inputRequestId); } } @@ -1325,7 +1300,7 @@ void CInstantSendManager::HandleFullyConfirmedBlock(const CBlockIndex* pindex) // And we don't need the recovered sig for the ISLOCK anymore, as the block in which it got mined is considered // fully confirmed now - sigman.TruncateRecoveredSig(utils::GetInstantSendLLMQType(true), islock->GetRequestId()); + sigman.TruncateRecoveredSig(Params().GetConsensus().llmqTypeDIP0024InstantSend, islock->GetRequestId()); } db.RemoveArchivedInstantSendLocks(pindex->nHeight - 100); diff --git a/src/llmq/instantsend.h b/src/llmq/instantsend.h index 152c96ff0cd249..4ee8eedba055f1 100644 --- a/src/llmq/instantsend.h +++ b/src/llmq/instantsend.h @@ -35,30 +35,22 @@ class CSigSharesManager; struct CInstantSendLock { - // This is the old format of instant send lock, it must be 0 - static constexpr uint8_t islock_version{0}; - // This is the new format of instant send deterministic lock, this should be incremented for new isdlock versions - static constexpr uint8_t isdlock_version{1}; + static constexpr uint8_t CURRENT_VERSION{1}; - uint8_t nVersion; + uint8_t nVersion{CURRENT_VERSION}; std::vector inputs; uint256 txid; uint256 cycleHash; CBLSLazySignature sig; - CInstantSendLock() : CInstantSendLock(isdlock_version) {} - explicit CInstantSendLock(const uint8_t desiredVersion) : nVersion(desiredVersion) {} + CInstantSendLock() = default; SERIALIZE_METHODS(CInstantSendLock, obj) { - if (s.GetVersion() >= ISDLOCK_PROTO_VERSION) { - READWRITE(obj.nVersion); - } + READWRITE(obj.nVersion); READWRITE(obj.inputs); READWRITE(obj.txid); - if (s.GetVersion() >= ISDLOCK_PROTO_VERSION) { - READWRITE(obj.cycleHash); - } + READWRITE(obj.cycleHash); READWRITE(obj.sig); } diff --git a/src/llmq/quorums.cpp b/src/llmq/quorums.cpp index dcfd7ac4785698..dd2ec5a7376c5c 100644 --- a/src/llmq/quorums.cpp +++ b/src/llmq/quorums.cpp @@ -327,7 +327,9 @@ void CQuorumManager::CheckQuorumConnections(const Consensus::LLMQParams& llmqPar } const auto myProTxHash = WITH_LOCK(activeMasternodeInfoCs, return activeMasternodeInfo.proTxHash); - bool isISType = llmqParams.type == Params().GetConsensus().llmqTypeInstantSend || + // FIXME: should only check llmqTypeDIP0024InstantSend here but feature_llmq_connections.py is broken + // bool isISType = llmqParams.type == Params().GetConsensus().llmqTypeDIP0024InstantSend; + bool isISType = llmqParams.type == Consensus::LLMQType::LLMQ_TEST_INSTANTSEND || llmqParams.type == Params().GetConsensus().llmqTypeDIP0024InstantSend; bool watchOtherISQuorums = isISType && !myProTxHash.IsNull() && diff --git a/src/llmq/utils.cpp b/src/llmq/utils.cpp index d2565efe54653c..b780a927b78b92 100644 --- a/src/llmq/utils.cpp +++ b/src/llmq/utils.cpp @@ -62,8 +62,6 @@ static std::pair GetMNUsageBySnapsho static void BuildQuorumSnapshot(const Consensus::LLMQParams& llmqParams, const CDeterministicMNList& allMns, const CDeterministicMNList& mnUsedAtH, std::vector& sortedCombinedMns, CQuorumSnapshot& quorumSnapshot, int nHeight, std::vector& skipList, const CBlockIndex* pCycleQuorumBaseBlockIndex); -static bool IsInstantSendLLMQTypeShared(); - uint256 GetHashModifier(const Consensus::LLMQParams& llmqParams, const CBlockIndex* pCycleQuorumBaseBlockIndex) { ASSERT_IF_DEBUG(pCycleQuorumBaseBlockIndex->nHeight % llmqParams.dkgInterval == 0); @@ -685,19 +683,6 @@ bool IsQuorumRotationEnabled(const Consensus::LLMQParams& llmqParams, const CBlo return IsDIP0024Active(pindex->GetAncestor(cycleQuorumBaseHeight - 1)); } -Consensus::LLMQType GetInstantSendLLMQType(const CQuorumManager& qman, const CBlockIndex* pindex) -{ - if (IsDIP0024Active(pindex) && !qman.ScanQuorums(Params().GetConsensus().llmqTypeDIP0024InstantSend, pindex, 1).empty()) { - return Params().GetConsensus().llmqTypeDIP0024InstantSend; - } - return Params().GetConsensus().llmqTypeInstantSend; -} - -Consensus::LLMQType GetInstantSendLLMQType(bool deterministic) -{ - return deterministic ? Params().GetConsensus().llmqTypeDIP0024InstantSend : Params().GetConsensus().llmqTypeInstantSend; -} - bool IsDIP0024Active(const CBlockIndex* pindex) { assert(pindex); @@ -742,17 +727,6 @@ int GetV20Since(const CBlockIndex* pindex) return VersionBitsStateSinceHeight(pindex, Params().GetConsensus(), Consensus::DEPLOYMENT_V20, llmq_versionbitscache); } -bool IsInstantSendLLMQTypeShared() -{ - if (Params().GetConsensus().llmqTypeInstantSend == Params().GetConsensus().llmqTypeChainLocks || - Params().GetConsensus().llmqTypeInstantSend == Params().GetConsensus().llmqTypePlatform || - Params().GetConsensus().llmqTypeInstantSend == Params().GetConsensus().llmqTypeMnhf) { - return true; - } - - return false; -} - uint256 DeterministicOutboundConnection(const uint256& proTxHash1, const uint256& proTxHash2) { // We need to deterministically select who is going to initiate the connection. The naive way would be to simply @@ -994,11 +968,12 @@ bool IsQuorumTypeEnabledInternal(Consensus::LLMQType llmqType, const CQuorumMana switch (llmqType) { - case Consensus::LLMQType::LLMQ_TEST_INSTANTSEND: case Consensus::LLMQType::LLMQ_DEVNET: - case Consensus::LLMQType::LLMQ_50_60: { - if (IsInstantSendLLMQTypeShared()) return true; - + return true; + case Consensus::LLMQType::LLMQ_50_60: + if (Params().NetworkIDString() == CBaseChainParams::TESTNET) return true; + // fall through + case Consensus::LLMQType::LLMQ_TEST_INSTANTSEND: { bool fDIP0024IsActive = optDIP0024IsActive.has_value() ? *optDIP0024IsActive : IsDIP0024Active(pindex); if (!fDIP0024IsActive) return true; diff --git a/src/llmq/utils.h b/src/llmq/utils.h index b6be96ac71d4cb..0df7d21d2d0c9b 100644 --- a/src/llmq/utils.h +++ b/src/llmq/utils.h @@ -70,8 +70,6 @@ std::vector GetEnabledQuorumTypes(const CBlockIndex* pindex std::vector> GetEnabledQuorumParams(const CBlockIndex* pindex); bool IsQuorumRotationEnabled(const Consensus::LLMQParams& llmqParams, const CBlockIndex* pindex); -Consensus::LLMQType GetInstantSendLLMQType(const CQuorumManager& qman, const CBlockIndex* pindex); -Consensus::LLMQType GetInstantSendLLMQType(bool deterministic); bool IsDIP0024Active(const CBlockIndex* pindex); bool IsV19Active(const CBlockIndex* pindex); bool IsV20Active(const CBlockIndex* pindex); diff --git a/src/protocol.h b/src/protocol.h index 64bd2382f4fc1e..a34d4caf66c336 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -524,7 +524,7 @@ enum GetDataMsg { /* MSG_QUORUM_DEBUG_STATUS = 27, */ // was shortly used on testnet/devnet/regtest MSG_QUORUM_RECOVERED_SIG = 28, MSG_CLSIG = 29, - /* MSG_ISLOCK = 30, */ // Non-deterministic InstantSend and not used anymore + /* MSG_ISLOCK = 30, */ // Non-deterministic InstantSend and not used anymore MSG_ISDLOCK = 31, }; diff --git a/src/rpc/quorums.cpp b/src/rpc/quorums.cpp index 3d46fb21adb75c..eb553fed2ac50f 100644 --- a/src/rpc/quorums.cpp +++ b/src/rpc/quorums.cpp @@ -978,7 +978,7 @@ static UniValue verifyislock(const JSONRPCRequest& request) const LLMQContext& llmq_ctx = EnsureLLMQContext(node); - auto llmqType = llmq::utils::GetInstantSendLLMQType(*llmq_ctx.qman, pBlockIndex); + auto llmqType = Params().GetConsensus().llmqTypeDIP0024InstantSend; // First check against the current active set, if it fails check against the last active set const auto& llmq_params_opt = llmq::GetLLMQParams(llmqType); CHECK_NONFATAL(llmq_params_opt.has_value()); diff --git a/src/test/evo_utils_tests.cpp b/src/test/evo_utils_tests.cpp index c9e796e7b5a166..2f214c0d0961bb 100644 --- a/src/test/evo_utils_tests.cpp +++ b/src/test/evo_utils_tests.cpp @@ -22,9 +22,6 @@ void Test(llmq::CQuorumManager& qman) { using namespace llmq::utils; const auto& consensus_params = Params().GetConsensus(); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeInstantSend, qman, nullptr, false, false), true); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeInstantSend, qman, nullptr, true, false), true); - BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeInstantSend, qman, nullptr, true, true), false); BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeDIP0024InstantSend, qman, nullptr, false, false), false); BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeDIP0024InstantSend, qman, nullptr, true, false), true); BOOST_CHECK_EQUAL(IsQuorumTypeEnabledInternal(consensus_params.llmqTypeDIP0024InstantSend, qman, nullptr, true, true), true); diff --git a/test/functional/feature_llmq_is_retroactive.py b/test/functional/feature_llmq_is_retroactive.py index 132a4da1fe1b4f..951a71191ad8ee 100755 --- a/test/functional/feature_llmq_is_retroactive.py +++ b/test/functional/feature_llmq_is_retroactive.py @@ -8,9 +8,9 @@ Tests retroactive signing -We have 6 nodes where node 0 is the control node, nodes 1-5 are masternodes. +We have 5 nodes where node 0 is the control node, nodes 1-4 are masternodes. Mempool inconsistencies are simulated via disconnecting/reconnecting node 3 -and by having a higher relay fee on nodes 4 and 5. +and by having a higher relay fee on node 4. ''' import time @@ -22,8 +22,7 @@ class LLMQ_IS_RetroactiveSigning(DashTestFramework): def set_test_params(self): # -whitelist is needed to avoid the trickling logic on node0 - self.set_dash_test_params(6, 5, [["-whitelist=127.0.0.1"], [], [], [], ["-minrelaytxfee=0.001"], ["-minrelaytxfee=0.001"]], fast_dip3_enforcement=True) - #self.set_dash_llmq_test_params(5, 3) + self.set_dash_test_params(5, 4, [["-whitelist=127.0.0.1"], [], [], [], ["-minrelaytxfee=0.001"]], fast_dip3_enforcement=True) def run_test(self): self.activate_dip8() @@ -83,10 +82,10 @@ def run_test(self): # otherwise it might announce the TX to node 3 when reconnecting self.wait_for_tx(txid, self.nodes[1]) self.wait_for_tx(txid, self.nodes[2]) - self.reconnect_isolated_node(2, 0) + self.reconnect_isolated_node(3, 0) # Make sure nodes actually try re-connecting quorum connections self.bump_mocktime(30) - self.wait_for_mnauth(self.nodes[3], 3) + self.wait_for_mnauth(self.nodes[3], 2) # node 3 fully reconnected but the TX wasn't relayed to it, so there should be no IS lock self.wait_for_instantlock(txid, self.nodes[0], False, 5) # push the tx directly via rpc