--- title: VRF Key Migration Guide description: Migrate existing validator nodes to use VRF keys without downtime --- # VRF Key Migration Guide This guide provides step-by-step instructions for adding VRF keys to existing Sonr validator nodes that were initialized before VRF key support was added. ## Overview VRF (Verifiable Random Function) keys are required for: - Multi-validator encryption features (added in v0.1.12) - Consensus-based key rotation - Secure encryption key derivation Existing nodes initialized before v0.1.12 may not have VRF keys generated. ## Pre-Migration Checklist Before starting the migration: - [ ] **Backup** your validator keys and configuration - [ ] **Identify** which validators need VRF keys - [ ] **Plan** migration during low-traffic period - [ ] **Coordinate** with other validators (for governance proposals) - [ ] **Test** on testnet first ## Migration Scenarios ### Scenario 1: Encryption Not Needed If your network doesn't use encryption features, you can disable encryption instead of generating VRF keys. **Option A: Disable via Governance** 1. Create governance proposal: ```bash cat > disable-encryption-proposal.json < enable-encryption-proposal.json < --force # Fix permissions chmod 0600 ~/.sonr/vrf_secret.key # Verify snrd keys vrf verify ``` ### Issue: "Failed to check and perform key rotation" **Cause**: Encryption enabled but VRF keys missing on some validators. **Fix**: 1. Identify validators without VRF keys 2. Temporarily disable encryption 3. Generate VRF keys on all validators 4. Re-enable encryption ### Issue: Network Stalled During Migration **Cause**: Too many validators offline simultaneously. **Fix**: 1. Ensure >2/3 voting power online 2. Coordinate restart timing 3. Use smaller migration windows per validator ### Issue: Inconsistent VRF Keys **Cause**: Different chain-id used during generation. **Fix**: ```bash # Check chain-id in genesis jq '.chain_id' ~/.sonr/config/genesis.json # Regenerate with correct chain-id snrd keys vrf generate --chain-id --force ``` ## Best Practices ### Before Migration - ✅ Test on testnet with same topology - ✅ Backup all validator data - ✅ Document rollback procedures - ✅ Prepare monitoring dashboards - ✅ Schedule during low-traffic period ### During Migration - ✅ Migrate one validator at a time (gradual) - ✅ Monitor logs continuously - ✅ Verify each step before proceeding - ✅ Keep communication channels open - ✅ Document any issues encountered ### After Migration - ✅ Verify all validators functional - ✅ Test encryption features - ✅ Monitor performance metrics - ✅ Update documentation - ✅ Schedule follow-up verification ## Timeline Recommendations ### Small Network (3-5 validators) - **Preparation**: 3-5 days - **Migration**: 1-2 hours - **Verification**: 1 day ### Medium Network (10-20 validators) - **Preparation**: 1 week - **Migration**: 4-6 hours (gradual) or 30 minutes (coordinated) - **Verification**: 2-3 days ### Large Network (50+ validators) - **Preparation**: 2-3 weeks - **Migration**: 1-2 days (gradual) or network upgrade - **Verification**: 1 week ## Support & Resources - **VRF Key Management Guide**: `/guides/vrf-key-management` - **GitHub Issues**: https://github.com/sonr-io/sonr/issues - **Discord**: Validator support channel - **Documentation**: https://docs.sonr.io ## Appendix: Automation Script For networks with many validators, use this automation script: ```bash #!/bin/bash # vrf-migration.sh - Automated VRF key migration helper set -e CHAIN_ID="${CHAIN_ID:-sonrtest_1-1}" BACKUP_DIR="${BACKUP_DIR:-$HOME/vrf-backup}" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color log_info() { echo -e "${GREEN}[INFO]${NC} $1" } log_warn() { echo -e "${YELLOW}[WARN]${NC} $1" } log_error() { echo -e "${RED}[ERROR]${NC} $1" } # Backup existing data backup_validator() { log_info "Creating backup..." mkdir -p "$BACKUP_DIR" tar -czf "$BACKUP_DIR/validator-$(date +%Y%m%d-%H%M%S).tar.gz" \ ~/.sonr/config/ \ ~/.sonr/data/priv_validator_state.json 2>/dev/null || true log_info "Backup created at $BACKUP_DIR" } # Generate VRF keys generate_vrf() { log_info "Generating VRF keys for chain: $CHAIN_ID" if snrd keys vrf generate --chain-id "$CHAIN_ID"; then log_info "VRF keys generated successfully" else log_error "Failed to generate VRF keys" exit 1 fi } # Verify VRF keys verify_vrf() { log_info "Verifying VRF keys..." if snrd keys vrf verify; then log_info "VRF keys verified successfully" else log_error "VRF key verification failed" exit 1 fi } # Fix permissions fix_permissions() { log_info "Fixing VRF key permissions..." chmod 0600 ~/.sonr/vrf_secret.key log_info "Permissions set to 0600" } # Main migration flow main() { log_info "Starting VRF key migration..." log_info "Chain ID: $CHAIN_ID" # Backup backup_validator # Generate keys generate_vrf # Fix permissions fix_permissions # Verify verify_vrf log_info "Migration completed successfully!" log_info "Please restart your validator node" } # Run migration main ``` Save and run: ```bash chmod +x vrf-migration.sh CHAIN_ID="sonrtest_1-1" ./vrf-migration.sh ```