Skip to content

feat: decode SML ProTx v3 entries#797

Open
xdustinface wants to merge 1 commit into
devfrom
fix/sml-extnetinfo-v3-decode
Open

feat: decode SML ProTx v3 entries#797
xdustinface wants to merge 1 commit into
devfrom
fix/sml-extnetinfo-v3-decode

Conversation

@xdustinface
Copy link
Copy Markdown
Collaborator

@xdustinface xdustinface commented Jun 1, 2026

Dash Core 23.1 introduced ProTx version 3 (ProTxVersion::ExtAddr). CSimplifiedMNListEntry gates two things on nVersion >= 3: the service address switches from the legacy fixed 18-byte MnNetInfo to a variable-length ExtNetInfo, and Evo nodes no longer serialize the inline platformHTTPPort (only platformNodeID is inline, the HTTP port lives in ExtNetInfo under PLATFORM_HTTPS). The previous decoder always read a fixed 18-byte address, desyncing the stream on v3 entries and failing with Invalid MasternodeType variant.

Add a faithful net_info module with Bip155Network, NetInfoEntry, NetInfoPurpose and ExtNetInfo types decoding the ADDRV2/BIP155 wire form (per-network address-length validation, big-endian ports, version short-circuit). Introduce MasternodeNetInfo::{Legacy, Extended} for MasternodeListEntry::service_address with a version-driven decode/encode branch and a primary_service_address() accessor that reconstructs IPv4/IPv6 SocketAddrs. Inline the mn_type codec into the entry path so v3 Evo entries read only platform_node_id and source platform_http_port from the PLATFORM_HTTPS entry, while v2 Evo entries keep the inline port.

MasternodeNetInfo carries a hand-written bincode codec whose Legacy arm reuses the bare SocketAddr layout so existing persisted engine snapshots keep decoding.

Also fix QuorumSnapshot::consensus_encode to write the compact-size activeQuorumMembers count that the decoder already consumed, which the byte-exact qrinfo round-trip requires.

Consumers (peer_addresses, masternode_helpers, masternode-seeds-fetcher) now go through primary_service_address().

Based on:

Summary by CodeRabbit

Release Notes

  • New Features

    • Added support for Protocol v3 Quorum and Masternode information with enhanced network data encoding.
    • Implemented support for multiple network types (IPv4, IPv6, Tor, I2P, CJDNS) alongside legacy address formats.
    • Improved masternode address handling with primary service address resolution for better connectivity.
  • Bug Fixes

    • Enhanced network address filtering to ensure only valid masternode entries are included in peer discovery.
    • Strengthened data integrity validation for Quorum information serialization and deserialization.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 80bd6f4d-4cc9-496a-a87f-13bef186c792

📥 Commits

Reviewing files that changed from the base of the PR and between a132945 and 65aea9a.

📒 Files selected for processing (7)
  • dash/src/network/message_qrinfo.rs
  • dash/src/sml/masternode_list/masternode_helpers.rs
  • dash/src/sml/masternode_list/peer_addresses.rs
  • dash/src/sml/masternode_list_entry/mod.rs
  • dash/src/sml/masternode_list_entry/net_info.rs
  • dash/tests/data/test_DML_diffs/qrinfo_core231_paloma.hex
  • masternode-seeds-fetcher/src/main.rs

📝 Walkthrough

Walkthrough

This PR adds ProTx v3 masternode support by introducing BIP155-based extended network info encoding/decoding, wrapping legacy and extended addresses in a MasternodeNetInfo enum, updating consensus serialization logic to handle v3 versioning, and integrating the new type throughout address-consuming functions with comprehensive fixture-based tests.

Changes

ProTx v3 Extended Network Info Support

