4NK_node/archive/docs/RESUME_AJOUT_DEV3.md
Nicolas Cantu b935cbab20 Réorganisation complète : tests, documentation et nettoyage
- Réorganisation des tests par catégorie (unit, integration, connectivity, external)
- Création de scripts d'exécution automatisés pour les tests
- Création de guides techniques complets (ARCHITECTURE.md, API.md)
- Transfert des informations depuis specs/ vers docs/
- Nettoyage et archivage des fichiers obsolètes
- Documentation complète des tests avec exemples
- Scripts de maintenance et nettoyage automatique
- Structure professionnelle prête pour l'évolution
2025-08-25 14:13:26 +02:00

14 KiB

Résumé : Ajout du Relais dev3.4nkweb.com

🎯 Objectif

Ajouter le relais externe dev3.4nkweb.com à l'infrastructure 4NK Node pour étendre le réseau de relais.

Actions Réalisées

1. Découverte du relais

  • URL : dev3.4nkweb.com
  • Port : 443 (HTTPS/WSS)
  • Chemin WebSocket : /ws/
  • URL complète : wss://dev3.4nkweb.com:443/ws/

2. Tests de connectivité

# Test HTTPS de base
curl -v https://dev3.4nkweb.com:443
# ✅ Réponse : Page HTML 4NK Web5

# Test WebSocket
curl -v -H "Connection: Upgrade" -H "Upgrade: websocket" \
     -H "Sec-WebSocket-Key: test" -H "Sec-WebSocket-Version: 13" \
     https://dev3.4nkweb.com:443/ws/
# ✅ Réponse : 101 Switching Protocols

3. Tests Python

# Test simple
python3 test_dev3_simple.py
# ✅ Connexion WSS établie
# ⚠️ Limitations de taille de message

# Test complet
python3 test_dev3_connectivity.py
# ✅ Connexion WSS établie
# ❌ Messages trop gros pour la synchronisation

4. Configuration

# external_nodes.conf
[relays]
dev3-relay = "dev3.4nkweb.com:443"

🚀 ARRÊT ET REDÉMARRAGE COMPLET DE 4NK_NODE

Date : $(date)

Motif : Redémarrage propre pour intégrer dev3.4nkweb.com

1. Arrêt de tous les services

# Arrêt de tous les conteneurs
docker stop $(docker ps -q) 2>/dev/null || true

# Arrêt de docker-compose
docker-compose down -v 2>/dev/null || true

# Vérification qu'aucun conteneur ne tourne
docker ps
# Output: (vide - aucun conteneur en cours)

2. Nettoyage complet

# Suppression de tous les conteneurs
docker rm -f $(docker ps -aq) 2>/dev/null || true
# Output: 38b00bb9a73d, 82832dff9e65, 27eb26cf34de, dcc0733ff65a, cf89e4d5d99a, 8f5815486a1d

# Nettoyage des réseaux
docker network prune -f
# Output: Deleted Networks: 4nk_node_btcnet

3. Création du réseau

# Création du réseau Docker
docker network create 4nk_node_btcnet
# Output: 5242f77defc3539b050defd7e1a144e1e066b28010ae97ad6b4e4a1eb553bfe7

4. Démarrage dans l'ordre logique

4.1 Tor Proxy

docker run -d --name tor-proxy --network 4nk_node_btcnet --network-alias tor \
  -p 9050:9050 -p 9051:9051 dperson/torproxy:latest
# Output: b2ae583570d4435cd5dcc41f44df8ff33445d4bf2bcbbfcdee0e0a239e7c3a28
# Status: Up 9 seconds (health: starting)

4.2 Bitcoin Core

docker run -d --name bitcoin-signet --network 4nk_node_btcnet --network-alias bitcoin \
  -p 38333:38333 -p 18443:18443 -p 29000:29000 \
  -v bitcoin_data:/home/bitcoin/.bitcoin \
  -v /home/desk/Téléchargements/code/4NK/4NK_node/bitcoin/bitcoin.conf:/home/bitcoin/.bitcoin/bitcoin.conf \
  4nk_node_bitcoin
# Output: 166a88e6817ecd680a41cf4a0a34b654df19fdd15ed408a53338ebb5bf4bbb98
# Status: Up 17 seconds

4.3 Blindbit Oracle

docker run -d --name blindbit-oracle --network 4nk_node_btcnet --network-alias blindbit \
  -p 8000:8000 \
  -v blindbit_data:/data \
  -v /home/desk/Téléchargements/code/4NK/4NK_node/blindbit/blindbit.toml:/data/blindbit.toml \
  -v bitcoin_data:/home/bitcoin/.bitcoin \
  4nk_node_blindbit
