Skip to content

feat: implement unified devbox plugin for snrd and hway development #1283

Description

@prdlk

Summary

Implement a unified production-ready Devbox plugin at the repository root that streamlines local development, testnet deployment, and service management for both snrd (blockchain node) and hway (Highway service). This plugin consolidates tooling through Devbox's plugin system with Nix flake package integration and virtual environment setup scripts.

Requirements

Core Plugin Architecture

  • Unified Plugin: Single plugin.json at repository root managing both snrd and hway
  • Nix Integration: Reference Nix flake packages for snrd and hway binaries
  • Virtual Environment Scripts: Setup scripts in {{ .Virtenv }} for environment configuration
  • Process Compose Integration: Leverage existing process-compose.yaml files for service orchestration

Snrd Capabilities

  • Testnet Management: Wrap bootstrap.sh and testnet.sh for validator setup
  • Transaction Operations: Convenience wrappers for snrd tx and snrd query commands
  • Validator Operations: Key management, node operations, and status monitoring
  • Environment Setup: Auto-configure CHAIN_ID, DENOM, RPC endpoints from .env
  • Service Lifecycle: Start/stop/restart/logs/status commands

Hway Capabilities

  • Service Orchestration: Start Highway service with dependency checks
  • Dependency Verification: Redis connectivity, IPFS availability checks
  • Task Queue Management: Asynq queue inspection and statistics
  • Actor System Monitoring: Proto.Actor health checks and status
  • Database Operations: Connection validation and migration helpers

Shared Features

  • Dependency Management: Declare required packages (docker, jq, redis-cli, ipfs)
  • Init Hooks: Automatic environment setup on shell initialization
  • Logging: Unified log viewing and tailing across services
  • Health Checks: Comprehensive readiness probes for all dependencies
  • Data Management: Backup/restore operations and clean state resets

Context

Affected Files

New Plugin Files

  • plugin.json - Root-level unified Devbox plugin configuration
  • .devbox/virtenv/setup-snrd.sh - Snrd environment initialization script
  • .devbox/virtenv/setup-hway.sh - Hway environment initialization script
  • .devbox/virtenv/health-check.sh - Shared health check utilities

Existing Scripts to Integrate

  • cmd/snrd/etc/bootstrap.sh - Testnet bootstrap orchestration
  • cmd/snrd/etc/testnet.sh - Multi-validator testnet initialization
  • cmd/snrd/etc/process-compose.yaml - Snrd process composition
  • cmd/hway/etc/process-compose.yaml - Hway process composition

Configuration Files

  • devbox.json - Root devbox configuration (will reference plugin)
  • .env - Environment variables for both services
  • flake.nix - Nix flake providing snrd and hway packages

Existing Plugins to Replace/Enhance

  • cmd/snrd/plugin.json - To be consolidated into root plugin
  • cmd/hway/plugin.json - To be consolidated into root plugin

Relevant Documentation

Acceptance Criteria

Plugin Structure

  • Root plugin.json created with unified configuration
  • Plugin includes snrd and hway packages from Nix flake
  • init_hook sets up environment from .env and initializes virtenv scripts
  • Creates necessary directories: {{ .Virtenv }}/data/snrd, {{ .Virtenv }}/data/hway, {{ .Virtenv }}/logs
  • Plugin declares dependencies: docker, jq, redis-cli, ipfs, process-compose

Snrd Scripts

  • scripts.snrd:init - Initialize validator configuration
  • scripts.snrd:start - Start snrd node via process-compose
  • scripts.snrd:testnet - Bootstrap testnet validator
  • scripts.snrd:stop - Stop snrd node gracefully
  • scripts.snrd:status - Display node status and sync info
  • scripts.snrd:logs - Tail snrd logs
  • scripts.snrd:query - Wrapper for query operations with common flags
  • scripts.snrd:tx - Wrapper for transaction operations with common flags
  • scripts.snrd:keys - Key management operations
  • scripts.snrd:clean - Reset node state and data

Hway Scripts

  • scripts.hway:start - Start Highway service with dependency checks
  • scripts.hway:stop - Stop Highway service gracefully
  • scripts.hway:restart - Restart Highway service
  • scripts.hway:logs - Tail Highway service logs
  • scripts.hway:health - Comprehensive health checks (Redis, IPFS, DB)
  • scripts.hway:redis - Open Redis CLI for queue inspection
  • scripts.hway:queue-stats - Display Asynq queue statistics
  • scripts.hway:ipfs-status - Check IPFS node connectivity

Shared Scripts

  • scripts.health - Overall system health check (both services)
  • scripts.env:check - Validate environment configuration
  • scripts.logs:all - Tail logs from both services
  • scripts.clean:all - Reset all service data
  • scripts.backup - Backup service data and configurations
  • scripts.restore - Restore from backup

Environment Configuration

  • Auto-load variables from .env: CHAIN_ID, DENOM, REDIS_URL, IPFS_API, DATABASE_URL
  • Set SNRD_HOME to {{ .Virtenv }}/data/snrd
  • Set HWAY_DATA to {{ .Virtenv }}/data/hway
  • Configure process-compose to use virtenv paths

Integration Tests

  • Test plugin initialization in clean devbox shell
  • Test snrd node startup and query operations
  • Test hway service startup with Redis/IPFS mocks
  • Verify environment variables are properly injected
  • Test health checks correctly identify missing dependencies
  • Verify log locations and permissions
  • Test backup/restore operations
  • Verify plugin works with both local and Docker deployments

Documentation

  • Update README with plugin usage instructions
  • Document validator setup workflow using snrd scripts
  • Document Highway service development workflow
  • Add troubleshooting guide for common plugin issues
  • Include examples of common workflows (init → start → status → logs)
  • Document environment variable requirements

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions