bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 17쪽 중 13쪽
built for broad chat application use cases with business logic for chat but in the future the protocol will be abstracted to form a base layer for any form of encrypted message passing use cases.
## Key Features
### Encrypted Communication
* **End-to-End Encryption**: Utilizing state-of-the-art encryption methodologies, the Towns Messaging Protocol ensures that all communications are secure from end to end. No one besides the sending and entitled users, including Towns Node Operators, are able to decrypt and read any messages in the Towns ecosystem.
* **Privacy by Design**: Emphasizing user privacy, the protocol guarantees that message contents remain inaccessible to anyone other than the intended recipients.
### Decentralization
* **Distributed Network**: The protocol operates on a network of distributed nodes, ensuring reliability and resilience against central points of failure.
* **User Autonomy**: Spaces within the protocol are user governed, fostering a community-driven environment where users have control over their communication channels.
### Scalability and Efficiency
* **Scalable Architecture**: Designed to handle high volumes of messages without compromising speed or security.
* **Resource Optimization**: Efficient use of network resources ensures that the protocol remains sustainable and cost-effective.
## Components
### Towns Chain
* A Layer 2 blockchain solution that acts as the backbone of the Towns Messaging Protocol, providing consensus and security.
### Stream Nodes
* Nodes responsible for managing the flow of messages within the protocol, handling tasks such as message validation, storage, and encryption.
### Entitlement Management
* Systems to manage user permissions and access within Spaces, ensuring a secure and organized communication environment.
# Event Lifecycle
Source: https://docs.towns.com/towns-messaging-protocol/stream-nodes/event-lifecycle
# User Event Lifecycle
This section outlines the lifecycle of a user event within the protocol. Each step is crucial in ensuring a seamless and secure transmission of data.
1. **Initiation of Event**: The lifecycle of an event initiates with a user action. e.g. sending a message, joining a channel, etc.
2. **Payload Construction**: Following the user action, a payload is constructed that describes the desired action. For specific payload types, such as messages, encryption is applied.
3. **Reference to Previous Mini Block Hash**: Each payload includes a reference to the hash of the preceding mini block, establishing a link in the chain of events.
4. **Signing the Event**: The user signs the payload, thereby converting it into an event. This step is crucial for validating the authenticity of the event.
5. **Transmission via RPC**: The event is then transmitted to a client-connected node using Remote Procedure Call (RPC) protocols.
6. **Routing Event Based on StreamId**: Upon receipt, the node routes the event to a responsible node. This is determined through a Stream Registry lookup of the specific StreamID associated with the event.
7. **Validation by Responsible Node**: The responsible node performs several checks: it validates the event signature, verifies entitlements, and conducts other consistency checks, including verifying the reference to the recent mini block hash, as dictated by the protocol settings.
8. **Propagation or Rejection**: If the event passes all checks, the responsible node propagates it to other nodes associated with the same StreamId. If the event fails any check, it is rejected.
9. **Reception and Verification by Other Nodes**: Other nodes receiving the propagated event repeat the validation checks. Future updates may allow for the postponement of these checks when a validation gadget is active.
10. **Local Commitment and Mini-Pool Placement**: Each node commits the event to its local storage and places it in the mini-pool data structure for the respective stream. The order of events in mini pools may vary across responsible nodes, with reconciliation occurring at the time of mini block creation.
11. **Mini Block Creation**: In sync with the river chain block time, open mini pools are visited to produce a mini block. This process is integral to maintaining the continuity
# Overview
Source: https://docs.towns.com/towns-messaging-protocol/stream-nodes/overview
## Introduction
Stream Nodes are a crucial component of the Towns Messaging Protocol, acting as the backbone of its decentralized messaging system. This overview provides insights into the functionalities, responsibilities, and importance of Stream Nodes within the protocol.
## Key Functionalities of Stream Nodes
Stream Nodes perform several vital functions in the Towns Messaging Protocol:
### Message Processing
* **Acceptance and Validation**: Stream Nodes are responsible for accepting encrypted messages from users, validating them against established protocol rules.
* **Storage and Management**: They manage the storage of messages, ensuring their availability and integrity.
### Mini-Block Creation
* **Mini-Block Assembly**: Stream Nodes play a key role in creating mini-blocks, which are collections of messages or events linked together.
* **Consensus Participation**: They participate in the consensus process to agree on the contents of each mini-block.
### Network Synchronization
* **Stream Management**: Stream Nodes manage chunks of streams, ensuring that messages are properly sequenced and distributed.
* **Node Collaboration**: They collaborate with other Stream Nodes to maintain the consistency and continuity of message streams.
## Integration with Towns Chain
Stream Nodes are intricately connected to the Towns Chain, enhancing the protocol's functionality:
* **Chain Interaction**: They interact with the Towns Chain for various operations, including node registration and mini-block hash commitments.
* **Decentralized Architecture**: As part of the decentralized infrastructure, Stream Nodes contribute to the robustness and security of the Towns Messaging Protocol.
# Stream Allocation
Source: https://docs.towns.com/towns-messaging-protocol/stream-nodes/stream-allocation
# Stream Allocation on Towns Protocol
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.
## Principles of Stream Allocation
1. **Base Mainnet and Towns Chain Authority**
* **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.
2. **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.
3. **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.
4. **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.
5. **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.
## Implementation Guidelines
* **Ensuring Fair Distribution**: Implement mechanisms to monitor and adjust the distribution of streams among nodes to ensure fairness and efficiency.
* **Secure Signature Verification**: Implement robust methods for verifying user signatures during stream creation, especially for DM streams.
* **Dynamic Rebalancing Logic**: Develop and integrate dynamic rebalancing logic that responds to changes in the network, such as nodes joining or leaving.
# Node Registry
Source: https://docs.towns.com/towns-messaging-protocol/towns-chain/node-registry
## Overview and Functionality
The Node Registry primary function is to manage the lifecycle of nodes — from their onboarding to their operational monitoring. This includes a rigorous registration process, ensuring that each node adheres to the network's stringent standards for performance and reliability. In essence, the Node Registry acts as the gatekeeper, maintaining the network's integrity and efficiency.
### Registration and Verification
At the heart of the Node Registry is the registration and verification process. New nodes are onboarded through a procedure that evaluates their compliance with specific performance and security standards. This process is crucial, as it maintains the high caliber of the network's infrastructure, ensuring that each node is capable and trustworthy. Requirements are able to evolve over time and adapt to incentives created by the protocol and demand for more operators.
### Node Management and Performance Monitoring
Once integrated into the network, nodes are continuously monitored for their performance and activity. This ongoing surveillance serves multiple purposes: it ensures that nodes remain operational and efficient, and it also provides critical data for network health assessments. The Node Registry's role in node management is pivotal in upholding the network's robustness and responsiveness.
### Deployment
The Node Registry is deployed on Base so that it can easily interact with both cross-chain entitlement contracts and governance contracts that also live on Base. Required information is subsequently bridged back and forth between Base and Towns Chain.
## Integration and Role within the Towns Chain
The Node Registry is not an isolated entity; it is deeply integrated into the Towns Chain's fabric. Implemented as a smart contract, it leverages the blockchain's inherent characteristics of immutability and transparency. This integration is vital for several reasons:
* **Coordination with Stream Registry**: The Node Registry works closely with the Stream Registry, ensuring a harmonious and efficient allocation of nodes to various streams within the Towns Messaging Protocol.
* **Upholding Decentralization and Security**: By managing the nodes in a decentralized manner, the Node Registry reinforces the network's distributed architecture, which is fundamental for security and resilience.
# Overview
Source: https://docs.towns.com/towns-messaging-protocol/towns-chain/overview
## Introduction
Towns Chain is an Ethereum Layer 2 blockchain built on OP-Stack that serves as the foundation for consensus and data integrity of streams. This section outlines the key aspects of the Towns Chain, elaborating on its role, functionality, and significance within the Towns Messaging Protocol ecosystem.
## Core Functionality
### Layer 2 Blockchain
* **Roll-up to Ethereum**: Towns Chain operates as a Layer 2 solution, rolling up to the Ethereum blockchain, thereby leveraging its security and trustworthiness while offering enhanced scalability and efficiency.
* **OP-Stack**: The chain is built on OP-stack getting the benefits of a battle tested Ethereum L2 stack with a future path of interoperability
### Smart Contract Integration
* **Stream Registry Contract**: Manages the allocation and operation of Stream Nodes, central to the messaging process.
* **Node Registry Contract**: Facilitates the registration and management of nodes within the network, ensuring a reliable and distributed node infrastructure.
## Scalability and Efficiency
* **High Throughput**: Designed for handling a large volume of messaging data with minimal latency, ensuring a seamless user experience.
* **Resource Optimization**: By operating as a Layer 2 solution, Towns Chain maintains low transaction costs and efficient resource usage, crucial for sustainable operation.
# Stream Registry
Source: https://docs.towns.com/towns-messaging-protocol/towns-chain/stream-registry
## Stream Node Allocation and Management
The Stream Registry is the canonical authority and provides the topology of stream locations and state in the Towns protocol. At the core of the Stream Registry's functionalities lies the dynamic allocation of Stream Nodes. This process is vital for ensuring an equitable and efficient distribution of network load across various streams. The registry acts as a central ledger, tracking the status and associations of Stream Nodes with specific message streams. This systematic management is pivotal in maintaining a well-organized and smoothly operating messaging network.
In a system governed by a stream registry, the canonical state is a critical component that serves as a reference point for all participants to reconcile their internal state. This means that every individual stream within the system must be accounted for in the stream registry, ensuring a comprehensive and up-to-date overview of the system's current status. Nodes, which are integral parts of this system, are endowed with the authority to write new streams into the registry. This process occurs whenever a new stream is created. Importantly, the creation of each stream is not arbitrary; it necessitates a justified reason.
The Stream Registry is deployed as an upgradeable smart contract to Towns Chain \[see].
## Role in Consensus and Security
The Stream Registry plays a significant role in achieving consensus among Stream Nodes regarding the state of various message streams. This consensus mechanism is a cornerstone for the integrity and security of the network. By overseeing node allocation, the Stream Registry directly contributes to enhancing the overall security and operational coherence of the messaging system.
## Scalability and Flexibility
A notable attribute of the Stream Registry is its adaptability in node allocation, a feature that significantly bolsters the scalability of the Towns Messaging Protocol. This adaptability is crucial in accommodating the fluctuating demands of the network. Moreover, the Stream Registry exhibits a high degree of flexibility in handling a diverse array of message streams, each with its unique set of requirements and characteristics, underscoring its versatility and capacity to manage complex network dynamics.
# Smart Contracts
Source: https://docs.towns.com/towns-smart-contracts/contracts
## Key Smart Contracts
Towns smart contracts are deployed using the Diamond Pattern (see [EIP-2535](https://eips.ethereum.org/EIPS/eip-2535)), which improves upon modularity and upgradeability.
The following is the current list of deployed diamond contracts on Base and a link to their associated facet addresses.
| Diamond | Network | Address | Facet Addresses |
| ------------ | ------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------- |
| SpaceFactory | Base | 0x9978c826d93883701522d2CA645d5436e5654252 | [Louper Link](https://louper.dev/diamond/0x9978c826d93883701522d2CA645d5436e5654252?network=base) |
| SpaceOwner | Base | 0x2824D1235d1CbcA6d61C00C3ceeCB9155cd33a42 | [Louper Link](https://louper.dev/diamond/0x2824D1235d1CbcA6d61C00C3ceeCB9155cd33a42?network=base) |
| Space | Base | 0x34f35E1ECA9C00791bF8121A01c20977d8bEB11C | [Louper Link](https://louper.dev/diamond/0x34f35E1ECA9C00791bF8121A01c20977d8bEB11C?network=base) |
| BaseRegistry | Base | 0x7c0422b31401C936172C897802CF0373B35B7698 | [Louper Link](https://louper.dev/diamond/0x7c0422b31401C936172C897802CF0373B35B7698?network=base) |
## Accessing and Interacting with the Contracts
These addresses provide direct access to the deployed contracts on Base. Developers and users of the Towns ecosystem can interact with these contracts for various purposes, including creating new Spaces, managing memberships, and implementing pricing strategies.
# Overview
Source: https://docs.towns.com/towns-smart-contracts/overview
Towns Smart Contracts are the cornerstone of the Towns ecosystem, establishing a robust framework for the creation, management, and interaction with digital communities, referred to as ‘Spaces’, on the blockchain. These contracts are deployed on [Base Mainnet](https://base.org), an Ethereum Layer 2 solution optimized for scalability and efficiency.
## Unique Contract Addresses for Each Space
* **Distinct Operations and Governance**: Each Space within the Towns ecosystem is equipped with a unique contract address. This individualized approach allows for distinct operations, governance, and interactions, ensuring that each Space maintains its unique identity and operational structure.
## Advantages of Towns Smart Contracts
* **Programmability**: Towns Smart Contracts allow every aspect of Spaces to be fully programmable. Developers can create sophisticated membership gating based on token balances, NFTs, or on-chain activity; implement dynamic pricing and automated subscriptions; deploy bots to enhance community interactions; and integrate seamlessly with other Web3 applications and decentralized finance (DeFi) protocols, unlocking new possibilities for on-chain community engagement.
* **Scalability and Efficiency**: By leveraging Ethereum Layer 2 solutions, Towns Smart Contracts significantly enhance the scalability of operations. This ensures that the increasing demands of digital communities are met without compromising on performance.
* **Reduced Transaction Costs**: The use of Layer 2 solutions also plays a pivotal role in reducing transaction costs, making it more economical for users to interact within the Towns ecosystem.
* **Enhanced Security and Transparency**: Smart contracts inherently provide a secure and transparent framework for digital interactions. The immutable nature of blockchain technology, combined with smart contract transparency, fosters a trustworthy environment for all users.
* **Automated Governance**: These contracts facilitate automated governance mechanisms. This automation ensures that the rules and protocols defined for each Space are consistently and impartially enforced.
## Deployment on Base Mainnet Chain
Towns Smart Contracts are deployed on Base Mainnet.
* **High Performance**: The Base Mainnet Chain is designed for high performance, crucial for the efficient operation of the Towns Smart Contracts.
* **Lower Transaction Costs**: Operating on this chain also ensures lower transaction costs, an essential factor for facilitating frequent and varied interactions within the Towns ecosystem.
* **Security**: Base Mainnet is built as an Ethereum L2 using Optimism. Blocks roll up to Ethereum Mainnet, deriving the security of one of the most secure public blockchain networks.
# Pricing Modules
Source: https://docs.towns.com/towns-smart-contracts/pricing-modules
## Overview
In the Towns ecosystem, Spaces have the flexibility to define their own pricing strategies through custom pricing modules. These modules are smart contracts that comply with the `IPricingModule` Interface and are responsible for determining the price of memberships based on variou프로젝트로 돌아가기