Skip to content

Add maximum group duration limit#116

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

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

Conversation

@WuXieSec
Copy link
Copy Markdown

This PR adds a maximum group duration limit to prevent indefinitely long savings cycles, as requested in #55.

Changes:

  • Add MAX_GROUP_DURATION constant (365 days)
  • Validate total_rounds * cycle_length <= max_duration during create_group
  • Add DurationTooLong error variant
  • Return clear error if duration exceeds limit
  • Add comprehensive test coverage

Why this matters:
Without a duration limit:

  • Groups could run for years or decades
  • Members would be locked in for unreasonable timeframes
  • Storage costs would accumulate indefinitely
  • Risk of abandoned groups increases

Implementation:
The validation calculates worst-case duration as:

total_duration = max_members * cycle_length

This assumes all members join (which determines total_rounds). If the total exceeds 365 days, group creation fails with DurationTooLong.

Test coverage:

  • ✅ Valid duration (5 members × 30 days = 150 days)
  • ❌ Duration exceeds limit (100 members × 10 days = 1000 days) → DurationTooLong
  • ❌ Just over boundary (366 members × 1 day) → DurationTooLong
  • ✅ Exactly at limit (365 members × 1 day = 365 days)

Closes #55

Changes:
- Add MAX_GROUP_DURATION constant (365 days)
- Validate total_rounds * cycle_length <= max_duration during create_group
- Add DurationTooLong error variant
- Return clear error if duration exceeds limit
- Add comprehensive test coverage

This prevents indefinitely long savings cycles and ensures
groups complete within a reasonable timeframe.

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