# Output: 34e41782e0633b140be2c2c330a1a769a6d1359938e1e5ea71b63153ab518422
# Status: Up 16 seconds

4.4 Construction de l'image sdk_relay

# Construction de l'image avec les dernières modifications
docker build -f sdk_relay/Dockerfile -t 4nk_node_sdk_relay_1 ..
# Output: Successfully built 70c4624704d3
# Output: Successfully tagged 4nk_node_sdk_relay_1:latest
# Temps: 43.55s (compilation Rust)

4.5 Relay 1

docker run -d --name sdk_relay_1 --network 4nk_node_btcnet --network-alias sdk_relay_1 \
  -p 8090:8090 -p 8091:8091 \
  -v bitcoin_data:/home/bitcoin/.bitcoin \
  -v /home/desk/Téléchargements/code/4NK/4NK_node/bitcoin/bitcoin.conf:/home/bitcoin/.bitcoin/bitcoin.conf \
  -v sdk_relay_1_data:/home/bitcoin/.4nk \
  -v /home/desk/Téléchargements/code/4NK/4NK_node/sdk_relay/.conf.docker.relay1:/home/bitcoin/.conf.docker \
  -e RUST_LOG=debug,bitcoincore_rpc=trace \
  -e HOME=/home/bitcoin \
  -e BITCOIN_COOKIE_PATH=/home/bitcoin/.bitcoin/signet/.cookie \
  -e ENABLE_SYNC_TEST=1 \
  4nk_node_sdk_relay_1 \
  /bin/sh -c "cp /home/bitcoin/.conf.docker /home/bitcoin/.conf && cp /home/bitcoin/.bitcoin/signet/.cookie /home/bitcoin/.4nk/bitcoin.cookie && chmod 600 /home/bitcoin/.4nk/bitcoin.cookie && /usr/local/bin/sdk_relay --config .conf"
# Output: 2f8b0dd684e18cc2850a74238d673b012b29d875106ba5c94d08d8d17ea7d933
# Status: Up 18 seconds

4.6 Relay 2

docker run -d --name sdk_relay_2 --network 4nk_node_btcnet --network-alias sdk_relay_2 \
  -p 8092:8090 -p 8093:8091 \
  -v bitcoin_data:/home/bitcoin/.bitcoin \
  -v /home/desk/Téléchargements/code/4NK/4NK_node/bitcoin/bitcoin.conf:/home/bitcoin/.bitcoin/bitcoin.conf \
  -v sdk_relay_2_data:/home/bitcoin/.4nk \
  -v /home/desk/Téléchargements/code/4NK/4NK_node/sdk_relay/.conf.docker.relay2:/home/bitcoin/.conf.docker \
  -e RUST_LOG=debug,bitcoincore_rpc=trace \
  -e HOME=/home/bitcoin \
  -e BITCOIN_COOKIE_PATH=/home/bitcoin/.bitcoin/signet/.cookie \
  -e ENABLE_SYNC_TEST=1 \
  4nk_node_sdk_relay_1 \
  /bin/sh -c "cp /home/bitcoin/.conf.docker /home/bitcoin/.conf && cp /home/bitcoin/.bitcoin/signet/.cookie /home/bitcoin/.4nk/bitcoin.cookie && chmod 600 /home/bitcoin/.4nk/bitcoin.cookie && /usr/local/bin/sdk_relay --config .conf"
# Output: e8f2907a4ba38424787fd90427aa7f1ccf0d6fb5eb0f7dc434a0d6a0d9d1494f
# Status: Up 16 seconds

4.7 Relay 3

docker run -d --name sdk_relay_3 --network 4nk_node_btcnet --network-alias sdk_relay_3 \
  -p 8094:8090 -p 8095:8091 \
  -v bitcoin_data:/home/bitcoin/.bitcoin \
  -v /home/desk/Téléchargements/code/4NK/4NK_node/bitcoin/bitcoin.conf:/home/bitcoin/.bitcoin/bitcoin.conf \
  -v sdk_relay_3_data:/home/bitcoin/.4nk \
  -v /home/desk/Téléchargements/code/4NK/4NK_node/sdk_relay/.conf.docker.relay3:/home/bitcoin/.conf.docker \
  -e RUST_LOG=debug,bitcoincore_rpc=trace \
  -e HOME=/home/bitcoin \
  -e BITCOIN_COOKIE_PATH=/home/bitcoin/.bitcoin/signet/.cookie \
  -e ENABLE_SYNC_TEST=1 \
  4nk_node_sdk_relay_1 \
  /bin/sh -c "cp /home/bitcoin/.conf.docker /home/bitcoin/.conf && cp /home/bitcoin/.bitcoin/signet/.cookie /home/bitcoin/.4nk/bitcoin.cookie && chmod 600 /home/bitcoin/.4nk/bitcoin.cookie && /usr/local/bin/sdk_relay --config .conf"
