-
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
Enable/disable coin transfers by denom #6527
Enable/disable coin transfers by denom #6527
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6527 +/- ##
==========================================
+ Coverage 55.60% 56.45% +0.85%
==========================================
Files 457 412 -45
Lines 27440 24503 -2937
==========================================
- Hits 15257 13834 -1423
+ Misses 11083 9578 -1505
+ Partials 1100 1091 -9 |
Modified SendEnabled property to be part of generic Params object Updated genesis functions to use default params structure
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.
Looks good! I left a couple of comments and a few questions
Remove empty denom capability from SendEnabled parameters Update simulation to exercise both configuration options independently
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.
ACK. Thanks, @iramiller. Minor suggestions and then I'll approve 👍
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.
Excellent work. I think this changeset makes sense. I left a few comments around nomenclature and UX, but overall looks great.
x/bank/keeper/send.go
Outdated
SetParams(ctx sdk.Context, params types.Params) | ||
|
||
GetSendEnabled(ctx sdk.Context, denom string) bool | ||
CoinsSendEnabled(ctx sdk.Context, coins ...sdk.Coin) error |
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.
CoinsSendEnabled(ctx sdk.Context, coins ...sdk.Coin) error | |
SendEnabledCoins(ctx sdk.Context, coins ...sdk.Coin) error |
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.
On second thought, I'm thinking this should rather take a variadic list of denominations (...string
) and be called SendEnabledDenoms
to complement SendEnabledDenom
.
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.
After reviewing the current usages of these methods, in all cases the arguments for denom
are passed in using coin.Denom
. In addition using the denom
string means that when a structure of coins
is present the denom
string must be extracted and passed into these functions (often adding yet another for-range loop). Based on this review and the existing methods which are all based on sdk.Coin
it would seem that for consistency we should be using the Coin
type and not a denom
string. Further a denom
string may not be a valid denom at all when it is handled outside of the Coin
class.
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.
You can assume all denoms are valid, and you can easily implement a method Coins#Denominations
that returns a unique list, so then it becomes SendEnabledDenoms(coins.Denoms())
.
x/bank/keeper/send.go
Outdated
GetParams(ctx sdk.Context) types.Params | ||
SetParams(ctx sdk.Context, params types.Params) | ||
|
||
GetSendEnabled(ctx sdk.Context, denom string) bool |
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.
GetSendEnabled(ctx sdk.Context, denom string) bool | |
SendEnabledDenom(ctx sdk.Context, denom string) bool |
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.
Related to above, method name order was changed however current implementation unifies on Coin as the parameter type in order to match all the other bank send keeper methods and improve developer ergonomics.
denominations to their send_enabled status. Entries in this list take | ||
precedence over the `DefaultSendEnabled` setting. | ||
|
||
## DefaultSendEnabled |
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'm not really convinced this is necessary or provides a cleaner UX. What is the drawback to just using SendEnabled
? I can see people getting confused over this IMHO.
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.
Great work!! Changes make sense to me.
Though one thing to note, if the DefaultSendEnabled = false
, then all ibc transfers will not be sendable by default since they will have new denoms. Is this desirable behaviour?
I will provide some additional follow up tomorrow (along with the requested usability/naming changes) but I wanted to provide my reasoning for the separate default setting from the coin specific ones now while the team members in the EU will see it. The inclusion of a default send enabled parameter preserves the existing behaviors for any deployments that may depend on it. For my team’s specific use cases we will largely use the default enabled true setting and only set a small subset of coins to false (out of many). In addition the separation of the default send enabled flag from the coin specific versions allow the system to be configured in either the ‘allow list’ or ‘deny list’ style depending on the security style favored. This type of flexibility seems useful for blocking all unexpected coins for example (IBC?). |
This justification in regards to IBC makes sense to me. I'm fairly certain without DefaultSendEnabled all coins being minted from IBC would be blocked except with a gov proposal. ICS20 (and similar IBC applications) could also be updated to set params on creation of a new coin, but I think that would be undesirable. cc/ @cwgoes -- Code looks good 👍 thanks for making the SDK better! |
Note regarding IBC: the
@AdityaSripal you can enable the Alternatively, we could add a regex validation on #6591 params to enable token denoms that match the given regex |
…com:iramiller/cosmos-sdk into 6518-enable-disable-coin-transfers-by-denom
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.
Something with the nomenclature and usage of params just doesn't sit right with me for some reason (e.g. default
shouldn't really be used in a param name). But I can't come up with anything cleaner or better, so I'll give an ACK here.
CHANGELOG.md
Outdated
@@ -127,6 +127,7 @@ be used to retrieve the actual proposal `Content`. Also the `NewMsgSubmitProposa | |||
* (modules) [\#6311](https://github.com/cosmos/cosmos-sdk/issues/6311) Remove `alias.go` usage | |||
* (x/auth) [\#6443](https://github.com/cosmos/cosmos-sdk/issues/6443) Move `FeeTx` and `TxWithMemo` interfaces from `x/auth/ante` to `types`. | |||
* (modules) [\#6447](https://github.com/cosmos/cosmos-sdk/issues/6447) Rename `blacklistedAddrs` to `blockedAddrs`. | |||
* (x/bank) [\6518](https://github.com/cosmos/cosmos-sdk/pull/6518) Support for per-denomination send_enabled flags. Existing send_enabled flag has been moved into a Params structure and transformed into an array of: `{denom: string, enabled: bool}` |
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.
can you move this to State Machine Breaking
? 🙏
GetSendEnabled(ctx sdk.Context) bool | ||
SetSendEnabled(ctx sdk.Context, enabled bool) | ||
GetParams(ctx sdk.Context) types.Params | ||
SetParams(ctx sdk.Context, params types.Params) |
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.
Why did we add SetParams
to SendKeeper
? This breaks ocaps even more. Just noting that this should be placed elsewhere at some point in the future.
* initial implementation of per denom sendenabled * Fix for accidentally removed keyword * Validate individual param in param array * Lint fix * Refactor bank params to use protobuf Modified SendEnabled property to be part of generic Params object Updated genesis functions to use default params structure * Refactor simulation genesis for clarity * update changelog for bank sendenable per denom * fix NoOpMsg type in multisend test * Add a coin denom send check utility function * Additional godoc comments and clarification * Add default send enabled parameter to bank. Remove empty denom capability from SendEnabled parameters Update simulation to exercise both configuration options independently * Minor suggested improvements. * simulation fix * bank proto sendenabled package name removed * Remove extra gogo proto yaml tags * Params rename IsSendEnabled to SendEnabledDenom * Refactor to SendEnabledCoin(s) * update slashing test to use bank params * Clean up change log entry for feature. Co-authored-by: Federico Kunze <[email protected]> Co-authored-by: Alessio Treglia <[email protected]> Co-authored-by: Alexander Bezobchuk <[email protected]>
Description
This PR extends the module properties of the Bank module to support setting a SendEnabled flag on specific coin denominations. The implementation was designed such that a default SendEnabled flag can be created for all denominations. This behavior was used to maintain the existing behavior of SendEnabled being set to True for all coin denominations.
Unit tests have been created around the extended parameter definitions to full cover all added behaviors for single sendenabled properties as well as the array of send enabled properties. The simulation test have been modified to match the updated API while maintaining the original behavior of setting the SendEnabled flag to false roughly 5% of the time.
closes: #6518
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 explorer