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: make stkxprt staking respect and update global liquid staking cap #770

Merged
merged 2 commits into from
Feb 26, 2024

Conversation

xlab
Copy link
Contributor

@xlab xlab commented Feb 23, 2024

1. Overview

Replaced direct calls to stakingKeeper with a wrapper that does updates on global liquid stake accounting and checks the caps.

@xlab xlab requested a review from a team as a code owner February 23, 2024 14:08
@xlab xlab requested review from puneet2019 and kruspy February 23, 2024 14:08
Copy link

@xlab your pull request is missing a changelog!

Copy link

Coverage after merging f/stkxprt-global-cap into main

70.02%

Coverage Report
FileBranchesFuncsLinesUncovered Lines
x/liquidstake/keeper
   grpc_query.go100%100%100%
   genesis.go100%100%86.96%14, 23, 32
   keeper.go100%100%77.50%..., 92, 95, 96, 97
   liquidstake.go100%100%60.11%..., 87, 88, 89, 90
   rebalancing.go100%100%93.39%..., 45, 46, 81, 82
x/liquidstake/types
   params.go100%100%79.87%..., 242, 243, 97, 98
   codec.go100%100%100%
   msgs.go100%100%45.69%..., 51, 52, 63, 71
   genesis.go100%100%100%
   liquidstake.go100%100%93.57%..., 63, 64, 73, 81
   rebalancing.go100%100%84%22, 23, 40, 41
   keys.go100%100%100%
x/liquidstakeibc
   module.go100%100%56.10%..., 96, 97, 98, 99
   module_ibc.go100%100%8.93%..., 88, 89, 90, 91
   genesis.go100%100%100%
x/liquidstakeibc/keeper
   host_chain.go100%100%98.91%129, 202, 203
   invariants.go100%100%100%
   unbonding.go100%100%100%
   validator_unbonding.go100%100%100%
   ica_handlers.go100%100%29.18%..., 96, 97, 98, 99
   lsm_deposit.go100%100%100%
   ica.go100%100%65%..., 70, 71, 72, 73
   rebalance.go100%100%91.21%..., 115, 116, 77, 80
   keeper.go100%100%96.43%..., 398, 406, 93, 94
   user_unbonding.go100%100%100%
   icq_queries.go100%100%80%..., 144, 145, 146, 147
   deposit.go100%100%99.02%87, 88
   hooks.go100%100%41.91%..., 902, 903, 937, 938
   migrations.go100%100%33.33%..., 23, 26, 27, 28
   delegation_strategy.go100%100%100%
   grpc_querier.go100%100%95.17%..., 310, 311, 319, 320
   ibc.go100%100%23.32%..., 92, 93, 94, 99
   msg_server.go100%100%61.25%..., 986, 987, 990, 991
   redelegation.go100%100%100%
   abci.go100%100%73.91%..., 83, 84, 85, 86
   icq.go100%100%76.47%..., 237, 43, 44, 45
   redelegation_txs.go100%100%100%
x/liquidstakeibc/types
   host_chain.go100%100%100%
   keys.go100%100%0%..., 127, 129, 130, 131
   codec.go100%100%100%
   liquidstakeibc.go100%100%100%
   params.go100%100%100%
   msgs.go100%100%88.27%..., 54, 58, 62, 66
   hooks.go100%100%0%..., 29, 30, 31, 34
   genesis.go100%100%100%
x/ratesync
   module_simulation.go100%100%0%..., 79, 80, 81, 82
   genesis.go100%100%100%
   module.go100%100%64.06%..., 80, 83, 84, 85
   module_ibc.go100%100%9.09%..., 96, 97, 98, 99
x/ratesync/keeper
   params.go100%100%84.62%14, 15
   ica_tx.go100%100%71.92%..., 83, 84, 85, 86
   chain.go100%100%100%
   msg_server.go100%100%68.42%..., 70, 71, 72, 73
   ibc.go100%100%67.09%..., 55, 67, 68, 69
   abci.go100%100%95.65%36
   keeper.go100%100%78.38%..., 80, 81, 88, 89
   query.go100%100%85.71%..., 40, 41, 47, 48
   hooks.go100%100%87.76%..., 27, 28, 68, 69
x/ratesync/types
   keys.go100%100%100%
   params.go100%100%75%31, 32, 33, 34
   codec.go100%100%0%..., 26, 27, 28, 29
   genesis.go100%100%100%
   types.go100%100%96.53%..., 137, 138, 28, 29
   msgs.go100%100%67.94%..., 66, 79, 96, 97

Copy link
Collaborator

@kruspy kruspy left a comment

Choose a reason for hiding this comment

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

LGTM.

