docs: add documentation for GovernanceContract.sol
This commit is contained in:
parent
3b73072301
commit
fe42c6005d
78
docs/GovernanceContract.md
Normal file
78
docs/GovernanceContract.md
Normal file
@ -0,0 +1,78 @@
|
||||
## Overview
|
||||
The GovernanceContract is a decentralized governance mechanism for managing community proposals and voting processes on the ChunkNet blockchain. It provides a transparent, secure method for community members to create, vote on, and finalize governance proposals.
|
||||
|
||||
## Interface
|
||||
|
||||
| Function | Parameters | Returns | Description |
|
||||
|----------|------------|---------|-------------|
|
||||
| `createProposal` | `string _description` | `uint256` | Create a new governance proposal |
|
||||
| `vote` | `uint256 _proposalId, bool _support` | `void` | Cast a vote on an active proposal |
|
||||
| `finalizeProposal` | `uint256 _proposalId` | `void` | Conclude voting and determine proposal status |
|
||||
| `getProposalDetails` | `uint256 _proposalId` | `Proposal` | Retrieve detailed information about a specific proposal |
|
||||
|
||||
## Events
|
||||
|
||||
- `ProposalCreated`: Emitted when a new proposal is created
|
||||
- `ProposalVoted`: Triggered when a community member votes
|
||||
- `ProposalStatusChanged`: Signals changes in proposal status
|
||||
|
||||
## Storage Layout
|
||||
|
||||
- `proposals`: Mapping of proposal IDs to Proposal structs
|
||||
- `proposalCount`: Total number of proposals created
|
||||
- `votingContract`: Reference to the VotingContract for voting power calculations
|
||||
- Constant parameters:
|
||||
- `VOTING_PERIOD`: 7 days
|
||||
- `QUORUM_PERCENTAGE`: 30%
|
||||
- `PASS_THRESHOLD_PERCENTAGE`: 50%
|
||||
|
||||
## Access Control
|
||||
|
||||
- Proposal creation: Open to all registered community members
|
||||
- Voting: Restricted to members with valid voting power
|
||||
- Proposal finalization: Can be called by any participant after voting period ends
|
||||
|
||||
## Security Considerations
|
||||
|
||||
- Prevents double voting through `hasVoted` mapping
|
||||
- Uses voting power from external VotingContract
|
||||
- Implements time-based voting restrictions
|
||||
- Requires quorum and pass threshold for proposal validation
|
||||
- Prevents proposal manipulation through cryptographic hashing
|
||||
|
||||
## Deployment
|
||||
|
||||
**Blockchain Environment**:
|
||||
- RPC URL: https://rpc.chunknet.org
|
||||
- Chain ID: 214562
|
||||
- Network: ChunkNet DevNet
|
||||
|
||||
**Deployment Steps**:
|
||||
1. Deploy VotingContract first
|
||||
2. Pass VotingContract address to GovernanceContract constructor
|
||||
3. Verify contract parameters
|
||||
4. Set appropriate access controls
|
||||
|
||||
**Recommended Deployment Configuration**:
|
||||
bash
|
||||
forge create GovernanceContract \
|
||||
--rpc-url https://rpc.chunknet.org \
|
||||
--private-key $DEPLOYER_PRIVATE_KEY \
|
||||
--constructor-args $VOTING_CONTRACT_ADDRESS
|
||||
|
||||
|
||||
## Testing
|
||||
|
||||
Test cases should cover:
|
||||
- Proposal creation validation
|
||||
- Voting mechanism
|
||||
- Quorum and threshold calculations
|
||||
- Proposal status transitions
|
||||
- Edge cases and potential attack vectors
|
||||
|
||||
Recommended test scenarios:
|
||||
- Create proposal with empty description
|
||||
- Vote before and after voting period
|
||||
- Test voting power calculations
|
||||
- Validate proposal finalization logic
|
||||
- Check event emissions
|
||||
Loading…
Reference in New Issue
Block a user