Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions scripts/derive_galileo_gas_parameter/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SCROLL_URL=https://rpc.scroll.io
MAINNET_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
BEACON_URL=https://eth-mainnet-beacon.g.alchemy.com/v2/YOUR_API_KEY
41 changes: 41 additions & 0 deletions scripts/derive_galileo_gas_parameter/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Environment variables (contains API keys)
.env

# Cached data files
*.pkl

# Python
__pycache__/
*.py[cod]
*$py.class
*.so
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# Virtual environments
.venv
venv/
ENV/

# IDE
.idea/
.vscode/
*.swp
*.swo

# Logs
*.log
54 changes: 54 additions & 0 deletions scripts/derive_galileo_gas_parameter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Galileo Gas Parameter Derivation

Derives L1 fee parameters (`commit_scalar`, `blob_scalar`, `penalty_multiplier`) for Scroll's Galileo upgrade by analyzing historical on-chain data.

## Prerequisites

- Python 3.10+
- pipenv
- gcc and python3-devel

```bash
# Ubuntu/Debian
sudo apt install python3-dev gcc
# Fedora/RHEL
sudo dnf install python3-devel gcc
```

## Installation

```bash
cd scripts/derive_galileo_gas_parameter
pipenv install
```

## Running

### 1. Create `.env` file

```bash
SCROLL_URL=https://rpc.scroll.io
MAINNET_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
BEACON_URL=https://eth-mainnet-beacon.g.alchemy.com/v2/YOUR_API_KEY
```

### 2. Usage

```bash
# Collect data from 30 recent batches
pipenv run python -u derive_galileo_gas_parameter.py --mode collect --n-batches 30

# Load previously cached data
pipenv run python -u derive_galileo_gas_parameter.py --mode load --start-batch 494041 --end-batch 494070
```

**Options:**
- `--mode {collect,load}` - Collect new data or load from cache (required)
- `--n-batches N` - Number of batches to collect (default: 30)
- `--start-batch N` / `--end-batch N` - Batch range for load mode
- `--target-penalty FLOAT` - Target penalty at P95 (default: 0.1 = 10%)
- `--penalty-multiplier FLOAT` - Use fixed penalty multiplier instead of calculating

### 3. Cached Data

Collected data is saved to `galileo_data_batch_{start}_{end}.pkl` for re-analysis without re-fetching from RPC. Use `--mode load` to reload.
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,15 @@
# Read RPC endpoints from environment variables
mainnet_url = os.getenv('MAINNET_URL', '')
scroll_url = os.getenv('SCROLL_URL', 'https://rpc.scroll.io')
beacon_url = os.getenv('BEACON_URL', '')

# Validate that environment variables are set
if not mainnet_url:
raise ValueError("MAINNET_URL environment variable is not set. Please set it to your Ethereum mainnet RPC endpoint.")
if not scroll_url:
raise ValueError("SCROLL_URL environment variable is not set. Please set it to your Scroll RPC endpoint.")
if not beacon_url:
raise ValueError("BEACON_URL environment variable is not set. Please set it to your Ethereum beacon chain RPC endpoint.")

# EtherFi contract addresses (lowercase for comparison)
ETHERFI_SPEND_ADDRESS = "0x7ca0b75e67e33c0014325b739a8d019c4fe445f0"
Expand Down Expand Up @@ -465,7 +468,7 @@ def collect_batch_data(n_batches=30, width=5, start_time=None):
print("=" * 60)

# Get L1 head
mainnet_beacon_url = "https://eth-mainnetbeacon.g.alchemy.com/v2/Lzj9QLupql91nuRFYAosy"
mainnet_beacon_url = beacon_url
l1_head = latest_finalized_event_block(width)
beacon_head_slot = beacon_head(l1_head, mainnet_beacon_url)

Expand Down