Highway Service (hway)
Highway is a high-performance task processing service for Sonr’s decentralized vault system. It provides asynchronous, durable execution of cryptographic operations using WebAssembly enclaves and Redis-backed job queues.Overview
Highway acts as a distributed task processor that handles secure cryptographic operations for the Sonr blockchain ecosystem. It leverages:- Asynq for reliable job queue management with Redis
- Proto.Actor for actor-based concurrency
- WebAssembly enclaves for secure cryptographic operations
- IPFS integration for decentralized storage
Quick Start
Prerequisites
- Redis server running on
127.0.0.1:6379
- Go 1.24.4 or later
Installation
Running the Service
- Concurrency: 10 workers
- Queue Priorities:
critical
: 6 workersdefault
: 3 workerslow
: 1 worker
Architecture
Highway implements a multi-layered architecture for secure task processing:Core Components
-
Task Processing Layer (
main.go
)- Asynq server configuration
- Task routing and worker management
- Redis connection handling
-
Actor System (
internal/vault/plugin/actor.go
)- Proto.Actor based concurrency
- Behavioral state management
- Lifecycle management for WASM plugins
-
Plugin Interface (
internal/vault/plugin/plugin.go
)- WebAssembly plugin abstraction
- Secure cryptographic operations
- Type-safe method calls
-
Task Definitions (
internal/vault/tasks/
)- Task type definitions
- Payload serialization
- Task processing logic
Supported Operations
Highway supports the following cryptographic operations through its vault system:Key Generation
Digital Signatures
Signature Verification
Vault Management
Export to IPFS
Import from IPFS
Vault Refresh
Task Management
Creating Tasks
Tasks are created using the Asynq task creation utilities:Task Types
Highway currently supports the following task types:vault:generate
- Generate new cryptographic key pairs
- Defining the task type constant in
internal/vault/tasks/types.go
- Creating appropriate payload and response structures
- Implementing the task processor
- Registering the handler in
main.go
Configuration
Redis Configuration
Highway connects to Redis using the following default settings:Worker Configuration
Actor System Configuration
Security Model
Highway implements a multi-layered security approach:- WebAssembly Isolation: All cryptographic operations run in WASM enclaves
- Actor Encapsulation: Each vault actor maintains isolated state
- Encrypted Storage: Vault data is encrypted before IPFS storage
- Password Protection: Additional password layer for import/export operations
- Request Validation: All requests undergo validation before processing
Development
Adding New Task Types
-
Define the task type:
-
Create payload structures:
-
Implement the processor:
-
Register the handler:
Testing
Highway includes comprehensive test suites for:- Task processing logic
- Actor system behavior
- WASM plugin integration
- Redis queue operations
Monitoring and Observability
Highway provides detailed logging for:- Task processing events
- Actor lifecycle management
- Plugin operation results
- Error conditions and recovery
Performance Considerations
- Concurrency: Adjust worker count based on CPU cores and workload
- Queue Priorities: Balance task priorities according to business requirements
- Redis Memory Usage: Monitor Redis memory consumption with large task volumes
- WASM Performance: Plugin operations are CPU-intensive; size workers accordingly
Troubleshooting
Common Issues
Redis Connection Failed- Ensure Redis server is running on the configured address
- Check Redis configuration and network connectivity
- Verify WASM plugin file exists and is accessible
- Check plugin manifest configuration
- Review Extism runtime requirements
- Review plugin loading prerequisites
- Check system memory and resource availability
- Verify Proto.Actor system configuration