Managing Transient State with Waku Relay's Stateless Forwarding
Explore how Waku Relay uses stateless forwarding and TTL mechanisms to enable low-latency decentralized messaging without the overhead of local storage.
16 Apr 2026, 02:20 UTC

The Challenge of Real-Time Decentralized Messaging
Building a decentralized pub/sub system often forces a choice: store every message for guaranteed delivery or accept loss for speed. For real-time chat, live telemetry, or signaling, storing transient packets on every relay node creates unsustainable storage and latency.
The takeaway is that Waku Relay solves this with a stateless forwarding mechanism. It treats the network as a pipe, prioritizing low-latency propagation over guaranteed delivery. If you need instant message movement across a peer‑to‑peer network without relays keeping massive archives, this is the primary tool.
How Stateless Forwarding Works
Waku Relay runs inside libp2p, using a topic‑based subscription model. A topic is an arbitrary string that names a channel. Nodes tell peers which topics they subscribe to.
Unlike a broker that queues messages for offline clients, a Waku Relay node does not store messages. When a message arrives, the relay checks the topic and forwards it to all peers subscribed to that topic. To stop infinite loops, Waku uses:
- Unique Message IDs: Each message carries a unique ID. If a relay sees an ID it already processed, it drops the packet.
- Time‑To‑Live (TTL): A TTL field works as a hop counter. Each relay decrements TTL; when it reaches zero the message is discarded, bounding traffic.
Implementing a Basic Relay Subscription
Add the waku-relay protocol to your libp2p node. The protocol uses a JSON‑oriented message format. Example code:
// Example: libp2p node with Waku Relay
const topic = 'sensor-data';
const msg = {
id: 'msg-001',
topic: topic,
payload: 'temp 22°C',
ttl: 4
};
// init libp2p with waku-relay (omitted)
await node.wakuRelay.subscribe(topic);
await node.wakuRelay.publish(msg);
node.wakuRelay.onMessage((m) => {
console.log('Received on ' + m.topic + ': ' + m.payload);
});
Note: Set TTL based on desired hop count; too high increases congestion, too low limits reach.
The Trade‑off: Speed vs. Reliability
Stateless forwarding moves complexity to the application layer.
| Aspect | Waku Relay | App‑Layer Need |
|---|---|---|
| Persistence | No local storage on relays | Use an external archival node for history |
| Authentication | Neutral forwarding (no built‑in auth) | Sign payloads and verify signatures |
| Ordering | No delivery/order guarantees | Include sequence numbers or timestamps |
Because relays do not authenticate senders, the network is open to spam or flooding. Mitigate by verifying application‑level signatures before processing any message.
Verifying Propagation
Run a hop test: three nodes A‑B‑C, A↔B, B↔C, no A‑C link. Publish from A with TTL=2; C should get it. With TTL=1, C should not. This confirms TTL limits propagation.
Closing Action
If your app needs instant, transient messaging and you can handle security at the application layer, Waku Relay is a good fit. Define your topics and pick a TTL that balances reach against network load.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.