Converge the coexisting subscription mechanisms

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

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
冷清
技术栈
rust

调研方向

首先比较 crates/core/src/scheduler.rs、crates/app/src/sse/mod.rs、crates/core/src/sigagg.rs 和 app/node/wire.rs 中命名的订阅实现,以 Charon 的 wireX 语义作为对等性参考。定义规范的订阅形态以及生命周期、丢弃、延迟、错误和取消订阅规则,然后迁移不一致的实现,并验证整个 workspace 中记录的语义保持一致。

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

描述

enhancement rust

Summary

The workspace has six mutually incompatible subscription patterns, with divergent semantics for lifetime, drop, lagging, and error propagation:

  1. tokio broadcast + spawned pump — only in the scheduler (the sole broadcast use in the workspace).
  2. Vec<mpsc::Sender<T>> fan-out — SSE listener, with both a builder-time and an actor-round-trip runtime subscribe (sse/mod.rs#L68).
  3. watch::Receiver-returning subscribe() — p2p peers, dkg sync, readiness.
  4. Sync Box<dyn Fn> callback vectors — consensus wrapper/qbft/priority; the prioritiser's is documented "Not thread safe relative to a running instance".
  5. Arc<dyn Fn> -> BoxFuture callback vectors — sigagg, parsigdb, fetcher (a consuming-builder variant), bcast, parsigex, validatorapi. Five different receiver forms (&self, &mut self, async &self, self -> Self, interior Mutex).
  6. Charon-style function-pointer wiring in app/node/wire.rs.

Semantics diverge where it matters:

  • Lagged is handled only in the scheduler, by silently and permanently unsubscribing the lagging subscriber; Closed also breaks silently.
  • Subscriber errors: scheduler logs and continues; sigagg propagates with ?, so one failing subscriber aborts the remaining ones (same in parsigdb) — this asymmetry is load-bearing for duty completion.
  • No subscribe() anywhere returns an unsubscribe handle (scheduler TODO), and the scheduler documents a known leak of detached tasks for stuck handlers.

Related: #84 (make sub calling non-blocking).

Proposed change

This is a design task first: pick one or two blessed shapes (e.g. broadcast/watch channels for events, an async-callback registry with defined error semantics for duty pipeline stages), and document lifetime/drop/lag/error rules. Then migrate the outliers. Concrete decisions to make:

  • Should a subscriber error abort sibling subscribers (current sigagg/parsigdb) or be isolated (current scheduler)? Charon's wireX semantics are the parity reference.
  • What happens on lag: drop events, kill the subscription (current), or apply backpressure?
  • Unsubscribe/drop story: handles vs relying on channel closure.
主要语言
Rust
星标
8
派生
5
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

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

NethermindEth/pluto 的其他 Issue

查看 NethermindEth/pluto 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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