Add a JSON node status command that reads a node's health event

未关闭
#271 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@victrvondoom 已经在做这个了。

开始于 2026年11月19日。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
rust
领域
cli, networking

调研方向

Start with mostro-cli --output json schema to see how existing commands are listed, then read the health event protocol page linked in the issue for the reader rules. Add a node status command that queries the configured relays for kind 38389 and 38385, validates the events, and reports the state. Done when each reader rule has a unit test and docs/commands.md documents the output.

由索引模型根据 Issue 内容生成。

描述

enhancement status: accepted

Problem

There is no way to ask mostro-cli whether a Mostro node can do its job right now. mostrod publishes a signed health event (kind 38389, protocol: Health event) every minute, and Semáforo (MostroP2P/semaforo) reads it in the browser. Neither the health event nor the info event (kind 38385) is reachable from the CLI: mostro-cli --output json schema at 0.17.1 lists no command that reads either.

This blocks clients that drive the CLI. MostroP2P/mcp#11 adds a catalog of the trusted nodes listed at mostro.community and lets the user pick one. An agent helping the user choose should be able to say "Argentina is reporting down since 14:10" instead of sending the user to a node that cannot pay out. mostro-mcp does not speak Nostr and must not start: anything it needs from the relays is a mostro-cli command first.

Proposal

A read-only command, mostro-cli node status (contract name node.status), with --output json support.

  • Input. One or more node public keys (--node=<hex|npub>, repeatable). With none, the configured MOSTRO_PUBKEY. Relays come from the usual configuration (RELAYS), with an optional --relays= override, so a client can check every node of a catalog in one run without changing its configured node.
  • No identity needed. The command reads public events only. It needs no mnemonic, no trade key and no local database, and never sends anything to a node.
  • Reading the health event follows the protocol's What a reader owes as a stateless reader:
    1. verify the signature, pubkey, kind = 38389, z = health, d = pubkey, and every required tag (interval within 30–3600, expiration = created_at + 3 × interval, no repeated tags or check names);
    2. query every configured relay and keep the valid event with the highest seq;
    3. ignore an event more than 300 seconds in the future;
    4. report the state as unknown when no valid event was found, when it has expired, or when it is older than 3 × interval. Absence is never ok.
  • Reading the info event (kind 38385): the instance name, mostro_version, escrow_mode, the fiat currencies, limits and fee it advertises, so a client can show what the node trades.
Output (one document, data.nodes[], one entry per requested key)
Field Meaning
pubkey the node, lowercase hex
name from the info event, or null
state ok, degraded, down (the event's status) or unknown (no valid fresh event)
unknown_reason when state is unknown: not_found, expired, stale or invalid; otherwise null
maintenance_mode as reported
checks [{name, state, since}], unknown names passed through, unknown states as unknown
escrow_mode, lnd_network, lnd_block_height, lnd_synced_to_chain as reported; null when omitted
mostro_version, interval, seq, created_at, expiration, event_id from the event used
relays_answered which relays answered the query, so "not found" can be told from "no relay answered"
independently_verified always false in this version (see below)
info the info event fields above, or null

When no relay answers, the document is an error with a code a client can tell apart from "the node published nothing".

Not in this issue
  • The independent block-height cross-check. The protocol says watchers SHOULD compare lnd_block_height with a block explorer or the median of trusted instances, and Semáforo does. Querying block explorers would add HTTP calls to third parties to a CLI that only talks to relays. This version reports what the node says about itself, marks it independently_verified: false, and leaves the cross-check to a follow-up (a median over the requested nodes that share an lnd_network would need no explorer).
  • Watcher heartbeats published under the same kind.
  • History or uptime. That is Semáforo's sampler; this command is a point-in-time read.

Acceptance criteria

  • node status is listed by mostro-cli --output json schema with its input and output schemas, as a command that needs no identity.
  • Each reader rule above has a unit test: bad signature, wrong d, missing required tag, repeated tag, repeated check name, interval out of range, wrong expiration, future created_at, expired, stale, and highest seq across relays.
  • A missing, expired, stale or invalid event yields state: unknown with the matching unknown_reason, never ok.
  • Several --node values are answered in one run, one entry each, in the order given.
  • No relay answering is an error outcome distinct from an empty result.
  • Verified against the scripted relay or the regtest node (mostrod publishes the health event from v0.19.x), with the result recorded in the spec's tasks.
  • docs/commands.md and the mostro-cli book document the command and its output.
主要语言
Rust
星标
39
派生
16
平均合并
6 小时
30 天内合并 PR
50

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

MostroP2P/mostro-cli 的其他 Issue

查看 MostroP2P/mostro-cli 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。