Skip to content

feat: implement weighted voting system based on node energy capacity#8

Open
syed-ghufran-hassan wants to merge 1 commit intoLuxbin-labs:masterfrom
syed-ghufran-hassan:patch-1
Open

feat: implement weighted voting system based on node energy capacity#8
syed-ghufran-hassan wants to merge 1 commit intoLuxbin-labs:masterfrom
syed-ghufran-hassan:patch-1

Conversation

@syed-ghufran-hassan
Copy link

@syed-ghufran-hassan syed-ghufran-hassan commented Feb 19, 2026

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.

✄ -----------------------------------------------------------------------------

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

  • My PR includes a detailed description as outlined in the "Description" and its two subsections above.
  • My PR follows the labeling requirements of this project (at minimum one label for T required)
    • External contributors: Use /cmd label <label-name> to add labels
    • Maintainers can also add labels manually
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works (if applicable)

Bot 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 once
  • See label documentation for all available labels

Other 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 commands

You can remove the "Checklist" section once all have been checked. Thank you for your contribution!

✄ -----------------------------------------------------------------------------

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant