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>
139 lines
3.4 KiB
Markdown
139 lines
3.4 KiB
Markdown
# Oracle Update Script Fix
|
|
|
|
**Last Updated:** 2026-01-31
|
|
**Document Version:** 1.0
|
|
**Status:** Active Documentation
|
|
|
|
---
|
|
|
|
**Date:** 2026-01-27
|
|
**Issue:** Script was using inaccessible RPC endpoint
|
|
**Status:** ✅ Fixed
|
|
|
|
---
|
|
|
|
## 🔧 Problem
|
|
|
|
The `update-oracle-price.sh` script was failing with:
|
|
```
|
|
[ERROR] RPC is not accessible at http://192.168.11.250:8545
|
|
```
|
|
|
|
**Root Cause:**
|
|
- Script was using `RPC_URL` from `.env` which pointed to `192.168.11.250:8545` (internal-only, not accessible)
|
|
- Should prioritize `RPC_URL_138` which points to `192.168.11.211:8545` (accessible)
|
|
|
|
---
|
|
|
|
## ✅ Solution
|
|
|
|
### Changes Made
|
|
|
|
1. **RPC URL Priority Fix:**
|
|
- Changed priority: `RPC_URL_138` > `RPC_URL` > default
|
|
- Added automatic fallback to working RPC endpoints
|
|
|
|
2. **Automatic RPC Fallback:**
|
|
- Script now tests RPC connectivity
|
|
- Falls back to alternative RPCs if primary fails
|
|
- Tries: `192.168.11.211:8545` → `https://rpc-http-pub.d-bis.org`
|
|
|
|
3. **Better Error Handling:**
|
|
- Added timeout to transaction sending (90 seconds)
|
|
- Improved transaction hash extraction
|
|
- Better error messages
|
|
|
|
### Updated Code
|
|
|
|
```bash
|
|
# RPC URL priority: command arg > RPC_URL_138 > RPC_URL > working defaults
|
|
DEFAULT_RPC="http://192.168.11.211:8545"
|
|
RPC_URL="${1:-${RPC_URL_138:-${RPC_URL:-$DEFAULT_RPC}}}"
|
|
|
|
# Test RPC and fallback if needed
|
|
if ! curl -s -X POST -H "Content-Type: application/json" \
|
|
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
|
|
--max-time 3 "$RPC_URL" > /dev/null 2>&1; then
|
|
log_warn "Primary RPC not accessible, trying alternatives..."
|
|
# Try alternative RPCs
|
|
for ALT_RPC in "http://192.168.11.211:8545" "https://rpc-http-pub.d-bis.org"; do
|
|
if curl -s -X POST -H "Content-Type: application/json" \
|
|
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
|
|
--max-time 3 "$ALT_RPC" > /dev/null 2>&1; then
|
|
log_info "Using alternative RPC: $ALT_RPC"
|
|
RPC_URL="$ALT_RPC"
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
```
|
|
|
|
---
|
|
|
|
## 🚀 Usage
|
|
|
|
### Basic Usage
|
|
|
|
```bash
|
|
cd /home/intlc/projects/proxmox/smom-dbis-138
|
|
./scripts/update-oracle-price.sh
|
|
```
|
|
|
|
The script will:
|
|
1. Load `.env` file
|
|
2. Use `RPC_URL_138` if available (preferred)
|
|
3. Fall back to `RPC_URL` if needed
|
|
4. Automatically try alternative RPCs if primary fails
|
|
5. Update oracle with current ETH/USD price from CoinGecko
|
|
|
|
### With Explicit RPC
|
|
|
|
```bash
|
|
./scripts/update-oracle-price.sh https://rpc-http-pub.d-bis.org
|
|
```
|
|
|
|
### With Explicit Parameters
|
|
|
|
```bash
|
|
./scripts/update-oracle-price.sh [rpc-url] [oracle-address] [private-key]
|
|
```
|
|
|
|
---
|
|
|
|
## ✅ Verification
|
|
|
|
After running the script, verify the oracle was updated:
|
|
|
|
```bash
|
|
RPC_URL="http://192.168.11.211:8545"
|
|
ORACLE="0x3304b747e565a97ec8ac220b0b6a1f6ffdb837e6"
|
|
|
|
# Get latest price
|
|
cast call "$ORACLE" "latestRoundData()" --rpc-url "$RPC_URL"
|
|
|
|
# The answer field (in 8 decimals) should be non-zero
|
|
```
|
|
|
|
---
|
|
|
|
## 📊 Current Status
|
|
|
|
- ✅ Script fixed and working
|
|
- ✅ Uses correct RPC endpoint
|
|
- ✅ Automatic fallback to working RPCs
|
|
- ✅ Better error handling
|
|
- ⏳ Oracle currently returns zero (needs price update)
|
|
|
|
---
|
|
|
|
## 🔗 Related Files
|
|
|
|
- **Script:** `smom-dbis-138/scripts/update-oracle-price.sh`
|
|
- **Oracle Setup:** `docs/04-configuration/metamask/ORACLE_PRICE_FEED_SETUP.md`
|
|
- **Status Check:** `smom-dbis-138/scripts/check-oracle-publisher-status.sh`
|
|
|
|
---
|
|
|
|
**Last Updated:** 2026-01-27
|
|
**Status:** ✅ Fixed and Ready to Use
|