Refuse a node that advertises an unknown protocol_version

Open
#200 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
cli

Research direction

Start in resolve_transport in src/cli.rs, at the match arm that logs the unknown protocol_version and falls back to gift wrap. Then read fetch_protocol_version_with to see where a missing tag and an unparseable tag both become None. Done when an unknown version returns a clear error unless --transport was passed, a "1" maps to gift wrap, a "2" maps to NIP-44 direct, and an unparseable tag is treated as unknown rather than v1, with tests for each case.

Written by the indexing model from the issue text.

Description

Problem

resolve_transport (src/cli.rs) falls back to gift wrap when the node advertises a protocol_version the CLI does not know:

Some(other) => {
    log::warn!("Node advertised unknown protocol_version={other}; defaulting to gift-wrap")
}

Protocols v1 and v2 are incompatible, and a node gives no error for a message in the wrong format. A node that advertises a future "3" would receive gift wraps it never reads, and the command would just time out.

Expected

The client rule is now in the protocol docs (MostroP2P/protocol#70, "Future protocol versions") and the daemon spec (MostroP2P/mostro#1003, §8):

  • Unknown protocol_version → fail with a clear error ("this node speaks protocol vN, which this mostro-cli version does not support"), unless the user passed --transport explicitly.
  • 1 → gift wrap, while the CLI still supports v1.
  • 2 → NIP-44 direct.
  • No tag, or no info event → a daemon older than v0.18.0 speaking v1 (current behavior, correct).

fetch_protocol_version_with currently folds "tag present but unparseable" into None together with "no tag". An unparseable value should count as unknown, not as v1.

Why now

mostrod v0.19.0 removes protocol v1 (MostroP2P/mostro#786) and keeps the versioning mechanism for a future v3. The CLI needs this rule before it drops its v1 code.

Dominant language
Rust
Stars
39
Forks
16
Avg merge
6h
Merged PRs (30d)
50

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from MostroP2P/mostro-cli

All issues in MostroP2P/mostro-cli

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.