feat: implement weighted voting system based on node energy capacity#8
Open
syed-ghufran-hassan wants to merge 1 commit intoLuxbin-labs:masterfrom
Open
feat: implement weighted voting system based on node energy capacity#8syed-ghufran-hassan wants to merge 1 commit intoLuxbin-labs:masterfrom
syed-ghufran-hassan wants to merge 1 commit intoLuxbin-labs:masterfrom
Conversation
Add dynamic voting power mechanism where nodes vote with weight proportional to their energy capacity (1 MW = 1 voting power). This ensures grid decisions reflect the stake and importance of each participant. Key features: - Weighted voting: votesFor/votesAgainst track total MW supporting/opposing - Quorum requirement: minimum 30% of total active capacity must participate - Approval threshold: 60% weighted approval needed for execution - Node health monitoring: auto-deactivation after 30 days without heartbeat - Real-time status tracking: approval percentages and quorum calculations New struct fields: - EnergyNode.votingPower: derived from capacity - EnergyNode.totalVotesCast: track node participation - totalActiveCapacity: global sum for quorum calculations Enhanced functions: - voteOnCommand: applies weighted voting power - registerEnergyNode: sets initial voting power from capacity - deactivateNode: removes capacity from total when nodes go offline - getCommandStatus: returns detailed vote breakdown and execution eligibility - checkNodeHealth: auto-maintenance for inactive nodes This improvement ensures democratic governance where influence scales with energy contribution, preventing minority control while maintaining operational efficiency through automated health checks.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add dynamic voting power mechanism where nodes vote with weight proportional to their energy capacity (1 MW = 1 voting power). This ensures grid decisions reflect the stake and importance of each participant.
Key features:
New struct fields:
Enhanced functions:
This improvement ensures democratic governance where influence scales with energy contribution, preventing minority control while maintaining operational efficiency through automated health checks.
✄ -----------------------------------------------------------------------------
Thank you for your Pull Request! 🙏 Please make sure it follows the contribution guidelines outlined in this
document and fill out the
sections below. Once you're ready to submit your PR for review, please delete this section and leave only the text under
the "Description" heading.
Description
This PR implements a weighted voting system for the EnergyGridControl contract, where a node's voting power is directly proportional to its registered energy capacity (MW). This enhancement ensures that governance decisions in the energy grid reflect the actual stake and operational significance of each participant.
Integration
This PR introduces a breaking change to the voting mechanism. Downstream projects must update their integration logic to account for the new weighted voting system.
Key Integration Changes
Voting Weight Calculation
Votes are now weighted by node capacity (1 MW = 1 voting power)
Update any off-chain vote tracking to multiply votes by node capacity
Modify UIs to display weighted vote counts instead of raw vote counts
Node Registration Requirements
All nodes must now specify capacity (in MW) during registration
Existing nodes need to be re-registered with capacity values
Implement capacity verification logic in your frontend
Quorum and Approval Thresholds
Commands now require:
Minimum 30% of total active capacity to participate (quorum)
60% weighted approval among participating votes
Update any automated command execution logic to check these new requirements
New Read-Only Functions to Use
getVotingPower(address) - Get current voting weight for a node
getCommandStatus(uint256) - Get detailed vote breakdown and execution eligibility
getTotalGridCapacity() - Get total active capacity for quorum calculations
Event Listening Updates
CommandVoted now emits votingPower (uint256) as the third parameter
CommandExecuted now emits totalVotesFor and totalVotesAgainst
NodeRegistered now emits votingPower as the fourth parameter
Review Notes
This PR replaces the simple binary voting system with a weighted voting mechanism where voting power is derived from a node's registered energy capacity. The implementation focuses on fairness, security, and real-world representation.
Checklist
Trequired)/cmd label <label-name>to add labelsBot Commands
You can use the following bot commands in comments to help manage your PR:
Labeling (Self-service for contributors):
/cmd label T1-FRAME- Add a single label/cmd label T1-FRAME R0-no-crate-publish-required- Add multiple labels/cmd label T6-XCM D2-substantial I5-enhancement- Add multiple labels at onceOther useful commands:
/cmd fmt- Format code (cargo +nightly fmt and taplo)/cmd prdoc- Generate PR documentation/cmd bench- Run benchmarks/cmd update-ui- Update UI tests/cmd --help- Show help for all available commandsYou can remove the "Checklist" section once all have been checked. Thank you for your contribution!
✄ -----------------------------------------------------------------------------