Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e7f1ef9
fix: public some ultilities
iamquang95 Jun 17, 2026
a383698
feat(core): implement prioritisier
iamquang95 Jun 17, 2026
df1fb27
fix: machete
iamquang95 Jun 17, 2026
4d049e6
fix: don't panic when duplicated duty
iamquang95 Jun 18, 2026
bded871
fix: don't flatten Deadline Error
iamquang95 Jun 18, 2026
333c3db
fix: derive local_id from priv key
iamquang95 Jun 18, 2026
750d779
fix: protocol_id start with slash
iamquang95 Jun 18, 2026
bdbdf95
fix: surface deadline compute failed error
iamquang95 Jun 18, 2026
6aedb6c
Merge remote-tracking branch 'origin/main' into feat/core-priority
iamquang95 Jun 18, 2026
d2123cc
fix: using HashSet to simplify code
iamquang95 Jun 18, 2026
ae5b3c6
fix: add debug on unexpected error
iamquang95 Jun 18, 2026
e1189dd
fix: protocol_id not start with slash
iamquang95 Jun 18, 2026
587e53d
fix: priority test
iamquang95 Jun 19, 2026
8de6e9e
fix: use p2p_context
iamquang95 Jun 21, 2026
969a105
Merge remote-tracking branch 'origin/main' into feat/core-priority
iamquang95 Jun 21, 2026
07530ca
ci: check multistream-select use local version
iamquang95 Jun 23, 2026
f770cea
refactor: implement From topic proposal
iamquang95 Jun 23, 2026
4ae83d6
refactor: rename ctx -> ct
iamquang95 Jun 23, 2026
8247be1
refactor: fix error cancel log
iamquang95 Jun 23, 2026
b319b64
fix: take first message
iamquang95 Jun 23, 2026
1b5f06f
fix: add HashRoot type
iamquang95 Jun 23, 2026
3ce672a
refactor: prioritiser
iamquang95 Jun 23, 2026
9c62e7d
refactor: make start can only called once
iamquang95 Jun 23, 2026
d2e089a
fix: upgrade quinn-proto
iamquang95 Jun 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,19 @@ jobs:
- name: Build (all features)
run: cargo test --locked --workspace --all-features --no-run

# Slash-less `charon/priority/2.0.0` Charon interop relies on the vendored
# multistream-select fork ([patch.crates-io] -> third_party/). If a libp2p
# bump moves the required version off the fork's, cargo only warns and
# silently falls back to the registry copy, regressing interop. Fail loudly
# instead: assert no registry-sourced multistream-select is in the graph.
- name: Verify multistream-select fork patch is applied
run: |
if ! cargo metadata --locked --format-version 1 \
| jq -e '[.packages[] | select(.name == "multistream-select" and .source != null)] | length == 0' > /dev/null; then
echo "::error::multistream-select fork patch not applied — a registry copy is in the dependency graph (likely a libp2p bump). Re-vendor third_party/multistream-select to the matching version (see its PATCHES.md)."
exit 1
fi
echo "multistream-select fork patch applied ✓"

- name: Run tests (all features)
run: cargo test --locked --workspace --all-features
44 changes: 35 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ members = [
"crates/tracing",
"crates/peerinfo",
"crates/frost",
"crates/priority",
]
# Vendored fork consumed only via [patch.crates-io]; excluded so it builds/tests
# standalone (its upstream code isn't written to this workspace's lints) without
# cargo treating it as a member.
exclude = ["third_party/multistream-select"]
resolver = "3"

[workspace.package]
Expand Down Expand Up @@ -162,3 +167,10 @@ opt-level = 3

[profile.test.package.aes]
opt-level = 3

# Forked multistream-select that accepts slash-less protocol names, required for
# the priority protocol to interoperate with Charon's "charon/priority/2.0.0"
# (no leading slash). Upstream rejects such names; the only delta is relaxing
# that check. See third_party/multistream-select/PATCHES.md.
[patch.crates-io]
multistream-select = { path = "third_party/multistream-select" }
4 changes: 2 additions & 2 deletions crates/consensus/src/qbft/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ impl SomeMsg<ConsensusQbftTypes> for Msg {
/// The hash input is deterministic protobuf encoding, then SSZ `PutBytes`
/// merkleization. `Any` is rejected because the consensus value hash must bind
/// to the inner message bytes, not the transport envelope.
pub(crate) fn hash_proto<M>(msg: &M) -> Result<[u8; 32]>
pub fn hash_proto<M>(msg: &M) -> Result<[u8; 32]>
where
M: prost::Message + prost::Name,
{
Expand All @@ -288,7 +288,7 @@ where
/// This helper hashes the bytes exactly as provided; it does not decode or
/// canonicalize a protobuf envelope. Callers must pass bytes produced from the
/// concrete inner message with deterministic field/map ordering.
pub(crate) fn hash_proto_bytes(encoded: &[u8]) -> Result<[u8; 32]> {
pub fn hash_proto_bytes(encoded: &[u8]) -> Result<[u8; 32]> {
let mut hasher = Hasher::default();
let index = hasher.index();
hasher.put_bytes(encoded).map_err(Error::HashProto)?;
Expand Down
10 changes: 10 additions & 0 deletions crates/core/src/deadline/calculator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Deadline calculator trait and beacon-node-derived implementation.

use std::sync::Arc;

use chrono::{DateTime, Duration, Utc};
use pluto_eth2api::EthBeaconNodeApiClient;

Expand Down Expand Up @@ -86,6 +88,14 @@ pub trait DeadlineCalculator: Send + Sync + 'static {
fn deadline(&self, duty: &Duty) -> Result<Option<DateTime<Utc>>>;
}

/// Lets a shared (`Arc`-wrapped) calculator satisfy the trait, so a single
/// calculator instance can back both a deadliner task and other consumers.
impl<T: DeadlineCalculator + ?Sized> DeadlineCalculator for Arc<T> {
fn deadline(&self, duty: &Duty) -> Result<Option<DateTime<Utc>>> {
(**self).deadline(duty)
}
}

/// Calculator that reports every duty as never expiring. Useful for
/// scenarios that need to plug into the deadliner API but don't actually want
/// any eviction (e.g. DKG, which is one-shot and outside the slot timeline).
Expand Down
2 changes: 1 addition & 1 deletion crates/p2p/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ pub(crate) fn default_swarm_config(cfg: libp2p::swarm::Config) -> libp2p::swarm:
}

/// Converts a secret key to a libp2p keypair.
pub(crate) fn keypair_from_secret_key(key: k256::SecretKey) -> crate::p2p::Result<Keypair> {
pub fn keypair_from_secret_key(key: k256::SecretKey) -> crate::p2p::Result<Keypair> {
let mut der = key.to_sec1_der()?;
let keypair = Keypair::secp256k1_from_der(&mut der)?;
Ok(keypair)
Expand Down
39 changes: 39 additions & 0 deletions crates/priority/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "pluto-priority"
version.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true
publish.workspace = true

[dependencies]
async-trait.workspace = true
chrono.workspace = true
either.workspace = true
futures.workspace = true
k256.workspace = true
libp2p.workspace = true
pluto-consensus.workspace = true
pluto-core.workspace = true
pluto-k1util.workspace = true
pluto-p2p.workspace = true
pluto-ssz.workspace = true
prost.workspace = true
prost-types.workspace = true
thiserror.workspace = true
tokio.workspace = true
tokio-util.workspace = true
tracing.workspace = true

[dev-dependencies]
pluto-testutil.workspace = true
rand.workspace = true
test-case.workspace = true
tokio = { workspace = true, features = ["test-util", "rt-multi-thread", "macros", "net", "time", "io-util"] }
# Interop proof: drive the patched multistream-select negotiation over real TCP.
multistream-select = "0.13"
tokio-util = { workspace = true, features = ["compat"] }
futures.workspace = true

[lints]
workspace = true
Loading
Loading