Some checks failed
API Endpoint Tests / test-api-endpoints (push) Successful in 10s
Blockchain Synchronization Verification / sync-verification (push) Failing after 3s
CLI Tests / test-cli (push) Failing after 4s
Documentation Validation / validate-docs (push) Successful in 8s
Documentation Validation / validate-policies-strict (push) Successful in 4s
Integration Tests / test-service-integration (push) Successful in 38s
Multi-Node Blockchain Health Monitoring / health-check (push) Successful in 2s
P2P Network Verification / p2p-verification (push) Successful in 3s
Security Scanning / security-scan (push) Successful in 40s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 15s
Smart Contract Tests / lint-solidity (push) Successful in 8s
- Relocate blockchain-event-bridge README content to docs/apps/blockchain/blockchain-event-bridge.md - Relocate blockchain-explorer README content to docs/apps/blockchain/blockchain-explorer.md - Replace app READMEs with redirect notices pointing to new documentation location - Consolidate documentation in central docs/ directory for better organization
4.4 KiB
4.4 KiB
Miner
Status
✅ Operational
Overview
Mining and block validation service for the AITBC blockchain using Proof-of-Authority consensus.
Architecture
Core Components
- Block Validator: Validates blocks from the network
- Block Proposer: Proposes new blocks (for authorized proposers)
- Transaction Validator: Validates transactions before inclusion
- Reward Claimer: Claims mining rewards
- Sync Manager: Manages blockchain synchronization
Quick Start (End Users)
Prerequisites
- Python 3.13+
- Access to blockchain RPC endpoint
- Valid proposer credentials (if proposing blocks)
Installation
cd /opt/aitbc/apps/miner
.venv/bin/pip install -r requirements.txt
Configuration
Set environment variables in .env:
BLOCKCHAIN_RPC_URL=http://localhost:8006
PROPOSER_ID=your-proposer-id
PROPOSER_PRIVATE_KEY=encrypted-key
MINING_ENABLED=true
VALIDATION_ENABLED=true
Running the Service
.venv/bin/python main.py
Developer Guide
Development Setup
- Clone the repository
- Create virtual environment:
python -m venv .venv - Install dependencies:
pip install -r requirements.txt - Configure blockchain RPC endpoint
- Configure proposer credentials (if proposing)
- Run tests:
pytest tests/
Project Structure
miner/
├── src/
│ ├── block_validator/ # Block validation
│ ├── block_proposer/ # Block proposal
│ ├── transaction_validator/ # Transaction validation
│ ├── reward_claimer/ # Reward claiming
│ └── sync_manager/ # Sync management
├── tests/ # Test suite
└── pyproject.toml # Project configuration
Testing
# Run all tests
pytest tests/
# Run block validator tests
pytest tests/test_validator.py
# Run block proposer tests
pytest tests/test_proposer.py
API Reference
Block Validation
Validate Block
POST /api/v1/mining/validate/block
Content-Type: application/json
{
"block": {},
"chain_id": "ait-mainnet"
}
Get Validation Status
GET /api/v1/mining/validation/status
Block Proposal
Propose Block
POST /api/v1/mining/propose/block
Content-Type: application/json
{
"chain_id": "ait-mainnet",
"transactions": [{}],
"timestamp": "2024-01-01T00:00:00Z"
}
Get Proposal Status
GET /api/v1/mining/proposal/status
Transaction Validation
Validate Transaction
POST /api/v1/mining/validate/transaction
Content-Type: application/json
{
"transaction": {},
"chain_id": "ait-mainnet"
}
Get Validation Queue
GET /api/v1/mining/validation/queue?limit=100
Reward Claiming
Claim Reward
POST /api/v1/mining/rewards/claim
Content-Type: application/json
{
"block_height": 1000,
"proposer_id": "string"
}
Get Reward History
GET /api/v1/mining/rewards/history?proposer_id=string
Sync Management
Get Sync Status
GET /api/v1/mining/sync/status
Trigger Sync
POST /api/v1/mining/sync/trigger
Content-Type: application/json
{
"from_height": 1000,
"to_height": 2000
}
Configuration
Environment Variables
BLOCKCHAIN_RPC_URL: Blockchain RPC endpointPROPOSER_ID: Proposer identifierPROPOSER_PRIVATE_KEY: Encrypted proposer private keyMINING_ENABLED: Enable block proposalVALIDATION_ENABLED: Enable block validationSYNC_INTERVAL: Sync interval in seconds
Consensus Parameters
- Block Time: Time between blocks (default: 10s)
- Max Transactions: Maximum transactions per block
- Block Size: Maximum block size in bytes
Validation Rules
- Signature Validation: Validate block signatures
- Transaction Validation: Validate transaction format
- State Validation: Validate state transitions
Troubleshooting
Block validation failed: Check block signature and state transitions.
Proposal rejected: Verify proposer authorization and block validity.
Sync not progressing: Check blockchain RPC connectivity and network status.
Reward claim failed: Verify proposer ID and block height.
Security Notes
- Secure proposer private key storage
- Validate all blocks before acceptance
- Monitor for double-spending attacks
- Implement rate limiting for proposal
- Regularly audit mining operations
- Use secure key management