Skip to content

Commit

Permalink
v3.3.0
Browse files Browse the repository at this point in the history
Add Lite Node Update Functionality.
  • Loading branch information
BLOCXTECH committed Apr 4, 2024
1 parent 20f3ccb commit 8636fcc
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 13 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AC_PREREQ([2.69])
define(_CLIENT_VERSION_MAJOR, 3)
define(_CLIENT_VERSION_MINOR, 2)
define(_CLIENT_VERSION_MINOR, 3)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ class CMainParams : public CChainParams {
{125469, uint256S("0x0000000000000055930a30f28b37e4ac702d1594a198d04cf2e362adf5bb990c")},
{134962, uint256S("0x0000000000000077dc834c1e9cd3a77df65cb6e0c8501a9aca969913d9bea351")},
{140865, uint256S("0x00000000000000219d7778c35f4feb67bda8b0024f54fb004078c3ebe90d16f7")},
{145107, uint256S("0x000000000000002ea096d79ed3680e8d94a97a050a6c7c5294c0d8efa5b9b5f3")},
{146200, uint256S("0x000000000000001e05ffd1d6d25b683e0bc9fb81af258ec4e0ec049c42b0892c")},
}
};

Expand Down
9 changes: 7 additions & 2 deletions src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -877,9 +877,14 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, const C
if (!dmn) {
return _state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "bad-protx-hash");
}
if (proTx.nType != dmn->nType) {
return _state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "bad-protx-type-mismatch");
if (IsLiteMNSporkENABLED()) {
proTx.nType = dmn->nType;
} else {
if (proTx.nType != dmn->nType) {
return _state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "bad-protx-type-mismatch");
}
}

if (!IsValidMnType(proTx.nType)) {
return _state.Invalid(ValidationInvalidReason::CONSENSUS, false, REJECT_INVALID, "bad-protx-type");
}
Expand Down
51 changes: 51 additions & 0 deletions src/governance/classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,57 @@ CAmount CSuperblock::GetPaymentsLimit(int nBlockHeight)
// some part of all blocks issued during the cycle goes to superblock, see GetBlockSubsidy
CAmount nSuperblockPartOfSubsidy = GetBlockSubsidy(nBlockHeight - 1, consensusParams, true);
CAmount nPaymentsLimit = nSuperblockPartOfSubsidy * nSuperblockCycle;

if (nBlockHeight == 175200) {
nPaymentsLimit = 214200 * COIN;
} else if (nBlockHeight == 321200) {
nPaymentsLimit = 170000 * COIN;
} else if (nBlockHeight == 467200) {
nPaymentsLimit = 138800 * COIN;
} else if (nBlockHeight == 613200) {
nPaymentsLimit = 109900 * COIN;
} else if (nBlockHeight == 759200) {
nPaymentsLimit = 86500 * COIN;
} else if (nBlockHeight == 905200) {
nPaymentsLimit = 66400 * COIN;
} else if (nBlockHeight == 1051200) {
nPaymentsLimit = 50800 * COIN;
} else if (nBlockHeight == 1197200) {
nPaymentsLimit = 39500 * COIN;
} else if (nBlockHeight == 1343200) {
nPaymentsLimit = 31700 * COIN;
} else if (nBlockHeight == 1489200) {
nPaymentsLimit = 23900 * COIN;
} else if (nBlockHeight == 1635200) {
nPaymentsLimit = 18420 * COIN;
} else if (nBlockHeight == 1781200) {
nPaymentsLimit = 15000 * COIN;
} else if (nBlockHeight == 1927200) {
nPaymentsLimit = 13240 * COIN;
} else if (nBlockHeight == 2044000) {
nPaymentsLimit = 13140 * COIN;
} else if (nBlockHeight == 2190000) {
nPaymentsLimit = 11580 * COIN;
} else if (nBlockHeight == 2336000) {
nPaymentsLimit = 10020 * COIN;
} else if (nBlockHeight == 2482000) {
nPaymentsLimit = 8460 * COIN;
} else if (nBlockHeight == 2628000) {
nPaymentsLimit = 6900 * COIN;
} else if (nBlockHeight == 2774000) {
nPaymentsLimit = 5340 * COIN;
} else if (nBlockHeight == 2920000) {
nPaymentsLimit = 3780 * COIN;
} else if (nBlockHeight == 3066000) {
nPaymentsLimit = 2220 * COIN;
} else if (nBlockHeight == 3212000) {
nPaymentsLimit = 1060 * COIN;
} else if (nBlockHeight == 3358000) {
nPaymentsLimit = 505 * COIN;
} else if (nBlockHeight == 3650000) {
nPaymentsLimit = 340 * COIN;
}

