- 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.
6.7 KiB
6.7 KiB
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
- Install dependencies:
npm install
cd watcher && npm install
- Configure
.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
npm run deploy:logger:mainnet
This will:
- Deploy CCIPLogger contract
- Display deployment address
- Provide verification command
Step 2: Deploy CCIPTxReporter to Chain-138
npm run deploy:reporter:chain138
This will:
- Deploy CCIPTxReporter contract
- Configure it with CCIPLogger address
- Display deployment address
Step 3: Verify Contracts
# 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
cd watcher
npm run build
npm start
Configuration
CCIP Directory
Use the Chainlink CCIP Directory 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
authorizedSignerfor batch verification - Configure
expectedSourceChainSelectorcorrectly - 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_totalccip_batches_success_totalccip_batches_failed_totalccip_tx_queue_sizeccip_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
- Start Chainlink Local:
docker run -p 6688:6688 chainlink/local:latest
- Run integration tests:
npm test
Testnet Testing
- Deploy to Sepolia (Ethereum testnet)
- Deploy to Chain-138 testnet (if available)
- Test full flow end-to-end
Cost Optimization
- Batching: Group multiple transactions per CCIP message
- Compression: Store only hashes on-chain, full data off-chain
- Adaptive Batching: Adjust batch size based on mempool activity
- Fee Management: Monitor and optimize CCIP fees
References
Support
For issues or questions:
- Check Chainlink CCIP documentation
- Review contract code comments
- Check watcher logs
- Contact Chainlink support for CCIP-specific issues