From 20b96881c4a4bdadd62dbb232506c51ec88ba9a5 Mon Sep 17 00:00:00 2001 From: aitbc Date: Wed, 15 Apr 2026 11:32:50 +0200 Subject: [PATCH] Fix RPC block production override and restore coordinator env vars after consolidation --- apps/blockchain-node/src/aitbc_chain/app.py | 9 ++++++++- examples/deploy.env.example | 1 + systemd/aitbc-blockchain-rpc.service | 4 ++-- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 120000 examples/deploy.env.example diff --git a/apps/blockchain-node/src/aitbc_chain/app.py b/apps/blockchain-node/src/aitbc_chain/app.py index 7ce44436..da0f5a6e 100755 --- a/apps/blockchain-node/src/aitbc_chain/app.py +++ b/apps/blockchain-node/src/aitbc_chain/app.py @@ -1,6 +1,7 @@ from __future__ import annotations import asyncio +import os import time from collections import defaultdict from contextlib import asynccontextmanager @@ -101,9 +102,15 @@ async def lifespan(app: FastAPI): ) await gossip_broker.set_backend(backend) proposers = [] + block_production_override = os.getenv("enable_block_production") + if block_production_override is None: + block_production_override = os.getenv("ENABLE_BLOCK_PRODUCTION") + block_production_enabled = settings.enable_block_production + if block_production_override is not None: + block_production_enabled = block_production_override.strip().lower() in {"1", "true", "yes", "on"} # Initialize PoA proposer for mining integration - if settings.enable_block_production and settings.proposer_id: + if block_production_enabled and settings.proposer_id: try: from .consensus import PoAProposer, ProposerConfig supported_chains = [c.strip() for c in settings.supported_chains.split(",") if c.strip()] diff --git a/examples/deploy.env.example b/examples/deploy.env.example new file mode 120000 index 00000000..758c711b --- /dev/null +++ b/examples/deploy.env.example @@ -0,0 +1 @@ +../scripts/deployment/deploy/.env.deploy.example \ No newline at end of file diff --git a/systemd/aitbc-blockchain-rpc.service b/systemd/aitbc-blockchain-rpc.service index f4fd6a68..68a933a3 100644 --- a/systemd/aitbc-blockchain-rpc.service +++ b/systemd/aitbc-blockchain-rpc.service @@ -9,10 +9,10 @@ Group=root WorkingDirectory=/opt/aitbc/apps/blockchain-node EnvironmentFile=/etc/aitbc/.env EnvironmentFile=/etc/aitbc/node.env -Environment=enable_block_production=false Environment=PATH=/usr/bin:/usr/local/bin:/usr/bin:/bin Environment=PYTHONPATH=/opt/aitbc/apps/blockchain-node/src:/opt/aitbc/apps/blockchain-node/scripts -ExecStart=/opt/aitbc/venv/bin/python -m uvicorn aitbc_chain.app:app --host ${rpc_bind_host} --port ${rpc_bind_port} +UnsetEnvironment=enable_block_production ENABLE_BLOCK_PRODUCTION +ExecStart=/usr/bin/env enable_block_production=false /opt/aitbc/venv/bin/python -m uvicorn aitbc_chain.app:app --host ${rpc_bind_host} --port ${rpc_bind_port} Restart=always RestartSec=5 StandardOutput=journal