Skip to content

Add maximum group duration limit#106

Open
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
WuXieSec:feat/max-group-duration
Open

Add maximum group duration limit#106
WuXieSec wants to merge 1 commit intosorosave-protocol:mainfrom
WuXieSec:feat/max-group-duration

Conversation

@WuXieSec
Copy link
Copy Markdown

This PR enforces a maximum total duration for savings groups to prevent indefinitely long cycles, as requested in #55.

Changes:

  • Add MAX_GROUP_DURATION constant (365 days in seconds)
  • Validate total_rounds * cycle_length <= MAX_GROUP_DURATION during start_group
  • Add DurationTooLong error variant to ContractError
  • Return clear error if duration exceeds limit
  • Add test coverage for both valid and invalid durations

Why this matters:
Without a duration limit, groups could theoretically run for years or decades, which:

  • Increases risk for participants
  • Makes planning difficult
  • Could lead to abandoned groups
  • Complicates dispute resolution

Implementation:
The validation happens in start_group (not create_group) because total_rounds equals the final member count, which isn't known until the group starts.

Example:

  • 10 members × 30-day cycles = 300 days total ✅
  • 10 members × 50-day cycles = 500 days total ❌ (exceeds 365-day limit)

Closes #55

Changes:
- Add MAX_GROUP_DURATION constant (365 days)
- Validate total_rounds * cycle_length <= max_duration in start_group
- Add DurationTooLong error variant
- Return clear error if duration exceeds limit
- Add test coverage for both valid and invalid durations

This prevents groups from running indefinitely long savings cycles,
ensuring reasonable timeframes for all participants.

Closes sorosave-protocol#55
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.

Add maximum group duration limit

1 participant