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:
138
scripts/utils/calculate-create-address.js
Normal file
138
scripts/utils/calculate-create-address.js
Normal file
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Calculate CREATE address given deployer and nonce
|
||||
*
|
||||
* CREATE formula:
|
||||
* address = keccak256(RLP(deployer_address, nonce))[12:]
|
||||
*
|
||||
* RLP encoding:
|
||||
* - For nonce = 0: RLP([deployer_address])
|
||||
* - For nonce > 0: RLP([deployer_address, nonce])
|
||||
*/
|
||||
|
||||
const { ethers } = require("ethers");
|
||||
const RLP = require("rlp");
|
||||
|
||||
// Target addresses from genesis.json
|
||||
const TARGET_WETH9 = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2";
|
||||
const TARGET_WETH10 = "0xf4BB2e28688e89fCcE3c0580D37d36A7672E8A9F";
|
||||
|
||||
// Potential deployers
|
||||
const DEPLOYERS = [
|
||||
"0x0742D35CC6634c0532925A3b844bc9E7595f0Beb",
|
||||
"0xa55A4B57A91561e9df5a883D4883Bd4b1a7C4882",
|
||||
"0x4a666f96fc8764181194447a7dfdb7d471b301c8",
|
||||
];
|
||||
|
||||
/**
|
||||
* Calculate CREATE address using RLP encoding
|
||||
*/
|
||||
function calculateCreateAddress(deployer, nonce) {
|
||||
const deployerBytes = Buffer.from(deployer.slice(2), 'hex');
|
||||
|
||||
let rlpEncoded;
|
||||
if (nonce === 0) {
|
||||
// RLP([deployer_address])
|
||||
rlpEncoded = RLP.encode([deployerBytes]);
|
||||
} else {
|
||||
// RLP([deployer_address, nonce])
|
||||
const nonceHex = nonce.toString(16);
|
||||
const nonceBytes = Buffer.from(nonceHex.padStart(nonceHex.length + (nonceHex.length % 2), '0'), 'hex');
|
||||
rlpEncoded = RLP.encode([deployerBytes, nonceBytes]);
|
||||
}
|
||||
|
||||
const hash = ethers.keccak256(rlpEncoded);
|
||||
const address = '0x' + hash.slice(-40);
|
||||
return ethers.getAddress(address);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find nonce that produces target address
|
||||
*/
|
||||
function findNonceForTarget(targetAddress, deployer, maxNonce = 10000) {
|
||||
console.log(`Finding nonce for deployer ${deployer} to produce ${targetAddress}...`);
|
||||
|
||||
for (let nonce = 0; nonce < maxNonce; nonce++) {
|
||||
const computed = calculateCreateAddress(deployer, nonce);
|
||||
|
||||
if (nonce % 1000 === 0 && nonce > 0) {
|
||||
process.stdout.write(`\rChecked ${nonce} nonces...`);
|
||||
}
|
||||
|
||||
if (computed.toLowerCase() === targetAddress.toLowerCase()) {
|
||||
console.log(`\n✅ Found nonce: ${nonce}`);
|
||||
console.log(` Deployer: ${deployer}`);
|
||||
console.log(` Computed: ${computed}`);
|
||||
return nonce;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\n❌ Could not find nonce after ${maxNonce} attempts`);
|
||||
return null;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const args = process.argv.slice(2);
|
||||
|
||||
if (args.length < 1) {
|
||||
console.log("Usage: node calculate-create-address.js <target-address> [deployer-address] [max-nonce]");
|
||||
console.log("");
|
||||
console.log("Examples:");
|
||||
console.log(" node calculate-create-address.js 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2");
|
||||
console.log(" node calculate-create-address.js 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 0x0742D35CC6634c0532925A3b844bc9E7595f0Beb");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const targetAddress = ethers.getAddress(args[0]);
|
||||
const deployer = args[1] ? ethers.getAddress(args[1]) : DEPLOYERS[0];
|
||||
const maxNonce = args[2] ? parseInt(args[2]) : 10000;
|
||||
|
||||
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
||||
console.log("Calculate CREATE Address");
|
||||
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
||||
console.log("");
|
||||
console.log(`Target Address: ${targetAddress}`);
|
||||
console.log(`Deployer: ${deployer}`);
|
||||
console.log(`Max Nonce: ${maxNonce}`);
|
||||
console.log("");
|
||||
|
||||
// Try all deployers if not specified
|
||||
const deployersToTry = args[1] ? [deployer] : DEPLOYERS;
|
||||
|
||||
for (const deployerAddr of deployersToTry) {
|
||||
const nonce = findNonceForTarget(targetAddress, deployerAddr, maxNonce);
|
||||
|
||||
if (nonce !== null) {
|
||||
console.log("");
|
||||
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
||||
console.log("✅ CREATE Parameters Found");
|
||||
console.log("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");
|
||||
console.log(`Target Address: ${targetAddress}`);
|
||||
console.log(`Deployer: ${deployerAddr}`);
|
||||
console.log(`Nonce: ${nonce}`);
|
||||
console.log("");
|
||||
console.log("Use these parameters in your deployment script:");
|
||||
console.log(` vm.startBroadcast(${deployerAddr});`);
|
||||
console.log(` // Ensure nonce is ${nonce}`);
|
||||
console.log(` WETH weth = new WETH();`);
|
||||
console.log("");
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("");
|
||||
console.log("❌ Could not find CREATE parameters for any deployer");
|
||||
console.log("You may need to:");
|
||||
console.log(" 1. Try different deployers");
|
||||
console.log(" 2. Increase max-nonce");
|
||||
console.log(" 3. Check if address was deployed with different method");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
main().catch(console.error);
|
||||
}
|
||||
|
||||
module.exports = { calculateCreateAddress, findNonceForTarget };
|
||||
|
||||
65
scripts/utils/get-mapped-address.sh
Executable file
65
scripts/utils/get-mapped-address.sh
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Get the mapped address for a genesis address
|
||||
# Usage: ./get-mapped-address.sh <genesis-address>
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
source .env 2>/dev/null || true
|
||||
|
||||
GENESIS_ADDRESS="${1:-}"
|
||||
|
||||
if [ -z "$GENESIS_ADDRESS" ]; then
|
||||
echo "Usage: $0 <genesis-address>"
|
||||
echo ""
|
||||
echo "Example:"
|
||||
echo " $0 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if AddressMapper is deployed
|
||||
ADDRESS_MAPPER="${ADDRESS_MAPPER:-}"
|
||||
|
||||
if [ -z "$ADDRESS_MAPPER" ]; then
|
||||
echo "⚠️ ADDRESS_MAPPER not set in .env"
|
||||
echo " Deploy AddressMapper first: forge script script/DeployAddressMapper.s.sol"
|
||||
echo ""
|
||||
echo "📋 Using static mapping from config/address-mapping.json..."
|
||||
|
||||
# Fallback to JSON file
|
||||
python3 << EOF
|
||||
import json
|
||||
import sys
|
||||
|
||||
try:
|
||||
with open('config/address-mapping.json', 'r') as f:
|
||||
mapping = json.load(f)
|
||||
|
||||
genesis_addr = "$GENESIS_ADDRESS".lower()
|
||||
|
||||
for name, data in mapping['mappings'].items():
|
||||
if data['genesisAddress'].lower() == genesis_addr:
|
||||
print(f"✅ Found mapping for {name}:")
|
||||
print(f" Genesis: {data['genesisAddress']}")
|
||||
print(f" Deployed: {data['deployedAddress']}")
|
||||
print(f" Reason: {data['reason']}")
|
||||
sys.exit(0)
|
||||
|
||||
print(f"❌ No mapping found for {GENESIS_ADDRESS}")
|
||||
print(" This address may not be mapped, or AddressMapper needs to be deployed")
|
||||
sys.exit(1)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
sys.exit(1)
|
||||
EOF
|
||||
else
|
||||
echo "🔍 Querying AddressMapper contract..."
|
||||
cast call "$ADDRESS_MAPPER" "getDeployedAddress(address)" "$GENESIS_ADDRESS" \
|
||||
--rpc-url "${RPC_URL:-http://localhost:8545}" 2>/dev/null | \
|
||||
grep -oE "0x[a-fA-F0-9]{40}" | head -1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user