diff --git a/qa/rpc-tests/autoix-mempool.py b/qa/rpc-tests/autoix-mempool.py index fdd3a57f3..f79fe772a 100755 --- a/qa/rpc-tests/autoix-mempool.py +++ b/qa/rpc-tests/autoix-mempool.py @@ -122,6 +122,21 @@ class AutoIXMempoolTest(DashTestFramework): def run_test(self): # make sure masternodes are synced sync_masternodes(self.nodes) + + self.nodes[0].spork("SPORK_17_QUORUM_DKG_ENABLED", 0) + self.wait_for_sporks_same() + self.mine_quorum() + + print("Test old InstantSend") + self.test_auto(); + + self.nodes[0].spork("SPORK_2_INSTANTSEND_ENABLED", 1) + self.wait_for_sporks_same() + + print("Test new InstantSend") + self.test_auto(True); + + def test_auto(self, new_is = False): self.activate_autoix_bip9() self.set_autoix_spork_state(True) @@ -151,8 +166,8 @@ class AutoIXMempoolTest(DashTestFramework): # autoIX is not working now assert(not self.send_simple_tx(sender, receiver)) - # regular IX is still working - assert(self.send_regular_IX(sender, receiver)) + # regular IX is still working for old IS but not for new one + assert(not self.send_regular_IX(sender, receiver) if new_is else self.send_regular_IX(sender, receiver)) # generate one block to clean up mempool and retry auto and regular IX # generate 2 more blocks to have enough confirmations for IX diff --git a/src/instantx.h b/src/instantx.h index c8c0aa585..aac54e2d1 100644 --- a/src/instantx.h +++ b/src/instantx.h @@ -45,11 +45,12 @@ extern int nCompleteTXLocks; */ class CInstantSend { -private: - static const std::string SERIALIZATION_VERSION_STRING; +public: /// Automatic locks of "simple" transactions are only allowed /// when mempool usage is lower than this threshold static const double AUTO_IX_MEMPOOL_THRESHOLD; +private: + static const std::string SERIALIZATION_VERSION_STRING; // Keep track of current block height int nCachedBlockHeight; diff --git a/src/llmq/quorums_instantsend.cpp b/src/llmq/quorums_instantsend.cpp index 6104f5b32..7f0a322ac 100644 --- a/src/llmq/quorums_instantsend.cpp +++ b/src/llmq/quorums_instantsend.cpp @@ -137,6 +137,10 @@ bool CInstantSendManager::ProcessTx(CNode* pfrom, const CTransaction& tx, CConnm bool CInstantSendManager::CheckCanLock(const CTransaction& tx, bool printDebug, const Consensus::Params& params) { + if (sporkManager.IsSporkActive(SPORK_16_INSTANTSEND_AUTOLOCKS) && (mempool.UsedMemoryShare() > CInstantSend::AUTO_IX_MEMPOOL_THRESHOLD)) { + return false; + } + int nInstantSendConfirmationsRequired = params.nInstantSendConfirmationsRequired; uint256 txHash = tx.GetHash();