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: refactor redelegations distribution logic #490

Merged
merged 10 commits into from
Jul 11, 2023

Conversation

joe-bowman
Copy link
Contributor

@joe-bowman joe-bowman commented Jul 10, 2023

1. Summary

Remove complexity and improve readability in rebalancing.

2.Type of change

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

3. Implementation details

Rewrite logic for readability and efficiency; don't handle locked tokens twice (potential bug?).

Use specific Delta types instead of trying to reuse ValidatorIntents and casting between Dec and Int all of the place 🤮

CalculateDeltasNew will supercede CalculateDeltas and be renamed with future work. It now outputs two slices, for targets and sources, instead of a single slice containing positive and negative deltas. The latter was far more difficult to reason about and required more complex logic to handle.

6. Limitations

Currently only affects redelegations. Deposit and unbonding logic uses legacy distribution.

7. Future Work (optional)

Update deposits and unbonding to use the new types and logic.

ajansari95
ajansari95 previously approved these changes Jul 10, 2023
Copy link
Contributor

@ajansari95 ajansari95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, cleannn

x/interchainstaking/types/rebalance.go Outdated Show resolved Hide resolved
x/interchainstaking/types/rebalance.go Outdated Show resolved Hide resolved
x/interchainstaking/types/rebalance.go Outdated Show resolved Hide resolved
x/interchainstaking/types/rebalance.go Outdated Show resolved Hide resolved
x/interchainstaking/types/rebalance.go Outdated Show resolved Hide resolved
x/interchainstaking/types/rebalance_test.go Show resolved Hide resolved
x/interchainstaking/types/rebalance_test.go Outdated Show resolved Hide resolved
ajansari95
ajansari95 previously approved these changes Jul 10, 2023
Copy link
Contributor

@ajansari95 ajansari95 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@joe-bowman
Copy link
Contributor Author

nits addressed @aljo242 @ajansari95

ajansari95
ajansari95 previously approved these changes Jul 11, 2023
Copy link
Contributor

@muku314115 muku314115 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ajansari95
Copy link
Contributor

DNM for now

@ajansari95 ajansari95 merged commit 81cd188 into develop Jul 11, 2023
@joe-bowman joe-bowman deleted the redelegations-rewrite branch November 7, 2023 22:57
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.

4 participants