Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Rewrite `core/qbft` to async-Rust-friendly API

Đang mở
#393 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
rust
Lĩnh vực
distributed-systems

Hướng nghiên cứu

Bắt đầu với crates/core/src/qbft/mod.rs và internal_test.rs của nó, sau đó so sánh với bản tham chiếu Go và strategysim_internal_test.go. Chạy các test QBFT hiện có trước khi thay đổi mô hình đồng thời. Công việc được xem là hoàn tất khi có API công khai bất đồng bộ, các test bất đồng bộ tương đương bao gồm tính tương đương với strategysim, clippy và định dạng sạch, cùng với các mục công khai được ghi tài liệu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement rust track:duty-pipeline

Context

The current Rust port of core/qbft (crates/core/src/qbft/mod.rs) is a faithful translation of the Go reference but built on synchronous, thread-based primitives:

  • crossbeam::channel for transport
  • std::thread::scope for spawning per-process workers
  • A blocking pub fn run(...) entry point
  • cancellation::CancellationToken (third-party crate, not tokio_util)

This is at odds with the rest of Pluto, which is tokio-async end to end. Every consumer that will eventually wire QBFT in (core/consensus, core/scheduler, the duty pipeline) is async. The current shape forces either (a) bridging via spawn_blocking and ad-hoc channel adapters, or (b) blocking inside async tasks — both bad.

Closes the gap left by #13, which produced the initial sync port.

Goal

Rewrite core/qbft with an async-Rust-native API that integrates cleanly with the rest of the workspace and preserves the Byzantine-safety guarantees of the Go reference.

Scope

API
  • run becomes pub async fn run(...) -> Result<Decision, QbftError>
  • Transport trait methods return impl Future<Output = Result<...>> + Send (or are async fn via trait async)
  • Cancellation uses tokio_util::sync::CancellationToken (already used elsewhere in Pluto)
  • Channels: tokio::sync::mpsc (and oneshot where appropriate)
  • No std::thread, no crossbeam, no std::sync::mpsc anywhere in the public or internal API
Internals
  • Replace thread::scope with tokio::spawn + JoinSet (or select! for per-instance loops)
  • Replace blocking sleeps/timers with tokio::time::sleep / Interval
  • Clock abstraction (fake_clock.rs) becomes async-aware so deterministic tests still work — likely using tokio::time::pause() + advance() rather than the current fake clock
  • Keep the algorithm shape (rounds, justifications, message bookkeeping) bit-for-bit identical to the Go reference — only the concurrency primitives change
Safety net (mandatory)
  • Port charon/core/consensus/qbft/strategysim_internal_test.go (~1040 LOC) as the parity gate. This is the test that catches BFT correctness regressions; without it we cannot trust the rewrite.
  • All current crates/core/src/qbft/internal_test.rs cases pass (or are replaced by equivalent async versions)

Acceptance criteria

  • Public API is fully async; no pub fn run blocking entry point remains
  • No crossbeam, std::thread, or third-party cancellation crate usage in crates/core/src/qbft/
  • All existing QBFT unit tests pass (rewritten as async where needed)
  • Strategysim parity test ported from Go and green
  • cargo clippy --workspace --all-targets --all-features -- -D warnings clean
  • cargo +nightly fmt --all --check clean
  • Public API documented; missing_docs warning re-enabled for the module

References

Notes

This is on the critical path for the duty-flow pipeline. core/consensus (#157) and downstream modules (core/scheduler #176, etc.) will consume the new async API directly, so this should land before consensus framework integration begins.

Ngôn ngữ chính
Rust
Star
8
Fork
5
Merge trung bình
3 ngày 1 giờ
Pull request đã merge (30 ngày)
2

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NethermindEth/pluto

Tất cả issue của NethermindEth/pluto

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.