chore(.gitignore): update gitignore to reflect removal of Highway and Vault components

This commit is contained in:
Prad Nukala
2025-10-21 12:30:43 -04:00
parent 3769d11f9f
commit ab44cf15eb
9 changed files with 76 additions and 390 deletions
+16 -22
View File
@@ -40,18 +40,16 @@ snrd
!cli/join-testnet/bin/
!cli/install/bin/
# ===== Node.js & Frontend =====
node_modules/
.pnpm-debug.log*
pnpm-debug.log*
package-lock.json
yarn.lock
*.tsbuildinfo
# Next.js
.next/
.vercel/
**/.open-next
# ===== Removed: Node.js & Frontend (no longer needed for blockchain-only repo) =====
# node_modules/
# .pnpm-debug.log*
# pnpm-debug.log*
# package-lock.json
# yarn.lock
# *.tsbuildinfo
# .next/
# .vercel/
# **/.open-next
# ===== Go Development =====
pkg/mod/
@@ -76,11 +74,7 @@ keyring-test/
mytestnet/
docker/testnet/testnet-data
# ===== Monorepo & Build Tools =====
.turbo/
.gitwork/
.changeset/.cli-state
.biome/
# ===== Build Tools =====
.devbox/
.task*
Taskfile.yml
@@ -95,7 +89,7 @@ logs/
configs/logs.json
tmp/
tmp*
tmp-swagger-gen/
tmp-openapi-gen/
# ===== Environment & Secrets =====
.env
@@ -122,8 +116,8 @@ COMPLETION_SUMMARY.md
data/
compose/
heighliner*
# Ignore individual module swagger files (generated in tmp directory)
tmp-swagger-gen/**/*.swagger.json
# Allow the final combined swagger.yaml
!client/docs/swagger-ui/swagger.yaml
# Ignore individual module OpenAPI files (generated in tmp directory)
tmp-openapi-gen/**/*.json
# Allow the final combined openapi.yml
!docs/static/openapi.yml
.mcp.json
+1 -80
View File
@@ -16,7 +16,7 @@ RUN apk add --no-cache \
WORKDIR /code
# Copy entire source code (including crypto module)
# Copy entire source code
COPY . .
# Fix git ownership issue
@@ -67,85 +67,6 @@ RUN --mount=type=cache,target=/go/pkg/mod \
echo "Ensuring binary is statically linked ..."; \
(file /code/build/snrd | grep "statically linked")
# --------------------------------------------------------
# Highway service build stage
FROM ${BASE_IMAGE} AS highway-builder
SHELL ["/bin/sh", "-ecuxo", "pipefail"]
# Install build dependencies
RUN apk add --no-cache \
ca-certificates \
build-base \
git \
linux-headers \
bash
WORKDIR /code
# Copy entire source code
COPY . .
# Fix git ownership issue
RUN git config --global --add safe.directory /code
# Download Go modules
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
GOTOOLCHAIN=auto go mod download
# Build Highway binary with optimizations
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
set -eux; \
VERSION=$(git describe --tags --always 2>/dev/null || echo "dev"); \
COMMIT=$(git log -1 --format='%H' 2>/dev/null || echo "unknown"); \
CGO_ENABLED=1 GOOS=linux \
go build \
-mod=readonly \
-tags "netgo" \
-ldflags "-X main.Version=${VERSION} \
-X main.Commit=${COMMIT} \
-w -s -linkmode=external -extldflags '-static'" \
-buildvcs=false \
-trimpath \
-o /code/build/hway \
./cmd/hway; \
file /code/build/hway; \
echo "Ensuring binary is statically linked ..."; \
(file /code/build/hway | grep "statically linked")
# --------------------------------------------------------
# Highway runtime image
FROM alpine:3.17 AS highway
LABEL org.opencontainers.image.title="Sonr Highway Service"
LABEL org.opencontainers.image.source="https://github.com/sonr-io/sonr"
# Copy binary from builder
COPY --from=highway-builder /code/build/hway /usr/bin/hway
# Install runtime dependencies
RUN apk add --no-cache ca-certificates wget
# Create non-root user
RUN adduser -D -u 1000 highway
# Set working directory
WORKDIR /home/highway
# Switch to non-root user
USER highway
# Health check endpoint
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --spider -q http://localhost:8090/health || exit 1
# Expose Highway port
EXPOSE 8090
# Set default command
ENTRYPOINT ["/usr/bin/hway"]
# --------------------------------------------------------
# Final minimal runtime image (default target for snrd)
FROM alpine:3.17
+28 -190
View File
@@ -106,10 +106,8 @@ make testnet-stop
### Building from Source
```bash
# Build all binaries
make build # snrd blockchain node
make build-hway # Highway service
make build-vault # Vault WASM plugin
# Build blockchain node
make build
# Build Docker image
make docker
@@ -162,38 +160,11 @@ make ipfs-status # Check IPFS connectivity
## 🏗️ Architecture
Sonr consists of three primary components and three custom modules:
### Service Architecture
```
┌─────────┐ ┌─────────┐ ┌─────────┐
│ Caddy │────▶│ snrd │ │ IPFS │
└─────────┘ └─────────┘ └─────────┘
│ │ │
│ ▼ ▼
│ ┌─────────┐ ┌─────────┐
└─────────▶│ Highway │────▶│ Redis │
└─────────┘ └─────────┘
```
- **Caddy**: Reverse proxy with gRPC-Web support (port 80)
- **Redis**: Task queue backend for Highway (port 6379)
- **Highway**: UCAN-based task processor (port 8090)
- **IPFS**: Distributed storage (API: 5001, Gateway: 8080)
- **snrd**: Blockchain node (gRPC: 9090, REST: 1317)
### Cross-Platform Support
The `localnet` target now automatically detects and uses the best available method:
1. Checks for local binary (built with `make install`)
2. Falls back to Docker if available
3. Handles permission issues on systems like Arch Linux
4. Supports systemd service installation (see `etc/systemd/`)
Sonr is a Cosmos SDK-based blockchain with integrated IPFS storage and three custom modules:
### Core Components
#### 1. **Blockchain Node (`snrd`)**
#### **Blockchain Node (`snrd`)**
The main blockchain daemon built with Cosmos SDK v0.50.14, providing:
@@ -201,22 +172,15 @@ The main blockchain daemon built with Cosmos SDK v0.50.14, providing:
- EVM compatibility via Evmos integration
- IBC for cross-chain communication
- CosmWasm smart contract support
- IPFS integration for decentralized storage
#### 2. **Highway Service (`hway`)**
### Cross-Platform Support
An Asynq-based task processing service for vault operations:
- Redis-backed job queue with priority levels
- Actor-based concurrency using Proto.Actor framework
- Processes cryptographic operations through WebAssembly enclaves
#### 3. **Motor Plugin (`motr`)**
WebAssembly-based vault system providing:
- Secure execution environment for sensitive operations
- Hardware-backed key management
- Multi-party computation capabilities
The `localnet` target automatically detects and uses the best available method:
1. Checks for local binary (built with `make install`)
2. Falls back to Docker if available
3. Handles permission issues on systems like Arch Linux
4. Supports systemd service installation (see `etc/systemd/`)
## 📖 Module Documentation
@@ -301,45 +265,12 @@ export BLOCK_TIME="1000ms"
# Network selection for Starship
export NETWORK="devnet" # or "testnet"
# Redis configuration
REDIS_URL=redis://redis:6379
REDIS_DB=0
# Highway service
HIGHWAY_PORT=8090
LOG_LEVEL=debug
# IPFS configuration
IPFS_API_URL=http://ipfs:5001
# Caddy configuration
CADDY_DOMAIN=localhost
```
Environment variables can be set directly or via a `.env` file in the project root.
### Docker Compose Services
The project includes a comprehensive Docker Compose setup for running all backend services:
```bash
# Start all services (Redis, Highway, Caddy, IPFS)
make docker-up
# Stop all services
make docker-down
# View service logs
make docker-logs # All services
make docker-logs-redis # Specific service
# Check service health
make docker-status
# Clean up Docker resources
make docker-clean
```
### Starship Configuration
Edit `starship.yml` to configure multi-node testnets:
@@ -353,146 +284,53 @@ chains:
# ... additional configuration
```
#### Troubleshooting
**Services not starting:**
```bash
# Check service status
make docker-status
# View detailed logs
make docker-logs
# Ensure Docker network exists
docker network ls | grep sonr-network
```
**Redis connection issues:**
```bash
# Test Redis connectivity
docker exec redis redis-cli ping
# Check Redis logs
make docker-logs-redis
```
### Troubleshooting
**IPFS not accessible:**
```bash
# Verify IPFS is running
curl http://127.0.0.1:5001/api/v0/version
# Check IPFS logs
docker compose -f etc/stack/compose.yml logs ipfs
# Check IPFS status
make ipfs-status
```
**Port conflicts:**
- Caddy: 80 (HTTP)
- Redis: 6379
- Highway: 8090
- IPFS API: 5001
- IPFS Gateway: 8080
- Node gRPC: 9090
- Node REST API: 1317
Stop conflicting services or modify ports in `etc/stack/compose.yml`.
Stop conflicting services or modify ports in configuration files.
## 🏗️ Project Structure
Sonr uses a modern monorepo architecture with pnpm workspaces for JavaScript/TypeScript packages alongside the Go blockchain implementation:
### Workspace Organization
Sonr is a focused Cosmos SDK blockchain implementation:
```
sonr/
├── app/ # Application setup and module wiring
├── cmd/ # Binary entry points
── snrd/ # Blockchain node
│ ├── hway/ # Highway service
│ └── motr/ # Motor WASM plugin
├── x/ # Custom chain modules
── snrd/ # Blockchain node daemon
├── x/ # Custom Cosmos SDK modules
│ ├── did/ # W3C DID implementation
│ ├── dwn/ # Decentralized Web Nodes
│ └── svc/ # Service management
├── types/ # Internal packages
│ ├── coins/ # Task processing
│ └── ipfs/ # Authorization networks
├── types/ # Internal Go packages
├── proto/ # Protobuf definitions
├── scripts/ # Utility scripts
├── test/ # Integration tests
├── docs/ # Documentation site
# Monorepo Packages (pnpm workspaces)
├── packages/ # Core JavaScript/TypeScript packages
│ ├── es/ # @sonr.io/es - ES client library
│ ├── sdk/ # @sonr.io/sdk - SDK package
│ └── ui/ # @sonr.io/ui - Shared UI components
├── cli/ # CLI tools
│ ├── install/ # @sonr.io/install - Installation CLI
│ └── join-testnet/# @sonr.io/join-testnet - Testnet CLI
└── web/ # Web applications
├── auth/ # Authentication app (Next.js)
└── dash/ # Dashboard app (Next.js)
```
### Working with the Monorepo
#### Installation
```bash
# Install all dependencies for the monorepo
pnpm install
# Build all packages
pnpm build
# Run development mode for all packages
pnpm dev
```
#### Package Management
```bash
# Run commands in specific packages
pnpm --filter @sonr.io/es build
pnpm --filter @sonr.io/sdk test
# Add dependencies to specific packages
pnpm --filter @sonr.io/ui add react
# Run commands in all packages
pnpm -r build # Build all packages
pnpm -r test # Test all packages
```
#### Versioning & Publishing
The monorepo uses [Changesets](https://github.com/changesets/changesets) for package versioning:
```bash
# Add a changeset for your changes
pnpm changeset
# Version packages based on changesets
pnpm changeset version
# Publish packages to npm
pnpm changeset publish
├── docs/ # Documentation
└── client/ # Client libraries and tooling
```
### Key Technologies
- **pnpm workspaces**: Efficient dependency management with single lockfile
- **TypeScript project references**: Incremental builds and better IDE performance
- **Turbo**: Build orchestration and caching for faster builds
- **Changesets**: Automated versioning and changelog generation
- **Biome**: Fast, unified linting and formatting (replaces ESLint/Prettier)
### Package Dependencies
- `@sonr.io/es`: Core ES client library with protobuf types
- `@sonr.io/sdk`: High-level SDK (depends on @sonr.io/es)
- `@sonr.io/ui`: Shared UI components for web applications
- `@sonr.io/install`: CLI tool for installing Sonr
- `@sonr.io/join-testnet`: CLI tool for joining testnet
- Web apps use all three core packages (@sonr.io/es, @sonr.io/sdk, @sonr.io/ui)
- **Cosmos SDK v0.50.14**: Blockchain framework
- **CometBFT v0.38.17**: Byzantine fault-tolerant consensus
- **IBC v8.7.0**: Inter-blockchain communication
- **CosmWasm v1.5.8**: Smart contract support
- **IPFS**: Decentralized storage integration
## 🤝 Community & Support
+7 -13
View File
@@ -62,13 +62,10 @@ ldflags := $(strip $(ldflags))
BUILD_FLAGS := -tags "$(build_tags_comma_sep)" -ldflags '$(ldflags)' -trimpath
# Build vault WASM module (required dependency)
VAULT_ROOT := $(GIT_ROOT)/cmd/vault
VAULT_OUT := $(GIT_ROOT)/x/dwn/client/plugin/vault.wasm
SNRD_OUT := $(GIT_ROOT)/build/snrd
SNRD_EXE_OUT := $(GIT_ROOT)/build/snrd.exe
.PHONY: all build install clean vault version help docker
.PHONY: all build install clean version help docker
all: build
@@ -82,7 +79,6 @@ else
endif
install:
@$(MAKE) -C $(VAULT_ROOT) build
ifeq ($(OS),Windows_NT)
@echo "Building snrd.exe for Windows..."
GOOS=windows GOARCH=amd64 go build -mod=readonly $(BUILD_FLAGS) -o $(SNRD_EXE_OUT) .
@@ -95,7 +91,6 @@ endif
clean:
@echo "Cleaning build artifacts..."
@rm -f $(SNRD_OUT) $(SNRD_EXE_OUT)
@$(MAKE) -C $(VAULT_ROOT) clean
@echo "Clean complete"
version:
@@ -150,14 +145,13 @@ help:
@echo "==================="
@echo ""
@echo "Available targets:"
@echo " build - Build snrd binary (with vault WASM)"
@echo " install - Install snrd to GOPATH/bin"
@echo " vault - Build vault WASM module only"
@echo " docker - Build Docker image (onsonr/snrd:latest)"
@echo " clean - Remove build artifacts"
@echo " version - Display version information"
@echo " build - Build snrd binary"
@echo " install - Install snrd to GOPATH/bin"
@echo " docker - Build Docker image (onsonr/snrd:latest)"
@echo " clean - Remove build artifacts"
@echo " version - Display version information"
@echo " link-wasmvm - Download WasmVM libraries for goreleaser"
@echo " help - Show this help message"
@echo " help - Show this help message"
@echo ""
@echo "Build options:"
@echo " LEDGER_ENABLED=true|false - Enable/disable ledger support (default: true)"
+8 -31
View File
@@ -54,33 +54,23 @@ build_locally() {
exit 1
fi
# Build binaries
# Build binary
echo "Building snrd..."
make build || {
echo "Error: Failed to build snrd"
exit 1
}
echo "Building motr..."
make motr || {
echo "Error: Failed to build motr"
exit 1
}
# Copy binaries to install directory
# Copy binary to install directory
cp build/snrd "${INSTALL_DIR}/" || {
echo "Error: Failed to copy snrd"
exit 1
}
cp build/motr.wasm "${INSTALL_DIR}/" || {
echo "Error: Failed to copy motr.wasm"
exit 1
}
# Make binaries executable
# Make binary executable
chmod +x "${INSTALL_DIR}/snrd"
echo "Binaries built and installed successfully to ${INSTALL_DIR}"
echo "Binary built and installed successfully to ${INSTALL_DIR}"
}
# Function to get latest release version
@@ -144,31 +134,18 @@ install_binaries() {
fi
fi
# Download motr.wasm (platform independent)
echo "Downloading motr.wasm..."
if ! curl -L "${BASE_URL}/motr.wasm" -o "${INSTALL_DIR}/motr.wasm" -f; then
echo "Warning: Failed to download from CDN, trying GitHub releases..."
# Fallback to GitHub releases
GITHUB_URL="https://github.com/sonr-io/sonr/releases/download/v${LATEST_VERSION}"
if ! curl -L "${GITHUB_URL}/motr.wasm" -o "${INSTALL_DIR}/motr.wasm" -f; then
echo "Error: Failed to download motr.wasm from both CDN and GitHub"
exit 1
fi
fi
# Make binaries executable
# Make binary executable
chmod +x "${INSTALL_DIR}/snrd"
echo "Binaries installed successfully to ${INSTALL_DIR}"
echo "Binary installed successfully to ${INSTALL_DIR}"
else
# Fall back to local build
build_locally "${INSTALL_DIR}"
fi
echo
echo "Available commands:"
echo " snrd - Blockchain daemon"
echo " motr.wasm - WebAssembly enclave"
echo "Installed:"
echo " snrd - Blockchain daemon"
echo
echo "Quick start:"
echo " snrd --help # Show available commands"
+13 -10
View File
@@ -22,7 +22,7 @@ GIT_ROOT := $(shell git rev-parse --show-toplevel)
###############################################################################
.DEFAULT_GOAL := help
all: build gen swagger-gen push
all: build gen openapi-gen push
proto: gen
generate: gen
@@ -53,20 +53,23 @@ test:
###############################################################################
### Documentation ###
###############################################################################
swagger-gen:
openapi-gen:
@gum log --level info "Generating OpenAPI documentation..."
@$(protoImage) buf generate --template proto/buf.gen.openapi.yaml
@gum log --level info "Combining swagger files into unified specification..."
@mkdir -p $(GIT_ROOT)/client/docs/swagger-ui
@gum log --level info "Combining OpenAPI files into unified specification..."
@mkdir -p $(GIT_ROOT)/docs/static
@npx swagger-combine $(GIT_ROOT)/client/docs/config.json \
-o $(GIT_ROOT)/client/docs/swagger-ui/swagger.yaml \
-o $(GIT_ROOT)/docs/static/openapi.yml \
-f yaml \
--continueOnConflictingPaths true \
--includeDefinitions true
@gum log --level info "Cleaning up temporary files..."
@rm -rf $(GIT_ROOT)/tmp-swagger-gen
@rm -rf $(GIT_ROOT)/tmp-openapi-gen
@gum log --level info "✅ OpenAPI documentation generated successfully"
@gum log --level info "✅ Unified API specification: client/docs/swagger-ui/swagger.yaml"
@gum log --level info "✅ Unified API specification: docs/static/openapi.yml"
# Backwards compatibility alias
swagger-gen: openapi-gen
push:
@npx buf push
@@ -86,15 +89,15 @@ help:
@gum log --level info ""
@gum log --level info "Available targets:"
@gum log --level info ""
@gum log --level info " all Run lint, gen, and swagger-gen targets"
@gum log --level info " all Run lint, gen, and openapi-gen targets"
@gum log --level info " gen Generate protobuf code and stubs"
@gum log --level info " lint Lint protobuf files"
@gum log --level info " check-breaking Check for breaking changes against main branch"
@gum log --level info " swagger-gen Generate OpenAPI documentation"
@gum log --level info " openapi-gen Generate OpenAPI documentation"
@gum log --level info " help Show this help message"
@gum log --level info ""
@gum log --level info "Environment:"
@gum log --level info " Proto builder: $(protoImageName)"
@gum log --level info " Spawn: onsonr/spawn:latest"
.PHONY: all gen lint check-breaking swagger-gen help
.PHONY: all gen lint check-breaking openapi-gen swagger-gen help
+2 -2
View File
@@ -1,9 +1,9 @@
version: v1
plugins:
# Generate OpenAPI v2 (Swagger) documentation
# Generate OpenAPI v2 documentation
# Follows Cosmos SDK standard approach: generate to tmp directory, then combine
- name: openapiv2
out: ../tmp-swagger-gen
out: ../tmp-openapi-gen
opt:
- logtostderr=true
- fqn_for_swagger_name=true
-41
View File
@@ -153,67 +153,32 @@ devbox_run() {
install() {
header "Install"
gum spin --show-error --spinner pulse --title "Installing pnpm..." -- pnpm install --frozen-lockfile
gum spin --show-error --spinner pulse --title "Installing Go..." -- go mod download
info "pnpm(10.14.0)"
info "go(1.24.7)"
separator
}
build_all() {
header "Build"
devbox_run "build:auth"
devbox_run "build:dash"
devbox_run "build:core"
devbox_run "build:com"
devbox_run "build:es"
devbox_run "build:hway"
devbox_run "build:motr"
devbox_run "build:pkl"
devbox_run "build:sdk"
devbox_run "build:ui"
devbox_run "build:vault"
separator
}
test_all() {
header "Test"
devbox_run "test:auth"
devbox_run "test:dash"
devbox_run "test:core"
devbox_run "test:com"
devbox_run "test:es"
devbox_run "test:hway"
devbox_run "test:motr"
devbox_run "test:pkl"
devbox_run "test:sdk"
devbox_run "test:ui"
devbox_run "test:vault"
separator
}
release_all() {
header "Release"
# devbox_run "release:auth"
# devbox_run "release:dash"
devbox_run "release:core"
devbox_run "release:com"
devbox_run "release:es"
devbox_run "release:hway"
devbox_run "release:motr"
devbox_run "release:pkl"
devbox_run "release:sdk"
devbox_run "release:ui"
devbox_run "release:vault"
separator
}
snapshot_all() {
header "Snapshot"
devbox_run "snapshot:core"
devbox_run "snapshot:hway"
devbox_run "snapshot:motr"
devbox_run "snapshot:vault"
separator
}
@@ -312,12 +277,6 @@ main() {
"snapshot-scopes")
snapshot_scopes
;;
"install-pnpm")
install_pnpm
;;
"install-go")
install_go
;;
"install")
install
;;
+1 -1
View File
@@ -28,7 +28,7 @@ rm -rf github.com
# Copy files over for dep injection
rm -rf api && mkdir api
custom_modules=$(find . -name 'module' -type d -not -path "./proto/*" -not -path "./.cache/*" -not -path "./node_modules/*" -not -path "./packages/*")
custom_modules=$(find . -name 'module' -type d -not -path "./proto/*" -not -path "./.cache/*")
# get the 1 up directory (so ./cosmos/mint/module becomes ./cosmos/mint)
# remove the relative path starter from base namespaces. so ./cosmos/mint becomes cosmos/mint