Layer / File(s) Summary
Extended network info data structure and wire format
dash/src/sml/masternode_list_entry/net_info.rs
New module implements BIP155 network types (IPv4/IPv6/Tor/I2p/Cjdns), NetInfoEntry (Service/Domain/Invalid variants), NetInfoPurpose codes (CoreP2P/PlatformP2P/PlatformHttps), and ExtNetInfo struct with version-aware consensus encode/decode preserving entry order. Includes platform_https_port() lookup and roundtrip validation tests.
MasternodeNetInfo wrapper and consensus integration
dash/src/sml/masternode_list_entry/mod.rs
Introduces MasternodeNetInfo enum (Legacy/Extended) with bincode-compatible encode/decode for backwards compatibility and primary_service_address() extraction. Updates MasternodeListEntry::service_address field type and rewrites consensus_encode/consensus_decode to route v<3 entries through legacy SocketAddr and v>=3 through ExtNetInfo, with version-dependent platform_http_port serialization.
Consumer functions updated to use primary_service_address()
dash/src/sml/masternode_list/masternode_helpers.rs, dash/src/sml/masternode_list/peer_addresses.rs, masternode-seeds-fetcher/src/main.rs
Updates has_masternode_at_location to extract primary_service_address() and short-circuit on None, peer_addresses_with_connectivity_nonce to filter invalid entries and derive SocketAddr from primary_service_address(), and collect_seeds to skip entries without a primary address and deduplicate by the derived SocketAddr.
v3 QRInfo fixture and validation tests
dash/src/network/message_qrinfo.rs, dash/tests/data/test_DML_diffs/qrinfo_core231_paloma.hex
Adds v3 QRInfo test data fixture and load_v3_qrinfo_bytes() helper with SHA-256 integrity check. Three new tests validate deserialization, byte-exact round-tripping, and cross-field validation of HighPerformance entries against decoded extended network info (including optional extra_share diffs).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

Suggested labels

ready-for-review

Suggested reviewers

  • QuantumExplorer
  • ZocoLini

Poem

🐰 Hop along through networks extended,
With BIP155 paths now resplendent,
v3 masternodes bloom in the spring,
Where IPv4 and Tor gently ring,
And platform addresses take their wing! 🌸

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: decode SML ProTx v3 entries' accurately summarizes the main objective of the changeset, which implements decoding support for ProTx v3 entries with extended network information.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sml-extnetinfo-v3-decode

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

❌ Patch coverage is 81.38425% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.77%. Comparing base (a132945) to head (65aea9a).

Files with missing lines Patch % Lines
dash/src/sml/masternode_list_entry/mod.rs 51.21% 40 Missing ⚠️
dash/src/sml/masternode_list_entry/net_info.rs 90.81% 26 Missing ⚠️
dash/src/sml/masternode_list/masternode_helpers.rs 0.00% 6 Missing ⚠️
dash/src/sml/masternode_list/peer_addresses.rs 0.00% 4 Missing ⚠️
dash/src/network/message_qrinfo.rs 95.45% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #797      +/-   ##
==========================================
+ Coverage   72.67%   72.77%   +0.09%     
==========================================
  Files         322      323       +1     
  Lines       71363    71745     +382     
==========================================
+ Hits        51866    52210     +344     
- Misses      19497    19535      +38     
Flag Coverage Δ
core 76.75% <81.38%> (+0.20%) ⬆️
ffi 46.42% <ø> (+0.01%) ⬆️
rpc 20.00% <ø> (ø)
spv 90.30% <ø> (ø)
wallet 71.29% <ø> (ø)
Files with missing lines Coverage Δ
dash/src/network/message_qrinfo.rs 73.00% <95.45%> (+20.43%) ⬆️
dash/src/sml/masternode_list/peer_addresses.rs 0.00% <0.00%> (ø)
dash/src/sml/masternode_list/masternode_helpers.rs 25.80% <0.00%> (-0.87%) ⬇️
dash/src/sml/masternode_list_entry/net_info.rs 90.81% <90.81%> (ø)
dash/src/sml/masternode_list_entry/mod.rs 60.00% <51.21%> (-21.58%) ⬇️

... and 2 files with indirect coverage changes

