-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Bank] Remove the unsafe balance changing API #8473
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8473 +/- ##
==========================================
- Coverage 61.47% 61.42% -0.06%
==========================================
Files 658 658
Lines 37588 37627 +39
==========================================
+ Hits 23109 23111 +2
- Misses 12067 12104 +37
Partials 2412 2412
|
* init supply in a different way * remove external usage of set supply * change(staking): replace SetSupply with MintCoins in tests * change(evidence): replace SetSupply with MintCoins in tests * change(crisis): remove SetSupply in tests * change(bank): remove set supply from genesis tests * change(bank): remove set supply from keeper tests * change(bank): remove remaining set supply usage from keeper tests * change(bank): remove set supply usage from grpc query and querier tests * change(bank): remove SetSupply from keeper interface Co-authored-by: Frojdi Dymylja <[email protected]>
…mos-sdk into jonathan-frojdi/refactor-bank
) * change(distribution): remove SetBalances usage from keeper tests * add(simapp): FundAccount utility function * chore(staking): use FundAccount in keeper tests * change(staking): remove usage of SetBalance in allocation tests * change(staking): remove usage of SetBalance in delegation tests * change(staking): remove usage of SetBalance in proposal handler tests * change(staking): remove usage of SetBalances in grpc query tests * change(staking): remove usage of SetBalances in operations tests * change(distribution): remove usage of SetBalances in genesis * change(authz): remove usage of SetBalances keeper and operations test * fix(authz): TestKeeperFees failing test * change(slashing): remove SetBalances from expected BankKeeper * change(slashing): remove usage of SetBalances in tests * change(distribution): remove SetBalances from expected BankKeeper * change(genutil): remove usage of SetBalances from tests * change(gov): remove SetBalances from expected BankKeeper * change(gov): remove usage of SetBalances from tests * change(staking): remove usage of SetBalances from slash tests * change(staking): remove SetBalances from expected BankKeeper * change(staking): remove usage of SetBalances from delegation tests * change(staking): remove usage of SetBalances from operations tests * change(staking): remove usage of SetBalances from validator tests * change(bank): remove usage of SetBalances from app tests * change(bank): remove usage of SetBalances from bench tests * change(bank): remove usage of SetBalances from querier tests * change(bank): remove usage of SetBalances from grpc query tests * change(bank): remove usage of SetBalances from operations tests * change(bank): partially remove usage of SetBalances from keeper tests * change(bank): finalize removal of usage of SetBalances from keeper tests * change(auth): remove usage of SetBalances from verify tests * change(auth): partially remove usage of SetBalances from tests * [Bank refactor]: finalize removal of setbalances from auth (#8527) * add tests with is check tx * temp commit * fix test * fix other test and remove setbalances * change(auth): remove usage of SetBalances is vesting tests Co-authored-by: Jonathan Gimeno <[email protected]> * change(types): remove usage of SetBalances in queries * fix(types): pagination tests * [Bank refactor] fix pagination tests (#8550) * fix tests * lint * change(bank): remove SetBalances from keeper public API Co-authored-by: Jonathan Gimeno <[email protected]> Co-authored-by: SaReN <[email protected]>
…rojdi/refactor-bank
I do agree on this point, I think this PR has showed some problems in the structure of simapp and its usage, I think the correct approach would be to open an issue and highlight those problems and eventually solve them, instead of creating a new package which might or might not be used or ignored in the future. I'm not even sure creating a new package is the correct solution of this problem. I think it would probably be worth to open a discussion on the structure and role of simapp in the sdk. But I don't think this PR is the correct place to start tackling this problem. I think it's better if we introduce this bad change which keeps thing consistent, rather than introducing a possible solution which adds confusion and might get discarded in the future. My philosophy is that "it's better to be consistent in doing thins in a bad way than being inconsistent in doing them in a good way" |
Please @robert-zaremba unblock this PR. More work will ensue in separate PRs. |
I don't agree on that. Creating a new package is simple thing, and I'm only concerned here for the new code. I'm worried that this excuse will continue and and we will pollute more and more this and other similar packages. |
I created an issue for refactoring simapp. I have a feeling it won't be done any time soon and that's why I want to urge to stop polluting simapp and increasing future breaking changes -> ref |
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.
Unblocking. At minimum I would like to change FundAccount
arguments - the function doesn't need to depend on the App. It only needs BankKeeper as an argument.
My other general comments adding stuff to simapp package are here: https://github.com/cosmos/cosmos-sdk/pull/8473/files#issuecomment-779871480
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.
👍
x/genutil/gentx_test.go
Outdated
suite.ctx, addr, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 25)}, | ||
) | ||
suite.Require().NoError(err) | ||
suite.Require().NoError(simapp.FundAccount(suite.app, suite.ctx, addr, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 25)})) |
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 feel this should be added to linting rules, developers shouldn't need to think about these things 🤔
I totally agree with what you're saying, the decision was made in order not to add more confusion, there are a lot of test helpers and packages in the sdk and adding one more or migrating the code somewhere else does not help. We should have a clear idea on the role of each package and the utilities that go inside it, this is why we felt this PR was not the correct place for this dicussion. |
I highly agree with what @robert-zaremba said. Would definitely make testing easier on my end at least. |
This PR breaks Ethermint as there is no way to set an updated balance to the store, which is required by the |
@fedekunze the AddBalance and SubBalance methods were removed because they bypassed supply checks. If I may ask, why can't your use case be covered via BurnCoins/MintCoins and MoveCoins (this is at least how we work-around set balance in a safe way)? |
Yeah that's possible, but ideally, it should be exposed through the bank keeper instead of having other modules create their own accounting methods |
I'm not sure if I understood what you're suggesting, but if it means to bring back AddBalance/SetBalance/SubBalance then it would mean going back to how it was before. Which would also break rosetta as balance and supply tracking are not guaranteed to work anymore. If you mean creating methods which make "account funding" easier, then we could bring in to bank the |
We want to move |
* temp commit * setbalance now is internal * remove set balances in genesis * feedback test commit * update tests * fix: genesis panic message * fix not bonded pool * fix(staking): genesis test * fix(simapp): rollback state fix change * fix(staking): genesis large val set test * [Bank Refactor] Frojdi jonathan/remove setsupply (cosmos#8491) * init supply in a different way * remove external usage of set supply * change(staking): replace SetSupply with MintCoins in tests * change(evidence): replace SetSupply with MintCoins in tests * change(crisis): remove SetSupply in tests * change(bank): remove set supply from genesis tests * change(bank): remove set supply from keeper tests * change(bank): remove remaining set supply usage from keeper tests * change(bank): remove set supply usage from grpc query and querier tests * change(bank): remove SetSupply from keeper interface Co-authored-by: Frojdi Dymylja <[email protected]> * remove setbalances from genesis in gov * remove keyring * add init genesis state * change(staking): make genesis checks coherent and add tests * remove setbalances on distribution * fix(staking): genesis tests * [Bank Refactor]: Remove SetBalances usage from the code and tests (cosmos#8509) * change(distribution): remove SetBalances usage from keeper tests * add(simapp): FundAccount utility function * chore(staking): use FundAccount in keeper tests * change(staking): remove usage of SetBalance in allocation tests * change(staking): remove usage of SetBalance in delegation tests * change(staking): remove usage of SetBalance in proposal handler tests * change(staking): remove usage of SetBalances in grpc query tests * change(staking): remove usage of SetBalances in operations tests * change(distribution): remove usage of SetBalances in genesis * change(authz): remove usage of SetBalances keeper and operations test * fix(authz): TestKeeperFees failing test * change(slashing): remove SetBalances from expected BankKeeper * change(slashing): remove usage of SetBalances in tests * change(distribution): remove SetBalances from expected BankKeeper * change(genutil): remove usage of SetBalances from tests * change(gov): remove SetBalances from expected BankKeeper * change(gov): remove usage of SetBalances from tests * change(staking): remove usage of SetBalances from slash tests * change(staking): remove SetBalances from expected BankKeeper * change(staking): remove usage of SetBalances from delegation tests * change(staking): remove usage of SetBalances from operations tests * change(staking): remove usage of SetBalances from validator tests * change(bank): remove usage of SetBalances from app tests * change(bank): remove usage of SetBalances from bench tests * change(bank): remove usage of SetBalances from querier tests * change(bank): remove usage of SetBalances from grpc query tests * change(bank): remove usage of SetBalances from operations tests * change(bank): partially remove usage of SetBalances from keeper tests * change(bank): finalize removal of usage of SetBalances from keeper tests * change(auth): remove usage of SetBalances from verify tests * change(auth): partially remove usage of SetBalances from tests * [Bank refactor]: finalize removal of setbalances from auth (cosmos#8527) * add tests with is check tx * temp commit * fix test * fix other test and remove setbalances * change(auth): remove usage of SetBalances is vesting tests Co-authored-by: Jonathan Gimeno <[email protected]> * change(types): remove usage of SetBalances in queries * fix(types): pagination tests * [Bank refactor] fix pagination tests (cosmos#8550) * fix tests * lint * change(bank): remove SetBalances from keeper public API Co-authored-by: Jonathan Gimeno <[email protected]> Co-authored-by: SaReN <[email protected]> * change(bank): remove SubtractCoins from keeper public API * change(ibc/transfer): remove AddCoins from relay tests * change(bank): remove AddCoins from public keeper API * fix imports * remove set balances * fix fee test * remove set balances * fix(staking): remove dependency on minter authorization for staking pools * chore: update CHANGELOG.md * update: x/distribution/keeper/keeper_test.go Co-authored-by: Robert Zaremba <[email protected]> * Update simapp/test_helpers.go Co-authored-by: Robert Zaremba <[email protected]> * Update x/staking/genesis_test.go Co-authored-by: Robert Zaremba <[email protected]> * fix(simapp): FundAccount amount variable name * fix some PR issues Co-authored-by: Frojdi Dymylja <[email protected]> Co-authored-by: Frojdi Dymylja <[email protected]> Co-authored-by: SaReN <[email protected]> Co-authored-by: Alessio Treglia <[email protected]> Co-authored-by: Robert Zaremba <[email protected]>
Description
This PR removes all the usage of unsafe balance changing methods from the bank keeper exposed API and all the sdk tests relying on it.
A new function was added in simapp, called
FundAccount
which can be used to fund an account which requires balance for tests.Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes