From c9490bd91b16dd5ca085047c10a991620c9f20cb Mon Sep 17 00:00:00 2001 From: Odysseas Gabrielides Date: Sun, 9 Apr 2023 08:12:39 +0300 Subject: [PATCH] feat: min protocol version check for SML serialisation (#5302) ## Issue being fixed or feature implemented This was reported/requested by @HashEngineering: > Older versions of our App won't sync due to if (obj.nVersion == BASIC_BLS_VERSION) . Older versions don't know what version a SML Entry is. As such, they will never read the type field. On the android client this causes an offset problem when reading the mnlistdiff and it will throw an exception that bans the peer that supplied it. Soon enough, no peers will be left to connect to because they will all give the android client bad data. ## What was done? With this PR, SML will serialise the new v19 fields (`nType`, `platformHTTPPort`, `platformNodeID`) if the client's version is at least equal to `70227`. Note: Serialisation for hashing skips the above rule. Also, functional test mininode protocol version is set to `70227`. ## How Has This Been Tested? ## 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 **For repository code-owners and collaborators only** - [x] I have assigned this pull request to a milestone --- src/evo/simplifiedmns.h | 3 +++ test/functional/test_framework/messages.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/evo/simplifiedmns.h b/src/evo/simplifiedmns.h index dd3882ca41..77165c56b6 100644 --- a/src/evo/simplifiedmns.h +++ b/src/evo/simplifiedmns.h @@ -73,6 +73,9 @@ public: obj.keyIDVoting, obj.isValid ); + if ((s.GetType() & SER_NETWORK) && s.GetVersion() < DMN_TYPE_PROTO_VERSION) { + return; + } if (obj.nVersion == BASIC_BLS_VERSION) { READWRITE(obj.nType); if (obj.nType == MnType::HighPerformance) { diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 970221f6d2..055b9c44e1 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -32,7 +32,7 @@ from test_framework.util import hex_str_to_bytes, assert_equal import dash_hash MIN_VERSION_SUPPORTED = 60001 -MY_VERSION = 70225 # BLS_SCHEME_PROTO_VERSION +MY_VERSION = 70227 # DMN_TYPE_PROTO_VERSION MY_SUBVERSION = b"/python-mininode-tester:0.0.3%s/" MY_RELAY = 1 # from version 70001 onwards, fRelay should be appended to version messages (BIP37)