Skip to content

Commit 0e53540

Browse files
authored
feat: mnlistdiff move nversion to first position (#5450)
## Issue being fixed or feature implemented Version field should always be the first field of a message for better readibility. ## What was done? - Introduced new protocol version `MNLISTDIFF_VERSION_ORDER` (`70229`). - `nVersion` serialisation order is changed for clients with protocol version greater than or equal to `70229`. - For clients with protocol version >= `70225` and < `70229` the old order is used: can be deprecated in the future. - Increased functional test P2P mininode's protocol version to `70229`. ## How Has This Been Tested? `feature_llmq_rotation.py` with new protocol version. ## Breaking Changes ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [x] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
1 parent 3e29e8f commit 0e53540

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/evo/simplifiedmns.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ class CSimplifiedMNListDiff
139139

140140
SERIALIZE_METHODS(CSimplifiedMNListDiff, obj)
141141
{
142+
if ((s.GetType() & SER_NETWORK) && s.GetVersion() >= MNLISTDIFF_VERSION_ORDER) {
143+
READWRITE(obj.nVersion);
144+
}
142145
READWRITE(obj.baseBlockHash, obj.blockHash, obj.cbTxMerkleTree, obj.cbTx);
143-
if ((s.GetType() & SER_NETWORK) && s.GetVersion() >= BLS_SCHEME_PROTO_VERSION) {
146+
if ((s.GetType() & SER_NETWORK) && s.GetVersion() >= BLS_SCHEME_PROTO_VERSION && s.GetVersion() < MNLISTDIFF_VERSION_ORDER) {
144147
READWRITE(obj.nVersion);
145148
}
146149
READWRITE(obj.deletedMNs, obj.mnList);

src/version.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313

14-
static const int PROTOCOL_VERSION = 70228;
14+
static const int PROTOCOL_VERSION = 70229;
1515

1616
//! initial proto version, to be increased after version/verack negotiation
1717
static const int INIT_PROTO_VERSION = 209;
@@ -52,6 +52,9 @@ static const int DMN_TYPE_PROTO_VERSION = 70227;
5252
//! Versioned Simplified Masternode List Entries were introduced in this version
5353
static const int SMNLE_VERSIONED_PROTO_VERSION = 70228;
5454

55+
//! Versioned Simplified Masternode List Entries were introduced in this version
56+
static const int MNLISTDIFF_VERSION_ORDER = 70229;
57+
5558
// Make sure that none of the values above collide with `ADDRV2_FORMAT`.
5659

5760
#endif // BITCOIN_VERSION_H

test/functional/test_framework/messages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import dash_hash
3333

3434
MIN_VERSION_SUPPORTED = 60001
35-
MY_VERSION = 70228 # SMNLE_VERSIONED_PROTO_VERSION
35+
MY_VERSION = 70229 # MNLISTDIFF_VERSION_ORDER
3636
MY_SUBVERSION = b"/python-mininode-tester:0.0.3%s/"
3737
MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)
3838

@@ -2038,13 +2038,13 @@ def __init__(self):
20382038
self.newQuorums = []
20392039

20402040
def deserialize(self, f):
2041+
self.nVersion = struct.unpack("<H", f.read(2))[0]
20412042
self.baseBlockHash = deser_uint256(f)
20422043
self.blockHash = deser_uint256(f)
20432044
self.merkleProof.deserialize(f)
20442045
self.cbTx = CTransaction()
20452046
self.cbTx.deserialize(f)
20462047
self.cbTx.rehash()
2047-
self.nVersion = struct.unpack("<H", f.read(2))[0]
20482048
self.deletedMNs = deser_uint256_vector(f)
20492049
self.mnList = []
20502050
for i in range(deser_compact_size(f)):

0 commit comments

Comments
 (0)