chore: initial commit for v0.0.1

DChain single-node blockchain + React Native messenger client.

Core:
- PBFT consensus with multi-sig validator admission + equivocation slashing
- BadgerDB + schema migration scaffold (CurrentSchemaVersion=0)
- libp2p gossipsub (tx/v1, blocks/v1, relay/v1, version/v1)
- Native Go contracts (username_registry) alongside WASM (wazero)
- WebSocket gateway with topic-based fanout + Ed25519-nonce auth
- Relay mailbox with NaCl envelope encryption (X25519 + Ed25519)
- Prometheus /metrics, per-IP rate limit, body-size cap

Deployment:
- Single-node compose (deploy/single/) with Caddy TLS + optional Prometheus
- 3-node dev compose (docker-compose.yml) with mocked internet topology
- 3-validator prod compose (deploy/prod/) for federation
- Auto-update from Gitea via /api/update-check + systemd timer
- Build-time version injection (ldflags → node --version)
- UI / Swagger toggle flags (DCHAIN_DISABLE_UI, DCHAIN_DISABLE_SWAGGER)

Client (client-app/):
- Expo / React Native / NativeWind
- E2E NaCl encryption, typing indicator, contact requests
- Auto-discovery of canonical contracts, chain_id aware, WS reconnect on node switch

Documentation:
- README.md, CHANGELOG.md, CONTEXT.md
- deploy/single/README.md with 6 operator scenarios
- deploy/UPDATE_STRATEGY.md with 4-layer forward-compat design
- docs/contracts/*.md per contract
This commit is contained in:
vsecoder
2026-04-17 14:16:44 +03:00
commit 7e7393e4f8
196 changed files with 55947 additions and 0 deletions

63
Dockerfile Normal file
View File

@@ -0,0 +1,63 @@
# ---- build stage ----
FROM golang:1.24-alpine AS builder
WORKDIR /app
# Cache module downloads separately from source changes
COPY go.mod go.sum ./
RUN go mod download
COPY . .
# Build-time version metadata (same convention as deploy/prod/Dockerfile.slim).
ARG VERSION_TAG=dev
ARG VERSION_COMMIT=none
ARG VERSION_DATE=unknown
ARG VERSION_DIRTY=false
RUN LDFLAGS="\
-X go-blockchain/node/version.Tag=${VERSION_TAG} \
-X go-blockchain/node/version.Commit=${VERSION_COMMIT} \
-X go-blockchain/node/version.Date=${VERSION_DATE} \
-X go-blockchain/node/version.Dirty=${VERSION_DIRTY}" && \
CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="$LDFLAGS" -o /bin/node ./cmd/node && \
CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="$LDFLAGS" -o /bin/client ./cmd/client && \
CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="$LDFLAGS" -o /bin/wallet ./cmd/wallet && \
CGO_ENABLED=0 GOOS=linux go build -trimpath -ldflags="$LDFLAGS" -o /bin/peerid ./cmd/peerid
# ---- runtime stage ----
FROM alpine:3.19
RUN apk add --no-cache ca-certificates tzdata netcat-openbsd
COPY --from=builder /bin/node /usr/local/bin/node
COPY --from=builder /bin/client /usr/local/bin/client
COPY --from=builder /bin/wallet /usr/local/bin/wallet
COPY --from=builder /bin/peerid /usr/local/bin/peerid
# Bake testnet keys into image so nodes always load consistent identities
# (avoids Windows volume-mount failures with ./testdata:/keys:ro)
COPY --from=builder /app/testdata/ /keys/
# Bake username_registry contract (messenger username with pricing)
COPY --from=builder /app/contracts/username_registry/username_registry.wasm /keys/username_registry.wasm
COPY --from=builder /app/contracts/username_registry/username_registry_abi.json /keys/username_registry_abi.json
# Bake governance contract (on-chain parameter governance)
COPY --from=builder /app/contracts/governance/governance.wasm /keys/governance.wasm
COPY --from=builder /app/contracts/governance/governance_abi.json /keys/governance_abi.json
# Bake auction contract (English auction with token escrow)
COPY --from=builder /app/contracts/auction/auction.wasm /keys/auction.wasm
COPY --from=builder /app/contracts/auction/auction_abi.json /keys/auction_abi.json
# Bake escrow contract (two-party trustless escrow)
COPY --from=builder /app/contracts/escrow/escrow.wasm /keys/escrow.wasm
COPY --from=builder /app/contracts/escrow/escrow_abi.json /keys/escrow_abi.json
# libp2p P2P port
EXPOSE 4001/tcp
# HTTP stats + explorer + relay API
EXPOSE 8080/tcp
ENTRYPOINT ["/usr/local/bin/node"]