LogPrint(BCLog::GOBJECT, "CSuperblock::GetPaymentsLimit -- Valid superblock height %d, payments max %lld\n", nBlockHeight, nPaymentsLimit);

return nPaymentsLimit;
Expand Down
3 changes: 1 addition & 2 deletions src/rpc/evo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,8 +902,7 @@ static UniValue protx_update_service_common_wrapper(const JSONRPCRequest& reques

EnsureWalletIsUnlocked(wallet.get());

bool isV19active = llmq::utils::IsV19Active(WITH_LOCK(cs_main, return ::ChainActive().Tip();));
if (isLITErequested && !isV19active) {
if (!IsLiteMNSporkENABLED() && isLITErequested) {
throw JSONRPCError(RPC_INVALID_REQUEST, "LITE aren't allowed yet");
}

Expand Down
4 changes: 3 additions & 1 deletion src/spork.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum SporkId : int32_t {
SPORK_17_QUORUM_DKG_ENABLED = 10016,
SPORK_19_CHAINLOCKS_ENABLED = 10018,
SPORK_21_QUORUM_ALL_CONNECTED = 10020,
SPORK_22_UPDATE_LITEMN = 10021,
SPORK_23_QUORUM_POSE = 10022,

SPORK_INVALID = -1,
Expand All @@ -63,13 +64,14 @@ struct CSporkDef
};

#define MAKE_SPORK_DEF(name, defaultValue) CSporkDef{name, defaultValue, #name}
[[maybe_unused]] static constexpr std::array<CSporkDef, 7> sporkDefs = {
[[maybe_unused]] static constexpr std::array<CSporkDef, 8> sporkDefs = {
MAKE_SPORK_DEF(SPORK_2_INSTANTSEND_ENABLED, 4070908800ULL), // OFF
MAKE_SPORK_DEF(SPORK_3_INSTANTSEND_BLOCK_FILTERING, 4070908800ULL), // OFF
MAKE_SPORK_DEF(SPORK_9_SUPERBLOCKS_ENABLED, 4070908800ULL), // OFF
MAKE_SPORK_DEF(SPORK_17_QUORUM_DKG_ENABLED, 4070908800ULL), // OFF
MAKE_SPORK_DEF(SPORK_19_CHAINLOCKS_ENABLED, 4070908800ULL), // OFF
MAKE_SPORK_DEF(SPORK_21_QUORUM_ALL_CONNECTED, 4070908800ULL), // OFF
MAKE_SPORK_DEF(SPORK_22_UPDATE_LITEMN, 4070908800ULL), // OFF
MAKE_SPORK_DEF(SPORK_23_QUORUM_POSE, 4070908800ULL), // OFF
};
#undef MAKE_SPORK_DEF
Expand Down
7 changes: 5 additions & 2 deletions src/util/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -968,9 +968,12 @@ bool ArgsManager::ReadConfigFiles(std::string& error, bool ignore_invalid_keys)
} else {
// Create an empty blocx.conf if it does not exist
FILE* configFile = fopen(GetConfigFile(confPath).string().c_str(), "a");
if (configFile != nullptr)
if (configFile != nullptr) {
std::string strHeader = "fallbackfee=0.0001\n";
fwrite(strHeader.c_str(), std::strlen(strHeader.c_str()), 1, configFile);
fclose(configFile);
return true; // Nothing to read, so just return
return true; // Nothing to read, so just return
}
}

// If datadir is changed in .conf file:
Expand Down
33 changes: 28 additions & 5 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
*pfMissingInputs = false;
}

if (::ChainActive().Height() > chainparams.GetConsensus().V3ForkHeight && tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
if (!sporkManager->IsSporkActive(SPORK_22_UPDATE_LITEMN) && ::ChainActive().Height() > chainparams.GetConsensus().V3ForkHeight && tx.nType == TRANSACTION_PROVIDER_UPDATE_SERVICE) {
// this condition will be removed from next version
if (Params().NetworkIDString() == CBaseChainParams::MAIN && ::ChainActive().Height() < 106300) {
return false;
Expand Down Expand Up @@ -1025,6 +1025,8 @@ bool isExtraFundAllocationHeight(int nHeight) {
return true;
} else if (nHeight == 130000) {
return true;
} else if (nHeight == 154000) {
return true;
} else if (nHeight == 220000) {
return true;
} else if (nHeight == 400000) {
Expand Down Expand Up @@ -1068,6 +1070,8 @@ CAmount GetExtraPayOutAmount(int nHeight) {
ExtraPayOutAmount = 1000000;
} else if (nHeight == 130000) {
ExtraPayOutAmount = 2000000;
} else if (nHeight == 154000) {
ExtraPayOutAmount = 300000;
} else if (nHeight == 220000) {
ExtraPayOutAmount = 1000000;
} else if (nHeight == 400000) {
Expand Down Expand Up @@ -2572,6 +2576,11 @@ CoinsCacheSizeState CChainState::GetCoinsCacheSizeState(
return CoinsCacheSizeState::OK;
}

bool IsLiteMNSporkENABLED()
{
return sporkManager->IsSporkActive(SPORK_22_UPDATE_LITEMN);
}

bool CChainState::FlushStateToDisk(
const CChainParams& chainparams,
CValidationState &state,
Expand Down Expand Up @@ -4035,8 +4044,18 @@ static bool ContextualCheckBlock(const CBlock& block, CValidationState& state, c
if ((found = txout.scriptPubKey == devPayoutScript && txout.nValue == devPayoutValue) == true)
break;
}
if (!found)
return state.Invalid(ValidationInvalidReason::TX_MISSING_INPUTS, "Developer reward check failed");
if (!found) {
if (nHeight < 153990) {
return state.Invalid(ValidationInvalidReason::TX_MISSING_INPUTS, "Developer reward check failed");
} else {
return state.Invalid(
ValidationInvalidReason::CONSENSUS,
false,
REJECT_INVALID,
"bad-cb-tx",
"Developer Reward Check Failed");
}
}
}

if(isExtraFundAllocationHeight(nHeight)) {
Expand All @@ -4050,8 +4069,12 @@ static bool ContextualCheckBlock(const CBlock& block, CValidationState& state, c
break;
}
if (!found) {
LogPrintf("nHeight is in dev reward is :>>>>>>>>>>> %d: %d: %d\n", nHeight, extraFund);
return state.Invalid(ValidationInvalidReason::TX_MISSING_INPUTS, "Extra reward allocation check failed");
return state.Invalid(
ValidationInvalidReason::CONSENSUS,
false,
REJECT_INVALID,
"bad-cb-tx",
"Extra reward allocation check failed");
}
}

Expand Down
1 change: 1 addition & 0 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ bool TestLockPointValidity(const LockPoints* lp) EXCLUSIVE_LOCKS_REQUIRED(cs_mai
* See consensus/consensus.h for flag definitions.
*/
bool CheckSequenceLocks(const CTxMemPool& pool, const CTransaction& tx, int flags, LockPoints* lp = nullptr, bool useExistingLockPoints = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
bool IsLiteMNSporkENABLED();

/**
* Closure representing one script verification
Expand Down

0 comments on commit 8636fcc

Please sign in to comment.