Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add DIP24 deployment bit assignment for devnets #2

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
8ebb834
Added GET_SNAPSHOT_INFO message handling
ogabrielides Sep 29, 2021
2b7d0f3
Renamed variable to avoid confusion with Quorum Index
ogabrielides Sep 29, 2021
3ae2e3b
Revert "Renamed variable to avoid confusion with Quorum Index"
ogabrielides Sep 30, 2021
515a8da
Quorum members by rotation
ogabrielides Sep 30, 2021
d01de73
Refactoring made
ogabrielides Oct 5, 2021
93fe253
Quorum utils functions
ogabrielides Oct 6, 2021
588c77d
Added TODO comments
ogabrielides Oct 7, 2021
733f0f0
Added caching in Quorum formation
ogabrielides Oct 7, 2021
17753f3
Refactoring
ogabrielides Oct 8, 2021
e90ae4b
Handle GET_QUORUM_ROTATION_INFO with baseBlockHash from client
ogabrielides Oct 11, 2021
e5eaaed
Storing QuorumSnaphots in evoDB when requesting them
ogabrielides Oct 11, 2021
dbc7c28
Removed processing of QUORUMROTATIONINFO message
ogabrielides Oct 12, 2021
4d967a2
Added DIP Enforcement param
ogabrielides Oct 12, 2021
ae1f7d2
Deleted file
ogabrielides Oct 12, 2021
622a634
Rename variables for better clarity
ogabrielides Oct 13, 2021
21d43a4
quorumIndex cache
ogabrielides Oct 18, 2021
f848060
Quorum Rotation deployment control
ogabrielides Oct 18, 2021
5e2fed9
Mode 2 skipList Mode
ogabrielides Oct 18, 2021
d3ed6f9
Usage of Bitsets for storing CQuorumSnapshots
ogabrielides Oct 18, 2021
88445f8
Renamed to DIP24
ogabrielides Oct 18, 2021
81f342e
Style adjustements
ogabrielides Oct 18, 2021
8a584a2
Correct handling of early quorum quarters
ogabrielides Oct 19, 2021
9f013a8
Renamed files
ogabrielides Oct 21, 2021
4d09969
Corrections
ogabrielides Oct 21, 2021
fc4a722
Handling of quorumIndex
ogabrielides Oct 22, 2021
769da87
Refactoring of truncate mechanism
ogabrielides Oct 22, 2021
46d3a01
Various fixes
ogabrielides Oct 25, 2021
82af9d8
Added documentation
ogabrielides Oct 25, 2021
88911c8
Interface correction
ogabrielides Oct 25, 2021
f22c96a
Various fixes
ogabrielides Oct 25, 2021
5ab3444
Added template type for indexed cache
ogabrielides Oct 25, 2021
9dd8d25
Added quorumIndex into commitmenHash
ogabrielides Oct 25, 2021
8e34713
Re added variable init
ogabrielides Oct 25, 2021
8d57bcf
Various changes
ogabrielides Oct 25, 2021
e44d12f
Needs to update maqQuorumsCache along with indexedQuorumsCache
ogabrielides Oct 26, 2021
72dae9c
Added CFinalCommitment version 2
ogabrielides Oct 27, 2021
948fb21
Renamed variables
ogabrielides Oct 27, 2021
d29c1f1
Fixes
ogabrielides Oct 27, 2021
bc8abbe
Refactoring & correct caching of quorumMembers by rotation
ogabrielides Oct 27, 2021
f66865e
Added assertions
ogabrielides Oct 27, 2021
68d2fa2
Refactoring
ogabrielides Oct 29, 2021
5d227ee
More asserts
ogabrielides Oct 29, 2021
feb0383
Interface change
ogabrielides Nov 1, 2021
afd4749
Handling of previous DKG session failure
ogabrielides Nov 1, 2021
9723245
Applied refactoring
ogabrielides Nov 1, 2021
d52315c
Build quarter members improvments
ogabrielides Nov 2, 2021
63d8e36
Merge Quorum Rotation and Decreased fee into one deployment (DIP24)
ogabrielides Nov 3, 2021
23869b3
Added new LLMQ Type
ogabrielides Nov 3, 2021
0330144
Added functional tests + refactoring
ogabrielides Nov 10, 2021
2d60f56
Refactoring
ogabrielides Nov 11, 2021
f632c15
Spreaded Quorum creation and Quorum Index adaptation
ogabrielides Nov 19, 2021
f000351
quorumIndex adaptations
ogabrielides Nov 22, 2021
a72e962
Added quorumIndex in CFinalCommitment
ogabrielides Nov 22, 2021
57bf384
Latest work
ogabrielides Nov 22, 2021
6861ecd
Final refactoring
ogabrielides Nov 23, 2021
4cf5300
Batch of refactoring
ogabrielides Nov 24, 2021
681c5c0
Fixes for tests
ogabrielides Nov 25, 2021
eeeeb14
Fix for CFinalCommitment
ogabrielides Nov 27, 2021
c7a4ac7
Fix for Quorums
ogabrielides Nov 29, 2021
4bca7d4
Fix
ogabrielides Nov 29, 2021
c2530f5
Small changes
ogabrielides Dec 2, 2021
054b092
Thread sync fic
ogabrielides Dec 3, 2021
c1f3ce3
Safety changes
ogabrielides Dec 5, 2021
34cbb0f
Reuse mns when needed
ogabrielides Dec 5, 2021
fe81366
LLMQ minSize equal to size for rotation
ogabrielides Dec 7, 2021
e7b0905
Safety checks
ogabrielides Dec 7, 2021
d74480c
Refactoring
ogabrielides Dec 7, 2021
9c9d531
More refactoring
ogabrielides Dec 8, 2021
124bb07
Fixes for rotationinfo handling
ogabrielides Dec 13, 2021
da2abe8
Merge fix
ogabrielides Dec 13, 2021
96faa24
Decreased llmq_devnet size
ogabrielides Dec 13, 2021
6ca575e
Fix for select quorum for signing with rotation
ogabrielides Dec 14, 2021
bfe8138
Fix for rotation of members
ogabrielides Dec 16, 2021
c470ec5
Various fixes
ogabrielides Dec 16, 2021
aaff07b
llmq_devet size back to 12
ogabrielides Dec 16, 2021
2100d7a
llmq_devet signingActiveQuorumCount to 2
ogabrielides Dec 16, 2021
737eefd
Reverted commit
ogabrielides Dec 16, 2021
54dd816
Correct order of MNs lists in Quorum Snapshots
ogabrielides Dec 18, 2021
f576e52
Fix for BuildQuorumRotationInfo
ogabrielides Dec 22, 2021
368461c
Adding extra logs
ogabrielides Dec 22, 2021
3fb106a
Sync rotation quorums + qrinfo changes
ogabrielides Dec 30, 2021
a1b5ccc
Fix + extra logs
ogabrielides Dec 31, 2021
ef7143d
Removed redundant field
ogabrielides Jan 3, 2022
cb23cb4
Removed limit of baseBlockHashesNb in getqrinfo
ogabrielides Jan 3, 2022
c8a7230
Fox for null final commitment + refactoring
ogabrielides Jan 4, 2022
cec5a7a
fix: add DIP24 deployment bit assignment for devnets
thephez Jan 6, 2022
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
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ BITCOIN_CORE_H = \
llmq/dkgsession.h \
llmq/init.h \
llmq/instantsend.h \
llmq/snapshot.h \
llmq/signing.h \
llmq/signing_shares.h \
llmq/utils.h \
Expand Down Expand Up @@ -388,6 +389,7 @@ libdash_server_a_SOURCES = \
llmq/dkgsession.cpp \
llmq/init.cpp \
llmq/instantsend.cpp \
llmq/snapshot.cpp \
llmq/signing.cpp \
llmq/signing_shares.cpp \
llmq/utils.cpp \
Expand Down
63 changes: 32 additions & 31 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5; // this corresponds to 10 periods

// Deployment of decreased proposal fee
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nStartTime = 1638316800; // Dec 1st, 2021
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nTimeout = 1669852800; // Dec 1st, 2022
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nWindowSize = 4032;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdStart = 3226; // 80% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nFalloffCoeff = 5; // this corresponds to 10 periods
// Deployment of Quorum Rotation DIP and decreased proposal fee (Values to be determined)
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nStartTime = 1638316800; // Dec 1st, 2021
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nTimeout = 1669852800; // Dec 1st, 2022
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nWindowSize = 4032;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdStart = 3226; // 80% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nFalloffCoeff = 5; // this corresponds to 10 periods

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000549cd3ccb81a55892330"); // 1450000
Expand Down Expand Up @@ -437,14 +437,14 @@ class CTestNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 60; // 60% of 100
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5; // this corresponds to 10 periods

// Deployment of decreased proposal fee
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nStartTime = 999999999999ULL; // TODO renable this before first RC
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nWindowSize = 4032;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdStart = 3226; // 80% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nFalloffCoeff = 5; // this corresponds to 10 periods
// Deployment of Quorum Rotation DIP and decreased proposal fee (Values to be determined)
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nStartTime = 1625097600; // July 1st, 2021
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nTimeout = 1656633600; // July 1st, 2022
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nWindowSize = 4032;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdStart = 3226; // 80% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdMin = 2420; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nFalloffCoeff = 5; // this corresponds to 10 periods

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000022f14ac5d56b5ef"); // 470000
Expand Down Expand Up @@ -630,14 +630,13 @@ class CDevNetParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 60; // 60% of 100
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5; // this corresponds to 10 periods

// Deployment of decreased proposal fee
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nStartTime = 1635724800; // Nov 1st, 2021
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nWindowSize = 100;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdStart = 80;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdMin = 60;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nFalloffCoeff = 5; // this corresponds to 10 periods
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nStartTime = 1625097600; // July 1st, 2021
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nTimeout = 1656633600; // July 1st, 2022
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nWindowSize = 100;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdStart = 80; // 80% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdMin = 60; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nFalloffCoeff = 5; // this corresponds to 10 periods

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000000000000000000");
Expand Down Expand Up @@ -843,13 +842,15 @@ class CRegTestParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdStart = 80;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nThresholdMin = 60;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0020].nFalloffCoeff = 5;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nWindowSize = 100;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdStart = 80;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nThresholdMin = 60;
consensus.vDeployments[Consensus::DEPLOYMENT_GOV_FEE].nFalloffCoeff = 5;

// Deployment of Quorum Rotation DIP and decreased proposal fee (Values to be determined)
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].bit = 7;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nTimeout = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nWindowSize = 300;
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdStart = 50; // 80% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nThresholdMin = 50; // 60% of 4032
consensus.vDeployments[Consensus::DEPLOYMENT_DIP0024].nFalloffCoeff = 5; // this corresponds to 10 periods

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x00");
Expand Down
2 changes: 1 addition & 1 deletion src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum DeploymentPos
DEPLOYMENT_DIP0008, // Deployment of ChainLock enforcement
DEPLOYMENT_REALLOC, // Deployment of Block Reward Reallocation
DEPLOYMENT_DIP0020, // Deployment of DIP0020, DIP0021 and LMQ_100_67 quorums
DEPLOYMENT_GOV_FEE, // Deployment of decreased governance proposal fee
DEPLOYMENT_DIP0024, // Deployment of DIP0024 (Quorum Rotation) and decreased governance proposal fee
// NOTE: Also add new deployments to VersionBitsDeploymentInfo in versionbits.cpp
MAX_VERSION_BITS_DEPLOYMENTS
};
Expand Down
11 changes: 9 additions & 2 deletions src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ CDeterministicMNList CDeterministicMNList::ApplyDiff(const CBlockIndex* pindex,
return result;
}

bool CDeterministicMNList::ContainsMN(const uint256& proTxHash) const
{
return mnMap.find(proTxHash);
}

