From d577982f5d915d6184449603ec7b0e1f2f34aad5 Mon Sep 17 00:00:00 2001 From: keruch <53012408+keruch@users.noreply.github.com> Date: Mon, 4 Nov 2024 20:15:31 +0300 Subject: [PATCH] feat(delayedack): added efficient query for pending packets by addr (#1385) --- app/apptesting/delayedack.go | 53 ++ app/apptesting/test_suite.go | 9 +- app/upgrades/v4/upgrade.go | 24 +- app/upgrades/v4/upgrade_test.go | 24 + ibctesting/bridging_fee_test.go | 2 +- ibctesting/delayed_ack_test.go | 4 +- ibctesting/eibc_test.go | 6 +- ibctesting/utils_test.go | 11 +- .../dymension/delayedack/events.proto | 25 - .../dymension/delayedack/query.proto | 13 +- x/common/types/rollapp_packet.go | 8 + x/delayedack/client/cli/query.go | 15 +- x/delayedack/genesis.go | 11 + x/delayedack/ibc_middleware.go | 9 + x/delayedack/keeper/finalize.go | 24 - x/delayedack/keeper/finalize_test.go | 8 +- x/delayedack/keeper/fraud_test.go | 32 +- x/delayedack/keeper/grpc_query.go | 25 +- x/delayedack/keeper/hooks_test.go | 3 +- x/delayedack/keeper/invariants_test.go | 57 +- x/delayedack/keeper/keeper.go | 21 +- x/delayedack/keeper/keeper_test.go | 5 +- x/delayedack/keeper/rollapp_packet.go | 105 ++- x/delayedack/keeper/rollapp_packet_test.go | 148 +++- x/delayedack/types/events.pb.go | 692 +----------------- x/delayedack/types/keys.go | 4 +- x/delayedack/types/query.pb.go | 281 +++---- x/delayedack/types/query.pb.gw.go | 72 +- 28 files changed, 595 insertions(+), 1096 deletions(-) create mode 100644 app/apptesting/delayedack.go diff --git a/app/apptesting/delayedack.go b/app/apptesting/delayedack.go new file mode 100644 index 000000000..943728a23 --- /dev/null +++ b/app/apptesting/delayedack.go @@ -0,0 +1,53 @@ +package apptesting + +import ( + "testing" + + transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + "github.com/stretchr/testify/require" + + commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" +) + +const ( + TestPacketReceiver = "testReceiver" + TestPacketSender = "testSender" +) + +func GenerateTestPacketData(t *testing.T) []byte { + t.Helper() + data := &transfertypes.FungibleTokenPacketData{ + Receiver: TestPacketReceiver, + Sender: TestPacketSender, + } + pd, err := transfertypes.ModuleCdc.MarshalJSON(data) + require.NoError(t, err) + return pd +} + +func GenerateTestPacket(t *testing.T, sequence uint64) *channeltypes.Packet { + t.Helper() + return &channeltypes.Packet{ + SourcePort: "testSourcePort", + SourceChannel: "testSourceChannel", + DestinationPort: "testDestinationPort", + DestinationChannel: "testDestinationChannel", + Data: GenerateTestPacketData(t), + Sequence: sequence, + } +} + +func GenerateRollappPackets(t *testing.T, rollappId string, num uint64) []commontypes.RollappPacket { + t.Helper() + var packets []commontypes.RollappPacket + for i := uint64(0); i < num; i++ { + packets = append(packets, commontypes.RollappPacket{ + RollappId: rollappId, + Packet: GenerateTestPacket(t, i), + Status: commontypes.Status_PENDING, + ProofHeight: i, + }) + } + return packets +} diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index 9e407bf13..f541cb0ee 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -183,13 +183,12 @@ func FundForAliasRegistration( ) } -func (s *KeeperTestHelper) FinalizeAllPendingPackets(rollappID, receiver string) int { +func (s *KeeperTestHelper) FinalizeAllPendingPackets(address string) int { s.T().Helper() - // Query all pending packets by receiver + // Query all pending packets by address querier := delayedackkeeper.NewQuerier(s.App.DelayedAckKeeper) - resp, err := querier.GetPendingPacketsByReceiver(s.Ctx, &delayedacktypes.QueryPendingPacketsByReceiverRequest{ - RollappId: rollappID, - Receiver: receiver, + resp, err := querier.GetPendingPacketsByAddress(s.Ctx, &delayedacktypes.QueryPendingPacketsByAddressRequest{ + Address: address, }) s.Require().NoError(err) // Finalize all packets and return the num of finalized diff --git a/app/upgrades/v4/upgrade.go b/app/upgrades/v4/upgrade.go index f2adaa0cf..ee94afefd 100644 --- a/app/upgrades/v4/upgrade.go +++ b/app/upgrades/v4/upgrade.go @@ -19,13 +19,13 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" ibcchannelkeeper "github.com/cosmos/ibc-go/v7/modules/core/04-channel/keeper" - evmtypes "github.com/evmos/ethermint/x/evm/types" feemarkettypes "github.com/evmos/ethermint/x/feemarket/types" epochskeeper "github.com/osmosis-labs/osmosis/v15/x/epochs/keeper" "github.com/dymensionxyz/dymension/v3/app/keepers" "github.com/dymensionxyz/dymension/v3/app/upgrades" + commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" delayedackkeeper "github.com/dymensionxyz/dymension/v3/x/delayedack/keeper" delayedacktypes "github.com/dymensionxyz/dymension/v3/x/delayedack/types" incentiveskeeper "github.com/dymensionxyz/dymension/v3/x/incentives/keeper" @@ -69,6 +69,10 @@ func CreateUpgradeHandler( return nil, err } + if err := migrateDelayedAckPacketIndex(ctx, keepers.DelayedAckKeeper); err != nil { + return nil, err + } + // Start running the module migrations logger.Debug("running module migrations ...") return mm.RunMigrations(ctx, configurator, fromVM) @@ -215,6 +219,24 @@ func migrateIncentivesParams(ctx sdk.Context, ik *incentiveskeeper.Keeper) { ik.SetParams(ctx, params) } +func migrateDelayedAckPacketIndex(ctx sdk.Context, dk delayedackkeeper.Keeper) error { + pendingPackets := dk.ListRollappPackets(ctx, delayedacktypes.ByStatus(commontypes.Status_PENDING)) + for _, packet := range pendingPackets { + pd, err := packet.GetTransferPacketData() + if err != nil { + return err + } + + switch packet.Type { + case commontypes.RollappPacket_ON_RECV: + dk.MustSetPendingPacketByAddress(ctx, pd.Receiver, packet.RollappPacketKey()) + case commontypes.RollappPacket_ON_ACK, commontypes.RollappPacket_ON_TIMEOUT: + dk.MustSetPendingPacketByAddress(ctx, pd.Sender, packet.RollappPacketKey()) + } + } + return nil +} + func ConvertOldRollappToNew(oldRollapp rollapptypes.Rollapp) rollapptypes.Rollapp { return rollapptypes.Rollapp{ RollappId: oldRollapp.RollappId, diff --git a/app/upgrades/v4/upgrade_test.go b/app/upgrades/v4/upgrade_test.go index f04b6cd85..aa5dca060 100644 --- a/app/upgrades/v4/upgrade_test.go +++ b/app/upgrades/v4/upgrade_test.go @@ -19,6 +19,8 @@ import ( "github.com/dymensionxyz/dymension/v3/app/apptesting" v4 "github.com/dymensionxyz/dymension/v3/app/upgrades/v4" "github.com/dymensionxyz/dymension/v3/testutil/sample" + commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" + delayedacktypes "github.com/dymensionxyz/dymension/v3/x/delayedack/types" rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" sequencertypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types" streamertypes "github.com/dymensionxyz/dymension/v3/x/streamer/types" @@ -74,6 +76,8 @@ func (s *UpgradeTestSuite) TestUpgrade() { // Create and store sequencers s.seedAndStoreSequencers(numRollapps) + s.seedPendingRollappPackets() + return nil }, upgrade: func() { @@ -126,6 +130,11 @@ func (s *UpgradeTestSuite) TestUpgrade() { return } + // Check rollapp packets + if err = s.validateDelayedAckIndexMigration(); err != nil { + return + } + s.validateStreamerMigration() return @@ -282,6 +291,14 @@ func (s *UpgradeTestSuite) validateStreamerMigration() { s.Require().Equal(expected, pointers) } +func (s *UpgradeTestSuite) validateDelayedAckIndexMigration() error { + packets := s.App.DelayedAckKeeper.ListRollappPackets(s.Ctx, delayedacktypes.ByStatus(commontypes.Status_PENDING)) + actual, err := s.App.DelayedAckKeeper.GetPendingPacketsByAddress(s.Ctx, apptesting.TestPacketReceiver) + s.Require().NoError(err) + s.Require().Equal(len(packets), len(actual)) + return nil +} + func (s *UpgradeTestSuite) seedAndStoreRollapps(numRollapps int) { for _, rollapp := range s.seedRollapps(numRollapps) { s.App.RollappKeeper.SetRollapp(s.Ctx, rollapp) @@ -340,3 +357,10 @@ func (s *UpgradeTestSuite) seedSequencers(numRollapps int) []sequencertypes.Sequ func rollappIDFromIdx(idx int) string { return fmt.Sprintf("roll%spp_123%d-1", string(rune(idx+'a')), idx+1) } + +func (s *UpgradeTestSuite) seedPendingRollappPackets() { + packets := apptesting.GenerateRollappPackets(s.T(), "testrollappid_1-1", 20) + for _, packet := range packets { + s.App.DelayedAckKeeper.SetRollappPacket(s.Ctx, packet) + } +} diff --git a/ibctesting/bridging_fee_test.go b/ibctesting/bridging_fee_test.go index dcc031414..65cf64692 100644 --- a/ibctesting/bridging_fee_test.go +++ b/ibctesting/bridging_fee_test.go @@ -97,7 +97,7 @@ func (s *bridgingFeeSuite) TestBridgingFee() { s.Require().NoError(err) // manually finalize packets through x/delayedack - s.finalizeRollappPacketsByReceiver(s.hubChain().SenderAccount.GetAddress().String()) + s.finalizeRollappPacketsByAddress(s.hubChain().SenderAccount.GetAddress().String()) // check balance after finalization expectedFee := s.hubApp().DelayedAckKeeper.BridgingFeeFromAmt(s.hubCtx(), transferredCoins.Amount) diff --git a/ibctesting/delayed_ack_test.go b/ibctesting/delayed_ack_test.go index 1eb90a508..90116a539 100644 --- a/ibctesting/delayed_ack_test.go +++ b/ibctesting/delayed_ack_test.go @@ -174,7 +174,7 @@ func (s *delayedAckSuite) TestTransferRollappToHubFinalization() { s.Require().NoError(err) // manually finalize packets through x/delayedack - s.finalizeRollappPacketsByReceiver(s.hubChain().SenderAccount.GetAddress().String()) + s.finalizeRollappPacketsByAddress(s.hubChain().SenderAccount.GetAddress().String()) // Validate ack is found found = hubIBCKeeper.ChannelKeeper.HasPacketAcknowledgement(s.hubCtx(), packet.GetDestPort(), packet.GetDestChannel(), packet.GetSequence()) @@ -230,7 +230,7 @@ func (s *delayedAckSuite) TestHubToRollappTimeout() { _, err = s.finalizeRollappState(1, currentRollappBlockHeight) s.Require().NoError(err) // manually finalize packets through x/delayedack - s.finalizeRollappPacketsByReceiver(receiverAccount.String()) + s.finalizeRollappPacketsByAddress(senderAccount.String()) // Validate funds are returned to the sender postFinalizeBalance := bankKeeper.GetBalance(s.hubCtx(), senderAccount, sdk.DefaultBondDenom) s.Require().Equal(preSendBalance.Amount, postFinalizeBalance.Amount) diff --git a/ibctesting/eibc_test.go b/ibctesting/eibc_test.go index aca048633..cd02d7caf 100644 --- a/ibctesting/eibc_test.go +++ b/ibctesting/eibc_test.go @@ -262,7 +262,7 @@ func (s *eibcSuite) TestEIBCDemandOrderFulfillment() { s.Require().NoError(err) // manually finalize packets through x/delayedack - s.finalizeRollappPacketsByReceiver(fulfiller.String()) + s.finalizeRollappPacketsByAddress(fulfiller.String()) // Check the fulfiller balance was updated fully with the IBC amount isUpdated := false @@ -346,7 +346,7 @@ func (s *eibcSuite) TestEIBCDemandOrderFulfillment() { s.Require().NoError(err) // manually finalize packets through x/delayedack - evts := s.finalizeRollappPacketsByReceiver(fulfiller.String()) + evts := s.finalizeRollappPacketsByAddress(fulfiller.String()) ack, err := ibctesting.ParseAckFromEvents(evts) s.Require().NoError(err) @@ -509,7 +509,7 @@ func (s *eibcSuite) TestTimeoutEIBCDemandOrderFulfillment() { _, err = s.finalizeRollappState(1, currentRollappBlockHeight) s.Require().NoError(err) // manually finalize packets through x/delayedack - s.finalizeRollappPacketsByReceiver(receiverAccount.String()) + s.finalizeRollappPacketsByAddress(fulfillerAccount.String()) // Funds are passed to the fulfiller fulfillerAccountBalanceAfterTimeout := bankKeeper.GetBalance(s.hubCtx(), fulfillerAccount, sdk.DefaultBondDenom) s.Require().True(fulfillerAccountBalanceAfterTimeout.IsEqual(fulfillerInitialBalance.Add(lastDemandOrder.Fee[0]))) diff --git a/ibctesting/utils_test.go b/ibctesting/utils_test.go index 484db77bb..b5efb0694 100644 --- a/ibctesting/utils_test.go +++ b/ibctesting/utils_test.go @@ -373,16 +373,15 @@ func (s *utilSuite) newTestChainWithSingleValidator(t *testing.T, coord *ibctest return chain } -func (s *utilSuite) finalizeRollappPacketsByReceiver(receiver string) sdk.Events { +func (s *utilSuite) finalizeRollappPacketsByAddress(address string) sdk.Events { s.T().Helper() - // Query all pending packets by receiver + // Query all pending packets by address querier := delayedackkeeper.NewQuerier(s.hubApp().DelayedAckKeeper) - resp, err := querier.GetPendingPacketsByReceiver(s.hubCtx(), &delayedacktypes.QueryPendingPacketsByReceiverRequest{ - RollappId: rollappChainID(), - Receiver: receiver, + resp, err := querier.GetPendingPacketsByAddress(s.hubCtx(), &delayedacktypes.QueryPendingPacketsByAddressRequest{ + Address: address, }) s.Require().NoError(err) - // Finalize all packets are collect events + // Finalize all packets and collect events events := make(sdk.Events, 0) for _, packet := range resp.RollappPackets { k := common.EncodePacketKey(packet.RollappPacketKey()) diff --git a/proto/dymensionxyz/dymension/delayedack/events.proto b/proto/dymensionxyz/dymension/delayedack/events.proto index b6748b1fd..7969f70df 100644 --- a/proto/dymensionxyz/dymension/delayedack/events.proto +++ b/proto/dymensionxyz/dymension/delayedack/events.proto @@ -19,28 +19,3 @@ message EventFinalizePacket { // PacketSequence is a sequence number of the packet. uint64 packet_sequence = 6; } - -message EventFinalizePacketsUntilHeight { - // Sender is the signer of the message. - string sender = 1; - // RollappID is the ID of the rollapp. - string rollapp_id = 2; - // Height is a height until which packets are to be finalized. Height is inclusive. - uint64 height = 3; - // FinalizedNum is the number of finalized packets. - uint64 finalized_num = 4; -} - -message EventFinalizeRollappPacketsByReceiver { - // Sender is the signer of the message. - string sender = 1; - // RollappID is the ID of the rollapp. - string rollapp_id = 2; - // Receiver is the one who waits tokens after the finalization. - string receiver = 3; - // Height is a height until which packets are to be finalized. - uint64 height = 4; - // FinalizedNum is the number of finalized packets. - uint64 finalized_num = 5; - -} diff --git a/proto/dymensionxyz/dymension/delayedack/query.proto b/proto/dymensionxyz/dymension/delayedack/query.proto index 32b33fc6a..d4bf62945 100644 --- a/proto/dymensionxyz/dymension/delayedack/query.proto +++ b/proto/dymensionxyz/dymension/delayedack/query.proto @@ -23,8 +23,8 @@ service Query { } // Queries a list of pending RollappPacket items by rollappID and receiver. - rpc GetPendingPacketsByReceiver(QueryPendingPacketsByReceiverRequest) returns (QueryPendingPacketByReceiverListResponse) { - option (google.api.http).get = "/dymensionxyz/dymension/delayedack/pending-receiver-packets/{rollappId}/{receiver}"; + rpc GetPendingPacketsByAddress(QueryPendingPacketsByAddressRequest) returns (QueryPendingPacketByAddressListResponse) { + option (google.api.http).get = "/dymensionxyz/dymension/delayedack/pending-receiver-packets/{address}"; } } @@ -49,13 +49,12 @@ message QueryRollappPacketListResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } -message QueryPendingPacketsByReceiverRequest { - string rollappId = 1; - string receiver = 2; - cosmos.base.query.v1beta1.PageRequest pagination = 3; +message QueryPendingPacketsByAddressRequest { + string address = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; } -message QueryPendingPacketByReceiverListResponse { +message QueryPendingPacketByAddressListResponse { repeated common.RollappPacket rollappPackets = 1 [(gogoproto.nullable) = false]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } \ No newline at end of file diff --git a/x/common/types/rollapp_packet.go b/x/common/types/rollapp_packet.go index dbdfa94ba..832ccbe2e 100644 --- a/x/common/types/rollapp_packet.go +++ b/x/common/types/rollapp_packet.go @@ -91,6 +91,14 @@ func (r RollappPacket) GetTransferPacketData() (transfertypes.FungibleTokenPacke return data, nil } +func (r RollappPacket) MustGetTransferPacketData() transfertypes.FungibleTokenPacketData { + data, err := r.GetTransferPacketData() + if err != nil { + panic(err) + } + return data +} + func (r RollappPacket) GetAck() (channeltypes.Acknowledgement, error) { var ack channeltypes.Acknowledgement if err := transfertypes.ModuleCdc.UnmarshalJSON(r.Acknowledgement, &ack); err != nil { diff --git a/x/delayedack/client/cli/query.go b/x/delayedack/client/cli/query.go index aac99e140..1451de912 100644 --- a/x/delayedack/client/cli/query.go +++ b/x/delayedack/client/cli/query.go @@ -27,7 +27,7 @@ func GetQueryCmd() *cobra.Command { cmd.AddCommand(CmdGetPacketsByRollapp()) cmd.AddCommand(CmdGetPacketsByStatus()) cmd.AddCommand(CmdGetPacketsByType()) - cmd.AddCommand(CmdGetPendingPacketsByReceiver()) + cmd.AddCommand(CmdGetPendingPacketsByAddress()) return cmd } @@ -219,11 +219,11 @@ func CmdGetPacketsByType() *cobra.Command { return cmd } -func CmdGetPendingPacketsByReceiver() *cobra.Command { +func CmdGetPendingPacketsByAddress() *cobra.Command { cmd := &cobra.Command{ - Use: "pending-packets-by-receiver [rollapp-id] [receiver]", - Short: "Get pending packets by receiver", - Args: cobra.MinimumNArgs(2), + Use: "pending-packets-by-address [address]", + Short: "Get pending packets by address", + Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { @@ -231,9 +231,8 @@ func CmdGetPendingPacketsByReceiver() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) - res, err := queryClient.GetPendingPacketsByReceiver(cmd.Context(), &types.QueryPendingPacketsByReceiverRequest{ - RollappId: args[0], - Receiver: args[1], + res, err := queryClient.GetPendingPacketsByAddress(cmd.Context(), &types.QueryPendingPacketsByAddressRequest{ + Address: args[0], Pagination: nil, // TODO: handle pagination }) if err != nil { diff --git a/x/delayedack/genesis.go b/x/delayedack/genesis.go index a10edd4e3..d451b59df 100644 --- a/x/delayedack/genesis.go +++ b/x/delayedack/genesis.go @@ -2,6 +2,8 @@ package delayedack import ( sdk "github.com/cosmos/cosmos-sdk/types" + + commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" "github.com/dymensionxyz/dymension/v3/x/delayedack/keeper" "github.com/dymensionxyz/dymension/v3/x/delayedack/types" ) @@ -10,6 +12,15 @@ import ( func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { k.SetParams(ctx, genState.Params) for _, packet := range genState.RollappPackets { + transferPacketData := packet.MustGetTransferPacketData() + switch packet.Type { + case commontypes.RollappPacket_ON_RECV: + k.MustSetPendingPacketByAddress(ctx, transferPacketData.Receiver, packet.RollappPacketKey()) + case commontypes.RollappPacket_ON_ACK, commontypes.RollappPacket_ON_TIMEOUT: + k.MustSetPendingPacketByAddress(ctx, transferPacketData.Sender, packet.RollappPacketKey()) + case commontypes.RollappPacket_UNDEFINED: + panic("invalid rollapp packet type") + } k.SetRollappPacket(ctx, packet) } } diff --git a/x/delayedack/ibc_middleware.go b/x/delayedack/ibc_middleware.go index e16041004..58b8034c9 100644 --- a/x/delayedack/ibc_middleware.go +++ b/x/delayedack/ibc_middleware.go @@ -200,6 +200,15 @@ func (w IBCMiddleware) savePacket(ctx sdk.Context, packet channeltypes.Packet, t Type: packetType, } + // Add the packet to the pending packet index + switch packetType { + case commontypes.RollappPacket_ON_RECV: + w.MustSetPendingPacketByAddress(ctx, transfer.FungibleTokenPacketData.Receiver, p.RollappPacketKey()) + case commontypes.RollappPacket_ON_ACK, commontypes.RollappPacket_ON_TIMEOUT: + w.MustSetPendingPacketByAddress(ctx, transfer.FungibleTokenPacketData.Sender, p.RollappPacketKey()) + } + + // Save the rollapp packet w.Keeper.SetRollappPacket(ctx, p) return p diff --git a/x/delayedack/keeper/finalize.go b/x/delayedack/keeper/finalize.go index 3026f28d3..42629c4f2 100644 --- a/x/delayedack/keeper/finalize.go +++ b/x/delayedack/keeper/finalize.go @@ -11,7 +11,6 @@ import ( "github.com/osmosis-labs/osmosis/v15/osmoutils" commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" - "github.com/dymensionxyz/dymension/v3/x/delayedack/types" ) // FinalizeRollappPacket finalizes a singe packet by its rollapp packet key. @@ -152,26 +151,3 @@ func (k Keeper) VerifyHeightFinalized(ctx sdk.Context, rollappID string, height } return nil } - -func (k Keeper) GetRollappLatestFinalizedHeight(ctx sdk.Context, rollappID string) (uint64, error) { - latestIndex, found := k.rollappKeeper.GetLatestFinalizedStateIndex(ctx, rollappID) - if !found { - return 0, gerrc.ErrNotFound.Wrapf("latest finalized state index is not found") - } - stateInfo, found := k.rollappKeeper.GetStateInfo(ctx, rollappID, latestIndex.Index) - if !found { - return 0, gerrc.ErrNotFound.Wrapf("state info is not found") - } - return stateInfo.GetLatestHeight(), nil -} - -func (k Keeper) GetPendingPacketsUntilLatestHeight(ctx sdk.Context, rollappID string) ([]commontypes.RollappPacket, uint64, error) { - // Get rollapp's latest finalized height - latestFinalizedHeight, err := k.GetRollappLatestFinalizedHeight(ctx, rollappID) - if err != nil { - return nil, 0, fmt.Errorf("get latest finalized height: rollapp '%s': %w", rollappID, err) - } - - // Get all pending rollapp packets until the latest finalized height - return k.ListRollappPackets(ctx, types.PendingByRollappIDByMaxHeight(rollappID, latestFinalizedHeight)), latestFinalizedHeight, nil -} diff --git a/x/delayedack/keeper/finalize_test.go b/x/delayedack/keeper/finalize_test.go index 9fa890597..a2f134fbd 100644 --- a/x/delayedack/keeper/finalize_test.go +++ b/x/delayedack/keeper/finalize_test.go @@ -23,7 +23,7 @@ func (s *DelayedAckTestSuite) TestFinalizePacket() { RollappId: rollapp, Status: commontypes.Status_PENDING, ProofHeight: 8, - Packet: s.getNewTestPacket(2), + Packet: apptesting.GenerateTestPacket(s.T(), 2), }, rollappHeight: 10, expectErr: false, @@ -35,7 +35,7 @@ func (s *DelayedAckTestSuite) TestFinalizePacket() { RollappId: rollapp, Status: commontypes.Status_FINALIZED, ProofHeight: 8, - Packet: s.getNewTestPacket(2), + Packet: apptesting.GenerateTestPacket(s.T(), 2), }, rollappHeight: 10, expectErr: true, @@ -47,7 +47,7 @@ func (s *DelayedAckTestSuite) TestFinalizePacket() { RollappId: rollapp, Status: commontypes.Status_PENDING, ProofHeight: 15, - Packet: s.getNewTestPacket(2), + Packet: apptesting.GenerateTestPacket(s.T(), 2), }, rollappHeight: 10, expectErr: true, @@ -135,7 +135,7 @@ func (s *DelayedAckTestSuite) TestFinalizePacketByPacketKey() { RollappId: rollapp, Status: commontypes.Status_PENDING, ProofHeight: 8, - Packet: s.getNewTestPacket(2), + Packet: apptesting.GenerateTestPacket(s.T(), 2), }, rollappHeight: 10, expectedPacketStatus: commontypes.Status_FINALIZED, diff --git a/x/delayedack/keeper/fraud_test.go b/x/delayedack/keeper/fraud_test.go index ae3555a28..dd844c0f4 100644 --- a/x/delayedack/keeper/fraud_test.go +++ b/x/delayedack/keeper/fraud_test.go @@ -2,8 +2,8 @@ package keeper_test import ( ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + "github.com/dymensionxyz/dymension/v3/app/apptesting" commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" damodule "github.com/dymensionxyz/dymension/v3/x/delayedack" "github.com/dymensionxyz/dymension/v3/x/delayedack/types" @@ -18,9 +18,9 @@ func (suite *DelayedAckTestSuite) TestHandleFraud() { ) rollappId := "testRollappId" - pkts := generatePackets(rollappId, 5) + pkts := apptesting.GenerateRollappPackets(suite.T(), rollappId, 5) rollappId2 := "testRollappId2" - pkts2 := generatePackets(rollappId2, 5) + pkts2 := apptesting.GenerateRollappPackets(suite.T(), rollappId2, 5) prefixPending1 := types.ByRollappIDByStatus(rollappId, commontypes.Status_PENDING) prefixPending2 := types.ByRollappIDByStatus(rollappId2, commontypes.Status_PENDING) prefixReverted := types.ByRollappIDByStatus(rollappId, commontypes.Status_REVERTED) @@ -59,9 +59,9 @@ func (suite *DelayedAckTestSuite) TestDeletionOfRevertedPackets() { ) rollappId := "testRollappId" - pkts := generatePackets(rollappId, 5) + pkts := apptesting.GenerateRollappPackets(suite.T(), rollappId, 5) rollappId2 := "testRollappId2" - pkts2 := generatePackets(rollappId2, 5) + pkts2 := apptesting.GenerateRollappPackets(suite.T(), rollappId2, 5) for _, pkt := range append(pkts, pkts2...) { keeper.SetRollappPacket(ctx, pkt) @@ -81,25 +81,3 @@ func (suite *DelayedAckTestSuite) TestDeletionOfRevertedPackets() { } // TODO: test refunds of pending packets - -/* ---------------------------------- utils --------------------------------- */ - -func generatePackets(rollappId string, num uint64) []commontypes.RollappPacket { - var packets []commontypes.RollappPacket - for i := uint64(0); i < num; i++ { - packets = append(packets, commontypes.RollappPacket{ - RollappId: rollappId, - Packet: &channeltypes.Packet{ - SourcePort: "testSourcePort", - SourceChannel: "testSourceChannel", - DestinationPort: "testDestinationPort", - DestinationChannel: "testDestinationChannel", - Data: []byte("testData"), - Sequence: i, - }, - Status: commontypes.Status_PENDING, - ProofHeight: i, - }) - } - return packets -} diff --git a/x/delayedack/keeper/grpc_query.go b/x/delayedack/keeper/grpc_query.go index 70d558627..4bce04f22 100644 --- a/x/delayedack/keeper/grpc_query.go +++ b/x/delayedack/keeper/grpc_query.go @@ -6,7 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" "github.com/dymensionxyz/dymension/v3/x/delayedack/types" "google.golang.org/grpc/codes" @@ -55,7 +54,7 @@ func (q Querier) GetPackets(goCtx context.Context, req *types.QueryRollappPacket return res, nil } -func (q Querier) GetPendingPacketsByReceiver(goCtx context.Context, req *types.QueryPendingPacketsByReceiverRequest) (*types.QueryPendingPacketByReceiverListResponse, error) { +func (q Querier) GetPendingPacketsByAddress(goCtx context.Context, req *types.QueryPendingPacketsByAddressRequest) (*types.QueryPendingPacketByAddressListResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "empty request") } @@ -63,27 +62,13 @@ func (q Querier) GetPendingPacketsByReceiver(goCtx context.Context, req *types.Q ctx := sdk.UnwrapSDKContext(goCtx) // Get all pending rollapp packets until the latest finalized height - rollappPendingPackets, _, err := q.GetPendingPacketsUntilLatestHeight(ctx, req.RollappId) + p, err := q.Keeper.GetPendingPacketsByAddress(ctx, req.Address) if err != nil { - return nil, fmt.Errorf("get pending rollapp packets until the latest finalized height: rollapp '%s': %w", req.RollappId, err) + return nil, fmt.Errorf("get pending packets by receiver %s: %w", req.Address, err) } - // Filter packets by receiver - result := make([]commontypes.RollappPacket, 0) - for _, packet := range rollappPendingPackets { - // Get packet data - pd, err := packet.GetTransferPacketData() - if err != nil { - return nil, fmt.Errorf("get transfer packet data: rollapp '%s': %w", req.RollappId, err) - } - // Return a packet if its receiver matches the one specified - if pd.Receiver == req.Receiver { - result = append(result, packet) - } - } - - return &types.QueryPendingPacketByReceiverListResponse{ - RollappPackets: result, + return &types.QueryPendingPacketByAddressListResponse{ + RollappPackets: p, Pagination: nil, // TODO: handle pagination }, nil } diff --git a/x/delayedack/keeper/hooks_test.go b/x/delayedack/keeper/hooks_test.go index c9eea7a98..552ab1d52 100644 --- a/x/delayedack/keeper/hooks_test.go +++ b/x/delayedack/keeper/hooks_test.go @@ -3,6 +3,7 @@ package keeper_test import ( channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + "github.com/dymensionxyz/dymension/v3/app/apptesting" commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" "github.com/dymensionxyz/dymension/v3/x/delayedack/types" ) @@ -52,7 +53,7 @@ func (suite *DelayedAckTestSuite) TestAfterEpochEnd() { SourceChannel: "testSourceChannel", DestinationPort: "testDestinationPort", DestinationChannel: "testDestinationChannel", - Data: []byte("testData"), + Data: apptesting.GenerateTestPacketData(suite.T()), Sequence: uint64(i), }, Status: commontypes.Status_PENDING, diff --git a/x/delayedack/keeper/invariants_test.go b/x/delayedack/keeper/invariants_test.go index 3b5c63abf..83a2de635 100644 --- a/x/delayedack/keeper/invariants_test.go +++ b/x/delayedack/keeper/invariants_test.go @@ -3,9 +3,8 @@ package keeper_test import ( "github.com/cometbft/cometbft/libs/rand" ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer" - transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + "github.com/dymensionxyz/dymension/v3/app/apptesting" commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" damodule "github.com/dymensionxyz/dymension/v3/x/delayedack" "github.com/dymensionxyz/dymension/v3/x/rollapp/types" @@ -53,11 +52,13 @@ func (suite *DelayedAckTestSuite) TestInvariants() { proofHeight := rollappBlocks[rollapp] + k rollappPacket := commontypes.RollappPacket{ RollappId: rollapp, - Packet: suite.getNewTestPacket(sequence), + Packet: apptesting.GenerateTestPacket(suite.T(), sequence), Status: commontypes.Status_PENDING, ProofHeight: proofHeight, } suite.App.DelayedAckKeeper.SetRollappPacket(suite.Ctx, rollappPacket) + err = suite.App.DelayedAckKeeper.SetPendingPacketByAddress(suite.Ctx, apptesting.TestPacketReceiver, rollappPacket.RollappPacketKey()) + suite.Require().NoError(err) sequence++ } @@ -75,10 +76,13 @@ func (suite *DelayedAckTestSuite) TestInvariants() { suite.App.RollappKeeper.FinalizeRollappStates(suite.Ctx) // manually finalize packets for all rollapps + finalizedNum := suite.FinalizeAllPendingPackets(apptesting.TestPacketReceiver) + // check the total number of packets + var total int for rollapp := range seqPerRollapp { - finalizedNum := suite.FinalizeAllPendingPackets(rollapp, testPacketReceiver) - suite.Require().Equal(rollappBlocks[rollapp], uint64(finalizedNum)) + total += int(rollappBlocks[rollapp]) } + suite.Require().Equal(total, finalizedNum) // test fraud for rollapp := range seqPerRollapp { @@ -115,13 +119,13 @@ func (suite *DelayedAckTestSuite) TestRollappPacketsCasesInvariant() { RollappId: rollapp, Status: commontypes.Status_FINALIZED, ProofHeight: 5, - Packet: suite.getNewTestPacket(1), + Packet: apptesting.GenerateTestPacket(suite.T(), 1), }, commontypes.RollappPacket{ RollappId: rollapp, Status: commontypes.Status_PENDING, ProofHeight: 15, - Packet: suite.getNewTestPacket(2), + Packet: apptesting.GenerateTestPacket(suite.T(), 2), }, false, }, @@ -134,13 +138,13 @@ func (suite *DelayedAckTestSuite) TestRollappPacketsCasesInvariant() { RollappId: rollapp, Status: commontypes.Status_FINALIZED, ProofHeight: 5, - Packet: suite.getNewTestPacket(1), + Packet: apptesting.GenerateTestPacket(suite.T(), 1), }, commontypes.RollappPacket{ RollappId: rollapp, Status: commontypes.Status_REVERTED, ProofHeight: 15, - Packet: suite.getNewTestPacket(2), + Packet: apptesting.GenerateTestPacket(suite.T(), 2), }, false, }, @@ -153,13 +157,13 @@ func (suite *DelayedAckTestSuite) TestRollappPacketsCasesInvariant() { RollappId: rollapp, Status: commontypes.Status_PENDING, ProofHeight: 5, - Packet: suite.getNewTestPacket(1), + Packet: apptesting.GenerateTestPacket(suite.T(), 1), }, commontypes.RollappPacket{ RollappId: rollapp, Status: commontypes.Status_PENDING, ProofHeight: 15, - Packet: suite.getNewTestPacket(2), + Packet: apptesting.GenerateTestPacket(suite.T(), 2), }, false, }, @@ -172,13 +176,13 @@ func (suite *DelayedAckTestSuite) TestRollappPacketsCasesInvariant() { RollappId: rollapp, Status: commontypes.Status_FINALIZED, ProofHeight: 5, - Packet: suite.getNewTestPacket(1), + Packet: apptesting.GenerateTestPacket(suite.T(), 1), }, commontypes.RollappPacket{ RollappId: rollapp, Status: commontypes.Status_PENDING, ProofHeight: 15, - Packet: suite.getNewTestPacket(2), + Packet: apptesting.GenerateTestPacket(suite.T(), 2), }, true, }, @@ -191,13 +195,13 @@ func (suite *DelayedAckTestSuite) TestRollappPacketsCasesInvariant() { RollappId: rollapp, Status: commontypes.Status_FINALIZED, ProofHeight: 5, - Packet: suite.getNewTestPacket(1), + Packet: apptesting.GenerateTestPacket(suite.T(), 1), }, commontypes.RollappPacket{ RollappId: rollapp, Status: commontypes.Status_PENDING, ProofHeight: 15, - Packet: suite.getNewTestPacket(2), + Packet: apptesting.GenerateTestPacket(suite.T(), 2), }, true, }, @@ -210,13 +214,13 @@ func (suite *DelayedAckTestSuite) TestRollappPacketsCasesInvariant() { RollappId: rollapp, Status: commontypes.Status_FINALIZED, ProofHeight: 5, - Packet: suite.getNewTestPacket(1), + Packet: apptesting.GenerateTestPacket(suite.T(), 1), }, commontypes.RollappPacket{ RollappId: rollapp, Status: commontypes.Status_FINALIZED, ProofHeight: 15, - Packet: suite.getNewTestPacket(2), + Packet: apptesting.GenerateTestPacket(suite.T(), 2), }, true, }, @@ -299,22 +303,3 @@ func (suite *DelayedAckTestSuite) TestRollappPacketsCasesInvariant() { }) } } - -const testPacketReceiver = "testReceiver" - -func (s *DelayedAckTestSuite) getNewTestPacket(sequence uint64) *channeltypes.Packet { - data := &transfertypes.FungibleTokenPacketData{ - Receiver: testPacketReceiver, - } - pd, err := transfertypes.ModuleCdc.MarshalJSON(data) - s.Require().NoError(err) - - return &channeltypes.Packet{ - SourcePort: "testSourcePort", - SourceChannel: testSourceChannel, - DestinationPort: "testDestinationPort", - DestinationChannel: "testDestinationChannel", - Data: pd, - Sequence: sequence, - } -} diff --git a/x/delayedack/keeper/keeper.go b/x/delayedack/keeper/keeper.go index 2d656b630..d864e7eba 100644 --- a/x/delayedack/keeper/keeper.go +++ b/x/delayedack/keeper/keeper.go @@ -3,6 +3,8 @@ package keeper import ( "fmt" + "cosmossdk.io/collections" + collcodec "cosmossdk.io/collections/codec" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -11,6 +13,7 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + "github.com/dymensionxyz/dymension/v3/internal/collcompat" "github.com/dymensionxyz/dymension/v3/x/delayedack/types" rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types" ) @@ -21,6 +24,12 @@ type Keeper struct { hooks types.MultiDelayedAckHooks paramstore paramtypes.Subspace + // pendingPacketsByAddress is an index of all pending packets associated with a Hub address. + // In case of ON_RECV packet (Rollapp -> Hub), the address is the packet receiver. + // In case of ON_ACK/ON_TIMEOUT packet (Hub -> Rollapp), the address is the packet sender. + // Index key: receiver address + packet key. + pendingPacketsByAddress collections.KeySet[collections.Pair[string, []byte]] + rollappKeeper types.RollappKeeper porttypes.ICS4Wrapper channelKeeper types.ChannelKeeper @@ -41,9 +50,15 @@ func NewKeeper( ps = ps.WithKeyTable(types.ParamKeyTable()) } return &Keeper{ - cdc: cdc, - storeKey: storeKey, - paramstore: ps, + cdc: cdc, + storeKey: storeKey, + paramstore: ps, + pendingPacketsByAddress: collections.NewKeySet( + collections.NewSchemaBuilder(collcompat.NewKVStoreService(storeKey)), + collections.NewPrefix(types.PendingPacketsByAddressKeyPrefix), + "pending_packets_by_receiver", + collections.PairKeyCodec(collections.StringKey, collcodec.NewBytesKey[[]byte]()), + ), rollappKeeper: rollappKeeper, ICS4Wrapper: ics4Wrapper, channelKeeper: channelKeeper, diff --git a/x/delayedack/keeper/keeper_test.go b/x/delayedack/keeper/keeper_test.go index ffb55e68b..21862c6c7 100644 --- a/x/delayedack/keeper/keeper_test.go +++ b/x/delayedack/keeper/keeper_test.go @@ -12,10 +12,7 @@ import ( "github.com/dymensionxyz/dymension/v3/x/delayedack/types" ) -const ( - delayedAckEventType = "delayedack" - testSourceChannel = "testSourceChannel" -) +const delayedAckEventType = "delayedack" type DelayedAckTestSuite struct { apptesting.KeeperTestHelper diff --git a/x/delayedack/keeper/rollapp_packet.go b/x/delayedack/keeper/rollapp_packet.go index 385cc16f1..c0441a17a 100644 --- a/x/delayedack/keeper/rollapp_packet.go +++ b/x/delayedack/keeper/rollapp_packet.go @@ -1,6 +1,9 @@ package keeper import ( + "errors" + + "cosmossdk.io/collections" sdk "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" @@ -25,6 +28,53 @@ func (k Keeper) SetRollappPacket(ctx sdk.Context, rollappPacket commontypes.Roll ) } +// SetPendingPacketByAddress stores a rollapp packet in the KVStore by its receiver. +// Helper index to query all packets by receiver. +func (k Keeper) SetPendingPacketByAddress(ctx sdk.Context, receiver string, rollappPacketKey []byte) error { + return k.pendingPacketsByAddress.Set(ctx, collections.Join(receiver, rollappPacketKey)) +} + +// MustSetPendingPacketByAddress stores a rollapp packet in the KVStore by its receiver. +// Helper index to query all packets by receiver. Panics on encoding errors. +func (k Keeper) MustSetPendingPacketByAddress(ctx sdk.Context, receiver string, rollappPacketKey []byte) { + err := k.SetPendingPacketByAddress(ctx, receiver, rollappPacketKey) + if err != nil { + panic(err) + } +} + +// DeletePendingPacketByAddress deletes a rollapp packet from the KVStore by its receiver. +func (k Keeper) DeletePendingPacketByAddress(ctx sdk.Context, receiver string, rollappPacketKey []byte) error { + return k.pendingPacketsByAddress.Remove(ctx, collections.Join(receiver, rollappPacketKey)) +} + +// MustDeletePendingPacketByAddress deletes a rollapp packet from the KVStore by its receiver. +// Panics on encoding error. Do not panic if the key is not found. +func (k Keeper) MustDeletePendingPacketByAddress(ctx sdk.Context, receiver string, rollappPacketKey []byte) { + err := k.DeletePendingPacketByAddress(ctx, receiver, rollappPacketKey) + if err != nil { + panic(err) + } +} + +// GetPendingPacketsByAddress retrieves rollapp packets from the KVStore by their receiver. +func (k Keeper) GetPendingPacketsByAddress(ctx sdk.Context, receiver string) ([]commontypes.RollappPacket, error) { + var packets []commontypes.RollappPacket + rng := collections.NewPrefixedPairRange[string, []byte](receiver) + err := k.pendingPacketsByAddress.Walk(ctx, rng, func(key collections.Pair[string, []byte]) (stop bool, err error) { + packet, err := k.GetRollappPacket(ctx, string(key.K2())) + if err != nil { + return true, err + } + packets = append(packets, *packet) + return false, nil + }) + if err != nil { + return nil, err + } + return packets, nil +} + // GetRollappPacket retrieves a rollapp packet from the KVStore. func (k Keeper) GetRollappPacket(ctx sdk.Context, rollappPacketKey string) (*commontypes.RollappPacket, error) { store := ctx.KVStore(k.storeKey) @@ -54,23 +104,27 @@ func (k Keeper) UpdateRollappPacketTransferAddress( if rollappPacket.Status != commontypes.Status_PENDING { return types.ErrCanOnlyUpdatePendingPacket } + transferPacketData, err := rollappPacket.GetTransferPacketData() if err != nil { return err } + // Set the recipient and sender based on the rollapp packet type - recipient, sender := transferPacketData.Receiver, transferPacketData.Sender - var originalTransferTarget string + var ( + recipient = transferPacketData.Receiver + sender = transferPacketData.Sender + originalTransferTarget string + ) switch rollappPacket.Type { case commontypes.RollappPacket_ON_RECV: originalTransferTarget = recipient recipient = address - case commontypes.RollappPacket_ON_TIMEOUT: - fallthrough - case commontypes.RollappPacket_ON_ACK: + case commontypes.RollappPacket_ON_ACK, commontypes.RollappPacket_ON_TIMEOUT: originalTransferTarget = sender sender = address } + // Create a new packet data with the updated recipient and sender newPacketData := transfertypes.NewFungibleTokenPacketData( transferPacketData.Denom, @@ -79,14 +133,21 @@ func (k Keeper) UpdateRollappPacketTransferAddress( recipient, transferPacketData.Memo, ) + // Marshall to binary and update the packet with this data - packetBytes := newPacketData.GetBytes() packet := rollappPacket.Packet - packet.Data = packetBytes + packet.Data = newPacketData.GetBytes() // Update rollapp packet with the new updated packet and save in the store rollappPacket.Packet = packet rollappPacket.OriginalTransferTarget = originalTransferTarget + + // Update index: delete the old packet and save the new one + k.MustDeletePendingPacketByAddress(ctx, originalTransferTarget, []byte(rollappPacketKey)) + k.MustSetPendingPacketByAddress(ctx, address, rollappPacket.RollappPacketKey()) + + // Save updated rollapp packet k.SetRollappPacket(ctx, *rollappPacket) + return nil } @@ -94,20 +155,42 @@ func (k Keeper) UpdateRollappPacketTransferAddress( // Updating the status should be called only with this method as it effects the key of the packet. // The assumption is that the passed rollapp packet status field is not updated directly. func (k *Keeper) UpdateRollappPacketWithStatus(ctx sdk.Context, rollappPacket commontypes.RollappPacket, newStatus commontypes.Status) (commontypes.RollappPacket, error) { - store := ctx.KVStore(k.storeKey) + if rollappPacket.Status != commontypes.Status_PENDING { + return commontypes.RollappPacket{}, types.ErrCanOnlyUpdatePendingPacket + } + if newStatus == commontypes.Status_PENDING { + return commontypes.RollappPacket{}, errors.New("cannot update packet to pending status") + } + + transferPacketData, err := rollappPacket.GetTransferPacketData() + if err != nil { + return commontypes.RollappPacket{}, err + } - // Delete the old rollapp packet oldKey := rollappPacket.RollappPacketKey() + + // Delete the old packet from the pending packets index depending on the packet type + switch rollappPacket.Type { + case commontypes.RollappPacket_ON_RECV: + k.MustDeletePendingPacketByAddress(ctx, transferPacketData.Receiver, oldKey) + case commontypes.RollappPacket_ON_ACK, commontypes.RollappPacket_ON_TIMEOUT: + k.MustDeletePendingPacketByAddress(ctx, transferPacketData.Sender, oldKey) + } + + // Delete the old rollapp packet + store := ctx.KVStore(k.storeKey) store.Delete(oldKey) + // Update the packet rollappPacket.Status = newStatus // Create a new rollapp packet with the updated status k.SetRollappPacket(ctx, rollappPacket) - // Call hook subscribers newKey := rollappPacket.RollappPacketKey() + + // Call hook subscribers keeperHooks := k.GetHooks() - err := keeperHooks.AfterPacketStatusUpdated(ctx, &rollappPacket, string(oldKey), string(newKey)) + err = keeperHooks.AfterPacketStatusUpdated(ctx, &rollappPacket, string(oldKey), string(newKey)) if err != nil { return rollappPacket, err } diff --git a/x/delayedack/keeper/rollapp_packet_test.go b/x/delayedack/keeper/rollapp_packet_test.go index e62354b8e..1fca74b66 100644 --- a/x/delayedack/keeper/rollapp_packet_test.go +++ b/x/delayedack/keeper/rollapp_packet_test.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + "github.com/dymensionxyz/dymension/v3/app/apptesting" commontypes "github.com/dymensionxyz/dymension/v3/x/common/types" "github.com/dymensionxyz/dymension/v3/x/delayedack/types" ) @@ -24,15 +25,8 @@ func (suite *DelayedAckTestSuite) TestRollappPacketEvents() { { name: "Test demand order fulfillment - success", rollappPacket: commontypes.RollappPacket{ - RollappId: "testRollappID", - Packet: &channeltypes.Packet{ - SourcePort: "testSourcePort", - SourceChannel: "testSourceChannel", - DestinationPort: "testDestinationPort", - DestinationChannel: "testDestinationChannel", - Data: []byte("testData"), - Sequence: 1, - }, + RollappId: "testRollappID", + Packet: apptesting.GenerateTestPacket(suite.T(), 1), Status: commontypes.Status_PENDING, ProofHeight: 1, }, @@ -169,27 +163,29 @@ func (suite *DelayedAckTestSuite) TestListRollappPackets() { suite.Require().Equal(totalLength, len(onRecvPackets)+len(onAckPackets)+len(onTimeoutPackets)) } -func (suite *DelayedAckTestSuite) TestUpdateRollappPacketWithStatus() { +func (suite *DelayedAckTestSuite) TestUpdateRollappPacketWithStatus_PendingToFinalized() { var err error keeper, ctx := suite.App.DelayedAckKeeper, suite.Ctx - packet := commontypes.RollappPacket{ - RollappId: "testRollappID", - Packet: &channeltypes.Packet{ - SourcePort: "testSourcePort", - SourceChannel: "testSourceChannel", - DestinationPort: "testDestinationPort", - DestinationChannel: "testDestinationChannel", - Data: []byte("testData"), - Sequence: 1, - }, + oldPacket := commontypes.RollappPacket{ + RollappId: "testRollappID", + Packet: apptesting.GenerateTestPacket(suite.T(), 1), Status: commontypes.Status_PENDING, ProofHeight: 1, } - keeper.SetRollappPacket(ctx, packet) + keeper.SetRollappPacket(ctx, oldPacket) + err = keeper.SetPendingPacketByAddress(ctx, apptesting.TestPacketReceiver, oldPacket.RollappPacketKey()) + suite.Require().NoError(err) + // Update the packet status - packet, err = keeper.UpdateRollappPacketWithStatus(ctx, packet, commontypes.Status_FINALIZED) + packet, err := keeper.UpdateRollappPacketWithStatus(ctx, oldPacket, commontypes.Status_FINALIZED) suite.Require().NoError(err) suite.Require().Equal(commontypes.Status_FINALIZED, packet.Status) + + // Check the updated packet is not in the receiver's index anymore + byReceiver, err := keeper.GetPendingPacketsByAddress(ctx, apptesting.TestPacketReceiver) + suite.Require().NoError(err) + suite.Require().Empty(len(byReceiver)) + packets := keeper.GetAllRollappPackets(ctx) suite.Require().Equal(1, len(packets)) // Set the packet and make sure there is only one packet in the store @@ -197,3 +193,111 @@ func (suite *DelayedAckTestSuite) TestUpdateRollappPacketWithStatus() { packets = keeper.GetAllRollappPackets(ctx) suite.Require().Equal(1, len(packets)) } + +func (suite *DelayedAckTestSuite) TestUpdateRollappPacketTransferAddress_ON_RECV() { + var err error + keeper, ctx := suite.App.DelayedAckKeeper, suite.Ctx + packet := commontypes.RollappPacket{ + RollappId: "testRollappID", + Packet: apptesting.GenerateTestPacket(suite.T(), 1), + Type: commontypes.RollappPacket_ON_RECV, + Status: commontypes.Status_PENDING, + ProofHeight: 1, + } + keeper.SetRollappPacket(ctx, packet) + err = keeper.SetPendingPacketByAddress(ctx, apptesting.TestPacketReceiver, packet.RollappPacketKey()) + suite.Require().NoError(err) + + // Update the packet receiver + const newReceiver = "newReceiver" + err = keeper.UpdateRollappPacketTransferAddress(ctx, string(packet.RollappPacketKey()), newReceiver) + suite.Require().NoError(err) + + // Check the state + packets := keeper.GetAllRollappPackets(ctx) + suite.Require().Equal(1, len(packets)) + pd1, err := packets[0].GetTransferPacketData() + suite.Require().NoError(err) + suite.Require().Equal(newReceiver, pd1.Receiver) + + // Check the packet key is the same + actualPacket, err := keeper.GetRollappPacket(ctx, string(packet.RollappPacketKey())) + suite.Require().NoError(err) + pd2, err := actualPacket.GetTransferPacketData() + suite.Require().NoError(err) + suite.Require().Equal(newReceiver, pd2.Receiver) + + // Check the index + // Check the packet is in the receiver's index + byReceiverNew, err := keeper.GetPendingPacketsByAddress(ctx, newReceiver) + suite.Require().NoError(err) + suite.Require().Equal(1, len(byReceiverNew)) + suite.Require().Equal(packet.RollappPacketKey(), byReceiverNew[0].RollappPacketKey()) + pd3, err := byReceiverNew[0].GetTransferPacketData() + suite.Require().NoError(err) + suite.Require().Equal(newReceiver, pd3.Receiver) + + // Check the packet is not in the receiver's index + byReceiverOld, err := keeper.GetPendingPacketsByAddress(ctx, apptesting.TestPacketReceiver) + suite.Require().NoError(err) + suite.Require().Empty(byReceiverOld) + + // Set the packet and make sure there is only one packet in the store + keeper.SetRollappPacket(ctx, packet) + packets = keeper.GetAllRollappPackets(ctx) + suite.Require().Equal(1, len(packets)) +} + +func (suite *DelayedAckTestSuite) TestUpdateRollappPacketTransferAddress_ON_ACK() { + var err error + keeper, ctx := suite.App.DelayedAckKeeper, suite.Ctx + packet := commontypes.RollappPacket{ + RollappId: "testRollappID", + Packet: apptesting.GenerateTestPacket(suite.T(), 1), + Type: commontypes.RollappPacket_ON_ACK, + Status: commontypes.Status_PENDING, + ProofHeight: 1, + } + keeper.SetRollappPacket(ctx, packet) + err = keeper.SetPendingPacketByAddress(ctx, apptesting.TestPacketSender, packet.RollappPacketKey()) + suite.Require().NoError(err) + + // Update the packet receiver + const newSender = "newSender" + err = keeper.UpdateRollappPacketTransferAddress(ctx, string(packet.RollappPacketKey()), newSender) + suite.Require().NoError(err) + + // Check the state + packets := keeper.GetAllRollappPackets(ctx) + suite.Require().Equal(1, len(packets)) + pd1, err := packets[0].GetTransferPacketData() + suite.Require().NoError(err) + suite.Require().Equal(newSender, pd1.Sender) + + // Check the packet key is the same + actualPacket, err := keeper.GetRollappPacket(ctx, string(packet.RollappPacketKey())) + suite.Require().NoError(err) + pd2, err := actualPacket.GetTransferPacketData() + suite.Require().NoError(err) + suite.Require().Equal(newSender, pd2.Sender) + + // Check the index + // Check the new packet is in the sender's index + bySenderNew, err := keeper.GetPendingPacketsByAddress(ctx, newSender) + suite.Require().NoError(err) + suite.Require().Equal(1, len(bySenderNew)) + suite.Require().Equal(packet.RollappPacketKey(), bySenderNew[0].RollappPacketKey()) + pd3, err := bySenderNew[0].GetTransferPacketData() + suite.Require().NoError(err) + suite.Require().Equal(newSender, pd3.Sender) + + // Check the old packet is not in the sender's index + bySenderOld, err := keeper.GetPendingPacketsByAddress(ctx, apptesting.TestPacketSender) + suite.Require().NoError(err) + suite.Require().Empty(bySenderOld) + + // Set the packet and make sure there is only one packet in the store + keeper.SetRollappPacket(ctx, packet) + packets = keeper.GetAllRollappPackets(ctx) + suite.Require().Equal(1, len(packets)) +} diff --git a/x/delayedack/types/events.pb.go b/x/delayedack/types/events.pb.go index 29cde468c..5cfa41511 100644 --- a/x/delayedack/types/events.pb.go +++ b/x/delayedack/types/events.pb.go @@ -113,163 +113,8 @@ func (m *EventFinalizePacket) GetPacketSequence() uint64 { return 0 } -type EventFinalizePacketsUntilHeight struct { - // Sender is the signer of the message. - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // RollappID is the ID of the rollapp. - RollappId string `protobuf:"bytes,2,opt,name=rollapp_id,json=rollappId,proto3" json:"rollapp_id,omitempty"` - // Height is a height until which packets are to be finalized. Height is inclusive. - Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` - // FinalizedNum is the number of finalized packets. - FinalizedNum uint64 `protobuf:"varint,4,opt,name=finalized_num,json=finalizedNum,proto3" json:"finalized_num,omitempty"` -} - -func (m *EventFinalizePacketsUntilHeight) Reset() { *m = EventFinalizePacketsUntilHeight{} } -func (m *EventFinalizePacketsUntilHeight) String() string { return proto.CompactTextString(m) } -func (*EventFinalizePacketsUntilHeight) ProtoMessage() {} -func (*EventFinalizePacketsUntilHeight) Descriptor() ([]byte, []int) { - return fileDescriptor_de2c6b6165d75670, []int{1} -} -func (m *EventFinalizePacketsUntilHeight) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventFinalizePacketsUntilHeight) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventFinalizePacketsUntilHeight.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EventFinalizePacketsUntilHeight) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventFinalizePacketsUntilHeight.Merge(m, src) -} -func (m *EventFinalizePacketsUntilHeight) XXX_Size() int { - return m.Size() -} -func (m *EventFinalizePacketsUntilHeight) XXX_DiscardUnknown() { - xxx_messageInfo_EventFinalizePacketsUntilHeight.DiscardUnknown(m) -} - -var xxx_messageInfo_EventFinalizePacketsUntilHeight proto.InternalMessageInfo - -func (m *EventFinalizePacketsUntilHeight) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -func (m *EventFinalizePacketsUntilHeight) GetRollappId() string { - if m != nil { - return m.RollappId - } - return "" -} - -func (m *EventFinalizePacketsUntilHeight) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *EventFinalizePacketsUntilHeight) GetFinalizedNum() uint64 { - if m != nil { - return m.FinalizedNum - } - return 0 -} - -type EventFinalizeRollappPacketsByReceiver struct { - // Sender is the signer of the message. - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // RollappID is the ID of the rollapp. - RollappId string `protobuf:"bytes,2,opt,name=rollapp_id,json=rollappId,proto3" json:"rollapp_id,omitempty"` - // Receiver is the one who waits tokens after the finalization. - Receiver string `protobuf:"bytes,3,opt,name=receiver,proto3" json:"receiver,omitempty"` - // Height is a height until which packets are to be finalized. - Height uint64 `protobuf:"varint,4,opt,name=height,proto3" json:"height,omitempty"` - // FinalizedNum is the number of finalized packets. - FinalizedNum uint64 `protobuf:"varint,5,opt,name=finalized_num,json=finalizedNum,proto3" json:"finalized_num,omitempty"` -} - -func (m *EventFinalizeRollappPacketsByReceiver) Reset() { *m = EventFinalizeRollappPacketsByReceiver{} } -func (m *EventFinalizeRollappPacketsByReceiver) String() string { return proto.CompactTextString(m) } -func (*EventFinalizeRollappPacketsByReceiver) ProtoMessage() {} -func (*EventFinalizeRollappPacketsByReceiver) Descriptor() ([]byte, []int) { - return fileDescriptor_de2c6b6165d75670, []int{2} -} -func (m *EventFinalizeRollappPacketsByReceiver) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventFinalizeRollappPacketsByReceiver) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventFinalizeRollappPacketsByReceiver.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *EventFinalizeRollappPacketsByReceiver) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventFinalizeRollappPacketsByReceiver.Merge(m, src) -} -func (m *EventFinalizeRollappPacketsByReceiver) XXX_Size() int { - return m.Size() -} -func (m *EventFinalizeRollappPacketsByReceiver) XXX_DiscardUnknown() { - xxx_messageInfo_EventFinalizeRollappPacketsByReceiver.DiscardUnknown(m) -} - -var xxx_messageInfo_EventFinalizeRollappPacketsByReceiver proto.InternalMessageInfo - -func (m *EventFinalizeRollappPacketsByReceiver) GetSender() string { - if m != nil { - return m.Sender - } - return "" -} - -func (m *EventFinalizeRollappPacketsByReceiver) GetRollappId() string { - if m != nil { - return m.RollappId - } - return "" -} - -func (m *EventFinalizeRollappPacketsByReceiver) GetReceiver() string { - if m != nil { - return m.Receiver - } - return "" -} - -func (m *EventFinalizeRollappPacketsByReceiver) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *EventFinalizeRollappPacketsByReceiver) GetFinalizedNum() uint64 { - if m != nil { - return m.FinalizedNum - } - return 0 -} - func init() { proto.RegisterType((*EventFinalizePacket)(nil), "dymensionxyz.dymension.delayedack.EventFinalizePacket") - proto.RegisterType((*EventFinalizePacketsUntilHeight)(nil), "dymensionxyz.dymension.delayedack.EventFinalizePacketsUntilHeight") - proto.RegisterType((*EventFinalizeRollappPacketsByReceiver)(nil), "dymensionxyz.dymension.delayedack.EventFinalizeRollappPacketsByReceiver") } func init() { @@ -277,34 +122,28 @@ func init() { } var fileDescriptor_de2c6b6165d75670 = []byte{ - // 427 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0xbd, 0x8e, 0xd3, 0x40, - 0x10, 0xce, 0x1e, 0x3e, 0x8b, 0x2c, 0x70, 0xc0, 0x9e, 0x74, 0xb2, 0x4e, 0xc2, 0x84, 0x20, 0x44, - 0x0a, 0x64, 0x8b, 0xbb, 0x82, 0xfe, 0x10, 0x08, 0x1a, 0x74, 0x2c, 0xd0, 0xd0, 0x58, 0xbe, 0xf5, - 0x5c, 0xbc, 0x8a, 0xbd, 0x6b, 0xd6, 0x76, 0x14, 0xe7, 0x29, 0x68, 0x78, 0x06, 0x1e, 0x81, 0x57, - 0xa0, 0x4c, 0x49, 0x89, 0x92, 0x17, 0x41, 0xde, 0xdd, 0xfc, 0x09, 0x42, 0x91, 0xce, 0x33, 0xdf, - 0xe7, 0x6f, 0xbe, 0xf9, 0x3c, 0xc6, 0x41, 0xd2,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0x77, - 0x97, 0x6c, 0xf8, 0x52, 0x83, 0x60, 0xe0, 0xb9, 0xda, 0xed, 0x91, 0xa5, 0xda, 0x6e, 0xff, 0x1b, - 0xc2, 0x0f, 0xff, 0x91, 0x54, 0xf9, 0x49, 0x54, 0x3c, 0xb3, 0xeb, 0xec, 0x99, 0xda, 0x09, 0x76, - 0xb7, 0x82, 0xb2, 0x15, 0x79, 0x8c, 0xef, 0x5c, 0xdb, 0x61, 0x49, 0x24, 0xea, 0x5c, 0xe7, 0xe3, - 0xd0, 0xdb, 0xab, 0xe6, 0xbb, 0x3a, 0xef, 0xff, 0x40, 0xf8, 0xc9, 0x96, 0xaf, 0xad, 0x78, 0xca, - 0x8b, 0x86, 0x02, 0x03, 0x3e, 0x06, 0xb5, 0xaf, 0xbb, 0x53, 0x7c, 0x53, 0x59, 0x09, 0xed, 0xaf, - 0x4b, 0x57, 0xf5, 0x86, 0x73, 0xe7, 0xff, 0xce, 0x0f, 0xff, 0x76, 0x7e, 0xf1, 0xfe, 0xe7, 0xdc, - 0x47, 0xb3, 0xb9, 0x8f, 0x7e, 0xcf, 0x7d, 0xf4, 0x75, 0xe1, 0x77, 0x66, 0x0b, 0xbf, 0xf3, 0x6b, - 0xe1, 0x77, 0x3e, 0xbf, 0x18, 0xf2, 0x2a, 0xad, 0xaf, 0xda, 0x0f, 0x1e, 0xee, 0x38, 0xea, 0xf1, - 0x79, 0x38, 0xd9, 0xfc, 0x59, 0xda, 0xfb, 0x29, 0xaf, 0x5c, 0x7d, 0xd5, 0xe7, 0x7f, 0x02, 0x00, - 0x00, 0xff, 0xff, 0xd4, 0x60, 0x15, 0xe5, 0x5e, 0x03, 0x00, 0x00, + // 333 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0x41, 0x4f, 0xc2, 0x30, + 0x14, 0xc7, 0x29, 0x22, 0x09, 0x35, 0x41, 0x2d, 0x89, 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, 0x55, 0x21, + 0xc1, 0xa9, 0xb5, 0x51, 0xa7, 0xd9, 0xbd, 0xa6, 0x3b, 0x76, 0x35, 0x8b, 0x50, 0xdf, 0x8c, 0x33, + 0x49, 0xe9, 0x6b, 0x21, 0xc1, 0xc7, 0x86, 0x52, 0xbe, 0xc9, 0x15, 0x26, 0x96, 0x99, 0x67, 0x2c, + 0x60, 0x71, 0xc8, 0x39, 0xa4, 0xce, 0xbe, 0x8e, 0x7a, 0x64, 0x94, 0x97, 0x8c, 0xdd, 0x99, 0x3e, + 0xb9, 0xc4, 0x87, 0x6b, 0x37, 0x7c, 0x4c, 0x80, 0x33, 0x70, 0xea, 0x3a, 0x6d, 0xd3, 0x5a, 0x6d, + 0xf7, 0xf6, 0xf9, 0x7b, 0xe9, 0xa2, 0xc5, 0xd2, 0x45, 0xbf, 0x4b, 0x17, 0x7d, 0xae, 0xdc, 0xca, + 0x62, 0xe5, 0x56, 0x7e, 0x56, 0x6e, 0xe5, 0xed, 0x66, 0x98, 0xa8, 0x78, 0x32, 0x28, 0xe3, 0x79, + 0x3b, 0x4e, 0x30, 0xed, 0x79, 0xb3, 0xed, 0xd3, 0x96, 0xdb, 0xe6, 0x83, 0xba, 0xbe, 0x41, 0xef, + 0x2f, 0x00, 0x00, 0xff, 0xff, 0x4b, 0xa4, 0x49, 0x5e, 0x0c, 0x02, 0x00, 0x00, } func (m *EventFinalizePacket) Marshal() (dAtA []byte, err error) { @@ -366,107 +205,6 @@ func (m *EventFinalizePacket) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *EventFinalizePacketsUntilHeight) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EventFinalizePacketsUntilHeight) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventFinalizePacketsUntilHeight) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.FinalizedNum != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.FinalizedNum)) - i-- - dAtA[i] = 0x20 - } - if m.Height != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x18 - } - if len(m.RollappId) > 0 { - i -= len(m.RollappId) - copy(dAtA[i:], m.RollappId) - i = encodeVarintEvents(dAtA, i, uint64(len(m.RollappId))) - i-- - dAtA[i] = 0x12 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintEvents(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *EventFinalizeRollappPacketsByReceiver) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *EventFinalizeRollappPacketsByReceiver) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventFinalizeRollappPacketsByReceiver) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.FinalizedNum != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.FinalizedNum)) - i-- - dAtA[i] = 0x28 - } - if m.Height != 0 { - i = encodeVarintEvents(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x20 - } - if len(m.Receiver) > 0 { - i -= len(m.Receiver) - copy(dAtA[i:], m.Receiver) - i = encodeVarintEvents(dAtA, i, uint64(len(m.Receiver))) - i-- - dAtA[i] = 0x1a - } - if len(m.RollappId) > 0 { - i -= len(m.RollappId) - copy(dAtA[i:], m.RollappId) - i = encodeVarintEvents(dAtA, i, uint64(len(m.RollappId))) - i-- - dAtA[i] = 0x12 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintEvents(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { offset -= sovEvents(v) base := offset @@ -508,56 +246,6 @@ func (m *EventFinalizePacket) Size() (n int) { return n } -func (m *EventFinalizePacketsUntilHeight) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - l = len(m.RollappId) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - if m.Height != 0 { - n += 1 + sovEvents(uint64(m.Height)) - } - if m.FinalizedNum != 0 { - n += 1 + sovEvents(uint64(m.FinalizedNum)) - } - return n -} - -func (m *EventFinalizeRollappPacketsByReceiver) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - l = len(m.RollappId) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - l = len(m.Receiver) - if l > 0 { - n += 1 + l + sovEvents(uint64(l)) - } - if m.Height != 0 { - n += 1 + sovEvents(uint64(m.Height)) - } - if m.FinalizedNum != 0 { - n += 1 + sovEvents(uint64(m.FinalizedNum)) - } - return n -} - func sovEvents(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -767,342 +455,6 @@ func (m *EventFinalizePacket) Unmarshal(dAtA []byte) error { } return nil } -func (m *EventFinalizePacketsUntilHeight) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventFinalizePacketsUntilHeight: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventFinalizePacketsUntilHeight: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RollappId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RollappId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalizedNum", wireType) - } - m.FinalizedNum = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.FinalizedNum |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventFinalizeRollappPacketsByReceiver) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: EventFinalizeRollappPacketsByReceiver: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventFinalizeRollappPacketsByReceiver: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RollappId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RollappId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Receiver", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthEvents - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvents - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Receiver = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field FinalizedNum", wireType) - } - m.FinalizedNum = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvents - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.FinalizedNum |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipEvents(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvents - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipEvents(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/delayedack/types/keys.go b/x/delayedack/types/keys.go index b32a8cdb3..a4ada6e9e 100644 --- a/x/delayedack/types/keys.go +++ b/x/delayedack/types/keys.go @@ -14,6 +14,4 @@ const ( MemStoreKey = "mem_delayedack" ) -func KeyPrefix(p string) []byte { - return []byte(p) -} +var PendingPacketsByAddressKeyPrefix = []byte{0x01} diff --git a/x/delayedack/types/query.pb.go b/x/delayedack/types/query.pb.go index ef1414040..d349fa7b7 100644 --- a/x/delayedack/types/query.pb.go +++ b/x/delayedack/types/query.pb.go @@ -234,24 +234,23 @@ func (m *QueryRollappPacketListResponse) GetPagination() *query.PageResponse { return nil } -type QueryPendingPacketsByReceiverRequest struct { - RollappId string `protobuf:"bytes,1,opt,name=rollappId,proto3" json:"rollappId,omitempty"` - Receiver string `protobuf:"bytes,2,opt,name=receiver,proto3" json:"receiver,omitempty"` - Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` +type QueryPendingPacketsByAddressRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryPendingPacketsByReceiverRequest) Reset() { *m = QueryPendingPacketsByReceiverRequest{} } -func (m *QueryPendingPacketsByReceiverRequest) String() string { return proto.CompactTextString(m) } -func (*QueryPendingPacketsByReceiverRequest) ProtoMessage() {} -func (*QueryPendingPacketsByReceiverRequest) Descriptor() ([]byte, []int) { +func (m *QueryPendingPacketsByAddressRequest) Reset() { *m = QueryPendingPacketsByAddressRequest{} } +func (m *QueryPendingPacketsByAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryPendingPacketsByAddressRequest) ProtoMessage() {} +func (*QueryPendingPacketsByAddressRequest) Descriptor() ([]byte, []int) { return fileDescriptor_0d5f080aa12bfc36, []int{4} } -func (m *QueryPendingPacketsByReceiverRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryPendingPacketsByAddressRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPendingPacketsByReceiverRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPendingPacketsByAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPendingPacketsByReceiverRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPendingPacketsByAddressRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -261,58 +260,51 @@ func (m *QueryPendingPacketsByReceiverRequest) XXX_Marshal(b []byte, determinist return b[:n], nil } } -func (m *QueryPendingPacketsByReceiverRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPendingPacketsByReceiverRequest.Merge(m, src) +func (m *QueryPendingPacketsByAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPendingPacketsByAddressRequest.Merge(m, src) } -func (m *QueryPendingPacketsByReceiverRequest) XXX_Size() int { +func (m *QueryPendingPacketsByAddressRequest) XXX_Size() int { return m.Size() } -func (m *QueryPendingPacketsByReceiverRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPendingPacketsByReceiverRequest.DiscardUnknown(m) +func (m *QueryPendingPacketsByAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPendingPacketsByAddressRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryPendingPacketsByReceiverRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryPendingPacketsByAddressRequest proto.InternalMessageInfo -func (m *QueryPendingPacketsByReceiverRequest) GetRollappId() string { +func (m *QueryPendingPacketsByAddressRequest) GetAddress() string { if m != nil { - return m.RollappId - } - return "" -} - -func (m *QueryPendingPacketsByReceiverRequest) GetReceiver() string { - if m != nil { - return m.Receiver + return m.Address } return "" } -func (m *QueryPendingPacketsByReceiverRequest) GetPagination() *query.PageRequest { +func (m *QueryPendingPacketsByAddressRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -type QueryPendingPacketByReceiverListResponse struct { +type QueryPendingPacketByAddressListResponse struct { RollappPackets []types.RollappPacket `protobuf:"bytes,1,rep,name=rollappPackets,proto3" json:"rollappPackets"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryPendingPacketByReceiverListResponse) Reset() { - *m = QueryPendingPacketByReceiverListResponse{} +func (m *QueryPendingPacketByAddressListResponse) Reset() { + *m = QueryPendingPacketByAddressListResponse{} } -func (m *QueryPendingPacketByReceiverListResponse) String() string { return proto.CompactTextString(m) } -func (*QueryPendingPacketByReceiverListResponse) ProtoMessage() {} -func (*QueryPendingPacketByReceiverListResponse) Descriptor() ([]byte, []int) { +func (m *QueryPendingPacketByAddressListResponse) String() string { return proto.CompactTextString(m) } +func (*QueryPendingPacketByAddressListResponse) ProtoMessage() {} +func (*QueryPendingPacketByAddressListResponse) Descriptor() ([]byte, []int) { return fileDescriptor_0d5f080aa12bfc36, []int{5} } -func (m *QueryPendingPacketByReceiverListResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryPendingPacketByAddressListResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPendingPacketByReceiverListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryPendingPacketByAddressListResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPendingPacketByReceiverListResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryPendingPacketByAddressListResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -322,26 +314,26 @@ func (m *QueryPendingPacketByReceiverListResponse) XXX_Marshal(b []byte, determi return b[:n], nil } } -func (m *QueryPendingPacketByReceiverListResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPendingPacketByReceiverListResponse.Merge(m, src) +func (m *QueryPendingPacketByAddressListResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryPendingPacketByAddressListResponse.Merge(m, src) } -func (m *QueryPendingPacketByReceiverListResponse) XXX_Size() int { +func (m *QueryPendingPacketByAddressListResponse) XXX_Size() int { return m.Size() } -func (m *QueryPendingPacketByReceiverListResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPendingPacketByReceiverListResponse.DiscardUnknown(m) +func (m *QueryPendingPacketByAddressListResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryPendingPacketByAddressListResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryPendingPacketByReceiverListResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryPendingPacketByAddressListResponse proto.InternalMessageInfo -func (m *QueryPendingPacketByReceiverListResponse) GetRollappPackets() []types.RollappPacket { +func (m *QueryPendingPacketByAddressListResponse) GetRollappPackets() []types.RollappPacket { if m != nil { return m.RollappPackets } return nil } -func (m *QueryPendingPacketByReceiverListResponse) GetPagination() *query.PageResponse { +func (m *QueryPendingPacketByAddressListResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } @@ -353,8 +345,8 @@ func init() { proto.RegisterType((*QueryParamsResponse)(nil), "dymensionxyz.dymension.delayedack.QueryParamsResponse") proto.RegisterType((*QueryRollappPacketsRequest)(nil), "dymensionxyz.dymension.delayedack.QueryRollappPacketsRequest") proto.RegisterType((*QueryRollappPacketListResponse)(nil), "dymensionxyz.dymension.delayedack.QueryRollappPacketListResponse") - proto.RegisterType((*QueryPendingPacketsByReceiverRequest)(nil), "dymensionxyz.dymension.delayedack.QueryPendingPacketsByReceiverRequest") - proto.RegisterType((*QueryPendingPacketByReceiverListResponse)(nil), "dymensionxyz.dymension.delayedack.QueryPendingPacketByReceiverListResponse") + proto.RegisterType((*QueryPendingPacketsByAddressRequest)(nil), "dymensionxyz.dymension.delayedack.QueryPendingPacketsByAddressRequest") + proto.RegisterType((*QueryPendingPacketByAddressListResponse)(nil), "dymensionxyz.dymension.delayedack.QueryPendingPacketByAddressListResponse") } func init() { @@ -362,48 +354,48 @@ func init() { } var fileDescriptor_0d5f080aa12bfc36 = []byte{ - // 645 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x55, 0x4f, 0x6f, 0x12, 0x41, - 0x14, 0x67, 0x68, 0x4b, 0xec, 0x34, 0xe9, 0x61, 0xec, 0x81, 0xac, 0xcd, 0x5a, 0x37, 0xfe, 0xa1, - 0x2a, 0x33, 0x81, 0x46, 0x3d, 0x35, 0xa6, 0x24, 0x4a, 0x8c, 0x1e, 0xe8, 0xda, 0x13, 0x07, 0xcd, - 0x00, 0x93, 0x75, 0x53, 0xd8, 0xd9, 0xee, 0x0e, 0xa4, 0x6b, 0xc3, 0xc5, 0x93, 0x37, 0x4d, 0xfc, - 0x02, 0x1e, 0x8d, 0xdf, 0xc3, 0xa4, 0x37, 0x9b, 0x78, 0xd0, 0x93, 0x31, 0xe0, 0x07, 0x31, 0x3b, - 0xb3, 0x2c, 0x50, 0xa0, 0x6c, 0xb9, 0x79, 0x63, 0x77, 0xdf, 0xef, 0xfd, 0x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 0xff, 0x1b, 0xc8, 0xfd, - 0xca, 0x06, 0x08, 0x00, 0x00, + // 644 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x55, 0xcf, 0x4e, 0x13, 0x41, + 0x18, 0xef, 0x14, 0xa8, 0x61, 0x48, 0x38, 0x8c, 0x1c, 0x36, 0x1b, 0xb2, 0xe2, 0x1a, 0x05, 0x54, + 0x66, 0xd2, 0x12, 0xf5, 0x44, 0x0c, 0x24, 0xd0, 0x68, 0x34, 0x81, 0xd5, 0x13, 0x07, 0xcd, 0xb4, + 0x3b, 0x59, 0x37, 0xb4, 0x3b, 0xcb, 0xce, 0x94, 0xb0, 0x12, 0x2e, 0x5e, 0xf4, 0x48, 0xe2, 0x5b, + 0xf8, 0x1e, 0x26, 0x9c, 0x0c, 0x89, 0x07, 0x3d, 0x19, 0x03, 0xbe, 0x87, 0x66, 0x67, 0xb6, 0xdb, + 0x96, 0xb6, 0x74, 0xe9, 0xcd, 0x5b, 0x67, 0xfa, 0xfd, 0xe6, 0xf7, 0x67, 0xbe, 0x6f, 0x16, 0xae, + 0xb8, 0x71, 0x93, 0x05, 0xc2, 0xe7, 0xc1, 0x61, 0xfc, 0x9e, 0x64, 0x0b, 0xe2, 0xb2, 0x06, 0x8d, + 0x99, 0x4b, 0xeb, 0x7b, 0x64, 0xbf, 0xc5, 0xa2, 0x18, 0x87, 0x11, 0x97, 0x1c, 0xdd, 0xee, 0x2e, + 0xc7, 0xd9, 0x02, 0x77, 0xca, 0xcd, 0x39, 0x8f, 0x7b, 0x5c, 0x55, 0x93, 0xe4, 0x97, 0x06, 0x9a, + 0xf3, 0x1e, 0xe7, 0x5e, 0x83, 0x11, 0x1a, 0xfa, 0x84, 0x06, 0x01, 0x97, 0x54, 0xfa, 0x3c, 0x10, + 0xe9, 0xbf, 0xf7, 0xeb, 0x5c, 0x34, 0xb9, 0x20, 0x35, 0x2a, 0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0xfd, 0x82, 0x1c, 0xa3, 0xbf, 0x00, 0x9a, 0x89, 0xb3, 0xc1, 0x9d, + 0x8e, 0xb6, 0x72, 0x67, 0x7c, 0xe5, 0xa8, 0x98, 0xcf, 0xc7, 0x3a, 0x67, 0x60, 0xa3, 0xdb, 0x2f, + 0x95, 0xf7, 0x2a, 0xda, 0xcc, 0xe3, 0x5d, 0x1f, 0xb7, 0x12, 0xb1, 0x3a, 0xf3, 0x0f, 0x58, 0xb4, + 0x92, 0x85, 0x91, 0x8e, 0xea, 0xf1, 0xc6, 0xce, 0xe9, 0xb9, 0x05, 0xce, 0xce, 0x2d, 0xf0, 0xfb, + 0xdc, 0x02, 0x27, 0x17, 0x56, 0xe1, 0xec, 0xc2, 0x2a, 0xfc, 0xbc, 0xb0, 0x0a, 0xbb, 0x4f, 0x3c, + 0x5f, 0xbe, 0x6b, 0xd5, 0x92, 0x41, 0x19, 0x46, 0x75, 0xb0, 0x4a, 0x0e, 0xbb, 0xf9, 0x92, 0xf7, + 0x54, 0xd4, 0x4a, 0xea, 0x83, 0xb4, 0xfa, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x19, 0xae, 0x61, 0xeb, + 0xd4, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -423,7 +415,7 @@ type QueryClient interface { // Queries a list of RollappPacket items by rollappID. GetPackets(ctx context.Context, in *QueryRollappPacketsRequest, opts ...grpc.CallOption) (*QueryRollappPacketListResponse, error) // Queries a list of pending RollappPacket items by rollappID and receiver. - GetPendingPacketsByReceiver(ctx context.Context, in *QueryPendingPacketsByReceiverRequest, opts ...grpc.CallOption) (*QueryPendingPacketByReceiverListResponse, error) + GetPendingPacketsByAddress(ctx context.Context, in *QueryPendingPacketsByAddressRequest, opts ...grpc.CallOption) (*QueryPendingPacketByAddressListResponse, error) } type queryClient struct { @@ -452,9 +444,9 @@ func (c *queryClient) GetPackets(ctx context.Context, in *QueryRollappPacketsReq return out, nil } -func (c *queryClient) GetPendingPacketsByReceiver(ctx context.Context, in *QueryPendingPacketsByReceiverRequest, opts ...grpc.CallOption) (*QueryPendingPacketByReceiverListResponse, error) { - out := new(QueryPendingPacketByReceiverListResponse) - err := c.cc.Invoke(ctx, "/dymensionxyz.dymension.delayedack.Query/GetPendingPacketsByReceiver", in, out, opts...) +func (c *queryClient) GetPendingPacketsByAddress(ctx context.Context, in *QueryPendingPacketsByAddressRequest, opts ...grpc.CallOption) (*QueryPendingPacketByAddressListResponse, error) { + out := new(QueryPendingPacketByAddressListResponse) + err := c.cc.Invoke(ctx, "/dymensionxyz.dymension.delayedack.Query/GetPendingPacketsByAddress", in, out, opts...) if err != nil { return nil, err } @@ -468,7 +460,7 @@ type QueryServer interface { // Queries a list of RollappPacket items by rollappID. GetPackets(context.Context, *QueryRollappPacketsRequest) (*QueryRollappPacketListResponse, error) // Queries a list of pending RollappPacket items by rollappID and receiver. - GetPendingPacketsByReceiver(context.Context, *QueryPendingPacketsByReceiverRequest) (*QueryPendingPacketByReceiverListResponse, error) + GetPendingPacketsByAddress(context.Context, *QueryPendingPacketsByAddressRequest) (*QueryPendingPacketByAddressListResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -481,8 +473,8 @@ func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsReq func (*UnimplementedQueryServer) GetPackets(ctx context.Context, req *QueryRollappPacketsRequest) (*QueryRollappPacketListResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetPackets not implemented") } -func (*UnimplementedQueryServer) GetPendingPacketsByReceiver(ctx context.Context, req *QueryPendingPacketsByReceiverRequest) (*QueryPendingPacketByReceiverListResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetPendingPacketsByReceiver not implemented") +func (*UnimplementedQueryServer) GetPendingPacketsByAddress(ctx context.Context, req *QueryPendingPacketsByAddressRequest) (*QueryPendingPacketByAddressListResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetPendingPacketsByAddress not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { @@ -525,20 +517,20 @@ func _Query_GetPackets_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } -func _Query_GetPendingPacketsByReceiver_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryPendingPacketsByReceiverRequest) +func _Query_GetPendingPacketsByAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryPendingPacketsByAddressRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).GetPendingPacketsByReceiver(ctx, in) + return srv.(QueryServer).GetPendingPacketsByAddress(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/dymensionxyz.dymension.delayedack.Query/GetPendingPacketsByReceiver", + FullMethod: "/dymensionxyz.dymension.delayedack.Query/GetPendingPacketsByAddress", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetPendingPacketsByReceiver(ctx, req.(*QueryPendingPacketsByReceiverRequest)) + return srv.(QueryServer).GetPendingPacketsByAddress(ctx, req.(*QueryPendingPacketsByAddressRequest)) } return interceptor(ctx, in, info, handler) } @@ -556,8 +548,8 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_GetPackets_Handler, }, { - MethodName: "GetPendingPacketsByReceiver", - Handler: _Query_GetPendingPacketsByReceiver_Handler, + MethodName: "GetPendingPacketsByAddress", + Handler: _Query_GetPendingPacketsByAddress_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -721,7 +713,7 @@ func (m *QueryRollappPacketListResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *QueryPendingPacketsByReceiverRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryPendingPacketsByAddressRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -731,12 +723,12 @@ func (m *QueryPendingPacketsByReceiverRequest) Marshal() (dAtA []byte, err error return dAtA[:n], nil } -func (m *QueryPendingPacketsByReceiverRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPendingPacketsByAddressRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPendingPacketsByReceiverRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPendingPacketsByAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -751,26 +743,19 @@ func (m *QueryPendingPacketsByReceiverRequest) MarshalToSizedBuffer(dAtA []byte) i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - } - if len(m.Receiver) > 0 { - i -= len(m.Receiver) - copy(dAtA[i:], m.Receiver) - i = encodeVarintQuery(dAtA, i, uint64(len(m.Receiver))) - i-- dAtA[i] = 0x12 } - if len(m.RollappId) > 0 { - i -= len(m.RollappId) - copy(dAtA[i:], m.RollappId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.RollappId))) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryPendingPacketByReceiverListResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryPendingPacketByAddressListResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -780,12 +765,12 @@ func (m *QueryPendingPacketByReceiverListResponse) Marshal() (dAtA []byte, err e return dAtA[:n], nil } -func (m *QueryPendingPacketByReceiverListResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryPendingPacketByAddressListResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPendingPacketByReceiverListResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryPendingPacketByAddressListResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -892,17 +877,13 @@ func (m *QueryRollappPacketListResponse) Size() (n int) { return n } -func (m *QueryPendingPacketsByReceiverRequest) Size() (n int) { +func (m *QueryPendingPacketsByAddressRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.RollappId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - l = len(m.Receiver) + l = len(m.Address) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -913,7 +894,7 @@ func (m *QueryPendingPacketsByReceiverRequest) Size() (n int) { return n } -func (m *QueryPendingPacketByReceiverListResponse) Size() (n int) { +func (m *QueryPendingPacketByAddressListResponse) Size() (n int) { if m == nil { return 0 } @@ -1347,7 +1328,7 @@ func (m *QueryRollappPacketListResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPendingPacketsByReceiverRequest) Unmarshal(dAtA []byte) error { +func (m *QueryPendingPacketsByAddressRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1370,15 +1351,15 @@ func (m *QueryPendingPacketsByReceiverRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPendingPacketsByReceiverRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPendingPacketsByAddressRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPendingPacketsByReceiverRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPendingPacketsByAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RollappId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1406,41 +1387,9 @@ func (m *QueryPendingPacketsByReceiverRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.RollappId = string(dAtA[iNdEx:postIndex]) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Receiver", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Receiver = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } @@ -1497,7 +1446,7 @@ func (m *QueryPendingPacketsByReceiverRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPendingPacketByReceiverListResponse) Unmarshal(dAtA []byte) error { +func (m *QueryPendingPacketByAddressListResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1520,10 +1469,10 @@ func (m *QueryPendingPacketByReceiverListResponse) Unmarshal(dAtA []byte) error fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPendingPacketByReceiverListResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryPendingPacketByAddressListResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPendingPacketByReceiverListResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryPendingPacketByAddressListResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/delayedack/types/query.pb.gw.go b/x/delayedack/types/query.pb.gw.go index 2032bdabf..fcd4b965a 100644 --- a/x/delayedack/types/query.pb.gw.go +++ b/x/delayedack/types/query.pb.gw.go @@ -153,11 +153,11 @@ func local_request_Query_GetPackets_0(ctx context.Context, marshaler runtime.Mar } var ( - filter_Query_GetPendingPacketsByReceiver_0 = &utilities.DoubleArray{Encoding: map[string]int{"rollappId": 0, "receiver": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} + filter_Query_GetPendingPacketsByAddress_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) -func request_Query_GetPendingPacketsByReceiver_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPendingPacketsByReceiverRequest +func request_Query_GetPendingPacketsByAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPendingPacketsByAddressRequest var metadata runtime.ServerMetadata var ( @@ -167,42 +167,31 @@ func request_Query_GetPendingPacketsByReceiver_0(ctx context.Context, marshaler _ = err ) - val, ok = pathParams["rollappId"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rollappId") - } - - protoReq.RollappId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rollappId", err) - } - - val, ok = pathParams["receiver"] + val, ok = pathParams["address"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "receiver") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") } - protoReq.Receiver, err = runtime.String(val) + protoReq.Address, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "receiver", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetPendingPacketsByReceiver_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetPendingPacketsByAddress_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.GetPendingPacketsByReceiver(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.GetPendingPacketsByAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_GetPendingPacketsByReceiver_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPendingPacketsByReceiverRequest +func local_request_Query_GetPendingPacketsByAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryPendingPacketsByAddressRequest var metadata runtime.ServerMetadata var ( @@ -212,36 +201,25 @@ func local_request_Query_GetPendingPacketsByReceiver_0(ctx context.Context, mars _ = err ) - val, ok = pathParams["rollappId"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rollappId") - } - - protoReq.RollappId, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rollappId", err) - } - - val, ok = pathParams["receiver"] + val, ok = pathParams["address"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "receiver") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") } - protoReq.Receiver, err = runtime.String(val) + protoReq.Address, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "receiver", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) } if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetPendingPacketsByReceiver_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetPendingPacketsByAddress_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.GetPendingPacketsByReceiver(ctx, &protoReq) + msg, err := server.GetPendingPacketsByAddress(ctx, &protoReq) return msg, metadata, err } @@ -298,7 +276,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_GetPendingPacketsByReceiver_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_GetPendingPacketsByAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -309,7 +287,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_GetPendingPacketsByReceiver_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_GetPendingPacketsByAddress_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -317,7 +295,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_GetPendingPacketsByReceiver_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_GetPendingPacketsByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -402,7 +380,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_GetPendingPacketsByReceiver_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_GetPendingPacketsByAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -411,14 +389,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_GetPendingPacketsByReceiver_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_GetPendingPacketsByAddress_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_GetPendingPacketsByReceiver_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_GetPendingPacketsByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -430,7 +408,7 @@ var ( pattern_Query_GetPackets_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"dymensionxyz", "dymension", "delayedack", "packets", "rollappId", "status"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_GetPendingPacketsByReceiver_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"dymensionxyz", "dymension", "delayedack", "pending-receiver-packets", "rollappId", "receiver"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_GetPendingPacketsByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"dymensionxyz", "dymension", "delayedack", "pending-receiver-packets", "address"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( @@ -438,5 +416,5 @@ var ( forward_Query_GetPackets_0 = runtime.ForwardResponseMessage - forward_Query_GetPendingPacketsByReceiver_0 = runtime.ForwardResponseMessage + forward_Query_GetPendingPacketsByAddress_0 = runtime.ForwardResponseMessage )