Skip to content
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

Merged

Conversation

mtsitrin
Copy link
Contributor

@mtsitrin mtsitrin commented Oct 28, 2024

  • remove Reverted status
  • handle rollapp packet deletion in case of HardFork
  • removed x/delayedack invariants as it's broken (since lazy finalization)

logger.Info("reverting IBC rollapp packets", "rollappID", rollappID)

// Get all the pending packets
rollappPendingPackets := k.ListRollappPackets(ctx, types.PendingByRollappIDFromHeight(rollappID, height))
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls open research topic

logger := ctx.Logger().With("module", "DelayedAckMiddleware")
logger.Info("reverting IBC rollapp packets", "rollappID", rollappID)

// Get all the pending packets
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Get all the pending packets
// Get all the pending packets from fork height inclusive

} else {
// for incoming packets, we need to reset the packet receipt
ibcPacket := rollappPacket.Packet
k.channelKeeper.SetPacketReceipt(ctx, ibcPacket.GetDestPort(), ibcPacket.GetDestChannel(), ibcPacket.GetSequence())
Copy link
Contributor

Choose a reason for hiding this comment

The 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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u right!
will fix

}

// Get all pending rollapp packets until the latest finalized height
return k.ListRollappPackets(ctx, types.PendingByRollappIDByMaxHeight(rollappID, latestFinalizedHeight)), latestFinalizedHeight, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like we're filitering by max latest finalized height instead from finalized height forwad.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this code haven't changed. copied from x/delayedack/keeper/finalize.go
it's not used for fraud, it used by the query GetPendingPacketsByReceiver
I'll rename for clarity

@mtsitrin mtsitrin marked this pull request as ready for review October 31, 2024 08:51
@mtsitrin mtsitrin requested a review from a team as a code owner October 31, 2024 08:51
@mtsitrin mtsitrin merged commit b08a106 into mtsitrin/937-rollapp-hard-fork-hub-side Oct 31, 2024
3 of 5 checks passed
@mtsitrin mtsitrin deleted the delyayedAck_callback branch October 31, 2024 08:51
Comment on lines +29 to 35
// 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())...)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be changed to follow the ADR:

  1. timeout - only deleting the rollapp packet
  2. on_ack - to delete packet and re-create the commitment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants