Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
59bc2ea
feat: add the evo snapshot v3 canonical bounded codec and context-fre…
PastaPastaPasta Aug 13, 2026
00228ce
fix: build the ReadFixedBitSet trailing-bits mask without an implicit…
PastaPastaPasta Aug 13, 2026
4488b64
test: cover the bounded CRangesSet unserializer
PastaPastaPasta Aug 13, 2026
0765965
fix: allow partial evo snapshot quorum history
PastaPastaPasta Aug 13, 2026
5aea447
fix: reject full-domain ranges during deserialization
PastaPastaPasta Aug 13, 2026
aea2e8c
fix: reject noncanonical MNHF signal order during deserialization
PastaPastaPasta Aug 20, 2026
5967566
fix: bound commitment bitsets by a format ceiling instead of static L…
PastaPastaPasta Aug 20, 2026
fdaff57
fix: validate credit-pool amounts and MNHF signal semantics context-free
PastaPastaPasta Aug 20, 2026
8d4ac9b
fix: replace previous contents when deserializing an evo snapshot
PastaPastaPasta Aug 20, 2026
8512a65
fix: bound same-prefix proTxHash runs against HAMT collision blowup
PastaPastaPasta Aug 20, 2026
776188b
fix: bind the CbTx height in VerifyEvoSnapshotCbTx
PastaPastaPasta Aug 20, 2026
1ea1e01
fix: replace per-quorum contents when deserializing CQuorumSnapshotData
PastaPastaPasta Aug 20, 2026
ec1ef2d
fix: bound cumulative historical MN-list reconstruction work
PastaPastaPasta Aug 20, 2026
1a90e7e
refactor: drop the C prefix from the new evo snapshot types
PastaPastaPasta Aug 28, 2026
babf47e
refactor: give every evo snapshot collection one explicit canonical c…
PastaPastaPasta Aug 28, 2026
da25ab6
build: list evo/snapshot.cpp where it is actually used
PastaPastaPasta Aug 28, 2026
7183a4d
fix: enforce the decoder's historical operation budget during validation
PastaPastaPasta Aug 28, 2026
c94bb8f
test: exercise evo per-quorum replacement for every cleared vector
PastaPastaPasta Aug 28, 2026
ccf37fe
test: name the noncanonical CRangesSet case for its actual defect
PastaPastaPasta Aug 28, 2026
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 @@ -235,6 +235,7 @@ BITCOIN_CORE_H = \
evo/providertx_service.h \
evo/simplifiedmns.h \
evo/smldiff.h \
evo/snapshot.h \
evo/specialtx.h \
evo/specialtx_filter.h \
evo/specialtxman.h \
Expand Down Expand Up @@ -550,6 +551,7 @@ libbitcoin_node_a_SOURCES = \
evo/providertx_service.cpp \
evo/simplifiedmns.cpp \
evo/smldiff.cpp \
evo/snapshot.cpp \
evo/specialtx.cpp \
evo/specialtx_filter.cpp \
evo/specialtxman.cpp \
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ BITCOIN_TESTS =\
test/evo_mnhf_tests.cpp \
test/evo_netinfo_tests.cpp \
test/evo_simplifiedmns_tests.cpp \
test/evo_snapshot_tests.cpp \
test/evo_trivialvalidation.cpp \
test/evo_utils_tests.cpp \
test/flatfile_tests.cpp \
Expand Down
4 changes: 2 additions & 2 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -882,11 +882,11 @@ class CRegTestParams : public CChainParams {
m_assumeutxo_data = MapAssumeutxo{
{
110,
{AssumeutxoHash{uint256S("0x9b2a277a3e3b979f1a539d57e949495d7f8247312dbc32bce6619128c192b44b")}, 110},
{AssumeutxoHash{uint256S("0x9b2a277a3e3b979f1a539d57e949495d7f8247312dbc32bce6619128c192b44b")}, EvoSnapshotHash{uint256{}}, 110},
},
{
200,
{AssumeutxoHash{uint256S("0x8a5bdd92252fc6b24663244bbe958c947bb036dc1f94ccd15439f48d8d1cb4e3")}, 200},
{AssumeutxoHash{uint256S("0x8a5bdd92252fc6b24663244bbe958c947bb036dc1f94ccd15439f48d8d1cb4e3")}, EvoSnapshotHash{uint256{}}, 200},
},
};

Expand Down
7 changes: 7 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ struct AssumeutxoHash : public BaseHash<uint256> {
explicit AssumeutxoHash(const uint256& hash) : BaseHash(hash) {}
};

struct EvoSnapshotHash : public BaseHash<uint256> {
explicit EvoSnapshotHash(const uint256& hash) : BaseHash(hash) {}
};

/**
* Holds configuration for use during UTXO snapshot load and validation. The contents
* here are security critical, since they dictate which UTXO snapshots are recognized
Expand All @@ -43,6 +47,9 @@ struct AssumeutxoData {
//! The expected hash of the deserialized UTXO set.
const AssumeutxoHash hash_serialized;

//! The expected single-SHA256 hash of the canonical Dash evo section.
const EvoSnapshotHash evo_hash;

//! Used to populate the nChainTx value, which is used during BlockManager::LoadBlockIndex().
//!
//! We need to hardcode the value here because this is computed cumulatively using block data,
Expand Down
24 changes: 24 additions & 0 deletions src/evo/deterministicmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,30 @@ void CDeterministicMNList::ApplyDiff(gsl::not_null<const CBlockIndex*> pindex, c
}
}

void CDeterministicMNList::ApplyDiffForSnapshot(const uint256& block_hash, int height,
uint32_t total_registered_count,
const CDeterministicMNListDiff& diff)
{
if (height < 0) throw std::runtime_error("negative historical MN-list height");
blockHash = block_hash;
nHeight = height;

for (const auto& id : diff.removedMns) {
auto dmn = GetMNByInternalId(id);
if (!dmn) throw std::runtime_error(strprintf("%s: can't find a removed masternode, id=%d", __func__, id));
RemoveMN(dmn->proTxHash);
}
for (const auto& dmn : diff.addedMNs) {
AddMN(dmn, /*fBumpTotalCount=*/false);
}
for (const auto& p : diff.updatedMNs) {
auto dmn = GetMNByInternalId(p.first);
if (!dmn) throw std::runtime_error(strprintf("%s: can't find an updated masternode, id=%d", __func__, p.first));
UpdateMN(*dmn, p.second);
}
nTotalRegisteredCount = total_registered_count;
}

void CDeterministicMNList::AddMN(const CDeterministicMNCPtr& dmn, bool fBumpTotalCount)
{
assert(dmn != nullptr);
Expand Down
7 changes: 7 additions & 0 deletions src/evo/deterministicmns.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ class CDeterministicMNList
assert(nHeight >= 0);
return nHeight;
}
/** Snapshot hashing also covers the pre-DIP3 default list (height -1). */
[[nodiscard]] int GetHeightForSnapshotCodec() const noexcept { return nHeight; }
void SetHeight(int _height)
{
assert(_height >= 0);
Expand Down Expand Up @@ -423,6 +425,11 @@ class CDeterministicMNList
void ApplyDiff(gsl::not_null<const CBlockIndex*> pindex, const CDeterministicMNListDiff& diff)
EXCLUSIVE_LOCKS_REQUIRED(!m_cached_sml_mutex);

/** Apply a snapshot-local historical diff without dereferencing block data. */
void ApplyDiffForSnapshot(const uint256& block_hash, int height, uint32_t total_registered_count,
const CDeterministicMNListDiff& diff)
EXCLUSIVE_LOCKS_REQUIRED(!m_cached_sml_mutex);

void AddMN(const CDeterministicMNCPtr& dmn, bool fBumpTotalCount = true) EXCLUSIVE_LOCKS_REQUIRED(!m_cached_sml_mutex);
void UpdateMN(const CDeterministicMN& oldDmn, const std::shared_ptr<const CDeterministicMNState>& pdmnState)
EXCLUSIVE_LOCKS_REQUIRED(!m_cached_sml_mutex);
Expand Down
Loading
Loading