# Next Steps Execution Guide

**Date**: 2025-01-12  
**Status**: Ready for Execution

---

## Overview

This guide provides step-by-step instructions for executing the remaining runtime tasks to complete the CCIP setup.

---

## Current Status

### ✅ Completed
- All verification scripts created
- All documentation created
- System health checks available
- Configuration scripts ready

### ⏳ Pending (Critical Blockers)

1. **Bridge Destination Configuration** (Tasks 3, 50, 51)
   - Status: 0/7 destinations configured for both bridges
   - Blocker: Requires private key and transaction execution

2. **Stuck Transaction Resolution** (Task 4)
   - Status: Transaction may be stuck in mempool
   - Action: Resolve before configuring destinations

3. **Fee Calculation Fix** (Task 61)
   - Status: Fee calculation not accessible
   - Action: Debug and fix

---

## Step-by-Step Execution

### Step 1: Resolve Stuck Transaction (Task 4)

**If you have a stuck transaction:**

```bash
# Check transaction status
./scripts/resolve-stuck-transaction.sh <address> <nonce>

# Options:
# 1. Wait for timeout (1-2 hours)
# 2. Replace with higher gas price
# 3. Use different account
```

**If no stuck transaction:**
- Proceed to Step 2

---

### Step 2: Configure Bridge Destinations (Tasks 3, 50, 51)

#### Option A: Configure Ethereum Mainnet Only

```bash
# Configure Ethereum Mainnet for both bridges
./scripts/configure-ethereum-mainnet-destination.sh <private_key>
```

#### Option B: Configure All Destinations

```bash
# Configure all 7 destinations (including Ethereum Mainnet)
./scripts/configure-all-bridge-destinations.sh <private_key> \
  0x2A0840e5117683b11682ac46f5CF5621E67269E3 \
  0xb7721dD53A8c629d9f1Ba31a5819AFe250002b03
```

**Verify Configuration:**
```bash
./scripts/check-bridge-config.sh
```

**Expected Result:**
- All 7 destinations configured for WETH9 Bridge
- All 7 destinations configured for WETH10 Bridge

---

### Step 3: Verify Configuration (Tasks 107, 108)

```bash
# Comprehensive verification
./scripts/verify-complete-ccip-setup.sh

# Health check
./scripts/ccip-health-check.sh

# Generate status report
./scripts/generate-ccip-status-report.sh
```

---

### Step 4: Start CCIP Monitor Service (Task 83)

**On Proxmox Host:**

```bash
# Start container
pct start 3501

# Start service
pct exec 3501 -- systemctl start ccip-monitor

# Enable on boot
pct exec 3501 -- systemctl enable ccip-monitor

# Verify
./scripts/check-ccip-monitor-health.sh
```

**Verify Service:**
```bash
# Check status
pct exec 3501 -- systemctl status ccip-monitor

# Check metrics
curl http://localhost:8000/metrics

# Check logs
pct exec 3501 -- journalctl -u ccip-monitor -n 50
```

---

### Step 5: Test Bridge Operations (Tasks 115, 116)

#### Pre-flight Check

```bash
# Run end-to-end test (dry run)
./scripts/test-end-to-end-bridge.sh 0.001
```

#### Execute Test Bridge

```bash
# Bridge small amount to Ethereum Mainnet
./scripts/wrap-and-bridge-to-ethereum.sh 0.001
```

**Verify on Destination:**
- Check Ethereum Mainnet for received tokens
- Verify message execution
- Confirm token amount

---

### Step 6: Fix Fee Calculation (Task 61)

**Debug Fee Calculation:**
```bash
# Test fee calculation
./scripts/verify-fee-calculation.sh 0.001 5009297550715157269

# Check Router functions
cast call 0x8078A09637e47Fa5Ed34F626046Ea2094a5CDE5e "getFeeToken()" --rpc-url http://192.168.11.250:8545
```

**If Fee Calculation Fails:**
1. Check Router contract ABI
2. Verify function signatures
3. Check LINK token availability
4. Update scripts as needed

---

### Step 7: Verify Token Pool Configuration (Tasks 19-21, 28-29)

```bash
# Find TokenAdminRegistry
./scripts/verify-token-admin-registry.sh

# If pool addresses found, verify pools
./scripts/verify-token-pool-config.sh <pool_address>
```

**Note**: Pool addresses may need to be retrieved from:
- Deployment transactions
- Contract storage
- Chainlink documentation

---

## Additional Tasks

### Oracle Network Deployment (Tasks 72-76)

**Only if CCIP message processing is needed:**

1. **Deploy Commit Oracle Nodes** (16 nodes, VMIDs 5410-5425)
2. **Deploy Execute Oracle Nodes** (16 nodes, VMIDs 5440-5455)
3. **Deploy RMN Nodes** (5-7 nodes, VMIDs 5470-5474 or 5470-5476)
4. **Deploy Ops/Admin Nodes** (2 nodes, VMIDs 5400-5401)
5. **Deploy Monitoring Nodes** (2 nodes, VMIDs 5402-5403)

**Note**: This is a major deployment task. Only proceed if oracle network is required for CCIP message processing.

---

### Message Indexing Implementation (Tasks 91-93)

**If message tracking is needed:**

1. Complete implementation in `backend/ccip/tracking/tracker.go`
2. Index MessageSent events from source chain
3. Index MessageExecuted events from destination chains
4. Link events by messageId

---

## Verification Checklist

After completing steps above, verify:

- [ ] All bridge destinations configured (7/7)
- [ ] CCIP Monitor service running
- [ ] Fee calculation working
- [ ] Bridge operations tested successfully
- [ ] Token pool configuration verified
- [ ] System health checks passing

**Run comprehensive verification:**
```bash
./scripts/verify-complete-ccip-setup.sh
```

---

## Troubleshooting

### Bridge Configuration Fails

**Issue**: Transaction fails or gets stuck

**Solutions**:
1. Check nonce: `cast nonce <address> --rpc-url <rpc_url>`
2. Increase gas price
3. Wait for previous transactions to clear
4. Use different account

### Fee Calculation Fails

**Issue**: Cannot calculate fees

**Solutions**:
1. Verify Router contract address
2. Check function availability
3. Verify LINK token configuration
4. Check RPC connectivity

### CCIP Monitor Not Starting

**Issue**: Service fails to start

**Solutions**:
1. Check container status: `pct status 3501`
2. Check service logs: `pct exec 3501 -- journalctl -u ccip-monitor -n 50`
3. Verify configuration: `/opt/ccip-monitor/.env`
4. Check RPC connectivity from container

---

## Quick Reference

### Essential Commands

```bash
# Health check
./scripts/ccip-health-check.sh

# Bridge configuration
./scripts/check-bridge-config.sh

# Configure Ethereum Mainnet
./scripts/configure-ethereum-mainnet-destination.sh <private_key>

# Comprehensive verification
./scripts/verify-complete-ccip-setup.sh

# Generate status report
./scripts/generate-ccip-status-report.sh
```

### Documentation

- **Operations**: `docs/CCIP_OPERATIONS_RUNBOOK.md`
- **Best Practices**: `docs/CCIP_BEST_PRACTICES.md`
- **Security**: `docs/CCIP_SECURITY_BEST_PRACTICES.md`
- **Verification**: `docs/CCIP_VERIFICATION_CHECKLIST.md`

---

## Success Criteria

System is fully operational when:

1. ✅ All 7 bridge destinations configured
2. ✅ CCIP Monitor service running
3. ✅ Bridge operations tested successfully
4. ✅ Fee calculation working
5. ✅ All health checks passing
6. ✅ End-to-end bridge flow verified

---

**Last Updated**: 2025-01-12

