-
Notifications
You must be signed in to change notification settings - Fork 592
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: mempool filter ibc spam #8409
Conversation
msgs := tx.GetMsgs() | ||
for _, msg := range msgs { | ||
// If one of the msgs is an IBC Transfer msg, limit it's size due to current spam potential. | ||
// 500KB for entire msg | ||
// 400KB for memo | ||
// 65KB for receiver | ||
if transferMsg, ok := msg.(*transfertypes.MsgTransfer); ok { | ||
if transferMsg.Size() > 500000 { // 500KB | ||
return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "msg size is too large") | ||
} | ||
|
||
if len([]byte(transferMsg.Memo)) > 400000 { // 400KB | ||
return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "memo is too large") | ||
} | ||
|
||
if len(transferMsg.Receiver) > 65000 { // 65KB | ||
return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "receiver address is too large") | ||
} | ||
} | ||
|
||
// If one of the msgs is from ICA, limit it's size due to current spam potential. | ||
// 500KB for packet data | ||
// 65KB for sender | ||
if icaMsg, ok := msg.(*icacontrollertypes.MsgSendTx); ok { | ||
if icaMsg.PacketData.Size() > 500000 { // 500KB | ||
return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "packet data is too large") | ||
} | ||
|
||
if len([]byte(icaMsg.Owner)) > 65000 { // 65KB | ||
return ctx, errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "owner address is too large") | ||
} | ||
} | ||
} |
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.
Consider copying some of the violating message JSONs from mintscan and adding them as unit tests
There is an example with arbitrage filters to help with boilerplate setup for this
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.
Tests added here 179d7e7
Closes: #XXX
What is the purpose of the change
Limits IBC Transfer messages to the following:
Limit ICA Send message to the following:
I opted to hard code these since adding them to the config would be deprecated in the next release. LMK if you think I should add them as config params.