# Output: e969cb2ead8151e74dfd3cd8eabddcedac551c2a52f0377a182c3ffe15305b90
# Status: Up 15 seconds

5. État final des services

docker ps
# Output:
# CONTAINER ID   IMAGE                     COMMAND                  CREATED              STATUS                   PORTS                         NAMES
# e969cb2ead81   4nk_node_sdk_relay_1      "/bin/sh -c 'cp /hom…"   21 seconds ago       Up 20 seconds            0.0.0.0:8094->8090/tcp, :::8094->8090/tcp, 0.0.0.0:8095->8091/tcp, :::8095->8091/tcp                         sdk_relay_3
# e8f2907a4ba3   4nk_node_sdk_relay_1      "/bin/sh -c 'cp /hom…"   46 seconds ago       Up 45 seconds            0.0.0.0:8092->8090/tcp, :::8092->8090/tcp, 0.0.0.0:8093->8091/tcp, :::8093->8091/tcp                         sdk_relay_2
# 2f8b0dd684e1   4nk_node_sdk_relay_1      "/bin/sh -c 'cp /hom…"   About a minute ago   Up About a minute        0.0.0.0:8090-8091->8090-8091/tcp, :::8090-8091->8090-8091/tcp                         sdk_relay_1
# 34e41782e063   4nk_node_blindbit         "blindbit-oracle -da…"   3 minutes ago        Up 3 minutes             0.0.0.0:8000->8000/tcp, :::8000->8000/tcp                         blindbit-oracle
# 166a88e6817e   4nk_node_bitcoin          "bitcoind -conf=/hom…"   3 minutes ago        Up 3 minutes             0.0.0.0:18443->18443/tcp, :::18443->18443/tcp, 0.0.0.0:29000->29000/tcp, :::29000->29000/tcp, 0.0.0.0:38333->38333/tcp, :::38333->38333/tcp, 38332/tcp   bitcoin-signet
# b2ae583570d4   dperson/torproxy:latest   "/sbin/tini -- /usr/…"   3 minutes ago        Up 3 minutes (healthy)   8118/tcp, 0.0.0.0:9050-9051->9050-9051/tcp, :::9050-9051->9050-9051/tcp                         tor-proxy

6. Ports exposés

Service Ports Internes Ports Externes Statut
Tor 9050, 9051 9050, 9051 Healthy
Bitcoin 38333, 18443, 29000 38333, 18443, 29000 Running
Blindbit 8000 8000 Running
Relay 1 8090, 8091 8090, 8091 Running
Relay 2 8090, 8091 8092, 8093 Running
Relay 3 8090, 8091 8094, 8095 Running

7. Volumes persistants

Volume Contenu Utilisé par
bitcoin_data Données Bitcoin Core Bitcoin, Blindbit, Relays
blindbit_data Données Blindbit Blindbit
sdk_relay_1_data Données Relay 1 Relay 1
sdk_relay_2_data Données Relay 2 Relay 2
sdk_relay_3_data Données Relay 3 Relay 3

8. Configuration des relais

Chaque relay utilise sa propre configuration :

  • Relay 1 : .conf.docker.relay1relay_id = "relay-1"
  • Relay 2 : .conf.docker.relay2relay_id = "relay-2"
  • Relay 3 : .conf.docker.relay3relay_id = "relay-3"

9. Variables d'environnement communes

RUST_LOG=debug,bitcoincore_rpc=trace
HOME=/home/bitcoin
BITCOIN_COOKIE_PATH=/home/bitcoin/.bitcoin/signet/.cookie
ENABLE_SYNC_TEST=1

10. Commandes de démarrage automatiques

Chaque relay exécute automatiquement :

cp /home/bitcoin/.conf.docker /home/bitcoin/.conf
cp /home/bitcoin/.bitcoin/signet/.cookie /home/bitcoin/.4nk/bitcoin.cookie
chmod 600 /home/bitcoin/.4nk/bitcoin.cookie
/usr/local/bin/sdk_relay --config .conf

📊 Résultats des Tests

Connectivité

  • HTTPS : Accessible
  • WSS : Accessible sur /ws/
  • SSL : Certificat Let's Encrypt valide
  • Protocole : TLSv1.3

⚠️ Limitations Découvertes

  • Taille des messages : Limitée (erreur "message too big")
  • Synchronisation : Non supportée (ancienne version)
  • Handshake : Format ancien uniquement

