Get started analyzing Zcash compact block overhead in 5 minutes.
# Check Rust is installed
rustc --version
# Check Python is installed
python --version # Should be 3.8+
# Check Zebrad is running
curl -X POST http://127.0.0.1:8232 -d '{"method":"getblockcount","params":[],"id":1}'
# Check lightwalletd is running
grpcurl -plaintext localhost:9067 listcargo new compact_block_analyzer
cd compact_block_analyzer
mkdir proto# Clone the lightwallet-protocol repo
git clone https://github.com/zcash/lightwallet-protocol.git temp_proto
cd temp_proto
git fetch origin pull/1/head:pr-1
git checkout pr-1
# Copy proto files
cp compact_formats.proto ../proto/
cp service.proto ../proto/
cd ..
rm -rf temp_protoCreate build.rs:
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.build_server(false)
.compile(
&["proto/service.proto", "proto/compact_formats.proto"],
&["proto/"],
)?;
Ok(())
}Replace Cargo.toml and src/main.rs with the provided artifacts.
cargo build --releasecargo run --release -- \
http://127.0.0.1:9067 \
http://127.0.0.1:8232 \
range 2400000 2400100 \
test.csvcargo run --release -- \
http://127.0.0.1:9067 \
http://127.0.0.1:8232 \
recommended \
results.csvThis will:
- Sample 5000 blocks strategically across all eras
- Take ~30 minutes (100ms delay between blocks)
- Provide statistically significant results
# Install Python dependencies
pip install pandas matplotlib seaborn numpy scipy
# Generate all charts
python visualize.py results.csvOpen charts/statistical_report.txt to see the analysis!
-
Median overhead (in the report)
- This is the "typical" overhead
- Most important single number
-
95th percentile (in the report)
- Worst-case planning
- Important for capacity planning
-
Distribution chart (
charts/distribution.png)- Shows the spread of overhead values
- Look for the shape (normal, skewed, bimodal?)
-
Bandwidth impact chart (
charts/bandwidth_impact.png)- Practical impact: MB per day, sync time, cost
- This makes the numbers concrete
The report will tell you:
- < 20% median overhead: Low impact, consider making it default
- 20-50% median overhead: Moderate impact, consider opt-in
- > 50% median overhead: High impact, needs separate method
# Restart lightwalletd
lightwalletd --grpc-bind-addr=127.0.0.1:9067 --zcash-conf-path=/path/to/zebra.conf# Check zebrad is running
ps aux | grep zebrad
# Check zebra.toml has RPC enabled
# Should have [rpc] section with listen_addr = "127.0.0.1:8232"# Ensure proto files exist
ls -la proto/
# Clean and rebuild
cargo clean
cargo build --release# Install all dependencies
pip install -r requirements.txt# Quick analysis (1500 blocks, ~15 minutes)
cargo run --release -- http://127.0.0.1:9067 http://127.0.0.1:8232 quick quick.csv
# Thorough analysis (11000 blocks, ~2 hours)
cargo run --release -- http://127.0.0.1:9067 http://127.0.0.1:8232 thorough thorough.csv
# Equal samples per era
cargo run --release -- http://127.0.0.1:9067 http://127.0.0.1:8232 equal equal.csv# Pre-Sapling era (heavy transparent)
cargo run --release -- http://127.0.0.1:9067 http://127.0.0.1:8232 range 100000 101000 pre_sapling.csv
# Recent blocks
cargo run --release -- http://127.0.0.1:9067 http://127.0.0.1:8232 range 2400000 2401000 recent.csv
# Visualize both
python visualize.py pre_sapling.csv -o charts_pre_sapling
python visualize.py recent.csv -o charts_recent- Read
statistical_report.txtfor detailed analysis - Examine correlation charts to understand what drives overhead
- Look at heatmaps to see how overhead varies by transaction patterns
- Check time series to see trends over blockchain history
-
Use 'recommended' mode for most analyses
- Balanced, statistically sound
- Reasonable time (~30 minutes)
-
Run multiple samples if results seem unexpected
- Sampling has some variance
- Multiple runs can confirm findings
-
Focus on recent blocks for current decisions
- Old blocks less relevant for current usage
- But historical context helps understand trends
-
Look at the whole picture
- Don't just look at mean/median
- Check the distribution, outliers, worst-case
-
Consider practical impact
- MB per day matters more than abstract percentages
- Think about mobile users, limited bandwidth
- Check
README.mdfor full documentation - Check
.claude_project_context.mdfor technical details - Check
AI_DISCLAIMER.mdfor limitations - Open an issue if you find bugs
- Validate results against your own calculations
Happy analyzing! 🚀