feat: implement automatic bulk sync for blockchain nodes
Some checks failed
Integration Tests / test-service-integration (push) Failing after 8s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 2s
P2P Network Verification / p2p-verification (push) Successful in 2s
Python Tests / test-python (push) Successful in 17s
Security Scanning / security-scan (push) Failing after 37s
Blockchain Synchronization Verification / sync-verification (push) Failing after 2s

- Add auto_sync_enabled, auto_sync_threshold, auto_sync_max_retries config
- Add min_bulk_sync_interval for rate limiting
- Implement gap detection in process_blocks() with automatic bulk sync trigger
- Add rate limiting to ChainSync.bulk_import_from() to prevent sync loops
- Automatic bulk sync triggers when gap > threshold (default 10 blocks)
- Retries block import after bulk sync completes
- Logs sync events for monitoring and debugging
This commit is contained in:
aitbc
2026-04-20 21:11:01 +02:00
parent 1053431ea6
commit 4f157e21ee
3 changed files with 60 additions and 0 deletions

View File

@@ -68,6 +68,12 @@ class ChainSettings(BaseSettings):
trusted_proposers: str = "" # comma-separated list of trusted proposer IDs
max_reorg_depth: int = 10 # max blocks to reorg on conflict
sync_validate_signatures: bool = True # validate proposer signatures on import
# Automatic bulk sync settings
auto_sync_enabled: bool = True # enable automatic bulk sync when gap detected
auto_sync_threshold: int = 10 # blocks gap threshold to trigger bulk sync
auto_sync_max_retries: int = 3 # max retry attempts for automatic bulk sync
min_bulk_sync_interval: int = 60 # minimum seconds between bulk sync attempts
gossip_backend: str = "memory"
gossip_broadcast_url: Optional[str] = None