🔧 Compatibilité

  • Ancienne version : Compatible
  • Nouvelle version : Messages trop gros
  • Synchronisation : Non supportée

🛠️ Outils Créés

1. Script de test simple

  • Fichier : test_dev3_simple.py
  • Fonction : Test de connectivité avec messages courts
  • Usage : python3 test_dev3_simple.py

2. Script de test complet

  • Fichier : test_dev3_connectivity.py
  • Fonction : Test de compatibilité ancienne/nouvelle version
  • Usage : python3 test_dev3_connectivity.py

3. Documentation de configuration

  • Fichier : CONFIGURATION_DEV3.md
  • Contenu : Guide complet d'utilisation et de dépannage

🚀 Utilisation

Connexion WebSocket

// Connexion JavaScript
const ws = new WebSocket('wss://dev3.4nkweb.com:443/ws/');

ws.onopen = function() {
    // Handshake simple (ancienne version)
    const handshake = {
        type: 'handshake',
        client_id: 'test-client',
        version: '0.9.0'
    };
    ws.send(JSON.stringify(handshake));
};

Connexion Python

import asyncio
import websockets
import json
import ssl

async def connect_to_dev3():
    uri = "wss://dev3.4nkweb.com:443/ws/"

    ssl_context = ssl.create_default_context()
    ssl_context.check_hostname = False
    ssl_context.verify_mode = ssl.CERT_NONE

    async with websockets.connect(uri, ssl=ssl_context) as websocket:
        handshake = {
            "type": "handshake",
            "client_id": "python-client",
            "version": "0.9.0"
        }
        await websocket.send(json.dumps(handshake))

asyncio.run(connect_to_dev3())

📈 État Actuel

Configuration Active

# Liste des nœuds externes
./add_external_node.sh list
# Output:
#   🔸 external-relay-2 -> localhost:8090
#   🔸 dev3-relay -> dev3.4nkweb.com:443

Tests de Validation

# Test de connectivité
./add_external_node.sh test dev3-relay
# ✅ Port 443 accessible sur dev3.4nkweb.com
# ✅ WebSocket répond
# ✅ Connectivité OK

🔄 Prochaines Étapes

1. Intégration dans le code

Pour que les relais locaux utilisent dev3.4nkweb.com, il faut :

// Modifier sync.rs pour charger external_nodes.conf
impl SyncManager {
    pub fn load_external_config(&self) -> Result<ExternalConfig> {
        let config_content = fs::read_to_string("external_nodes.conf")?;
        let config: ExternalConfig = toml::from_str(&config_content)?;
        Ok(config)
    }
}

2. Redémarrage des relais

# Appliquer la configuration
docker-compose restart sdk_relay_1 sdk_relay_2 sdk_relay_3

3. Tests de synchronisation

# Tester la synchronisation avec dev3
./test_sync_logs.sh test

⚠️ Limitations Actuelles

1. Synchronisation

  • Le relais dev3.4nkweb.com ne supporte pas la synchronisation
  • Messages de sync trop gros pour l'ancienne version
  • Nécessite une mise à jour du relais

2. Messages

  • Limitation de taille des messages
  • Format ancien uniquement
  • Pas de support des nouveaux protocoles

3. Compatibilité

  • Compatible avec l'ancienne version
  • Incompatible avec la nouvelle version
  • Nécessite adaptation des messages

🎯 Recommandations

1. Utilisation immédiate

  • Utiliser pour les connexions basiques
  • Compatible avec l'ancienne version
  • ⚠️ Éviter les messages de synchronisation

2. Amélioration future

  • 🔄 Mettre à jour le relais dev3.4nkweb.com
  • 🔄 Supprimer les limitations de taille
  • 🔄 Ajouter le support de la synchronisation

3. Monitoring

  • 📊 Surveiller la connectivité
  • 📊 Tester régulièrement
  • 📊 Documenter les changements

📝 Conclusion

Le relais dev3.4nkweb.com a été ajouté avec succès à la configuration externe. Il est :

  • Accessible en WSS sur le port 443
  • Fonctionnel pour les connexions basiques
  • ⚠️ Limité par l'ancienne version
  • 🔄 Prêt pour une future mise à jour

La configuration est maintenant prête pour l'intégration dans le code et les tests de synchronisation !

L'infrastructure 4NK Node est maintenant complètement redémarrée et opérationnelle avec :

  • 6 services en cours d'exécution
  • 3 relais configurés pour la synchronisation
  • Configuration externe prête pour dev3.4nkweb.com
  • Tous les ports correctement exposés
  • Volumes persistants préservés