Skip to content

Commit d44117f

Browse files
committed
Update script and add README
1 parent c208ece commit d44117f

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Test Data Generator
2+
3+
Generates test data for ETH light client integration tests on NEAR.
4+
5+
## Usage
6+
7+
### Generate Sepolia Test Data
8+
```bash
9+
cd contracts/near/eth2-client/src/data/
10+
uv run dump_sepolia_data.py
11+
```
12+
13+
### Dependencies
14+
Uses `uv` for fast dependency management:
15+
```bash
16+
# Install uv if needed
17+
curl -LsSf https://astral.sh/uv/install.sh | sh
18+
19+
# Dependencies auto-installed on first run with uv
20+
# Or manually: uv add requests web3 tqdm eth2spec
21+
```
22+
23+
### Environment Variables
24+
- `NETWORK`: Network name (default: `sepolia`)
25+
- `EXECUTION_RPC`: Ethereum RPC endpoint
26+
- `CONSENSUS_API`: Beacon chain API endpoint
27+
- `BLOCK_WINDOW`: Block window size (default: `50`)
28+
- `BATCH_SIZE`: RPC batch size (default: `50`)
29+
30+
### Output Files
31+
- `{network}/execution_blocks_{start}_{end}.json`: Execution block headers
32+
- `{network}/light_client_update_period_{period}.json`: Light client updates
33+
- `{network}/beacon_header_{slot}.json`: Beacon block headers
34+
35+
## Integration Tests
36+
37+
The script generates data used by:
38+
- `get_sepolia_test_data()` in `tests/utils.rs`
39+
- Integration tests in `tests/integration_tests.rs`
40+
41+
### Update Test Data
42+
1. Run the script to generate new data files
43+
2. Update hardcoded block numbers and periods in `tests/utils.rs:106-122`
44+
3. Run tests: `cargo test`
45+
46+
### How It Works
47+
- Fetches 4 most recent light client update periods
48+
- Downloads corresponding execution blocks in 2 batches
49+
- Generates Merkle proofs for block hash verification
50+
- Creates normalized JSON files matching Rust struct format
51+
52+
The test expects specific file patterns matching the periods and block ranges defined in `utils.rs`.

β€Žcontracts/near/eth2-client/src/data/dump_sepolia_data.pyβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ def get_block_number_for_period(period: int) -> int:
337337

338338

339339
def main():
340-
periods = [925, 926, 927, 928]
341-
dump_light_client_updates(periods)
340+
# Fetch the 4 most recent light client updates
341+
periods = get_recent_light_client_updates(4)
342342
print(f"πŸŽ‰ Updates fetched for periods: {periods}")
343343

344344
rev = list(reversed(periods))

0 commit comments

Comments
Β (0)