Files
smom-dbis-138/docs/NEXT_STEPS_COMPLETE_GUIDE.md

935 lines
24 KiB
Markdown
Raw Normal View History

2025-12-12 14:56:07 -08:00
# Complete Next Steps Guide - Phase 2 & Smart Contract Deployment
## Overview
This guide provides comprehensive next steps for completing the DeFi Oracle Meta Mainnet (ChainID 138) deployment, including Phase 2 infrastructure deployment and all smart contract deployments.
**⚡ Full Parallel Mode**: All operations run in parallel where possible for maximum speed (~3-4x faster)
**🔧 .env Integration**: All configuration uses `.env` file - single source of truth, no duplication
---
## Quick Start (Full Parallel)
```bash
# 1. Ensure .env is configured
source .env
# 2. Deploy everything in parallel (fastest)
./scripts/deployment/deploy-phase2-and-contracts-parallel.sh
# Or step-by-step parallel:
./scripts/deployment/generate-phase2-tfvars.sh
cd terraform/phases/phase2 && terraform apply
./terraform/phases/phase2/scripts/start-services.sh all
source .env && ./scripts/deployment/deploy-contracts-parallel.sh
./scripts/deployment/verify-contracts-parallel.sh
```
**Estimated Time**: ~10-15 minutes (vs ~40 minutes sequential)
---
## Table of Contents
1. [Phase 2 Deployment Completion](#phase-2-deployment-completion) - All regions parallel
2. [Prerequisites for Contract Deployment](#prerequisites-for-contract-deployment) - .env configuration
3. [Smart Contract Deployment Sequence](#smart-contract-deployment-sequence) - Full parallel mode
4. [Configuration & Integration](#configuration--integration) - Automated via .env
5. [Testing & Verification](#testing--verification) - Parallel verification
6. [Production Readiness Checklist](#production-readiness-checklist)
7. [Complete Parallel Deployment](#complete-parallel-deployment-all-in-one) - Master script
---
## Phase 2 Deployment Completion
### Prerequisites: Load .env Configuration
**Important**: All configuration is managed through `.env` file. Ensure you have a `.env` file in the project root with required variables:
```bash
# Load .env if not already loaded
cd /home/intlc/projects/smom-dbis-138
source .env # or: set -a && source .env && set +a
# Required variables (add to .env if missing):
# ENVIRONMENT=prod
# VM_ADMIN_USERNAME=besuadmin
# SSH_PRIVATE_KEY_PATH=/path/to/ssh/private/key
```
### Step 1: Verify Phase 1 Completion
```bash
cd terraform/phases/phase1
terraform output phase1_us_regions
terraform output ssh_connection_strings
```
**Expected Output**: 5 regions (centralus, eastus, eastus2, westus, westus2) with VM information.
### Step 2: Generate Phase 2 Configuration (Automated)
**Use the helper script to generate `terraform.tfvars` from Phase 1 outputs and `.env`:**
```bash
# This script reads .env and Phase 1 outputs, generates terraform.tfvars automatically
./scripts/deployment/generate-phase2-tfvars.sh
# Review generated file
cat terraform/phases/phase2/terraform.tfvars
```
**Manual alternative** (if script fails):
Ensure your `.env` has these variables, then create `terraform/phases/phase2/terraform.tfvars` manually:
```hcl
environment = "${ENVIRONMENT:-prod}"
vm_admin_username = "${VM_ADMIN_USERNAME:-besuadmin}"
ssh_private_key_path = "${SSH_PRIVATE_KEY_PATH}"
# Phase 1 VM information - get from: terraform/phases/phase1/terraform output -json phase1_us_regions
phase1_vm_info = {
# ... (paste output from Phase 1)
}
```
### Step 3: Deploy Phase 2 Docker Compose Files (Parallel)
**Terraform deploys to all 5 regions in parallel automatically:**
```bash
cd terraform/phases/phase2
terraform init
terraform plan
terraform apply
# All regions deploy concurrently - no sequential steps needed
```
### Step 4: Start Phase 2 Services (Full Parallel)
**All regions start simultaneously - script handles parallelization automatically:**
```bash
cd terraform/phases/phase2/scripts
# Start all regions in parallel (automatically parallelized)
./start-services.sh all
# Script automatically:
# - Starts all 5 regions simultaneously
# - Waits for all to complete
# - Reports success/failure for each region
# - Exits with error if any region fails
```
### Step 5: Verify Phase 2 Deployment (Full Parallel)
**All regions checked simultaneously with organized output:**
```bash
cd terraform/phases/phase2/scripts
# Check all regions in parallel (automatically parallelized)
./status.sh all
# Script automatically:
# - Checks all 5 regions simultaneously
# - Collects output from each region
# - Displays results in order
# - Cleans up temporary files
```
**Expected**: All docker-compose services running (Besu, FireFly, Cacti, Chainlink, databases, monitoring) across all 5 regions.
---
## Prerequisites for Contract Deployment
### 1. Environment Setup
**Ensure `.env` file exists in project root** (created/updated from Phase 2 setup):
```bash
# Load .env
cd /home/intlc/projects/smom-dbis-138
source .env
# Required variables in .env:
# RPC Configuration
RPC_URL=http://<besu-rpc-node>:8545
CHAIN_ID=138
# Deployer Configuration
PRIVATE_KEY=<your_deployer_private_key>
DEPLOYER_ADDRESS=<your_deployer_address> # Optional: auto-calculated from PRIVATE_KEY
# CCIP Configuration (required for bridges)
CCIP_ROUTER=<ccip_router_address_or_leave_empty_to_deploy>
CCIP_FEE_TOKEN=<link_token_address_or_zero_address_for_native> # Use 0x0000000000000000000000000000000000000000 for native
# Oracle Configuration
ORACLE_DESCRIPTION="ETH/USD Price Feed"
ORACLE_HEARTBEAT=60
ORACLE_DEVIATION_THRESHOLD=50
# Deployment Flags
DEPLOY_WETH9=true
DEPLOY_WETH10=true
DEPLOY_BRIDGES=true
# MultiSig Configuration (optional)
MULTISIG_OWNERS=<comma_separated_owner_addresses> # e.g., "0x123...,0x456...,0x789..."
```
**All deployment scripts automatically load `.env`** - no need to manually export variables.
### 2. Fund Deployer Address
Ensure your deployer address has sufficient native tokens (ETH) for:
- Contract deployment gas costs
- CCIP fees (if using native token)
- Initial contract setup transactions
**Estimated Costs**: ~0.1-0.5 ETH for complete deployment
### 3. Verify RPC Connection
```bash
# Test RPC endpoint
curl -X POST $RPC_URL \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
```
### 4. Compile Contracts
```bash
forge build
forge test # Run tests before deployment
```
---
## Smart Contract Deployment Sequence
### Deployment Order (Critical - Must Follow This Sequence)
```
1. CCIP Router (if deploying custom)
2. LINK Token (if deploying, or use existing/zero address)
3. Multicall
4. CREATE2 Factory
5. WETH9
6. WETH10
7. CCIPWETH9Bridge
8. CCIPWETH10Bridge
9. Oracle Aggregator
10. Oracle Proxy
11. MultiSig (Governance)
12. CCIP Sender/Receiver (if needed)
```
### Method 1: Parallel Automated Deployment (Recommended)
**Use the parallel deployment script** (faster than sequential):
```bash
cd /home/intlc/projects/smom-dbis-138
source .env # Ensure .env is loaded
# Parallel deployment (deploys independent contracts simultaneously)
./scripts/deployment/deploy-contracts-parallel.sh
```
This script:
- **Phase 1**: Deploys independent contracts in parallel (Multicall, WETH9, WETH10 simultaneously)
- **Phase 2**: Deploys CCIP Router (if needed)
- **Phase 3**: Deploys bridge contracts in parallel (CCIPWETH9Bridge, CCIPWETH10Bridge simultaneously)
- **Phase 4**: Deploys Oracle and MultiSig in parallel (independent contracts)
- Automatically updates `.env` with deployed addresses
- Handles dependencies between contracts
- Provides deployment summary
**Performance**: ~3-4x faster than sequential deployment (all independent operations run simultaneously).
### Method 1b: Sequential Automated Deployment (Alternative)
If you prefer sequential deployment or encounter parallel execution issues:
```bash
cd /home/intlc/projects/smom-dbis-138
source .env # Ensure .env is loaded
# Sequential deployment (safer, slower)
./scripts/deployment/deploy-contracts-ordered.sh
```
This script:
- Deploys all contracts in correct order (one at a time)
- Automatically updates `.env` with deployed addresses
- Handles dependencies between contracts
- Provides deployment summary
### Method 2: Manual Step-by-Step Deployment
#### Step 1: Load Environment
```bash
cd /home/intlc/projects/smom-dbis-138
source .env # Load all variables from .env
```
#### Step 2: Deploy Independent Contracts in Parallel
**Deploy Multicall, WETH9, and WETH10 simultaneously** (they have no dependencies):
```bash
# Parallel deployment of independent contracts
forge script script/DeployMulticall.s.sol:DeployMulticall \
--rpc-url "$RPC_URL" \
--broadcast \
--private-key "$PRIVATE_KEY" \
--verify &
MULTICALL_PID=$!
forge script script/DeployWETH.s.sol:DeployWETH \
--rpc-url "$RPC_URL" \
--broadcast \
--private-key "$PRIVATE_KEY" \
--verify &
WETH9_PID=$!
forge script script/DeployWETH10.s.sol:DeployWETH10 \
--rpc-url "$RPC_URL" \
--broadcast \
--private-key "$PRIVATE_KEY" \
--verify &
WETH10_PID=$!
# Wait for all to complete
wait $MULTICALL_PID
wait $WETH9_PID
wait $WETH10_PID
# Extract addresses and update .env (scripts handle this automatically)
source .env # Reload to get new addresses
```
#### Step 3: Deploy CCIP Router (if needed)
```bash
# If deploying custom CCIP Router
if [ -z "$CCIP_ROUTER" ] || [ "$CCIP_ROUTER" = "0x0000000000000000000000000000000000000000" ]; then
forge script script/DeployCCIPRouter.s.sol:DeployCCIPRouter \
--sig "run(address,uint256,uint256)" \
"${CCIP_FEE_TOKEN:-0x0000000000000000000000000000000000000000}" \
"1000000000000000" \
"1000000000" \
--rpc-url "$RPC_URL" \
--broadcast \
--private-key "$PRIVATE_KEY" \
--verify
# Update .env with deployed address (use deploy script's auto-update feature)
fi
source .env # Reload
```
**Note**: If using Chainlink's official CCIP Router, set `CCIP_ROUTER` in `.env` to the official address.
#### Step 4: Deploy CCIP Bridges in Parallel
**Deploy both bridges simultaneously** (they depend on CCIP_ROUTER and WETH addresses):
```bash
# Ensure dependencies are in .env
source .env
# Parallel bridge deployment
forge script script/DeployCCIPWETH9Bridge.s.sol:DeployCCIPWETH9Bridge \
--rpc-url "$RPC_URL" \
--broadcast \
--private-key "$PRIVATE_KEY" \
--verify &
BRIDGE9_PID=$!
forge script script/DeployCCIPWETH10Bridge.s.sol:DeployCCIPWETH10Bridge \
--rpc-url "$RPC_URL" \
--broadcast \
--private-key "$PRIVATE_KEY" \
--verify &
BRIDGE10_PID=$!
wait $BRIDGE9_PID
wait $BRIDGE10_PID
source .env # Reload addresses
```
#### Step 5: Deploy Oracle and MultiSig in Parallel
**Deploy Oracle and MultiSig simultaneously** (they are independent):
```bash
source .env
# Deploy Oracle and MultiSig in parallel
forge script script/DeployOracle.s.sol:DeployOracle \
--rpc-url "$RPC_URL" \
--broadcast \
--private-key "$PRIVATE_KEY" \
--verify &
ORACLE_PID=$!
if [ -n "$MULTISIG_OWNERS" ]; then
forge script script/DeployMultiSig.s.sol:DeployMultiSig \
--rpc-url "$RPC_URL" \
--broadcast \
--private-key "$PRIVATE_KEY" \
--verify &
MULTISIG_PID=$!
wait $ORACLE_PID $MULTISIG_PID
else
echo "⚠️ MULTISIG_OWNERS not set in .env. Skipping MultiSig deployment."
wait $ORACLE_PID
fi
source .env # Reload addresses
```
#### Step 7: Deploy CCIP Sender/Receiver (if needed)
```bash
source .env
# If deploying custom CCIP endpoints
forge script script/DeployCCIPSender.s.sol:DeployCCIPSender \
--rpc-url "$RPC_URL" \
--broadcast \
--private-key "$PRIVATE_KEY" \
--verify
```
**Note**: All addresses are automatically saved to `.env` by the deployment scripts. Manual `.env` updates are only needed if using raw `forge script` commands.
### Method 3: Individual Contract Scripts
For deploying single contracts (can run multiple in parallel manually):
```bash
# Load .env first
source .env
# WETH9 only
make deploy-weth
# or
./scripts/deployment/deploy-weth.sh
# WETH10 only
make deploy-weth10
# or
./scripts/deployment/deploy-weth10.sh
# Deploy multiple contracts in parallel manually:
make deploy-weth &
make deploy-weth10 &
wait
# All WETH contracts with CCIP bridges (uses parallel internally where possible)
make deploy-weth-ccip
# or
./scripts/deployment/deploy-weth-with-ccip.sh
# Individual bridges (can deploy in parallel)
make deploy-ccip-weth9-bridge &
make deploy-ccip-weth10-bridge &
wait
```
---
## Configuration & Integration
### 1. Configure CCIP Bridges
After deploying bridges, configure them:
```bash
# Configure WETH9 Bridge
./scripts/deployment/configure-weth9-bridge.sh
# Configure WETH10 Bridge
./scripts/deployment/configure-weth10-bridge.sh
```
**Configuration includes**:
- Setting trusted destination chains
- Configuring fee tokens
- Setting up cross-chain message routing
- Whitelisting approved senders/receivers
### 2. Initialize Oracle
```bash
# Set up price feed
cast send $ORACLE_PROXY_ADDRESS \
"submit(uint256)" \
<price_in_wei> \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY
# Example: Submit $2000 ETH/USD price (2000 * 10^8 = 200000000000)
cast send $ORACLE_PROXY_ADDRESS \
"submit(uint256)" \
200000000000 \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY
```
### 3. Configure MultiSig
```bash
# Add owners
cast send $MULTISIG_ADDRESS \
"addOwner(address)" \
<owner_address> \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY
# Set threshold (e.g., 2 of 3)
cast send $MULTISIG_ADDRESS \
"changeThreshold(uint256)" \
2 \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY
```
### 4. Integrate with FireFly
Update FireFly configuration to use deployed contracts:
```yaml
# FireFly configuration
smart_contracts:
weth9: "<WETH9_ADDRESS>"
weth10: "<WETH10_ADDRESS>"
oracle: "<ORACLE_PROXY_ADDRESS>"
multisig: "<MULTISIG_ADDRESS>"
```
### 5. Configure Chainlink CCIP
If using Chainlink CCIP nodes, configure them:
```bash
# Update Chainlink node configuration
# Point to deployed CCIP Router
# Configure fee tokens
# Set up destination chains
```
---
## Testing & Verification
### 1. Verify Contract Deployments (Parallel)
**Use parallel verification for faster results:**
```bash
# Load .env first
source .env
# Verify all contracts in parallel (recommended - fastest)
./scripts/deployment/verify-contracts-parallel.sh
# Sequential verification (alternative)
./scripts/deployment/verify-on-chain-deployments.sh
# Check specific contracts (can run in parallel manually)
cast code "$WETH9_ADDRESS" --rpc-url "$RPC_URL" &
cast code "$WETH10_ADDRESS" --rpc-url "$RPC_URL" &
cast code "$CCIPWETH9BRIDGE_ADDRESS" --rpc-url "$RPC_URL" &
wait
```
### 2. Test WETH Contracts
```bash
# Test WETH9 deposit
cast send $WETH9_ADDRESS \
"deposit()" \
--value 1ether \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY
# Test WETH9 withdrawal
cast send $WETH9_ADDRESS \
"withdraw(uint256)" \
1ether \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY
```
### 3. Test CCIP Bridges
```bash
# Test cross-chain WETH9 transfer
# (Requires destination chain configuration)
cast send $CCIPWETH9BRIDGE_ADDRESS \
"bridgeTokens(uint256,uint64,bytes)" \
<amount> \
<destination_chain_selector> \
<recipient_address_bytes> \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY \
--value <ccip_fee>
```
### 4. Test Oracle
```bash
# Read latest price
cast call $ORACLE_PROXY_ADDRESS \
"latestRoundData()" \
--rpc-url $RPC_URL
# Submit price update
cast send $ORACLE_PROXY_ADDRESS \
"submit(uint256)" \
<price> \
--rpc-url $RPC_URL \
--private-key $PRIVATE_KEY
```
### 5. End-to-End Testing
```bash
# Run comprehensive tests
forge test --fork-url $RPC_URL -vvv
# Run integration tests
npm test # If TypeScript/JavaScript tests exist
```
### 6. Monitor Contract Events
```bash
# Watch for deployment events
cast logs --from-block 0 \
--address $WETH9_ADDRESS \
--rpc-url $RPC_URL
# Watch CCIP bridge events
cast logs --from-block 0 \
--address $CCIPWETH9BRIDGE_ADDRESS \
--rpc-url $RPC_URL
```
---
## Production Readiness Checklist
### Infrastructure ✅
- [ ] Phase 1 VMs deployed and accessible
- [ ] Phase 2 docker-compose services running
- [ ] All 5 regions operational (cus, eus, eus2, wus, wus2)
- [ ] Network connectivity verified
- [ ] Monitoring stack operational (Prometheus, Grafana, Loki)
- [ ] Logging operational (Promtail shipping logs)
### Smart Contracts ✅
- [ ] All contracts deployed
- [ ] Contract addresses saved to `.env`
- [ ] Contract source code verified (if applicable)
- [ ] CCIP Router configured
- [ ] WETH9 & WETH10 deployed and tested
- [ ] CCIP bridges deployed and configured
- [ ] Oracle deployed and receiving price updates
- [ ] MultiSig deployed and configured
- [ ] All contract permissions set correctly
### Integration ✅
- [ ] FireFly configured with contract addresses
- [ ] Cacti configured for cross-chain monitoring
- [ ] Chainlink nodes configured (if applicable)
- [ ] Cross-chain routes configured
- [ ] Fee tokens configured
### Security ✅
- [ ] Private keys secured (use Key Vault)
- [ ] MultiSig owners configured
- [ ] Access control verified
- [ ] Security audit completed (if applicable)
- [ ] Emergency pause mechanisms tested
### Monitoring & Observability ✅
- [ ] Prometheus scraping metrics
- [ ] Grafana dashboards configured
- [ ] Alerts configured in Alertmanager
- [ ] Logs centralized in Loki
- [ ] Contract event monitoring set up
### Documentation ✅
- [ ] Contract addresses documented
- [ ] Deployment process documented
- [ ] Configuration documented
- [ ] Operations runbooks created
- [ ] API documentation updated
### Testing ✅
- [ ] Unit tests passing
- [ ] Integration tests passing
- [ ] End-to-end tests passing
- [ ] Load testing completed
- [ ] Security testing completed
---
## Quick Reference Commands
### Phase 2 Management
```bash
# Generate Phase 2 config from Phase 1 outputs and .env
./scripts/deployment/generate-phase2-tfvars.sh
# Deploy Phase 2 (all regions in parallel)
cd terraform/phases/phase2 && terraform apply
# Start services (all regions in parallel)
./terraform/phases/phase2/scripts/start-services.sh all
# Stop services (all regions in parallel)
./terraform/phases/phase2/scripts/stop-services.sh all
# Check status (all regions in parallel)
./terraform/phases/phase2/scripts/status.sh all
```
### Contract Deployment
```bash
# Load .env first
source .env
# Parallel deployment (recommended - fastest)
./scripts/deployment/deploy-contracts-parallel.sh
# Sequential deployment (alternative)
./scripts/deployment/deploy-contracts-ordered.sh
# Individual contracts (can run multiple in parallel manually)
make deploy-weth &
make deploy-weth10 &
wait
make deploy-weth-ccip
./scripts/deployment/deploy-multicall.sh
./scripts/deployment/deploy-multisig.sh
```
### Verification
```bash
# Load .env first
source .env
# Verify deployments in parallel (recommended - fastest)
./scripts/deployment/verify-contracts-parallel.sh
# Sequential verification (alternative)
./scripts/deployment/verify-on-chain-deployments.sh
./scripts/deployment/verify-deployment.sh
# Check contract code in parallel (uses .env RPC_URL)
cast code "$WETH9_ADDRESS" --rpc-url "$RPC_URL" &
cast code "$WETH10_ADDRESS" --rpc-url "$RPC_URL" &
cast code "$CCIPWETH9BRIDGE_ADDRESS" --rpc-url "$RPC_URL" &
wait
```
### Testing
```bash
# Load .env first
source .env
# Run tests (uses .env RPC_URL)
forge test
forge test --fork-url "$RPC_URL"
# Integration tests
npm test
# Run tests in parallel (faster)
forge test --fork-url "$RPC_URL" -j $(nproc)
```
---
## Troubleshooting
### Environment Configuration
**Problem**: Variables not found / scripts fail with "not set" errors
**Solution**:
- Ensure `.env` file exists in project root: `ls -la .env`
- Load `.env` before running scripts: `source .env`
- Check variables are set: `grep PRIVATE_KEY .env`
- Use helper script to generate Phase 2 config: `./scripts/deployment/generate-phase2-tfvars.sh`
**Problem**: Duplicate variable definitions
**Solution**:
- **All configuration should be in `.env` only** - don't duplicate in scripts or command line
- Remove hardcoded values from scripts
- Use `${VAR:-default}` syntax for optional variables
- Scripts automatically load `.env` - don't manually export variables
### Phase 2 Issues
**Problem**: Cannot SSH to VMs
**Solution**:
- Verify VPN/ExpressRoute/Cloudflare Tunnel connectivity
- Check NSG rules allow SSH from your IP
- Verify `SSH_PRIVATE_KEY_PATH` in `.env`: `grep SSH_PRIVATE_KEY_PATH .env`
- Regenerate terraform.tfvars: `./scripts/deployment/generate-phase2-tfvars.sh`
**Problem**: Docker compose services not starting
**Solution**:
- Check logs: `docker compose logs` on VM
- Verify volumes exist: `ls -la /opt/*`
- Check permissions: `sudo chown -R besuadmin:besuadmin /opt/*`
- All regions deploy in parallel - check individual region: `./status.sh <region>`
### Contract Deployment Issues
**Problem**: Deployment fails with "insufficient funds"
**Solution**: Fund deployer address with native tokens
**Problem**: CCIP Router deployment fails
**Solution**:
- Verify `CCIP_FEE_TOKEN` in `.env`: `grep CCIP_FEE_TOKEN .env`
- Use zero address for native token: `CCIP_FEE_TOKEN=0x0000000000000000000000000000000000000000`
- Check fee parameters (baseFee, dataFeePerByte) in deployment script
- Reload `.env`: `source .env`
**Problem**: Bridge deployment fails
**Solution**:
- Verify `CCIP_ROUTER` is set in `.env`: `grep CCIP_ROUTER .env`
- Ensure `WETH9_ADDRESS` and `WETH10_ADDRESS` are in `.env`: `grep WETH.*ADDRESS .env`
- Check `CCIP_FEE_TOKEN` configuration in `.env`
- Deploy dependencies first (use parallel script which handles order automatically)
**Problem**: Parallel deployment failures
**Solution**:
- Check individual contract deployments sequentially first
- Verify `.env` has all required addresses before parallel bridge deployment
- Use sequential script if parallel fails: `./scripts/deployment/deploy-contracts-ordered.sh`
---
## Support & Resources
- **Documentation**: `docs/` directory
- **Terraform Phase 1**: `terraform/phases/phase1/README.md`
- **Terraform Phase 2**: `terraform/phases/phase2/README.md`
- **Contract Documentation**: `contracts/README.md`
- **Deployment Scripts**: `scripts/deployment/README.md`
- **Environment Configuration**: `.env` file (create from `.env.example` if exists)
## Key Points: Using .env & Full Parallel Mode
1. **Single Source of Truth**: All configuration is in `.env` - no duplication
2. **Automatic Loading**: All scripts automatically `source .env`
3. **Auto-Updates**: Deployment scripts automatically update `.env` with deployed addresses
4. **Full Parallel Execution**: All independent operations run simultaneously:
- Phase 2: All 5 regions deploy/start/stop/check in parallel
- Contracts: Independent contracts deploy in parallel (Multicall, WETH9, WETH10, Oracle, MultiSig)
- Bridges: Both bridge contracts deploy in parallel
- Verification: All contracts verified in parallel
- Testing: Forge tests use parallel execution (`-j $(nproc)`)
5. **No Manual Exports**: Don't manually export variables - scripts handle it
6. **Performance**: ~3-4x faster than sequential execution
### Quick .env Checklist
```bash
# Required variables
grep -E "^(PRIVATE_KEY|RPC_URL|CHAIN_ID|SSH_PRIVATE_KEY_PATH)=" .env
# Optional but recommended
grep -E "^(CCIP_ROUTER|CCIP_FEE_TOKEN|MULTISIG_OWNERS|ENVIRONMENT|VM_ADMIN_USERNAME)=" .env
# Verify .env is valid
source .env && echo "✅ .env loaded successfully"
```
---
---
## Complete Parallel Deployment (All-in-One)
### Master Script: Deploy Phase 2 + Contracts in Parallel
**For the fastest deployment, use the master parallel script:**
```bash
cd /home/intlc/projects/smom-dbis-138
source .env # Ensure .env is loaded
# Deploy Phase 2 and contracts in full parallel mode
./scripts/deployment/deploy-phase2-and-contracts-parallel.sh
```
This script:
- Generates Phase 2 configuration from Phase 1 outputs and .env
- Deploys Phase 2 docker-compose to all 5 regions in parallel
- Starts Phase 2 services in parallel (all regions)
- Deploys all contracts in parallel (independent contracts simultaneously)
- Verifies both Phase 2 and contracts in parallel
**Performance**: Complete deployment in ~10-15 minutes (vs ~40 minutes sequential)
### Individual Parallel Operations
If you prefer step-by-step control:
```bash
# 1. Generate Phase 2 config (reads .env + Phase 1)
./scripts/deployment/generate-phase2-tfvars.sh
# 2. Deploy Phase 2 (all regions parallel)
cd terraform/phases/phase2 && terraform apply
# 3. Start services (all regions parallel)
./terraform/phases/phase2/scripts/start-services.sh all
# 4. Deploy contracts (parallel where possible)
source .env && ./scripts/deployment/deploy-contracts-parallel.sh
# 5. Verify everything (parallel)
./terraform/phases/phase2/scripts/status.sh all &
source .env && ./scripts/deployment/verify-contracts-parallel.sh &
wait
```
---
**Last Updated**: $(date)
**Status**: Complete Deployment Guide with Full Parallel Execution & .env Integration