This file implements the on-chain governance system for the Canopy blockchain, handling parameter changes, treasury subsidies, and proposal management. It provides the mechanisms for validators and stakeholders to propose, vote on, and implement changes to the blockchain's parameters.
The governance system is designed to handle:
- Proposal validation and approval
- Parameter updates across different logical spaces
- State conformity to parameter changes
- Polling functionality for community feedback
- Protocol version management for feature activation
- Root chain identification and management
The proposal management system in the Canopy blockchain handles the validation and approval of governance proposals through a decentralized process. This system is a critical componen t that enables on-chain governance, allowing the network to evolve and adapt through consensus.
Proposals in Canopy follow a specific lifecycle:
- Creation: A community member creates a proposal in JSON format
- Distribution: The proposal is shared with validators (typically via Discord or governance forums)
- Validator Configuration: Validators decide whether to approve or reject the proposal
- Submission: Once sufficient approval is gathered, the proposal can be submitted as a transaction
This allows validators to have control over which proposals they support, while still maintaining consensus through the two-thirds majority rule.
Parameters in the Canopy blockchain are organized into logical "spaces" for better organization, facilitating effective management and updates:
-
Consensus Parameters: Control fundamental blockchain behavior
- Protocol version (stored as a string)
- Maximum block size
- Root chain ID
-
Validator Parameters: Govern validator behavior
- Unstaking blocks
- Maximum pause blocks
- Slashing percentages for violations
- Maximum committee size
-
Fee Parameters: Set transaction costs
- Transaction fees
- Operation fees
-
Governance Parameters: Control the governance process itself
- Proposal requirements
- Voting periods
Each parameter space contains specific parameters that can be updated through governance proposals. Most parameters are primarily stored as uint64 values, providing a clear structure for developers and users to understand the system. This organization makes it easier to manage and update related parameters together, ensuring that the critical components of the blockchain operate smoothly.
The governance system includes a polling mechanism that allows for "straw polling" - non-binding votes that gauge community sentiment. This works by:
- Parsing transaction memos for poll commands
- Tracking votes from both validators and regular accounts
- Calculating results based on voting power (tokens)
This provides a way to gather feedback from the community without requiring formal on-chain governance proposals.
The protocol version system enables feature activation at specific heights. By updating the protocol version parameter, new features can be enabled once the blockchain reaches a certain height. This allows for coordinated upgrades without requiring hard forks.
When a parameter is updated, the system follows these steps:
- The previous parameters are saved for comparison
- The parameter space is identified (Consensus, Validator, Fee, or Governance)
- The parameter is updated with the new value
- The updated parameter space is saved back to state
- If necessary, the state is adjusted to conform to the new parameters
This process ensures that parameter updates are applied consistently and that the blockchain state remains valid after updates.
The governance system interacts closely with the validator system:
- When MaxCommitteeSize is reduced, the governance system must update validator committees
- Validator voting power determines the outcome of governance proposals
- Slashing parameters set by governance control validator penalties
This relationship ensures that validators operate within the rules set by governance while also giving them a say in how those rules evolve.
The protocol version parameter interacts with feature activation:
- New features can check if they should be enabled based on the current protocol version
- Features can be programmed to activate at specific heights
- This allows for coordinated upgrades without requiring hard forks
For example, a new transaction type could be added to the code but remain inactive until the protocol version reaches a certain value and the blockchain reaches the specified height.
The polling system provides a way for the community to express opinions without formal governance:
- Transactions with special memo commands are parsed for poll votes
- Votes are weighted by token holdings (for accounts) or voting power (for validators)
- Results show approval percentages for both validators and regular accounts
This creates a feedback mechanism that can inform formal governance proposals and gauge community sentiment.
- Height-based validation ensures proposals are only processed within their valid range
- Parameter validation prevents invalid values from being set
- State conformity ensures the blockchain remains in a valid state after parameter updates
- Protocol version management allows for controlled feature activation
- Root chain management maintains the security of the validator set