Reduce Generic Parameter Proliferation with `dyn` Trait Objects
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 22/100
- Tipo de issue
- Refactorización
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- rust
- Área
- backend, networking, payments
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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)
- Lenguaje dominante
- Rust
- Estrellas
- 1.4k
- Forks
- 482
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de lightningdevkit/rust-lightning
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
lightningdevkit/rust-lightning#4767 ·
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
lightningdevkit/rust-lightning#1849 ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 22/100
lightningdevkit/rust-lightning#4764 · 3 comentarios ·
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 22/100
lightningdevkit/rust-lightning#4757 · 1 comentario ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 28/100
lightningdevkit/rust-lightning#4739 ·
Todos los issues de lightningdevkit/rust-lightning
Issues similares
-
bug help wanted ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
userFRM/egui-charts#4292 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
Tripstack-Corp/spyc#1352 ·
Los mantenedores suelen responder en 1 día
-
marketing
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
area:tui enhancement P2
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
agent-of-empires/agent-of-empires#6077 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día