- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
7.1 KiB
Compilation Recommendations for Large Contract Project
Last Updated: 2026-01-31
Document Version: 1.0
Status: Active Documentation
Date: 2025-01-19
Issue: Compilation timing out for 266 contract files
Status: Recommendations provided
Problem Analysis
Current Situation
- Total files: 266 Solidity files
- Contract files: 148 contracts
- Deployment scripts: 10+ scripts
- Compilation: Timing out (30 minute timeout exceeded)
- Configuration:
via_ir = true,optimizer = true,optimizer_runs = 200
VM Resources
- Memory: 16GB (5.3GB used, 8.9GB free, 10GB available)
- CPU: 4 cores
- Disk: 196GB (5.6GB used, 181GB free)
Resources are sufficient - the issue is compilation strategy, not resources.
Recommendations
1. Compile Only What's Needed for Deployment (RECOMMENDED)
Instead of compiling all 266 files, compile only the contracts needed for the specific deployment scripts.
Strategy A: Compile by Deployment Script
# Compile only WETH9 Bridge contracts
forge build --force script/DeployCCIPWETH9Bridge.s.sol
# Compile only WETH10 Bridge contracts
forge build --force script/DeployCCIPWETH10Bridge.s.sol
# Compile only LINK deployment
forge build --force script/DeployLinkToCanonicalAddress.s.sol
Strategy B: Use Selective Import Compilation
Foundry automatically compiles only what's needed for each script, but you can help it by:
# Compile with explicit script
forge script script/DeployCCIPWETH9Bridge.s.sol:DeployCCIPWETH9Bridge --dry-run
# This will compile only what's needed
2. Optimize Compiler Settings for Faster Compilation
Create a compilation profile optimized for speed vs. gas optimization:
[profile.fast]
optimizer = true
optimizer_runs = 1 # Minimal optimization for faster compilation
via_ir = false # Disable IR for faster compilation (if no stack too deep errors)
Usage:
forge build --profile fast
Trade-off: Larger bytecode, more gas, but much faster compilation.
3. Increase Memory Limits
Set higher memory limits for Solidity compiler:
[profile.default]
solc = "0.8.20"
optimizer = true
optimizer_runs = 200
via_ir = true
# Add memory settings
[evm]
memory_limit = "1gb" # Increase if needed
4. Compile in Stages
Break compilation into stages:
# Stage 1: Compile core contracts only
forge build --force contracts/bridge/trustless/
# Stage 2: Compile bridge contracts
forge build --force contracts/bridge/
# Stage 3: Compile deployment scripts
forge build --force script/
5. Use Incremental Compilation
Leverage Foundry's incremental compilation by not using --force:
# First compilation (may take longer)
forge build
# Subsequent compilations (only changed files)
forge build # Much faster
6. Compile Deployment Scripts Only
For deployment purposes, you only need the deployment scripts compiled:
# Compile deployment scripts and their dependencies only
forge build script/DeployCCIPWETH9Bridge.s.sol script/DeployCCIPWETH10Bridge.s.sol script/DeployLinkToCanonicalAddress.s.sol
7. Adjust Optimizer Settings
Reduce optimizer runs for faster compilation:
[profile.deploy]
optimizer = true
optimizer_runs = 100 # Reduced from 200 for faster compilation
via_ir = true
8. Split Compilation with Cache
Use Foundry's cache more effectively:
# Clear cache first (fresh start)
forge clean
# Compile with explicit output
forge build --force --sizes
# This shows sizes and helps identify large contracts
Recommended Approach for Deployment
Option 1: Compile Script-Specific (FASTEST)
# In VM
cd /home/intlc/projects/proxmox/smom-dbis-138
# Compile and deploy WETH9 Bridge (only compiles what's needed)
forge script script/DeployCCIPWETH9Bridge.s.sol:DeployCCIPWETH9Bridge \
--rpc-url http://localhost:8545 \
--broadcast \
--private-key $PRIVATE_KEY \
--slow
# Compile and deploy WETH10 Bridge
forge script script/DeployCCIPWETH10Bridge.s.sol:DeployCCIPWETH10Bridge \
--rpc-url http://localhost:8545 \
--broadcast \
--private-key $PRIVATE_KEY \
--slow
# Compile and deploy LINK
forge script script/DeployLinkToCanonicalAddress.s.sol:DeployLinkToCanonicalAddress \
--rpc-url http://localhost:8545 \
--broadcast \
--private-key $PRIVATE_KEY \
--slow
Advantage: Only compiles what each script needs, much faster.
Option 2: Two-Stage Compilation
# Stage 1: Compile with fast profile (if created)
forge build --profile fast # Or compile incrementally without --force
# Stage 2: Deploy using deployment script
bash scripts/deploy-all-bridges-standalone.sh
Option 3: Update Deployment Script to Compile Per Script
Modify deploy-all-bridges-standalone.sh to compile before each deployment:
# Before each forge script command, add:
echo "Compiling contracts for WETH9 Bridge..."
forge build script/DeployCCIPWETH9Bridge.s.sol --force 2>&1 | tail -10
Compiler Settings Comparison
| Setting | Current | Fast Profile | Deploy Profile |
|---|---|---|---|
| optimizer | true | true | true |
| optimizer_runs | 200 | 1 | 100 |
| via_ir | true | false | true |
| Speed | Slow | Fast | Medium |
| Gas | Optimized | High | Medium |
| Use Case | Production | Development | Deployment |
Implementation Steps
Step 1: Create Fast Compilation Profile
Add to foundry.toml:
[profile.fast]
optimizer = true
optimizer_runs = 1
via_ir = false
Step 2: Update Deployment Script
Modify deployment script to use selective compilation or fast profile.
Step 3: Test Compilation
# Test fast compilation
forge build --profile fast
# Verify it completes within timeout
# Then use for deployment
Alternative: Compile Locally and Copy
If VM compilation continues to timeout:
-
Compile on local system (which has more resources potentially)
-
Copy compiled artifacts to VM:
# On local system cd smom-dbis-138 forge build --force # Copy out/ and cache/ to VM tar czf compiled-artifacts.tar.gz out/ cache/ scp compiled-artifacts.tar.gz root@192.168.11.10:/tmp/ # In VM cd /home/intlc/projects/proxmox/smom-dbis-138 tar xzf /tmp/compiled-artifacts.tar.gz -
Deploy using pre-compiled artifacts
Recommended Solution for Current Deployment
For immediate deployment, use Option 1: Script-Specific Compilation:
# Each forge script command will compile only what's needed
forge script script/DeployCCIPWETH9Bridge.s.sol:DeployCCIPWETH9Bridge \
--rpc-url http://localhost:8545 \
--broadcast \
--private-key $PRIVATE_KEY \
--slow \
-vvv
This avoids the need to compile all 266 files upfront.
Monitoring Compilation Progress
# Watch compilation progress
forge build --force 2>&1 | tee compilation.log
# In another terminal, monitor
tail -f compilation.log | grep -E "Compiling|Error|Success"
Status: Recommendations ready for implementation
Next: Update deployment strategy to use script-specific compilation