chore: refactor logging module, update genesis timestamp, remove model relationships, and reorganize routers - Rename logging.py to logger.py and update import paths in poa.py and main.py - Update devnet genesis timestamp to 1766828620 - Remove SQLModel Relationship declarations from Block, Transaction, and Receipt models - Add SessionDep type alias and get_session dependency in coordinator-api deps - Reorganize coordinator-api routers: replace explorer/registry with exchange, users, marketplace
7.8 KiB
Governance Module
The AITBC governance module enables decentralized decision-making through proposal voting and parameter changes.
Overview
The governance system allows AITBC token holders to:
- Create proposals for protocol changes
- Vote on active proposals
- Execute approved proposals
- Track governance history
API Endpoints
Get Governance Parameters
Retrieve current governance system parameters.
GET /api/v1/governance/parameters
Response:
{
"min_proposal_voting_power": 1000,
"max_proposal_title_length": 200,
"max_proposal_description_length": 5000,
"default_voting_period_days": 7,
"max_voting_period_days": 30,
"min_quorum_threshold": 0.01,
"max_quorum_threshold": 1.0,
"min_approval_threshold": 0.01,
"max_approval_threshold": 1.0,
"execution_delay_hours": 24
}
List Proposals
Get a list of governance proposals.
GET /api/v1/governance/proposals?status={status}&limit={limit}&offset={offset}
Query Parameters:
status(optional): Filter by proposal status (active,passed,rejected,executed)limit(optional): Number of proposals to return (default: 20)offset(optional): Number of proposals to skip (default: 0)
Response:
[
{
"id": "proposal-uuid",
"title": "Proposal Title",
"description": "Description of the proposal",
"type": "parameter_change",
"target": {},
"proposer": "user-address",
"status": "active",
"created_at": "2025-12-28T18:00:00Z",
"voting_deadline": "2025-12-28T18:00:00Z",
"quorum_threshold": 0.1,
"approval_threshold": 0.5,
"current_quorum": 0.15,
"current_approval": 0.75,
"votes_for": 150,
"votes_against": 50,
"votes_abstain": 10,
"total_voting_power": 1000000
}
]
Create Proposal
Create a new governance proposal.
POST /api/v1/governance/proposals
Request Body:
{
"title": "Reduce Transaction Fees",
"description": "This proposal suggests reducing transaction fees...",
"type": "parameter_change",
"target": {
"fee_percentage": "0.05"
},
"voting_period": 7,
"quorum_threshold": 0.1,
"approval_threshold": 0.5
}
Fields:
title: Proposal title (10-200 characters)description: Detailed description (50-5000 characters)type: Proposal type (parameter_change,protocol_upgrade,fund_allocation,policy_change)target: Target configuration for the proposalvoting_period: Voting period in days (1-30)quorum_threshold: Minimum participation percentage (0.01-1.0)approval_threshold: Minimum approval percentage (0.01-1.0)
Get Proposal
Get details of a specific proposal.
GET /api/v1/governance/proposals/{proposal_id}
Submit Vote
Submit a vote on a proposal.
POST /api/v1/governance/vote
Request Body:
{
"proposal_id": "proposal-uuid",
"vote": "for",
"reason": "I support this change because..."
}
Fields:
proposal_id: ID of the proposal to vote onvote: Vote option (for,against,abstain)reason(optional): Reason for the vote (max 500 characters)
Get Voting Power
Check a user's voting power.
GET /api/v1/governance/voting-power/{user_id}
Response:
{
"user_id": "user-address",
"voting_power": 10000
}
Execute Proposal
Execute an approved proposal.
POST /api/v1/governance/execute/{proposal_id}
Note: Proposals can only be executed after:
- Voting period has ended
- Quorum threshold is met
- Approval threshold is met
- 24-hour execution delay has passed
Proposal Types
Parameter Change
Modify system parameters like fees, limits, or thresholds.
Example Target:
{
"transaction_fee": "0.05",
"min_stake_amount": "1000",
"max_block_size": "2000"
}
Protocol Upgrade
Initiate a protocol upgrade with version changes.
Example Target:
{
"version": "1.2.0",
"upgrade_type": "hard_fork",
"activation_block": 1000000,
"changes": {
"new_features": ["feature1", "feature2"],
"breaking_changes": ["change1"]
}
}
Fund Allocation
Allocate funds from the treasury.
Example Target:
{
"amount": "1000000",
"recipient": "0x123...",
"purpose": "Ecosystem development fund",
"milestones": [
{
"description": "Phase 1 development",
"amount": "500000",
"deadline": "2025-06-30"
}
]
}
Policy Change
Update governance or operational policies.
Example Target:
{
"policy_name": "voting_period",
"new_value": "14 days",
"rationale": "Longer voting period for better participation"
}
Voting Process
- Proposal Creation: Any user with sufficient voting power can create a proposal
- Voting Period: Token holders vote during the specified voting period
- Quorum Check: Minimum participation must be met
- Approval Check: Minimum approval ratio must be met
- Execution Delay: 24-hour delay before execution
- Execution: Approved changes are implemented
Database Schema
GovernanceProposal
id: Unique proposal identifiertitle: Proposal titledescription: Detailed descriptiontype: Proposal typetarget: Target configuration (JSON)proposer: Address of the proposerstatus: Current statuscreated_at: Creation timestampvoting_deadline: End of voting periodquorum_threshold: Minimum participation requiredapproval_threshold: Minimum approval requiredexecuted_at: Execution timestamprejection_reason: Reason for rejection
ProposalVote
id: Unique vote identifierproposal_id: Reference to proposalvoter_id: Address of the votervote: Vote choice (for/against/abstain)voting_power: Power at time of votereason: Vote reasonvoted_at: Vote timestamp
TreasuryTransaction
id: Unique transaction identifierproposal_id: Reference to proposalfrom_address: Source addressto_address: Destination addressamount: Transfer amountstatus: Transaction statustransaction_hash: Blockchain hash
Security Considerations
- Voting Power: Based on AITBC token holdings
- Double Voting: Prevented by tracking voter addresses
- Execution Delay: Prevents rush decisions
- Quorum Requirements: Ensures sufficient participation
- Proposal Thresholds: Prevents spam proposals
Integration Guide
Frontend Integration
// Fetch proposals
const response = await fetch('/api/v1/governance/proposals');
const proposals = await response.json();
// Submit vote
await fetch('/api/v1/governance/vote', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
proposal_id: 'uuid',
vote: 'for',
reason: 'Support this proposal'
})
});
Smart Contract Integration
The governance system can be integrated with smart contracts for:
- On-chain voting
- Automatic execution
- Treasury management
- Parameter enforcement
Best Practices
- Clear Proposals: Provide detailed descriptions and rationales
- Reasonable Thresholds: Set achievable quorum and approval thresholds
- Community Discussion: Use forums for proposal discussion
- Gradual Changes: Implement major changes in phases
- Monitoring: Track proposal outcomes and system impact
Future Enhancements
- Delegated Voting: Allow users to delegate voting power
- Quadratic Voting: Implement more sophisticated voting mechanisms
- Time-locked Voting: Lock tokens for voting power boosts
- Multi-sig Execution: Require multiple signatures for execution
- Proposal Templates: Standardize proposal formats
Support
For governance-related questions:
- Check the API documentation
- Review proposal history
- Contact the governance team
- Participate in community discussions