Skip to content

Commit 6461451

Browse files
committed
fix(scripts): address wallet-operator-mapper review feedback
Fix critical bugs and configuration issues identified in code review: Bug Fixes: - Fix wallet count aggregation in analyze-per-operator.js - Changed assignment operator from = to += on lines 122, 125 - Now correctly sums wallet counts across all operators per provider - Previously only recorded last operator's count, causing incorrect analysis Configuration: - Externalize hard-coded file paths to environment variables - query-dkg-events.js: Use PROOF_OF_FUNDS_PATH with ./data/ fallback - validate-operator-list.js: Use THRESHOLD_STAKERS_CSV_PATH with ./data/ fallback - Scripts now portable across team members and environments Documentation: - Add data file setup section to README.md - Document two setup options: default directory and env variables - Create data/README.md with file requirements and sources - Update .env.example with new configuration variables - Add data/ directory to .gitignore All review comments from piotr-roslaniec addressed.
1 parent efceeb2 commit 6461451

File tree

6 files changed

+51
-5
lines changed

6 files changed

+51
-5
lines changed

scripts/wallet-operator-mapper/.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,10 @@ QUERY_DELAY_MS=100
1111

1212
# Optional: Enable verbose logging
1313
DEBUG=false
14+
15+
# Data file paths (optional - defaults to ./data/ directory)
16+
# Path to tBTC proof-of-funds JSON file
17+
PROOF_OF_FUNDS_PATH=./data/tbtc-proof-of-funds.json
18+
19+
# Path to threshold stakers CSV file
20+
THRESHOLD_STAKERS_CSV_PATH=./data/threshold_stakers_may_2025.csv

scripts/wallet-operator-mapper/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ package-lock.json
88
# Output
99
wallet-operator-mapping.json
1010

11+
# Data files
12+
data/
13+
1114
# Logs
1215
*.log
1316
npm-debug.log*

scripts/wallet-operator-mapper/README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,44 @@ npm install
1212
cp .env.example .env
1313
# Edit .env with your Alchemy/Infura archive node URL
1414

15-
# 3. Run analysis
15+
# 3. Set up data files (see Data Files Setup below)
16+
mkdir -p data
17+
# Copy required data files to ./data/ directory
18+
19+
# 4. Run analysis
1620
node analyze-per-operator.js
1721
```
1822

23+
## Data Files Setup
24+
25+
The scripts require two data files from the Memory Bank project:
26+
27+
### Required Files
28+
29+
1. **tBTC Proof of Funds** (`tbtc-proof-of-funds.json`)
30+
- Contains wallet balances and metadata
31+
- Source: Memory Bank `/knowledge/20251006-tbtc-proof-of-funds.json`
32+
33+
2. **Threshold Stakers CSV** (`threshold_stakers_may_2025.csv`)
34+
- Contains operator list and stake information
35+
- Source: Memory Bank `/knowledge/threshold_stakers_may_2025.csv`
36+
37+
### Setup Options
38+
39+
**Option 1: Use default data directory** (recommended)
40+
```bash
41+
mkdir -p data
42+
cp /path/to/memory-bank/knowledge/20251006-tbtc-proof-of-funds.json data/tbtc-proof-of-funds.json
43+
cp /path/to/memory-bank/knowledge/threshold_stakers_may_2025.csv data/threshold_stakers_may_2025.csv
44+
```
45+
46+
**Option 2: Use environment variables**
47+
```bash
48+
# Add to .env file:
49+
PROOF_OF_FUNDS_PATH=/custom/path/to/tbtc-proof-of-funds.json
50+
THRESHOLD_STAKERS_CSV_PATH=/custom/path/to/threshold_stakers_may_2025.csv
51+
```
52+
1953
## What This Does
2054

2155
Analyzes tBTC wallets to identify which contain deprecated operators being removed during consolidation.

scripts/wallet-operator-mapper/analyze-per-operator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,10 @@ Object.entries(operatorShares).forEach(([addr, data]) => {
119119
if (providerShares[data.provider]) {
120120
if (data.status === 'KEEP') {
121121
providerShares[data.provider].keep += data.totalShare;
122-
providerShares[data.provider].keepWallets = data.walletCount;
122+
providerShares[data.provider].keepWallets += data.walletCount;
123123
} else {
124124
providerShares[data.provider].disable += data.totalShare;
125-
providerShares[data.provider].disableWallets = data.walletCount;
125+
providerShares[data.provider].disableWallets += data.walletCount;
126126
}
127127
}
128128
});

scripts/wallet-operator-mapper/query-dkg-events.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ if (limitArg) {
2929
}
3030

3131
// File paths
32-
const PROOF_OF_FUNDS_PATH = '/Users/leonardosaturnino/Documents/GitHub/memory-bank/20250809-beta-staker-consolidation/knowledge/20251006-tbtc-proof-of-funds.json';
32+
const PROOF_OF_FUNDS_PATH = process.env.PROOF_OF_FUNDS_PATH ||
33+
path.join(__dirname, 'data', 'tbtc-proof-of-funds.json');
3334
const OPERATORS_PATH = path.join(__dirname, 'operators.json');
3435
const BRIDGE_CONTRACT_PATH = path.join(__dirname, 'contracts', 'Bridge.json');
3536
const OUTPUT_PATH = path.join(__dirname, 'wallet-operator-mapping.json');

scripts/wallet-operator-mapper/validate-operator-list.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const fs = require('fs');
1010
const path = require('path');
1111

1212
const MAPPING_FILE = path.join(__dirname, 'wallet-operator-mapping.json');
13-
const CSV_PATH = '/Users/leonardosaturnino/Documents/GitHub/memory-bank/20250809-beta-staker-consolidation/knowledge/threshold_stakers_may_2025.csv';
13+
const CSV_PATH = process.env.THRESHOLD_STAKERS_CSV_PATH ||
14+
path.join(__dirname, 'data', 'threshold_stakers_may_2025.csv');
1415

1516
console.log('🔍 Operator List Validation\n');
1617
console.log('='.repeat(80));

0 commit comments

Comments
 (0)