diff --git a/AITBC_FIXES_20260313.md b/AITBC_FIXES_20260313.md new file mode 100644 index 00000000..c07ccef5 --- /dev/null +++ b/AITBC_FIXES_20260313.md @@ -0,0 +1,139 @@ +# AITBC System Fixes - 2026-03-13 + +## Issues Resolved + +### 1. Matrix Agent Not Responding +**Problem:** Agent read messages but didn't answer due to duplicate plugin loading. + +**Root Cause:** Two copies of the Matrix plugin existed: +- System: `/usr/lib/node_modules/openclaw/extensions/matrix` +- Local: `/root/.openclaw/extensions/matrix` + +**Fix:** +- Removed both copies +- Reinstalled via `openclaw plugins install @openclaw/matrix` (v2026.3.12) to local extensions +- Removed conflicting system copy +- Added `groupAllowFrom: ["*"]` to allow all senders in allowed rooms +- Added room settings: `autoReply: true`, `requireMention: false` + +**Status:** ✅ Matrix channel working, no duplicate warnings. + +--- + +### 2. Blockchain Node - Missing `chain_id` Column +**Problem:** `Failed to propose block` error: `no such column: chain_id`. + +**Root Cause:** The `mempool` table (in `data/mempool.db`) lacked the `chain_id` column, required by the database-backed mempool implementation. The `block` table already had it. + +**Fix:** +```sql +ALTER TABLE mempool ADD COLUMN chain_id VARCHAR NOT NULL DEFAULT 'ait-devnet'; +CREATE INDEX idx_mempool_chain_id ON mempool(chain_id); +``` + +**Status:** ✅ PoA proposer now runs without errors. + +--- + +### 3. Missing RPC Endpoint `/rpc/mempool` +**Problem:** `GET /rpc/mempool` returned 404 Not Found. + +**Root Cause:** The endpoint was not implemented in the RPC router. + +**Fix:** Added to `/opt/aitbc/apps/blockchain-node/src/aitbc_chain/rpc/router.py`: + +```python +@router.get("/mempool", summary="Get mempool transactions") +async def get_mempool_endpoint(chain_id: str = "ait-devnet", limit: int = 100) -> Dict[str, Any]: + """Get pending transactions in the mempool for a chain""" + ... +``` + +**Status:** ✅ Endpoint now returns mempool data (empty if no transactions). + +--- + +## Tools Installed + +### System (apt) +- sqlite3, strace, ltrace, gdb, psmisc, lsof, net-tools, iproute2 +- python3-venv, python3-pip, python3-dev, build-essential +- curl, wget, git, jq, htop, nmap + +### Python (pip) +- ipdb, ptpython, ipython, debugpy +- memory_profiler, line_profiler +- py-spy, snakeviz +- rich, traceback-with-variables +- pytest, pytest-cov, pytest-xdist, hypothesis + +--- + +## Git Repository + +Workspace initialized at `/root/.openclaw/workspace`: +- Tracked config files: `openclaw.json`, identity files, SOUL.md, etc. +- `.gitignore` excludes sensitive data (credentials, sessions, logs) +- Remote: `git@gitea.bubuit.net:oib/aitbc.git` (SSH deploy key added) + +**Note:** Application code (`/opt/aitbc/apps/...`) is separate and not in this repo. + +--- + +## Current Running Services + +- OpenClaw Gateway (matrix + webchat) +- Blockchain Node (PoA proposer active) +- Uvicorn RPC server on port 8006 +- Uvicorn app on port 8025 + +--- + +## Verification + +```bash +# Matrix agent +openclaw channels status --probe + +# Blockchain RPC +curl http://localhost:8006/rpc/head +curl "http://localhost:8006/rpc/mempool?chain_id=ait-devnet" + +# Logs +tail -f /var/log/aitbc_node.log +``` + +--- + +## Recommendations + +### Security (Matrix Agent) +Currently `groupAllowFrom: ["*"]` with `requireMention: false` means **anyone** in allowed rooms can trigger arbitrary code execution (coding profile). Consider: + +```json +"channels": { + "matrix": { + "groupPolicy": "allowlist", + "groups": { + "!TuWuNlZVCNESaZmHiA:matrix.bubuit.net": { + "allow": true, + "autoReply": true, + "requireMention": true, + "users": ["@your_user_id:matrix.bubuit.net"] + } + } + } +} +``` + +### Database Migrations +Future schema changes should use Alembic migrations. The `mempool` table needs an Alembic migration to add `chain_id` for consistency. + +### Monitoring +- Set up log rotation for `/var/log/aitbc_node.log` +- Monitor `/rpc/metrics` for Prometheus metrics +- Watch for repeated `Failed to propose block` errors + +--- + +**All critical issues resolved as of 2026-03-13 19:00 UTC.**