From 941fff1b9d0f55c98ff2f26eaa57fefdc2e09c8e Mon Sep 17 00:00:00 2001 From: aitbc Date: Wed, 22 Apr 2026 13:41:06 +0200 Subject: [PATCH] Fix sync error: use block_data['height'] instead of undefined height variable --- aitbc/constants.py | 30 +++++++++++++ aitbc/exceptions.py | 44 ++++++++++++++++++++ apps/blockchain-node/src/aitbc_chain/sync.py | 2 +- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 aitbc/constants.py create mode 100644 aitbc/exceptions.py diff --git a/aitbc/constants.py b/aitbc/constants.py new file mode 100644 index 00000000..3927d5cb --- /dev/null +++ b/aitbc/constants.py @@ -0,0 +1,30 @@ +""" +AITBC Common Constants +Centralized constants for AITBC system paths and configuration +""" + +from pathlib import Path + +# AITBC System Paths +DATA_DIR = Path("/var/lib/aitbc") +CONFIG_DIR = Path("/etc/aitbc") +LOG_DIR = Path("/var/log/aitbc") +REPO_DIR = Path("/opt/aitbc") + +# Common subdirectories +KEYSTORE_DIR = DATA_DIR / "keystore" +BLOCKCHAIN_DATA_DIR = DATA_DIR / "data" / "ait-mainnet" +MARKETPLACE_DATA_DIR = DATA_DIR / "data" / "marketplace" + +# Configuration files +ENV_FILE = CONFIG_DIR / ".env" +NODE_ENV_FILE = CONFIG_DIR / "node.env" + +# Default ports +BLOCKCHAIN_RPC_PORT = 8006 +BLOCKCHAIN_P2P_PORT = 7070 +AGENT_COORDINATOR_PORT = 9001 +MARKETPLACE_PORT = 8081 + +# Package version +PACKAGE_VERSION = "0.3.0" diff --git a/aitbc/exceptions.py b/aitbc/exceptions.py new file mode 100644 index 00000000..4687b4a7 --- /dev/null +++ b/aitbc/exceptions.py @@ -0,0 +1,44 @@ +""" +AITBC Exception Hierarchy +Base exception classes for AITBC applications +""" + + +class AITBCError(Exception): + """Base exception for all AITBC errors""" + pass + + +class ConfigurationError(AITBCError): + """Raised when configuration is invalid or missing""" + pass + + +class NetworkError(AITBCError): + """Raised when network operations fail""" + pass + + +class AuthenticationError(AITBCError): + """Raised when authentication fails""" + pass + + +class EncryptionError(AITBCError): + """Raised when encryption or decryption fails""" + pass + + +class DatabaseError(AITBCError): + """Raised when database operations fail""" + pass + + +class ValidationError(AITBCError): + """Raised when input validation fails""" + pass + + +class BridgeError(AITBCError): + """Base exception for bridge errors""" + pass diff --git a/apps/blockchain-node/src/aitbc_chain/sync.py b/apps/blockchain-node/src/aitbc_chain/sync.py index 83facfce..ae3fbe60 100755 --- a/apps/blockchain-node/src/aitbc_chain/sync.py +++ b/apps/blockchain-node/src/aitbc_chain/sync.py @@ -380,7 +380,7 @@ class ChainSync: if computed_root != expected_root: logger.warning( - f"[SYNC] State root mismatch at height {height}: " + f"[SYNC] State root mismatch at height {block_data['height']}: " f"expected {expected_root.hex()}, computed {computed_root.hex()}" ) # For now, log warning but accept block (to be enforced in Phase 1.3)