Skip to content

Add Per-Ballot Token/Vote Limits #39

@Just-Bamford

Description

@Just-Bamford

��# Issue 20: Add Per-Ballot Token/Vote Limits

Problem

No upper bound on tokens or votes per ballot. Uncapped counts could exhaust ledger resources.

Solution

  • Add BallotLimits { max_tokens: u32, max_votes: u32 } struct
  • Store limits in BallotMetadata during record_ballot
  • Check limits in record_token and record_vote before incrementing
  • Return LimitExceeded error when limit reached

Implementation Tasks

  • Define BallotLimits struct
  • Add limits to record_ballot parameters
  • Store limits in BallotMetadata
  • Add limit checks in record_token and record_vote
  • Return LimitExceeded error with current count
  • Unit tests: limits are enforced correctly
  • Test: zero limit blocks all operations

Note for Contributors

Complete Issue #1 (ballot metadata storage) first. Limits are set during record_ballot and are immutable thereafter. The ballots creator (or admin) specifies max_tokens and max_votes when creating the ballot. Zero limit means unlimited (or use u32::MAX for explicit "no limit"). When incrementing would exceed limit, return LimitExceeded error with current count. This prevents ballots from growing unbounded and exhausting ledger resources. Limits enable resource management for ballot operators. Consider implementing optional limits (configurable per ballot). Each ballot can have different limits. Limits do not prevent reading � only writes are blocked when limits are reached.

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions