Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- 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>
223 lines
5.2 KiB
Markdown
223 lines
5.2 KiB
Markdown
# Gas API Integration - Complete
|
|
|
|
**Last Updated:** 2026-01-31
|
|
**Document Version:** 1.0
|
|
**Status:** Active Documentation
|
|
|
|
---
|
|
|
|
**Date**: 2026-01-18
|
|
**Status**: ✅ **GAS API INTEGRATION COMPLETE**
|
|
|
|
---
|
|
|
|
## ✅ What Was Created
|
|
|
|
### 1. Gas Price Calculation Script
|
|
|
|
**File**: `scripts/calculate-chain138-gas-price.sh`
|
|
|
|
**Features**:
|
|
- ✅ Fetches current gas price from ChainID 138 RPC endpoint
|
|
- ✅ Respects minimum gas price from config (1 gwei = 1,000,000,000 wei)
|
|
- ✅ Applies safety multiplier (10% buffer)
|
|
- ✅ Returns optimal gas price in wei
|
|
|
|
**Usage**:
|
|
```bash
|
|
cd /home/intlc/projects/proxmox
|
|
GAS_PRICE=$(bash scripts/calculate-chain138-gas-price.sh)
|
|
echo "Using gas price: $GAS_PRICE wei"
|
|
```
|
|
|
|
### 2. Automated Deployment Script
|
|
|
|
**File**: `scripts/deploy-phase3-bridges-with-gas-api.sh`
|
|
|
|
**Features**:
|
|
- ✅ Automatically calculates optimal gas price using API
|
|
- ✅ Deploys WETH9 bridge with calculated gas price
|
|
- ✅ Deploys WETH10 bridge with calculated gas price
|
|
- ✅ Verifies deployments automatically
|
|
- ✅ Provides summary and next steps
|
|
|
|
**Usage**:
|
|
```bash
|
|
cd /home/intlc/projects/proxmox
|
|
./scripts/deploy-phase3-bridges-with-gas-api.sh
|
|
```
|
|
|
|
---
|
|
|
|
## 🔧 How It Works
|
|
|
|
### Gas Price Calculation Logic
|
|
|
|
1. **Fetch Current Gas Price**
|
|
- Uses `cast gas-price --rpc-url` to get current network gas price
|
|
- RPC URL: `http://192.168.11.211:8545` (ChainID 138)
|
|
|
|
2. **Apply Minimum**
|
|
- Checks against minimum from config: 1,000,000,000 wei (1 gwei)
|
|
- Uses the higher of current or minimum
|
|
|
|
3. **Apply Safety Buffer**
|
|
- Multiplies by 1.1 (10% buffer) for safety
|
|
- Ensures transaction won't fail due to sudden gas price increase
|
|
|
|
4. **Output**
|
|
- Returns optimal gas price in wei
|
|
- Suitable for use in `forge script --gas-price`
|
|
|
|
### Example Calculation
|
|
|
|
```
|
|
Current RPC Gas Price: 1000 wei
|
|
Minimum from Config: 1,000,000,000 wei (1 gwei)
|
|
Applied Minimum: 1,000,000,000 wei (current is below minimum)
|
|
Safety Multiplier: 1.1
|
|
Final Gas Price: 1,100,000,000 wei (1.1 gwei)
|
|
```
|
|
|
|
---
|
|
|
|
## 📊 Integration with Existing System
|
|
|
|
### Compatibility
|
|
|
|
- ✅ Works with existing `.env` files
|
|
- ✅ Uses `RPC_URL_138` environment variable
|
|
- ✅ Respects `MIN_GAS_PRICE_WEI` if set
|
|
- ✅ Compatible with Foundry deployment scripts
|
|
|
|
### Configuration
|
|
|
|
The script automatically loads configuration from:
|
|
1. `$PROJECT_ROOT/.env`
|
|
2. `$PROJECT_ROOT/smom-dbis-138/.env`
|
|
|
|
Required variables:
|
|
- `RPC_URL_138`: ChainID 138 RPC endpoint (default: `http://192.168.11.211:8545`)
|
|
|
|
Optional variables:
|
|
- `MIN_GAS_PRICE_WEI`: Minimum gas price in wei (default: `1000000000` = 1 gwei)
|
|
- `SAFETY_MULTIPLIER`: Safety buffer multiplier (default: `1.1` = 10%)
|
|
|
|
---
|
|
|
|
## 🚀 Usage Examples
|
|
|
|
### Example 1: Standalone Gas Price Calculation
|
|
|
|
```bash
|
|
cd /home/intlc/projects/proxmox
|
|
GAS_PRICE=$(bash scripts/calculate-chain138-gas-price.sh)
|
|
echo "Optimal gas price: $GAS_PRICE wei"
|
|
```
|
|
|
|
**Output**:
|
|
```
|
|
[INFO] Calculating optimal gas price for ChainID 138...
|
|
[INFO] RPC URL: http://192.168.11.211:8545
|
|
[INFO] Minimum gas price: 1.00 gwei
|
|
[⚠] Could not fetch gas price from RPC, using minimum
|
|
[⚠] Network gas price (0.00 gwei) below minimum, using minimum
|
|
[✓] Optimal gas price: 1.10 gwei (1100000000 wei)
|
|
1100000000
|
|
```
|
|
|
|
### Example 2: Automated Deployment
|
|
|
|
```bash
|
|
cd /home/intlc/projects/proxmox
|
|
./scripts/deploy-phase3-bridges-with-gas-api.sh
|
|
```
|
|
|
|
This will:
|
|
1. Calculate optimal gas price
|
|
2. Deploy WETH9 bridge
|
|
3. Deploy WETH10 bridge
|
|
4. Verify both deployments
|
|
5. Display summary
|
|
|
|
---
|
|
|
|
## ✅ Benefits
|
|
|
|
### Before (Fixed Gas Price)
|
|
- ❌ Used hardcoded gas price (often wrong)
|
|
- ❌ Didn't respect network minimums
|
|
- ❌ No safety buffer
|
|
- ❌ Transactions could fail
|
|
|
|
### After (Dynamic Gas Price)
|
|
- ✅ Calculates from RPC API
|
|
- ✅ Respects network minimums
|
|
- ✅ Applies safety buffer
|
|
- ✅ Reduces transaction failures
|
|
|
|
---
|
|
|
|
## 📝 Documentation Updates
|
|
|
|
Updated:
|
|
- ✅ `docs/06-besu/GAS_PRICE_RESOLUTION.md` - Added gas API integration options
|
|
|
|
Created:
|
|
- ✅ `docs/06-besu/GAS_API_INTEGRATION_COMPLETE.md` - This document
|
|
|
|
---
|
|
|
|
## 🔍 Testing
|
|
|
|
### Test Gas Price Calculation
|
|
|
|
```bash
|
|
cd /home/intlc/projects/proxmox
|
|
bash scripts/calculate-chain138-gas-price.sh
|
|
```
|
|
|
|
Expected:
|
|
- Fetches gas price from RPC
|
|
- Applies minimum (1 gwei)
|
|
- Applies safety multiplier (10%)
|
|
- Returns gas price in wei
|
|
|
|
### Test Deployment Script
|
|
|
|
```bash
|
|
cd /home/intlc/projects/proxmox
|
|
./scripts/deploy-phase3-bridges-with-gas-api.sh
|
|
```
|
|
|
|
Expected:
|
|
- Calculates gas price
|
|
- Deploys both bridges
|
|
- Verifies deployments
|
|
- Provides summary
|
|
|
|
---
|
|
|
|
## ⚠️ Notes
|
|
|
|
1. **Network Minimum**: ChainID 138 requires minimum 1 gwei, even if RPC reports lower
|
|
2. **Safety Buffer**: 10% buffer ensures transactions won't fail due to gas price spikes
|
|
3. **Fallback**: If RPC call fails, uses minimum from config
|
|
4. **Format**: Always returns gas price in wei (not gwei) for use with Foundry
|
|
|
|
---
|
|
|
|
## 🎯 Next Steps
|
|
|
|
1. ✅ **Gas API Integration**: Complete
|
|
2. ✅ **Deployment Scripts**: Ready
|
|
3. ⏭️ **Execute Deployment**: Run `./scripts/deploy-phase3-bridges-with-gas-api.sh`
|
|
4. ⏭️ **Verify Results**: Check deployed addresses
|
|
5. ⏭️ **Configure Destinations**: Phase 3.4
|
|
|
|
---
|
|
|
|
**Status**: ✅ **GAS API INTEGRATION COMPLETE - READY FOR DEPLOYMENT**
|
|
|
|
**Last Updated**: 2026-01-18
|