Add genesis block existence check to PoA proposer start() method
Some checks failed
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
Cross-Node Transaction Testing / transaction-test (push) Has been cancelled
Deploy to Testnet / deploy-testnet (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
Multi-Node Stress Testing / stress-test (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

- Block production now requires a genesis block to exist before starting
- Prevents automatic local genesis creation and subsequent chain divergence
- Follower nodes without genesis will not produce blocks even if proposer_id is present
This commit is contained in:
aitbc
2026-05-26 19:38:58 +02:00
parent 7f1c8794c3
commit f06ac1142d

View File

@@ -124,6 +124,14 @@ 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()