|
| 1 | +# bitcell-governance |
| 2 | + |
| 3 | +On-chain governance system for the BitCell blockchain, implementing RC3-005 requirements. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **Proposal System**: Submit proposals for parameter changes, treasury spending, and protocol upgrades |
| 8 | +- **Token-Weighted Voting**: Democratic voting with 1 CELL = 1 vote (linear) or quadratic voting option |
| 9 | +- **Vote Delegation**: Delegate voting power to trusted representatives |
| 10 | +- **Timelock Execution**: Mandatory waiting period before proposal execution |
| 11 | +- **Guardian Controls**: Multi-sig emergency cancellation and fast-track capabilities |
| 12 | +- **Comprehensive Testing**: 20 unit tests covering all functionality |
| 13 | + |
| 14 | +## Quick Start |
| 15 | + |
| 16 | +Add to your `Cargo.toml`: |
| 17 | + |
| 18 | +```toml |
| 19 | +[dependencies] |
| 20 | +bitcell-governance = { path = "crates/bitcell-governance" } |
| 21 | +``` |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +```rust |
| 26 | +use bitcell_governance::*; |
| 27 | + |
| 28 | +// Create governance manager with guardians |
| 29 | +let guardians = vec![guardian1, guardian2, guardian3]; |
| 30 | +let mut governance = GovernanceManager::new(guardians); |
| 31 | + |
| 32 | +// Submit a proposal |
| 33 | +let proposal_id = governance.submit_proposal( |
| 34 | + proposer_pubkey, |
| 35 | + ProposalType::ParameterChange { |
| 36 | + parameter: "block_time".to_string(), |
| 37 | + new_value: vec![10], |
| 38 | + }, |
| 39 | + "Reduce block time to 10s".to_string(), |
| 40 | + 14400, // voting period in blocks |
| 41 | + current_block, |
| 42 | +)?; |
| 43 | + |
| 44 | +// Vote on the proposal |
| 45 | +governance.vote( |
| 46 | + proposal_id, |
| 47 | + voter_pubkey, |
| 48 | + VoteType::For, |
| 49 | + token_balance, |
| 50 | + current_block, |
| 51 | + false, // quadratic voting |
| 52 | +)?; |
| 53 | + |
| 54 | +// Finalize after voting period |
| 55 | +governance.finalize_proposal(proposal_id, current_block + 15000)?; |
| 56 | + |
| 57 | +// Execute after timelock |
| 58 | +governance.execute_proposal(proposal_id, current_block + 30000)?; |
| 59 | +``` |
| 60 | + |
| 61 | +## Documentation |
| 62 | + |
| 63 | +See `docs/GOVERNANCE.md` for comprehensive documentation including: |
| 64 | + |
| 65 | +- Architecture overview |
| 66 | +- Proposal types |
| 67 | +- Voting process |
| 68 | +- Guardian controls |
| 69 | +- Security features |
| 70 | +- Best practices |
| 71 | +- Integration guide |
| 72 | + |
| 73 | +## Testing |
| 74 | + |
| 75 | +```bash |
| 76 | +cargo test -p bitcell-governance |
| 77 | +``` |
| 78 | + |
| 79 | +All tests pass: |
| 80 | +- 20 unit tests |
| 81 | +- Coverage of all major functionality |
| 82 | +- Edge case testing |
| 83 | + |
| 84 | +## License |
| 85 | + |
| 86 | +MIT OR Apache-2.0 |
0 commit comments