@Claudius-Maginificent
Copy link
Copy Markdown

Confirmed — this branch fixes SML ProTx-v3 decoding for us. ✅

We hit the exact Invalid MasternodeType variant / InvalidEnumValue { max: 1, received: 7791 } failure decoding qrinfo/MnListDiff from a Core 23.1.2 devnet (paloma, proto 70240) — see #795. Pinning dash-spv/dashcore/key-wallet/… to this branch (2a68c38) and re-running our platform-wallet SPV e2e suite against the live devnet (cold cache, real peers, no fixture):

Processing QRInfo message
QRInfo processed: rotated_quorum_count=2, fully_verified_count=2
All MnListDiff responses received
Masternodes: Synced 15606/15606 | diffs_processed: 2, qr_infos_requested: 1
ChainLock manager synced (masternode data available)
mn-list synced current_height=15606 elapsed=5.4s

No InvalidEnumValue anywhere in the log — the v3 ExtNetInfo entries now decode and the mn-list reaches Synced. As a bonus, the handshake against proto-70240 peers also completes cleanly (verack received), which eb889af couldn't do. Zero source changes needed on our side — the dependency bump alone was sufficient.

(Our e2e test runs well past mn-list sync and only stops later at an unrelated operator precondition — the test bank's Platform credit balance — so nothing further here reflects on this PR.)

Thanks for the quick turnaround!

🤖 Co-authored by Claudius the Magnificent AI Agent

Base automatically changed from fix/quorum-snapshot-encode-compact-size to dev June 2, 2026 01:19
Dash Core 23.1 introduced ProTx version 3 (`ProTxVersion::ExtAddr`). `CSimplifiedMNListEntry` gates two things on `nVersion >= 3`: the service address switches from the legacy fixed 18-byte `MnNetInfo` to a variable-length `ExtNetInfo`, and Evo nodes no longer serialize the inline `platformHTTPPort` (only `platformNodeID` is inline, the HTTP port lives in `ExtNetInfo` under `PLATFORM_HTTPS`). The previous decoder always read a fixed 18-byte address, desyncing the stream on v3 entries and failing with `Invalid MasternodeType variant`.

Add a faithful `net_info` module with `Bip155Network`, `NetInfoEntry`, `NetInfoPurpose` and `ExtNetInfo` types decoding the ADDRV2/BIP155 wire form (per-network address-length validation, big-endian ports, version short-circuit). Introduce `MasternodeNetInfo::{Legacy, Extended}` for `MasternodeListEntry::service_address` with a version-driven decode/encode branch and a `primary_service_address()` accessor that reconstructs IPv4/IPv6 `SocketAddr`s. Inline the `mn_type` codec into the entry path so v3 Evo entries read only `platform_node_id` and source `platform_http_port` from the `PLATFORM_HTTPS` entry, while v2 Evo entries keep the inline port.

`MasternodeNetInfo` carries a hand-written `bincode` codec whose `Legacy` arm reuses the bare `SocketAddr` layout so existing persisted engine snapshots keep decoding.

Also fix `QuorumSnapshot::consensus_encode` to write the compact-size `activeQuorumMembers` count that the decoder already consumed, which the byte-exact `qrinfo` round-trip requires.

Consumers (`peer_addresses`, `masternode_helpers`, `masternode-seeds-fetcher`) now go through `primary_service_address()`.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 2, 2026

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@github-actions github-actions Bot added the merge-conflict The PR conflicts with the target branch. label Jun 2, 2026
@xdustinface xdustinface force-pushed the fix/sml-extnetinfo-v3-decode branch from 2a68c38 to 65aea9a Compare June 2, 2026 01:25
@github-actions github-actions Bot removed the merge-conflict The PR conflicts with the target branch. label Jun 2, 2026
@xdustinface xdustinface marked this pull request as ready for review June 2, 2026 01:33
@github-actions github-actions Bot added the ready-for-review CodeRabbit has approved this PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review CodeRabbit has approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants