Skip to content

feat: finalize transport v2 migration (Phase C)#626

Open
AndreaDiazCorreia wants to merge 2 commits into
mainfrom
feat/transport-v2-phase-c
Open

feat: finalize transport v2 migration (Phase C)#626
AndreaDiazCorreia wants to merge 2 commits into
mainfrom
feat/transport-v2-phase-c

Conversation

@AndreaDiazCorreia

@AndreaDiazCorreia AndreaDiazCorreia commented Jun 22, 2026

Copy link
Copy Markdown
Member

Finalizes the transport v1 → v2 migration (docs/architecture/TRANSPORT_V2_MIGRATION.md). The send/receive wiring already landed in Phase A (#621) and Phase B (#624); this closes the remaining loose ends.

Changes

  • Remove Config.mostroVersion: the message version is now derived from the transport — MostroMessage.toJson defaults to 1 (gift wrap), and wrapNip44 passes 2.
  • Testable orders filter: extract buildOrdersFilter(transport, tradeKeys, mostroPubkey) from the subscription manager, with unit tests (v1 → kind 1059; v2 → kind 14 pinned to authors=[mostroPubkey]).
  • Docs: mark the migration complete — update the status, §4.2 (version derived from transport), and the Phase C/D sections with references to the actual tests.

Verification

  • flutter analyze: no issues.
  • flutter test: all pass (v1 path unchanged).

Summary by CodeRabbit

  • Documentation
    • Architecture guide updated to reflect Transport v2 migration completion, including dual receive/send support and automatic protocol version detection.
  • Refactor
    • Mostro message versioning is now derived from the selected transport path rather than global configuration.
    • Orders filter construction is now centralized via a transport-aware helper.
  • New Features
    • Mostro node “protocol version” is shown in the About screen with explanatory text.
  • Tests
    • Added tests for transport-aware orders filters and updated service integration tests to align with the new versioning behavior.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 555ba4e8-b518-453c-abb1-b5d3c5ea0652

📥 Commits

Reviewing files that changed from the base of the PR and between 99e2707 and 0af1788.

📒 Files selected for processing (6)
  • lib/features/settings/about_screen.dart
  • lib/l10n/intl_de.arb
  • lib/l10n/intl_en.arb
  • lib/l10n/intl_es.arb
  • lib/l10n/intl_fr.arb
  • lib/l10n/intl_it.arb
✅ Files skipped from review due to trivial changes (4)
  • lib/l10n/intl_en.arb
  • lib/l10n/intl_es.arb
  • lib/l10n/intl_de.arb
  • lib/l10n/intl_it.arb

Walkthrough

Removes the global Config.mostroVersion constant, updates MostroMessage.toJson to derive the protocol version from the transport (defaulting to 1), extracts the orders subscription filter logic into a standalone buildOrdersFilter function with tests, adds a protocol version display row to the about screen with localization strings in five languages, and marks the Transport v2 migration documentation as complete.

Changes

Transport v2 migration finalization

Layer / File(s) Summary
Remove global version constant and update message serialization
lib/core/config.dart, lib/data/models/mostro_message.dart
Removes Config.mostroVersion static field, drops the config.dart import from MostroMessage, and updates toJson to default version to 1 directly instead of reading from the removed constant.
Extract buildOrdersFilter and add transport mapping tests
lib/features/subscriptions/subscription_manager.dart, test/features/subscriptions/orders_filter_test.dart, test/services/mostro_service_test.dart
Adds @visibleForTesting top-level buildOrdersFilter function mapping Transport.giftWrap to kind 1059 (no authors) and Transport.nip44 to kind 14 (authors pinned), replaces inline filter construction with a call to the new function, adds a test group verifying both filter shapes, and updates four mostro_service_test messages to use hardcoded version: 1.
Display protocol version in about screen with localization
lib/features/settings/about_screen.dart, lib/l10n/intl_*.arb
Adds a new information row to the Mostro node technical details in AboutScreen displaying instance.protocolVersion, adds localization entries for protocolVersion label and protocolVersionExplanation in English, German, Spanish, French, and Italian.
Update migration documentation
docs/architecture/TRANSPORT_V2_MIGRATION.md
Updates status to "Migration complete," documents removal of the global Config.mostroVersion constant, rewrites the version-derivation section to explain how version is now derived from the resolved transport, updates the touch-points table, and expands Phase C/D documentation for buildOrdersFilter extraction and test coverage.

Sequence Diagram(s)

No sequence diagrams generated. The changes do not introduce new multi-component interactions or control flow modifications that would benefit from sequencing visualization; they are primarily constant removal, function extraction, UI additions, and documentation updates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • MostroP2P/mobile#620: Directly implements the transport-v2 migration semantics that this PR's docs and Config.mostroVersion removal finalize.
  • MostroP2P/mobile#621: Contains the transport-aware orders filter logic (kind 1059 vs kind 14) that this PR extracts into the testable buildOrdersFilter function.
  • MostroP2P/mobile#624: Added per-transport toJson(version) and NIP-44 version: 2 emission that this PR finalizes by removing the global Config.mostroVersion dependency.

Suggested reviewers

  • grunch
  • ermeme

Poem

🐇 Hop, hop — the global constant's gone!
No mostroVersion to rely upon,
The transport now decides the 1 or 2,
buildOrdersFilter tested, clean and true.
Migration complete, the docs now say —
This bunny stamps the PR: ✅ today! 🎉

🚥 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: finalize transport v2 migration (Phase C)' directly and accurately summarizes the main change—completing the transport v2 migration Phase C by removing the global version constant and extracting testable filter logic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/transport-v2-phase-c

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.

ermeme[bot]
ermeme Bot previously approved these changes Jun 22, 2026

@ermeme ermeme Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed by Hermes Agent. The transport-v2 finalization looks correct, and I did not find blocking issues on the current head.

@ermeme

ermeme Bot commented Jun 22, 2026

Copy link
Copy Markdown

A couple of non-blocking nits I would leave as follow-up comments:

  1. lib/features/subscriptions/subscription_manager.dart: the new buildOrdersFilter(...) helper is a good seam, but the import order is now a bit off (flutter/foundation.dart is separated from the other package imports). Running the formatter/import sorter would keep the file consistent with Dart style.
  2. test/services/mostro_service_test.dart: in the full-privacy test, mockNostrService.publishEvent(any) is stubbed twice back-to-back. The second stub is redundant and can be removed.

Nothing here changes my verdict; the PR still looks good to merge.

grunch
grunch previously approved these changes Jun 22, 2026

@grunch grunch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review — Phase C (finalize transport v2)

Verified by checking out the branch: regenerated code and ran flutter analyze + flutter test on the affected and related files.

Checks ✅

  • Config.mostroVersion removed, no dangling references in lib/.
  • Config import removed from mostro_message.dart (no longer used there); still imported/used in mostro_service_test.dart (Config.keyDerivationPath) → no unused import.
  • v1 path (wrapserializetoJson() default) yields version: 1, identical to the previous Config.mostroVersion = 1 → byte-for-byte equivalent.
  • v2 path (wrapNip44toJson(version: 2)) is correct.
  • buildOrdersFilter reproduces the original switch exactly (kinds / p / authors), is well documented and annotated @visibleForTesting.
  • All 5 test files cited in the docs exist and pass (orders_filter, mostro_service, nip44, transport, mostro_instance, restore_decode).

Removing Config.mostroVersion is safe: it was a static int but only ever read (never mutated). The other mostroVersion in the repo (MostroInstance.mostroVersion, a String = daemon version) is semantically different and unaffected.

Minor (non-blocking)

  1. Docs say "Migration complete… merged" inside a still-open PR: the §Status claims Phase C is already merged, when it is precisely this PR. Cosmetic — becomes true on merge.
  2. Scattered magic version numbers: the "giftWrap=1 / nip44=2" mapping lives in the ?? 1 default of toJson, the literal version: 2 in wrapNip44, and resolveTransport. It works and is commented, but a single source of truth (e.g. Transport.wireVersion) would prevent future drift.

Environment note (unrelated to this PR)

I could not fully reproduce "flutter analyze: no issues": there are 2 pre-existing errors (ScrollCacheExtent in lib/features/chat/widgets/chat_messages_list.dart:119, introduced in #613, SDK-version dependent). Not attributable to this PR — worth a separate issue.

Verdict

Approved. Clean, low-risk refactor that preserves the v1 path exactly, enables the already-existing v2 path, and improves testability. Docs are accurate.


(Edited: original review text was posted in Spanish by mistake; reposting in English.)

Add protocol_version field to about screen showing the node's transport protocol (1 = NIP-59 gift wrap, 2 = NIP-44 direct messages) with explanatory dialog. Add localized strings in en/es/it/de/fr.
@AndreaDiazCorreia AndreaDiazCorreia dismissed stale reviews from grunch and ermeme[bot] via 0af1788 June 23, 2026 02:23

@ermeme ermeme Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current head again. The new protocol-version info row and localization keys look fine; I don't see any blocking issues.

@Catrya Catrya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. When try to create a new order (Mostrod: anti-abuse bond = false).
Image Image
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Bad state: Tried to rebuild StateProvider<Session?>#e0a7c() multiple times in the same frame
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ #0   ProviderScheduler.debugNotifyDidBuild (package:riverpod/src/core/scheduler.dart:181:9)
│ #1   ProviderElement.buildState (package:riverpod/src/core/element.dart:731:27)
│ #2   ProviderElement._performRebuild (package:riverpod/src/core/element.dart:638:7)
│ #3   ProviderElement.flush (package:riverpod/src/core/element.dart:705:7)
│ #4   $ProviderBaseImpl._addListener (package:riverpod/src/core/provider/provider.dart:119:24)
│ #5   ProviderContainer.listen (package:riverpod/src/core/provider_container.dart:1102:26)
│ #6   ProviderContainer.read (package:riverpod/src/core/provider_container.dart:1028:17)
│ #7   Ref.read (package:riverpod/src/core/ref.dart:609:30)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 00:19:28.984 (+0:17:13.715157)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ ⛔ Error handling automatic cancellation for order 
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ Bad state: Tried to rebuild StateProvider<Session?>#81776(304867118) multiple times in the same frame
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ #0   ProviderScheduler.debugNotifyDidBuild (package:riverpod/src/core/scheduler.dart:181:9)
│ #1   ProviderElement.buildState (package:riverpod/src/core/element.dart:731:27)
│ #2   ProviderElement._performRebuild (package:riverpod/src/core/element.dart:638:7)
│ #3   ProviderElement.flush (package:riverpod/src/core/element.dart:705:7)
│ #4   $ProviderBaseImpl._addListener (package:riverpod/src/core/provider/provider.dart:119:24)
│ #5   ProviderContainer.listen (package:riverpod/src/core/provider_container.dart:1102:26)
│ #6   ProviderContainer.read (package:riverpod/src/core/provider_container.dart:1028:17)
│ #7   Ref.read (package:riverpod/src/core/ref.dart:609:30)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ 00:19:28.986 (+0:17:13.717585)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ ⛔ Error handling automatic cancellation for order 304867118
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
  1. When try to create a new order (Mostro: anti-abuse bond=true)
Image ``` ── │ #0 getNotificationLaunchOrderId (package:mostro_mobile/features/notifications/services/background_notification_service.dart:61:12) │ #1 ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ │ 00:15:26.130 (+0:13:10.861509) ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ │ ⛔ Error checking notification launch details: UnimplementedError: getNotificationAppLaunchDetails() has not been implemented └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ```

@Catrya

Catrya commented Jun 23, 2026

Copy link
Copy Markdown
Member

When try to take an order for just a few seconds a red screen apears but i hadn't time to do an screenshot.
then I canceled it

Also when try to take a new order and then go back to order book
image

Another exception was thrown: ProviderException: Tried to use a provider that is in error state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants