Add Oracle Aggregator and CCIP Integration
- Introduced Aggregator.sol for Chainlink-compatible oracle functionality, including round-based updates and access control. - Added OracleWithCCIP.sol to extend Aggregator with CCIP cross-chain messaging capabilities. - Created .gitmodules to include OpenZeppelin contracts as a submodule. - Developed a comprehensive deployment guide in NEXT_STEPS_COMPLETE_GUIDE.md for Phase 2 and smart contract deployment. - Implemented Vite configuration for the orchestration portal, supporting both Vue and React frameworks. - Added server-side logic for the Multi-Cloud Orchestration Portal, including API endpoints for environment management and monitoring. - Created scripts for resource import and usage validation across non-US regions. - Added tests for CCIP error handling and integration to ensure robust functionality. - Included various new files and directories for the orchestration portal and deployment scripts.
This commit is contained in:
115
docs/ccip-integration/DEPLOYMENT_GUIDE.md
Normal file
115
docs/ccip-integration/DEPLOYMENT_GUIDE.md
Normal file
@@ -0,0 +1,115 @@
|
||||
# CCIP Integration Deployment Guide
|
||||
|
||||
## Complete Deployment Checklist
|
||||
|
||||
### Phase 1: Prerequisites
|
||||
|
||||
- [ ] Install Node.js 18+ and npm
|
||||
- [ ] Install Hardhat: `npm install`
|
||||
- [ ] Install watcher dependencies: `cd watcher && npm install`
|
||||
- [ ] Set up PostgreSQL database
|
||||
- [ ] Configure `.env` file with all required variables
|
||||
- [ ] Fund deployer wallet with ETH (Mainnet) and native token (Chain-138)
|
||||
- [ ] Obtain CCIP router addresses from Chainlink CCIP Directory
|
||||
|
||||
### Phase 2: Deploy CCIPLogger (Ethereum Mainnet)
|
||||
|
||||
1. **Verify Configuration**
|
||||
```bash
|
||||
# Check .env has required variables
|
||||
grep -E "PRIVATE_KEY|ETHEREUM_MAINNET_RPC|CCIP_ETH_ROUTER|CHAIN138_SELECTOR" .env
|
||||
```
|
||||
|
||||
2. **Deploy Contract**
|
||||
```bash
|
||||
npm run deploy:logger:mainnet
|
||||
```
|
||||
|
||||
3. **Verify on Etherscan**
|
||||
```bash
|
||||
npx hardhat verify --network mainnet <CCIP_LOGGER_ADDRESS> <ROUTER> <SIGNER> <SELECTOR>
|
||||
```
|
||||
|
||||
4. **Update .env**
|
||||
- Contract address will be automatically added
|
||||
- Verify `CCIP_LOGGER_ETH_ADDRESS` is set
|
||||
|
||||
### Phase 3: Deploy CCIPTxReporter (Chain-138)
|
||||
|
||||
1. **Verify Configuration**
|
||||
```bash
|
||||
# Ensure CCIPLogger address is set
|
||||
grep CCIP_LOGGER_ETH_ADDRESS .env
|
||||
```
|
||||
|
||||
2. **Deploy Contract**
|
||||
```bash
|
||||
npm run deploy:reporter:chain138
|
||||
```
|
||||
|
||||
3. **Update .env**
|
||||
- Contract address will be automatically added
|
||||
- Verify `CCIP_REPORTER_CHAIN138_ADDRESS` is set
|
||||
|
||||
4. **Fund Contract**
|
||||
```bash
|
||||
# Send ETH to CCIPTxReporter for CCIP fees
|
||||
cast send <CCIP_REPORTER_ADDRESS> --value 1ether --private-key $PRIVATE_KEY --rpc-url $CHAIN138_RPC_URL
|
||||
```
|
||||
|
||||
### Phase 4: Set Up Watcher/Relayer
|
||||
|
||||
1. **Initialize Database**
|
||||
```bash
|
||||
# Database will be auto-initialized on first run
|
||||
```
|
||||
|
||||
2. **Configure Watcher**
|
||||
```bash
|
||||
# Update watcher/.env with:
|
||||
# - Database connection
|
||||
# - RPC endpoints
|
||||
# - Contract addresses
|
||||
# - Private keys (use secure key management)
|
||||
```
|
||||
|
||||
3. **Build and Start**
|
||||
```bash
|
||||
cd watcher
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
Or with Docker:
|
||||
```bash
|
||||
cd watcher/docker
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Phase 5: Verification and Testing
|
||||
|
||||
1. **Test Single Transaction**
|
||||
```bash
|
||||
# On Chain-138, send a test transaction
|
||||
# Watch logs for relay confirmation
|
||||
```
|
||||
|
||||
2. **Monitor Events**
|
||||
```bash
|
||||
# On Ethereum Mainnet, watch for RemoteTxLogged events
|
||||
cast logs --from-block latest "RemoteTxLogged(uint64,bytes32,address,address,uint256,bytes)" --rpc-url $ETHEREUM_MAINNET_RPC
|
||||
```
|
||||
|
||||
3. **Check Metrics**
|
||||
- Prometheus: http://localhost:9090
|
||||
- Database: Query `outbox` table
|
||||
- Logs: Check watcher logs
|
||||
|
||||
## Environment Variables Reference
|
||||
|
||||
See `docs/ccip-integration/README.md` for complete environment variable reference.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
See main README for troubleshooting guide.
|
||||
|
||||
51
docs/ccip-integration/QUICK_START.md
Normal file
51
docs/ccip-integration/QUICK_START.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# CCIP Integration Quick Start
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# Install main dependencies
|
||||
npm install
|
||||
|
||||
# Install watcher dependencies
|
||||
cd watcher && npm install && cd ..
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
Add to `.env`:
|
||||
|
||||
```env
|
||||
# Ethereum Mainnet
|
||||
ETHEREUM_MAINNET_RPC=https://mainnet.infura.io/v3/YOUR_KEY
|
||||
ETHERSCAN_API_KEY=your_key
|
||||
CCIP_ETH_ROUTER=0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D
|
||||
ETH_MAINNET_SELECTOR=0x500147
|
||||
|
||||
# Chain-138
|
||||
CHAIN138_RPC_URL=https://rpc.d-bis.org
|
||||
CCIP_CHAIN138_ROUTER=<router-address>
|
||||
CHAIN138_SELECTOR=0x000000000000008a
|
||||
|
||||
# Deployment
|
||||
PRIVATE_KEY=0x...
|
||||
```
|
||||
|
||||
## Deploy
|
||||
|
||||
```bash
|
||||
# 1. Deploy CCIPLogger to Ethereum Mainnet
|
||||
npm run deploy:logger:mainnet
|
||||
|
||||
# 2. Deploy CCIPTxReporter to Chain-138
|
||||
npm run deploy:reporter:chain138
|
||||
|
||||
# 3. Start watcher
|
||||
cd watcher && npm start
|
||||
```
|
||||
|
||||
## Verify
|
||||
|
||||
```bash
|
||||
# Check events on Ethereum
|
||||
cast logs --from-block latest "RemoteTxLogged(uint64,bytes32,address,address,uint256,bytes)" --rpc-url $ETHEREUM_MAINNET_RPC
|
||||
```
|
||||
222
docs/ccip-integration/README.md
Normal file
222
docs/ccip-integration/README.md
Normal file
@@ -0,0 +1,222 @@
|
||||
# CCIP Integration: Chain-138 to Ethereum Mainnet
|
||||
|
||||
## Overview
|
||||
|
||||
Production-grade CCIP integration that turns Chain-138 activity into verified, on-chain Ethereum transactions using Chainlink CCIP.
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
Chain-138 (Source) Chainlink CCIP Ethereum Mainnet (Destination)
|
||||
┌──────────────────┐ ┌──────────────┐ ┌──────────────────┐
|
||||
│ CCIPTxReporter │ ────ccipSend───> │ CCIP Router │ ────ccipReceive─> │ CCIPLogger │
|
||||
│ (Sender) │ │ / Oracle │ │ (Receiver) │
|
||||
└──────────────────┘ │ Network │ └──────────────────┘
|
||||
▲ └──────────────┘ │
|
||||
│ │
|
||||
│ ▼
|
||||
┌──────────────────┐ ┌──────────────┐
|
||||
│ Watcher/Relayer │ │ Events & │
|
||||
│ (Off-chain) │ │ State │
|
||||
└──────────────────┘ └──────────────┘
|
||||
```
|
||||
|
||||
## Components
|
||||
|
||||
### 1. Smart Contracts
|
||||
|
||||
#### CCIPLogger (Ethereum Mainnet)
|
||||
- **Location**: `contracts/ccip-integration/CCIPLogger.sol`
|
||||
- **Purpose**: Receives and logs Chain-138 transactions via CCIP
|
||||
- **Features**:
|
||||
- Replay protection (batch ID tracking)
|
||||
- Optional signature verification
|
||||
- Source chain validation
|
||||
- Event emission for indexing
|
||||
|
||||
#### CCIPTxReporter (Chain-138)
|
||||
- **Location**: `contracts/ccip-integration/CCIPTxReporter.sol`
|
||||
- **Purpose**: Reports Chain-138 transactions to Ethereum via CCIP
|
||||
- **Features**:
|
||||
- Single transaction reporting
|
||||
- Batch reporting (cost optimization)
|
||||
- Fee estimation
|
||||
- Automatic refund of excess fees
|
||||
|
||||
### 2. Deployment Scripts
|
||||
|
||||
- **CCIPLogger**: `scripts/ccip-deployment/deploy-ccip-logger.js`
|
||||
- **CCIPTxReporter**: `scripts/ccip-deployment/deploy-ccip-reporter.js`
|
||||
|
||||
### 3. Watcher/Relayer Service
|
||||
|
||||
- **Location**: `watcher/`
|
||||
- **Purpose**: Off-chain service that watches Chain-138 and relays transactions
|
||||
- **Features**:
|
||||
- WebSocket/HTTP subscription to Chain-138
|
||||
- Postgres outbox pattern for reliability
|
||||
- Batching for cost optimization
|
||||
- Retry logic with exponential backoff
|
||||
- Metrics and monitoring
|
||||
|
||||
## Deployment Guide
|
||||
|
||||
### Prerequisites
|
||||
|
||||
1. Install dependencies:
|
||||
```bash
|
||||
npm install
|
||||
cd watcher && npm install
|
||||
```
|
||||
|
||||
2. Configure `.env`:
|
||||
```env
|
||||
# Ethereum Mainnet
|
||||
ETHEREUM_MAINNET_RPC=https://mainnet.infura.io/v3/YOUR_KEY
|
||||
ETHERSCAN_API_KEY=your_etherscan_key
|
||||
CCIP_ETH_ROUTER=0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D
|
||||
ETH_MAINNET_SELECTOR=0x500147
|
||||
|
||||
# Chain-138
|
||||
CHAIN138_RPC_URL=https://rpc.d-bis.org
|
||||
CHAIN138_RPC_WS=wss://rpc.d-bis.org/ws
|
||||
CCIP_CHAIN138_ROUTER=<chain-138-ccip-router-address>
|
||||
CHAIN138_SELECTOR=0x000000000000008a
|
||||
|
||||
# Deployment
|
||||
PRIVATE_KEY=your_deployer_private_key
|
||||
AUTHORIZED_SIGNER=optional_signer_address
|
||||
|
||||
# Relayer
|
||||
RELAYER_PRIVATE_KEY=relayer_private_key
|
||||
BATCH_SIGNER_PRIVATE_KEY=batch_signer_private_key
|
||||
DATABASE_URL=postgresql://user:pass@localhost:5432/ccip_relayer
|
||||
```
|
||||
|
||||
### Step 1: Deploy CCIPLogger to Ethereum Mainnet
|
||||
|
||||
```bash
|
||||
npm run deploy:logger:mainnet
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Deploy CCIPLogger contract
|
||||
2. Display deployment address
|
||||
3. Provide verification command
|
||||
|
||||
### Step 2: Deploy CCIPTxReporter to Chain-138
|
||||
|
||||
```bash
|
||||
npm run deploy:reporter:chain138
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Deploy CCIPTxReporter contract
|
||||
2. Configure it with CCIPLogger address
|
||||
3. Display deployment address
|
||||
|
||||
### Step 3: Verify Contracts
|
||||
|
||||
```bash
|
||||
# Verify CCIPLogger on Etherscan
|
||||
npx hardhat verify --network mainnet <CCIP_LOGGER_ADDRESS> <ROUTER> <SIGNER> <SELECTOR>
|
||||
|
||||
# Verify CCIPTxReporter (if explorer available)
|
||||
npx hardhat verify --network chain138 <CCIP_REPORTER_ADDRESS> <ROUTER> <SELECTOR> <RECEIVER>
|
||||
```
|
||||
|
||||
### Step 4: Start Watcher/Relayer
|
||||
|
||||
```bash
|
||||
cd watcher
|
||||
npm run build
|
||||
npm start
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### CCIP Directory
|
||||
|
||||
Use the [Chainlink CCIP Directory](https://docs.chain.link/ccip/supported-networks) to get:
|
||||
- Chain selectors for each network
|
||||
- Router addresses
|
||||
- Supported tokens
|
||||
|
||||
### Chain Selectors
|
||||
|
||||
Update chain selectors in `.env` based on CCIP Directory:
|
||||
- Ethereum Mainnet: Check CCIP Directory
|
||||
- Chain-138: Check CCIP Directory or contact Chainlink support
|
||||
|
||||
## Security Checklist
|
||||
|
||||
- [ ] Use multisig (Gnosis Safe) for contract ownership
|
||||
- [ ] Store private keys in hardware KMS (AWS KMS, GCP KMS, YubiKey)
|
||||
- [ ] Set `authorizedSigner` for batch verification
|
||||
- [ ] Configure `expectedSourceChainSelector` correctly
|
||||
- [ ] Implement rate limiting in watcher
|
||||
- [ ] Set up monitoring and alerting
|
||||
- [ ] Test on testnets before mainnet deployment
|
||||
- [ ] Review gas limits and fee management
|
||||
- [ ] Implement circuit breakers for error conditions
|
||||
|
||||
## Monitoring
|
||||
|
||||
### Metrics
|
||||
|
||||
The watcher exposes Prometheus metrics:
|
||||
- `ccip_batches_sent_total`
|
||||
- `ccip_batches_success_total`
|
||||
- `ccip_batches_failed_total`
|
||||
- `ccip_tx_queue_size`
|
||||
- `ccip_fee_estimate_gwei`
|
||||
|
||||
### Alerts
|
||||
|
||||
Set up alerts for:
|
||||
- Failed batch deliveries
|
||||
- Low LINK/ETH balance
|
||||
- High queue size
|
||||
- CCIP delivery latency
|
||||
|
||||
## Testing
|
||||
|
||||
### Local Testing with Chainlink Local
|
||||
|
||||
1. Start Chainlink Local:
|
||||
```bash
|
||||
docker run -p 6688:6688 chainlink/local:latest
|
||||
```
|
||||
|
||||
2. Run integration tests:
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
|
||||
### Testnet Testing
|
||||
|
||||
1. Deploy to Sepolia (Ethereum testnet)
|
||||
2. Deploy to Chain-138 testnet (if available)
|
||||
3. Test full flow end-to-end
|
||||
|
||||
## Cost Optimization
|
||||
|
||||
1. **Batching**: Group multiple transactions per CCIP message
|
||||
2. **Compression**: Store only hashes on-chain, full data off-chain
|
||||
3. **Adaptive Batching**: Adjust batch size based on mempool activity
|
||||
4. **Fee Management**: Monitor and optimize CCIP fees
|
||||
|
||||
## References
|
||||
|
||||
- [Chainlink CCIP Documentation](https://docs.chain.link/ccip)
|
||||
- [CCIP Directory](https://docs.chain.link/ccip/supported-networks)
|
||||
- [CCIP Starter Kit](https://github.com/smartcontractkit/ccip-starter-kit)
|
||||
- [Chainlink Local](https://github.com/smartcontractkit/chainlink-local)
|
||||
|
||||
## Support
|
||||
|
||||
For issues or questions:
|
||||
1. Check Chainlink CCIP documentation
|
||||
2. Review contract code comments
|
||||
3. Check watcher logs
|
||||
4. Contact Chainlink support for CCIP-specific issues
|
||||
Reference in New Issue
Block a user