-
Notifications
You must be signed in to change notification settings - Fork 104
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
[TRA-671] Prevent connect messages in x/authz #2434
Conversation
WalkthroughThe changes introduce new functionality for handling "Connect" messages within the protocol's message validation logic. A constant Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
protocol/lib/ante/nested_msg.go (2)
89-91
: LGTM: Prevent Connect messages in MsgExec.The addition of the check for Connect messages within
MsgExec
is appropriate and consistent with the existing code. It successfully implements the PR objective of preventing connect messages in x/authz.For consistency, consider updating the error message to match the style of the dYdX message check:
- return fmt.Errorf("Invalid nested msg for MsgExec: Connect msg type") + return fmt.Errorf("Invalid nested msg for MsgExec: connect msg type")This change would make the error message fully lowercase, matching the "dydx msg type" error.
Line range hint
15-91
: Summary: Successfully implemented prevention of Connect messages in x/authzThe changes in this file effectively implement the PR objective of preventing Connect messages in x/authz. The additions include:
- A new constant
CONNECT_MSG_PREFIX
for identifying Connect messages.- A new function
IsConnectMsg
to check if a message is a Connect message.- An update to the
validateInnerMsg
function to prevent Connect messages withinMsgExec
.These changes are well-integrated with the existing code and follow consistent patterns. The implementation should successfully prevent Connect messages from being nested within
MsgExec
messages, enhancing the security and integrity of the system.Consider adding unit tests to verify the behavior of the
IsConnectMsg
function and the updatedvalidateInnerMsg
function, especially focusing on the new Connect message check.protocol/testutil/msgs/nested_msgs.go (1)
127-131
: LGTM: New message type added correctly.The new
MsgExecWithConnectMessage
is properly declared and follows the existing pattern in the file. It correctly incorporates the newmarketmap
package.Consider whether the empty
marketmap.MsgUpsertMarkets{}
needs to be populated with actual data for testing purposes. If not, you might want to add a comment explaining why it's left empty.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- protocol/lib/ante/nested_msg.go (3 hunks)
- protocol/lib/ante/nested_msg_test.go (3 hunks)
- protocol/testutil/msgs/nested_msgs.go (3 hunks)
🔇 Additional comments (11)
protocol/lib/ante/nested_msg.go (2)
15-15
: LGTM: New constant for Connect messages.The addition of
CONNECT_MSG_PREFIX
constant is appropriate and consistent with the existing code style.
36-39
: LGTM: New function to identify Connect messages.The
IsConnectMsg
function is well-implemented and consistent with the existing code style. It provides a clear way to identify Connect messages.protocol/testutil/msgs/nested_msgs.go (4)
13-13
: LGTM: New import statement added correctly.The new import for the
marketmap
package is properly formatted and consistent with the existing import style.
131-131
: LGTM: New byte slice variable declared correctly.The
MsgExecWithConnectMessageTxBytes
variable is properly declared, following the existing pattern in the file. It's correctly positioned alongside other similar declarations.
50-52
: LGTM: Initialization for new message type added correctly.The
init()
function has been properly updated to include the initialization and encoding of the newMsgExecWithConnectMessage
. This follows the existing pattern and ensures consistency with other message types.
Line range hint
1-145
: Summary: New message type formarketmap
package integrated successfully.The changes in this file successfully introduce a new message type
MsgExecWithConnectMessage
related to themarketmap
package. This addition is consistent with the existing code structure and patterns. While these changes lay the groundwork for handling connect messages, the exact mechanism for preventing them in x/authz is not evident from this file alone. Ensure that the implementation in other parts of the codebase aligns with the PR objective.To ensure the changes are properly integrated, please run the following command to check for any references to the new message type:
✅ Verification successful
Summary: New message type for
marketmap
package integrated successfully.The changes in this file successfully introduce the new message type
MsgExecWithConnectMessage
related to themarketmap
package. These additions are consistent with the existing code structure and patterns. Furthermore, references toMsgExecWithConnectMessage
are localized within this file and the corresponding test file, ensuring proper integration and testing coverage. The implementation aligns with the PR objective of preventing connect messages in x/authz.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for references to MsgExecWithConnectMessage rg "MsgExecWithConnectMessage" --type goLength of output: 524
protocol/lib/ante/nested_msg_test.go (5)
25-25
: LGTM: New error variable for Connect messages.The addition of
invalidInnerMsgErr_Connect
is consistent with the existing error variables and correctly describes the scenario for an invalid nested message of Connect type.
110-125
: LGTM: New test function for invalid Connect messages.The
TestIsConnectMsg_Invalid
function is well-structured and follows the established pattern for similar tests in this file. It correctly tests that non-Connect messages are not identified as Connect messages.
127-138
: LGTM: New test function for valid Connect messages.The
TestIsConnectMsg_Valid
function is well-implemented and consistent with other test functions in this file. It correctly verifies that all Connect messages are properly identified.
177-180
: LGTM: New test case for Connect messages in MsgExec.The addition of the "Invalid MsgExec: Connect custom msg" test case is consistent with other test cases and correctly uses the new
invalidInnerMsgErr_Connect
error. This ensures proper handling of Connect messages in MsgExec contexts.
25-25
: Summary: Comprehensive test coverage added for Connect messages.The changes in this file successfully introduce test coverage for Connect messages in the nested message validation system. The additions include:
- A new error variable for Connect messages.
- Test functions for both valid and invalid Connect messages.
- A test case for Connect messages in the MsgExec context.
These changes are consistent with the existing code structure and improve the overall test coverage of the ante package.
Also applies to: 110-138, 177-180
Changelist
[Describe or list the changes made in this PR]
Test Plan
[Describe how this PR was tested (if applicable)]
Author/Reviewer Checklist
state-breaking
label.indexer-postgres-breaking
label.PrepareProposal
orProcessProposal
, manually add the labelproposal-breaking
.feature:[feature-name]
.backport/[branch-name]
.refactor
,chore
,bug
.Summary by CodeRabbit
New Features
MsgExecWithConnectMessage
, to handle specific transaction scenarios.Bug Fixes
Tests