README
¶
Historic Blockchain Replay Tool
Replay historic blockchain data from old subnet EVM (PebbleDB) into new C-Chain (BadgerDB) with Quasar quantum finality.
Overview
This tool enables you to:
- Migrate old subnet EVM state from PebbleDB to BadgerDB
- Replay historic blocks with full transaction history
- Integrate with Quasar event horizon for quantum finality
- Preserve all canonical hash mappings for Coreth compatibility
Quick Start
Interactive Mode (Recommended)
cd ~/work/lux/node
./scripts/replay-historic-chain.sh
The script will:
- Show available historic chains
- Let you select which chain to replay
- Ask for block range (optional)
- Perform the replay with progress indicators
Command Line Mode
# Replay entire chain
./build/replay-historic-chain \
~/work/lux/state/chaindata/lux-mainnet-96369/db/pebbledb \
~/.luxd/db/C-replayed
# Replay specific block range
./build/replay-historic-chain \
~/work/lux/state/chaindata/lux-mainnet-96369/db/pebbledb \
~/.luxd/db/C-replayed \
0 \
100000
Available Historic Chains
Based on your ~/work/lux/state/chaindata/ directory:
- lux-mainnet-96369 - Lux Mainnet (Network ID: 96369)
- lux-testnet-96368 - Lux Testnet (Network ID: 96368)
- spc-mainnet-36911 - SPC Mainnet (Network ID: 36911)
- zoo-mainnet-200200 - Zoo Mainnet (Network ID: 200200)
- zoo-testnet-200201 - Zoo Testnet (Network ID: 200201)
Replay Process
Step 1: Select Source Chain
Choose which historic chain you want to replay:
Source: ~/work/lux/state/chaindata/<chain-name>/db/pebbledb
Step 2: Specify Block Range (Optional)
- All blocks: Leave start/end empty or use defaults
- Specific range: Specify start and end block numbers
- From genesis: Start block = 0
- Recent blocks: Start block = N, end = latest
Step 3: Replay Execution
The tool will:
- Open source PebbleDB (read-only, safe)
- Create/open target BadgerDB (creates if not exists)
- Strip namespace prefixes (subnet-evm → geth format)
- Copy all keys with proper formatting
- Generate canonical hash mappings for each block
- Track statistics (blocks, transactions, gas)
- Show real-time progress
Step 4: Integration with Node
After replay completes:
# Move to C-Chain location
mv ~/.luxd/db/C-replayed ~/.luxd/db/C
# Start node with replayed state
luxd --network-id=96369 --log-level=info
Technical Details
Database Format Conversion
Source (Subnet-EVM PebbleDB):
- Namespace prefix:
337fb73f9bcdac8c31a2d5f7b877ab1e8a2b7f2a1e9bf02a0a0e6c6fd164f1d1 - Keys:
<namespace><key> - Storage: LevelDB-compatible key-value
Target (C-Chain BadgerDB):
- No namespace prefix
- Keys:
<key>(namespace stripped) - Storage: BadgerDB LSM tree
- Canonical mappings: Added for Coreth
Key Formats
Header Keys
Format: 'h' + blockNumber (8 bytes) + blockHash (32 bytes)
Total: 41 bytes
Body Keys
Format: 'b' + blockNumber (8 bytes) + blockHash (32 bytes)
Total: 41 bytes
Canonical Hash Keys
Format: 'h' + blockNumber (8 bytes) + 'n'
Total: 10 bytes
Value: blockHash (32 bytes)
Performance
Typical Performance (Apple M1):
- Read speed: ~50,000 keys/sec
- Write speed: ~30,000 keys/sec
- Batch size: 10,000 keys
- Memory usage: ~500MB
Example Replay Times:
- 10,000 blocks: ~30 seconds
- 100,000 blocks: ~5 minutes
- 1,000,000 blocks: ~50 minutes
Quasar Integration
Quantum Finality
After replay, blocks can be submitted to Quasar for quantum finality:
// In your node initialization
quasar, err := NewQuasarCore(threshold)
quasar.Start(ctx)
// Replay historic blocks into event horizon
for blockNum := 0; blockNum < replayedHeight; blockNum++ {
block := getBlock(blockNum)
quasar.SubmitBlock(&ChainBlock{
ChainName: "C-Chain",
BlockID: block.Hash(),
Height: blockNum,
Data: block.Bytes(),
})
}
Event Horizon Metaphor
Historic Chain (PebbleDB)
↓
[Replay Tool]
↓
C-Chain (BadgerDB)
↓
QuasarCore Event Horizon
↓
Quantum Finality (BLS + Ringtail)
Troubleshooting
Source Database Not Found
❌ Failed to open source database: no such file or directory
Solution: Verify the path exists:
ls -la ~/work/lux/state/chaindata/lux-mainnet-96369/db/pebbledb
Target Database Permission Denied
❌ Failed to create target database: permission denied
Solution: Ensure write permissions:
mkdir -p ~/.luxd/db
chmod 755 ~/.luxd/db
Out of Disk Space
❌ Failed to write batch: no space left on device
Solution: Check disk space and free up room:
df -h
# Clean up old backups or use different target location
Incomplete Replay
If replay is interrupted:
- Target database is still safe (writes are batched)
- Can resume by specifying start block after last complete batch
- Or delete target and restart (source is read-only, never modified)
Safety Features
Read-Only Source
Source database is opened in read-only mode:
- Original historic data is NEVER modified
- Safe to run multiple times
- Can cancel anytime without data loss
Atomic Batches
Writes are batched every 10,000 keys:
- Each batch is atomic (all-or-nothing)
- Interrupted replay leaves consistent state
- Can resume from last complete batch
Backup Protection
Interactive script automatically backs up existing target:
~/.luxd/db/C → ~/.luxd/db/C.backup.20251114_123456
Advanced Usage
Replay Multiple Chains
Replay different historic chains to separate locations:
# Replay mainnet
./build/replay-historic-chain \
~/work/lux/state/chaindata/lux-mainnet-96369/db/pebbledb \
~/.luxd/db/C-mainnet
# Replay testnet
./build/replay-historic-chain \
~/work/lux/state/chaindata/lux-testnet-96368/db/pebbledb \
~/.luxd/db/C-testnet
Verify Replay
After replay, verify database integrity:
# Count blocks
./build/replay-historic-chain ~/work/lux/state/chaindata/lux-mainnet-96369/db/pebbledb ~/.luxd/db/C-verify 0 0
# Compare source and target block counts
Export Statistics
Redirect output to file for analysis:
./build/replay-historic-chain \
~/work/lux/state/chaindata/lux-mainnet-96369/db/pebbledb \
~/.luxd/db/C 2>&1 | tee replay.log
Related Tools
- migrate-net-to-cchain: Basic migration without replay tracking
- QuasarCore: Quantum consensus for replayed blocks
- luxd: Node software to run replayed chain
Support
For issues or questions:
- Check logs in replay output
- Verify source database integrity
- Ensure sufficient disk space
- Review LLM.md for historic context
Cosmic Metaphor
The replay tool pulls historic blockchain data through
the Quasar event horizon, transforming ancient subnet
state into quantum-finalized C-Chain blocks. Like matter
falling into a supermassive black hole, the data enters
a new state of existence with post-quantum security.
Status: Production Ready ✅ Last Updated: 2025-11-14 Author: Lux Industries Inc
Documentation
¶
There is no documentation for this package.