docs: update README + api docs + architecture for v2.0.0 feed

README
  - Mention social feed in the one-line description and feature bullets
  - Add relay + feed endpoint tables to the API overview (was
    previously empty on messaging)
  - List media/ package in the repo structure

docs/api/
  - New docs/api/feed.md: full reference for /feed/publish, fetch,
    stats, view, author, timeline, trending, foryou, hashtag; all
    on-chain CREATE_POST / DELETE_POST / FOLLOW / LIKE payloads;
    fee economics; server-side scrubbing contract.
  - docs/api/relay.md rewritten: /relay/broadcast is now the primary
    E2E path with a complete envelope schema; /relay/send kept but
    flagged ⚠ NOT E2E; DELETE /relay/inbox/{id} documented with the
    new Ed25519 signed-auth body.
  - docs/api/README.md index: added feed.md row.

docs/architecture.md
  - L2 Transport layer description updated to include the feed
    mailbox alongside the 1:1 relay mailbox.
  - New "Социальная лента (v2.0.0)" section right after the 1:1
    message flow: ASCII diagram of publish + on-chain commit +
    timeline fetch, economic summary, metadata-scrub summary.

docs/node/README.md
  - Removed stale chan:/chan-member: keys from the BadgerDB schema
    reference; replaced with the v2.0.0 feed keys (post:,
    postbyauthor:, follow:, followin:, like:, likecount:).

docs/update-system.md
  - Example features[] array updated to match the actual node output
    (channels_v1 removed, feed_v2 / media_scrub / relay_broadcast added).

Node feature flags
  - api_well_known_version.go: dropped channels_v1 tag (the
    /api/channels/:id endpoint was removed in the feed refactor);
    added feed_v2, media_scrub, relay_broadcast so clients can
    feature-detect the v2.0.0 surface.
  - Comment example updated channels_v2/v1 → feed_v3/v2.

Client
  - CLIENT_REQUIRED_FEATURES expanded to include the v2.0.0 feature
    flags the client now depends on (feed_v2, media_scrub,
    relay_broadcast); checkNodeVersion() will flag older nodes as
    unsupported and surface an upgrade prompt.

All 7 Go test packages green; tsc --noEmit clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
vsecoder
2026-04-18 22:06:06 +03:00
parent 6425b5cffb
commit 1a8731f479
9 changed files with 479 additions and 45 deletions

View File

@@ -2,16 +2,18 @@
## Обзор
DChain — это L1-блокчейн для децентрализованного мессенджера. Архитектура разделена на четыре слоя:
DChain — это L1-блокчейн для децентрализованного мессенджера + социальной ленты. Архитектура разделена на четыре слоя:
```
┌─────────────────────────────────────────────────────────────┐
│ L3 Application — messaging, usernames, auctions, escrow
│ L3 Application — messaging, social feed, usernames,
│ auctions, escrow │
│ (Smart contracts: username_registry, governance, auction, │
│ escrow; deployed on-chain via DEPLOY_CONTRACT) │
│ escrow; native feed events; deployed on-chain) │
├─────────────────────────────────────────────────────────────┤
│ L2 Transport — relay mailbox, E2E NaCl encryption
(relay/, mailbox, GossipSub envelopes, RELAY_PROOF tx)
│ L2 Transport — relay mailbox (1:1 E2E) +
feed mailbox (public posts + attachments)
│ (relay/, media scrubber, GossipSub envelopes, RELAY_PROOF) │
├─────────────────────────────────────────────────────────────┤
│ L1 Chain — PBFT consensus, WASM VM, BadgerDB │
│ (blockchain/, consensus/, vm/, identity/) │
@@ -189,6 +191,50 @@ Alice node1 (relay) Bob
---
## Социальная лента (v2.0.0)
Публичные посты в Twitter/VK-стиле. Заменила channel-модель (каналы
удалены полностью). Живёт гибридно — метаданные on-chain, тела в relay
feed-mailbox:
```
Alice node1 (hosting relay) Bob
│ │ │
│─ POST /feed/publish ──────▶│ │
│ (body + EXIF-scrub) │ │
│ │ store in feed-mailbox │
│ │ (TTL 30 days) │
│ │ │
│◀── response: content_hash, │ │
│ estimated_fee_ut, id │ │
│ │ │
│─ CREATE_POST tx ──────────▶│── PBFT commit ──────────▶ │
│ (fee = 1000 + size × 1) │ │
│ │ on-chain: post:<id> │
│ │ │
│ │ │─ GET /feed/timeline
│ │◀── merge followed authors │ (from chain)
│ │ │
│ │── GET /feed/post/{id} ───▶│
│ │ (body from mailbox) │
```
**Экономика:**
- Автор платит `BasePostFee(1000) + size × PostByteFee(1)` µT
- Вся плата уходит `hosting_relay` пубкею — компенсация за хранение
- `MaxPostSize = 256 KiB` — hard cap, защищает мейлбокс от abuse
**Метаданные:**
- EXIF/GPS/camera-info удаляется обязательно на сервере (in-proc для
изображений, через FFmpeg-сайдкар для видео)
- Лайки / follows — on-chain транзакции (provable + anti-Sybil fee)
- Просмотры — off-chain counter в relay (on-chain было бы абсурдно)
- Хэштеги — авто-индекс при publish, inverted-index в BadgerDB
Детали — [api/feed.md](api/feed.md).
---
## Динамические валидаторы
Сет валидаторов хранится on-chain в `validator:<pubkey>`. Любой текущий валидатор может добавить или убрать другого (ADD_VALIDATOR / REMOVE_VALIDATOR tx). После commit такого блока PBFT-движок перезагружает сет без рестарта ноды.