Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/981 max can allocate cannot be negative #982

Merged
merged 4 commits into from
Dec 31, 2023

Conversation

joe-bowman
Copy link
Contributor

1. Summary

Fixes #981

Ensure MaxCanAllocate cannot be negative. Add denfensive checks to DetermineAllocationsForDelegation to ensure safety from under and overflows.

2.Type of change

  • Bug fix (non-breaking change which fixes an issue)

3. Implementation details

Add a sdkmath.MaxInt(0, previousVal) to ensure that min is 0 if previousVal was negative.

Add defensive checks in DetermineAllocationsForDelegation to determine that maxCanAllocate is positive (caps cannot be negative) and that overall allocation sum is equal to the input amount.

Copy link

codecov bot commented Dec 31, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (2783379) 61.75% compared to head (efedaaa) 61.73%.
Report is 1 commits behind head on main.

❗ Current head efedaaa differs from pull request most recent head cf2c987. Consider uploading reports for the commit cf2c987 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #982      +/-   ##
==========================================
- Coverage   61.75%   61.73%   -0.03%     
==========================================
  Files         172      172              
  Lines       14116    14122       +6     
==========================================
  Hits         8718     8718              
- Misses       4651     4656       +5     
- Partials      747      748       +1     
Flag Coverage Δ
unittests 61.73% <12.50%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
x/interchainstaking/keeper/delegation.go 92.27% <100.00%> (ø)
x/interchainstaking/types/delegation.go 77.12% <0.00%> (-3.15%) ⬇️

@faddat faddat enabled auto-merge (squash) December 31, 2023 14:29
@faddat faddat merged commit 79b93f6 into main Dec 31, 2023
13 checks passed
@joe-bowman joe-bowman deleted the fix/981-max-can-allocate-cannot-be-negative branch December 31, 2023 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MaxCanAllocate can return negative values on overallocation
2 participants