From 9a6565cf9d5c736856bd2d28dcdb03318ee5f7a5 Mon Sep 17 00:00:00 2001 From: Eric Warehime Date: Tue, 20 Jan 2026 12:44:23 -0800 Subject: [PATCH] fix: Update iter prefix in rate-limitting reset handler --- CHANGELOG.md | 7 ++++++- modules/apps/rate-limiting/keeper/pending_send.go | 5 ++++- .../apps/rate-limiting/keeper/pending_send_test.go | 12 ++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 169a076fff7..a962768cdae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,12 +37,14 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] ### Features + * [\#8573](https://github.com/cosmos/ibc-go/pull/8573) Support custom address codecs in transfer, PFM, and rate limiting. * [\#8285](https://github.com/cosmos/ibc-go/pull/8285) Packet forward middleware. * [\#8545](https://github.com/cosmos/ibc-go/pull/8545) Support sending multiple payloads in the same packet for atomic payload execution. * [\#8473](https://github.com/cosmos/ibc-go/pull/8473) Support sending v2 packets on v1 channel identifiers using aliasing. ### Improvements + * [\#8734](https://github.com/cosmos/ibc-go/pull/8734) Add extra validation for ProtoJSON unmarshalling in ICS-27 ICA. ### Dependencies @@ -51,6 +53,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (light-clients/08-wasm)[\#8500](https://github.com/cosmos/ibc-go/pull/8500) Bump **github.com/prysmaticlabs/prysm/v5** to **github.com/OffchainLabs/prysm/v6@v6.0.4** ### API Breaking + * (apps) [\#8476](https://github.com/cosmos/ibc-go/pull/8476) Remove `ParamSubspace` from all `Keeper` constructors * (light-clients/08-wasm) [\#8511](https://github.com/cosmos/ibc-go/pull/8511) Remove deprecated `Checksums` type * (core/02-client) [\#8516](https://github.com/cosmos/ibc-go/pull/8516) Remove deprecated `SubmitMisbehaviour` message handler @@ -61,6 +64,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +(apps/rate-limiting) [\#8767](https://github.com/cosmos/ibc-go/pull/8767) Fix string conflict in rate-limiting prefix iterator + ### Testing API * [\#8366](https://github.com/cosmos/ibc-go/pull/8366) - Replaced the deprecated `codec.ProtoMarshaler` interface with `proto.Message`. @@ -87,7 +92,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * (core/api) [\#8303](https://github.com/cosmos/ibc-go/pull/8303) Prefix-based routing in IBCv2 Router -- (apps/callbacks) [\#8353](https://github.com/cosmos/ibc-go/pull/8353) Add field in callbacks data for custom calldata +* (apps/callbacks) [\#8353](https://github.com/cosmos/ibc-go/pull/8353) Add field in callbacks data for custom calldata ### Bug Fixes diff --git a/modules/apps/rate-limiting/keeper/pending_send.go b/modules/apps/rate-limiting/keeper/pending_send.go index 86ac633751e..1066b3e3bb9 100644 --- a/modules/apps/rate-limiting/keeper/pending_send.go +++ b/modules/apps/rate-limiting/keeper/pending_send.go @@ -71,7 +71,10 @@ func (k *Keeper) RemoveAllChannelPendingSendPackets(ctx sdk.Context, channelID s adapter := runtime.KVStoreAdapter(k.storeService.OpenKVStore(ctx)) store := prefix.NewStore(adapter, types.PendingSendPacketPrefix) - iterator := storetypes.KVStorePrefixIterator(store, []byte(channelID)) + channelIDBz := make([]byte, types.PendingSendPacketChannelLength) + copy(channelIDBz, channelID) + + iterator := storetypes.KVStorePrefixIterator(store, channelIDBz) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { diff --git a/modules/apps/rate-limiting/keeper/pending_send_test.go b/modules/apps/rate-limiting/keeper/pending_send_test.go index f5066da5030..9f190d71502 100644 --- a/modules/apps/rate-limiting/keeper/pending_send_test.go +++ b/modules/apps/rate-limiting/keeper/pending_send_test.go @@ -5,7 +5,7 @@ import "fmt" func (s *KeeperTestSuite) TestPendingSendPacketPrefix() { // Store 5 packets across two channels sendPackets := []string{} - for _, channelID := range []string{"channel-0", "channel-1"} { + for _, channelID := range []string{"channel-1", "channel-11"} { for sequence := range uint64(5) { s.chainA.GetSimApp().RateLimitKeeper.SetPendingSendPacket(s.chainA.GetContext(), channelID, sequence) sendPackets = append(sendPackets, fmt.Sprintf("%s/%d", channelID, sequence)) @@ -13,7 +13,7 @@ func (s *KeeperTestSuite) TestPendingSendPacketPrefix() { } // Check that they each sequence number is found - for _, channelID := range []string{"channel-0", "channel-1"} { + for _, channelID := range []string{"channel-1", "channel-11"} { for sequence := range uint64(5) { found := s.chainA.GetSimApp().RateLimitKeeper.CheckPacketSentDuringCurrentQuota(s.chainA.GetContext(), channelID, sequence) s.Require().True(found, "send packet should have been found - channel %s, sequence: %d", channelID, sequence) @@ -25,14 +25,14 @@ func (s *KeeperTestSuite) TestPendingSendPacketPrefix() { s.Require().Equal(sendPackets, actualSendPackets, "all send packets") // Remove 0 sequence numbers and all sequence numbers from channel-0 - s.chainA.GetSimApp().RateLimitKeeper.RemovePendingSendPacket(s.chainA.GetContext(), "channel-0", 0) s.chainA.GetSimApp().RateLimitKeeper.RemovePendingSendPacket(s.chainA.GetContext(), "channel-1", 0) - s.chainA.GetSimApp().RateLimitKeeper.RemoveAllChannelPendingSendPackets(s.chainA.GetContext(), "channel-0") + s.chainA.GetSimApp().RateLimitKeeper.RemovePendingSendPacket(s.chainA.GetContext(), "channel-11", 0) + s.chainA.GetSimApp().RateLimitKeeper.RemoveAllChannelPendingSendPackets(s.chainA.GetContext(), "channel-1") // Check that only the remaining sequences are found - for _, channelID := range []string{"channel-0", "channel-1"} { + for _, channelID := range []string{"channel-1", "channel-11"} { for sequence := range uint64(5) { - expected := (channelID == "channel-1") && (sequence != 0) + expected := (channelID == "channel-11") && (sequence != 0) actual := s.chainA.GetSimApp().RateLimitKeeper.CheckPacketSentDuringCurrentQuota(s.chainA.GetContext(), channelID, sequence) s.Require().Equal(expected, actual, "send packet after removal - channel: %s, sequence: %d", channelID, sequence) }