Skip to content

Commit

Permalink
Introduce spork SPORK_20_INSTANTSEND_LLMQ_BASED to switch between new…
Browse files Browse the repository at this point in the history
…/old system
  • Loading branch information
codablock committed Mar 7, 2019
1 parent 2806907 commit f5dcb00
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
15 changes: 3 additions & 12 deletions src/llmq/quorums_instantsend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,26 +861,17 @@ bool CInstantSendManager::GetConflictingTx(const CTransaction& tx, uint256& retC

bool IsOldInstantSendEnabled()
{
int spork2Value = sporkManager.GetSporkValue(SPORK_2_INSTANTSEND_ENABLED);
if (spork2Value == 0) {
return true;
}
return false;
return sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED) && !sporkManager.IsSporkActive(SPORK_20_INSTANTSEND_LLMQ_BASED);
}

bool IsNewInstantSendEnabled()
{
int spork2Value = sporkManager.GetSporkValue(SPORK_2_INSTANTSEND_ENABLED);
if (spork2Value == 1) {
return true;
}
return false;
return sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED) && sporkManager.IsSporkActive(SPORK_20_INSTANTSEND_LLMQ_BASED);
}

bool IsInstantSendEnabled()
{
int spork2Value = sporkManager.GetSporkValue(SPORK_2_INSTANTSEND_ENABLED);
return spork2Value == 0 || spork2Value == 1;
return sporkManager.IsSporkActive(SPORK_2_INSTANTSEND_ENABLED);
}

}
12 changes: 5 additions & 7 deletions src/llmq/quorums_instantsend.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,11 @@ class CInstantSendManager : public CRecoveredSigsListener

extern CInstantSendManager* quorumInstantSendManager;

// The meaning of spork 2 has changed in v0.14. Before that, spork 2 was simply time based and either enabled or not
// After 0.14, spork 2 can have 3 states.
// 0 = old system is active (0 is compatible with the value set on mainnet at time of deployment)
// 1 = new system is active (old nodes will interpret this as the old system being enabled, but then won't get enough IX lock votes)
// everything else = disabled
// TODO When the new system is fully deployed and enabled, we can remove this special handling of the spork in a future version
// and revert to the old behaviour.
// This involves 2 sporks: SPORK_2_INSTANTSEND_ENABLED and SPORK_20_INSTANTSEND_LLMQ_BASED
// SPORK_2_INSTANTSEND_ENABLED generally enables/disables InstantSend and SPORK_20_INSTANTSEND_LLMQ_BASED switches
// between the old and the new (LLMQ based) system
// TODO When the new system is fully deployed and enabled, we can remove this special handling in a future version
// and revert to only using SPORK_2_INSTANTSEND_ENABLED.
bool IsOldInstantSendEnabled();
bool IsNewInstantSendEnabled();
bool IsInstantSendEnabled();
Expand Down
3 changes: 3 additions & 0 deletions src/spork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ std::map<int, int64_t> mapSporkDefaults = {
{SPORK_17_QUORUM_DKG_ENABLED, 4070908800ULL}, // OFF
{SPORK_18_QUORUM_DEBUG_ENABLED, 4070908800ULL}, // OFF
{SPORK_19_CHAINLOCKS_ENABLED, 4070908800ULL}, // OFF
{SPORK_20_INSTANTSEND_LLMQ_BASED, 4070908800ULL}, // OFF
};

bool CSporkManager::SporkValueIsActive(int nSporkID, int64_t &nActiveValueRet) const
Expand Down Expand Up @@ -291,6 +292,7 @@ int CSporkManager::GetSporkIDByName(const std::string& strName)
if (strName == "SPORK_17_QUORUM_DKG_ENABLED") return SPORK_17_QUORUM_DKG_ENABLED;
if (strName == "SPORK_18_QUORUM_DEBUG_ENABLED") return SPORK_18_QUORUM_DEBUG_ENABLED;
if (strName == "SPORK_19_CHAINLOCKS_ENABLED") return SPORK_19_CHAINLOCKS_ENABLED;
if (strName == "SPORK_20_INSTANTSEND_LLMQ_BASED") return SPORK_20_INSTANTSEND_LLMQ_BASED;

LogPrint("spork", "CSporkManager::GetSporkIDByName -- Unknown Spork name '%s'\n", strName);
return -1;
Expand All @@ -310,6 +312,7 @@ std::string CSporkManager::GetSporkNameByID(int nSporkID)
case SPORK_17_QUORUM_DKG_ENABLED: return "SPORK_17_QUORUM_DKG_ENABLED";
case SPORK_18_QUORUM_DEBUG_ENABLED: return "SPORK_18_QUORUM_DEBUG_ENABLED";
case SPORK_19_CHAINLOCKS_ENABLED: return "SPORK_19_CHAINLOCKS_ENABLED";
case SPORK_20_INSTANTSEND_LLMQ_BASED: return "SPORK_20_INSTANTSEND_LLMQ_BASED";
default:
LogPrint("spork", "CSporkManager::GetSporkNameByID -- Unknown Spork ID %d\n", nSporkID);
return "Unknown";
Expand Down
3 changes: 2 additions & 1 deletion src/spork.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ static const int SPORK_16_INSTANTSEND_AUTOLOCKS = 10015;
static const int SPORK_17_QUORUM_DKG_ENABLED = 10016;
static const int SPORK_18_QUORUM_DEBUG_ENABLED = 10017;
static const int SPORK_19_CHAINLOCKS_ENABLED = 10018;
static const int SPORK_20_INSTANTSEND_LLMQ_BASED = 10019;

static const int SPORK_START = SPORK_2_INSTANTSEND_ENABLED;
static const int SPORK_END = SPORK_19_CHAINLOCKS_ENABLED;
static const int SPORK_END = SPORK_20_INSTANTSEND_LLMQ_BASED;

extern std::map<int, int64_t> mapSporkDefaults;
extern CSporkManager sporkManager;
Expand Down

0 comments on commit f5dcb00

Please sign in to comment.