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: tally grpc query #8718

Merged
merged 2 commits into from
Sep 19, 2024
Merged

fix: tally grpc query #8718

merged 2 commits into from
Sep 19, 2024

Conversation

czarcas7ic
Copy link
Member

@czarcas7ic czarcas7ic commented Sep 19, 2024

Closes: #XXX

What is the purpose of the change

For the grpc query, we used to just log errors and continue. During the sdk v50 upgrade, we for some reason changed to returning errors. This brings back the old logic.

Pre sdk v50 logic for comparison

for i, lock := range synthlocks {
// get locked coin from the lock ID
interim, ok := k.GetIntermediaryAccountFromLockId(ctx, lock.UnderlyingLockId)
if !ok {
continue
}
lock, err := k.lk.GetLockByID(ctx, lock.UnderlyingLockId)
if err != nil {
ctx.Logger().Error("lockup retrieval failed with underlying lock", "Lock", lock, "Error", err)
continue
}
coin, err := lock.SingleCoin()
if err != nil {
ctx.Logger().Error("lock fails to meet expected invariant, it contains multiple coins", "Lock", lock, "Error", err)
continue
}
// get osmo-equivalent token amount
amount, err := k.GetSuperfluidOSMOTokens(ctx, interim.Denom, coin.Amount)
if err != nil {
ctx.Logger().Error("failed to get osmo equivalent of token", "Denom", interim.Denom, "Amount", coin.Amount, "Error", err)
continue
}
// get validator shares equivalent to the token amount
valAddr, err := sdk.ValAddressFromBech32(interim.ValAddr)
if err != nil {
ctx.Logger().Error("failed to decode validator address", "Intermediary", interim.ValAddr, "LockID", lock.ID, "Error", err)
continue
}
validator, found := k.sk.GetValidator(ctx, valAddr)
if !found {
ctx.Logger().Error("validator does not exist for lock", "Validator", valAddr, "LockID", lock.ID)
continue
}
shares, err := validator.SharesFromTokens(amount)
if err != nil {
// tokens are not valid. continue.
continue
}

@czarcas7ic czarcas7ic marked this pull request as ready for review September 19, 2024 03:49
Copy link
Contributor

@nicolaslara nicolaslara left a comment

Choose a reason for hiding this comment

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

This makes sense.

@czarcas7ic czarcas7ic merged commit 768fbf7 into v26.x Sep 19, 2024
1 check passed
@czarcas7ic czarcas7ic deleted the adam/temp-fix-tally branch September 19, 2024 04:08
@Jeongseup
Copy link

Thank you so much

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.

3 participants