void CDeterministicMNList::AddMN(const CDeterministicMNCPtr& dmn, bool fBumpTotalCount)
{
assert(dmn != nullptr);
Expand Down Expand Up @@ -875,7 +880,9 @@ bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock& block, const C
}
if (!qc.commitment.IsNull()) {
const auto& llmq_params = llmq::GetLLMQParams(qc.commitment.llmqType);
uint32_t quorumHeight = qc.nHeight - (qc.nHeight % llmq_params.dkgInterval);
//uint32_t quorumHeight = qc.nHeight - (qc.nHeight % llmq_params.dkgInterval - qc.commitment.quorumIndex);
int qcnHeight = static_cast<int>(qc.nHeight);
int quorumHeight = qcnHeight - (qcnHeight % llmq_params.dkgInterval - qc.commitment.quorumIndex);
auto pQuorumBaseBlockIndex = pindexPrev->GetAncestor(quorumHeight);
if (!pQuorumBaseBlockIndex || pQuorumBaseBlockIndex->GetBlockHash() != qc.commitment.quorumHash) {
// we should actually never get into this case as validation should have caught it...but let's be sure
Expand Down Expand Up @@ -922,7 +929,7 @@ void CDeterministicMNManager::HandleQuorumCommitment(const llmq::CFinalCommitmen
{
// The commitment has already been validated at this point, so it's safe to use members of it

auto members = llmq::CLLMQUtils::GetAllQuorumMembers(llmq::GetLLMQParams(qc.llmqType), pQuorumBaseBlockIndex);
auto members = llmq::CLLMQUtils::GetAllQuorumMembers(qc.llmqType, pQuorumBaseBlockIndex);

for (size_t i = 0; i < members.size(); i++) {
if (!mnList.HasMN(members[i]->proTxHash)) {
Expand Down
1 change: 1 addition & 0 deletions src/evo/deterministicmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ class CDeterministicMNList
CSimplifiedMNListDiff BuildSimplifiedDiff(const CDeterministicMNList& to) const;
CDeterministicMNList ApplyDiff(const CBlockIndex* pindex, const CDeterministicMNListDiff& diff) const;

bool ContainsMN(const uint256& proTxHash) const;
void AddMN(const CDeterministicMNCPtr& dmn, bool fBumpTotalCount = true);
void UpdateMN(const CDeterministicMNCPtr& oldDmn, const CDeterministicMNStateCPtr& pdmnState);
void UpdateMN(const uint256& proTxHash, const CDeterministicMNStateCPtr& pdmnState);
Expand Down
2 changes: 1 addition & 1 deletion src/evo/specialtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ bool CheckSpecialTx(const CTransaction& tx, const CBlockIndex* pindexPrev, CVali
case TRANSACTION_QUORUM_COMMITMENT:
return llmq::CheckLLMQCommitment(tx, pindexPrev, state);
case TRANSACTION_MNHF_SIGNAL:
return VersionBitsTipState(Params().GetConsensus(), Consensus::DEPLOYMENT_GOV_FEE) == ThresholdState::ACTIVE && CheckMNHFTx(tx, pindexPrev, state);
return VersionBitsTipState(Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024) == ThresholdState::ACTIVE && CheckMNHFTx(tx, pindexPrev, state);
}
} catch (const std::exception& e) {
LogPrintf("%s -- failed: %s\n", __func__, e.what());
Expand Down
2 changes: 1 addition & 1 deletion src/governance/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingC
findScript << OP_RETURN << ToByteVector(nExpectedHash);

AssertLockHeld(cs_main);
bool fork_active = VersionBitsState(LookupBlockIndex(nBlockHash), Params().GetConsensus(), Consensus::DEPLOYMENT_GOV_FEE, versionbitscache) == ThresholdState::ACTIVE;
bool fork_active = VersionBitsState(LookupBlockIndex(nBlockHash), Params().GetConsensus(), Consensus::DEPLOYMENT_DIP0024, versionbitscache) == ThresholdState::ACTIVE;
CAmount nMinFee = GetMinCollateralFee(fork_active);

LogPrint(BCLog::GOBJECT, "CGovernanceObject::IsCollateralValid -- txCollateral->vout.size() = %s, findScript = %s, nMinFee = %lld\n",
Expand Down
4 changes: 4 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
#include <llmq/init.h>
#include <llmq/blockprocessor.h>
#include <llmq/signing.h>
#include <llmq/snapshot.h>
#include <llmq/utils.h>

#include <statsd_client.h>
Expand Down Expand Up @@ -321,6 +322,7 @@ void PrepareShutdown(InitInterfaces& interfaces)
pblocktree.reset();
llmq::DestroyLLMQSystem();
deterministicMNManager.reset();
llmq::quorumSnapshotManager.reset();
evoDb.reset();
}
for (const auto& client : interfaces.chain_clients) {
Expand Down Expand Up @@ -1981,6 +1983,8 @@ bool AppInitMain(InitInterfaces& interfaces)
evoDb.reset(new CEvoDB(nEvoDbCache, false, fReset || fReindexChainState));
deterministicMNManager.reset();
deterministicMNManager.reset(new CDeterministicMNManager(*evoDb));
llmq::quorumSnapshotManager.reset();
llmq::quorumSnapshotManager.reset(new llmq::CQuorumSnapshotManager(*evoDb));

llmq::InitLLMQSystem(*evoDb, false, fReset || fReindexChainState);

Expand Down
Loading