TEP-3: Unchained Messaging Protocol

This TEP was authored by Pouya Eghbali <pouya@timeleap.swiss> on 2025-02-03.
ℹ️
Review
This TEP is currently under review.

Abstract

This document describes the Unchained Messaging Protocol (UMP), a protocol for sharing data and state between nodes on the Unchained network. UMP enables nodes to subscribe to topics and receive messages from other nodes, allowing them to share data and state with each other.

Motivation

Unchained is a federated network where each node has a specific role. Instead of using peer-to-peer messaging, Unchained employs a broker system to route messages between nodes. This means that, rather than having each node forward messages for all other nodes, the broker takes on this responsibility.

While this feature enhances network scalability, it introduces a new challenge: nodes on the network lack access to all data, making state sharing cumbersome. To address this, we propose the Unchained Messaging Protocol (UMP) to enable nodes to efficiently share data and state with each other.

Specification

This section provides a detailed specification of the Unchained Messaging Protocol (UMP), outlining its high-level design and user story.

Broker-based

Since the broker is responsible for routing messages between nodes, and is the connection point for all nodes, it is the ideal place to implement the UMP. The broker can act as a message hub, allowing nodes to share data and state with each other.

In case of multiple brokers, they each can subscribe to the same topic and forward messages to each other. This way, the network can be scaled horizontally by adding more brokers.

Topics

Topics are the primary way to categorize messages in UMP. Each message is published to a specific topic, and nodes can subscribe to topics to receive messages. Topics can be used to share data, state, or events between nodes.

Topics are scoped and workers can use wildcards to subscribe to multiple topics at once. For example, a worker can subscribe to `system.user.*` to receive messages related to all users or `system.*` to receive all system messages.

Plugins can define their own topics to share data and state with other nodes. For example, a chat plugin by developer 'alice' can define topics such as 'tld.alice.chat.message', 'tld.alice.chat.user', and 'tld.alice.chat.room' to share messages, users, and rooms.

Dataframes

Dataframes are the primary data structure used in UMP to share data and state between nodes. A dataframe has the following structure:

The 'Hash' field is a unique identifier for the dataframe, generated by the publisher. The 'Timestamp' field is the time the dataframe was created. The 'Topic' field is the topic the dataframe belongs to. The 'Meta' field stores additional metadata about the dataframe in Sia format.

Developers should use the 'Topic' field to determine the type of data in the dataframe. For example, a dataframe with the topic 'tld.alice.chat.message' contains a chat message, and the 'Meta' field contains the message content.

Rationale

UMP is designed to enable nodes to share data and state with each other in a scalable and efficient manner. By using brokers as message hubs, UMP allows nodes to subscribe to topics and receive messages from other nodes. This enables nodes to share data and state with each other, making it easier to build distributed applications on the Unchained network.

This is an essential requirement to build a decentralized consenus for the Unchained network. For example, for every RPC call from a client, the broker can publish information about the call to all nodes, where each node updates the balances of the sender and receiver. Since each message contains the signature of the sender, nodes can verify the authenticity of the message and update the balances accordingly.

Backwards Compatibility

The Unchained Messaging Protocol (UMP) has been implemented in the Unchained network. This document serves as the formal specification to ensure compatibility across all nodes. The already implemented UMP will be updated to comply with this specification.

Reference Implementation

N/A

References

N/A

How was this page?

Timeleap SA.

Pl. de l'Industrie 2, 1180 Rolle, Switzerland

Logo

Social Media

Tokenomics

Info