If you breathe like a client and act like a client, then you're probably a client.
Afferent is a p2p instrumentation framework for analyzing live networking activity within Ethereum's consensus layer. Afferent works by embedding a fully functional Ethereum consensus client (Prysm), and weaving in instrumentation in strategic places to capture precise datapoints in minimally invasive ways. Probes leverage Prysm's machinery to offer external behaviour that's identical to any other Ethereum client. Compared to building standalone tools, this approach yields more realistic and representative measurements, enables reliable continuous long-lived captures, and reduces the effort required to develop robust tools.
Why "Afferent"?
Afferent authors are fascinated by biology and neuroscience. Afferent neurons carry sensory information from peripheral parts of the body towards the central nervous system (in a centripetal direction). They are also responsible for our sense of _interoception_: they monitor the internal state of the body by watching vitals like heart rate, blood pressure, gas levels, glucose levels, etc. This information travels along the vagus nerve and various sympathetic and parasympathetic pathways, where it is partially processed before it reaches the CNS for full integration and reaction.- Basic gossipsub Tracing: JSON-based event tracing for libp2p pubsub interactions, capturing detailed protocol behavior and message flow.
- 🚧 Enhanced gossipsub analysis: Capture local mesh snapshots, peer scoring dynamics, and structured events for improved analysis.
- 🚧 Granular network I/O attribution: Categorize traffic by protocol context and purpose, distinguishing activity by topic and action type.
- 🚧 Wire-level propagation metrics: Measure attestation, block, and blob propagation in real-time, capturing latency and network bottlenecks.
- 🚧 Multi-head gossipsub: Spawn multiple network identities to build evolving models of network topology and characteristics.
- 🚧 DAS guardian integration: Monitor node compliance with data availability custody requirements.
- 🚧 Continuous crawler: Run sophisticated analysis including underlay metrics and status response recording.
afferent/
├── cmd/afferent/ # Main application entrypoint
├── probes/ # Modular instrumentation components
│ └── gossipsub/ # Gossipsub instrumentation
├── ext/ # External dependencies (git submodules)
│ ├── go-libp2p/ # Core p2p networking library
│ ├── go-libp2p-pubsub/ # Pubsub protocol implementation
│ └── prysm/ # Prysm (Ethereum consensus client)
│ └── x/ # Prysm extensions for instrumentation
└── out/ # Build artifacts and trace outputs
Afferent maintains a minimally-invasive approach to instrumentation. When adding new capabilities:
- Implement probes as modular components in the
probes/directory. - Use interceptor patterns to inject instrumentation.
- Minimize modifications to upstream dependencies.
- Document output formats and analysis methods.