informalsystems / partnership-heliax

1 stars 0 forks source link

Compute total_unbonded more efficietnly #48

Closed angbrav closed 1 year ago

angbrav commented 1 year ago

We could solve the iteration over the set_unbonds by grouping unbonds by a pair of bond start epoch and unbond epoch.

brentstone commented 1 year ago

This is addressed in Namada in b7eddc2c46cdc72aafe1abd6c91e8ab9ab929e5c. Will add to #43

brentstone commented 1 year ago

Now addressed in the pseudocode in 16bb8860715ad3ebb801c81c18ab019a72f9af7e

brentstone commented 1 year ago

Why do we actually use set_unbonds as opposed to simply using the Unbonds themselves? They both encode the same information I believe: only set_unbonds stores the epoch at which an unbond becomes active, while Unbond encodes the withdrawal epoch. However, there's a 1 to 1 correspondence between these two epochs.

Perhaps it is because the data structures in the pseudocode are slightly different? However, in Namada, they are implemented the same as Map<Epoch, Map<Epoch, token::Amount>>. I wonder if we can just remove this.

angbrav commented 1 year ago

I agree all information in set_unbonds is in unbonds. The idea was to keep them separate to avoid iterating over unbonds. But given the way is implemented in Namada, it is redundant. Nevertheless, with the more efficient way of computing total_unbonded, I believe this "problem" goes away.

brentstone commented 1 year ago

Completed in #54