Files
proxmox/docs/SMART_CONTRACT_CONNECTIONS_AND_NEXT_LXCS.md

454 lines
12 KiB
Markdown

# Smart Contract Connections & Next LXC Containers
**Date**: $(date)
**Purpose**: Overview of smart contract connections required and list of next LXC containers to deploy
---
## 🔗 Smart Contract Connections Required
### 1. RPC Endpoint Connections
All services that interact with smart contracts need to connect to Besu RPC endpoints:
#### Primary RPC Endpoints
- **HTTP RPC**: `http://192.168.11.250:8545` (or load-balanced endpoint)
- **WebSocket RPC**: `ws://192.168.11.250:8546`
- **Chain ID**: 138
#### RPC Node IPs (Current Deployment)
| VMID | Hostname | IP Address | RPC Port | WS Port |
|------|----------|------------|----------|---------|
| 2500 | besu-rpc-1 | 192.168.11.250 | 8545 | 8546 |
| 2501 | besu-rpc-2 | 192.168.11.251 | 8545 | 8546 |
| 2502 | besu-rpc-3 | 192.168.11.252 | 8545 | 8546 |
**Note**: Services should use load-balanced endpoint or connect to multiple RPC nodes for redundancy.
---
### 2. Services Requiring Smart Contract Connections
#### 2.1 Oracle Publisher Service
**VMID**: 3500
**IP**: 192.168.11.68
**Status**: ⏳ Pending Deployment
**Required Connections**:
- **RPC Endpoint**: `RPC_URL_138=http://192.168.11.250:8545`
- **WebSocket**: `WS_URL_138=ws://192.168.11.250:8546`
- **Oracle Contract Address**: (To be configured after deployment)
- **Private Key**: (For signing transactions)
- **Data Sources**: External price feed APIs
**Configuration File**: `/opt/oracle-publisher/.env`
```bash
RPC_URL_138=http://192.168.11.250:8545
WS_URL_138=ws://192.168.11.250:8546
ORACLE_CONTRACT_ADDRESS=
PRIVATE_KEY=
UPDATE_INTERVAL=60
METRICS_PORT=8000
```
**Smart Contract Interactions**:
- Read oracle contract state
- Submit price updates via transactions
- Monitor contract events
---
#### 2.2 CCIP Monitor Service
**VMID**: 3501
**IP**: 192.168.11.69
**Status**: ⏳ Pending Deployment
**Required Connections**:
- **RPC Endpoint**: `RPC_URL_138=http://192.168.11.250:8545`
- **CCIP Router Contract**: (Chainlink CCIP router address)
- **CCIP Sender Contract**: (Sender contract address)
- **LINK Token Contract**: (LINK token address on Chain 138)
**Configuration File**: `/opt/ccip-monitor/.env`
```bash
RPC_URL_138=http://192.168.11.250:8545
CCIP_ROUTER_ADDRESS=
CCIP_SENDER_ADDRESS=
LINK_TOKEN_ADDRESS=
METRICS_PORT=8000
CHECK_INTERVAL=60
ALERT_WEBHOOK=
```
**Smart Contract Interactions**:
- Monitor CCIP router contract events
- Track cross-chain message flow
- Monitor LINK token transfers
- Alert on failures
---
#### 2.3 Price Feed Keeper Service
**VMID**: 3502
**IP**: 192.168.11.70
**Status**: ⏳ Pending Deployment
**Required Connections**:
- **RPC Endpoint**: `RPC_URL_138=http://192.168.11.250:8545`
- **Keeper Contract Address**: (Automation contract)
- **Oracle Contract Address**: (Oracle to trigger updates)
- **Private Key**: (For executing keeper transactions)
**Configuration File**: `/opt/keeper/.env`
```bash
RPC_URL_138=http://192.168.11.250:8545
KEEPER_CONTRACT_ADDRESS=
ORACLE_CONTRACT_ADDRESS=
PRIVATE_KEY=
UPDATE_INTERVAL=300
HEALTH_PORT=3000
```
**Smart Contract Interactions**:
- Check keeper contract for upkeep needed
- Execute upkeep transactions
- Monitor oracle contract state
- Trigger price feed updates
---
#### 2.4 Financial Tokenization Service
**VMID**: 3503
**IP**: 192.168.11.71
**Status**: ⏳ Pending Deployment
**Required Connections**:
- **RPC Endpoint**: `BESU_RPC_URL=http://192.168.11.250:8545`
- **Tokenization Contract Address**: (Tokenization smart contract)
- **ERC-20/ERC-721 Contracts**: (Token contracts)
- **Private Key**: (For tokenization operations)
**Configuration File**: `/opt/financial-tokenization/.env`
```bash
BESU_RPC_URL=http://192.168.11.250:8545
TOKENIZATION_CONTRACT_ADDRESS=
PRIVATE_KEY=
CHAIN_ID=138
```
**Smart Contract Interactions**:
- Deploy token contracts
- Mint/burn tokens
- Transfer tokens
- Query token balances
- Manage token metadata
---
#### 2.5 Hyperledger Firefly
**VMID**: 6200
**IP**: 192.168.11.66
**Status**: ✅ Ready (needs RPC configuration)
**Required Connections**:
- **RPC Endpoint**: `FF_BLOCKCHAIN_RPC=http://192.168.11.250:8545`
- **WebSocket**: `FF_BLOCKCHAIN_WS=ws://192.168.11.250:8546`
**Configuration File**: `/opt/firefly/docker-compose.yml`
```yaml
environment:
- FF_BLOCKCHAIN_RPC=http://192.168.11.250:8545
- FF_BLOCKCHAIN_WS=ws://192.168.11.250:8546
- FF_CHAIN_ID=138
```
**Smart Contract Interactions**:
- Deploy Firefly contracts
- Tokenization operations
- Multi-party workflows
- Event streaming
---
#### 2.6 Hyperledger Cacti
**VMID**: 5200
**IP**: 192.168.11.64
**Status**: ✅ Ready (needs RPC configuration)
**Required Connections**:
- **RPC Endpoint**: `BESU_RPC_URL=http://192.168.11.250:8545`
- **WebSocket**: `BESU_WS_URL=ws://192.168.11.250:8546`
**Configuration File**: `/opt/cacti/docker-compose.yml`
```yaml
environment:
- BESU_RPC_URL=http://192.168.11.250:8545
- BESU_WS_URL=ws://192.168.11.250:8546
```
**Smart Contract Interactions**:
- Cross-chain contract calls
- Besu ledger connector operations
- Multi-ledger integration
---
#### 2.7 Blockscout Explorer
**VMID**: 5000
**IP**: 192.168.11.140
**Status**: ⏳ Pending Deployment
**Required Connections**:
- **RPC Endpoint**: `ETHEREUM_JSONRPC_HTTP_URL=http://192.168.11.250:8545`
- **Trace RPC**: `ETHEREUM_JSONRPC_TRACE_URL=http://192.168.11.250:8545`
**Configuration File**: `/opt/blockscout/docker-compose.yml`
```yaml
environment:
- ETHEREUM_JSONRPC_HTTP_URL=http://192.168.11.250:8545
- ETHEREUM_JSONRPC_TRACE_URL=http://192.168.11.250:8545
- ETHEREUM_JSONRPC_WS_URL=ws://192.168.11.250:8546
```
**Smart Contract Interactions**:
- Index all contract interactions
- Verify contract source code
- Track token transfers
- Display transaction history
---
## 📦 Next LXC Containers to Deploy
### Priority 1: Smart Contract Services (High Priority)
| VMID | Hostname | IP Address | Service | Status | Priority |
|------|----------|------------|---------|--------|----------|
| 3500 | oracle-publisher-1 | 192.168.11.68 | Oracle Publisher | ⏳ Pending | P1 - High |
| 3501 | ccip-monitor-1 | 192.168.11.69 | CCIP Monitor | ⏳ Pending | P1 - High |
| 3502 | keeper-1 | 192.168.11.70 | Price Feed Keeper | ⏳ Pending | P1 - High |
| 3503 | financial-tokenization-1 | 192.168.11.71 | Financial Tokenization | ⏳ Pending | P2 - Medium |
**Total**: 4 containers
---
### Priority 2: Hyperledger Services (Ready for Deployment)
| VMID | Hostname | IP Address | Service | Status | Priority |
|------|----------|------------|---------|--------|----------|
| 5200 | cacti-1 | 192.168.11.64 | Hyperledger Cacti | ✅ Ready | P1 - High |
| 6000 | fabric-1 | 192.168.11.65 | Hyperledger Fabric | ✅ Ready | P2 - Medium |
| 6200 | firefly-1 | 192.168.11.66 | Hyperledger Firefly | ✅ Ready | P1 - High |
| 6400 | indy-1 | 192.168.11.67 | Hyperledger Indy | ✅ Ready | P2 - Medium |
**Total**: 4 containers
**Note**: These are ready but need RPC endpoint configuration after deployment.
---
### Priority 3: Monitoring Stack (High Priority)
| VMID | Hostname | IP Address | Service | Status | Priority |
|------|----------|------------|---------|--------|----------|
| 3504 | monitoring-stack-1 | 192.168.11.80 | Prometheus | ⏳ Pending | P1 - High |
| 3505 | monitoring-stack-2 | 192.168.11.81 | Grafana | ⏳ Pending | P1 - High |
| 3506 | monitoring-stack-3 | 192.168.11.82 | Loki | ⏳ Pending | P2 - Medium |
| 3507 | monitoring-stack-4 | 192.168.11.83 | Alertmanager | ⏳ Pending | P2 - Medium |
| 3508 | monitoring-stack-5 | 192.168.11.84 | Additional monitoring | ⏳ Pending | P2 - Medium |
**Total**: 5 containers
---
### Priority 4: Explorer (Medium Priority)
| VMID | Hostname | IP Address | Service | Status | Priority |
|------|----------|------------|---------|--------|----------|
| 5000 | blockscout-1 | 192.168.11.140 | Blockscout Explorer | ⏳ Pending | P2 - Medium |
**Total**: 1 container
---
## 📊 Summary
### Total Containers to Deploy Next
**By Priority**:
- **P1 (High)**: 7 containers
- Oracle Publisher (3500)
- CCIP Monitor (3501)
- Keeper (3502)
- Cacti (5200)
- Firefly (6200)
- Prometheus (3504)
- Grafana (3505)
- **P2 (Medium)**: 7 containers
- Financial Tokenization (3503)
- Fabric (6000)
- Indy (6400)
- Loki (3506)
- Alertmanager (3507)
- Monitoring Stack 5 (3508)
- Blockscout (5000)
**Grand Total**: **14 containers** ready for deployment
---
## 🚀 Deployment Commands
### Deploy Smart Contract Services
```bash
cd /opt/smom-dbis-138-proxmox
DEPLOY_ORACLE=true DEPLOY_CCIP_MONITOR=true DEPLOY_KEEPER=true DEPLOY_TOKENIZATION=true \
./scripts/deployment/deploy-services.sh
```
### Deploy Hyperledger Services
```bash
cd /opt/smom-dbis-138-proxmox
./scripts/deployment/deploy-hyperledger-services.sh
```
### Deploy Monitoring Stack
```bash
cd /opt/smom-dbis-138-proxmox
./scripts/deployment/deploy-monitoring.sh
```
### Deploy Explorer
```bash
cd /opt/smom-dbis-138-proxmox
./scripts/deployment/deploy-explorer.sh
```
### Deploy Everything
```bash
cd /opt/smom-dbis-138-proxmox
./deploy-all.sh
```
---
## ⚙️ Post-Deployment Configuration
After deploying containers, configure RPC connections:
### 1. Configure Oracle Publisher
```bash
pct exec 3500 -- bash -c "cat > /opt/oracle-publisher/.env <<EOF
RPC_URL_138=http://192.168.11.250:8545
WS_URL_138=ws://192.168.11.250:8546
ORACLE_CONTRACT_ADDRESS=<deploy-oracle-contract-first>
PRIVATE_KEY=<oracle-private-key>
UPDATE_INTERVAL=60
METRICS_PORT=8000
EOF"
```
### 2. Configure CCIP Monitor
```bash
pct exec 3501 -- bash -c "cat > /opt/ccip-monitor/.env <<EOF
RPC_URL_138=http://192.168.11.250:8545
CCIP_ROUTER_ADDRESS=<ccip-router-address>
CCIP_SENDER_ADDRESS=<ccip-sender-address>
LINK_TOKEN_ADDRESS=<link-token-address>
METRICS_PORT=8000
CHECK_INTERVAL=60
EOF"
```
### 3. Configure Keeper
```bash
pct exec 3502 -- bash -c "cat > /opt/keeper/.env <<EOF
RPC_URL_138=http://192.168.11.250:8545
KEEPER_CONTRACT_ADDRESS=<keeper-contract-address>
ORACLE_CONTRACT_ADDRESS=<oracle-contract-address>
PRIVATE_KEY=<keeper-private-key>
UPDATE_INTERVAL=300
EOF"
```
### 4. Configure Financial Tokenization
```bash
pct exec 3503 -- bash -c "cat > /opt/financial-tokenization/.env <<EOF
BESU_RPC_URL=http://192.168.11.250:8545
TOKENIZATION_CONTRACT_ADDRESS=<tokenization-contract-address>
PRIVATE_KEY=<tokenization-private-key>
CHAIN_ID=138
EOF"
```
### 5. Configure Hyperledger Services
```bash
# Firefly
pct exec 6200 -- bash -c "cd /opt/firefly && \
sed -i 's|FF_BLOCKCHAIN_RPC=.*|FF_BLOCKCHAIN_RPC=http://192.168.11.250:8545|' docker-compose.yml && \
sed -i 's|FF_BLOCKCHAIN_WS=.*|FF_BLOCKCHAIN_WS=ws://192.168.11.250:8546|' docker-compose.yml"
# Cacti
pct exec 5200 -- bash -c "cd /opt/cacti && \
sed -i 's|BESU_RPC_URL=.*|BESU_RPC_URL=http://192.168.11.250:8545|' docker-compose.yml && \
sed -i 's|BESU_WS_URL=.*|BESU_WS_URL=ws://192.168.11.250:8546|' docker-compose.yml"
```
### 6. Configure Blockscout
```bash
pct exec 5000 -- bash -c "cd /opt/blockscout && \
sed -i 's|ETHEREUM_JSONRPC_HTTP_URL=.*|ETHEREUM_JSONRPC_HTTP_URL=http://192.168.11.250:8545|' docker-compose.yml && \
sed -i 's|ETHEREUM_JSONRPC_TRACE_URL=.*|ETHEREUM_JSONRPC_TRACE_URL=http://192.168.11.250:8545|' docker-compose.yml"
```
---
## 📝 Notes
1. **Contract Addresses**: Smart contract addresses need to be deployed first before configuring services
2. **Private Keys**: Store private keys securely (use secrets management)
3. **RPC Load Balancing**: Consider using a load balancer for RPC endpoints
4. **Network Access**: Ensure all containers can reach RPC nodes (192.168.11.250-252)
5. **Firewall**: Configure firewall rules to allow RPC connections between containers
---
## 🔍 Verification
After configuration, verify connections:
```bash
# Test RPC connection from service container
pct exec 3500 -- curl -X POST http://192.168.11.250:8545 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
# Check service logs
pct exec 3500 -- journalctl -u oracle-publisher -f
# Verify WebSocket connection
pct exec 3500 -- python3 -c "
import asyncio
import websockets
async def test():
async with websockets.connect('ws://192.168.11.250:8546') as ws:
await ws.send('{\"jsonrpc\":\"2.0\",\"method\":\"eth_subscribe\",\"params\":[\"newHeads\"],\"id\":1}')
print(await ws.recv())
asyncio.run(test())
"
```
---
**Next Steps**:
1. Deploy Priority 1 containers (Oracle, CCIP Monitor, Keeper)
2. Deploy and configure Hyperledger services
3. Deploy monitoring stack
4. Deploy explorer
5. Configure all RPC connections
6. Deploy smart contracts
7. Update service configurations with contract addresses