timewave-computer / valence-services

Other
3 stars 0 forks source link

Fix mutable config in rebalancer #72

Closed stiiifff closed 3 months ago

stiiifff commented 3 months ago

We have some data per target that we need to save in order to use it in next rebalance (last I and last input). Currently we are saving this data inside the target struct in the config, this makes the target vector mutable which is incorrect.

The targets provided by the user, should never change in storage. Inside the calculation there are cases where we need to calculate new targets percentage based on some limits met, but it should never be saved into storage.

This is a new bug that was introduced by my last bug fix, instead of only saving the data I need (last_i and last_input), I am saving the whole targets, this includes some inner rebalancer calculation when the minimum limit is hit.

Art3miX commented 3 months ago

Current fix was to only save specific data of what we need, not ideal.

Ideally we would separate user given data from in-place changes (changes required during rebalancing), this would mitigate issues like that in the future, as we won't need to update the config in storage.

Art3miX commented 3 months ago

This bug is fixed, opened new issue to improve the code to mitigate bugs like this in the future #73