Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
68442e8
chore: add TODO for llmq/utils.h refactoring
knst Dec 4, 2023
a7ad399
refactor: drop IsDIP0024Active and its usage of llmq_vbc
knst Dec 4, 2023
c329615
refactor: use value_or in std::optional
knst Dec 18, 2023
8f3d3db
refactor: drop dependency governance/classes on llmq/utils
knst Dec 4, 2023
c25d336
refactor: drop dependency masternode/payments on llmq/utils
knst Dec 4, 2023
f3d2f2d
refactor: drop dependency unit test block_reward_reallocation_tests o…
knst Dec 4, 2023
bacaa80
fix: use proper pindex/pindex->pprev in credit pool code during v20/m…
knst Dec 4, 2023
e94f575
refactor: drop dependency of specialtxman on llmq/utils
knst Dec 4, 2023
82c01ea
refactor: drop dependency creditpool on llmq/utils
knst Dec 4, 2023
251a897
refactor: rename argument pindex to pindexPrev in GetMNPayee and GetP…
knst Dec 4, 2023
13adedb
refactor: move common code in deterministicmns to the helper
knst Dec 4, 2023
f7274c4
refactor: use deployment status in deterministicmns instead llmq's he…
knst Dec 4, 2023
5a84eb0
refactor: drop default value from IsDIP3Enforced()
knst Dec 4, 2023
a79aa56
refactor: move out helper IsDIP3Enforced from deterministicmns
knst Dec 4, 2023
c742b9a
refactor: drop unused llmq::utils::IsMNRewardReallocationActive
knst Dec 4, 2023
377d929
refactor: drop dependency evo/simplifiedmns on llmq/utils
knst Dec 4, 2023
488c895
refactor: use DeploymentActiveAfter in ehf_signals
knst Dec 4, 2023
2128d58
refactor: use DeploymentActiveAfter in cbtx
knst Dec 4, 2023
9aa4371
refactor: use DeploymentActiveAfter in evo/mnauth
knst Dec 4, 2023
7bce9d8
refactor: use CFinalCommitment::GetVersion in llmq/{commitment,dkgses…
knst Dec 4, 2023
c4d634c
refactor: use DeploymentActiveAfter in init.cpp
knst Dec 4, 2023
39dc612
refactor: drop dependency test/util/setup_common on llmq/utils
knst Dec 4, 2023
1ed7f0c
refactor: use DeploymentActiveAfter instead llmq::utils in rpc/
knst Dec 4, 2023
ad4d753
refactor: use DeploymentActiveAfter in llmq/blockprocessor
knst Dec 4, 2023
55abf7f
refactor: drop dependency test/evo_deterministicmns_tests on llmq::utils
knst Dec 4, 2023
5d4b16a
refactor: drop public method llmq::utils::IsV19Active
knst Dec 4, 2023
db43793
refactor: drop dependency miner on llmq::utils::IsV20Active
knst Dec 4, 2023
70fa626
refactor: drop dependency validation on llmq/utils
knst Dec 4, 2023
bc0f0bf
chore: removed TODO for TESTNET_LLMQ_25_67_ACTIVATION_HEIGHT so far a…
knst Dec 4, 2023
917089d
refactor: drop public llmq::utils::IsV20Active method
knst Dec 4, 2023
f57859f
refactor: drop llmq_versionbitscache in favor of g_versionbitscache
knst Dec 4, 2023
1b3237d
fix: remove unused cs_main lock from src/miner.cpp - it's not used by…
knst Dec 5, 2023
c3c9ccf
refactor: drop global variable fDIP0001ActiveAtTip - partial implemen…
knst Dec 5, 2023
42e65f4
chore: remaining TODO goes to other PRs
knst Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/deploymentstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ inline bool DeploymentEnabled(const Consensus::Params& params, Consensus::Deploy
return params.vDeployments[dep].nTimeout != 0;
}

/** this function is convenient helper for DIP0003 because 'active' and 'enforced' are different statuses for DIP0003 */
constexpr bool DeploymentDIP0003Enforced(const int nHeight, const Consensus::Params& params)
{
return nHeight >= params.DIP0003EnforcementHeight;
}

#endif // BITCOIN_DEPLOYMENTSTATUS_H
5 changes: 3 additions & 2 deletions src/evo/cbtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <chain.h>
#include <chainparams.h>
#include <consensus/merkle.h>
#include <deploymentstatus.h>
#include <validation.h>

bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidationState& state)
Expand All @@ -42,12 +43,12 @@ bool CheckCbTx(const CTransaction& tx, const CBlockIndex* pindexPrev, TxValidati
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-cbtx-height");
}

bool fDIP0008Active = pindexPrev->nHeight >= Params().GetConsensus().DIP0008Height;
const bool fDIP0008Active{DeploymentActiveAt(*pindexPrev, Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0008)};
if (fDIP0008Active && cbTx.nVersion < CCbTx::Version::MERKLE_ROOT_QUORUMS) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-cbtx-version");
}

bool isV20 = llmq::utils::IsV20Active(pindexPrev);
const bool isV20{DeploymentActiveAfter(pindexPrev, Params().GetConsensus(), Consensus::DEPLOYMENT_V20)};
if ((isV20 && cbTx.nVersion < CCbTx::Version::CLSIG_AND_BALANCE) || (!isV20 && cbTx.nVersion >= CCbTx::Version::CLSIG_AND_BALANCE)) {
return state.Invalid(TxValidationResult::TX_CONSENSUS, "bad-cbtx-version");
}
Expand Down
26 changes: 14 additions & 12 deletions src/evo/creditpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
#include <evo/specialtx.h>

