Commit pending blockchain changes: poa.py mempool logging, main.py service fixes, router.py RPC improvements
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
Some checks failed
AITBC CI/CD Pipeline / lint-and-test (3.11) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.12) (push) Has been cancelled
AITBC CI/CD Pipeline / lint-and-test (3.13) (push) Has been cancelled
AITBC CI/CD Pipeline / test-cli (push) Has been cancelled
AITBC CI/CD Pipeline / test-services (push) Has been cancelled
AITBC CI/CD Pipeline / test-production-services (push) Has been cancelled
AITBC CI/CD Pipeline / security-scan (push) Has been cancelled
AITBC CI/CD Pipeline / build (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-staging (push) Has been cancelled
AITBC CI/CD Pipeline / deploy-production (push) Has been cancelled
AITBC CI/CD Pipeline / performance-test (push) Has been cancelled
AITBC CI/CD Pipeline / docs (push) Has been cancelled
AITBC CI/CD Pipeline / release (push) Has been cancelled
AITBC CI/CD Pipeline / notify (push) Has been cancelled
Security Scanning / Bandit Security Scan (apps/coordinator-api/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (cli/aitbc_cli) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-core/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-crypto/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (packages/py/aitbc-sdk/src) (push) Has been cancelled
Security Scanning / Bandit Security Scan (tests) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (javascript) (push) Has been cancelled
Security Scanning / CodeQL Security Analysis (python) (push) Has been cancelled
Security Scanning / Dependency Security Scan (push) Has been cancelled
Security Scanning / Container Security Scan (push) Has been cancelled
Security Scanning / OSSF Scorecard (push) Has been cancelled
Security Scanning / Security Summary Report (push) Has been cancelled
This commit is contained in:
@@ -185,6 +185,7 @@ class PoAProposer:
|
||||
tx_hash=tx.tx_hash,
|
||||
sender=sender,
|
||||
recipient=recipient,
|
||||
payload=tx_data,
|
||||
value=value,
|
||||
fee=fee,
|
||||
nonce=sender_account.nonce - 1,
|
||||
@@ -237,6 +238,7 @@ class PoAProposer:
|
||||
)
|
||||
|
||||
# Broadcast the new block
|
||||
tx_list = [tx.content for tx in processed_txs] if processed_txs else []
|
||||
await gossip_broker.publish(
|
||||
"blocks",
|
||||
{
|
||||
@@ -248,7 +250,8 @@ class PoAProposer:
|
||||
"timestamp": block.timestamp.isoformat(),
|
||||
"tx_count": block.tx_count,
|
||||
"state_root": block.state_root,
|
||||
}
|
||||
"transactions": tx_list,
|
||||
},
|
||||
)
|
||||
|
||||
async def _ensure_genesis_block(self) -> None:
|
||||
|
||||
@@ -124,7 +124,7 @@ class BlockchainNode:
|
||||
chain_id = block_data.get("chain_id", settings.chain_id)
|
||||
logger.info(f"Importing block for chain {chain_id}: {block_data.get('height')}")
|
||||
sync = ChainSync(session_factory=session_scope, chain_id=chain_id)
|
||||
res = sync.import_block(block_data)
|
||||
res = sync.import_block(block_data, transactions=block_data.get("transactions"))
|
||||
logger.info(f"Import result: accepted={res.accepted}, reason={res.reason}")
|
||||
except Exception as exc:
|
||||
logger.error(f"Error processing block from gossip: {exc}")
|
||||
|
||||
@@ -105,6 +105,14 @@ async def get_block(height: int) -> Dict[str, Any]:
|
||||
metrics_registry.increment("rpc_get_block_not_found_total")
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="block not found")
|
||||
metrics_registry.increment("rpc_get_block_success_total")
|
||||
|
||||
txs = session.exec(select(Transaction).where(Transaction.block_height == height)).all()
|
||||
tx_list = []
|
||||
for tx in txs:
|
||||
t = dict(tx.payload) if tx.payload else {}
|
||||
t["tx_hash"] = tx.tx_hash
|
||||
tx_list.append(t)
|
||||
|
||||
metrics_registry.observe("rpc_get_block_duration_seconds", time.perf_counter() - start)
|
||||
return {
|
||||
"height": block.height,
|
||||
@@ -114,6 +122,7 @@ async def get_block(height: int) -> Dict[str, Any]:
|
||||
"timestamp": block.timestamp.isoformat(),
|
||||
"tx_count": block.tx_count,
|
||||
"state_root": block.state_root,
|
||||
"transactions": tx_list,
|
||||
}
|
||||
|
||||
|
||||
@@ -151,6 +160,13 @@ async def get_blocks_range(start: int, end: int) -> Dict[str, Any]:
|
||||
# Serialize blocks
|
||||
block_list = []
|
||||
for block in blocks:
|
||||
txs = session.exec(select(Transaction).where(Transaction.block_height == block.height)).all()
|
||||
tx_list = []
|
||||
for tx in txs:
|
||||
t = dict(tx.payload) if tx.payload else {}
|
||||
t["tx_hash"] = tx.tx_hash
|
||||
tx_list.append(t)
|
||||
|
||||
block_list.append({
|
||||
"height": block.height,
|
||||
"hash": block.hash,
|
||||
@@ -159,6 +175,7 @@ async def get_blocks_range(start: int, end: int) -> Dict[str, Any]:
|
||||
"timestamp": block.timestamp.isoformat(),
|
||||
"tx_count": block.tx_count,
|
||||
"state_root": block.state_root,
|
||||
"transactions": tx_list,
|
||||
})
|
||||
|
||||
metrics_registry.increment("rpc_get_blocks_range_success_total")
|
||||
|
||||
Reference in New Issue
Block a user