feat: complete codebase remediation with all phases
Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 56s
Blockchain Synchronization Verification / sync-verification (push) Failing after 3s
CLI Tests / test-cli (push) Failing after 5s
Coverage Phase 1 (70% Target) / test-coverage-70 (push) Failing after 19s
Coverage Phase 2 (85% Target) / test-coverage-85 (push) Failing after 18s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Successful in 3s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 4s
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Successful in 5s
Deploy to Testnet / deploy-testnet (push) Failing after 21s
Documentation Validation / validate-docs (push) Failing after 13s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Failing after 2s
Multi-Chain Island Architecture Tests / test-multi-chain-island (push) Successful in 4s
Multi-Node Blockchain Health Monitoring / health-check (push) Failing after 14s
Node Failover Simulation / failover-test (push) Successful in 9s
P2P Network Verification / p2p-verification (push) Successful in 5s
Package Tests / Python package - aitbc-agent-sdk (push) Successful in 51s
Package Tests / Python package - aitbc-core (push) Failing after 3s
Package Tests / Python package - aitbc-crypto (push) Successful in 22s
Package Tests / Python package - aitbc-sdk (push) Successful in 16s
Package Tests / JavaScript package - aitbc-sdk-js (push) Successful in 21s
Package Tests / JavaScript package - aitbc-token (push) Failing after 18s
Production Tests / Production Integration Tests (push) Failing after 1m9s
Python Tests / test-python (push) Failing after 3s
Security Scanning / security-scan (push) Failing after 41s
Smart Contract Tests / test-solidity (map[name:aitbc-contracts path:contracts]) (push) Failing after 6s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Failing after 7s
Smart Contract Tests / test-foundry (push) Failing after 20s
Smart Contract Tests / lint-solidity (push) Failing after 4s
Smart Contract Tests / deploy-contracts (push) Failing after 5s
Cross-Chain Functionality Tests / aggregate-results (push) Successful in 2s
Multi-Node Stress Testing / stress-test (push) Successful in 2s
Cross-Node Transaction Testing / transaction-test (push) Successful in 3s

Phase 1: Security fixes
- Added CORSMiddleware to marketplace-service with specific origins
- Fixed blockchain-node auth to fail closed on JWT errors
- Added security regression tests (test_cors_configuration.py, test_dispute_auth.py)

Phase 2: Repository cleanup
- Removed 51 fix/backup/legacy files
- Deleted marketplace-service-debug directory

Phase 3.1: Python version constraints
- Updated aitbc-crypto and aitbc-sdk with requires-python >=3.13
- Added explicit [tool.poetry].packages declarations

Phase 3.2: Agent service DI architecture
- Created aitbc-agent-core package with protocols and shared service
- Implemented adapters for agent-management and coordinator-api
- Created factory functions for gradual migration
- Added migration comments to existing integration files

Phase 4.1: Auth/utils extraction
- Created auth.py module with JWT validation and security utilities
- Created utils.py module with common helpers

Phase 4.2: Router decomposition
- Decomposed router.py into 10 domain modules (58 endpoints)
- Created route table snapshot for verification
- Preserved router_old.py as reference

Phase 5: App shell classification
- Documented app shell patterns across services

Phase 6: Quality gates
- Verified mypy type checking (75% error reduction)
- Analyzed logging inconsistencies with structlog migration plan
- Removed unused orjson dependency

Documentation:
- Created comprehensive remediation report
- Added architecture documentation for DI pattern
- Added quality analysis documents
This commit is contained in:
aitbc
2026-05-24 20:21:23 +02:00
parent 13ada12b49
commit 573aae065b
112 changed files with 9171 additions and 7831 deletions

View File

@@ -1,38 +0,0 @@
#!/bin/bash
set -e
# Extract the update
cd /home/oib/aitbc
tar -xzf update.tar.gz
# Deploy to blockchain-node
echo "Deploying to blockchain-node..."
sudo cp -r apps/blockchain-node/src/* /opt/blockchain-node/src/
sudo cp -r apps/blockchain-node/migrations/* /opt/blockchain-node/migrations/
# Deploy to coordinator-api
echo "Deploying to coordinator-api..."
sudo cp -r apps/coordinator-api/src/* /opt/coordinator-api/src/
# Stop services
sudo systemctl stop aitbc-blockchain-node-1 aitbc-blockchain-rpc-1 aitbc-coordinator-api || true
sudo systemctl stop aitbc-blockchain-node aitbc-blockchain-rpc || true
# Run DB Migrations
echo "Running DB migrations..."
cd /opt/blockchain-node
# Drop the old database to be safe since it might have schema issues we fixed
sudo rm -f data/chain.db* data/blockchain.db* || true
sudo -u root PYTHONPATH=src:scripts .venv/bin/python -m alembic upgrade head
# Run Genesis
echo "Creating Genesis..."
cd /opt/blockchain-node
sudo -u root PYTHONPATH=src:scripts .venv/bin/python /home/oib/aitbc/dev/scripts/create_genesis_all.py
# Start services
echo "Restarting services..."
sudo systemctl restart aitbc-blockchain-node-1 aitbc-blockchain-rpc-1 aitbc-coordinator-api || true
sudo systemctl restart aitbc-blockchain-node aitbc-blockchain-rpc || true
echo "Done!"

View File

@@ -1,57 +0,0 @@
import os
import re
def replace_in_file(filepath, replacements):
with open(filepath, 'r') as f:
content = f.read()
modified = content
for old, new in replacements:
modified = modified.replace(old, new)
if modified != content:
with open(filepath, 'w') as f:
f.write(modified)
print(f"Fixed links in {filepath}")
# Fix docs/README.md
replace_in_file('docs/README.md', [
('../3_miners/1_quick-start.md', '3_miners/1_quick-start.md'),
('../2_clients/1_quick-start.md', '2_clients/1_quick-start.md'),
('../8_development/', '8_development/'),
('../11_agents/', '11_agents/'),
('../cli/README.md', '../cli/README.md') # Actually, this should probably point to docs/5_reference/ or somewhere else, let's just make it a relative link up one dir
])
# Fix docs/0_getting_started/3_cli.md
replace_in_file('docs/0_getting_started/3_cli.md', [
('../11_agents/swarm/', '../11_agents/swarm.md') # Link to the file instead of directory
])
# Fix docs/0_getting_started/ENHANCED_SERVICES_IMPLEMENTATION_GUIDE.md
replace_in_file('docs/0_getting_started/ENHANCED_SERVICES_IMPLEMENTATION_GUIDE.md', [
('docs/', '../')
])
# Fix docs/18_explorer/EXPLORER_FINAL_STATUS.md
replace_in_file('docs/18_explorer/EXPLORER_FINAL_STATUS.md', [
('../apps/blockchain-explorer/README.md', '../../apps/blockchain-explorer/README.md')
])
# Fix docs/20_phase_reports/COMPREHENSIVE_GUIDE.md
replace_in_file('docs/20_phase_reports/COMPREHENSIVE_GUIDE.md', [
('docs/11_agents/', '../11_agents/'),
('docs/2_clients/', '../2_clients/'),
('docs/6_architecture/', '../6_architecture/'),
('docs/10_plan/', '../10_plan/'),
('LICENSE', '../../LICENSE')
])
# Fix docs/security/SECURITY_AGENT_WALLET_PROTECTION.md
replace_in_file('docs/security/SECURITY_AGENT_WALLET_PROTECTION.md', [
('../docs/SECURITY_ARCHITECTURE.md', 'SECURITY_ARCHITECTURE.md'),
('../docs/SMART_CONTRACT_SECURITY.md', 'SMART_CONTRACT_SECURITY.md'),
('../docs/AGENT_DEVELOPMENT.md', '../11_agents/AGENT_DEVELOPMENT.md')
])
print("Finished fixing broken links")

View File

@@ -1,45 +0,0 @@
import os
def replace_in_file(filepath, replacements):
try:
with open(filepath, 'r') as f:
content = f.read()
modified = content
for old, new in replacements:
modified = modified.replace(old, new)
if modified != content:
with open(filepath, 'w') as f:
f.write(modified)
print(f"Fixed links in {filepath}")
except Exception as e:
print(f"Error in {filepath}: {e}")
# Fix docs/README.md
replace_in_file('docs/README.md', [
('../cli/README.md', '0_getting_started/3_cli.md')
])
# Fix docs/8_development/DEVELOPMENT_GUIDELINES.md
replace_in_file('docs/8_development/DEVELOPMENT_GUIDELINES.md', [
('../.windsurf/workflows/project-organization.md', '../../.windsurf/workflows/project-organization.md'),
('../.windsurf/workflows/file-organization-prevention.md', '../../.windsurf/workflows/file-organization-prevention.md')
])
# Fix docs/20_phase_reports/COMPREHENSIVE_GUIDE.md
replace_in_file('docs/20_phase_reports/COMPREHENSIVE_GUIDE.md', [
('../11_agents/marketplace/', '../11_agents/README.md'),
('../11_agents/swarm/', '../11_agents/README.md'),
('../11_agents/development/', '../11_agents/README.md'),
('../10_plan/multi-language-apis-completed.md', '../12_issues/multi-language-apis-completed.md') # Assuming it might move or we just remove it
])
# Fix docs/security/SECURITY_AGENT_WALLET_PROTECTION.md
replace_in_file('docs/security/SECURITY_AGENT_WALLET_PROTECTION.md', [
('SECURITY_ARCHITECTURE.md', 'SECURITY_OVERVIEW.md'), # If it exists
('SMART_CONTRACT_SECURITY.md', 'README.md'),
('../11_agents/AGENT_DEVELOPMENT.md', '../11_agents/README.md')
])
print("Finished fixing broken links 2")

View File

@@ -1,15 +0,0 @@
with open("/home/oib/windsurf/aitbc/apps/blockchain-node/src/aitbc_chain/sync.py", "r") as f:
content = f.read()
# Update get_sync_status to also return supported_chains
content = content.replace(
""" return {
"chain_id": self._chain_id,
"head_height": head.height if head else -1,""",
""" return {
"chain_id": self._chain_id,
"head_height": head.height if head else -1,"""
)
# And in sync.py we need to fix the cross-site-sync polling to support multiple chains
# Let's check cross_site_sync loop in main.py

View File

@@ -1,25 +0,0 @@
--- a/apps/blockchain-node/src/aitbc_chain/database.py
+++ b/apps/blockchain-node/src/aitbc_chain/database.py
@@ -3,11 +3,22 @@
from contextlib import contextmanager
from sqlmodel import Session, SQLModel, create_engine
+from sqlalchemy import event
from .config import settings
_engine = create_engine(f"sqlite:///{settings.db_path}", echo=False)
+@event.listens_for(_engine, "connect")
+def set_sqlite_pragma(dbapi_connection, connection_record):
+ cursor = dbapi_connection.cursor()
+ cursor.execute("PRAGMA journal_mode=WAL")
+ cursor.execute("PRAGMA synchronous=NORMAL")
+ cursor.execute("PRAGMA cache_size=-64000")
+ cursor.execute("PRAGMA temp_store=MEMORY")
+ cursor.execute("PRAGMA mmap_size=30000000000")
+ cursor.execute("PRAGMA busy_timeout=5000")
+ cursor.close()
def init_db() -> None:
settings.db_path.parent.mkdir(parents=True, exist_ok=True)

View File

@@ -1,33 +0,0 @@
#!/bin/bash
# Force both nodes to stop and delete their databases
ssh aitbc-cascade "systemctl stop aitbc-blockchain-node-1 aitbc-blockchain-rpc-1 && rm -f /opt/blockchain-node/data/chain.db /opt/blockchain-node/data/mempool.db"
ssh aitbc1-cascade "systemctl stop aitbc-blockchain-node-1 aitbc-blockchain-rpc-1 && rm -f /opt/blockchain-node/data/chain.db /opt/blockchain-node/data/mempool.db"
# Update poa.py to use a deterministic timestamp for genesis blocks so they match exactly across nodes
cat << 'PYEOF' > patch_poa_genesis_fixed.py
with open("/home/oib/windsurf/aitbc/apps/blockchain-node/src/aitbc_chain/consensus/poa.py", "r") as f:
content = f.read()
content = content.replace(
""" timestamp = datetime.utcnow()
block_hash = self._compute_block_hash(0, "0x00", timestamp)""",
""" # Use a deterministic genesis timestamp so all nodes agree on the genesis block hash
timestamp = datetime(2025, 1, 1, 0, 0, 0)
block_hash = self._compute_block_hash(0, "0x00", timestamp)"""
)
with open("/home/oib/windsurf/aitbc/apps/blockchain-node/src/aitbc_chain/consensus/poa.py", "w") as f:
f.write(content)
PYEOF
python3 patch_poa_genesis_fixed.py
scp /home/oib/windsurf/aitbc/apps/blockchain-node/src/aitbc_chain/consensus/poa.py aitbc-cascade:/opt/blockchain-node/src/aitbc_chain/consensus/poa.py
scp /home/oib/windsurf/aitbc/apps/blockchain-node/src/aitbc_chain/consensus/poa.py aitbc1-cascade:/opt/blockchain-node/src/aitbc_chain/consensus/poa.py
# Restart everything
ssh aitbc-cascade "systemctl start aitbc-blockchain-node-1 aitbc-blockchain-rpc-1"
ssh aitbc1-cascade "systemctl start aitbc-blockchain-node-1 aitbc-blockchain-rpc-1"
echo "Waiting for nodes to start and create genesis blocks..."
sleep 5

View File

@@ -1,20 +0,0 @@
--- a/apps/blockchain-node/src/aitbc_chain/consensus/poa.py
+++ b/apps/blockchain-node/src/aitbc_chain/consensus/poa.py
@@ -171,7 +171,7 @@
)
# Broadcast the new block
- gossip_broker.publish(
+ await gossip_broker.publish(
"blocks",
{
"height": block.height,
@@ -207,7 +207,7 @@
session.commit()
# Broadcast genesis block for initial sync
- gossip_broker.publish(
+ await gossip_broker.publish(
"blocks",
{
"height": genesis.height,

View File

@@ -1,11 +0,0 @@
--- a/apps/blockchain-node/src/aitbc_chain/consensus/poa.py
+++ b/apps/blockchain-node/src/aitbc_chain/consensus/poa.py
@@ -194,7 +194,7 @@
except Exception as e:
logger.error(f"Failed to propose block: {e}")
- def _ensure_genesis_block(self) -> None:
+ async def _ensure_genesis_block(self) -> None:
"""Ensure genesis block exists"""
with self.session_factory() as session:
if session.exec(select(Block).where(Block.height == 0)).first():

View File

@@ -1,11 +0,0 @@
--- a/apps/blockchain-node/src/aitbc_chain/consensus/poa.py
+++ b/apps/blockchain-node/src/aitbc_chain/consensus/poa.py
@@ -101,7 +101,7 @@
# Wait for interval before proposing next block
await asyncio.sleep(self.config.interval_seconds)
- self._propose_block()
+ await self._propose_block()
except asyncio.CancelledError:
pass

View File

@@ -1,11 +0,0 @@
--- a/apps/blockchain-node/src/aitbc_chain/consensus/poa.py
+++ b/apps/blockchain-node/src/aitbc_chain/consensus/poa.py
@@ -81,7 +81,7 @@
if self._task is not None:
return
self._logger.info("Starting PoA proposer loop", extra={"interval": self._config.interval_seconds})
- self._ensure_genesis_block()
+ await self._ensure_genesis_block()
self._stop_event.clear()
self._task = asyncio.create_task(self._run_loop())

View File

@@ -1,151 +0,0 @@
"""
Bitcoin Exchange Router for AITBC
"""
from typing import Dict, Any
from fastapi import APIRouter, HTTPException, BackgroundTasks
from sqlmodel import Session
import uuid
import time
import json
import os
from ..deps import require_admin_key, require_client_key
from ..domain import Wallet
from ..schemas import ExchangePaymentRequest, ExchangePaymentResponse
router = APIRouter(tags=["exchange"])
# In-memory storage for demo (use database in production)
payments: Dict[str, Dict] = {}
# Bitcoin configuration
BITCOIN_CONFIG = {
'testnet': True,
'main_address': 'tb1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh', # Testnet address
'exchange_rate': 100000, # 1 BTC = 100,000 AITBC
'min_confirmations': 1,
'payment_timeout': 3600 # 1 hour
}
@router.post("/exchange/create-payment", response_model=ExchangePaymentResponse)
async def create_payment(
request: ExchangePaymentRequest,
background_tasks: BackgroundTasks,
api_key: str = require_client_key()
) -> Dict[str, Any]:
"""Create a new Bitcoin payment request"""
# Validate request
if request.aitbc_amount <= 0 or request.btc_amount <= 0:
raise HTTPException(status_code=400, detail="Invalid amount")
# Calculate expected BTC amount
expected_btc = request.aitbc_amount / BITCOIN_CONFIG['exchange_rate']
# Allow small difference for rounding
if abs(request.btc_amount - expected_btc) > 0.00000001:
raise HTTPException(status_code=400, detail="Amount mismatch")
# Create payment record
payment_id = str(uuid.uuid4())
payment = {
'payment_id': payment_id,
'user_id': request.user_id,
'aitbc_amount': request.aitbc_amount,
'btc_amount': request.btc_amount,
'payment_address': BITCOIN_CONFIG['main_address'],
'status': 'pending',
'created_at': int(time.time()),
'expires_at': int(time.time()) + BITCOIN_CONFIG['payment_timeout'],
'confirmations': 0,
'tx_hash': None
}
# Store payment
payments[payment_id] = payment
# Start payment monitoring in background
background_tasks.add_task(monitor_payment, payment_id)
return payment
@router.get("/exchange/payment-status/{payment_id}")
async def get_payment_status(payment_id: str) -> Dict[str, Any]:
"""Get payment status"""
if payment_id not in payments:
raise HTTPException(status_code=404, detail="Payment not found")
payment = payments[payment_id]
# Check if expired
if payment['status'] == 'pending' and time.time() > payment['expires_at']:
payment['status'] = 'expired'
return payment
@router.post("/exchange/confirm-payment/{payment_id}")
async def confirm_payment(
payment_id: str,
tx_hash: str,
api_key: str = require_admin_key()
) -> Dict[str, Any]:
"""Confirm payment (webhook from payment processor)"""
if payment_id not in payments:
raise HTTPException(status_code=404, detail="Payment not found")
payment = payments[payment_id]
if payment['status'] != 'pending':
raise HTTPException(status_code=400, detail="Payment not in pending state")
# Verify transaction (in production, verify with blockchain API)
# For demo, we'll accept any tx_hash
payment['status'] = 'confirmed'
payment['tx_hash'] = tx_hash
payment['confirmed_at'] = int(time.time())
# Mint AITBC tokens to user's wallet
try:
from ..services.blockchain import mint_tokens
await mint_tokens(payment['user_id'], payment['aitbc_amount'])
except Exception as e:
print(f"Error minting tokens: {e}")
# In production, handle this error properly
return {
'status': 'ok',
'payment_id': payment_id,
'aitbc_amount': payment['aitbc_amount']
}
@router.get("/exchange/rates")
async def get_exchange_rates() -> Dict[str, float]:
"""Get current exchange rates"""
return {
'btc_to_aitbc': BITCOIN_CONFIG['exchange_rate'],
'aitbc_to_btc': 1.0 / BITCOIN_CONFIG['exchange_rate'],
'fee_percent': 0.5
}
async def monitor_payment(payment_id: str):
"""Monitor payment for confirmation (background task)"""
import asyncio
while payment_id in payments:
payment = payments[payment_id]
# Check if expired
if payment['status'] == 'pending' and time.time() > payment['expires_at']:
payment['status'] = 'expired'
break
# In production, check blockchain for payment
# For demo, we'll wait for manual confirmation
await asyncio.sleep(30) # Check every 30 seconds

View File

@@ -1,151 +0,0 @@
import re
with open("/home/oib/windsurf/aitbc/apps/blockchain-node/src/aitbc_chain/models.py", "r") as f:
content = f.read()
# First fix the `__table_args__` import
content = content.replace(
"from sqlmodel import Field, Relationship, SQLModel",
"from sqlmodel import Field, Relationship, SQLModel\nfrom sqlalchemy import UniqueConstraint"
)
# Fix Block model
content = content.replace(
"""class Block(SQLModel, table=True):
__tablename__ = "block"
id: Optional[int] = Field(default=None, primary_key=True)
height: int = Field(index=True, unique=True)
hash: str = Field(index=True, unique=True)""",
"""class Block(SQLModel, table=True):
__tablename__ = "block"
__table_args__ = (UniqueConstraint("chain_id", "height", name="uix_block_chain_height"),)
id: Optional[int] = Field(default=None, primary_key=True)
chain_id: str = Field(index=True)
height: int = Field(index=True)
hash: str = Field(index=True, unique=True)"""
)
# Fix Transaction model
content = content.replace(
"""class Transaction(SQLModel, table=True):
__tablename__ = "transaction"
id: Optional[int] = Field(default=None, primary_key=True)
tx_hash: str = Field(index=True, unique=True)
block_height: Optional[int] = Field(
default=None,
index=True,
foreign_key="block.height",
)""",
"""class Transaction(SQLModel, table=True):
__tablename__ = "transaction"
__table_args__ = (UniqueConstraint("chain_id", "tx_hash", name="uix_tx_chain_hash"),)
id: Optional[int] = Field(default=None, primary_key=True)
chain_id: str = Field(index=True)
tx_hash: str = Field(index=True)
block_height: Optional[int] = Field(
default=None,
index=True,
)"""
)
# Fix Receipt model
content = content.replace(
"""class Receipt(SQLModel, table=True):
__tablename__ = "receipt"
id: Optional[int] = Field(default=None, primary_key=True)
job_id: str = Field(index=True)
receipt_id: str = Field(index=True, unique=True)
block_height: Optional[int] = Field(
default=None,
index=True,
foreign_key="block.height",
)""",
"""class Receipt(SQLModel, table=True):
__tablename__ = "receipt"
__table_args__ = (UniqueConstraint("chain_id", "receipt_id", name="uix_receipt_chain_id"),)
id: Optional[int] = Field(default=None, primary_key=True)
chain_id: str = Field(index=True)
job_id: str = Field(index=True)
receipt_id: str = Field(index=True)
block_height: Optional[int] = Field(
default=None,
index=True,
)"""
)
# Fix Account model
content = content.replace(
"""class Account(SQLModel, table=True):
__tablename__ = "account"
address: str = Field(primary_key=True)""",
"""class Account(SQLModel, table=True):
__tablename__ = "account"
chain_id: str = Field(primary_key=True)
address: str = Field(primary_key=True)"""
)
# Fix Block relationships sa_relationship_kwargs
content = content.replace(
""" transactions: List["Transaction"] = Relationship(
back_populates="block",
sa_relationship_kwargs={"lazy": "selectin"}
)""",
""" transactions: List["Transaction"] = Relationship(
back_populates="block",
sa_relationship_kwargs={
"lazy": "selectin",
"primaryjoin": "and_(Transaction.block_height==Block.height, Transaction.chain_id==Block.chain_id)",
"foreign_keys": "[Transaction.block_height, Transaction.chain_id]"
}
)"""
)
content = content.replace(
""" receipts: List["Receipt"] = Relationship(
back_populates="block",
sa_relationship_kwargs={"lazy": "selectin"}
)""",
""" receipts: List["Receipt"] = Relationship(
back_populates="block",
sa_relationship_kwargs={
"lazy": "selectin",
"primaryjoin": "and_(Receipt.block_height==Block.height, Receipt.chain_id==Block.chain_id)",
"foreign_keys": "[Receipt.block_height, Receipt.chain_id]"
}
)"""
)
# Fix reverse relationships
content = content.replace(
""" block: Optional["Block"] = Relationship(back_populates="transactions")""",
""" block: Optional["Block"] = Relationship(
back_populates="transactions",
sa_relationship_kwargs={
"primaryjoin": "and_(Transaction.block_height==Block.height, Transaction.chain_id==Block.chain_id)",
"foreign_keys": "[Transaction.block_height, Transaction.chain_id]"
}
)"""
)
content = content.replace(
""" block: Optional["Block"] = Relationship(back_populates="receipts")""",
""" block: Optional["Block"] = Relationship(
back_populates="receipts",
sa_relationship_kwargs={
"primaryjoin": "and_(Receipt.block_height==Block.height, Receipt.chain_id==Block.chain_id)",
"foreign_keys": "[Receipt.block_height, Receipt.chain_id]"
}
)"""
)
with open("/home/oib/windsurf/aitbc/apps/blockchain-node/src/aitbc_chain/models.py", "w") as f:
f.write(content)

View File

@@ -1,13 +0,0 @@
with open("/home/oib/windsurf/aitbc/apps/blockchain-node/src/aitbc_chain/consensus/poa.py", "r") as f:
content = f.read()
content = content.replace(
""" timestamp = datetime.now(timezone.utc)
block_hash = self._compute_block_hash(0, "0x00", timestamp)""",
""" # Use a deterministic genesis timestamp so all nodes agree on the genesis block hash
timestamp = datetime(2025, 1, 1, 0, 0, 0)
block_hash = self._compute_block_hash(0, "0x00", timestamp)"""
)
with open("/home/oib/windsurf/aitbc/apps/blockchain-node/src/aitbc_chain/consensus/poa.py", "w") as f:
f.write(content)