Skip to content

Commit 2756cb7

Browse files
PastaPastaPastaUdjinM6
authored andcommitted
remove spork 12 (#2754)
Signed-off-by: Pasta <Pasta@dash.org>
1 parent 6332310 commit 2756cb7

File tree

5 files changed

+0
-98
lines changed

5 files changed

+0
-98
lines changed

src/rpc/misc.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ UniValue spork(const JSONRPCRequest& request)
302302

303303
//broadcast new spork
304304
if(sporkManager.UpdateSpork(nSporkID, nValue, *g_connman)){
305-
sporkManager.ExecuteSpork(nSporkID, nValue);
306305
return "success";
307306
} else {
308307
throw std::runtime_error(

src/spork.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ std::vector<CSporkDef> sporkDefs = {
2222
MAKE_SPORK_DEF(SPORK_5_INSTANTSEND_MAX_VALUE, 1000), // 1000 Dash
2323
MAKE_SPORK_DEF(SPORK_6_NEW_SIGS, 4070908800ULL), // OFF
2424
MAKE_SPORK_DEF(SPORK_9_SUPERBLOCKS_ENABLED, 4070908800ULL), // OFF
25-
MAKE_SPORK_DEF(SPORK_12_RECONSIDER_BLOCKS, 0), // 0 BLOCKS
2625
MAKE_SPORK_DEF(SPORK_15_DETERMINISTIC_MNS_ENABLED, 4070908800ULL), // OFF
2726
MAKE_SPORK_DEF(SPORK_16_INSTANTSEND_AUTOLOCKS, 4070908800ULL), // OFF
2827
MAKE_SPORK_DEF(SPORK_17_QUORUM_DKG_ENABLED, 4070908800ULL), // OFF
@@ -184,12 +183,6 @@ void CSporkManager::ProcessSpork(CNode* pfrom, const std::string& strCommand, CD
184183
}
185184
spork.Relay(connman);
186185

187-
//does a task if needed
188-
int64_t nActiveValue = 0;
189-
if (SporkValueIsActive(spork.nSporkID, nActiveValue)) {
190-
ExecuteSpork(spork.nSporkID, nActiveValue);
191-
}
192-
193186
} else if (strCommand == NetMsgType::GETSPORKS) {
194187
LOCK(cs); // make sure to not lock this together with cs_main
195188
for (const auto& pair : mapSporksActive) {
@@ -201,35 +194,6 @@ void CSporkManager::ProcessSpork(CNode* pfrom, const std::string& strCommand, CD
201194

202195
}
203196

204-
void CSporkManager::ExecuteSpork(SporkId nSporkID, int nValue)
205-
{
206-
//correct fork via spork technology
207-
if(nSporkID == SPORK_12_RECONSIDER_BLOCKS && nValue > 0) {
208-
// allow to reprocess 24h of blocks max, which should be enough to resolve any issues
209-
int64_t nMaxBlocks = 576;
210-
// this potentially can be a heavy operation, so only allow this to be executed once per 10 minutes
211-
int64_t nTimeout = 10 * 60;
212-
213-
static int64_t nTimeExecuted = 0; // i.e. it was never executed before
214-
215-
if(GetTime() - nTimeExecuted < nTimeout) {
216-
LogPrint(BCLog::SPORK, "CSporkManager::ExecuteSpork -- ERROR: Trying to reconsider blocks, too soon - %d/%d\n", GetTime() - nTimeExecuted, nTimeout);
217-
return;
218-
}
219-
220-
if(nValue > nMaxBlocks) {
221-
LogPrintf("CSporkManager::ExecuteSpork -- ERROR: Trying to reconsider too many blocks %d/%d\n", nValue, nMaxBlocks);
222-
return;
223-
}
224-
225-
226-
LogPrintf("CSporkManager::ExecuteSpork -- Reconsider Last %d Blocks\n", nValue);
227-
228-
ReprocessBlocks(nValue);
229-
nTimeExecuted = GetTime();
230-
}
231-
}
232-
233197
bool CSporkManager::UpdateSpork(SporkId nSporkID, int64_t nValue, CConnman& connman)
234198
{
235199
CSporkMessage spork = CSporkMessage(nSporkID, nValue, GetAdjustedTime());

src/spork.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ enum SporkId : int32_t {
2626
SPORK_5_INSTANTSEND_MAX_VALUE = 10004,
2727
SPORK_6_NEW_SIGS = 10005,
2828
SPORK_9_SUPERBLOCKS_ENABLED = 10008,
29-
SPORK_12_RECONSIDER_BLOCKS = 10011,
3029
SPORK_15_DETERMINISTIC_MNS_ENABLED = 10014,
3130
SPORK_16_INSTANTSEND_AUTOLOCKS = 10015,
3231
SPORK_17_QUORUM_DKG_ENABLED = 10016,
@@ -227,13 +226,6 @@ class CSporkManager
227226
*/
228227
void ProcessSpork(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);
229228

230-
/**
231-
* ExecuteSpork is used to perform certain actions based on the spork value.
232-
*
233-
* Currently only used with Spork 12.
234-
*/
235-
void ExecuteSpork(SporkId nSporkID, int nValue);
236-
237229
/**
238230
* UpdateSpork is used by the spork RPC command to set a new spork value, sign
239231
* and broadcast the spork message.

src/validation.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE;
105105

106106
CBlockPolicyEstimator feeEstimator;
107107
CTxMemPool mempool(&feeEstimator);
108-
std::map<uint256, int64_t> mapRejectedBlocks GUARDED_BY(cs_main);
109108

110109
static void CheckBlockIndex(const Consensus::Params& consensusParams);
111110

@@ -2197,7 +2196,6 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
21972196
// The node which relayed this should switch to correct chain.
21982197
// TODO: relay instantsend data/proof.
21992198
LOCK(cs_main);
2200-
mapRejectedBlocks.insert(std::make_pair(block.GetHash(), GetTime()));
22012199
return state.DoS(10, error("ConnectBlock(DASH): transaction %s conflicts with transaction lock %s", tx->GetHash().ToString(), hashLocked.ToString()),
22022200
REJECT_INVALID, "conflict-tx-lock");
22032201
}
@@ -2213,7 +2211,6 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
22132211
// The node which relayed this should switch to correct chain.
22142212
// TODO: relay instantsend data/proof.
22152213
LOCK(cs_main);
2216-
mapRejectedBlocks.insert(std::make_pair(block.GetHash(), GetTime()));
22172214
return state.DoS(10, error("ConnectBlock(DASH): transaction %s conflicts with transaction lock %s", tx->GetHash().ToString(), conflictLock->txid.ToString()),
22182215
REJECT_INVALID, "conflict-tx-lock");
22192216
}
@@ -2242,7 +2239,6 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
22422239
LogPrint(BCLog::BENCHMARK, " - IsBlockValueValid: %.2fms [%.2fs]\n", 0.001 * (nTime5_3 - nTime5_2), nTimeValueValid * 0.000001);
22432240

22442241
if (!IsBlockPayeeValid(*block.vtx[0], pindex->nHeight, blockReward)) {
2245-
mapRejectedBlocks.insert(std::make_pair(block.GetHash(), GetTime()));
22462242
return state.DoS(0, error("ConnectBlock(DASH): couldn't find masternode or superblock payments"),
22472243
REJECT_INVALID, "bad-cb-payee");
22482244
}
@@ -2698,49 +2694,6 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
26982694
return true;
26992695
}
27002696

2701-
bool DisconnectBlocks(int blocks)
2702-
{
2703-
LOCK(cs_main);
2704-
2705-
CValidationState state;
2706-
const CChainParams& chainparams = Params();
2707-
2708-
LogPrintf("DisconnectBlocks -- Got command to replay %d blocks\n", blocks);
2709-
for(int i = 0; i < blocks; i++) {
2710-
if(!DisconnectTip(state, chainparams) || !state.IsValid()) {
2711-
return false;
2712-
}
2713-
}
2714-
2715-
return true;
2716-
}
2717-
2718-
void ReprocessBlocks(int nBlocks)
2719-
{
2720-
LOCK(cs_main);
2721-
2722-
std::map<uint256, int64_t>::iterator it = mapRejectedBlocks.begin();
2723-
while(it != mapRejectedBlocks.end()){
2724-
//use a window twice as large as is usual for the nBlocks we want to reset
2725-
if((*it).second > GetTime() - (nBlocks*60*5)) {
2726-
BlockMap::iterator mi = mapBlockIndex.find((*it).first);
2727-
if (mi != mapBlockIndex.end() && (*mi).second) {
2728-
2729-
CBlockIndex* pindex = (*mi).second;
2730-
LogPrintf("ReprocessBlocks -- %s\n", (*it).first.ToString());
2731-
2732-
ResetBlockFailureFlags(pindex);
2733-
}
2734-
}
2735-
++it;
2736-
}
2737-
2738-
DisconnectBlocks(nBlocks);
2739-
2740-
CValidationState state;
2741-
ActivateBestChain(state, Params());
2742-
}
2743-
27442697
/**
27452698
* Return the tip of the chain with the most work in it, that isn't
27462699
* known to be invalid (it's however far from certain to be valid).

src/validation.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,6 @@ extern int64_t nMaxTipAge;
186186
extern bool fLargeWorkForkFound;
187187
extern bool fLargeWorkInvalidChainFound;
188188

189-
extern std::map<uint256, int64_t> mapRejectedBlocks;
190-
191189
extern std::atomic<bool> fDIP0001ActiveAtTip;
192190

193191
/** Block hash whose ancestors we will assume to have valid scripts without checking them. */
@@ -455,10 +453,6 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus
455453

456454
/** Functions for validating blocks and updating the block tree */
457455

458-
/** Reprocess a number of blocks to try and get on the correct chain again **/
459-
bool DisconnectBlocks(int blocks);
460-
void ReprocessBlocks(int nBlocks);
461-
462456
/** Context-independent validity checks */
463457
bool CheckBlock(const CBlock& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
464458

0 commit comments

Comments
 (0)