-
Notifications
You must be signed in to change notification settings - Fork 624
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
perf(ante): Make the redundancy ante-handler check not run recvpacket middleware #6248
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -526,6 +526,46 @@ func (k *Keeper) RecvPacket(goCtx context.Context, msg *channeltypes.MsgRecvPack | |||||
return &channeltypes.MsgRecvPacketResponse{Result: channeltypes.SUCCESS}, nil | ||||||
} | ||||||
|
||||||
// RecvPacketCheckNonRedundant checks that a MsgRecvPacket is: | ||||||
// 1) Valid | ||||||
// 2) Not a duplicate of a packet already received | ||||||
// It is only intended to be ran on CheckTx. | ||||||
func (k *Keeper) RecvPacketCheckNonRedundant(goCtx context.Context, msg *channeltypes.MsgRecvPacket) (bool, error) { | ||||||
ctx := sdk.UnwrapSDKContext(goCtx) | ||||||
|
||||||
// Lookup module by channel capability | ||||||
module, capability, err := k.ChannelKeeper.LookupModuleByChannel(ctx, msg.Packet.DestinationPort, msg.Packet.DestinationChannel) | ||||||
if err != nil { | ||||||
return false, errorsmod.Wrap(err, "could not retrieve module from port-id") | ||||||
} | ||||||
|
||||||
// Retrieve callbacks from router | ||||||
_, ok := k.PortKeeper.Route(module) | ||||||
if !ok { | ||||||
return false, errorsmod.Wrapf(porttypes.ErrInvalidRoute, "route not found to module: %s", module) | ||||||
} | ||||||
|
||||||
// Perform TAO verification | ||||||
// | ||||||
// If the packet was already received, perform a no-op | ||||||
// Use a cached context to prevent accidental state changes | ||||||
cacheCtx, writeFn := ctx.CacheContext() | ||||||
// TODO: Update RecvPacket to skip MT inclusion checks on Recheck. | ||||||
// Its slightly involved because right now every client is responsible for checking that the | ||||||
// height exists on the client, rather than the channel keeper. | ||||||
err = k.ChannelKeeper.RecvPacket(cacheCtx, capability, msg.Packet, msg.ProofCommitment, msg.ProofHeight) | ||||||
|
||||||
switch err { | ||||||
case nil: | ||||||
writeFn() | ||||||
case channeltypes.ErrNoOpMsg: | ||||||
return true, nil | ||||||
default: | ||||||
return false, errorsmod.Wrap(err, "receive packet verification failed") | ||||||
} | ||||||
return false, nil | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect return value in - return false, nil
+ return true, nil This function should return Committable suggestion
Suggested change
|
||||||
} | ||||||
|
||||||
// Timeout defines a rpc handler method for MsgTimeout. | ||||||
func (k *Keeper) Timeout(goCtx context.Context, msg *channeltypes.MsgTimeout) (*channeltypes.MsgTimeoutResponse, error) { | ||||||
ctx := sdk.UnwrapSDKContext(goCtx) | ||||||
|
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.
Tip
Codebase Verification
The verification process has confirmed the presence and implementation of the
RecvPacketCheckNonRedundant
function within themodules/core/keeper/msg_server.go
file. The function is designed to handle errors appropriately, as evidenced by the detailed error handling and conditional logic present in the function's implementation.However, the verification process did not find any test cases specifically targeting the
RecvPacketCheckNonRedundant
function. This absence of direct test coverage could pose risks, especially considering the function's role in handling packet redundancy checks, which are critical for the system's integrity and performance.Given this situation, it is recommended to implement dedicated test cases to ensure the robustness and correctness of the
RecvPacketCheckNonRedundant
function under various scenarios, including error conditions and edge cases.Action Points:
RecvPacketCheckNonRedundant
to cover various scenarios and error conditions.Analysis chain
Integration of
RecvPacketCheckNonRedundant
looks good, but ensure thorough testing of error scenarios.Scripts Executed
The following scripts were executed for the analysis:
Script:
Length of output: 2667