-
Notifications
You must be signed in to change notification settings - Fork 607
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
refactor(deps): switch to cosmossdk.io/math from fork math #6238
Conversation
Important Notice This PR modifies an in-repo Go module. It is one of:
The dependent Go modules, especially the root one, will have to be Please follow the instructions below:
Please let us know if you need any help. |
7f08d85
to
40a7f6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, what's the reason for decision behind making an alias package osmomath and then importing from osmomath directly instead of using sdkmath package?
This is to reduce verbosity from the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, nice work, must have been pain going through all this
func ZeroBigDec() BigDec { return BigDec{new(big.Int).Set(zeroInt)} } | ||
func OneBigDec() BigDec { return BigDec{precisionInt()} } | ||
func SmallestBigDec() BigDec { return BigDec{new(big.Int).Set(oneInt)} } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like these changes, feels like this is what it should have always been
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work with this PR, reviewed an it works as expected 👍
I have one comment based on the use of sdk.ZeroDec(
and other uses of the sdk types package for math functions. There's an alias created there that is very similar to the alias created in the osmomath
package.
When we run grep -r "sdk.ZeroDec("
we find we refer to the alias in our sdk fork, could we just use osmomath.ZeroDec(
here instead? And remove the need to import the sdk "github.com/cosmos/cosmos-sdk/types"
package for math functions?
Approved here with the understanding that this suggestion should probably be another PR if we want to go that route. ⚡
40a7f6f
to
0c8f0ae
Compare
Seems that some updates got affected by merge conflicts, thanks for catching. Will reswitch everything prior to merge |
* refactor(deps): switch to cosmossdk.io/math from fork math * switch remaining things * updates (cherry picked from commit ca75f4c) # Conflicts: # app/apptesting/concentrated_liquidity.go # app/apptesting/pool_manager.go # app/apptesting/test_suite.go # app/upgrades/v16/upgrades.go # app/upgrades/v17/constants.go # app/upgrades/v18/upgrades_test.go # app/upgrades/v19/upgrades.go # app/upgrades/v19/upgrades_test.go # app/upgrades/v3/forks.go # app/upgrades/v9/prop214.go # cmd/osmosisd/cmd/genesis.go # cmd/osmosisd/cmd/root.go # go.mod # go.sum # osmomath/sqrt.go # osmomath/sqrt_big_test.go # osmomath/sqrt_test.go # osmoutils/osmocli/dynamic_test.go # simulation/simtypes/randutil.go # tests/cl-genesis-positions/go.mod # tests/cl-genesis-positions/go.sum # tests/e2e/configurer/chain/chain.go # tests/e2e/configurer/chain/commands.go # tests/e2e/configurer/chain/queries.go # tests/e2e/configurer/upgrade.go # tests/e2e/containers/containers.go # tests/e2e/e2e_test.go # tests/e2e/helpers_e2e_test.go # tests/e2e/initialization/config.go # tests/e2e/initialization/node.go # tests/ibc-hooks/ibc_middleware_test.go # tests/ibc-hooks/path_validation_test.go # tests/ibc-hooks/xcs_cw20_test.go # tests/simulator/sim_test.go # tests/simulator/state.go # wasmbinding/query_plugin_test.go # wasmbinding/test/custom_msg_test.go # wasmbinding/test/helpers_test.go # wasmbinding/test/messages_test.go # x/concentrated-liquidity/bench_test.go # x/concentrated-liquidity/client/query_proto_wrap.go # x/concentrated-liquidity/event.go # x/concentrated-liquidity/incentives.go # x/concentrated-liquidity/incentives_test.go # x/concentrated-liquidity/math/precompute.go # x/concentrated-liquidity/model/msgs.go # x/concentrated-liquidity/model/msgs_test.go # x/concentrated-liquidity/msg_server.go # x/concentrated-liquidity/msg_server_test.go # x/concentrated-liquidity/simulation/sim_msgs.go # x/concentrated-liquidity/total_liquidity.go # x/concentrated-liquidity/types/expected_keepers.go # x/concentrated-liquidity/types/gov_test.go # x/concentrated-liquidity/types/msgs_test.go # x/concentrated-liquidity/types/params_test.go # x/cosmwasmpool/cosmwasm/msg/transmuter/transmuter_test.go # x/cosmwasmpool/model/pool_test.go # x/cosmwasmpool/model/store_model.go # x/cosmwasmpool/pool_module_test.go # x/gamm/client/cli/query_test.go # x/gamm/client/cli/tx_test.go # x/gamm/keeper/export_test.go # x/gamm/keeper/gas_test.go # x/gamm/keeper/genesis_test.go # x/gamm/keeper/grpc_query.go # x/gamm/keeper/grpc_query_test.go # x/gamm/keeper/keeper_test.go # x/gamm/keeper/msg_server_test.go # x/gamm/keeper/pool.go # x/gamm/keeper/pool_test.go # x/gamm/keeper/share.go # x/gamm/keeper/swap.go # x/gamm/keeper/swap_test.go # x/gamm/keeper/total_liquidity.go # x/gamm/pool-models/balancer/amm_test.go # x/gamm/pool-models/balancer/marshal_test.go # x/gamm/pool-models/balancer/msgs_test.go # x/gamm/pool-models/balancer/pool.go # x/gamm/pool-models/balancer/pool_asset.go # x/gamm/pool-models/balancer/pool_params.go # x/gamm/pool-models/internal/cfmm_common/lp_test.go # x/gamm/pool-models/stableswap/msgs_test.go # x/gamm/pool-models/stableswap/pool_params.go # x/gamm/pool-models/stableswap/util_test.go # x/gamm/simulation/sim_msgs.go # x/gamm/types/expected_keepers.go # x/gamm/types/gov.go # x/gamm/types/msgs_test.go # x/gamm/types/pool.go # x/ibc-rate-limit/ibc_middleware_test.go # x/incentives/client/cli/query_test.go # x/incentives/keeper/distribute.go # x/incentives/keeper/distribute_test.go # x/incentives/keeper/export_test.go # x/incentives/keeper/gauge.go # x/incentives/keeper/gauge_test.go # x/incentives/keeper/grpc_query_test.go # x/incentives/keeper/keeper_test.go # x/incentives/keeper/msg_server_test.go # x/incentives/keeper/store_test.go # x/incentives/simulation/operations.go # x/incentives/types/expected_keepers.go # x/incentives/types/gauge.go # x/incentives/types/msgs_test.go # x/lockup/keeper/bench_test.go # x/lockup/keeper/genesis_test.go # x/lockup/keeper/grpc_query_test.go # x/lockup/keeper/invariants.go # x/lockup/keeper/lock.go # x/lockup/keeper/lock_test.go # x/lockup/keeper/msg_server_test.go # x/lockup/keeper/store.go # x/lockup/types/msgs_test.go # x/mint/keeper/export_test.go # x/mint/keeper/genesis.go # x/mint/simulation/decoder_test.go # x/mint/simulation/genesis.go # x/mint/simulation/genesis_test.go # x/mint/types/minter_test.go # x/mint/types/params_test.go # x/pool-incentives/keeper/distr_test.go # x/pool-incentives/keeper/genesis.go # x/pool-incentives/keeper/genesis_test.go # x/pool-incentives/keeper/grpc_query.go # x/pool-incentives/keeper/grpc_query_test.go # x/pool-incentives/keeper/hooks.go # x/pool-incentives/keeper/keeper_test.go # x/pool-incentives/types/genesis_test.go # x/pool-incentives/types/gov_test.go # x/pool-incentives/types/incentives_test.go # x/pool-incentives/types/record_test.go # x/poolmanager/client/cli/tx.go # x/poolmanager/client/cli/tx_test.go # x/poolmanager/client/testutil/test_helpers.go # x/poolmanager/create_pool_test.go # x/poolmanager/events/emit_test.go # x/poolmanager/export_test.go # x/poolmanager/keeper_test.go # x/poolmanager/msg_server_test.go # x/poolmanager/router.go # x/poolmanager/router_test.go # x/poolmanager/taker_fee.go # x/poolmanager/types/expected_keepers.go # x/poolmanager/types/gov_test.go # x/poolmanager/types/msgs_test.go # x/poolmanager/types/params.go # x/protorev/client/cli/utils.go # x/protorev/keeper/developer_fees.go # x/protorev/keeper/developer_fees_test.go # x/protorev/keeper/emit.go # x/protorev/keeper/emit_test.go # x/protorev/keeper/epoch_hook_test.go # x/protorev/keeper/grpc_query_test.go # x/protorev/keeper/hooks.go # x/protorev/keeper/hooks_test.go # x/protorev/keeper/keeper_test.go # x/protorev/keeper/msg_server_test.go # x/protorev/keeper/posthandler_test.go # x/protorev/keeper/protorev_test.go # x/protorev/keeper/rebalance.go # x/protorev/keeper/rebalance_test.go # x/protorev/keeper/routes.go # x/protorev/keeper/routes_test.go # x/protorev/keeper/statistics.go # x/protorev/keeper/statistics_test.go # x/protorev/types/expected_keepers.go # x/protorev/types/msg_test.go # x/superfluid/client/cli/query_test.go # x/superfluid/keeper/concentrated_liquidity.go # x/superfluid/keeper/edge_case_test.go # x/superfluid/keeper/epoch.go # x/superfluid/keeper/epoch_test.go # x/superfluid/keeper/export_test.go # x/superfluid/keeper/genesis_test.go # x/superfluid/keeper/gov/gov_test.go # x/superfluid/keeper/grpc_query.go # x/superfluid/keeper/hooks.go # x/superfluid/keeper/hooks_test.go # x/superfluid/keeper/intermediary_account_test.go # x/superfluid/keeper/internal/events/emit_test.go # x/superfluid/keeper/invariants.go # x/superfluid/keeper/keeper_test.go # x/superfluid/keeper/msg_server_test.go # x/superfluid/keeper/stake_test.go # x/superfluid/keeper/superfluid_asset_test.go # x/superfluid/keeper/twap_price.go # x/superfluid/keeper/twap_price_test.go # x/superfluid/keeper/unpool_test.go # x/superfluid/simulation/genesis.go # x/superfluid/types/errors.go # x/superfluid/types/expected_keepers.go # x/superfluid/types/msg_test.go # x/tokenfactory/keeper/createdenom_test.go # x/tokenfactory/module.go # x/tokenfactory/types/msgs_test.go # x/twap/api.go # x/twap/client/query_proto_wrap_test.go # x/twap/listeners.go # x/twap/migrate_test.go # x/twap/store_test.go # x/twap/types/twapmock/amminterface.go # x/txfees/keeper/feedecorator.go # x/txfees/keeper/feedecorator_test.go # x/txfees/keeper/feetokens.go # x/txfees/keeper/hooks.go # x/txfees/keeper/hooks_test.go # x/txfees/keeper/keeper_test.go # x/txfees/types/expected_keepers.go # x/valset-pref/client/cli/query_test.go # x/valset-pref/export_test.go # x/valset-pref/keeper.go # x/valset-pref/keeper_test.go # x/valset-pref/msg_server_test.go # x/valset-pref/simulation/sim_msgs.go # x/valset-pref/types/expected_interfaces.go # x/valset-pref/types/msgs_test.go # x/valset-pref/validator_set_test.go
* refactor(deps): switch to cosmossdk.io/math from fork math * switch remaining things * updates (cherry picked from commit ca75f4c) # Conflicts: # go.mod # go.sum # tests/e2e/e2e_test.go # tests/ibc-hooks/ibc_middleware_test.go # tests/ibc-hooks/path_validation_test.go # x/concentrated-liquidity/incentives.go # x/concentrated-liquidity/incentives_test.go # x/concentrated-liquidity/math/precompute.go # x/concentrated-liquidity/math/tick.go # x/concentrated-liquidity/math/tick_test.go # x/concentrated-liquidity/model/pool.go # x/concentrated-liquidity/pool.go # x/concentrated-liquidity/types/constants.go # x/concentrated-liquidity/types/errors.go # x/incentives/keeper/distribute.go # x/incentives/keeper/distribute_test.go # x/incentives/keeper/gauge_test.go # x/incentives/keeper/keeper_test.go # x/incentives/keeper/store_test.go # x/poolmanager/router.go # x/poolmanager/router_test.go # x/protorev/keeper/keeper_test.go # x/protorev/keeper/posthandler_test.go # x/protorev/keeper/routes_test.go
…6238) (#6341) * squash * Generated protofile changes --------- Co-authored-by: roman <[email protected]> Co-authored-by: github-actions <[email protected]>
Progress towards: #6099
What is the purpose of the change
This PR proposes creating an alias for
sdkmath
types inosmomath
.Primarily, its goal is to remove the need for the verbose and unreadable prefix "Legacy" from
Dec
.To avoid having to directly import both
sdkmath
andosmomath
in files where bothDec
andInt
/Uint
types are used we also create aliases for integer types. The aliases are created in the new filesdk_math_alias.go
To avoid name clashes with
BigDec
andBigDec
, their constrictor APIs are now broken to contain "Big" in the suffix. For example,NewDec
->NewBigDec
.Important Notes
by default in proto marhaling/unmarshaling. Instead, they get set to nil values.
precompute.go
in CL due tomaxBitLen
changesInt
toDec
, "LegacyDec" is still present since it is impossible to define a method onInt
outside ofcosmossdk.io/math
packagemaxDecBitLen
+ proto marshalingTesting and Verifying
This change is already covered by existing tests
Documentation and Release Note
Unreleased
section ofCHANGELOG.md
?Where is the change documented?
x/{module}/README.md
)