I see any of the SafelyIncreaseTotalLiquidStakedTokens and DecreaseTotalLiquidStakedTokens messes with the validator specific liquid shares. We really need to make sure of it.

Also, that all entrypoints (Delegate, Undelegate, StakeToLP) are covered by this.

If that is the case, then add tests and we good to go.

@puneet2019
Copy link
Member

should we also add it to the rebalancing (i don't think so), auto compounding (yes)..

@xlab
Copy link
Contributor Author

xlab commented Feb 23, 2024

should we also add it to the rebalancing (i don't think so), auto compounding (yes)..

autocompounding uses k.LiquidDelegate already, so just handling the error better

Copy link

Coverage after merging f/stkxprt-global-cap into main

69.99%

Coverage Report
FileBranchesFuncsLinesUncovered Lines
x/liquidstake/keeper
   genesis.go100%100%86.96%14, 23, 32
   rebalancing.go100%100%92.98%..., 45, 46, 81, 82
   grpc_query.go100%100%100%
   keeper.go100%100%77.50%..., 92, 95, 96, 97
   liquidstake.go100%100%59.78%..., 87, 88, 89, 90
x/liquidstake/types
   genesis.go100%100%100%
   msgs.go100%100%45.69%..., 51, 52, 63, 71
   codec.go100%100%100%
   params.go100%100%79.87%..., 242, 243, 97, 98
   rebalancing.go100%100%84%22, 23, 40, 41
   keys.go100%100%100%
   liquidstake.go100%100%93.57%..., 63, 64, 73, 81
x/liquidstakeibc
   module_ibc.go100%100%8.93%..., 88, 89, 90, 91
   genesis.go100%100%100%
   module.go100%100%56.10%..., 96, 97, 98, 99
x/liquidstakeibc/keeper
   deposit.go100%100%99.02%87, 88
   delegation_strategy.go100%100%100%
   msg_server.go100%100%61.25%..., 986, 987, 990, 991
   redelegation_txs.go100%100%100%
   invariants.go100%100%100%
   lsm_deposit.go100%100%100%
   rebalance.go100%100%91.21%..., 115, 116, 77, 80
   host_chain.go100%100%98.91%129, 202, 203
   redelegation.go100%100%100%
   user_unbonding.go100%100%100%
   ica.go100%100%65%..., 70, 71, 72, 73
   keeper.go100%100%96.43%..., 398, 406, 93, 94
   hooks.go100%100%41.91%..., 902, 903, 937, 938
   migrations.go100%100%33.33%..., 23, 26, 27, 28
   grpc_querier.go100%100%95.17%..., 310, 311, 319, 320
   validator_unbonding.go100%100%100%
   unbonding.go100%100%100%
   abci.go100%100%73.91%..., 83, 84, 85, 86
   icq.go100%100%76.47%..., 237, 43, 44, 45
   icq_queries.go100%100%80%..., 144, 145, 146, 147
   ibc.go100%100%23.32%..., 92, 93, 94, 99
   ica_handlers.go100%100%29.18%..., 96, 97, 98, 99
x/liquidstakeibc/types
   keys.go100%100%0%..., 127, 129, 130, 131
   hooks.go100%100%0%..., 29, 30, 31, 34
   msgs.go100%100%88.27%..., 54, 58, 62, 66
   params.go100%100%100%
   host_chain.go100%100%100%
   codec.go100%100%100%
   genesis.go100%100%100%
   liquidstakeibc.go100%100%100%
x/ratesync
   module_simulation.go100%100%0%..., 79, 80, 81, 82
   module_ibc.go100%100%9.09%..., 96, 97, 98, 99
   module.go100%100%64.06%..., 80, 83, 84, 85
   genesis.go100%100%100%
x/ratesync/keeper
   params.go100%100%84.62%14, 15
   keeper.go100%100%78.38%..., 80, 81, 88, 89
   query.go100%100%85.71%..., 40, 41, 47, 48
   hooks.go100%100%87.76%..., 27, 28, 68, 69
   chain.go100%100%100%
   ibc.go100%100%67.09%..., 55, 67, 68, 69
   abci.go100%100%95.65%36
   msg_server.go100%100%68.42%..., 70, 71, 72, 73
   ica_tx.go100%100%71.92%..., 83, 84, 85, 86
x/ratesync/types
   types.go100%100%96.53%..., 137, 138, 28, 29
   codec.go100%100%0%..., 26, 27, 28, 29
   keys.go100%100%100%
   msgs.go100%100%67.94%..., 66, 79, 96, 97
   genesis.go100%100%100%
   params.go100%100%75%31, 32, 33, 34

@xlab xlab merged commit 8dab3fa into main Feb 26, 2024
9 of 10 checks passed
@xlab xlab deleted the f/stkxprt-global-cap branch February 26, 2024 10:45
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