#include <chain.h>
#include <chainparams.h>
#include <consensus/validation.h>
#include <llmq/utils.h>
#include <deploymentstatus.h>
#include <logging.h>
#include <node/blockstorage.h>
#include <validation.h>
Expand Down Expand Up @@ -80,19 +81,19 @@ std::string CCreditPool::ToString() const
locked, currentLimit);
}

std::optional<CCreditPool> CCreditPoolManager::GetFromCache(const CBlockIndex* const block_index)
std::optional<CCreditPool> CCreditPoolManager::GetFromCache(const CBlockIndex& block_index)
{
if (!llmq::utils::IsV20Active(block_index)) return CCreditPool{};
if (!DeploymentActiveAt(block_index, Params().GetConsensus(), Consensus::DEPLOYMENT_V20)) return CCreditPool{};

const uint256 block_hash = block_index->GetBlockHash();
const uint256 block_hash = block_index.GetBlockHash();
CCreditPool pool;
{
LOCK(cache_mutex);
if (creditPoolCache.get(block_hash, pool)) {
return pool;
}
}
if (block_index->nHeight % DISK_SNAPSHOT_PERIOD == 0) {
if (block_index.nHeight % DISK_SNAPSHOT_PERIOD == 0) {
if (evoDb.Read(std::make_pair(DB_CREDITPOOL_SNAPSHOT, block_hash), pool)) {
LOCK(cache_mutex);
creditPoolCache.insert(block_hash, pool);
Expand Down Expand Up @@ -202,10 +203,11 @@ CCreditPool CCreditPoolManager::GetCreditPool(const CBlockIndex* block_index, co
std::stack<const CBlockIndex *> to_calculate;

std::optional<CCreditPool> poolTmp;
while (!(poolTmp = GetFromCache(block_index)).has_value()) {
while (block_index != nullptr && !(poolTmp = GetFromCache(*block_index)).has_value()) {
to_calculate.push(block_index);
block_index = block_index->pprev;
}
if (block_index == nullptr) poolTmp = CCreditPool{};
while (!to_calculate.empty()) {
poolTmp = ConstructCreditPool(to_calculate.top(), *poolTmp, consensusParams);
to_calculate.pop();
Expand All @@ -218,16 +220,16 @@ CCreditPoolManager::CCreditPoolManager(CEvoDB& _evoDb)
{
}

CCreditPoolDiff::CCreditPoolDiff(CCreditPool starter, const CBlockIndex *pindex, const Consensus::Params& consensusParams, const CAmount blockSubsidy) :
CCreditPoolDiff::CCreditPoolDiff(CCreditPool starter, const CBlockIndex *pindexPrev, const Consensus::Params& consensusParams, const CAmount blockSubsidy) :
pool(std::move(starter)),
pindex(pindex),
pindexPrev(pindexPrev),
params(consensusParams)
{
assert(pindex);
assert(pindexPrev);

if (llmq::utils::IsMNRewardReallocationActive(pindex)) {
if (DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_MN_RR)) {
// We consider V20 active if mn_rr is active
platformReward = MasternodePayments::PlatformShare(GetMasternodePayment(pindex->nHeight, blockSubsidy, /*fV20Active=*/ true));
platformReward = MasternodePayments::PlatformShare(GetMasternodePayment(pindexPrev->nHeight + 1, blockSubsidy, /*fV20Active=*/ true));
}
}

Expand Down Expand Up @@ -274,7 +276,7 @@ bool CCreditPoolDiff::ProcessLockUnlockTransaction(const CTransaction& tx, TxVal
if (tx.nVersion != 3) return true;
if (tx.nType != TRANSACTION_ASSET_LOCK && tx.nType != TRANSACTION_ASSET_UNLOCK) return true;

if (!CheckAssetLockUnlockTx(tx, pindex, pool.indexes, state)) {
if (!CheckAssetLockUnlockTx(tx, pindexPrev, pool.indexes, state)) {
// pass the state returned by the function above
return false;
}
Expand Down
6 changes: 3 additions & 3 deletions src/evo/creditpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ class CCreditPoolDiff {
CAmount sessionUnlocked{0};
CAmount platformReward{0};

const CBlockIndex *pindex{nullptr};
const CBlockIndex *pindexPrev{nullptr};
const Consensus::Params& params;
public:
explicit CCreditPoolDiff(CCreditPool starter, const CBlockIndex *pindex,
explicit CCreditPoolDiff(CCreditPool starter, const CBlockIndex *pindexPrev,
const Consensus::Params& consensusParams,
const CAmount blockSubsidy);

Expand Down Expand Up @@ -128,7 +128,7 @@ class CCreditPoolManager
CCreditPool GetCreditPool(const CBlockIndex* block, const Consensus::Params& consensusParams);

private:
std::optional<CCreditPool> GetFromCache(const CBlockIndex* const block_index);
std::optional<CCreditPool> GetFromCache(const CBlockIndex& block_index);
void AddToCache(const uint256& block_hash, int height, const CCreditPool& pool);

CCreditPool ConstructCreditPool(const CBlockIndex* block_index, CCreditPool prev, const Consensus::Params& consensusParams);
Expand Down
Loading