Fix genesis creation to only run when block production is enabled
Some checks failed
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (push) Has been cancelled
Multi-Node Stress Testing / stress-test (push) Has been cancelled
Blockchain Synchronization Verification / sync-verification (push) Has been cancelled
Coverage Phase 1 (70% Target) / test-coverage-70 (push) Has been cancelled
Coverage Phase 2 (85% Target) / test-coverage-85 (push) Has been cancelled
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Has been cancelled
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Has been cancelled
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Has been cancelled
Cross-Chain Functionality Tests / aggregate-results (push) Has been cancelled
Integration Tests / test-service-integration (push) Has been cancelled
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Has been cancelled
Multi-Node Blockchain Health Monitoring / health-check (push) Has been cancelled
Node Failover Simulation / failover-test (push) Has been cancelled
P2P Network Verification / p2p-verification (push) Has been cancelled
Python Tests / test-python (push) Has been cancelled
Security Scanning / security-scan (push) Has been cancelled

- Move _ensure_genesis_for_chains() inside block production enabled check in main.py
- Prevents follower nodes from creating local genesis blocks
- Removes redundant genesis check from poa.start() since genesis creation is now controlled at startup
- Follower nodes will sync genesis from hub instead of creating their own
This commit is contained in:
aitbc
2026-05-26 19:53:16 +02:00
parent f06ac1142d
commit c84d81cb2d
2 changed files with 1 additions and 9 deletions

View File

@@ -124,14 +124,6 @@ class PoAProposer:
if not getattr(settings, "enable_block_production", True):
self._logger.info("Block production disabled, skipping PoA proposer loop")
return
# Check if genesis block exists before starting proposer loop
with self._session_factory() as session:
genesis = session.exec(
select(Block).where(Block.chain_id == self._config.chain_id).where(Block.height == 0).limit(1)
).first()
if genesis is None:
self._logger.warning("No genesis block found, skipping PoA proposer loop. Block production requires a genesis block.")
return
self._logger.info("Starting PoA proposer loop", extra={"interval": self._config.interval_seconds})
await self._ensure_genesis_block()

View File

@@ -287,9 +287,9 @@ class BlockchainNode:
else:
logger.warning("Island manager not available - island operations will be disabled")
await self._ensure_genesis_for_chains()
# Start proposers only if enabled (followers set enable_block_production=False)
if self._block_production_enabled():
await self._ensure_genesis_for_chains()
self._start_proposers()
else:
logger.info("Block production disabled on this node", extra={"proposer_id": settings.proposer_id})