Skip to content
Open
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
18 changes: 18 additions & 0 deletions scripts/derive_galileo_gas_parameter/Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
web3 = "<7,>=6"
pandas = "*"
numpy = "*"
rlp = "*"
zstandard = "*"
requests = "*"
async_timeout = "*"

[dev-packages]

[requires]
python_version = "3.10"
2,166 changes: 2,166 additions & 0 deletions scripts/derive_galileo_gas_parameter/Pipfile.lock

Large diffs are not rendered by default.

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.
70 changes: 70 additions & 0 deletions scripts/derive_galileo_gas_parameter/claude.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Project Description

This is a Scroll L2 blockchain gas fee parameter calculation project for deriving Scroll gas fee parameters.

# Environment Setup

Claude is executed within a pipenv shell environment, so all packages should already be installed.

# Guidelines

- All Python script comments must be in English
- When executing `derive_galileo_gas_parameter.py`, output should be redirected to a fixed log file
- Use the `-u` option to disable output buffering for real-time logging
- Always use `/tmp/derive_galileo_gas_parameter.log` as the log file
- Example: `python -u derive_galileo_gas_parameter.py --mode collect --n-batches 5 > /tmp/derive_galileo_gas_parameter.log 2>&1 &`

# Python Script Execution

## Command Format

```bash
python -u derive_galileo_gas_parameter.py [OPTIONS] > /tmp/derive_galileo_gas_parameter.log 2>&1 &
```

## Options

- `--mode {collect,load}` (required): Operation mode
- `collect`: Collect new data from blockchain
- `load`: Load data from cached pickle file

- `--n-batches N`: Number of batches to collect (default: 30)
- Only used in `collect` mode

- `--start-batch N`: Start batch index (required for `load` mode)

- `--end-batch N`: End batch index (required for `load` mode)

- `--target-penalty FLOAT`: Target penalty at P95 (default: 0.1 = 10%)

- `--penalty-multiplier FLOAT`: Fixed penalty multiplier (optional, will be calculated from P95 if not specified)

## Examples

Collect data for 3 batches:
```bash
python -u derive_galileo_gas_parameter.py --mode collect --n-batches 3 > /tmp/derive_galileo_gas_parameter.log 2>&1 &
```

Load cached data:
```bash
python -u derive_galileo_gas_parameter.py --mode load --start-batch 12345 --end-batch 12347 > /tmp/derive_galileo_gas_parameter.log 2>&1 &
```

Collect with custom target penalty:
```bash
python -u derive_galileo_gas_parameter.py --mode collect --n-batches 30 --target-penalty 0.15 > /tmp/derive_galileo_gas_parameter.log 2>&1 &
```

## Monitoring Execution

Check log output in real-time:
```bash
tail -f /tmp/derive_galileo_gas_parameter.log
```

View complete log:
```bash
cat /tmp/derive_galileo_gas_parameter.log
```

Loading