Skip to content

Commit f8f4f7a

Browse files
committed
.env + gitignore + readme
1 parent 8fc6d65 commit f8f4f7a

File tree

4 files changed

+102
-1
lines changed

4 files changed

+102
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SCROLL_URL=https://rpc.scroll.io
2+
MAINNET_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
3+
BEACON_URL=https://eth-mainnet-beacon.g.alchemy.com/v2/YOUR_API_KEY
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Environment variables (contains API keys)
2+
.env
3+
4+
# Cached data files
5+
*.pkl
6+
7+
# Python
8+
__pycache__/
9+
*.py[cod]
10+
*$py.class
11+
*.so
12+
.Python
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
29+
# Virtual environments
30+
.venv
31+
venv/
32+
ENV/
33+
34+
# IDE
35+
.idea/
36+
.vscode/
37+
*.swp
38+
*.swo
39+
40+
# Logs
41+
*.log
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Galileo Gas Parameter Derivation
2+
3+
Derives L1 fee parameters (`commit_scalar`, `blob_scalar`, `penalty_multiplier`) for Scroll's Galileo upgrade by analyzing historical on-chain data.
4+
5+
## Prerequisites
6+
7+
- Python 3.10+
8+
- pipenv
9+
- gcc and python3-devel
10+
11+
```bash
12+
# Ubuntu/Debian
13+
sudo apt install python3-dev gcc
14+
# Fedora/RHEL
15+
sudo dnf install python3-devel gcc
16+
```
17+
18+
## Installation
19+
20+
```bash
21+
cd scripts/derive_galileo_gas_parameter
22+
pipenv install
23+
```
24+
25+
## Running
26+
27+
### 1. Create `.env` file
28+
29+
```bash
30+
SCROLL_URL=https://rpc.scroll.io
31+
MAINNET_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY
32+
BEACON_URL=https://eth-mainnet-beacon.g.alchemy.com/v2/YOUR_API_KEY
33+
```
34+
35+
### 2. Usage
36+
37+
```bash
38+
# Collect data from 30 recent batches
39+
pipenv run python -u derive_galileo_gas_parameter.py --mode collect --n-batches 30
40+
41+
# Load previously cached data
42+
pipenv run python -u derive_galileo_gas_parameter.py --mode load --start-batch 494041 --end-batch 494070
43+
```
44+
45+
**Options:**
46+
- `--mode {collect,load}` - Collect new data or load from cache (required)
47+
- `--n-batches N` - Number of batches to collect (default: 30)
48+
- `--start-batch N` / `--end-batch N` - Batch range for load mode
49+
- `--target-penalty FLOAT` - Target penalty at P95 (default: 0.1 = 10%)
50+
- `--penalty-multiplier FLOAT` - Use fixed penalty multiplier instead of calculating
51+
52+
### 3. Cached Data
53+
54+
Collected data is saved to `galileo_data_batch_{start}_{end}.pkl` for re-analysis without re-fetching from RPC. Use `--mode load` to reload.

scripts/derive_galileo_gas_parameter/derive_galileo_gas_parameter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@
3232
# Read RPC endpoints from environment variables
3333
mainnet_url = os.getenv('MAINNET_URL', '')
3434
scroll_url = os.getenv('SCROLL_URL', 'https://rpc.scroll.io')
35+
beacon_url = os.getenv('BEACON_URL', '')
3536

3637
# Validate that environment variables are set
3738
if not mainnet_url:
3839
raise ValueError("MAINNET_URL environment variable is not set. Please set it to your Ethereum mainnet RPC endpoint.")
3940
if not scroll_url:
4041
raise ValueError("SCROLL_URL environment variable is not set. Please set it to your Scroll RPC endpoint.")
42+
if not beacon_url:
43+
raise ValueError("BEACON_URL environment variable is not set. Please set it to your Ethereum beacon chain RPC endpoint.")
4144

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

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

0 commit comments

Comments
 (0)