287 lines
6.3 KiB
Markdown
287 lines
6.3 KiB
Markdown
# Validator Deployment Guide - ChainID 138
|
|
|
|
**Date**: 2025-01-12
|
|
**Purpose**: Guide for deploying contracts via validator nodes when RPC deployment fails
|
|
|
|
---
|
|
|
|
## Overview
|
|
|
|
Validator nodes typically have full network permissions and may be able to deploy contracts even when RPC nodes cannot. This guide explains how to deploy contracts via validator nodes.
|
|
|
|
---
|
|
|
|
## Prerequisites
|
|
|
|
1. **Validator Node Access**
|
|
- SSH access to validator node
|
|
- Validator node IP: 192.168.11.100-104
|
|
- Validator VMID: 1000-1004
|
|
|
|
2. **Network Configuration**
|
|
- ChainID: 138
|
|
- RPC Endpoint: (validator node)
|
|
- Deployer Account: (with sufficient balance)
|
|
|
|
3. **Required Tools**
|
|
- Foundry (forge, cast)
|
|
- SSH access
|
|
- Contract source code
|
|
|
|
---
|
|
|
|
## Step-by-Step Deployment
|
|
|
|
### Step 1: Access Validator Node
|
|
|
|
```bash
|
|
# SSH into validator node
|
|
ssh root@192.168.11.100
|
|
|
|
# Or via Proxmox
|
|
pct enter 1000
|
|
```
|
|
|
|
### Step 2: Verify Validator Status
|
|
|
|
```bash
|
|
# Check Besu service status
|
|
systemctl status besu-validator
|
|
|
|
# Check if validator is synced
|
|
cast block-number --rpc-url http://localhost:8545
|
|
|
|
# Verify chain ID
|
|
cast chain-id --rpc-url http://localhost:8545
|
|
```
|
|
|
|
### Step 3: Prepare Deployment Environment
|
|
|
|
```bash
|
|
# Create deployment directory
|
|
mkdir -p /tmp/contract-deployment
|
|
cd /tmp/contract-deployment
|
|
|
|
# Initialize Foundry project
|
|
forge init --no-git --force .
|
|
|
|
# Copy contract source
|
|
# (Copy MockLinkToken.sol to src/MockLinkToken.sol)
|
|
```
|
|
|
|
### Step 4: Configure Deployment
|
|
|
|
```bash
|
|
# Set environment variables
|
|
export RPC_URL="http://localhost:8545"
|
|
export PRIVATE_KEY="<your-deployer-private-key>"
|
|
export GAS_PRICE="20000000000" # 20 gwei
|
|
export GAS_LIMIT="10000000" # 10M gas
|
|
```
|
|
|
|
### Step 5: Deploy Contract
|
|
|
|
#### Method 1: Using forge create
|
|
|
|
```bash
|
|
forge create src/MockLinkToken.sol:MockLinkToken \
|
|
--rpc-url "$RPC_URL" \
|
|
--private-key "$PRIVATE_KEY" \
|
|
--gas-price "$GAS_PRICE" \
|
|
--gas-limit "$GAS_LIMIT" \
|
|
--legacy \
|
|
--broadcast
|
|
```
|
|
|
|
#### Method 2: Using forge script
|
|
|
|
```bash
|
|
# Create deployment script
|
|
cat > script/DeployMockLinkToken.s.sol << 'EOF'
|
|
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.19;
|
|
|
|
import {Script} from "forge-std/Script.sol";
|
|
import {MockLinkToken} from "../src/MockLinkToken.sol";
|
|
|
|
contract DeployMockLinkToken is Script {
|
|
function run() external returns (MockLinkToken) {
|
|
vm.startBroadcast();
|
|
MockLinkToken token = new MockLinkToken();
|
|
vm.stopBroadcast();
|
|
return token;
|
|
}
|
|
}
|
|
EOF
|
|
|
|
# Deploy
|
|
forge script script/DeployMockLinkToken.s.sol:DeployMockLinkToken \
|
|
--rpc-url "$RPC_URL" \
|
|
--private-key "$PRIVATE_KEY" \
|
|
--broadcast \
|
|
--gas-price "$GAS_PRICE" \
|
|
--gas-limit "$GAS_LIMIT" \
|
|
--legacy
|
|
```
|
|
|
|
### Step 6: Verify Deployment
|
|
|
|
```bash
|
|
# Get deployed contract address from output
|
|
CONTRACT_ADDRESS="<deployed-address>"
|
|
|
|
# Verify contract exists
|
|
cast code "$CONTRACT_ADDRESS" --rpc-url "$RPC_URL"
|
|
|
|
# Test contract functions
|
|
cast call "$CONTRACT_ADDRESS" "name()" --rpc-url "$RPC_URL"
|
|
cast call "$CONTRACT_ADDRESS" "symbol()" --rpc-url "$RPC_URL"
|
|
cast call "$CONTRACT_ADDRESS" "totalSupply()" --rpc-url "$RPC_URL"
|
|
```
|
|
|
|
---
|
|
|
|
## Alternative: Direct Validator Deployment Script
|
|
|
|
Create a deployment script that can be run on validator nodes:
|
|
|
|
```bash
|
|
#!/usr/bin/env bash
|
|
# Deploy MockLinkToken on Validator Node
|
|
|
|
set -euo pipefail
|
|
|
|
RPC_URL="${1:-http://localhost:8545}"
|
|
PRIVATE_KEY="${2:-}"
|
|
GAS_PRICE="${3:-20000000000}"
|
|
GAS_LIMIT="${4:-10000000}"
|
|
|
|
if [ -z "$PRIVATE_KEY" ]; then
|
|
echo "Error: PRIVATE_KEY not provided"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Deploying MockLinkToken..."
|
|
echo "RPC: $RPC_URL"
|
|
echo "Gas Price: $GAS_PRICE"
|
|
echo "Gas Limit: $GAS_LIMIT"
|
|
echo ""
|
|
|
|
# Deploy
|
|
DEPLOY_OUTPUT=$(forge create src/MockLinkToken.sol:MockLinkToken \
|
|
--rpc-url "$RPC_URL" \
|
|
--private-key "$PRIVATE_KEY" \
|
|
--gas-price "$GAS_PRICE" \
|
|
--gas-limit "$GAS_LIMIT" \
|
|
--legacy \
|
|
--broadcast 2>&1)
|
|
|
|
echo "$DEPLOY_OUTPUT"
|
|
|
|
# Extract contract address
|
|
CONTRACT_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE "Deployed to: 0x[0-9a-fA-F]{40}" | awk '{print $3}' || echo "")
|
|
|
|
if [ -n "$CONTRACT_ADDRESS" ]; then
|
|
echo ""
|
|
echo "✅ Contract deployed: $CONTRACT_ADDRESS"
|
|
echo ""
|
|
echo "Verifying deployment..."
|
|
CODE=$(cast code "$CONTRACT_ADDRESS" --rpc-url "$RPC_URL" 2>/dev/null || echo "")
|
|
if [ -n "$CODE" ] && [ "$CODE" != "0x" ] && [ ${#CODE} -gt 100 ]; then
|
|
echo "✅ Contract verified on-chain"
|
|
else
|
|
echo "⚠️ Contract not found on-chain"
|
|
fi
|
|
else
|
|
echo "❌ Deployment failed"
|
|
exit 1
|
|
fi
|
|
```
|
|
|
|
---
|
|
|
|
## Troubleshooting
|
|
|
|
### Issue: Cannot Access Validator Node
|
|
|
|
**Solution**:
|
|
- Verify SSH access is configured
|
|
- Check Proxmox container status
|
|
- Ensure network connectivity
|
|
|
|
### Issue: Validator Not Synced
|
|
|
|
**Solution**:
|
|
- Wait for validator to sync
|
|
- Check validator logs: `journalctl -u besu-validator -f`
|
|
- Verify validator is producing blocks
|
|
|
|
### Issue: Deployment Still Fails
|
|
|
|
**Solution**:
|
|
- Check validator logs for errors
|
|
- Verify deployer account has sufficient balance
|
|
- Try with different gas settings
|
|
- Check if validator has deployment permissions
|
|
|
|
---
|
|
|
|
## Security Considerations
|
|
|
|
1. **Validator Access**
|
|
- Validator nodes are critical infrastructure
|
|
- Only authorized personnel should access
|
|
- Follow network security policies
|
|
|
|
2. **Private Key Security**
|
|
- Never store private keys on validator nodes
|
|
- Use secure key management
|
|
- Rotate keys regularly
|
|
|
|
3. **Deployment Verification**
|
|
- Always verify deployed contracts
|
|
- Check contract bytecode matches source
|
|
- Test contract functions after deployment
|
|
|
|
---
|
|
|
|
## Network Administrator Contact
|
|
|
|
If validator deployment also fails:
|
|
|
|
1. **Contact Network Administrators**
|
|
- Provide deployment logs
|
|
- Share diagnostic report
|
|
- Request investigation
|
|
|
|
2. **Request Manual Deployment**
|
|
- Provide contract bytecode
|
|
- Request network administrator to deploy
|
|
- Verify deployment after completion
|
|
|
|
---
|
|
|
|
## Next Steps
|
|
|
|
After successful deployment:
|
|
|
|
1. **Update Configuration**
|
|
- Update `.env` with contract address
|
|
- Update CCIP configuration
|
|
- Update token lists
|
|
|
|
2. **Verify Integration**
|
|
- Test contract with CCIP bridge
|
|
- Verify token transfers work
|
|
- Check event emissions
|
|
|
|
3. **Document Deployment**
|
|
- Record deployment details
|
|
- Update deployment documentation
|
|
- Share with team
|
|
|
|
---
|
|
|
|
**Last Updated**: 2025-01-12
|
|
|