Reduce Generic Parameter Proliferation with `dyn` Trait Objects
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 22/100
- Type d'issue
- Refactorisation
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- rust
- Domaine
- backend, networking, payments
Piste de recherche
This is a design-level change to core LDK types (ChannelManager, OnionMessenger, PeerManager) rather than a first-timer edit. Start from how those types are parameterized and from existing DynSigner usage as the stated precedent. The issue names object-safe candidates (BroadcasterInterface, FeeEstimator, Logger, EntropySource) versus traits that are not yet object-safe (Watch, SignerProvider, Router). Done means fewer type parameters on ChannelManager with no measurable hot-path change; expect many impls and downstream consumers to move together.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Core types have excessive generic parameters that harm maintainability:
ChannelManager- 10 type parametersOnionMessenger- 9 type parametersPeerManager- 8 type parameters
This makes certain refactors nearly impossible. Adding a new dependency to ChannelManager means threading a new generic through dozens of impl blocks, all their where clauses, and every downstream consumer. The friction discourages improvements that would otherwise be straightforward.
Performance concerns are overstated
The traits behind these parameters do I/O, networking, disk access, and cryptographic operations - all measured in microseconds to milliseconds. A vtable call costs ~1 nanosecond. The overhead is unmeasurable noise.
There are no hot paths here. Lightning nodes are I/O-bound, not CPU-bound. No one has ever profiled LDK and found vtable dispatch as a bottleneck - because it isn't one.
Precedent
DynSigner already exists in the codebase and demonstrates that dynamic dispatch works fine for signing operations - one of the more performance-sensitive areas.
Proposal
Start with ChannelManager and convert object-safe traits to dyn. Candidates:
BroadcasterInterfaceFeeEstimatorLoggerEntropySource
Traits with associated types (Watch, SignerProvider) or generic methods (Router) would need more work to become object-safe.
Expected outcome
Significantly reduce ChannelManager's type parameter count. Make future refactors tractable. No measurable performance change.
(co-authored by Claude)
- Langage dominant
- Rust
- Étoiles
- 1.4k
- Forks
- 482
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de lightningdevkit/rust-lightning
-
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
lightningdevkit/rust-lightning#4767 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
lightningdevkit/rust-lightning#1849 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 22/100
lightningdevkit/rust-lightning#4764 · 3 commentaires ·
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 22/100
lightningdevkit/rust-lightning#4757 · 1 commentaire ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 28/100
lightningdevkit/rust-lightning#4739 ·
Toutes les issues de lightningdevkit/rust-lightning
Issues similaires
-
bug help wanted ui
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
userFRM/egui-charts#4292 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 83/100
Tripstack-Corp/spyc#1352 ·
Les mainteneurs répondent en général sous 1 jour
-
marketing
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
area:tui enhancement P2
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
agent-of-empires/agent-of-empires#6077 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour