-
Notifications
You must be signed in to change notification settings - Fork 349
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
feat(hard_fork): part2 (Delyayed ack callback) #1355
Changes from 7 commits
bc97ab9
15265c9
98fdc67
711ed12
a876310
fe155de
92a67e0
5da8f8d
5a5df7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,14 +9,11 @@ | |
commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" | ||
) | ||
|
||
func (k Keeper) HandleFraud(ctx sdk.Context, rollappID string, ibc porttypes.IBCModule) error { | ||
// Get all the pending packets | ||
rollappPendingPackets := k.ListRollappPackets(ctx, types.ByRollappIDByStatus(rollappID, commontypes.Status_PENDING)) | ||
if len(rollappPendingPackets) == 0 { | ||
return nil | ||
} | ||
func (k Keeper) HandleHardFork(ctx sdk.Context, rollappID string, height uint64, ibc porttypes.IBCModule) error { | ||
logger := ctx.Logger().With("module", "DelayedAckMiddleware") | ||
logger.Info("reverting IBC rollapp packets", "rollappID", rollappID) | ||
|
||
// Get all the pending packets | ||
rollappPendingPackets := k.ListRollappPackets(ctx, types.PendingByRollappIDFromHeight(rollappID, height)) | ||
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. probably wont fix for now but I think possible DOS if a lot of packets and fraud is e.g few days ago. 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. pls open research topic |
||
|
||
// Iterate over all the pending packets and revert them | ||
for _, rollappPacket := range rollappPendingPackets { | ||
|
@@ -28,22 +25,25 @@ | |
"sequence", rollappPacket.Packet.Sequence, | ||
} | ||
|
||
// refund all pending outgoing packets | ||
if rollappPacket.Type == commontypes.RollappPacket_ON_ACK || rollappPacket.Type == commontypes.RollappPacket_ON_TIMEOUT { | ||
// refund all pending outgoing packets | ||
// we don't have access directly to `refundPacketToken` function, so we'll use the `OnTimeoutPacket` function | ||
err := ibc.OnTimeoutPacket(ctx, *rollappPacket.Packet, rollappPacket.Relayer) | ||
if err != nil { | ||
logger.Error("failed to refund reverted packet", append(logContext, "error", err.Error())...) | ||
} | ||
Comment on lines
+29
to
35
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. should be changed to follow the ADR:
|
||
} | ||
// Update status to reverted | ||
_, err := k.UpdateRollappPacketWithStatus(ctx, rollappPacket, commontypes.Status_REVERTED) | ||
if err != nil { | ||
logger.Error("error reverting IBC rollapp packet", append(logContext, "error", err.Error())...) | ||
return err | ||
} else { | ||
// for incoming packets, we need to reset the packet receipt | ||
ibcPacket := rollappPacket.Packet | ||
k.channelKeeper.SetPacketReceipt(ctx, ibcPacket.GetDestPort(), ibcPacket.GetDestChannel(), ibcPacket.GetSequence()) | ||
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. I don't see how this is deleting the packet reciept? from the ADR // remove receipt
ibcPacket := rollappPacket.Packet
receiptKey := host.PacketReceiptKey(ibcPacket.GetDestPort(), ibcPacket.GetDestChannel(), ibcPacket.GetSequence())
channelKeeperStore.Delete(receiptKey) 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. u right! |
||
} | ||
|
||
// delete the packet | ||
k.DeleteRollappPacket(ctx, &rollappPacket) | ||
logger.Debug("reverted IBC rollapp packet", logContext...) | ||
} | ||
|
||
logger.Info("reverting IBC rollapp packets", "rollappID", rollappID, "numPackets", len(rollappPendingPackets)) | ||
|
||
return nil | ||
} |
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.