- 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.1 KiB
Script Consolidation and Modularization Plan
Overview
This document outlines the consolidation and modularization strategy for scripts in this repository. The goal is to reduce duplication, improve maintainability, and create reusable components.
Library Structure (Created)
✅ scripts/lib/ - Common libraries
lib/common/colors.sh- Color definitionslib/common/logging.sh- Logging functionslib/common/paths.sh- Path definitionslib/common/utils.sh- Utility functionslib/config/env.sh- Environment loadinglib/config/regions.sh- Region code mapping (single source of truth)lib/azure/cli.sh- Azure CLI wrapperslib/init.sh- Initialize all libraries
Script Groups Identified for Consolidation
1. Deployment Scripts - High Duplication
Monitor Scripts (Can be consolidated into 1-2 scripts)
monitor-deployment.shmonitor-and-complete.shmonitor-and-fix.shmonitor-continuous.shmonitor-deployment-live.shlive-monitor.shcontinuous-monitor.shmonitor-36-region-deployment.shdeployment-dashboard.sh
Action: Create monitor-deployment.sh with modes: --continuous, --live, --complete, --fix
Parallel Deployment Scripts (Can be consolidated)
deploy-parallel.shdeploy-all-parallel.shdeploy-besu-parallel.shdeploy-max-parallel.shdeploy-ultra-parallel.shdeploy-besu-max-parallel.shdeploy-monitoring-parallel.shconfigure-kubernetes-parallel.shconfigure-kubernetes-max-parallel.shdeploy-contracts-parallel.shverify-all-clusters-parallel.shverify-all-max-parallel.sh
Action: Create generic deploy-parallel.sh with resource type parameter
Phase Deployment Scripts
deploy-infrastructure-phase1.shdeploy-infrastructure-phase2.shdeploy-infrastructure-phase3.shdeploy-infrastructure-phase4.shdeploy-infrastructure-all-phases.shdeploy-all-phases.shcomplete-all-phases-parallel.shexecute-all-phases.shwait-and-complete-all.sh
Action: Create deploy-phase.sh with phase number parameter
Complete/All Scripts
complete-all-deployment.shcomplete-all-next-steps.shcomplete-all-tasks.shcomplete-infrastructure-deployment.shwait-and-run-all-next-steps.shrun-all-next-steps.shwait-and-run-next-steps.shrun-next-steps-with-available.sh
Action: Consolidate into complete-deployment.sh with step options
2. Cost Calculation Scripts - High Duplication
calculate-accurate-costs.shcalculate-accurate-deployment-costs.shcalculate-conservative-costs.shcalculate-contract-deployment-costs.shcalculate-gas-fees.shupdate-all-cost-estimates.shupdate-cost-estimates.shfinalize-cost-estimates.shget-accurate-gas-price.shget-conservative-gas-price.shget-mainnet-gas-prices.shget-real-gas-prices.shtest-etherscan-gas-api.sh
Action: Create lib/deployment/costs.sh library + single calculate-costs.sh script
3. Verification Scripts
verify-chain138-complete.shverify-chain138-full-deployment.shverify-chain138-services.shverify-deployment.shverify-mainnet-deployments.shverify-on-chain-deployments.shverify-all-clusters-parallel.shverify-36-region-clusters.shverify-all-max-parallel.shverify-contract-etherscan.sh
Action: Create verify-deployment.sh with resource type and mode options
4. Contract Deployment Scripts
deploy-weth.shdeploy-weth10.shdeploy-weth-with-ccip.shdeploy-ccip-weth9-bridge.shdeploy-ccip-weth10-bridge.shdeploy-multicall.shdeploy-multisig.shdeploy-ccip-router.sh
Action: Create generic deploy-contract.sh with contract name parameter
5. Check/Status Scripts
check-deployment-status.shcheck-infrastructure-status.shcheck-mainnet-deployment-status.shcheck-terraform-status.shcheck-all-deployment-sources.shcheck-existing-deployments.shcheck-mainnet-balances.shcheck-wallet-balances.shcheck-and-proceed.shcheck-rpc-status.sh
Action: Create check-status.sh with resource type parameter
6. Import Scripts
import-existing-clusters.shimport-all-resources.sh
Action: Create import-resources.sh with resource type parameter (these are already similar)
Migration Strategy
Phase 1: Library Adoption ✅ (In Progress)
- ✅ Create common library structure
- ✅ Create shared utilities
- 🔄 Update key scripts to use libraries (example created)
Phase 2: High-Impact Consolidations
- Consolidate monitor scripts
- Consolidate parallel deployment scripts
- Consolidate cost calculation scripts
Phase 3: Medium-Impact Consolidations
- Consolidate verification scripts
- Consolidate check/status scripts
- Consolidate contract deployment scripts
Phase 4: Cleanup
- Remove deprecated scripts
- Update documentation
- Update Makefile targets
Script Template
All new scripts should follow this template:
#!/bin/bash
# Script description
# Usage: script-name.sh [OPTIONS]
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../lib/init.sh"
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--option)
OPTION="$2"
shift 2
;;
*)
log_error "Unknown option: $1"
exit 1
;;
esac
done
# Main script logic
ensure_azure_cli || exit 1
log_section "Script Title"
Benefits
- Reduced Duplication: ~50% reduction in script count
- Single Source of Truth: Region codes, colors, utilities defined once
- Consistency: All scripts use same logging, error handling
- Maintainability: Update once, applies everywhere
- Easier Testing: Reusable functions can be unit tested
- Better Documentation: Clear library structure
Progress Tracking
- Create library structure
- Create common utilities
- Create example refactored script
- Migrate high-priority scripts
- Consolidate monitor scripts
- Consolidate deployment scripts
- Consolidate cost scripts
- Update documentation
- Remove deprecated scripts