Overview
Validation ensures that your blockchain maintains its integrity by verifying cryptographic signatures, hash chains, and data consistency. Regular validation confirms that no tampering has occurred.Basic Validation
Run the validate command to check blockchain integrity:What Gets Validated
The validation process performs comprehensive checks:1. Genesis Block Verification
- Confirms genesis block exists at height 0
- Verifies genesis block structure
- Checks initial creator public key
2. Chain Continuity
For each block in sequence:- Each block’s
prev_hashmatches the previous block’shash - Block heights increment sequentially
- No gaps in the chain
3. Cryptographic Signatures
Every block’s signature is verified:4. Merkle Tree Verification
Results are verified against the Merkle root:- Reconstruct Merkle tree from block results
- Compare calculated root with stored
merkle_root - Ensures results haven’t been tampered with
5. Data Integrity
Validate result data:- Station IDs exist in database
- Candidate IDs exist in database
- Vote counts are non-negative
- Timestamps are valid
Detecting Tampering
Let’s demonstrate how validation detects tampering:Query shows tampered data
Query the blockchain - it will show the modified value:The tampered value (71) appears in the output.
This demonstrates Ubu-Block’s core principle: No “fungua servers” - data cannot be secretly modified without detection.
Validation Algorithm
The validation process follows this algorithm:Validation Frequency
When to Validate
After receiving new blocks
After receiving new blocks
When your node receives blocks from peers, validate before accepting:
Scheduled validation
Scheduled validation
Run periodic validation to detect corruption:
After database operations
After database operations
Validate after any manual database operations or maintenance.
Before critical operations
Before critical operations
Validate before:
- Generating reports
- Syncing with new peers
- Backup operations
Performance Considerations
Validation complexity:- Time Complexity: O(n) where n is the number of blocks
- Space Complexity: O(1) - processes blocks sequentially
Error Types
Invalid Signature
- Block may be corrupted
- Wrong public key used
- Check if block was transmitted correctly
Broken Chain
- Database corruption
- Missing blocks
- Attempt to restore from backup or resync
Merkle Root Mismatch
- Results table was modified
- Restore results from the correct source
- Resync from trusted peer
Validation in P2P Networks
When running as a P2P node, validation occurs automatically:Invalid blocks are rejected before being added to your local blockchain. This prevents propagation of corrupted data.
Validation Reporting
For detailed validation reports, use direct database queries:Recovering from Validation Failures
Option 1: Restore from Backup
If you have a known-good backup:Option 2: Resync from Network
Resync the blockchain from trusted peers:Option 3: Manual Repair
For specific corruption, manual SQL repair may be possible (advanced users only).Best Practices
- Regular Validation: Run validation at least daily
- Automated Monitoring: Set up alerts for validation failures
- Backup Strategy: Maintain verified backups
- Immutable Storage: Use read-only filesystems when possible
- Audit Logs: Keep logs of all validation runs