Summary of Bug
The bank module stores the Send Disabled status for coins in a configuration block. This approach does not scale to a large number of token denominations. As additional coins are added to this parameter configuration the gas read/write costs for maintaining the list becomes excessive.
Version
latest/main
Steps to Reproduce
The current implementation of the Send method checks parameter configuration on every call to determine if a coin is allowed to be sent.
|
// IsSendEnabledCoin returns the current SendEnabled status of the provided coin's denom |
|
func (k BaseSendKeeper) IsSendEnabledCoin(ctx sdk.Context, coin sdk.Coin) bool { |
|
return k.GetParams(ctx).SendEnabledDenom(coin.Denom) |
|
} |
|
func (p Params) SendEnabledDenom(denom string) bool { |
|
for _, pse := range p.SendEnabled { |
|
if pse.Denom == denom { |
|
return pse.Enabled |
|
} |
|
} |
|
return p.DefaultSendEnabled |
|
} |
This approach is extremely inefficient and does not scale to a large number of restricted coins. Within the Provenance Blockchain there are many coin denominations which are set to "send disabled" so that users can not transfer these coins directly and must use appropriate APIs to do so.
A more efficient approach would be to store the send disabled status directly in the KVStore using a key based on the denomination. This would remove a significant amount of processing from each send call as well as allow a much larger number of tokens to be restricted/send disabled without impacting transaction performance.
For Admin Use
Summary of Bug
The bank module stores the Send Disabled status for coins in a configuration block. This approach does not scale to a large number of token denominations. As additional coins are added to this parameter configuration the gas read/write costs for maintaining the list becomes excessive.
Version
latest/main
Steps to Reproduce
The current implementation of the Send method checks parameter configuration on every call to determine if a coin is allowed to be sent.
cosmos-sdk/x/bank/keeper/send.go
Lines 316 to 319 in 567a6be
cosmos-sdk/x/bank/types/params.go
Lines 62 to 69 in 567a6be
This approach is extremely inefficient and does not scale to a large number of restricted coins. Within the Provenance Blockchain there are many coin denominations which are set to "send disabled" so that users can not transfer these coins directly and must use appropriate APIs to do so.
A more efficient approach would be to store the send disabled status directly in the KVStore using a key based on the denomination. This would remove a significant amount of processing from each send call as well as allow a much larger number of tokens to be restricted/send disabled without impacting transaction performance.
For Admin Use