Skip to content

Commit

Permalink
update autoix-mempool.py to test both "old" and "new" InstantSend (an…
Browse files Browse the repository at this point in the history
…d fix CheckCanLock to respect mempool limits)
  • Loading branch information
UdjinM6 authored and codablock committed Mar 7, 2019
1 parent 843b6d7 commit 41a71fe
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
19 changes: 17 additions & 2 deletions qa/rpc-tests/autoix-mempool.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,21 @@ def fill_mempool(self):
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)

Expand Down Expand Up @@ -151,8 +166,8 @@ def run_test(self):

# 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
Expand Down
5 changes: 3 additions & 2 deletions src/instantx.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/llmq/quorums_instantsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 41a71fe

Please sign in to comment.