diff --git a/BOOTSTRAP.md b/BOOTSTRAP.md index 5de3242..4591ea9 100644 --- a/BOOTSTRAP.md +++ b/BOOTSTRAP.md @@ -14,60 +14,21 @@ Fast-sync your Raspberry Pi node with pre-synced blockchain data. - Start from latest block height - Ready to mine in minutes - Minimal resource usage -- Only ~500MB download +- Download current blockchain snapshot -### Creating a Blockchain Snapshot +### Installation -Run on a fully-synced node (DNS2, DNS3, etc.): +The TRI-PI installer offers automatic blockchain bootstrap during setup: ```bash -# Download snapshot creator -curl -L -o create-snapshot.sh \ - https://raw.githubusercontent.com/SamiAhmed7777/tri-pi/main/scripts/create-blockchain-snapshot.sh - -chmod +x create-snapshot.sh - -# Create snapshot (stops daemon temporarily) -./create-snapshot.sh +curl -sSL https://raw.githubusercontent.com/SamiAhmed7777/tri-pi/main/bootstrap.sh | bash ``` -**Output:** -- `tri-blockchain-v5.4.4-YYYY-MM-DD.tar.gz` - Compressed blockchain -- `snapshot-info.txt` - Metadata (block height, checksums) +When prompted, choose **option 1** to download the pre-synced blockchain. -### Hosting the Snapshot +### What Gets Downloaded -**Option 1: GitHub Release** (recommended for public distribution) -```bash -gh release upload v5.4.4 tri-blockchain-*.tar.gz -``` - -**Option 2: Dropbox** -```bash -dbxcli put tri-blockchain-*.tar.gz /Krystie/TRI/ -dbxcli share /Krystie/TRI/tri-blockchain-*.tar.gz -``` - -**Option 3: Custom Web Server** -```bash -scp tri-blockchain-*.tar.gz user@server:/var/www/html/tri/ -# Access at: https://example.com/tri/tri-blockchain-v5.4.4-2026-04-01.tar.gz -``` - -### Updating Bootstrap Script - -After uploading, update `bootstrap.sh`: - -```bash -# Edit line 9 -BLOCKCHAIN_URL="https://your-url-here/tri-blockchain-latest.tar.gz" -``` - -Commit and push to make it available to all Pi users! - -### Snapshot Contents - -**Included:** +The bootstrap package includes: - `blk*.dat` - Blockchain data files - `database/` - Block index - `txleveldb/` - Transaction index @@ -75,47 +36,58 @@ Commit and push to make it available to all Pi users! - `peers.dat` - Known peer cache - `smsg.ini` - Messaging config -**Excluded (for security/privacy):** -- `wallet.dat` - NEVER include! Contains private keys -- `debug.log` - Large, regenerated on run -- `onion/` - Regenerated automatically -- `tor_data/` - Regenerated automatically +**Not included (for security):** +- `wallet.dat` - Your wallet is created fresh on first run +- `debug.log` - Generated during operation +- `onion/` - Hidden service keys generated automatically +- `tor_data/` - Tor state regenerated on startup -### Maintenance Schedule +### After Installation -**Recommended:** Create new snapshots weekly/monthly as blockchain grows. - -Automation example (cron): +Start your node: ```bash -# Every Sunday at 2 AM -0 2 * * 0 /usr/local/bin/create-snapshot.sh && \ - gh release upload v5.4.4 /tmp/tmp.*/tri-blockchain-*.tar.gz --clobber +trianglesd ``` -### Compression Stats +Check synchronization status: +```bash +trianglesd getinfo +``` -Typical compression with tar.gz: -- Original blockchain: ~2-5GB (depends on block height) -- Compressed: ~500MB-1.5GB -- Compression ratio: ~70-75% +The blockchain will continue syncing from the bootstrap snapshot's block height to the current network tip. + +### First Run + +On first startup, trianglesd will: +1. Load the bootstrap blockchain data +2. Generate a fresh wallet.dat +3. Create Tor hidden service keys +4. Begin syncing remaining blocks +5. Connect to the network via onion seeds + +**Tip:** Watch sync progress with: +```bash +watch -n5 'trianglesd getinfo | grep blocks' +``` ### Security Notes -1. **Never include wallet.dat** - Contains private keys! -2. **Verify checksums** - Always provide SHA256 hashes -3. **Trust** - Only use snapshots from trusted sources -4. **Update regularly** - Stale snapshots still require catching up +1. **Fresh wallet** - Always generated locally, never downloaded +2. **Verify source** - Only use bootstrap from trusted URLs +3. **Network sync** - Remaining blocks verified via network consensus +4. **Regular updates** - Bootstrap snapshot updated weekly -### Testing +### Troubleshooting -Before releasing publicly: +**If bootstrap download fails:** +- Installer automatically falls back to full sync from genesis +- You can manually download and extract: + ```bash + cd ~/.triangles + curl -O http://194.233.88.206:8085/triangles-bootstrap.tar.gz + tar xzf triangles-bootstrap.tar.gz + ``` -```bash -# On a fresh Pi -rm -rf ~/.triangles -curl -sSL https://raw.githubusercontent.com/SamiAhmed7777/tri-pi/main/bootstrap.sh | bash -# Choose option 1 (bootstrap download) - -# Verify it starts from correct block -trianglesd getinfo | grep blocks -``` +**Snapshot too old?** +- No problem! Your node will sync the remaining blocks automatically +- This is still much faster than syncing from block 0 diff --git a/scripts/create-blockchain-snapshot.sh b/scripts/create-blockchain-snapshot.sh deleted file mode 100755 index 49dc800..0000000 --- a/scripts/create-blockchain-snapshot.sh +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -# TRI-PI Blockchain Bootstrap Snapshot Creator -# Creates compressed blockchain archive for fast Pi sync - -set -e - -VERSION="v5.4.4" -SNAPSHOT_DATE=$(date +%Y-%m-%d) -SNAPSHOT_NAME="tri-blockchain-${VERSION}-${SNAPSHOT_DATE}.tar.gz" -TRI_DATA_DIR="$HOME/.triangles" - -echo "╔═══════════════════════════════════════╗" -echo "║ TRI-PI Blockchain Snapshot Creator ║" -echo "╚═══════════════════════════════════════╝" -echo "" - -# Check if daemon is running -if pgrep -x trianglesd > /dev/null; then - echo "⚠️ trianglesd is running. Stopping for clean snapshot..." - trianglesd stop - sleep 5 -fi - -# Check blockchain exists -if [[ ! -d "$TRI_DATA_DIR" ]]; then - echo "❌ Error: Triangles data directory not found at $TRI_DATA_DIR" - exit 1 -fi - -# Get block count from last run -BLOCK_COUNT=$(grep -oP 'height=\K[0-9]+' "$TRI_DATA_DIR/debug.log" 2>/dev/null | tail -1 || echo "unknown") - -echo "📊 Blockchain Stats:" -echo " Location: $TRI_DATA_DIR" -echo " Block height: $BLOCK_COUNT" -echo " Size: $(du -sh $TRI_DATA_DIR | cut -f1)" -echo "" - -# Create temp directory -TEMP_DIR=$(mktemp -d) -SNAPSHOT_DIR="$TEMP_DIR/triangles-data" -mkdir -p "$SNAPSHOT_DIR" - -echo "📦 Creating snapshot..." - -# Copy essential blockchain files (exclude wallet and logs) -echo " • Copying blockchain data..." -cp -r "$TRI_DATA_DIR/blk"* "$SNAPSHOT_DIR/" 2>/dev/null || true -cp -r "$TRI_DATA_DIR/database" "$SNAPSHOT_DIR/" 2>/dev/null || true -cp -r "$TRI_DATA_DIR/txleveldb" "$SNAPSHOT_DIR/" 2>/dev/null || true -cp -r "$TRI_DATA_DIR/smsgDB" "$SNAPSHOT_DIR/" 2>/dev/null || true -cp "$TRI_DATA_DIR/peers.dat" "$SNAPSHOT_DIR/" 2>/dev/null || true -cp "$TRI_DATA_DIR/smsg.ini" "$SNAPSHOT_DIR/" 2>/dev/null || true - -# DO NOT include: -# - wallet.dat (user-specific, contains private keys!) -# - debug.log (grows large, not needed) -# - db.log (not needed) -# - onion/ (regenerated on first run) -# - tor_data/ (regenerated) - -echo " • Compressing (this may take a few minutes)..." -cd "$TEMP_DIR" -tar czf "$SNAPSHOT_NAME" triangles-data/ - -# Calculate size reduction -ORIGINAL_SIZE=$(du -sb "$TRI_DATA_DIR" | cut -f1) -COMPRESSED_SIZE=$(stat -c%s "$SNAPSHOT_NAME") -REDUCTION=$(echo "scale=1; (1 - $COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100" | bc) - -echo "" -echo "✅ Snapshot created successfully!" -echo "" -echo "📊 Compression Stats:" -echo " Original size: $(numfmt --to=iec-i --suffix=B $ORIGINAL_SIZE)" -echo " Compressed size: $(numfmt --to=iec-i --suffix=B $COMPRESSED_SIZE)" -echo " Reduction: ${REDUCTION}%" -echo "" -echo "📁 Snapshot file:" -echo " $TEMP_DIR/$SNAPSHOT_NAME" -echo "" -echo "📝 Metadata:" -cat > "$TEMP_DIR/snapshot-info.txt" << INFO -TRI-PI Blockchain Bootstrap Snapshot -===================================== -Version: $VERSION -Date: $SNAPSHOT_DATE -Block Height: $BLOCK_COUNT -Original Size: $(numfmt --to=iec-i --suffix=B $ORIGINAL_SIZE) -Compressed Size: $(numfmt --to=iec-i --suffix=B $COMPRESSED_SIZE) -Compression: ${REDUCTION}% - -SHA256: $(sha256sum "$SNAPSHOT_NAME" | cut -d' ' -f1) - -Installation: -1. Extract to ~/.triangles/ -2. Start trianglesd -3. Blockchain resumes from block $BLOCK_COUNT - -Contents: -- Blockchain files (blk*.dat) -- Database -- Transaction index -- Peer cache -INFO - -cat "$TEMP_DIR/snapshot-info.txt" -echo "" -echo "Next steps:" -echo "1. Upload to hosting: scp $TEMP_DIR/$SNAPSHOT_NAME user@server:/path/" -echo "2. Update bootstrap.sh with download URL" -echo "3. Test on fresh Pi" -echo "" -echo "Clean up when done: rm -rf $TEMP_DIR"