Stream Allocation is a core component of the Towns Protocol, providing a robust and efficient mechanism for managing streams. This document outlines the key principles and processes that govern stream allocation within the Towns ecosystem.
Base Mainnet Authority: Base Mainnet is the authoritative layer for channels and spaces.
Towns Chain Authority: The Stream Registry on the Towns Chain serves as the authority for the allocation of other streams.
User Stream Creation and Verification
User Stream Inception: User streams are initiated with a verifiable signature from the user. This ensures that each stream is securely linked to the initiating user.
Channel Stream Inception: Channel streams are initiated by a client but verified by the existence of the channel already having been created on Base in the Space contract.
Signature Requirement: A verifiable signature from the user is mandatory to create a direct message (DM) stream for them.
Stream Allocation Process
Deterministic Allocation: Stream allocation is deterministic, based on the Towns Chain block number, randomness, and the list of active nodes.
Replication Standard: Streams are replicated to the default protocol replication setting of 5. This ensures redundancy and reliability in stream data.
Workload Equality Among Nodes
Equal Work Distribution: Over time, each node is expected to perform roughly the same total amount of work, despite operating on different individual streams.
Adaptive Workload: The system adjusts the allocation of streams to maintain workload equality among nodes.
Stream Rebalancing
Rebalancing on Node Joining/Leaving: Streams are rebalanced when nodes join or leave the network.
Adding New Nodes: Some stream replicas are added to new nodes to ensure they become equal participants in the system.
Handling Node Departure: Similarly, stream replicas are adjusted when nodes leave to maintain the balance and integrity of the system.