From 88dbcbcc64480a03e37b75f278907d37c8b3b731 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Thu, 20 Jul 2023 10:40:59 +0700 Subject: [PATCH 01/20] update interchain-test and lint --- proto/centauri/ratelimit/v1beta1/query.proto | 16 +- tests/interchaintest/polkadot_chain_test.go | 8 +- tests/interchaintest/upgrade_chain_test.go | 4 +- x/ratelimit/keeper/abci.go | 2 +- x/ratelimit/keeper/epoch.go | 6 +- x/ratelimit/keeper/genesis.go | 10 +- x/ratelimit/keeper/grpc_query.go | 24 +- x/ratelimit/keeper/keeper.go | 2 +- x/ratelimit/keeper/msg_server.go | 4 +- x/ratelimit/keeper/packet.go | 4 +- x/ratelimit/keeper/rate_limit.go | 80 ++-- x/ratelimit/relay_test.go | 4 +- x/ratelimit/types/epoch.go | 4 +- x/ratelimit/types/errors.go | 2 +- x/ratelimit/types/expected_keepers.go | 4 +- x/ratelimit/types/genesis.go | 2 +- x/ratelimit/types/keys.go | 10 +- x/ratelimit/types/msg.go | 32 +- x/ratelimit/types/query.pb.go | 356 +++++++++--------- x/ratelimit/types/query.pb.gw.go | 64 ++-- x/ratelimit/types/quota.go | 2 +- x/ratelimit/types/ratelimit.pb.go | 20 +- x/ratelimit/types/tx.pb.go | 80 ++-- x/transfermiddleware/client/cli/cli.go | 2 +- x/transfermiddleware/keeper/genesis.go | 2 +- x/transfermiddleware/keeper/genesis_test.go | 12 +- x/transfermiddleware/keeper/grpc_query.go | 4 +- x/transfermiddleware/keeper/ics4wrapper.go | 6 +- x/transfermiddleware/keeper/keeper.go | 4 +- x/transfermiddleware/keeper/msg_server.go | 2 +- x/transfermiddleware/keeper/relay.go | 2 +- x/transfermiddleware/types/genesis_test.go | 8 +- x/transfermiddleware/types/info_test.go | 4 +- x/transfermiddleware/types/msg.go | 6 +- .../types/parachain_token_info.pb.go | 20 +- x/transfermiddleware/types/query.pb.go | 40 +- x/transfermiddleware/types/tx.pb.go | 20 +- 37 files changed, 434 insertions(+), 438 deletions(-) diff --git a/proto/centauri/ratelimit/v1beta1/query.proto b/proto/centauri/ratelimit/v1beta1/query.proto index 7826edc2f..af1f24bfd 100644 --- a/proto/centauri/ratelimit/v1beta1/query.proto +++ b/proto/centauri/ratelimit/v1beta1/query.proto @@ -17,12 +17,12 @@ service Query { option (google.api.http).get = "/centauri/ratelimit/ratelimit/{channel_id}/by_denom"; } - rpc RateLimitsByChainId(QueryRateLimitsByChainIdRequest) - returns (QueryRateLimitsByChainIdResponse) { + rpc RateLimitsByChainID(QueryRateLimitsByChainIDRequest) + returns (QueryRateLimitsByChainIDResponse) { option (google.api.http).get = "/centauri/ratelimit/ratelimits/{chain_id}"; } - rpc RateLimitsByChannelId(QueryRateLimitsByChannelIdRequest) - returns (QueryRateLimitsByChannelIdResponse) { + rpc RateLimitsByChannelID(QueryRateLimitsByChannelIDRequest) + returns (QueryRateLimitsByChannelIDResponse) { option (google.api.http).get = "/centauri/ratelimit/ratelimits/{channel_id}"; } @@ -43,13 +43,13 @@ message QueryRateLimitRequest { } message QueryRateLimitResponse { RateLimit rate_limit = 1; } -message QueryRateLimitsByChainIdRequest { string chain_id = 1; } -message QueryRateLimitsByChainIdResponse { +message QueryRateLimitsByChainIDRequest { string chain_id = 1; } +message QueryRateLimitsByChainIDResponse { repeated RateLimit rate_limits = 1 [ (gogoproto.nullable) = false ]; } -message QueryRateLimitsByChannelIdRequest { string channel_id = 1; } -message QueryRateLimitsByChannelIdResponse { +message QueryRateLimitsByChannelIDRequest { string channel_id = 1; } +message QueryRateLimitsByChannelIDResponse { repeated RateLimit rate_limits = 1 [ (gogoproto.nullable) = false ]; } diff --git a/tests/interchaintest/polkadot_chain_test.go b/tests/interchaintest/polkadot_chain_test.go index f79788371..6022acbb2 100644 --- a/tests/interchaintest/polkadot_chain_test.go +++ b/tests/interchaintest/polkadot_chain_test.go @@ -39,13 +39,13 @@ func TestPolkadotComposableChainStart(t *testing.T) { ChainID: "rococo-local", Images: []ibc.DockerImage{ { - Repository: "seunlanlege/centauri-polkadot", - Version: "v0.9.27", + Repository: "parity/polkadot", + Version: "v0.9.39", UidGid: "1000:1000", }, { - Repository: "seunlanlege/centauri-parachain", - Version: "v0.9.27", + Repository: "composablefi/parachain-node", + Version: "13f3db34-1688755040", // UidGid: "1025:1025", }, }, diff --git a/tests/interchaintest/upgrade_chain_test.go b/tests/interchaintest/upgrade_chain_test.go index 58b6ce4b6..94e26672d 100644 --- a/tests/interchaintest/upgrade_chain_test.go +++ b/tests/interchaintest/upgrade_chain_test.go @@ -20,7 +20,7 @@ const ( func TestCentauriUpgrade(t *testing.T) { repo, version := GetDockerImageInfo() - CosmosChainUpgradeTest(t, repo, version, "reward") + CosmosChainUpgradeTest(t, repo, version, "v4") } func CosmosChainUpgradeTest(t *testing.T, upgradeContainerRepo, upgradeVersion, upgradeName string) { @@ -39,7 +39,7 @@ func CosmosChainUpgradeTest(t *testing.T, upgradeContainerRepo, upgradeVersion, Images: []ibc.DockerImage{ { Repository: "ghcr.io/notional-labs/centauri", - Version: "3.1.2", + Version: "3.2.3", UidGid: "1025:1025", }, }, diff --git a/x/ratelimit/keeper/abci.go b/x/ratelimit/keeper/abci.go index 8e3aace1b..1674ae91c 100644 --- a/x/ratelimit/keeper/abci.go +++ b/x/ratelimit/keeper/abci.go @@ -37,7 +37,7 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { logger.Info(fmt.Sprintf("Starting new epoch with identifier %s epoch number %d", epochInfo.Identifier, epochInfo.CurrentEpoch)) } else { k.AfterEpochEnd(ctx, epochInfo) - epochInfo.CurrentEpoch += 1 + epochInfo.CurrentEpoch++ epochInfo.CurrentEpochStartTime = epochInfo.CurrentEpochStartTime.Add(epochInfo.Duration) logger.Info(fmt.Sprintf("Starting epoch with identifier %s epoch number %d", epochInfo.Identifier, epochInfo.CurrentEpoch)) } diff --git a/x/ratelimit/keeper/epoch.go b/x/ratelimit/keeper/epoch.go index 7b788668f..266adf938 100644 --- a/x/ratelimit/keeper/epoch.go +++ b/x/ratelimit/keeper/epoch.go @@ -117,14 +117,14 @@ func (k Keeper) NumBlocksSinceEpochStart(ctx sdk.Context, identifier string) (in } func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochInfo types.EpochInfo) { - if epochInfo.Identifier == types.DAY_EPOCH { + if epochInfo.Identifier == types.DayEpoch { epochHour := uint64(epochInfo.CurrentEpoch) for _, rateLimit := range k.GetAllRateLimits(ctx) { if epochHour%rateLimit.Quota.DurationHours == 0 { - err := k.ResetRateLimit(ctx, rateLimit.Path.Denom, rateLimit.Path.ChannelId) + err := k.ResetRateLimit(ctx, rateLimit.Path.Denom, rateLimit.Path.ChannelID) if err != nil { - k.Logger(ctx).Error(fmt.Sprintf("Unable to reset quota for Denom: %s, ChannelId: %s", rateLimit.Path.Denom, rateLimit.Path.ChannelId)) + k.Logger(ctx).Error(fmt.Sprintf("Unable to reset quota for Denom: %s, ChannelID: %s", rateLimit.Path.Denom, rateLimit.Path.ChannelID)) } } } diff --git a/x/ratelimit/keeper/genesis.go b/x/ratelimit/keeper/genesis.go index c6da50481..ed894b8b7 100644 --- a/x/ratelimit/keeper/genesis.go +++ b/x/ratelimit/keeper/genesis.go @@ -16,17 +16,17 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { for _, addressPair := range genState.WhitelistedAddressPairs { k.SetWhitelistedAddressPair(ctx, addressPair) } - for _, pendingPacketId := range genState.PendingSendPacketSequenceNumbers { - splits := strings.Split(pendingPacketId, "/") + for _, pendingPacketID := range genState.PendingSendPacketSequenceNumbers { + splits := strings.Split(pendingPacketID, "/") if len(splits) != 2 { - panic("Invalid pending send packet, must be of form: {channelId}/{sequenceNumber}") + panic("Invalid pending send packet, must be of form: {channelID}/{sequenceNumber}") } - channelId := splits[0] + channelID := splits[0] sequence, err := strconv.ParseUint(splits[1], 10, 64) if err != nil { panic(err) } - k.SetPendingSendPacket(ctx, channelId, sequence) + k.SetPendingSendPacket(ctx, channelID, sequence) } for _, epoch := range genState.Epochs { err := k.AddEpochInfo(ctx, epoch) diff --git a/x/ratelimit/keeper/grpc_query.go b/x/ratelimit/keeper/grpc_query.go index 7798e6a40..04d3c77ef 100644 --- a/x/ratelimit/keeper/grpc_query.go +++ b/x/ratelimit/keeper/grpc_query.go @@ -13,16 +13,16 @@ import ( var _ types.QueryServer = Keeper{} // Query all rate limits -func (k Keeper) AllRateLimits(goCtx context.Context, req *types.QueryAllRateLimitsRequest) (*types.QueryAllRateLimitsResponse, error) { +func (k Keeper) AllRateLimits(goCtx context.Context, _ *types.QueryAllRateLimitsRequest) (*types.QueryAllRateLimitsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) rateLimits := k.GetAllRateLimits(ctx) return &types.QueryAllRateLimitsResponse{RateLimits: rateLimits}, nil } -// Query a rate limit by denom and channelId +// Query a rate limit by denom and channelID func (k Keeper) RateLimit(goCtx context.Context, req *types.QueryRateLimitRequest) (*types.QueryRateLimitResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - rateLimit, found := k.GetRateLimit(ctx, req.Denom, req.ChannelId) + rateLimit, found := k.GetRateLimit(ctx, req.Denom, req.ChannelID) if !found { return &types.QueryRateLimitResponse{}, nil } @@ -30,20 +30,20 @@ func (k Keeper) RateLimit(goCtx context.Context, req *types.QueryRateLimitReques } // Query all rate limits for a given chain -func (k Keeper) RateLimitsByChainId(goCtx context.Context, req *types.QueryRateLimitsByChainIdRequest) (*types.QueryRateLimitsByChainIdResponse, error) { +func (k Keeper) RateLimitsByChainID(goCtx context.Context, req *types.QueryRateLimitsByChainIDRequest) (*types.QueryRateLimitsByChainIDResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) rateLimits := []types.RateLimit{} for _, rateLimit := range k.GetAllRateLimits(ctx) { // Determine the client state from the channel Id - _, clientState, err := k.channelKeeper.GetChannelClientState(ctx, transfertypes.PortID, rateLimit.Path.ChannelId) + _, clientState, err := k.channelKeeper.GetChannelClientState(ctx, transfertypes.PortID, rateLimit.Path.ChannelID) if err != nil { - return &types.QueryRateLimitsByChainIdResponse{}, errorsmod.Wrapf(types.ErrInvalidClientState, "Unable to fetch client state from channelId") + return &types.QueryRateLimitsByChainIDResponse{}, errorsmod.Wrapf(types.ErrInvalidClientState, "Unable to fetch client state from channelID") } client, ok := clientState.(*ibctmtypes.ClientState) if !ok { - return &types.QueryRateLimitsByChainIdResponse{}, errorsmod.Wrapf(types.ErrInvalidClientState, "Client state is not tendermint") + return &types.QueryRateLimitsByChainIDResponse{}, errorsmod.Wrapf(types.ErrInvalidClientState, "Client state is not tendermint") } // If the chain ID matches, add the rate limit to the returned list @@ -52,26 +52,26 @@ func (k Keeper) RateLimitsByChainId(goCtx context.Context, req *types.QueryRateL } } - return &types.QueryRateLimitsByChainIdResponse{RateLimits: rateLimits}, nil + return &types.QueryRateLimitsByChainIDResponse{RateLimits: rateLimits}, nil } // Query all rate limits for a given channel -func (k Keeper) RateLimitsByChannelId(goCtx context.Context, req *types.QueryRateLimitsByChannelIdRequest) (*types.QueryRateLimitsByChannelIdResponse, error) { +func (k Keeper) RateLimitsByChannelID(goCtx context.Context, req *types.QueryRateLimitsByChannelIDRequest) (*types.QueryRateLimitsByChannelIDResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) rateLimits := []types.RateLimit{} for _, rateLimit := range k.GetAllRateLimits(ctx) { // If the channel ID matches, add the rate limit to the returned list - if rateLimit.Path.ChannelId == req.ChannelId { + if rateLimit.Path.ChannelID == req.ChannelID { rateLimits = append(rateLimits, rateLimit) } } - return &types.QueryRateLimitsByChannelIdResponse{RateLimits: rateLimits}, nil + return &types.QueryRateLimitsByChannelIDResponse{RateLimits: rateLimits}, nil } // Query all whitelisted addresses -func (k Keeper) AllWhitelistedAddresses(goCtx context.Context, req *types.QueryAllWhitelistedAddressesRequest) (*types.QueryAllWhitelistedAddressesResponse, error) { +func (k Keeper) AllWhitelistedAddresses(goCtx context.Context, _ *types.QueryAllWhitelistedAddressesRequest) (*types.QueryAllWhitelistedAddressesResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) whitelistedAddresses := k.GetAllWhitelistedAddressPairs(ctx) return &types.QueryAllWhitelistedAddressesResponse{AddressPairs: whitelistedAddresses}, nil diff --git a/x/ratelimit/keeper/keeper.go b/x/ratelimit/keeper/keeper.go index 0962b61b5..5f25273dd 100644 --- a/x/ratelimit/keeper/keeper.go +++ b/x/ratelimit/keeper/keeper.go @@ -55,7 +55,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // GetParams get all parameters as types.Params -func (k Keeper) GetParams(ctx sdk.Context) types.Params { +func (k Keeper) GetParams(_ sdk.Context) types.Params { return types.NewParams() } diff --git a/x/ratelimit/keeper/msg_server.go b/x/ratelimit/keeper/msg_server.go index ece478fde..891d8499c 100644 --- a/x/ratelimit/keeper/msg_server.go +++ b/x/ratelimit/keeper/msg_server.go @@ -60,7 +60,7 @@ func (k Keeper) RemoveTransferRateLimit(goCtx context.Context, msg *types.MsgRem return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) } - err := k.RemoveRateLimit(ctx, msg.Denom, msg.ChannelId) + err := k.RemoveRateLimit(ctx, msg.Denom, msg.ChannelID) if err != nil { return nil, err } @@ -75,7 +75,7 @@ func (k Keeper) ResetTransferRateLimit(goCtx context.Context, msg *types.MsgRese return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) } - err := k.ResetRateLimit(ctx, msg.Denom, msg.ChannelId) + err := k.ResetRateLimit(ctx, msg.Denom, msg.ChannelID) if err != nil { return nil, err } diff --git a/x/ratelimit/keeper/packet.go b/x/ratelimit/keeper/packet.go index 3bfca4baa..f6377b58f 100644 --- a/x/ratelimit/keeper/packet.go +++ b/x/ratelimit/keeper/packet.go @@ -110,7 +110,7 @@ func (k Keeper) ParseDenomFromRecvPacket(packet channeltypes.Packet, packetData return denom } -// Parses the sender and channelId and denom for the corresponding RateLimit object, and +// Parses the sender and channelID and denom for the corresponding RateLimit object, and // the sender/receiver/transfer amount // // The Stride channelID should always be used as the key for the RateLimit object (not the counterparty channelID) @@ -190,7 +190,7 @@ func (k Keeper) ReceiveRateLimitedPacket(ctx sdk.Context, packet channeltypes.Pa // Middleware implementation for OnAckPacket with rate limiting // If the packet failed, we should decrement the Outflow func (k Keeper) AcknowledgeRateLimitedPacket(ctx sdk.Context, packet channeltypes.Packet, ack []byte) error { - // Parse the denom, channelId, and amount from the packet + // Parse the denom, channelID, and amount from the packet packetInfo, err := k.ParsePacketInfo(packet, types.PACKET_SEND) if err != nil { return err diff --git a/x/ratelimit/keeper/rate_limit.go b/x/ratelimit/keeper/rate_limit.go index ca3b09c9d..a0c3128f3 100644 --- a/x/ratelimit/keeper/rate_limit.go +++ b/x/ratelimit/keeper/rate_limit.go @@ -13,9 +13,9 @@ import ( "github.com/notional-labs/centauri/v4/x/ratelimit/types" ) -// Get the rate limit byte key built from the denom and channelId -func GetRateLimitItemKey(denom string, channelId string) []byte { - return append(types.KeyPrefix(denom), types.KeyPrefix(channelId)...) +// Get the rate limit byte key built from the denom and channelID +func GetRateLimitItemKey(denom string, channelID string) []byte { + return append(types.KeyPrefix(denom), types.KeyPrefix(channelID)...) } // The total value on a given path (aka, the denominator in the percentage calculation) @@ -25,7 +25,7 @@ func (k Keeper) GetChannelValue(ctx sdk.Context, denom string) math.Int { } // If the rate limit is exceeded or the denom is blacklisted, we emit an event -func EmitTransferDeniedEvent(ctx sdk.Context, reason, denom, channelId string, direction types.PacketDirection, amount math.Int, err error) { +func EmitTransferDeniedEvent(ctx sdk.Context, reason, denom, channelID string, direction types.PacketDirection, amount math.Int, err error) { ctx.EventManager().EmitEvent( sdk.NewEvent( types.EventTransferDenied, @@ -33,7 +33,7 @@ func EmitTransferDeniedEvent(ctx sdk.Context, reason, denom, channelId string, d sdk.NewAttribute(types.AttributeKeyReason, reason), sdk.NewAttribute(types.AttributeKeyAction, strings.ToLower(direction.String())), // packet_send or packet_recv sdk.NewAttribute(types.AttributeKeyDenom, denom), - sdk.NewAttribute(types.AttributeKeyChannel, channelId), + sdk.NewAttribute(types.AttributeKeyChannel, channelID), sdk.NewAttribute(types.AttributeKeyAmount, amount.String()), sdk.NewAttribute(types.AttributeKeyError, err.Error()), ), @@ -60,11 +60,11 @@ func (k Keeper) CheckRateLimitAndUpdateFlow( packetInfo RateLimitedPacketInfo, ) (updatedFlow bool, err error) { denom := packetInfo.Denom - channelId := packetInfo.ChannelID + channelID := packetInfo.ChannelID amount := packetInfo.Amount // If there's no rate limit yet for this denom, no action is necessary - rateLimit, found := k.GetRateLimit(ctx, denom, channelId) + rateLimit, found := k.GetRateLimit(ctx, denom, channelID) if !found { return false, nil } @@ -77,7 +77,7 @@ func (k Keeper) CheckRateLimitAndUpdateFlow( // Update the flow object with the change in amount if err := k.UpdateFlow(rateLimit, direction, amount); err != nil { // If the rate limit was exceeded, emit an event - EmitTransferDeniedEvent(ctx, types.EventRateLimitExceeded, denom, channelId, direction, amount, err) + EmitTransferDeniedEvent(ctx, types.EventRateLimitExceeded, denom, channelID, direction, amount, err) return false, err } // If there's no quota error, update the rate limit object in the store with the new flow @@ -87,19 +87,19 @@ func (k Keeper) CheckRateLimitAndUpdateFlow( } // If a SendPacket fails or times out, undo the outflow increment that happened during the send -func (k Keeper) UndoSendPacket(ctx sdk.Context, channelId string, sequence uint64, denom string, amount math.Int) error { - rateLimit, found := k.GetRateLimit(ctx, denom, channelId) +func (k Keeper) UndoSendPacket(ctx sdk.Context, channelID string, sequence uint64, denom string, amount math.Int) error { + rateLimit, found := k.GetRateLimit(ctx, denom, channelID) if !found { return nil } // If the packet was sent during this quota, decrement the outflow // Otherwise, it can be ignored - if k.CheckPacketSentDuringCurrentQuota(ctx, channelId, sequence) { + if k.CheckPacketSentDuringCurrentQuota(ctx, channelID, sequence) { rateLimit.Flow.Outflow = rateLimit.Flow.Outflow.Sub(amount) k.SetRateLimit(ctx, rateLimit) - k.RemovePendingSendPacket(ctx, channelId, sequence) + k.RemovePendingSendPacket(ctx, channelID, sequence) } return nil @@ -108,15 +108,15 @@ func (k Keeper) UndoSendPacket(ctx sdk.Context, channelId string, sequence uint6 // Reset the rate limit after expiration // The inflow and outflow should get reset to 0, the channelValue should be updated, // and all pending send packet sequence numbers should be removed -func (k Keeper) ResetRateLimit(ctx sdk.Context, denom string, channelId string) error { +func (k Keeper) ResetRateLimit(ctx sdk.Context, denom string, channelID string) error { if k.tfmwKeeper.HasParachainIBCTokenInfoByNativeDenom(ctx, denom) { tokenInfo := k.tfmwKeeper.GetParachainIBCTokenInfoByNativeDenom(ctx, denom) - if channelId == tokenInfo.ChannelId { + if channelID == tokenInfo.ChannelID { denom = tokenInfo.IbcDenom } } - rateLimit, found := k.GetRateLimit(ctx, denom, channelId) + rateLimit, found := k.GetRateLimit(ctx, denom, channelID) if !found { return types.ErrRateLimitNotFound } @@ -129,7 +129,7 @@ func (k Keeper) ResetRateLimit(ctx sdk.Context, denom string, channelId string) rateLimit.Flow = &flow k.SetRateLimit(ctx, rateLimit) - k.RemoveAllChannelPendingSendPackets(ctx, channelId) + k.RemoveAllChannelPendingSendPackets(ctx, channelID) return nil } @@ -137,38 +137,38 @@ func (k Keeper) ResetRateLimit(ctx sdk.Context, denom string, channelId string) func (k Keeper) SetRateLimit(ctx sdk.Context, rateLimit types.RateLimit) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RateLimitKeyPrefix) - rateLimitKey := GetRateLimitItemKey(rateLimit.Path.Denom, rateLimit.Path.ChannelId) + rateLimitKey := GetRateLimitItemKey(rateLimit.Path.Denom, rateLimit.Path.ChannelID) rateLimitValue := k.cdc.MustMarshal(&rateLimit) store.Set(rateLimitKey, rateLimitValue) } // Removes a rate limit object from the store using denom and channel-id -func (k Keeper) RemoveRateLimit(ctx sdk.Context, denom string, channelId string) error { +func (k Keeper) RemoveRateLimit(ctx sdk.Context, denom string, channelID string) error { if k.tfmwKeeper.HasParachainIBCTokenInfoByNativeDenom(ctx, denom) { tokenInfo := k.tfmwKeeper.GetParachainIBCTokenInfoByNativeDenom(ctx, denom) - if channelId == tokenInfo.ChannelId { + if channelID == tokenInfo.ChannelID { denom = tokenInfo.IbcDenom } } - _, found := k.GetRateLimit(ctx, denom, channelId) + _, found := k.GetRateLimit(ctx, denom, channelID) if !found { return types.ErrRateLimitNotFound } store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RateLimitKeyPrefix) - rateLimitKey := GetRateLimitItemKey(denom, channelId) + rateLimitKey := GetRateLimitItemKey(denom, channelID) store.Delete(rateLimitKey) return nil } // Grabs and returns a rate limit object from the store using denom and channel-id -func (k Keeper) GetRateLimit(ctx sdk.Context, denom string, channelId string) (rateLimit types.RateLimit, found bool) { +func (k Keeper) GetRateLimit(ctx sdk.Context, denom string, channelID string) (rateLimit types.RateLimit, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RateLimitKeyPrefix) - rateLimitKey := GetRateLimitItemKey(denom, channelId) + rateLimitKey := GetRateLimitItemKey(denom, channelID) rateLimitValue := store.Get(rateLimitKey) if len(rateLimitValue) == 0 { @@ -185,7 +185,7 @@ func (k Keeper) AddRateLimit(ctx sdk.Context, msg *types.MsgAddRateLimit) error denom := msg.Denom if k.tfmwKeeper.HasParachainIBCTokenInfoByNativeDenom(ctx, denom) { tokenInfo := k.tfmwKeeper.GetParachainIBCTokenInfoByNativeDenom(ctx, denom) - if msg.ChannelId == tokenInfo.ChannelId { + if msg.ChannelID == tokenInfo.ChannelID { denom = tokenInfo.IbcDenom } } @@ -196,7 +196,7 @@ func (k Keeper) AddRateLimit(ctx sdk.Context, msg *types.MsgAddRateLimit) error } // Confirm the rate limit does not already exist - _, found := k.GetRateLimit(ctx, denom, msg.ChannelId) + _, found := k.GetRateLimit(ctx, denom, msg.ChannelID) if found { return errorsmod.Wrap(types.ErrRateLimitAlreadyExists, "rate limit already exists") } @@ -204,7 +204,7 @@ func (k Keeper) AddRateLimit(ctx sdk.Context, msg *types.MsgAddRateLimit) error // Create and store the rate limit object path := types.Path{ Denom: denom, - ChannelId: msg.ChannelId, + ChannelID: msg.ChannelID, } quota := types.Quota{ MaxPercentSend: msg.MaxPercentSend, @@ -232,13 +232,13 @@ func (k Keeper) UpdateRateLimit(ctx sdk.Context, msg *types.MsgUpdateRateLimit) denom := msg.Denom if k.tfmwKeeper.HasParachainIBCTokenInfoByNativeDenom(ctx, denom) { tokenInfo := k.tfmwKeeper.GetParachainIBCTokenInfoByNativeDenom(ctx, denom) - if msg.ChannelId == tokenInfo.ChannelId { + if msg.ChannelID == tokenInfo.ChannelID { denom = tokenInfo.IbcDenom } } // Confirm the rate limit exists - _, found := k.GetRateLimit(ctx, denom, msg.ChannelId) + _, found := k.GetRateLimit(ctx, denom, msg.ChannelID) if !found { return errorsmod.Wrap(types.ErrRateLimitNotFound, "rate limit not found") } @@ -247,7 +247,7 @@ func (k Keeper) UpdateRateLimit(ctx sdk.Context, msg *types.MsgUpdateRateLimit) // The flow should also get reset to 0 path := types.Path{ Denom: denom, - ChannelId: msg.ChannelId, + ChannelID: msg.ChannelID, } quota := types.Quota{ MaxPercentSend: msg.MaxPercentSend, @@ -288,25 +288,25 @@ func (k Keeper) GetAllRateLimits(ctx sdk.Context) []types.RateLimit { } // Sets the sequence number of a packet that was just sent -func (k Keeper) SetPendingSendPacket(ctx sdk.Context, channelId string, sequence uint64) { +func (k Keeper) SetPendingSendPacket(ctx sdk.Context, channelID string, sequence uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PendingSendPacketPrefix) - key := types.GetPendingSendPacketKey(channelId, sequence) + key := types.GetPendingSendPacketKey(channelID, sequence) store.Set(key, []byte{1}) } // Remove a pending packet sequence number from the store // Used after the ack or timeout for a packet has been received -func (k Keeper) RemovePendingSendPacket(ctx sdk.Context, channelId string, sequence uint64) { +func (k Keeper) RemovePendingSendPacket(ctx sdk.Context, channelID string, sequence uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PendingSendPacketPrefix) - key := types.GetPendingSendPacketKey(channelId, sequence) + key := types.GetPendingSendPacketKey(channelID, sequence) store.Delete(key) } // Checks whether the packet sequence number is in the store - indicating that it was // sent during the current quota -func (k Keeper) CheckPacketSentDuringCurrentQuota(ctx sdk.Context, channelId string, sequence uint64) bool { +func (k Keeper) CheckPacketSentDuringCurrentQuota(ctx sdk.Context, channelID string, sequence uint64) bool { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PendingSendPacketPrefix) - key := types.GetPendingSendPacketKey(channelId, sequence) + key := types.GetPendingSendPacketKey(channelID, sequence) valueBz := store.Get(key) found := len(valueBz) != 0 return found @@ -323,11 +323,11 @@ func (k Keeper) GetAllPendingSendPackets(ctx sdk.Context) []string { for ; iterator.Valid(); iterator.Next() { key := iterator.Key() - channelId := string(key[:types.PendingSendPacketChannelLength]) - channelId = strings.TrimRight(channelId, "\x00") // removes null bytes from suffix + channelID := string(key[:types.PendingSendPacketChannelLength]) + channelID = strings.TrimRight(channelID, "\x00") // removes null bytes from suffix sequence := binary.BigEndian.Uint64(key[types.PendingSendPacketChannelLength:]) - packetId := fmt.Sprintf("%s/%d", channelId, sequence) + packetId := fmt.Sprintf("%s/%d", channelID, sequence) pendingPackets = append(pendingPackets, packetId) } @@ -336,10 +336,10 @@ func (k Keeper) GetAllPendingSendPackets(ctx sdk.Context) []string { // Remove all pending sequence numbers from the store // This is executed when the quota resets -func (k Keeper) RemoveAllChannelPendingSendPackets(ctx sdk.Context, channelId string) { +func (k Keeper) RemoveAllChannelPendingSendPackets(ctx sdk.Context, channelID string) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.PendingSendPacketPrefix) - iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefix(channelId)) + iterator := sdk.KVStorePrefixIterator(store, types.KeyPrefix(channelID)) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { diff --git a/x/ratelimit/relay_test.go b/x/ratelimit/relay_test.go index 50d9ec1b4..55ae69fef 100644 --- a/x/ratelimit/relay_test.go +++ b/x/ratelimit/relay_test.go @@ -99,7 +99,7 @@ func (suite *RateLimitTestSuite) TestReceiveIBCToken() { chainBRateLimitKeeper := suite.chainB.RateLimit() msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ Denom: nativeDenom, - ChannelId: path.EndpointB.ChannelID, + ChannelID: path.EndpointB.ChannelID, MaxPercentSend: sdk.NewInt(5), MaxPercentRecv: sdk.NewInt(5), DurationHours: 1, @@ -210,7 +210,7 @@ func (suite *RateLimitTestSuite) TestSendIBCToken() { chainBRateLimitKeeper := suite.chainB.RateLimit() msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ Denom: nativeDenom, - ChannelId: path.EndpointB.ChannelID, + ChannelID: path.EndpointB.ChannelID, MaxPercentSend: sdk.NewInt(5), MaxPercentRecv: sdk.NewInt(5), DurationHours: 1, diff --git a/x/ratelimit/types/epoch.go b/x/ratelimit/types/epoch.go index 6ad9be68b..185b90b31 100644 --- a/x/ratelimit/types/epoch.go +++ b/x/ratelimit/types/epoch.go @@ -6,8 +6,8 @@ import ( ) var ( - DAY_EPOCH = "hour" - EpochHourPeriod time.Duration = time.Hour * 24 + DayEpoch = "hour" + EpochHourPeriod time.Duration = 24 * time.Hour ) // Validate also validates epoch info. diff --git a/x/ratelimit/types/errors.go b/x/ratelimit/types/errors.go index c362de065..0e21c7d30 100644 --- a/x/ratelimit/types/errors.go +++ b/x/ratelimit/types/errors.go @@ -10,7 +10,7 @@ var ( ErrRateLimitNotFound = errorsmod.Register(ModuleName, 2, "rate limit not found") ErrZeroChannelValue = errorsmod.Register(ModuleName, 3, "channel value is zero") ErrQuotaExceeded = errorsmod.Register(ModuleName, 4, "quota exceeded") - ErrInvalidClientState = errorsmod.Register(ModuleName, 5, "unable to determine client state from channelId") + ErrInvalidClientState = errorsmod.Register(ModuleName, 5, "unable to determine client state from channelID") ErrChannelNotFound = errorsmod.Register(ModuleName, 6, "channel does not exist") ErrDenomIsBlacklisted = errorsmod.Register(ModuleName, 7, "denom is blacklisted") ) diff --git a/x/ratelimit/types/expected_keepers.go b/x/ratelimit/types/expected_keepers.go index e1f5bd29a..96e72013f 100644 --- a/x/ratelimit/types/expected_keepers.go +++ b/x/ratelimit/types/expected_keepers.go @@ -15,6 +15,6 @@ type BankKeeper interface { // ChannelKeeper defines the channel contract that must be fulfilled when // creating a x/ratelimit keeper. type ChannelKeeper interface { - GetChannel(ctx sdk.Context, portID string, channelID string) (channeltypes.Channel, bool) - GetChannelClientState(ctx sdk.Context, portID string, channelID string) (string, exported.ClientState, error) + GetChannel(ctx sdk.Context, portID, channelID string) (channeltypes.Channel, bool) + GetChannelClientState(ctx sdk.Context, portID, channelID string) (string, exported.ClientState, error) } diff --git a/x/ratelimit/types/genesis.go b/x/ratelimit/types/genesis.go index ca95a8d53..a6dc8ef42 100644 --- a/x/ratelimit/types/genesis.go +++ b/x/ratelimit/types/genesis.go @@ -5,7 +5,7 @@ func DefaultGenesisState() *GenesisState { return &GenesisState{ Params: DefaultParams(), RateLimits: []RateLimit{}, - Epochs: []EpochInfo{NewGenesisEpochInfo(DAY_EPOCH, EpochHourPeriod)}, + Epochs: []EpochInfo{NewGenesisEpochInfo(DayEpoch, EpochHourPeriod)}, } } diff --git a/x/ratelimit/types/keys.go b/x/ratelimit/types/keys.go index 246dcc301..cdc6996ea 100644 --- a/x/ratelimit/types/keys.go +++ b/x/ratelimit/types/keys.go @@ -27,17 +27,17 @@ var ( AddressWhitelistKeyPrefix = KeyPrefix("address-blacklist") EpochKeyPrefix = KeyPrefix("epoch") - PendingSendPacketChannelLength int = 16 + PendingSendPacketChannelLength = 16 ) -func GetPendingSendPacketKey(channelId string, sequenceNumber uint64) []byte { - channelIdBz := make([]byte, PendingSendPacketChannelLength) - copy(channelIdBz[:], channelId) +func GetPendingSendPacketKey(channelID string, sequenceNumber uint64) []byte { + channelIDBz := make([]byte, PendingSendPacketChannelLength) + copy(channelIDBz, channelID) sequenceNumberBz := make([]byte, 8) binary.BigEndian.PutUint64(sequenceNumberBz, sequenceNumber) - return append(channelIdBz, sequenceNumberBz...) + return append(channelIDBz, sequenceNumberBz...) } func GetAddressWhitelistKey(sender, receiver string) []byte { diff --git a/x/ratelimit/types/msg.go b/x/ratelimit/types/msg.go index caaaf77d6..d9e6b506a 100644 --- a/x/ratelimit/types/msg.go +++ b/x/ratelimit/types/msg.go @@ -28,7 +28,7 @@ func NewMsgAddRateLimit( return &MsgAddRateLimit{ Authority: authority, Denom: denom, - ChannelId: channelID, + ChannelID: channelID, MaxPercentSend: maxPercentSend, MaxPercentRecv: maxPercentRecv, DurationHours: durationHours, @@ -59,8 +59,8 @@ func (msg *MsgAddRateLimit) ValidateBasic() error { return errorsmod.Wrap(err, "invalid authority address") } - // validate channelIds - if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { + // validate channelIDs + if err := host.ChannelIdentifierValidator(msg.ChannelID); err != nil { return err } @@ -96,7 +96,7 @@ func NewMsgUpdateRateLimit( return &MsgUpdateRateLimit{ Authority: authority, Denom: denom, - ChannelId: channelID, + ChannelID: channelID, MaxPercentSend: maxPercentSend, MaxPercentRecv: maxPercentRecv, DurationHours: durationHours, @@ -127,8 +127,8 @@ func (msg *MsgUpdateRateLimit) ValidateBasic() error { return errorsmod.Wrap(err, "invalid authority address") } - // validate channelIds - if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { + // validate channelIDs + if err := host.ChannelIdentifierValidator(msg.ChannelID); err != nil { return err } @@ -161,7 +161,7 @@ func NewMsgRemoveRateLimit( return &MsgRemoveRateLimit{ Authority: authority, Denom: denom, - ChannelId: channelID, + ChannelID: channelID, } } @@ -189,12 +189,10 @@ func (msg *MsgRemoveRateLimit) ValidateBasic() error { return errorsmod.Wrap(err, "invalid authority address") } - // validate channelIds - if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { - return err - } + // validate channelIDs + err := host.ChannelIdentifierValidator(msg.ChannelID) - return nil + return err } var _ sdk.Msg = &MsgResetRateLimit{} @@ -207,7 +205,7 @@ func NewMsgResetRateLimit( return &MsgResetRateLimit{ Authority: authority, Denom: denom, - ChannelId: channelID, + ChannelID: channelID, } } @@ -235,10 +233,8 @@ func (msg *MsgResetRateLimit) ValidateBasic() error { return errorsmod.Wrap(err, "invalid authority address") } - // validate channelIds - if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { - return err - } + // validate channelIDs + err := host.ChannelIdentifierValidator(msg.ChannelID) - return nil + return err } diff --git a/x/ratelimit/types/query.pb.go b/x/ratelimit/types/query.pb.go index 9c9dcb3d8..e78b01bde 100644 --- a/x/ratelimit/types/query.pb.go +++ b/x/ratelimit/types/query.pb.go @@ -111,7 +111,7 @@ func (m *QueryAllRateLimitsResponse) GetRateLimits() []RateLimit { type QueryRateLimitRequest struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty"` } func (m *QueryRateLimitRequest) Reset() { *m = QueryRateLimitRequest{} } @@ -154,9 +154,9 @@ func (m *QueryRateLimitRequest) GetDenom() string { return "" } -func (m *QueryRateLimitRequest) GetChannelId() string { +func (m *QueryRateLimitRequest) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } @@ -205,22 +205,22 @@ func (m *QueryRateLimitResponse) GetRateLimit() *RateLimit { return nil } -type QueryRateLimitsByChainIdRequest struct { +type QueryRateLimitsByChainIDRequest struct { ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` } -func (m *QueryRateLimitsByChainIdRequest) Reset() { *m = QueryRateLimitsByChainIdRequest{} } -func (m *QueryRateLimitsByChainIdRequest) String() string { return proto.CompactTextString(m) } -func (*QueryRateLimitsByChainIdRequest) ProtoMessage() {} -func (*QueryRateLimitsByChainIdRequest) Descriptor() ([]byte, []int) { +func (m *QueryRateLimitsByChainIDRequest) Reset() { *m = QueryRateLimitsByChainIDRequest{} } +func (m *QueryRateLimitsByChainIDRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRateLimitsByChainIDRequest) ProtoMessage() {} +func (*QueryRateLimitsByChainIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor_b0fc123b957ea496, []int{4} } -func (m *QueryRateLimitsByChainIdRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryRateLimitsByChainIDRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryRateLimitsByChainIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryRateLimitsByChainIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryRateLimitsByChainIdRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryRateLimitsByChainIDRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -230,41 +230,41 @@ func (m *QueryRateLimitsByChainIdRequest) XXX_Marshal(b []byte, deterministic bo return b[:n], nil } } -func (m *QueryRateLimitsByChainIdRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryRateLimitsByChainIdRequest.Merge(m, src) +func (m *QueryRateLimitsByChainIDRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRateLimitsByChainIDRequest.Merge(m, src) } -func (m *QueryRateLimitsByChainIdRequest) XXX_Size() int { +func (m *QueryRateLimitsByChainIDRequest) XXX_Size() int { return m.Size() } -func (m *QueryRateLimitsByChainIdRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryRateLimitsByChainIdRequest.DiscardUnknown(m) +func (m *QueryRateLimitsByChainIDRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRateLimitsByChainIDRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryRateLimitsByChainIdRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryRateLimitsByChainIDRequest proto.InternalMessageInfo -func (m *QueryRateLimitsByChainIdRequest) GetChainId() string { +func (m *QueryRateLimitsByChainIDRequest) GetChainId() string { if m != nil { return m.ChainId } return "" } -type QueryRateLimitsByChainIdResponse struct { +type QueryRateLimitsByChainIDResponse struct { RateLimits []RateLimit `protobuf:"bytes,1,rep,name=rate_limits,json=rateLimits,proto3" json:"rate_limits"` } -func (m *QueryRateLimitsByChainIdResponse) Reset() { *m = QueryRateLimitsByChainIdResponse{} } -func (m *QueryRateLimitsByChainIdResponse) String() string { return proto.CompactTextString(m) } -func (*QueryRateLimitsByChainIdResponse) ProtoMessage() {} -func (*QueryRateLimitsByChainIdResponse) Descriptor() ([]byte, []int) { +func (m *QueryRateLimitsByChainIDResponse) Reset() { *m = QueryRateLimitsByChainIDResponse{} } +func (m *QueryRateLimitsByChainIDResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRateLimitsByChainIDResponse) ProtoMessage() {} +func (*QueryRateLimitsByChainIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor_b0fc123b957ea496, []int{5} } -func (m *QueryRateLimitsByChainIdResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryRateLimitsByChainIDResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryRateLimitsByChainIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryRateLimitsByChainIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryRateLimitsByChainIdResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryRateLimitsByChainIDResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -274,41 +274,41 @@ func (m *QueryRateLimitsByChainIdResponse) XXX_Marshal(b []byte, deterministic b return b[:n], nil } } -func (m *QueryRateLimitsByChainIdResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryRateLimitsByChainIdResponse.Merge(m, src) +func (m *QueryRateLimitsByChainIDResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRateLimitsByChainIDResponse.Merge(m, src) } -func (m *QueryRateLimitsByChainIdResponse) XXX_Size() int { +func (m *QueryRateLimitsByChainIDResponse) XXX_Size() int { return m.Size() } -func (m *QueryRateLimitsByChainIdResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryRateLimitsByChainIdResponse.DiscardUnknown(m) +func (m *QueryRateLimitsByChainIDResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRateLimitsByChainIDResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryRateLimitsByChainIdResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryRateLimitsByChainIDResponse proto.InternalMessageInfo -func (m *QueryRateLimitsByChainIdResponse) GetRateLimits() []RateLimit { +func (m *QueryRateLimitsByChainIDResponse) GetRateLimits() []RateLimit { if m != nil { return m.RateLimits } return nil } -type QueryRateLimitsByChannelIdRequest struct { - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` +type QueryRateLimitsByChannelIDRequest struct { + ChannelID string `protobuf:"bytes,1,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty"` } -func (m *QueryRateLimitsByChannelIdRequest) Reset() { *m = QueryRateLimitsByChannelIdRequest{} } -func (m *QueryRateLimitsByChannelIdRequest) String() string { return proto.CompactTextString(m) } -func (*QueryRateLimitsByChannelIdRequest) ProtoMessage() {} -func (*QueryRateLimitsByChannelIdRequest) Descriptor() ([]byte, []int) { +func (m *QueryRateLimitsByChannelIDRequest) Reset() { *m = QueryRateLimitsByChannelIDRequest{} } +func (m *QueryRateLimitsByChannelIDRequest) String() string { return proto.CompactTextString(m) } +func (*QueryRateLimitsByChannelIDRequest) ProtoMessage() {} +func (*QueryRateLimitsByChannelIDRequest) Descriptor() ([]byte, []int) { return fileDescriptor_b0fc123b957ea496, []int{6} } -func (m *QueryRateLimitsByChannelIdRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryRateLimitsByChannelIDRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryRateLimitsByChannelIdRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryRateLimitsByChannelIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryRateLimitsByChannelIdRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryRateLimitsByChannelIDRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -318,41 +318,41 @@ func (m *QueryRateLimitsByChannelIdRequest) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *QueryRateLimitsByChannelIdRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryRateLimitsByChannelIdRequest.Merge(m, src) +func (m *QueryRateLimitsByChannelIDRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRateLimitsByChannelIDRequest.Merge(m, src) } -func (m *QueryRateLimitsByChannelIdRequest) XXX_Size() int { +func (m *QueryRateLimitsByChannelIDRequest) XXX_Size() int { return m.Size() } -func (m *QueryRateLimitsByChannelIdRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryRateLimitsByChannelIdRequest.DiscardUnknown(m) +func (m *QueryRateLimitsByChannelIDRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRateLimitsByChannelIDRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryRateLimitsByChannelIdRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryRateLimitsByChannelIDRequest proto.InternalMessageInfo -func (m *QueryRateLimitsByChannelIdRequest) GetChannelId() string { +func (m *QueryRateLimitsByChannelIDRequest) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } -type QueryRateLimitsByChannelIdResponse struct { +type QueryRateLimitsByChannelIDResponse struct { RateLimits []RateLimit `protobuf:"bytes,1,rep,name=rate_limits,json=rateLimits,proto3" json:"rate_limits"` } -func (m *QueryRateLimitsByChannelIdResponse) Reset() { *m = QueryRateLimitsByChannelIdResponse{} } -func (m *QueryRateLimitsByChannelIdResponse) String() string { return proto.CompactTextString(m) } -func (*QueryRateLimitsByChannelIdResponse) ProtoMessage() {} -func (*QueryRateLimitsByChannelIdResponse) Descriptor() ([]byte, []int) { +func (m *QueryRateLimitsByChannelIDResponse) Reset() { *m = QueryRateLimitsByChannelIDResponse{} } +func (m *QueryRateLimitsByChannelIDResponse) String() string { return proto.CompactTextString(m) } +func (*QueryRateLimitsByChannelIDResponse) ProtoMessage() {} +func (*QueryRateLimitsByChannelIDResponse) Descriptor() ([]byte, []int) { return fileDescriptor_b0fc123b957ea496, []int{7} } -func (m *QueryRateLimitsByChannelIdResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryRateLimitsByChannelIDResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryRateLimitsByChannelIdResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryRateLimitsByChannelIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryRateLimitsByChannelIdResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryRateLimitsByChannelIDResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -362,19 +362,19 @@ func (m *QueryRateLimitsByChannelIdResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *QueryRateLimitsByChannelIdResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryRateLimitsByChannelIdResponse.Merge(m, src) +func (m *QueryRateLimitsByChannelIDResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryRateLimitsByChannelIDResponse.Merge(m, src) } -func (m *QueryRateLimitsByChannelIdResponse) XXX_Size() int { +func (m *QueryRateLimitsByChannelIDResponse) XXX_Size() int { return m.Size() } -func (m *QueryRateLimitsByChannelIdResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryRateLimitsByChannelIdResponse.DiscardUnknown(m) +func (m *QueryRateLimitsByChannelIDResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryRateLimitsByChannelIDResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryRateLimitsByChannelIdResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryRateLimitsByChannelIDResponse proto.InternalMessageInfo -func (m *QueryRateLimitsByChannelIdResponse) GetRateLimits() []RateLimit { +func (m *QueryRateLimitsByChannelIDResponse) GetRateLimits() []RateLimit { if m != nil { return m.RateLimits } @@ -466,10 +466,10 @@ func init() { proto.RegisterType((*QueryAllRateLimitsResponse)(nil), "centauri.ratelimit.v1beta1.QueryAllRateLimitsResponse") proto.RegisterType((*QueryRateLimitRequest)(nil), "centauri.ratelimit.v1beta1.QueryRateLimitRequest") proto.RegisterType((*QueryRateLimitResponse)(nil), "centauri.ratelimit.v1beta1.QueryRateLimitResponse") - proto.RegisterType((*QueryRateLimitsByChainIdRequest)(nil), "centauri.ratelimit.v1beta1.QueryRateLimitsByChainIdRequest") - proto.RegisterType((*QueryRateLimitsByChainIdResponse)(nil), "centauri.ratelimit.v1beta1.QueryRateLimitsByChainIdResponse") - proto.RegisterType((*QueryRateLimitsByChannelIdRequest)(nil), "centauri.ratelimit.v1beta1.QueryRateLimitsByChannelIdRequest") - proto.RegisterType((*QueryRateLimitsByChannelIdResponse)(nil), "centauri.ratelimit.v1beta1.QueryRateLimitsByChannelIdResponse") + proto.RegisterType((*QueryRateLimitsByChainIDRequest)(nil), "centauri.ratelimit.v1beta1.QueryRateLimitsByChainIDRequest") + proto.RegisterType((*QueryRateLimitsByChainIDResponse)(nil), "centauri.ratelimit.v1beta1.QueryRateLimitsByChainIDResponse") + proto.RegisterType((*QueryRateLimitsByChannelIDRequest)(nil), "centauri.ratelimit.v1beta1.QueryRateLimitsByChannelIDRequest") + proto.RegisterType((*QueryRateLimitsByChannelIDResponse)(nil), "centauri.ratelimit.v1beta1.QueryRateLimitsByChannelIDResponse") proto.RegisterType((*QueryAllWhitelistedAddressesRequest)(nil), "centauri.ratelimit.v1beta1.QueryAllWhitelistedAddressesRequest") proto.RegisterType((*QueryAllWhitelistedAddressesResponse)(nil), "centauri.ratelimit.v1beta1.QueryAllWhitelistedAddressesResponse") } @@ -479,46 +479,46 @@ func init() { } var fileDescriptor_b0fc123b957ea496 = []byte{ - // 612 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x4f, 0x6f, 0x12, 0x41, - 0x18, 0xc6, 0x99, 0x6a, 0xad, 0xbc, 0xb5, 0x07, 0xc7, 0x56, 0xe9, 0xaa, 0x5b, 0x5c, 0x6d, 0x53, - 0x25, 0xb2, 0x01, 0x52, 0x2f, 0xad, 0x7f, 0x8a, 0x5e, 0x9a, 0x70, 0x50, 0x2e, 0x26, 0x26, 0x4a, - 0x06, 0x76, 0x02, 0x6b, 0xe8, 0xce, 0x76, 0x67, 0x50, 0x89, 0xe9, 0xc5, 0xc4, 0xbb, 0x89, 0xdf, - 0xc1, 0xab, 0x1f, 0xc2, 0x0b, 0x89, 0x07, 0x9b, 0x78, 0xf1, 0x64, 0x0c, 0xf8, 0x41, 0xcc, 0xce, - 0xce, 0x2e, 0x42, 0x61, 0x0b, 0x24, 0xbd, 0x2d, 0x33, 0xef, 0xf3, 0xcc, 0xef, 0x7d, 0x77, 0x9e, - 0x05, 0x36, 0x6a, 0xd4, 0x11, 0xa4, 0xe5, 0xd9, 0xa6, 0x47, 0x04, 0x6d, 0xda, 0xfb, 0xb6, 0x30, - 0xdf, 0xe4, 0xaa, 0x54, 0x90, 0x9c, 0x79, 0xd0, 0xa2, 0x5e, 0x3b, 0xeb, 0x7a, 0x4c, 0x30, 0xac, - 0x85, 0x75, 0xd9, 0xa8, 0x2e, 0xab, 0xea, 0xb4, 0x3b, 0x31, 0x1e, 0xfd, 0x6a, 0xe9, 0xa3, 0x5d, + // 613 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x95, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0xeb, 0xc1, 0x18, 0x7d, 0xc7, 0x0e, 0x98, 0x0d, 0xb6, 0x00, 0x59, 0x09, 0x6c, 0x1a, + 0x54, 0x34, 0x6a, 0xab, 0x71, 0xd9, 0xf8, 0xb3, 0xb2, 0x4b, 0xa5, 0x1e, 0xa0, 0x17, 0x24, 0x24, + 0xa8, 0xdc, 0xc6, 0x6a, 0x83, 0xba, 0x38, 0x8b, 0x5d, 0xa0, 0x42, 0xbb, 0x20, 0x71, 0x47, 0xe2, + 0x3b, 0x70, 0xe5, 0x43, 0x70, 0xa9, 0xc4, 0x81, 0x49, 0x5c, 0x38, 0x21, 0xd4, 0xf2, 0x41, 0x50, + 0x1c, 0x27, 0xa5, 0x5d, 0x1b, 0xda, 0x4a, 0xbb, 0x39, 0xf6, 0xfb, 0x3c, 0xfe, 0xbd, 0x8e, 0x9f, + 0x04, 0x36, 0x6b, 0xd4, 0x11, 0xa4, 0xe5, 0xd9, 0xa6, 0x47, 0x04, 0x6d, 0xda, 0x07, 0xb6, 0x30, + 0x5f, 0x67, 0xab, 0x54, 0x90, 0xac, 0x79, 0xd8, 0xa2, 0x5e, 0x3b, 0xe3, 0x7a, 0x4c, 0x30, 0xac, + 0x85, 0x75, 0x99, 0xa8, 0x2e, 0xa3, 0xea, 0xb4, 0x3b, 0x31, 0x1e, 0xfd, 0x6a, 0xe9, 0xa3, 0x5d, 0xab, 0x33, 0x56, 0x6f, 0x52, 0x93, 0xb8, 0xb6, 0x49, 0x1c, 0x87, 0x09, 0x22, 0x6c, 0xe6, 0x70, - 0xb5, 0xbb, 0x5c, 0x67, 0x75, 0x26, 0x1f, 0x4d, 0xff, 0x29, 0x58, 0x35, 0xae, 0xc2, 0xea, 0x33, - 0x1f, 0x65, 0xb7, 0xd9, 0x2c, 0x13, 0x41, 0x4b, 0xbe, 0x1d, 0x2f, 0xd3, 0x83, 0x16, 0xe5, 0xc2, - 0x78, 0x0d, 0xda, 0xa8, 0x4d, 0xee, 0x32, 0x87, 0x53, 0x5c, 0x82, 0x45, 0x9f, 0xa0, 0x22, 0x11, - 0x78, 0x0a, 0xa5, 0xcf, 0x6c, 0x2e, 0xe6, 0xd7, 0xb3, 0xe3, 0x9b, 0xc9, 0x46, 0x26, 0xc5, 0xb3, - 0x9d, 0xdf, 0x6b, 0x89, 0x32, 0x78, 0x91, 0xab, 0x51, 0x82, 0x15, 0x79, 0x56, 0x54, 0xa3, 0x20, - 0xf0, 0x32, 0xcc, 0x5b, 0xd4, 0x61, 0xfb, 0x29, 0x94, 0x46, 0x9b, 0xc9, 0x72, 0xf0, 0x03, 0x5f, - 0x07, 0xa8, 0x35, 0x88, 0xe3, 0xd0, 0x66, 0xc5, 0xb6, 0x52, 0x73, 0x72, 0x2b, 0xa9, 0x56, 0xf6, - 0x2c, 0xe3, 0x15, 0x5c, 0x1e, 0x76, 0x53, 0xd4, 0x4f, 0x00, 0xfa, 0xd4, 0xd2, 0x73, 0x52, 0xe8, - 0x72, 0x32, 0xc2, 0x35, 0x76, 0x60, 0x6d, 0xd0, 0x9f, 0x17, 0xdb, 0x8f, 0x1b, 0xc4, 0x76, 0xf6, - 0xac, 0x90, 0x7b, 0x15, 0xce, 0xd7, 0xfc, 0x15, 0x9f, 0x2f, 0x40, 0x5f, 0xa8, 0x05, 0x15, 0x86, - 0x0b, 0xe9, 0xf1, 0xea, 0x53, 0x99, 0x6e, 0x11, 0x6e, 0x8c, 0x3a, 0x31, 0x98, 0x56, 0x48, 0x3c, - 0x38, 0x53, 0x34, 0x3c, 0x53, 0x0f, 0x8c, 0x38, 0x8f, 0x53, 0xe1, 0x5e, 0x87, 0x9b, 0xe1, 0x0d, - 0x7c, 0xde, 0xb0, 0x7d, 0x25, 0x17, 0xd4, 0xda, 0xb5, 0x2c, 0x8f, 0x72, 0x4e, 0xa3, 0x8b, 0xfa, - 0x11, 0xc1, 0xad, 0xf8, 0x3a, 0x45, 0xf7, 0x12, 0x96, 0x48, 0xb0, 0x58, 0x71, 0x89, 0xed, 0x85, - 0x7c, 0xf9, 0x38, 0xbe, 0xe3, 0x86, 0x4f, 0x89, 0xed, 0x29, 0xd8, 0x0b, 0xa4, 0xbf, 0xc4, 0xf3, - 0x9d, 0x05, 0x98, 0x97, 0x1c, 0xf8, 0x0b, 0x82, 0xa5, 0x81, 0xd8, 0xe0, 0xad, 0xb8, 0x33, 0xc6, - 0x66, 0x50, 0xbb, 0x37, 0xad, 0x2c, 0xe8, 0xd4, 0xd8, 0xf8, 0xf0, 0xf3, 0xef, 0xe7, 0xb9, 0x34, - 0xd6, 0xcd, 0x11, 0x5f, 0x90, 0xe8, 0x89, 0xe3, 0xaf, 0x08, 0x92, 0x91, 0x1c, 0xe7, 0x4e, 0x3c, - 0x6d, 0x38, 0x9f, 0x5a, 0x7e, 0x1a, 0x89, 0x82, 0xdb, 0x96, 0x70, 0x5b, 0xb8, 0x10, 0x0b, 0x67, - 0xbe, 0xef, 0x5f, 0xc7, 0x43, 0xb3, 0xda, 0xae, 0x04, 0xd1, 0xff, 0x86, 0xe0, 0xd2, 0x88, 0xe4, - 0xe0, 0xed, 0xc9, 0x41, 0x8e, 0xa5, 0x55, 0xdb, 0x99, 0x4d, 0xac, 0xfa, 0xc9, 0xc9, 0x7e, 0x32, - 0xf8, 0x76, 0xfc, 0xb0, 0x65, 0x43, 0xf2, 0x8b, 0x70, 0x88, 0xbf, 0x23, 0x58, 0x19, 0x99, 0x24, - 0x7c, 0x7f, 0x5a, 0x94, 0x81, 0x14, 0x6b, 0x0f, 0x66, 0x95, 0xab, 0x5e, 0x0a, 0xb2, 0x97, 0xbb, - 0x38, 0x33, 0x41, 0x2f, 0xe1, 0xcb, 0xc1, 0x3f, 0x10, 0x5c, 0x19, 0x93, 0x3d, 0xfc, 0x70, 0x92, - 0x1b, 0x1c, 0x93, 0x6e, 0xed, 0xd1, 0xec, 0x06, 0x93, 0xbc, 0x9f, 0xb7, 0x7d, 0x65, 0x85, 0x84, - 0xd2, 0x62, 0xa6, 0xd3, 0xd5, 0xd1, 0x51, 0x57, 0x47, 0x7f, 0xba, 0x3a, 0xfa, 0xd4, 0xd3, 0x13, - 0x47, 0x3d, 0x3d, 0xf1, 0xab, 0xa7, 0x27, 0x5e, 0x5c, 0x7c, 0xf7, 0x9f, 0x58, 0xb4, 0x5d, 0xca, - 0xab, 0xe7, 0xe4, 0x9f, 0x69, 0xe1, 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x90, 0x72, 0x96, 0x2b, - 0xf2, 0x07, 0x00, 0x00, + 0xb5, 0xba, 0x5c, 0x67, 0x75, 0x26, 0x87, 0xa6, 0x3f, 0x0a, 0x66, 0x8d, 0xab, 0xb0, 0xf6, 0xd4, + 0x47, 0xd9, 0x6b, 0x36, 0xcb, 0x44, 0xd0, 0x92, 0x6f, 0xc7, 0xcb, 0xf4, 0xb0, 0x45, 0xb9, 0x30, + 0x5e, 0x81, 0x36, 0x6a, 0x91, 0xbb, 0xcc, 0xe1, 0x14, 0x97, 0x60, 0xd1, 0x27, 0xa8, 0x48, 0x04, + 0xbe, 0x8a, 0x52, 0x67, 0xb6, 0x16, 0x73, 0x1b, 0x99, 0xf1, 0xcd, 0x64, 0x22, 0x93, 0xc2, 0xd9, + 0xce, 0xaf, 0xf5, 0x44, 0x19, 0xbc, 0xc8, 0xd5, 0x28, 0xc1, 0x8a, 0xdc, 0x2b, 0xaa, 0x51, 0x10, + 0x78, 0x19, 0xe6, 0x2d, 0xea, 0xb0, 0x83, 0x55, 0x94, 0x42, 0x5b, 0xc9, 0x72, 0xf0, 0x80, 0xaf, + 0x03, 0xd4, 0x1a, 0xc4, 0x71, 0x68, 0xb3, 0x62, 0x5b, 0xab, 0x73, 0x72, 0x29, 0xa9, 0x66, 0x8a, + 0x96, 0xf1, 0x12, 0x2e, 0x0f, 0xbb, 0x29, 0xea, 0x7d, 0x80, 0x3e, 0xb5, 0xf4, 0x9c, 0x14, 0xba, + 0x9c, 0x8c, 0x70, 0x8d, 0x5d, 0x58, 0x1f, 0xf4, 0xe7, 0x85, 0xf6, 0xe3, 0x06, 0xb1, 0x9d, 0xe2, + 0x7e, 0xc8, 0xbd, 0x06, 0xe7, 0x6b, 0xfe, 0x8c, 0xcf, 0x17, 0xa0, 0x2f, 0xc8, 0xe7, 0xa2, 0x65, + 0xb8, 0x90, 0x1a, 0xaf, 0x3e, 0x95, 0xd3, 0x2d, 0xc0, 0x8d, 0x51, 0x3b, 0x06, 0xa7, 0x15, 0x12, + 0x0f, 0x9e, 0x29, 0x1a, 0x3e, 0x53, 0x0f, 0x8c, 0x38, 0x8f, 0x53, 0xe1, 0xde, 0x80, 0x9b, 0xe1, + 0x0d, 0x7c, 0xd6, 0xb0, 0x7d, 0x25, 0x17, 0xd4, 0xda, 0xb3, 0x2c, 0x8f, 0x72, 0x4e, 0xa3, 0x8b, + 0xfa, 0x01, 0xc1, 0xad, 0xf8, 0x3a, 0x45, 0xf7, 0x02, 0x96, 0x48, 0x30, 0x59, 0x71, 0x89, 0xed, + 0x85, 0x7c, 0xb9, 0x38, 0xbe, 0x93, 0x86, 0x4f, 0x88, 0xed, 0x29, 0xd8, 0x0b, 0xa4, 0x3f, 0xc5, + 0x73, 0x9d, 0x05, 0x98, 0x97, 0x1c, 0xf8, 0x33, 0x82, 0xa5, 0x81, 0xd8, 0xe0, 0xed, 0xb8, 0x3d, + 0xc6, 0x66, 0x50, 0xbb, 0x37, 0xad, 0x2c, 0xe8, 0xd4, 0xd8, 0x7c, 0xff, 0xe3, 0xcf, 0xa7, 0xb9, + 0x14, 0xd6, 0xcd, 0x11, 0x5f, 0x90, 0x68, 0xc4, 0xf1, 0x17, 0x04, 0xc9, 0x48, 0x8e, 0xb3, 0xff, + 0xdd, 0x6d, 0x38, 0x9f, 0x5a, 0x6e, 0x1a, 0x89, 0x82, 0xdb, 0x91, 0x70, 0xdb, 0x38, 0x1f, 0x0b, + 0x67, 0xbe, 0xeb, 0x5f, 0xc7, 0x23, 0xb3, 0xda, 0xae, 0x04, 0xd1, 0xff, 0x8a, 0xe0, 0xd2, 0x88, + 0xe4, 0xe0, 0x9d, 0xc9, 0x41, 0x4e, 0xa4, 0x55, 0xdb, 0x9d, 0x4d, 0xac, 0xfa, 0xc9, 0xca, 0x7e, + 0xd2, 0xf8, 0x76, 0xfc, 0x61, 0xcb, 0x86, 0xe4, 0x17, 0xe1, 0x08, 0x7f, 0x43, 0xb0, 0x32, 0x32, + 0x49, 0xf8, 0xfe, 0xb4, 0x28, 0x03, 0x29, 0xd6, 0x1e, 0xcc, 0x2a, 0x57, 0xbd, 0xe4, 0x65, 0x2f, + 0x77, 0x71, 0x7a, 0x82, 0x5e, 0xc2, 0x97, 0x83, 0xbf, 0x23, 0xb8, 0x32, 0x26, 0x7b, 0xf8, 0xe1, + 0x24, 0x37, 0x38, 0x26, 0xdd, 0xda, 0xa3, 0xd9, 0x0d, 0x26, 0x79, 0x3f, 0x6f, 0xfa, 0xca, 0x0a, + 0x09, 0xa5, 0x85, 0x74, 0xa7, 0xab, 0xa3, 0xe3, 0xae, 0x8e, 0x7e, 0x77, 0x75, 0xf4, 0xb1, 0xa7, + 0x27, 0x8e, 0x7b, 0x7a, 0xe2, 0x67, 0x4f, 0x4f, 0x3c, 0xbf, 0xf8, 0xf6, 0x1f, 0xb1, 0x68, 0xbb, + 0x94, 0x57, 0xcf, 0xc9, 0x9f, 0x69, 0xfe, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x21, 0x22, 0x2b, + 0xa5, 0xf2, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -535,8 +535,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { AllRateLimits(ctx context.Context, in *QueryAllRateLimitsRequest, opts ...grpc.CallOption) (*QueryAllRateLimitsResponse, error) RateLimit(ctx context.Context, in *QueryRateLimitRequest, opts ...grpc.CallOption) (*QueryRateLimitResponse, error) - RateLimitsByChainId(ctx context.Context, in *QueryRateLimitsByChainIdRequest, opts ...grpc.CallOption) (*QueryRateLimitsByChainIdResponse, error) - RateLimitsByChannelId(ctx context.Context, in *QueryRateLimitsByChannelIdRequest, opts ...grpc.CallOption) (*QueryRateLimitsByChannelIdResponse, error) + RateLimitsByChainID(ctx context.Context, in *QueryRateLimitsByChainIDRequest, opts ...grpc.CallOption) (*QueryRateLimitsByChainIDResponse, error) + RateLimitsByChannelID(ctx context.Context, in *QueryRateLimitsByChannelIDRequest, opts ...grpc.CallOption) (*QueryRateLimitsByChannelIDResponse, error) AllWhitelistedAddresses(ctx context.Context, in *QueryAllWhitelistedAddressesRequest, opts ...grpc.CallOption) (*QueryAllWhitelistedAddressesResponse, error) } @@ -566,18 +566,18 @@ func (c *queryClient) RateLimit(ctx context.Context, in *QueryRateLimitRequest, return out, nil } -func (c *queryClient) RateLimitsByChainId(ctx context.Context, in *QueryRateLimitsByChainIdRequest, opts ...grpc.CallOption) (*QueryRateLimitsByChainIdResponse, error) { - out := new(QueryRateLimitsByChainIdResponse) - err := c.cc.Invoke(ctx, "/centauri.ratelimit.v1beta1.Query/RateLimitsByChainId", in, out, opts...) +func (c *queryClient) RateLimitsByChainID(ctx context.Context, in *QueryRateLimitsByChainIDRequest, opts ...grpc.CallOption) (*QueryRateLimitsByChainIDResponse, error) { + out := new(QueryRateLimitsByChainIDResponse) + err := c.cc.Invoke(ctx, "/centauri.ratelimit.v1beta1.Query/RateLimitsByChainID", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) RateLimitsByChannelId(ctx context.Context, in *QueryRateLimitsByChannelIdRequest, opts ...grpc.CallOption) (*QueryRateLimitsByChannelIdResponse, error) { - out := new(QueryRateLimitsByChannelIdResponse) - err := c.cc.Invoke(ctx, "/centauri.ratelimit.v1beta1.Query/RateLimitsByChannelId", in, out, opts...) +func (c *queryClient) RateLimitsByChannelID(ctx context.Context, in *QueryRateLimitsByChannelIDRequest, opts ...grpc.CallOption) (*QueryRateLimitsByChannelIDResponse, error) { + out := new(QueryRateLimitsByChannelIDResponse) + err := c.cc.Invoke(ctx, "/centauri.ratelimit.v1beta1.Query/RateLimitsByChannelID", in, out, opts...) if err != nil { return nil, err } @@ -597,8 +597,8 @@ func (c *queryClient) AllWhitelistedAddresses(ctx context.Context, in *QueryAllW type QueryServer interface { AllRateLimits(context.Context, *QueryAllRateLimitsRequest) (*QueryAllRateLimitsResponse, error) RateLimit(context.Context, *QueryRateLimitRequest) (*QueryRateLimitResponse, error) - RateLimitsByChainId(context.Context, *QueryRateLimitsByChainIdRequest) (*QueryRateLimitsByChainIdResponse, error) - RateLimitsByChannelId(context.Context, *QueryRateLimitsByChannelIdRequest) (*QueryRateLimitsByChannelIdResponse, error) + RateLimitsByChainID(context.Context, *QueryRateLimitsByChainIDRequest) (*QueryRateLimitsByChainIDResponse, error) + RateLimitsByChannelID(context.Context, *QueryRateLimitsByChannelIDRequest) (*QueryRateLimitsByChannelIDResponse, error) AllWhitelistedAddresses(context.Context, *QueryAllWhitelistedAddressesRequest) (*QueryAllWhitelistedAddressesResponse, error) } @@ -612,11 +612,11 @@ func (*UnimplementedQueryServer) AllRateLimits(ctx context.Context, req *QueryAl func (*UnimplementedQueryServer) RateLimit(ctx context.Context, req *QueryRateLimitRequest) (*QueryRateLimitResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RateLimit not implemented") } -func (*UnimplementedQueryServer) RateLimitsByChainId(ctx context.Context, req *QueryRateLimitsByChainIdRequest) (*QueryRateLimitsByChainIdResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RateLimitsByChainId not implemented") +func (*UnimplementedQueryServer) RateLimitsByChainID(ctx context.Context, req *QueryRateLimitsByChainIDRequest) (*QueryRateLimitsByChainIDResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RateLimitsByChainID not implemented") } -func (*UnimplementedQueryServer) RateLimitsByChannelId(ctx context.Context, req *QueryRateLimitsByChannelIdRequest) (*QueryRateLimitsByChannelIdResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method RateLimitsByChannelId not implemented") +func (*UnimplementedQueryServer) RateLimitsByChannelID(ctx context.Context, req *QueryRateLimitsByChannelIDRequest) (*QueryRateLimitsByChannelIDResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RateLimitsByChannelID not implemented") } func (*UnimplementedQueryServer) AllWhitelistedAddresses(ctx context.Context, req *QueryAllWhitelistedAddressesRequest) (*QueryAllWhitelistedAddressesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AllWhitelistedAddresses not implemented") @@ -662,38 +662,38 @@ func _Query_RateLimit_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } -func _Query_RateLimitsByChainId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryRateLimitsByChainIdRequest) +func _Query_RateLimitsByChainID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRateLimitsByChainIDRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).RateLimitsByChainId(ctx, in) + return srv.(QueryServer).RateLimitsByChainID(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/centauri.ratelimit.v1beta1.Query/RateLimitsByChainId", + FullMethod: "/centauri.ratelimit.v1beta1.Query/RateLimitsByChainID", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).RateLimitsByChainId(ctx, req.(*QueryRateLimitsByChainIdRequest)) + return srv.(QueryServer).RateLimitsByChainID(ctx, req.(*QueryRateLimitsByChainIDRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_RateLimitsByChannelId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryRateLimitsByChannelIdRequest) +func _Query_RateLimitsByChannelID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryRateLimitsByChannelIDRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).RateLimitsByChannelId(ctx, in) + return srv.(QueryServer).RateLimitsByChannelID(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/centauri.ratelimit.v1beta1.Query/RateLimitsByChannelId", + FullMethod: "/centauri.ratelimit.v1beta1.Query/RateLimitsByChannelID", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).RateLimitsByChannelId(ctx, req.(*QueryRateLimitsByChannelIdRequest)) + return srv.(QueryServer).RateLimitsByChannelID(ctx, req.(*QueryRateLimitsByChannelIDRequest)) } return interceptor(ctx, in, info, handler) } @@ -729,12 +729,12 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_RateLimit_Handler, }, { - MethodName: "RateLimitsByChainId", - Handler: _Query_RateLimitsByChainId_Handler, + MethodName: "RateLimitsByChainID", + Handler: _Query_RateLimitsByChainID_Handler, }, { - MethodName: "RateLimitsByChannelId", - Handler: _Query_RateLimitsByChannelId_Handler, + MethodName: "RateLimitsByChannelID", + Handler: _Query_RateLimitsByChannelID_Handler, }, { MethodName: "AllWhitelistedAddresses", @@ -825,10 +825,10 @@ func (m *QueryRateLimitRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0x12 } @@ -877,7 +877,7 @@ func (m *QueryRateLimitResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *QueryRateLimitsByChainIdRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryRateLimitsByChainIDRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -887,12 +887,12 @@ func (m *QueryRateLimitsByChainIdRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryRateLimitsByChainIdRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRateLimitsByChainIDRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryRateLimitsByChainIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRateLimitsByChainIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -907,7 +907,7 @@ func (m *QueryRateLimitsByChainIdRequest) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } -func (m *QueryRateLimitsByChainIdResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryRateLimitsByChainIDResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -917,12 +917,12 @@ func (m *QueryRateLimitsByChainIdResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryRateLimitsByChainIdResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRateLimitsByChainIDResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryRateLimitsByChainIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRateLimitsByChainIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -944,7 +944,7 @@ func (m *QueryRateLimitsByChainIdResponse) MarshalToSizedBuffer(dAtA []byte) (in return len(dAtA) - i, nil } -func (m *QueryRateLimitsByChannelIdRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryRateLimitsByChannelIDRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -954,27 +954,27 @@ func (m *QueryRateLimitsByChannelIdRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryRateLimitsByChannelIdRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRateLimitsByChannelIDRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryRateLimitsByChannelIdRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRateLimitsByChannelIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *QueryRateLimitsByChannelIdResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryRateLimitsByChannelIDResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -984,12 +984,12 @@ func (m *QueryRateLimitsByChannelIdResponse) Marshal() (dAtA []byte, err error) return dAtA[:n], nil } -func (m *QueryRateLimitsByChannelIdResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryRateLimitsByChannelIDResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryRateLimitsByChannelIdResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryRateLimitsByChannelIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1116,7 +1116,7 @@ func (m *QueryRateLimitRequest) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -1136,7 +1136,7 @@ func (m *QueryRateLimitResponse) Size() (n int) { return n } -func (m *QueryRateLimitsByChainIdRequest) Size() (n int) { +func (m *QueryRateLimitsByChainIDRequest) Size() (n int) { if m == nil { return 0 } @@ -1149,7 +1149,7 @@ func (m *QueryRateLimitsByChainIdRequest) Size() (n int) { return n } -func (m *QueryRateLimitsByChainIdResponse) Size() (n int) { +func (m *QueryRateLimitsByChainIDResponse) Size() (n int) { if m == nil { return 0 } @@ -1164,20 +1164,20 @@ func (m *QueryRateLimitsByChainIdResponse) Size() (n int) { return n } -func (m *QueryRateLimitsByChannelIdRequest) Size() (n int) { +func (m *QueryRateLimitsByChannelIDRequest) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } return n } -func (m *QueryRateLimitsByChannelIdResponse) Size() (n int) { +func (m *QueryRateLimitsByChannelIDResponse) Size() (n int) { if m == nil { return 0 } @@ -1419,7 +1419,7 @@ func (m *QueryRateLimitRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1447,7 +1447,7 @@ func (m *QueryRateLimitRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1556,7 +1556,7 @@ func (m *QueryRateLimitResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryRateLimitsByChainIdRequest) Unmarshal(dAtA []byte) error { +func (m *QueryRateLimitsByChainIDRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1579,10 +1579,10 @@ func (m *QueryRateLimitsByChainIdRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryRateLimitsByChainIdRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryRateLimitsByChainIDRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRateLimitsByChainIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryRateLimitsByChainIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1638,7 +1638,7 @@ func (m *QueryRateLimitsByChainIdRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryRateLimitsByChainIdResponse) Unmarshal(dAtA []byte) error { +func (m *QueryRateLimitsByChainIDResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1661,10 +1661,10 @@ func (m *QueryRateLimitsByChainIdResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryRateLimitsByChainIdResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryRateLimitsByChainIDResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRateLimitsByChainIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryRateLimitsByChainIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1722,7 +1722,7 @@ func (m *QueryRateLimitsByChainIdResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryRateLimitsByChannelIdRequest) Unmarshal(dAtA []byte) error { +func (m *QueryRateLimitsByChannelIDRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1745,15 +1745,15 @@ func (m *QueryRateLimitsByChannelIdRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryRateLimitsByChannelIdRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryRateLimitsByChannelIDRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRateLimitsByChannelIdRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryRateLimitsByChannelIDRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1781,7 +1781,7 @@ func (m *QueryRateLimitsByChannelIdRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1804,7 +1804,7 @@ func (m *QueryRateLimitsByChannelIdRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryRateLimitsByChannelIdResponse) Unmarshal(dAtA []byte) error { +func (m *QueryRateLimitsByChannelIDResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1827,10 +1827,10 @@ func (m *QueryRateLimitsByChannelIdResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryRateLimitsByChannelIdResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryRateLimitsByChannelIDResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryRateLimitsByChannelIdResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryRateLimitsByChannelIDResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/ratelimit/types/query.pb.gw.go b/x/ratelimit/types/query.pb.gw.go index 95020deff..bad710f6f 100644 --- a/x/ratelimit/types/query.pb.gw.go +++ b/x/ratelimit/types/query.pb.gw.go @@ -71,7 +71,7 @@ func request_Query_RateLimit_0(ctx context.Context, marshaler runtime.Marshaler, return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ChannelID, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) @@ -105,7 +105,7 @@ func local_request_Query_RateLimit_0(ctx context.Context, marshaler runtime.Mars return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ChannelID, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) @@ -123,8 +123,8 @@ func local_request_Query_RateLimit_0(ctx context.Context, marshaler runtime.Mars } -func request_Query_RateLimitsByChainId_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRateLimitsByChainIdRequest +func request_Query_RateLimitsByChainID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRateLimitsByChainIDRequest var metadata runtime.ServerMetadata var ( @@ -145,13 +145,13 @@ func request_Query_RateLimitsByChainId_0(ctx context.Context, marshaler runtime. return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) } - msg, err := client.RateLimitsByChainId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.RateLimitsByChainID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_RateLimitsByChainId_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRateLimitsByChainIdRequest +func local_request_Query_RateLimitsByChainID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRateLimitsByChainIDRequest var metadata runtime.ServerMetadata var ( @@ -172,13 +172,13 @@ func local_request_Query_RateLimitsByChainId_0(ctx context.Context, marshaler ru return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "chain_id", err) } - msg, err := server.RateLimitsByChainId(ctx, &protoReq) + msg, err := server.RateLimitsByChainID(ctx, &protoReq) return msg, metadata, err } -func request_Query_RateLimitsByChannelId_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRateLimitsByChannelIdRequest +func request_Query_RateLimitsByChannelID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRateLimitsByChannelIDRequest var metadata runtime.ServerMetadata var ( @@ -193,19 +193,19 @@ func request_Query_RateLimitsByChannelId_0(ctx context.Context, marshaler runtim return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ChannelID, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) } - msg, err := client.RateLimitsByChannelId(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.RateLimitsByChannelID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_RateLimitsByChannelId_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryRateLimitsByChannelIdRequest +func local_request_Query_RateLimitsByChannelID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryRateLimitsByChannelIDRequest var metadata runtime.ServerMetadata var ( @@ -220,13 +220,13 @@ func local_request_Query_RateLimitsByChannelId_0(ctx context.Context, marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "channel_id") } - protoReq.ChannelId, err = runtime.String(val) + protoReq.ChannelID, err = runtime.String(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "channel_id", err) } - msg, err := server.RateLimitsByChannelId(ctx, &protoReq) + msg, err := server.RateLimitsByChannelID(ctx, &protoReq) return msg, metadata, err } @@ -301,7 +301,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_RateLimitsByChainId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_RateLimitsByChainID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -312,7 +312,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_RateLimitsByChainId_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_RateLimitsByChainID_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 { @@ -320,11 +320,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_RateLimitsByChainId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_RateLimitsByChainID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_RateLimitsByChannelId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_RateLimitsByChannelID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -335,7 +335,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_RateLimitsByChannelId_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_RateLimitsByChannelID_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 { @@ -343,7 +343,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_RateLimitsByChannelId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_RateLimitsByChannelID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -451,7 +451,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_RateLimitsByChainId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_RateLimitsByChainID_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) @@ -460,18 +460,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_RateLimitsByChainId_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_RateLimitsByChainID_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_RateLimitsByChainId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_RateLimitsByChainID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_RateLimitsByChannelId_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_RateLimitsByChannelID_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) @@ -480,14 +480,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_RateLimitsByChannelId_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_RateLimitsByChannelID_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_RateLimitsByChannelId_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_RateLimitsByChannelID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -519,9 +519,9 @@ var ( pattern_Query_RateLimit_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"centauri", "ratelimit", "channel_id", "by_denom"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_RateLimitsByChainId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"centauri", "ratelimit", "ratelimits", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_RateLimitsByChainID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"centauri", "ratelimit", "ratelimits", "chain_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_RateLimitsByChannelId_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"centauri", "ratelimit", "ratelimits", "channel_id"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_RateLimitsByChannelID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"centauri", "ratelimit", "ratelimits", "channel_id"}, "", runtime.AssumeColonVerbOpt(false))) pattern_Query_AllWhitelistedAddresses_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"centauri", "ratelimit", "whitelisted_addresses"}, "", runtime.AssumeColonVerbOpt(false))) ) @@ -531,9 +531,9 @@ var ( forward_Query_RateLimit_0 = runtime.ForwardResponseMessage - forward_Query_RateLimitsByChainId_0 = runtime.ForwardResponseMessage + forward_Query_RateLimitsByChainID_0 = runtime.ForwardResponseMessage - forward_Query_RateLimitsByChannelId_0 = runtime.ForwardResponseMessage + forward_Query_RateLimitsByChannelID_0 = runtime.ForwardResponseMessage forward_Query_AllWhitelistedAddresses_0 = runtime.ForwardResponseMessage ) diff --git a/x/ratelimit/types/quota.go b/x/ratelimit/types/quota.go index 8bfa24581..67fa5c063 100644 --- a/x/ratelimit/types/quota.go +++ b/x/ratelimit/types/quota.go @@ -5,7 +5,7 @@ import ( ) // CheckExceedsQuota checks if new in/out flow is going to reach the max in/out or not -func (q *Quota) CheckExceedsQuota(direction PacketDirection, amount math.Int, totalValue math.Int) bool { +func (q *Quota) CheckExceedsQuota(direction PacketDirection, amount, totalValue math.Int) bool { // If there's no channel value (this should be almost impossible), it means there is no // supply of the asset, so we shoudn't prevent inflows/outflows if totalValue.IsZero() { diff --git a/x/ratelimit/types/ratelimit.pb.go b/x/ratelimit/types/ratelimit.pb.go index af9923387..2c6895c3d 100644 --- a/x/ratelimit/types/ratelimit.pb.go +++ b/x/ratelimit/types/ratelimit.pb.go @@ -51,7 +51,7 @@ func (PacketDirection) EnumDescriptor() ([]byte, []int) { type Path struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty"` } func (m *Path) Reset() { *m = Path{} } @@ -94,9 +94,9 @@ func (m *Path) GetDenom() string { return "" } -func (m *Path) GetChannelId() string { +func (m *Path) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } @@ -368,10 +368,10 @@ func (m *Path) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintRatelimit(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintRatelimit(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0x12 } @@ -603,7 +603,7 @@ func (m *Path) Size() (n int) { if l > 0 { n += 1 + l + sovRatelimit(uint64(l)) } - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovRatelimit(uint64(l)) } @@ -748,7 +748,7 @@ func (m *Path) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -776,7 +776,7 @@ func (m *Path) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/ratelimit/types/tx.pb.go b/x/ratelimit/types/tx.pb.go index cc47a6df0..d7ef5fb1d 100644 --- a/x/ratelimit/types/tx.pb.go +++ b/x/ratelimit/types/tx.pb.go @@ -35,7 +35,7 @@ type MsgAddRateLimit struct { // overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + ChannelID string `protobuf:"bytes,3,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty"` MaxPercentSend github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=max_percent_send,json=maxPercentSend,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_send"` MaxPercentRecv github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=max_percent_recv,json=maxPercentRecv,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_recv"` DurationHours uint64 `protobuf:"varint,6,opt,name=duration_hours,json=durationHours,proto3" json:"duration_hours,omitempty"` @@ -88,9 +88,9 @@ func (m *MsgAddRateLimit) GetDenom() string { return "" } -func (m *MsgAddRateLimit) GetChannelId() string { +func (m *MsgAddRateLimit) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } @@ -143,7 +143,7 @@ type MsgUpdateRateLimit struct { // overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + ChannelID string `protobuf:"bytes,3,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty"` MaxPercentSend github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=max_percent_send,json=maxPercentSend,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_send"` MaxPercentRecv github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=max_percent_recv,json=maxPercentRecv,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_recv"` DurationHours uint64 `protobuf:"varint,6,opt,name=duration_hours,json=durationHours,proto3" json:"duration_hours,omitempty"` @@ -196,9 +196,9 @@ func (m *MsgUpdateRateLimit) GetDenom() string { return "" } -func (m *MsgUpdateRateLimit) GetChannelId() string { +func (m *MsgUpdateRateLimit) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } @@ -251,7 +251,7 @@ type MsgRemoveRateLimit struct { // overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + ChannelID string `protobuf:"bytes,3,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty"` } func (m *MsgRemoveRateLimit) Reset() { *m = MsgRemoveRateLimit{} } @@ -301,9 +301,9 @@ func (m *MsgRemoveRateLimit) GetDenom() string { return "" } -func (m *MsgRemoveRateLimit) GetChannelId() string { +func (m *MsgRemoveRateLimit) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } @@ -349,7 +349,7 @@ type MsgResetRateLimit struct { // overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + ChannelID string `protobuf:"bytes,3,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty"` } func (m *MsgResetRateLimit) Reset() { *m = MsgResetRateLimit{} } @@ -399,9 +399,9 @@ func (m *MsgResetRateLimit) GetDenom() string { return "" } -func (m *MsgResetRateLimit) GetChannelId() string { +func (m *MsgResetRateLimit) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } @@ -728,10 +728,10 @@ func (m *MsgAddRateLimit) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x22 - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0x1a } @@ -820,10 +820,10 @@ func (m *MsgUpdateRateLimit) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x22 - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0x1a } @@ -887,10 +887,10 @@ func (m *MsgRemoveRateLimit) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0x1a } @@ -954,10 +954,10 @@ func (m *MsgResetRateLimit) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0x1a } @@ -1026,7 +1026,7 @@ func (m *MsgAddRateLimit) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1063,7 +1063,7 @@ func (m *MsgUpdateRateLimit) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1100,7 +1100,7 @@ func (m *MsgRemoveRateLimit) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1130,7 +1130,7 @@ func (m *MsgResetRateLimit) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -1247,7 +1247,7 @@ func (m *MsgAddRateLimit) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1275,7 +1275,7 @@ func (m *MsgAddRateLimit) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { @@ -1530,7 +1530,7 @@ func (m *MsgUpdateRateLimit) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1558,7 +1558,7 @@ func (m *MsgUpdateRateLimit) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { @@ -1813,7 +1813,7 @@ func (m *MsgRemoveRateLimit) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1841,7 +1841,7 @@ func (m *MsgRemoveRateLimit) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2009,7 +2009,7 @@ func (m *MsgResetRateLimit) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2037,7 +2037,7 @@ func (m *MsgResetRateLimit) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex diff --git a/x/transfermiddleware/client/cli/cli.go b/x/transfermiddleware/client/cli/cli.go index 01e9a86f4..6296cfef4 100644 --- a/x/transfermiddleware/client/cli/cli.go +++ b/x/transfermiddleware/client/cli/cli.go @@ -67,7 +67,7 @@ func GetEscowAddress() *cobra.Command { } queryClient := types.NewQueryClient(clientCtx) res, err := queryClient.EscrowAddress(cmd.Context(), &types.QueryEscrowAddressRequest{ - ChannelId: args[0], + ChannelID: args[0], }) if err != nil { return err diff --git a/x/transfermiddleware/keeper/genesis.go b/x/transfermiddleware/keeper/genesis.go index 84639e543..a8f5fe519 100644 --- a/x/transfermiddleware/keeper/genesis.go +++ b/x/transfermiddleware/keeper/genesis.go @@ -9,7 +9,7 @@ import ( // InitGenesis initializes the transfermiddleware module's state from a provided genesis state. func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) { for _, tokenInfo := range genState.TokenInfos { - k.AddParachainIBCInfo(ctx, tokenInfo.IbcDenom, tokenInfo.ChannelId, tokenInfo.NativeDenom, tokenInfo.AssetId) + k.AddParachainIBCInfo(ctx, tokenInfo.IbcDenom, tokenInfo.ChannelID, tokenInfo.NativeDenom, tokenInfo.AssetId) } k.SetParams(ctx, genState.Params) } diff --git a/x/transfermiddleware/keeper/genesis_test.go b/x/transfermiddleware/keeper/genesis_test.go index 984cb3aca..f7fd09b47 100644 --- a/x/transfermiddleware/keeper/genesis_test.go +++ b/x/transfermiddleware/keeper/genesis_test.go @@ -15,7 +15,7 @@ func TestTFMInitGenesis(t *testing.T) { tokenInfos := make([]types.ParachainIBCTokenInfo, 1) tokenInfos[0] = types.ParachainIBCTokenInfo{ IbcDenom: "ibc-test", - ChannelId: "channel-0", + ChannelID: "channel-0", NativeDenom: "pica", AssetId: "1", } @@ -29,7 +29,7 @@ func TestTFMInitGenesis(t *testing.T) { require.Equal(t, "1", info.AssetId) require.Equal(t, "pica", info.NativeDenom) require.Equal(t, "ibc-test", info.IbcDenom) - require.Equal(t, "channel-0", info.ChannelId) + require.Equal(t, "channel-0", info.ChannelID) } func TestTFMExportGenesis(t *testing.T) { @@ -44,12 +44,12 @@ func TestTFMExportGenesis(t *testing.T) { require.Equal(t, "1", genesis.TokenInfos[0].AssetId) require.Equal(t, "pica", genesis.TokenInfos[0].NativeDenom) - require.Equal(t, "channel-0", genesis.TokenInfos[0].ChannelId) + require.Equal(t, "channel-0", genesis.TokenInfos[0].ChannelID) require.Equal(t, "ibc-test", genesis.TokenInfos[0].IbcDenom) require.Equal(t, "2", genesis.TokenInfos[1].AssetId) require.Equal(t, "poke", genesis.TokenInfos[1].NativeDenom) - require.Equal(t, "channel-1", genesis.TokenInfos[1].ChannelId) + require.Equal(t, "channel-1", genesis.TokenInfos[1].ChannelID) require.Equal(t, "ibc-test2", genesis.TokenInfos[1].IbcDenom) } @@ -71,11 +71,11 @@ func TestIterateParaTokenInfos(t *testing.T) { require.Equal(t, "1", infos[0].AssetId) require.Equal(t, "pica", infos[0].NativeDenom) - require.Equal(t, "channel-0", infos[0].ChannelId) + require.Equal(t, "channel-0", infos[0].ChannelID) require.Equal(t, "ibc-test", infos[0].IbcDenom) require.Equal(t, "2", infos[1].AssetId) require.Equal(t, "poke", infos[1].NativeDenom) - require.Equal(t, "channel-1", infos[1].ChannelId) + require.Equal(t, "channel-1", infos[1].ChannelID) require.Equal(t, "ibc-test2", infos[1].IbcDenom) } diff --git a/x/transfermiddleware/keeper/grpc_query.go b/x/transfermiddleware/keeper/grpc_query.go index 696c09815..2b6c53d2f 100644 --- a/x/transfermiddleware/keeper/grpc_query.go +++ b/x/transfermiddleware/keeper/grpc_query.go @@ -15,13 +15,13 @@ func (k Keeper) ParaTokenInfo(c context.Context, req *types.QueryParaTokenInfoRe return &types.QueryParaTokenInfoResponse{ IbcDenom: info.IbcDenom, NativeDenom: info.NativeDenom, - ChannelId: info.ChannelId, + ChannelID: info.ChannelID, AssetId: info.AssetId, }, nil } func (k Keeper) EscrowAddress(_ context.Context, req *types.QueryEscrowAddressRequest) (*types.QueryEscrowAddressResponse, error) { - escrowAddress := transfertypes.GetEscrowAddress(transfertypes.PortID, req.ChannelId) + escrowAddress := transfertypes.GetEscrowAddress(transfertypes.PortID, req.ChannelID) return &types.QueryEscrowAddressResponse{ EscrowAddress: escrowAddress.String(), diff --git a/x/transfermiddleware/keeper/ics4wrapper.go b/x/transfermiddleware/keeper/ics4wrapper.go index 65b9d8d92..52d8e5872 100644 --- a/x/transfermiddleware/keeper/ics4wrapper.go +++ b/x/transfermiddleware/keeper/ics4wrapper.go @@ -112,7 +112,7 @@ func (keeper Keeper) SendPacket( // check if denom in fungibleTokenPacketData is native denom in parachain info and parachainInfo := keeper.GetParachainIBCTokenInfoByNativeDenom(ctx, fungibleTokenPacketData.Denom) - if parachainInfo.ChannelId != sourceChannel || parachainInfo.NativeDenom != fungibleTokenPacketData.Denom { + if parachainInfo.ChannelID != sourceChannel || parachainInfo.NativeDenom != fungibleTokenPacketData.Denom { return keeper.ICS4Wrapper.SendPacket(ctx, chanCap, sourcePort, sourceChannel, timeoutHeight, timeoutTimestamp, data) } @@ -187,10 +187,10 @@ func (keeper Keeper) refundToken(ctx sdk.Context, packet channeltypes.Packet, da return nil } - if packet.GetSourceChannel() == paraTokenInfo.ChannelId { + if packet.GetSourceChannel() == paraTokenInfo.ChannelID { nativeToken := sdk.NewCoin(paraTokenInfo.NativeDenom, transferAmount) // send IBC token to escrow address ibc token - escrowAddress := transfertypes.GetEscrowAddress(transfertypes.PortID, paraTokenInfo.ChannelId) + escrowAddress := transfertypes.GetEscrowAddress(transfertypes.PortID, paraTokenInfo.ChannelID) if err := keeper.bankKeeper.SendCoins(ctx, sender, escrowAddress, sdk.NewCoins(token)); err != nil { panic(fmt.Sprintf("unable to send coins from account to module despite previously minting coins to module account: %v", err)) } diff --git a/x/transfermiddleware/keeper/keeper.go b/x/transfermiddleware/keeper/keeper.go index 88423fc5b..941c5009a 100644 --- a/x/transfermiddleware/keeper/keeper.go +++ b/x/transfermiddleware/keeper/keeper.go @@ -71,7 +71,7 @@ func (keeper Keeper) AddParachainIBCInfo(ctx sdk.Context, ibcDenom, channelID, n info := types.ParachainIBCTokenInfo{ IbcDenom: ibcDenom, - ChannelId: channelID, + ChannelID: channelID, NativeDenom: nativeDenom, AssetId: assetID, } @@ -203,7 +203,7 @@ func (keeper Keeper) GetNativeDenomByIBCDenomSecondaryIndex(ctx sdk.Context, ibc func (keeper Keeper) GetTotalEscrowedToken(ctx sdk.Context) (coins sdk.Coins) { keeper.IterateParaTokenInfos(ctx, func(index int64, info types.ParachainIBCTokenInfo) (stop bool) { - escrowCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelId), info.IbcDenom) + escrowCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelID), info.IbcDenom) coins = append(coins, escrowCoin) return false }) diff --git a/x/transfermiddleware/keeper/msg_server.go b/x/transfermiddleware/keeper/msg_server.go index e089d4a1d..13ed6d26a 100644 --- a/x/transfermiddleware/keeper/msg_server.go +++ b/x/transfermiddleware/keeper/msg_server.go @@ -32,7 +32,7 @@ func (ms msgServer) AddParachainIBCTokenInfo(goCtx context.Context, req *types.M return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, req.Authority) } - err := ms.AddParachainIBCInfo(ctx, req.IbcDenom, req.ChannelId, req.NativeDenom, req.AssetId) + err := ms.AddParachainIBCInfo(ctx, req.IbcDenom, req.ChannelID, req.NativeDenom, req.AssetId) if err != nil { return nil, err } diff --git a/x/transfermiddleware/keeper/relay.go b/x/transfermiddleware/keeper/relay.go index c7494af3e..9e93b7848 100644 --- a/x/transfermiddleware/keeper/relay.go +++ b/x/transfermiddleware/keeper/relay.go @@ -49,7 +49,7 @@ func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data t } // lock ibc token if dstChannel is paraChannel - if packet.GetDestChannel() == paraTokenInfo.ChannelId { + if packet.GetDestChannel() == paraTokenInfo.ChannelID { // escrow ibc token escrowAddress := transfertypes.GetEscrowAddress(packet.GetDestPort(), packet.GetDestChannel()) diff --git a/x/transfermiddleware/types/genesis_test.go b/x/transfermiddleware/types/genesis_test.go index d211cd08a..28128c42a 100644 --- a/x/transfermiddleware/types/genesis_test.go +++ b/x/transfermiddleware/types/genesis_test.go @@ -9,25 +9,25 @@ import ( var ( info1 = ParachainIBCTokenInfo{ IbcDenom: "ibc-test-1", - ChannelId: "channel-1", + ChannelID: "channel-1", NativeDenom: "native-1", AssetId: "1", } info2 = ParachainIBCTokenInfo{ IbcDenom: "ibc-test-2", - ChannelId: "channel-2", + ChannelID: "channel-2", NativeDenom: "native-2", AssetId: "2", } invalidAssetID = ParachainIBCTokenInfo{ IbcDenom: "ibc-test-3", - ChannelId: "channel-3", + ChannelID: "channel-3", NativeDenom: "native-3", AssetId: "asset-3", } dup1 = ParachainIBCTokenInfo{ IbcDenom: "ibc-test-4", - ChannelId: "channel-4", + ChannelID: "channel-4", NativeDenom: "native-1", AssetId: "1", } diff --git a/x/transfermiddleware/types/info_test.go b/x/transfermiddleware/types/info_test.go index 52010caa0..7ae683a26 100644 --- a/x/transfermiddleware/types/info_test.go +++ b/x/transfermiddleware/types/info_test.go @@ -11,13 +11,13 @@ func TestValidateBasic(t *testing.T) { var ( validInfo = types.ParachainIBCTokenInfo{ IbcDenom: "ibc-test-1", - ChannelId: "channel-1", + ChannelID: "channel-1", NativeDenom: "native-1", AssetId: "1", } invalidInfo = types.ParachainIBCTokenInfo{ IbcDenom: "ibc-test-1", - ChannelId: "channel-1", + ChannelID: "channel-1", NativeDenom: "native-1", AssetId: "asset-1", } diff --git a/x/transfermiddleware/types/msg.go b/x/transfermiddleware/types/msg.go index e298809a2..9ad3ee9a5 100644 --- a/x/transfermiddleware/types/msg.go +++ b/x/transfermiddleware/types/msg.go @@ -27,7 +27,7 @@ func NewMsgAddParachainIBCTokenInfo( IbcDenom: ibcDenom, NativeDenom: nativeDenom, AssetId: assetID, - ChannelId: channelID, + ChannelID: channelID, } } @@ -55,8 +55,8 @@ func (msg *MsgAddParachainIBCTokenInfo) ValidateBasic() error { return sdkerrors.Wrap(err, "invalid authority address") } - // validate channelIds - if err := host.ChannelIdentifierValidator(msg.ChannelId); err != nil { + // validate channelIDs + if err := host.ChannelIdentifierValidator(msg.ChannelID); err != nil { return err } diff --git a/x/transfermiddleware/types/parachain_token_info.pb.go b/x/transfermiddleware/types/parachain_token_info.pb.go index effd9f8de..9f492749f 100644 --- a/x/transfermiddleware/types/parachain_token_info.pb.go +++ b/x/transfermiddleware/types/parachain_token_info.pb.go @@ -34,7 +34,7 @@ type ParachainIBCTokenInfo struct { // dotsama chain. IbcDenom string `protobuf:"bytes,1,opt,name=ibc_denom,json=ibcDenom,proto3" json:"ibc_denom,omitempty" yaml:"ibc_denom"` // channel_id is source channel in IBC connection from centauri chain - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty" yaml:"channel_id"` // native denom is new native minted denom in centauri chain. NativeDenom string `protobuf:"bytes,3,opt,name=native_denom,json=nativeDenom,proto3" json:"native_denom,omitempty" yaml:"native_denom"` // asset id is the id of the asset on Picasso @@ -81,9 +81,9 @@ func (m *ParachainIBCTokenInfo) GetIbcDenom() string { return "" } -func (m *ParachainIBCTokenInfo) GetChannelId() string { +func (m *ParachainIBCTokenInfo) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } @@ -228,10 +228,10 @@ func (m *ParachainIBCTokenInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintParachainTokenInfo(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintParachainTokenInfo(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0x12 } @@ -304,7 +304,7 @@ func (m *ParachainIBCTokenInfo) Size() (n int) { if l > 0 { n += 1 + l + sovParachainTokenInfo(uint64(l)) } - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovParachainTokenInfo(uint64(l)) } @@ -403,7 +403,7 @@ func (m *ParachainIBCTokenInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -431,7 +431,7 @@ func (m *ParachainIBCTokenInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { diff --git a/x/transfermiddleware/types/query.pb.go b/x/transfermiddleware/types/query.pb.go index 49ac2c3d0..baea27af5 100644 --- a/x/transfermiddleware/types/query.pb.go +++ b/x/transfermiddleware/types/query.pb.go @@ -31,7 +31,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // message QueryEscrowAddressRequest type QueryEscrowAddressRequest struct { - ChannelId string `protobuf:"bytes,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + ChannelID string `protobuf:"bytes,1,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty" yaml:"channel_id"` } func (m *QueryEscrowAddressRequest) Reset() { *m = QueryEscrowAddressRequest{} } @@ -67,9 +67,9 @@ func (m *QueryEscrowAddressRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryEscrowAddressRequest proto.InternalMessageInfo -func (m *QueryEscrowAddressRequest) GetChannelId() string { +func (m *QueryEscrowAddressRequest) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } @@ -169,7 +169,7 @@ func (m *QueryParaTokenInfoRequest) GetNativeDenom() string { // RPC method. type QueryParaTokenInfoResponse struct { IbcDenom string `protobuf:"bytes,1,opt,name=ibc_denom,json=ibcDenom,proto3" json:"ibc_denom,omitempty" yaml:"ibc_denom"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty" yaml:"channel_id"` NativeDenom string `protobuf:"bytes,3,opt,name=native_denom,json=nativeDenom,proto3" json:"native_denom,omitempty" yaml:"native_denom"` AssetId string `protobuf:"bytes,4,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` } @@ -214,9 +214,9 @@ func (m *QueryParaTokenInfoResponse) GetIbcDenom() string { return "" } -func (m *QueryParaTokenInfoResponse) GetChannelId() string { +func (m *QueryParaTokenInfoResponse) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } @@ -418,10 +418,10 @@ func (m *QueryEscrowAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0xa } @@ -522,10 +522,10 @@ func (m *QueryParaTokenInfoResponse) MarshalToSizedBuffer(dAtA []byte) (int, err i-- dAtA[i] = 0x1a } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0x12 } @@ -556,7 +556,7 @@ func (m *QueryEscrowAddressRequest) Size() (n int) { } var l int _ = l - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -599,7 +599,7 @@ func (m *QueryParaTokenInfoResponse) Size() (n int) { if l > 0 { n += 1 + l + sovQuery(uint64(l)) } - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovQuery(uint64(l)) } @@ -651,7 +651,7 @@ func (m *QueryEscrowAddressRequest) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -679,7 +679,7 @@ func (m *QueryEscrowAddressRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -929,7 +929,7 @@ func (m *QueryParaTokenInfoResponse) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -957,7 +957,7 @@ func (m *QueryParaTokenInfoResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { diff --git a/x/transfermiddleware/types/tx.pb.go b/x/transfermiddleware/types/tx.pb.go index ff5a1ef70..dd5426258 100644 --- a/x/transfermiddleware/types/tx.pb.go +++ b/x/transfermiddleware/types/tx.pb.go @@ -34,7 +34,7 @@ type MsgAddParachainIBCTokenInfo struct { // authority is the address that controls the module (defaults to x/gov unless // overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` - ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"` + ChannelID string `protobuf:"bytes,2,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty" yaml:"channel_id"` IbcDenom string `protobuf:"bytes,3,opt,name=ibc_denom,json=ibcDenom,proto3" json:"ibc_denom,omitempty" yaml:"ibc_denom"` NativeDenom string `protobuf:"bytes,4,opt,name=native_denom,json=nativeDenom,proto3" json:"native_denom,omitempty" yaml:"native_denom"` AssetId string `protobuf:"bytes,5,opt,name=asset_id,json=assetId,proto3" json:"asset_id,omitempty" yaml:"asset_id"` @@ -80,9 +80,9 @@ func (m *MsgAddParachainIBCTokenInfo) GetAuthority() string { return "" } -func (m *MsgAddParachainIBCTokenInfo) GetChannelId() string { +func (m *MsgAddParachainIBCTokenInfo) GetChannelID() string { if m != nil { - return m.ChannelId + return m.ChannelID } return "" } @@ -572,10 +572,10 @@ func (m *MsgAddParachainIBCTokenInfo) MarshalToSizedBuffer(dAtA []byte) (int, er i-- dAtA[i] = 0x1a } - if len(m.ChannelId) > 0 { - i -= len(m.ChannelId) - copy(dAtA[i:], m.ChannelId) - i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelId))) + if len(m.ChannelID) > 0 { + i -= len(m.ChannelID) + copy(dAtA[i:], m.ChannelID) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChannelID))) i-- dAtA[i] = 0x12 } @@ -753,7 +753,7 @@ func (m *MsgAddParachainIBCTokenInfo) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.ChannelId) + l = len(m.ChannelID) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -902,7 +902,7 @@ func (m *MsgAddParachainIBCTokenInfo) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChannelId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -930,7 +930,7 @@ func (m *MsgAddParachainIBCTokenInfo) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ChannelId = string(dAtA[iNdEx:postIndex]) + m.ChannelID = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { From d4cac083c149374741878bf5208475ed3f6bd799 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Thu, 20 Jul 2023 10:58:29 +0700 Subject: [PATCH 02/20] packet-forward-middleware version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1dccd2395..b4271c828 100644 --- a/go.mod +++ b/go.mod @@ -188,7 +188,7 @@ replace ( // ibc-go with wasm client github.com/cosmos/ibc-go/v7 => github.com/notional-labs/ibc-go/v7 v7.0.0-wasm-client - github.com/strangelove-ventures/packet-forward-middleware/v7 => github.com/notional-labs/packet-forward-middleware/v7 v7.0.0-20230719072346-7acf9377aac3 + github.com/strangelove-ventures/packet-forward-middleware/v7 => github.com/notional-labs/packet-forward-middleware/v7 v7.0.0-20230720035542-4b1cd673ad3e github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/terra-money/alliance => github.com/notional-labs/alliance v1.0.1-0.20230523105704-66dba9499c01 diff --git a/go.sum b/go.sum index fdbac6cf0..8f0cddc4b 100644 --- a/go.sum +++ b/go.sum @@ -772,8 +772,8 @@ github.com/notional-labs/alliance v1.0.1-0.20230523105704-66dba9499c01 h1:koCsoc github.com/notional-labs/alliance v1.0.1-0.20230523105704-66dba9499c01/go.mod h1:GFQ8TsXDMTpu7kif0Dwddz6rxazy0ZJQHfN38ZmAodI= github.com/notional-labs/ibc-go/v7 v7.0.0-wasm-client h1:oQxReLXp48oCIW1zYL+YYg7Nr3L5ginxzJjWXSk1zHM= github.com/notional-labs/ibc-go/v7 v7.0.0-wasm-client/go.mod h1:ISHo/Qitjtvj2svGmttaZv03zVXmS+uqvUyF9kFqlI0= -github.com/notional-labs/packet-forward-middleware/v7 v7.0.0-20230719072346-7acf9377aac3 h1:LBK82QivQaiycoKZPGDV3fJL1KTWy8AAoerEGUno/60= -github.com/notional-labs/packet-forward-middleware/v7 v7.0.0-20230719072346-7acf9377aac3/go.mod h1:L7nnQ9rEoYLyulE9M/zhcBcHDWqMMSQn8cf4yY5A+T8= +github.com/notional-labs/packet-forward-middleware/v7 v7.0.0-20230720035542-4b1cd673ad3e h1:5Jm678g0o1NJ8TibGYVyMf62pxwcfKgbd3GEgKyMyjI= +github.com/notional-labs/packet-forward-middleware/v7 v7.0.0-20230720035542-4b1cd673ad3e/go.mod h1:3jaW2/rb+utcdgh54fUxnvrWMFLe8OyQA0sgUOHYtCE= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= From 9f0683a2b7c01d1c6402875bbfc96e2a34440122 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Thu, 20 Jul 2023 11:26:03 +0700 Subject: [PATCH 03/20] lint --- app/app.go | 6 +++--- x/ibc-hooks/client/cli/query.go | 2 +- x/ibc-hooks/hooks.go | 8 ++++---- x/ibc-hooks/ibc_module.go | 2 +- x/ibc-hooks/ics4_middleware.go | 2 +- x/ibc-hooks/keeper/keeper.go | 2 +- x/ibc-hooks/module.go | 4 ++-- x/ibc-hooks/relay_test.go | 2 +- x/ibc-hooks/utils.go | 2 +- x/ibc-hooks/wasm_hook.go | 2 +- x/ratelimit/ibc_middleware.go | 4 ++-- x/ratelimit/keeper/rate_limit.go | 12 ++++++------ x/ratelimit/types/epoch.go | 4 ++-- x/transfermiddleware/keeper/abci.go | 2 -- 14 files changed, 26 insertions(+), 28 deletions(-) diff --git a/app/app.go b/app/app.go index e46157207..82c64a285 100644 --- a/app/app.go +++ b/app/app.go @@ -703,9 +703,9 @@ func (app *CentauriApp) setupUpgradeStoreLoaders() { } func (app *CentauriApp) customPreUpgradeHandler(upgradeInfo upgradetypes.Plan) { - switch upgradeInfo.Name { - default: - } + // switch upgradeInfo.Name { + // default: + // } } func (app *CentauriApp) setupUpgradeHandlers() { diff --git a/x/ibc-hooks/client/cli/query.go b/x/ibc-hooks/client/cli/query.go index 0350649e4..f66a5ec7c 100644 --- a/x/ibc-hooks/client/cli/query.go +++ b/x/ibc-hooks/client/cli/query.go @@ -13,7 +13,7 @@ import ( "github.com/notional-labs/centauri/v4/x/ibc-hooks/types" ) -func indexRunCmd(cmd *cobra.Command, args []string) error { +func indexRunCmd(cmd *cobra.Command, _ []string) error { usageTemplate := `Usage:{{if .HasAvailableSubCommands}} {{.CommandPath}} [command]{{end}} diff --git a/x/ibc-hooks/hooks.go b/x/ibc-hooks/hooks.go index 2a2fc2cd3..3802f23ea 100644 --- a/x/ibc-hooks/hooks.go +++ b/x/ibc-hooks/hooks.go @@ -1,4 +1,4 @@ -package ibc_hooks +package ibchooks import ( // external libraries @@ -14,13 +14,13 @@ import ( type Hooks interface{} type OnChanOpenInitOverrideHooks interface { - OnChanOpenInitOverride(im IBCMiddleware, ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string) (string, error) + OnChanOpenInitOverride(im IBCMiddleware, ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string) (string, error) } type OnChanOpenInitBeforeHooks interface { - OnChanOpenInitBeforeHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string) + OnChanOpenInitBeforeHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string) } type OnChanOpenInitAfterHooks interface { - OnChanOpenInitAfterHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID string, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version string, finalVersion string, err error) + OnChanOpenInitAfterHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, version, finalVersion string, err error) } // OnChanOpenTry Hooks diff --git a/x/ibc-hooks/ibc_module.go b/x/ibc-hooks/ibc_module.go index 0d876f891..e21558919 100644 --- a/x/ibc-hooks/ibc_module.go +++ b/x/ibc-hooks/ibc_module.go @@ -1,4 +1,4 @@ -package ibc_hooks +package ibchooks import ( // external libraries diff --git a/x/ibc-hooks/ics4_middleware.go b/x/ibc-hooks/ics4_middleware.go index ab45dcb7e..e9ddedd82 100644 --- a/x/ibc-hooks/ics4_middleware.go +++ b/x/ibc-hooks/ics4_middleware.go @@ -1,4 +1,4 @@ -package ibc_hooks +package ibchooks import ( // external libraries diff --git a/x/ibc-hooks/keeper/keeper.go b/x/ibc-hooks/keeper/keeper.go index 26edf4b4a..704ef9b41 100644 --- a/x/ibc-hooks/keeper/keeper.go +++ b/x/ibc-hooks/keeper/keeper.go @@ -55,6 +55,6 @@ func (k Keeper) DeletePacketCallback(ctx sdk.Context, channel string, packetSequ func DeriveIntermediateSender(channel, originalSender, bech32Prefix string) (string, error) { senderStr := fmt.Sprintf("%s/%s", channel, originalSender) senderHash32 := address.Hash(types.SenderPrefix, []byte(senderStr)) - sender := sdk.AccAddress(senderHash32[:]) + sender := sdk.AccAddress(senderHash32) return sdk.Bech32ifyAddressBytes(bech32Prefix, sender) } diff --git a/x/ibc-hooks/module.go b/x/ibc-hooks/module.go index 7a03b9407..ce32a8e2a 100644 --- a/x/ibc-hooks/module.go +++ b/x/ibc-hooks/module.go @@ -1,4 +1,4 @@ -package ibc_hooks +package ibchooks import ( "encoding/json" @@ -35,7 +35,7 @@ func (AppModuleBasic) Name() string { } // RegisterLegacyAminoCodec registers the ibc-hooks module's types on the given LegacyAmino codec. -func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {} +func (AppModuleBasic) RegisterLegacyAminoCodec(_ *codec.LegacyAmino) {} // RegisterInterfaces registers the module's interface types. func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} diff --git a/x/ibc-hooks/relay_test.go b/x/ibc-hooks/relay_test.go index 996f3d2a0..6314687f6 100644 --- a/x/ibc-hooks/relay_test.go +++ b/x/ibc-hooks/relay_test.go @@ -1,4 +1,4 @@ -package ibc_hooks_test +package ibchooks_test import ( "fmt" diff --git a/x/ibc-hooks/utils.go b/x/ibc-hooks/utils.go index e8c084e60..38865fccf 100644 --- a/x/ibc-hooks/utils.go +++ b/x/ibc-hooks/utils.go @@ -1,4 +1,4 @@ -package ibc_hooks +package ibchooks import ( "encoding/json" diff --git a/x/ibc-hooks/wasm_hook.go b/x/ibc-hooks/wasm_hook.go index a475fb5de..b4798677b 100644 --- a/x/ibc-hooks/wasm_hook.go +++ b/x/ibc-hooks/wasm_hook.go @@ -1,4 +1,4 @@ -package ibc_hooks +package ibchooks import ( "encoding/json" diff --git a/x/ratelimit/ibc_middleware.go b/x/ratelimit/ibc_middleware.go index 1d2513936..2cd090891 100644 --- a/x/ratelimit/ibc_middleware.go +++ b/x/ratelimit/ibc_middleware.go @@ -179,6 +179,6 @@ func (im IBCMiddleware) WriteAcknowledgement( } // GetAppVersion returns the application version of the underlying application -func (i IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { - return i.keeper.GetAppVersion(ctx, portID, channelID) +func (im IBCMiddleware) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool) { + return im.keeper.GetAppVersion(ctx, portID, channelID) } diff --git a/x/ratelimit/keeper/rate_limit.go b/x/ratelimit/keeper/rate_limit.go index a0c3128f3..c31961727 100644 --- a/x/ratelimit/keeper/rate_limit.go +++ b/x/ratelimit/keeper/rate_limit.go @@ -14,7 +14,7 @@ import ( ) // Get the rate limit byte key built from the denom and channelID -func GetRateLimitItemKey(denom string, channelID string) []byte { +func GetRateLimitItemKey(denom, channelID string) []byte { return append(types.KeyPrefix(denom), types.KeyPrefix(channelID)...) } @@ -108,7 +108,7 @@ func (k Keeper) UndoSendPacket(ctx sdk.Context, channelID string, sequence uint6 // Reset the rate limit after expiration // The inflow and outflow should get reset to 0, the channelValue should be updated, // and all pending send packet sequence numbers should be removed -func (k Keeper) ResetRateLimit(ctx sdk.Context, denom string, channelID string) error { +func (k Keeper) ResetRateLimit(ctx sdk.Context, denom, channelID string) error { if k.tfmwKeeper.HasParachainIBCTokenInfoByNativeDenom(ctx, denom) { tokenInfo := k.tfmwKeeper.GetParachainIBCTokenInfoByNativeDenom(ctx, denom) if channelID == tokenInfo.ChannelID { @@ -144,7 +144,7 @@ func (k Keeper) SetRateLimit(ctx sdk.Context, rateLimit types.RateLimit) { } // Removes a rate limit object from the store using denom and channel-id -func (k Keeper) RemoveRateLimit(ctx sdk.Context, denom string, channelID string) error { +func (k Keeper) RemoveRateLimit(ctx sdk.Context, denom, channelID string) error { if k.tfmwKeeper.HasParachainIBCTokenInfoByNativeDenom(ctx, denom) { tokenInfo := k.tfmwKeeper.GetParachainIBCTokenInfoByNativeDenom(ctx, denom) if channelID == tokenInfo.ChannelID { @@ -165,7 +165,7 @@ func (k Keeper) RemoveRateLimit(ctx sdk.Context, denom string, channelID string) } // Grabs and returns a rate limit object from the store using denom and channel-id -func (k Keeper) GetRateLimit(ctx sdk.Context, denom string, channelID string) (rateLimit types.RateLimit, found bool) { +func (k Keeper) GetRateLimit(ctx sdk.Context, denom, channelID string) (rateLimit types.RateLimit, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RateLimitKeyPrefix) rateLimitKey := GetRateLimitItemKey(denom, channelID) @@ -327,8 +327,8 @@ func (k Keeper) GetAllPendingSendPackets(ctx sdk.Context) []string { channelID = strings.TrimRight(channelID, "\x00") // removes null bytes from suffix sequence := binary.BigEndian.Uint64(key[types.PendingSendPacketChannelLength:]) - packetId := fmt.Sprintf("%s/%d", channelID, sequence) - pendingPackets = append(pendingPackets, packetId) + packetID := fmt.Sprintf("%s/%d", channelID, sequence) + pendingPackets = append(pendingPackets, packetID) } return pendingPackets diff --git a/x/ratelimit/types/epoch.go b/x/ratelimit/types/epoch.go index 185b90b31..9d188b5f3 100644 --- a/x/ratelimit/types/epoch.go +++ b/x/ratelimit/types/epoch.go @@ -6,8 +6,8 @@ import ( ) var ( - DayEpoch = "hour" - EpochHourPeriod time.Duration = 24 * time.Hour + DayEpoch = "hour" + EpochHourPeriod = 24 * time.Hour ) // Validate also validates epoch info. diff --git a/x/transfermiddleware/keeper/abci.go b/x/transfermiddleware/keeper/abci.go index b5811a40f..79989b7b6 100644 --- a/x/transfermiddleware/keeper/abci.go +++ b/x/transfermiddleware/keeper/abci.go @@ -13,8 +13,6 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { if ctx.BlockTime().After(removeList.RemoveTime) { k.RemoveParachainIBCInfo(ctx, removeList.NativeDenom) } - return false }) - } From 8165ae1a537c3c549cc2980ebdf27138aa76ec06 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Thu, 20 Jul 2023 11:41:57 +0700 Subject: [PATCH 04/20] lint --- app/ibctesting/event_utils.go | 12 ++++++------ app/keepers/keepers.go | 2 +- x/ibc-hooks/hooks.go | 10 +++++----- x/ibc-hooks/module.go | 16 ++++++++-------- x/ibc-hooks/wasm_hook.go | 4 ++-- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/ibctesting/event_utils.go b/app/ibctesting/event_utils.go index e910ab69e..dea990a82 100644 --- a/app/ibctesting/event_utils.go +++ b/app/ibctesting/event_utils.go @@ -78,19 +78,19 @@ func ParsePacketFromEvents(events sdk.Events) (channeltypes.Packet, error) { packet.Sequence = seq case channeltypes.AttributeKeySrcPort: - packet.SourcePort = string(attr.Value) + packet.SourcePort = attr.Value case channeltypes.AttributeKeySrcChannel: - packet.SourceChannel = string(attr.Value) + packet.SourceChannel = attr.Value case channeltypes.AttributeKeyDstPort: - packet.DestinationPort = string(attr.Value) + packet.DestinationPort = attr.Value case channeltypes.AttributeKeyDstChannel: - packet.DestinationChannel = string(attr.Value) + packet.DestinationChannel = attr.Value case channeltypes.AttributeKeyTimeoutHeight: - height, err := clienttypes.ParseHeight(string(attr.Value)) + height, err := clienttypes.ParseHeight(attr.Value) if err != nil { return channeltypes.Packet{}, err } @@ -98,7 +98,7 @@ func ParsePacketFromEvents(events sdk.Events) (channeltypes.Packet, error) { packet.TimeoutHeight = height case channeltypes.AttributeKeyTimeoutTimestamp: - timestamp, err := strconv.ParseUint(string(attr.Value), 10, 64) + timestamp, err := strconv.ParseUint(attr.Value, 10, 64) if err != nil { return channeltypes.Packet{}, err } diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 1cd6ba5fb..0ff568ea4 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -414,7 +414,7 @@ func (appKeepers *AppKeepers) InitSpecialKeepers( appCodec codec.Codec, cdc *codec.LegacyAmino, bApp *baseapp.BaseApp, - invCheckPeriod uint, + _ uint, // invCheckPeriod skipUpgradeHeights map[int64]bool, homePath string, ) { diff --git a/x/ibc-hooks/hooks.go b/x/ibc-hooks/hooks.go index 3802f23ea..813c767fa 100644 --- a/x/ibc-hooks/hooks.go +++ b/x/ibc-hooks/hooks.go @@ -31,18 +31,18 @@ type OnChanOpenTryBeforeHooks interface { OnChanOpenTryBeforeHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string) } type OnChanOpenTryAfterHooks interface { - OnChanOpenTryAfterHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion string, version string, err error) + OnChanOpenTryAfterHook(ctx sdk.Context, order channeltypes.Order, connectionHops []string, portID, channelID string, channelCap *capabilitytypes.Capability, counterparty channeltypes.Counterparty, counterpartyVersion, version string, err error) } // OnChanOpenAck Hooks type OnChanOpenAckOverrideHooks interface { - OnChanOpenAckOverride(im IBCMiddleware, ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string) error + OnChanOpenAckOverride(im IBCMiddleware, ctx sdk.Context, portID, channelID, counterpartyChannelID, counterpartyVersion string) error } type OnChanOpenAckBeforeHooks interface { - OnChanOpenAckBeforeHook(ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string) + OnChanOpenAckBeforeHook(ctx sdk.Context, portID, channelID, counterpartyChannelID, counterpartyVersion string) } type OnChanOpenAckAfterHooks interface { - OnChanOpenAckAfterHook(ctx sdk.Context, portID, channelID string, counterpartyChannelID string, counterpartyVersion string, err error) + OnChanOpenAckAfterHook(ctx sdk.Context, portID, channelID, counterpartyChannelID, counterpartyVersion string, err error) } // OnChanOpenConfirm Hooks @@ -167,5 +167,5 @@ type GetAppVersionBeforeHooks interface { GetAppVersionBeforeHook(ctx sdk.Context, portID, channelID string) } type GetAppVersionAfterHooks interface { - GetAppVersionAfterHook(ctx sdk.Context, portID, channelID string, result string, success bool) + GetAppVersionAfterHook(ctx sdk.Context, portID, channelID, result string, success bool) } diff --git a/x/ibc-hooks/module.go b/x/ibc-hooks/module.go index ce32a8e2a..2f6813374 100644 --- a/x/ibc-hooks/module.go +++ b/x/ibc-hooks/module.go @@ -42,21 +42,21 @@ func (b AppModuleBasic) RegisterInterfaces(_ cdctypes.InterfaceRegistry) {} // DefaultGenesis returns default genesis state as raw bytes for the // module. -func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { +func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage { emptyString := "{}" return []byte(emptyString) } // ValidateGenesis performs genesis state validation for the ibc-hooks module. -func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { +func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { return nil } // RegisterRESTRoutes registers the REST routes for the ibc-hooks module. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {} +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, rtr *mux.Router) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc-hooks module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) {} +func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, mux *runtime.ServeMux) {} // GetTxCmd returns no root tx command for the ibc-hooks module. func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } @@ -95,21 +95,21 @@ func (AppModule) QuerierRoute() string { // RegisterServices registers a gRPC query service to respond to the // module-specific gRPC queries. -func (am AppModule) RegisterServices(cfg module.Configurator) { +func (am AppModule) RegisterServices(_ module.Configurator) { } // InitGenesis performs genesis initialization for the ibc-hooks module. It returns // no validator updates. -func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { +func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } -func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { +func (am AppModule) ExportGenesis(_ sdk.Context, _ codec.JSONCodec) json.RawMessage { return json.RawMessage([]byte("{}")) } // BeginBlock returns the begin blocker for the ibc-hooks module. -func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) { } // EndBlock returns the end blocker for the ibc-hooks module. It returns no validator diff --git a/x/ibc-hooks/wasm_hook.go b/x/ibc-hooks/wasm_hook.go index b4798677b..b3b194af4 100644 --- a/x/ibc-hooks/wasm_hook.go +++ b/x/ibc-hooks/wasm_hook.go @@ -210,7 +210,7 @@ func (h WasmHooks) OnAcknowledgementPacketOverride(im IBCMiddleware, ctx sdk.Con } // Notify the sender that the ack has been received - ackAsJson, err := json.Marshal(acknowledgement) + ackAsJSON, err := json.Marshal(acknowledgement) if err != nil { // If the ack is not a json object, error return err @@ -218,7 +218,7 @@ func (h WasmHooks) OnAcknowledgementPacketOverride(im IBCMiddleware, ctx sdk.Con sudoMsg := []byte(fmt.Sprintf( `{"ibc_lifecycle_complete": {"ibc_ack": {"channel": "%s", "sequence": %d, "ack": %s, "success": %s}}}`, - packet.SourceChannel, packet.Sequence, ackAsJson, success)) + packet.SourceChannel, packet.Sequence, ackAsJSON, success)) _, err = h.ContractKeeper.Sudo(ctx, contractAddr, sudoMsg) if err != nil { // error processing the callback From 392f4ea412fb784038fdd6a0fdcf3d2e082de42e Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Thu, 20 Jul 2023 12:01:02 +0700 Subject: [PATCH 05/20] lint --- app/app.go | 2 +- app/ibctesting/chain.go | 4 ++-- app/ibctesting/event_utils.go | 6 +++--- app/upgrades/v4/upgrade.go | 4 ++-- x/ibc-hooks/module.go | 8 ++++---- x/ibc-hooks/wasm_hook.go | 2 +- x/ratelimit/keeper/abci.go | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/app.go b/app/app.go index 82c64a285..12d8e88a3 100644 --- a/app/app.go +++ b/app/app.go @@ -702,7 +702,7 @@ func (app *CentauriApp) setupUpgradeStoreLoaders() { } } -func (app *CentauriApp) customPreUpgradeHandler(upgradeInfo upgradetypes.Plan) { +func (app *CentauriApp) customPreUpgradeHandler(_ upgradetypes.Plan) { // switch upgradeInfo.Name { // default: // } diff --git a/app/ibctesting/chain.go b/app/ibctesting/chain.go index c61d29598..03b41b1ad 100644 --- a/app/ibctesting/chain.go +++ b/app/ibctesting/chain.go @@ -650,7 +650,7 @@ func (chain *TestChain) StoreContractCode(suite *suite.Suite, path string) { wasmCode, err := os.ReadFile(path) suite.Require().NoError(err) - src := wasmtypes.StoreCodeProposalFixture(func(p *wasmtypes.StoreCodeProposal) { + src := wasmtypes.StoreCodeProposalFixture(func(p *wasmtypes.StoreCodeProposal) { //nolint: staticcheck p.RunAs = govModuleAddress.String() p.WASMByteCode = wasmCode checksum := sha256.Sum256(wasmCode) @@ -685,7 +685,7 @@ func mustSubmitAndExecuteLegacyProposal(t *testing.T, ctx sdk.Context, content v } // does not fail on submit proposal -func submitLegacyProposal(t *testing.T, ctx sdk.Context, content v1beta1.Content, myActorAddress string, govAuthority string, msgServer v1.MsgServer) (*v1.MsgExecLegacyContent, error) { +func submitLegacyProposal(t *testing.T, ctx sdk.Context, content v1beta1.Content, myActorAddress, govAuthority string, msgServer v1.MsgServer) (*v1.MsgExecLegacyContent, error) { t.Helper() contentMsg, err := v1.NewLegacyContent(content, govAuthority) require.NoError(t, err) diff --git a/app/ibctesting/event_utils.go b/app/ibctesting/event_utils.go index dea990a82..b0d268dd0 100644 --- a/app/ibctesting/event_utils.go +++ b/app/ibctesting/event_utils.go @@ -65,12 +65,12 @@ func ParsePacketFromEvents(events sdk.Events) (channeltypes.Packet, error) { if ev.Type == channeltypes.EventTypeSendPacket { packet := channeltypes.Packet{} for _, attr := range ev.Attributes { - switch string(attr.Key) { - case channeltypes.AttributeKeyData: + switch attr.Key { + case channeltypes.AttributeKeyDataHex: packet.Data = []byte(attr.Value) case channeltypes.AttributeKeySequence: - seq, err := strconv.ParseUint(string(attr.Value), 10, 64) + seq, err := strconv.ParseUint(attr.Value, 10, 64) if err != nil { return channeltypes.Packet{}, err } diff --git a/app/upgrades/v4/upgrade.go b/app/upgrades/v4/upgrade.go index 45f489ce1..f38149200 100644 --- a/app/upgrades/v4/upgrade.go +++ b/app/upgrades/v4/upgrade.go @@ -11,8 +11,8 @@ import ( func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, - bpm upgrades.BaseAppParamManager, - keepers *keepers.AppKeepers, + _ upgrades.BaseAppParamManager, + _ *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { return mm.RunMigrations(ctx, configurator, vm) diff --git a/x/ibc-hooks/module.go b/x/ibc-hooks/module.go index 2f6813374..e0bc65430 100644 --- a/x/ibc-hooks/module.go +++ b/x/ibc-hooks/module.go @@ -48,15 +48,15 @@ func (AppModuleBasic) DefaultGenesis(_ codec.JSONCodec) json.RawMessage { } // ValidateGenesis performs genesis state validation for the ibc-hooks module. -func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { +func (AppModuleBasic) ValidateGenesis(_ codec.JSONCodec, _ client.TxEncodingConfig, _ json.RawMessage) error { return nil } // RegisterRESTRoutes registers the REST routes for the ibc-hooks module. -func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, rtr *mux.Router) {} +func (AppModuleBasic) RegisterRESTRoutes(_ client.Context, _ *mux.Router) {} // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the ibc-hooks module. -func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, mux *runtime.ServeMux) {} +func (AppModuleBasic) RegisterGRPCGatewayRoutes(_ client.Context, _ *runtime.ServeMux) {} // GetTxCmd returns no root tx command for the ibc-hooks module. func (AppModuleBasic) GetTxCmd() *cobra.Command { return nil } @@ -100,7 +100,7 @@ func (am AppModule) RegisterServices(_ module.Configurator) { // InitGenesis performs genesis initialization for the ibc-hooks module. It returns // no validator updates. -func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { +func (am AppModule) InitGenesis(_ sdk.Context, _ codec.JSONCodec, _ json.RawMessage) []abci.ValidatorUpdate { return []abci.ValidatorUpdate{} } diff --git a/x/ibc-hooks/wasm_hook.go b/x/ibc-hooks/wasm_hook.go index b3b194af4..b48c6bf8e 100644 --- a/x/ibc-hooks/wasm_hook.go +++ b/x/ibc-hooks/wasm_hook.go @@ -273,7 +273,7 @@ func (h WasmHooks) OnTimeoutPacketOverride(im IBCMiddleware, ctx sdk.Context, pa return nil } -func ValidateAndParseMemo(memo string, receiver string) (isWasmRouted bool, contractAddr sdk.AccAddress, msgBytes []byte, err error) { +func ValidateAndParseMemo(memo, receiver string) (isWasmRouted bool, contractAddr sdk.AccAddress, msgBytes []byte, err error) { isWasmRouted, metadata := jsonStringHasKey(memo, "wasm") if !isWasmRouted { return isWasmRouted, sdk.AccAddress{}, nil, nil diff --git a/x/ratelimit/keeper/abci.go b/x/ratelimit/keeper/abci.go index 1674ae91c..059371d28 100644 --- a/x/ratelimit/keeper/abci.go +++ b/x/ratelimit/keeper/abci.go @@ -17,7 +17,7 @@ func (k Keeper) BeginBlocker(ctx sdk.Context) { // If blocktime < initial epoch start time, return if ctx.BlockTime().Before(epochInfo.StartTime) { - return + return true } // if epoch counting hasn't started, signal we need to start. shouldInitialEpochStart := !epochInfo.EpochCountingStarted From 0bea6b7a6b3a5aab64e2c4c33c9662b55b188761 Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Thu, 20 Jul 2023 12:10:36 +0700 Subject: [PATCH 06/20] revert AttributeKeyData --- app/ibctesting/event_utils.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ibctesting/event_utils.go b/app/ibctesting/event_utils.go index b0d268dd0..8b6ed2981 100644 --- a/app/ibctesting/event_utils.go +++ b/app/ibctesting/event_utils.go @@ -66,7 +66,7 @@ func ParsePacketFromEvents(events sdk.Events) (channeltypes.Packet, error) { packet := channeltypes.Packet{} for _, attr := range ev.Attributes { switch attr.Key { - case channeltypes.AttributeKeyDataHex: + case channeltypes.AttributeKeyData: //nolint: staticcheck packet.Data = []byte(attr.Value) case channeltypes.AttributeKeySequence: From d8c5042bfb470d967ea4e4c301b27a384afeae1d Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Thu, 20 Jul 2023 12:56:14 +0700 Subject: [PATCH 07/20] revert keeper --- app/upgrades/v4/upgrade.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v4/upgrade.go b/app/upgrades/v4/upgrade.go index 107063971..6557fe3de 100644 --- a/app/upgrades/v4/upgrade.go +++ b/app/upgrades/v4/upgrade.go @@ -13,7 +13,7 @@ func CreateUpgradeHandler( mm *module.Manager, configurator module.Configurator, _ upgrades.BaseAppParamManager, - _ *keepers.AppKeepers, + keepers *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { // Add params for transfer middleware From ef01d6c1656a20296fb87c496606dd32444c2758 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=E1=BA=B7c?= Date: Tue, 1 Aug 2023 12:39:42 +0700 Subject: [PATCH 08/20] custom bank total supply logic and test --- custom/bank/bank_test.go | 32 +++++++++++++++++++++++++-- x/transfermiddleware/keeper/keeper.go | 5 +++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/custom/bank/bank_test.go b/custom/bank/bank_test.go index 252b03ce5..bb72961e4 100644 --- a/custom/bank/bank_test.go +++ b/custom/bank/bank_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" customibctesting "github.com/notional-labs/centauri/v4/app/ibctesting" "github.com/stretchr/testify/suite" @@ -48,24 +49,30 @@ func (suite *CustomBankTestSuite) TestTotalSupply() { var ( transferAmount = sdk.NewInt(1000000000) // when transfer via sdk transfer from A (module) -> B (contract) - coinToSendToB = sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) - timeoutHeight = clienttypes.NewHeight(1, 110) + coinToSendToB = sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) + timeoutHeight = clienttypes.NewHeight(1, 110) + originAmt, err = sdk.NewIntFromString("10000000001100000000000") + chainBOriginSuply = sdk.NewCoin("stake", originAmt) ) + suite.Require().True(err) var ( expChainBBalanceDiff sdk.Coin path = NewTransferPath(suite.chainA, suite.chainB) + escrowAddr = transfertypes.GetEscrowAddress(transfertypes.PortID, "channel-0") ) testCases := []struct { name string expChainABalanceDiff sdk.Coin expTotalSupplyDiff sdk.Coins + expChainBTotalSuppy sdk.Coins malleate func() }{ { "Total supply with no transfermiddleware setup", sdk.NewCoin(sdk.DefaultBondDenom, transferAmount), sdk.Coins{sdk.NewCoin("ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878", transferAmount)}, + sdk.Coins{sdk.NewCoin("ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878", transferAmount), chainBOriginSuply}, func() { expChainBBalanceDiff = ibctransfertypes.GetTransferCoin(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, coinToSendToB.Denom, transferAmount) }, @@ -74,6 +81,7 @@ func (suite *CustomBankTestSuite) TestTotalSupply() { "Total supply with transfermiddleware setup", sdk.NewCoin(sdk.DefaultBondDenom, transferAmount), sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, transferAmount)), + sdk.Coins{chainBOriginSuply.Add(sdk.NewCoin("stake", transferAmount))}, func() { // Add parachain token info chainBtransMiddleware := suite.chainB.TransferMiddleware() @@ -82,6 +90,25 @@ func (suite *CustomBankTestSuite) TestTotalSupply() { suite.Require().NoError(err) }, }, + { + "Total supply with transfermiddleware setup and pre mint", + sdk.NewCoin(sdk.DefaultBondDenom, transferAmount), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, transferAmount)), + sdk.Coins{chainBOriginSuply.Add(sdk.NewCoin("stake", transferAmount))}, + func() { + // Premint for escrow + err := suite.chainB.GetBankKeeper().MintCoins(suite.chainB.GetContext(), "mint", sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000000000)))) + suite.Require().NoError(err) + err = suite.chainB.GetBankKeeper().SendCoinsFromModuleToAccount(suite.chainB.GetContext(), "mint", escrowAddr, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000000000)))) + suite.Require().NoError(err) + + // Add parachain token info + chainBtransMiddleware := suite.chainB.TransferMiddleware() + expChainBBalanceDiff = sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) + err = chainBtransMiddleware.AddParachainIBCInfo(suite.chainB.GetContext(), "ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878", "channel-0", sdk.DefaultBondDenom, sdk.DefaultBondDenom) + suite.Require().NoError(err) + }, + }, } for _, tc := range testCases { suite.Run(tc.name, func() { @@ -128,6 +155,7 @@ func (suite *CustomBankTestSuite) TestTotalSupply() { totalSupply, err := suite.chainB.GetBankKeeper().TotalSupply(suite.chainB.GetContext(), &banktypes.QueryTotalSupplyRequest{}) suite.Require().NoError(err) suite.Require().Equal(totalSupply.Supply, originalChainBTotalSupply.Supply.Add(tc.expTotalSupplyDiff...)) + suite.Require().Equal(totalSupply.Supply, tc.expChainBTotalSuppy) }) } } diff --git a/x/transfermiddleware/keeper/keeper.go b/x/transfermiddleware/keeper/keeper.go index 88423fc5b..dc1bb1b67 100644 --- a/x/transfermiddleware/keeper/keeper.go +++ b/x/transfermiddleware/keeper/keeper.go @@ -203,8 +203,9 @@ func (keeper Keeper) GetNativeDenomByIBCDenomSecondaryIndex(ctx sdk.Context, ibc func (keeper Keeper) GetTotalEscrowedToken(ctx sdk.Context) (coins sdk.Coins) { keeper.IterateParaTokenInfos(ctx, func(index int64, info types.ParachainIBCTokenInfo) (stop bool) { - escrowCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelId), info.IbcDenom) - coins = append(coins, escrowCoin) + escrowIbcCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelId), info.IbcDenom) + escrowNativeCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelId), info.NativeDenom) + coins = append(coins, escrowIbcCoin, escrowNativeCoin) return false }) From 42b58cc558aa67eb2cf4a5389928a60f649258f1 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Mon, 7 Aug 2023 16:11:39 +0700 Subject: [PATCH 09/20] add v4_5 fork upgrade --- app/app.go | 8 ++--- app/fork.go | 15 +++++++++ app/upgrades/v4_5/constants.go | 15 +++++++++ app/upgrades/v4_5/fork.go | 60 ++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 app/fork.go create mode 100644 app/upgrades/v4_5/constants.go create mode 100644 app/upgrades/v4_5/fork.go diff --git a/app/app.go b/app/app.go index e46157207..17735a958 100644 --- a/app/app.go +++ b/app/app.go @@ -31,7 +31,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/vesting" vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" "github.com/cosmos/cosmos-sdk/x/bank" - bech32stakingmigration "github.com/notional-labs/centauri/v4/bech32-migration/staking" "github.com/notional-labs/centauri/v4/app/keepers" v4 "github.com/notional-labs/centauri/v4/app/upgrades/v4" @@ -113,6 +112,7 @@ import ( "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + v4_5 "github.com/notional-labs/centauri/v4/app/upgrades/v4_5" upgrades "github.com/notional-labs/centauri/v4/app/upgrades" ) @@ -133,6 +133,7 @@ var ( EnableSpecificProposals = "" Upgrades = []upgrades.Upgrade{v4.Upgrade} + Forks = []upgrades.Fork{v4_5.Fork} ) // GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to @@ -576,10 +577,7 @@ func (app *CentauriApp) GetTxConfig() client.TxConfig { // BeginBlocker application updates every begin block func (app *CentauriApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { - if ctx.BlockHeight() == ForkHeight { - bech32stakingmigration.MigrateUnbonding(ctx, app.GetKey(stakingtypes.StoreKey), app.appCodec) - } - + BeginBlockForks(ctx, app) return app.mm.BeginBlock(ctx, req) } diff --git a/app/fork.go b/app/fork.go new file mode 100644 index 000000000..551862c27 --- /dev/null +++ b/app/fork.go @@ -0,0 +1,15 @@ +package app + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// BeginBlockForks is intended to be ran in a chain upgrade. +func BeginBlockForks(ctx sdk.Context, app *CentauriApp) { + for _, fork := range Forks { + if ctx.BlockHeight() == fork.UpgradeHeight { + fork.BeginForkLogic(ctx, &app.AppKeepers) + return + } + } +} diff --git a/app/upgrades/v4_5/constants.go b/app/upgrades/v4_5/constants.go new file mode 100644 index 000000000..a4b5843ac --- /dev/null +++ b/app/upgrades/v4_5/constants.go @@ -0,0 +1,15 @@ +package v45 + +import "github.com/notional-labs/centauri/v4/app/upgrades" + +const ( + // UpgradeName defines the on-chain upgrade name for the Centauri upgrade. + UpgradeName = "v4_5" + UpgradeHeight = 957554 +) + +var Fork = upgrades.Fork{ + UpgradeName: UpgradeName, + UpgradeHeight: UpgradeHeight, + BeginForkLogic: RunForkLogic, +} diff --git a/app/upgrades/v4_5/fork.go b/app/upgrades/v4_5/fork.go new file mode 100644 index 000000000..cdb131975 --- /dev/null +++ b/app/upgrades/v4_5/fork.go @@ -0,0 +1,60 @@ +package v45 + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/authz" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + + "github.com/notional-labs/centauri/v4/app/keepers" +) + +func RunForkLogic(ctx sdk.Context, appKeepers *keepers.AppKeepers) { + for i := 0; i < 100; i++ { + fmt.Println("Switching to v4_5 code") + } + + // Specifying the whole list instead of adding and removing. Less fragile. + hostParams := icahosttypes.Params{ + HostEnabled: true, + AllowMessages: []string{ + // Change: Normal Msg + sdk.MsgTypeURL(&banktypes.MsgSend{}), + sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}), + sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}), + sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}), + sdk.MsgTypeURL(&distrtypes.MsgSetWithdrawAddress{}), + sdk.MsgTypeURL(&distrtypes.MsgWithdrawValidatorCommission{}), + sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}), + sdk.MsgTypeURL(&govtypes.MsgVote{}), + sdk.MsgTypeURL(&authz.MsgExec{}), + sdk.MsgTypeURL(&authz.MsgGrant{}), + sdk.MsgTypeURL(&authz.MsgRevoke{}), + + // Change: Added MsgTrasnsfer + sdk.MsgTypeURL(&ibctransfertypes.MsgTransfer{}), + sdk.MsgTypeURL(&banktypes.MsgSend{}), + sdk.MsgTypeURL(&stakingtypes.MsgDelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgBeginRedelegate{}), + sdk.MsgTypeURL(&stakingtypes.MsgCreateValidator{}), + sdk.MsgTypeURL(&stakingtypes.MsgEditValidator{}), + + // Change: Added MsgUndelegate + sdk.MsgTypeURL(&stakingtypes.MsgUndelegate{}), + sdk.MsgTypeURL(&distrtypes.MsgWithdrawDelegatorReward{}), + sdk.MsgTypeURL(&distrtypes.MsgSetWithdrawAddress{}), + sdk.MsgTypeURL(&distrtypes.MsgWithdrawValidatorCommission{}), + sdk.MsgTypeURL(&distrtypes.MsgFundCommunityPool{}), + sdk.MsgTypeURL(&govtypes.MsgVote{}), + }, + } + appKeepers.ICAHostKeeper.SetParams(ctx, hostParams) +} From a02aac0933834e9943f8971934d6aa768803073f Mon Sep 17 00:00:00 2001 From: vuong177 Date: Mon, 7 Aug 2023 17:27:05 +0700 Subject: [PATCH 10/20] update fork height to 967554 --- app/upgrades/v4_5/constants.go | 2 +- msg.json | 72 ++++++++++++++++++++++++++++++++++ testnode.sh | 2 +- 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 msg.json diff --git a/app/upgrades/v4_5/constants.go b/app/upgrades/v4_5/constants.go index a4b5843ac..f17b5dd49 100644 --- a/app/upgrades/v4_5/constants.go +++ b/app/upgrades/v4_5/constants.go @@ -5,7 +5,7 @@ import "github.com/notional-labs/centauri/v4/app/upgrades" const ( // UpgradeName defines the on-chain upgrade name for the Centauri upgrade. UpgradeName = "v4_5" - UpgradeHeight = 957554 + UpgradeHeight = 967554 ) var Fork = upgrades.Fork{ diff --git a/msg.json b/msg.json new file mode 100644 index 000000000..902e0ee15 --- /dev/null +++ b/msg.json @@ -0,0 +1,72 @@ +{ + "body": { + "messages": [ + { + "@type": "/cosmos.gov.v1.MsgSubmitProposal", + "messages": [ + { + "@type": "/centauri.ratelimit.v1beta1.MsgAddRateLimit", + "authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq", + "denom": "ibc/EF48E6B1A1A19F47ECAEA62F5670C37C0580E86A9E88498B7E393EB6F49F33C0", + "channel_id": "channel-2", + "max_percent_send": "30", + "max_percent_recv": "30", + "duration_hours": "24" + }, + { + "@type": "/centauri.ratelimit.v1beta1.MsgAddRateLimit", + "authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq", + "denom": "ibc/47BD209179859CDE4A2806763D7189B6E6FE13A17880FE2B42DE1E6C1E329E23", + "channel_id": "channel-2", + "max_percent_send": "30", + "max_percent_recv": "30", + "duration_hours": "24" + }, + { + "@type": "/centauri.ratelimit.v1beta1.MsgAddRateLimit", + "authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq", + "denom": "ibc/F3EC9F834E57DF704FA3AEAF14E8391C2E58397FE56960AD70E67562990D8265", + "channel_id": "channel-2", + "max_percent_send": "30", + "max_percent_recv": "30", + "duration_hours": "24" + }, + { + "@type": "/centauri.ratelimit.v1beta1.MsgAddRateLimit", + "authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq", + "denom": "ibc/6727B2F071643B3841BD535ECDD4ED9CAE52ABDD0DCD07C3630811A7A37B215C", + "channel_id": "channel-2", + "max_percent_send": "30", + "max_percent_recv": "30", + "duration_hours": "24" + } + ], + "initial_deposit": [ + { + "denom": "ppica", + "amount": "500000000000000000" + } + ], + "proposer": "centauri10556m38z4x6pqalr9rl5ytf3cff8q46nk85k9m", + "metadata": "Add Transfer RateLimit", + "title": "Add Transfer RateLimit", + "summary": "Add Transfer RateLimit for ATOM and OSMO" + } + ], + "memo": "", + "timeout_height": "0", + "extension_options": [], + "non_critical_extension_options": [] + }, + "auth_info": { + "signer_infos": [], + "fee": { + "amount": [], + "gas_limit": "200000", + "payer": "", + "granter": "" + }, + "tip": null + }, + "signatures": [] +} \ No newline at end of file diff --git a/testnode.sh b/testnode.sh index a1bf9649d..34f2fda31 100644 --- a/testnode.sh +++ b/testnode.sh @@ -44,4 +44,4 @@ sed -i'' -e 's/max_body_bytes = /max_body_bytes = 1/g' ~/.banksy/config/config.t cat $HOME/.banksy/config/genesis.json | jq '.app_state["gov"]["params"]["voting_period"]="45s"' > $HOME/.banksy/config/tmp_genesis.json && mv $HOME/.banksy/config/tmp_genesis.json $HOME/.banksy/config/genesis.json # Start the node (remove the --pruning=nothing flag if historical queries are not needed) -centaurid start --pruning=nothing --minimum-gas-prices=0stake +# centaurid start --pruning=nothing --minimum-gas-prices=0stake From c1c3bb81598b4c9b01c75c20952723ac2129f3ca Mon Sep 17 00:00:00 2001 From: vuong177 Date: Mon, 7 Aug 2023 17:27:21 +0700 Subject: [PATCH 11/20] minor --- msg.json | 72 -------------------------------------------------------- 1 file changed, 72 deletions(-) delete mode 100644 msg.json diff --git a/msg.json b/msg.json deleted file mode 100644 index 902e0ee15..000000000 --- a/msg.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "body": { - "messages": [ - { - "@type": "/cosmos.gov.v1.MsgSubmitProposal", - "messages": [ - { - "@type": "/centauri.ratelimit.v1beta1.MsgAddRateLimit", - "authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq", - "denom": "ibc/EF48E6B1A1A19F47ECAEA62F5670C37C0580E86A9E88498B7E393EB6F49F33C0", - "channel_id": "channel-2", - "max_percent_send": "30", - "max_percent_recv": "30", - "duration_hours": "24" - }, - { - "@type": "/centauri.ratelimit.v1beta1.MsgAddRateLimit", - "authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq", - "denom": "ibc/47BD209179859CDE4A2806763D7189B6E6FE13A17880FE2B42DE1E6C1E329E23", - "channel_id": "channel-2", - "max_percent_send": "30", - "max_percent_recv": "30", - "duration_hours": "24" - }, - { - "@type": "/centauri.ratelimit.v1beta1.MsgAddRateLimit", - "authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq", - "denom": "ibc/F3EC9F834E57DF704FA3AEAF14E8391C2E58397FE56960AD70E67562990D8265", - "channel_id": "channel-2", - "max_percent_send": "30", - "max_percent_recv": "30", - "duration_hours": "24" - }, - { - "@type": "/centauri.ratelimit.v1beta1.MsgAddRateLimit", - "authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq", - "denom": "ibc/6727B2F071643B3841BD535ECDD4ED9CAE52ABDD0DCD07C3630811A7A37B215C", - "channel_id": "channel-2", - "max_percent_send": "30", - "max_percent_recv": "30", - "duration_hours": "24" - } - ], - "initial_deposit": [ - { - "denom": "ppica", - "amount": "500000000000000000" - } - ], - "proposer": "centauri10556m38z4x6pqalr9rl5ytf3cff8q46nk85k9m", - "metadata": "Add Transfer RateLimit", - "title": "Add Transfer RateLimit", - "summary": "Add Transfer RateLimit for ATOM and OSMO" - } - ], - "memo": "", - "timeout_height": "0", - "extension_options": [], - "non_critical_extension_options": [] - }, - "auth_info": { - "signer_infos": [], - "fee": { - "amount": [], - "gas_limit": "200000", - "payer": "", - "granter": "" - }, - "tip": null - }, - "signatures": [] -} \ No newline at end of file From d198a8c6bcb61f272f19a81e39fde124549cf3ee Mon Sep 17 00:00:00 2001 From: GnaD13 Date: Tue, 15 Aug 2023 09:49:42 +0700 Subject: [PATCH 12/20] add min amount for rate limit --- proto/centauri/ratelimit/v1beta1/params.proto | 7 +- x/ratelimit/keeper/keeper.go | 10 +- x/ratelimit/keeper/rate_limit.go | 9 +- x/ratelimit/relay_test.go | 258 +++++++++++++++++- x/ratelimit/types/flow.go | 8 +- x/ratelimit/types/params.go | 33 ++- x/ratelimit/types/params.pb.go | 65 ++++- x/ratelimit/types/quota.go | 6 +- 8 files changed, 366 insertions(+), 30 deletions(-) diff --git a/proto/centauri/ratelimit/v1beta1/params.proto b/proto/centauri/ratelimit/v1beta1/params.proto index 22186f8ac..f3fddc98b 100644 --- a/proto/centauri/ratelimit/v1beta1/params.proto +++ b/proto/centauri/ratelimit/v1beta1/params.proto @@ -7,4 +7,9 @@ import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; // Params holds parameters for the mint module. -message Params {} +message Params { + string min_rate_limit_amount = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} diff --git a/x/ratelimit/keeper/keeper.go b/x/ratelimit/keeper/keeper.go index 0962b61b5..b7b5d5970 100644 --- a/x/ratelimit/keeper/keeper.go +++ b/x/ratelimit/keeper/keeper.go @@ -38,6 +38,11 @@ func NewKeeper( tfmwKeeper tfmwkeeper.Keeper, authority string, ) *Keeper { + // set KeyTable if it has not already been set + if !ps.HasKeyTable() { + ps = ps.WithKeyTable(types.ParamKeyTable()) + } + return &Keeper{ cdc: cdc, storeKey: key, @@ -55,8 +60,9 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { } // GetParams get all parameters as types.Params -func (k Keeper) GetParams(ctx sdk.Context) types.Params { - return types.NewParams() +func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { + k.paramstore.GetParamSet(ctx, ¶ms) + return params } // SetParams set the params diff --git a/x/ratelimit/keeper/rate_limit.go b/x/ratelimit/keeper/rate_limit.go index ca3b09c9d..3e385f63c 100644 --- a/x/ratelimit/keeper/rate_limit.go +++ b/x/ratelimit/keeper/rate_limit.go @@ -41,12 +41,13 @@ func EmitTransferDeniedEvent(ctx sdk.Context, reason, denom, channelId string, d } // Adds an amount to the flow in either the SEND or RECV direction -func (k Keeper) UpdateFlow(rateLimit types.RateLimit, direction types.PacketDirection, amount math.Int) error { +func (k Keeper) UpdateFlow(ctx sdk.Context, rateLimit types.RateLimit, direction types.PacketDirection, amount math.Int) error { + minRateLimitAmount := k.GetParams(ctx).MinRateLimitAmount switch direction { case types.PACKET_SEND: - return rateLimit.Flow.AddOutflow(amount, *rateLimit.Quota) + return rateLimit.Flow.AddOutflow(amount, *rateLimit.Quota, minRateLimitAmount) case types.PACKET_RECV: - return rateLimit.Flow.AddInflow(amount, *rateLimit.Quota) + return rateLimit.Flow.AddInflow(amount, *rateLimit.Quota, minRateLimitAmount) default: return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid packet direction (%s)", direction.String()) } @@ -75,7 +76,7 @@ func (k Keeper) CheckRateLimitAndUpdateFlow( return false, nil } // Update the flow object with the change in amount - if err := k.UpdateFlow(rateLimit, direction, amount); err != nil { + if err := k.UpdateFlow(ctx, rateLimit, direction, amount); err != nil { // If the rate limit was exceeded, emit an event EmitTransferDeniedEvent(ctx, types.EventRateLimitExceeded, denom, channelId, direction, amount, err) return false, err diff --git a/x/ratelimit/relay_test.go b/x/ratelimit/relay_test.go index 50d9ec1b4..2c87eb44c 100644 --- a/x/ratelimit/relay_test.go +++ b/x/ratelimit/relay_test.go @@ -45,7 +45,7 @@ func TestKeeperTestSuite(t *testing.T) { func (suite *RateLimitTestSuite) TestReceiveIBCToken() { var ( - transferAmount = sdk.NewInt(1000000000) + transferAmount = sdk.NewInt(1_000_000_000_000) // when transfer via sdk transfer from A (module) -> B (contract) ibcDenom = "ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878" nativeDenom = "ppica" @@ -68,7 +68,16 @@ func (suite *RateLimitTestSuite) TestReceiveIBCToken() { originalChainABalance := suite.chainA.AllBalances(suite.chainA.SenderAccount.GetAddress()) originalChainBBalance := suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) - msg := transfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, nativeTokenSendOnChainA, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0, "") + msg := transfertypes.NewMsgTransfer( + path.EndpointA.ChannelConfig.PortID, + path.EndpointA.ChannelID, + nativeTokenSendOnChainA, + suite.chainA.SenderAccount.GetAddress().String(), + suite.chainB.SenderAccount.GetAddress().String(), + timeoutHeight, + 0, + "", + ) _, err = suite.chainA.SendMsgs(msg) suite.Require().NoError(err) suite.Require().NoError(err, path.EndpointB.UpdateClient()) @@ -100,8 +109,8 @@ func (suite *RateLimitTestSuite) TestReceiveIBCToken() { msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ Denom: nativeDenom, ChannelId: path.EndpointB.ChannelID, - MaxPercentSend: sdk.NewInt(5), - MaxPercentRecv: sdk.NewInt(5), + MaxPercentSend: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 + MaxPercentRecv: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 DurationHours: 1, } err = chainBRateLimitKeeper.AddRateLimit(suite.chainB.GetContext(), &msgAddRateLimit) @@ -155,7 +164,7 @@ func (suite *RateLimitTestSuite) TestReceiveIBCToken() { func (suite *RateLimitTestSuite) TestSendIBCToken() { var ( - transferAmount = sdk.NewInt(1000000000) + transferAmount = sdk.NewInt(1_000_000_000_000) // when transfer via sdk transfer from A (module) -> B (contract) ibcDenom = "ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878" nativeDenom = "ppica" @@ -211,8 +220,8 @@ func (suite *RateLimitTestSuite) TestSendIBCToken() { msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ Denom: nativeDenom, ChannelId: path.EndpointB.ChannelID, - MaxPercentSend: sdk.NewInt(5), - MaxPercentRecv: sdk.NewInt(5), + MaxPercentSend: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 + MaxPercentRecv: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 DurationHours: 1, } err = chainBRateLimitKeeper.AddRateLimit(suite.chainB.GetContext(), &msgAddRateLimit) @@ -259,3 +268,238 @@ func (suite *RateLimitTestSuite) TestSendIBCToken() { balances := suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) suite.Require().Equal(expBalance, balances) } + +func (suite *RateLimitTestSuite) TestReceiveIBCTokenWithMinRateLimitAmount() { + var ( + transferAmount = sdk.NewInt(100_000_000_000) + // when transfer via sdk transfer from A (module) -> B (contract) + ibcDenom = "ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878" + nativeDenom = "ppica" + nativeTokenSendOnChainA = sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) + nativeTokenReceiveOnChainB = sdk.NewCoin(nativeDenom, transferAmount) + timeoutHeight = clienttypes.NewHeight(1, 110) + expChainABalanceDiff = sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) + ) + + suite.SetupTest() // reset + + path := NewTransferPath(suite.chainA, suite.chainB) + suite.coordinator.Setup(path) + + // Add parachain token info + chainBtransMiddlewareKeeper := suite.chainB.TransferMiddleware() + err := chainBtransMiddlewareKeeper.AddParachainIBCInfo(suite.chainB.GetContext(), ibcDenom, path.EndpointB.ChannelID, nativeDenom, sdk.DefaultBondDenom) + suite.Require().NoError(err) + + originalChainABalance := suite.chainA.AllBalances(suite.chainA.SenderAccount.GetAddress()) + originalChainBBalance := suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) + + msg := transfertypes.NewMsgTransfer( + path.EndpointA.ChannelConfig.PortID, + path.EndpointA.ChannelID, + nativeTokenSendOnChainA, + suite.chainA.SenderAccount.GetAddress().String(), + suite.chainB.SenderAccount.GetAddress().String(), + timeoutHeight, + 0, + "", + ) + _, err = suite.chainA.SendMsgs(msg) + suite.Require().NoError(err) + suite.Require().NoError(err, path.EndpointB.UpdateClient()) + + // then + suite.Require().Equal(1, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + // and when relay to chain B and handle Ack on chain A + err = suite.coordinator.RelayAndAckPendingPackets(path) + suite.Require().NoError(err) + + // then + suite.Require().Equal(0, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + // and source chain balance was decreased + newChainABalance := suite.chainA.AllBalances(suite.chainA.SenderAccount.GetAddress()) + suite.Require().Equal(originalChainABalance.Sub(expChainABalanceDiff), newChainABalance) + + // and dest chain balance contains voucher + expBalance := originalChainBBalance.Add(nativeTokenReceiveOnChainB) + gotBalance := suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) + + suite.Require().Equal(expBalance, gotBalance) + + // add rate limit + chainBRateLimitKeeper := suite.chainB.RateLimit() + msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ + Denom: nativeDenom, + ChannelId: path.EndpointB.ChannelID, + MaxPercentSend: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 + MaxPercentRecv: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 + DurationHours: 1, + } + err = chainBRateLimitKeeper.AddRateLimit(suite.chainB.GetContext(), &msgAddRateLimit) + suite.Require().NoError(err) + + // send from A to B + transferAmount = sdk.NewInt(10_000_000_000) + nativeTokenSendOnChainA = sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) + msg = transfertypes.NewMsgTransfer(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, nativeTokenSendOnChainA, suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), timeoutHeight, 0, "") + _, err = suite.chainA.SendMsgs(msg) + suite.Require().NoError(err) + suite.Require().NoError(err, path.EndpointB.UpdateClient()) + + // then + suite.Require().Equal(1, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + // and when relay to chain B and handle Ack on chain A + err = suite.coordinator.RelayAndAckPendingPackets(path) + suite.Require().NoError(err) + + // then + suite.Require().Equal(0, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + expBalance = expBalance.Add(sdk.NewCoin(nativeDenom, transferAmount)) + gotBalance = suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) + suite.Require().Equal(expBalance, gotBalance) + + // send 1 more time + _, err = suite.chainA.SendMsgs(msg) + suite.Require().NoError(err) + suite.Require().NoError(err, path.EndpointB.UpdateClient()) + + // then + suite.Require().Equal(1, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + // and when relay to chain B and handle Ack on chain A + err = suite.coordinator.RelayAndAckPendingPackets(path) + suite.Require().NoError(err) + + // then + suite.Require().Equal(0, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + // not receive token because catch the threshold => balances have no change + gotBalance = suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) + suite.Require().Equal(expBalance, gotBalance) +} + +func (suite *RateLimitTestSuite) TestSendIBCTokenWithMinRateLimitAmount() { + var ( + transferAmount = sdk.NewInt(100_000_000_000) + // when transfer via sdk transfer from A (module) -> B (contract) + ibcDenom = "ibc/C053D637CCA2A2BA030E2C5EE1B28A16F71CCB0E45E8BE52766DC1B241B77878" + nativeDenom = "ppica" + nativeTokenSendOnChainA = sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) + nativeTokenReceiveOnChainB = sdk.NewCoin(nativeDenom, transferAmount) + timeoutHeight = clienttypes.NewHeight(1, 110) + expChainABalanceDiff = sdk.NewCoin(sdk.DefaultBondDenom, transferAmount) + ) + + suite.SetupTest() // reset + + path := NewTransferPath(suite.chainA, suite.chainB) + suite.coordinator.Setup(path) + + // Add parachain token info + chainBtransMiddlewareKeeper := suite.chainB.TransferMiddleware() + err := chainBtransMiddlewareKeeper.AddParachainIBCInfo(suite.chainB.GetContext(), ibcDenom, path.EndpointB.ChannelID, nativeDenom, sdk.DefaultBondDenom) + suite.Require().NoError(err) + + originalChainABalance := suite.chainA.AllBalances(suite.chainA.SenderAccount.GetAddress()) + originalChainBBalance := suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) + + msg := transfertypes.NewMsgTransfer( + path.EndpointA.ChannelConfig.PortID, + path.EndpointA.ChannelID, + nativeTokenSendOnChainA, + suite.chainA.SenderAccount.GetAddress().String(), + suite.chainB.SenderAccount.GetAddress().String(), + timeoutHeight, + 0, + "", + ) + _, err = suite.chainA.SendMsgs(msg) + suite.Require().NoError(err) + suite.Require().NoError(err, path.EndpointB.UpdateClient()) + + // then + suite.Require().Equal(1, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + // and when relay to chain B and handle Ack on chain A + err = suite.coordinator.RelayAndAckPendingPackets(path) + suite.Require().NoError(err) + + // then + suite.Require().Equal(0, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + // and source chain balance was decreased + newChainABalance := suite.chainA.AllBalances(suite.chainA.SenderAccount.GetAddress()) + suite.Require().Equal(originalChainABalance.Sub(expChainABalanceDiff), newChainABalance) + + // and dest chain balance contains voucher + expBalance := originalChainBBalance.Add(nativeTokenReceiveOnChainB) + gotBalance := suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) + + suite.Require().Equal(expBalance, gotBalance) + + originalChainBBalance = gotBalance + // add rate limit 5% + chainBRateLimitKeeper := suite.chainB.RateLimit() + msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ + Denom: nativeDenom, + ChannelId: path.EndpointB.ChannelID, + MaxPercentSend: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 + MaxPercentRecv: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 + DurationHours: 1, + } + err = chainBRateLimitKeeper.AddRateLimit(suite.chainB.GetContext(), &msgAddRateLimit) + suite.Require().NoError(err) + + // send from B to A + transferAmount = sdk.NewInt(10_000_000_000) + nativeTokenSendOnChainB := sdk.NewCoin(nativeDenom, transferAmount) + msg = transfertypes.NewMsgTransfer(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID, nativeTokenSendOnChainB, suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), timeoutHeight, 0, "") + _, err = suite.chainB.SendMsgs(msg) + suite.Require().NoError(err) + suite.Require().NoError(err, path.EndpointA.UpdateClient()) + + // then + suite.Require().Equal(1, len(suite.chainB.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainA.PendingSendPackets)) + + // and when relay to chain B and handle Ack on chain A + err = suite.coordinator.RelayAndAckPendingPacketsReverse(path) + suite.Require().NoError(err) + + // then + suite.Require().Equal(0, len(suite.chainA.PendingSendPackets)) + suite.Require().Equal(0, len(suite.chainB.PendingSendPackets)) + + expBalance = originalChainBBalance.Sub(nativeTokenSendOnChainB) + gotBalance = suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) + suite.Require().Equal(expBalance, gotBalance) + + // send 1 more time + _, err = suite.chainB.SendMsgsWithExpPass(false, msg) + suite.Require().Error(err) // catch the threshold so should not be sent + + // SignAndDeliver calls app.Commit() + suite.chainB.NextBlock() + + // increment sequence for successful transaction execution + err = suite.chainB.SenderAccount.SetSequence(suite.chainB.SenderAccount.GetSequence() + 1) + suite.Require().NoError(err) + + suite.chainB.Coordinator.IncrementTime() + + // not receive token because catch the threshold => balances have no change + balances := suite.chainB.AllBalances(suite.chainB.SenderAccount.GetAddress()) + suite.Require().Equal(expBalance, balances) +} diff --git a/x/ratelimit/types/flow.go b/x/ratelimit/types/flow.go index dce7192ab..41edc2298 100644 --- a/x/ratelimit/types/flow.go +++ b/x/ratelimit/types/flow.go @@ -18,10 +18,10 @@ func NewFlow(channelValue math.Int) Flow { // Adds an amount to the rate limit's flow after an incoming packet was received // Returns an error if the new inflow will cause the rate limit to exceed its quota -func (f *Flow) AddInflow(amount math.Int, quota Quota) error { +func (f *Flow) AddInflow(amount math.Int, quota Quota, minRateLimit math.Int) error { netInflow := f.Inflow.Sub(f.Outflow).Add(amount) - if quota.CheckExceedsQuota(PACKET_RECV, netInflow, f.ChannelValue) { + if quota.CheckExceedsQuota(PACKET_RECV, netInflow, f.ChannelValue, minRateLimit) { return errorsmod.Wrapf(ErrQuotaExceeded, "Inflow exceeds quota - Net Inflow: %v, Channel Value: %v, Threshold: %v%%", netInflow, f.ChannelValue, quota.MaxPercentRecv) @@ -33,10 +33,10 @@ func (f *Flow) AddInflow(amount math.Int, quota Quota) error { // Adds an amount to the rate limit's flow after a packet was sent // Returns an error if the new outflow will cause the rate limit to exceed its quota -func (f *Flow) AddOutflow(amount math.Int, quota Quota) error { +func (f *Flow) AddOutflow(amount math.Int, quota Quota, minRateLimit math.Int) error { netOutflow := f.Outflow.Sub(f.Inflow).Add(amount) - if quota.CheckExceedsQuota(PACKET_SEND, netOutflow, f.ChannelValue) { + if quota.CheckExceedsQuota(PACKET_SEND, netOutflow, f.ChannelValue, minRateLimit) { return errorsmod.Wrapf(ErrQuotaExceeded, "Outflow exceeds quota - Net Outflow: %v, Channel Value: %v, Threshold: %v%%", netOutflow, f.ChannelValue, quota.MaxPercentSend) diff --git a/x/ratelimit/types/params.go b/x/ratelimit/types/params.go index 4f3215e35..642cbaafe 100644 --- a/x/ratelimit/types/params.go +++ b/x/ratelimit/types/params.go @@ -1,32 +1,55 @@ package types import ( + fmt "fmt" + + "cosmossdk.io/math" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) var _ paramtypes.ParamSet = (*Params)(nil) +var ( + DefaultMinRateLimitAmount = math.NewIntFromUint64(10_000_000_000) +) + +// Param keys store keys +var ( + KeyMinRateLimitAmount = []byte("minratelimitamount") +) + // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } // NewParams creates a new Params instance -func NewParams() Params { - return Params{} +func NewParams(minRateLimitAmount math.Int) Params { + return Params{MinRateLimitAmount: minRateLimitAmount} } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams() + return NewParams(DefaultMinRateLimitAmount) } -// ParamSetPairs get the params.ParamSet +// Implements params.ParamSet. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{} + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyMinRateLimitAmount, &p.MinRateLimitAmount, validateMinRateLimitAmount), + } } // Validate validates the set of params func (p Params) Validate() error { return nil } + +func validateMinRateLimitAmount(i interface{}) error { + _, ok := i.(math.Int) + if !ok { + return fmt.Errorf("invalid parameter type string: %T", i) + } + + return nil +} diff --git a/x/ratelimit/types/params.pb.go b/x/ratelimit/types/params.pb.go index bc9bf28dc..a620a9586 100644 --- a/x/ratelimit/types/params.pb.go +++ b/x/ratelimit/types/params.pb.go @@ -6,6 +6,7 @@ package types import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -26,6 +27,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params holds parameters for the mint module. type Params struct { + MinRateLimitAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=min_rate_limit_amount,json=minRateLimitAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_rate_limit_amount"` } func (m *Params) Reset() { *m = Params{} } @@ -70,17 +72,22 @@ func init() { } var fileDescriptor_1b21f4042f9a3cfb = []byte{ - // 152 bytes of a gzipped FileDescriptorProto + // 229 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4f, 0x4e, 0xcd, 0x2b, 0x49, 0x2c, 0x2d, 0xca, 0xd4, 0x2f, 0x4a, 0x2c, 0x49, 0xcd, 0xc9, 0xcc, 0xcd, 0x2c, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x82, 0x29, 0xd4, 0x83, 0x2b, 0xd4, 0x83, 0x2a, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd3, 0x07, 0xb1, 0x20, 0x3a, 0xa4, 0x24, 0x93, 0xf3, 0x8b, 0x73, - 0xf3, 0x8b, 0xe3, 0x21, 0x12, 0x10, 0x0e, 0x44, 0x4a, 0x89, 0x83, 0x8b, 0x2d, 0x00, 0x6c, 0xb8, - 0x93, 0xf6, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, - 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x09, 0x56, 0x20, 0x39, - 0xa9, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xac, 0xdb, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, - 0x91, 0xb5, 0x1b, 0x71, 0xb5, 0x00, 0x00, 0x00, + 0xf3, 0x8b, 0xe3, 0x21, 0x12, 0x10, 0x0e, 0x44, 0x4a, 0x29, 0x9b, 0x8b, 0x2d, 0x00, 0x6c, 0xb8, + 0x50, 0x22, 0x97, 0x68, 0x6e, 0x66, 0x5e, 0x3c, 0xc8, 0xcc, 0x78, 0xb0, 0xa1, 0xf1, 0x89, 0xb9, + 0xf9, 0xa5, 0x79, 0x25, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x7a, 0x27, 0xee, 0xc9, 0x33, + 0xdc, 0xba, 0x27, 0xaf, 0x96, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0x0b, 0x35, + 0x09, 0x4a, 0xe9, 0x16, 0xa7, 0x64, 0xeb, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0x79, 0xe6, 0x95, + 0x04, 0x09, 0xe5, 0x66, 0xe6, 0x05, 0x25, 0x96, 0xa4, 0xfa, 0x80, 0x8c, 0x72, 0x04, 0x9b, 0xe4, + 0xa4, 0x7d, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, + 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x82, 0x15, 0x48, 0xbe, + 0x06, 0x1b, 0x92, 0xc4, 0x06, 0x76, 0xa0, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x43, 0x79, + 0x57, 0x18, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -103,6 +110,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.MinRateLimitAmount.Size() + i -= size + if _, err := m.MinRateLimitAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintParams(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -123,6 +140,8 @@ func (m *Params) Size() (n int) { } var l int _ = l + l = m.MinRateLimitAmount.Size() + n += 1 + l + sovParams(uint64(l)) return n } @@ -161,6 +180,40 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinRateLimitAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinRateLimitAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/ratelimit/types/quota.go b/x/ratelimit/types/quota.go index 8bfa24581..092063b73 100644 --- a/x/ratelimit/types/quota.go +++ b/x/ratelimit/types/quota.go @@ -5,7 +5,7 @@ import ( ) // CheckExceedsQuota checks if new in/out flow is going to reach the max in/out or not -func (q *Quota) CheckExceedsQuota(direction PacketDirection, amount math.Int, totalValue math.Int) bool { +func (q *Quota) CheckExceedsQuota(direction PacketDirection, amount math.Int, totalValue math.Int, minRateLimitAmount math.Int) bool { // If there's no channel value (this should be almost impossible), it means there is no // supply of the asset, so we shoudn't prevent inflows/outflows if totalValue.IsZero() { @@ -18,5 +18,9 @@ func (q *Quota) CheckExceedsQuota(direction PacketDirection, amount math.Int, to threshold = totalValue.Mul(q.MaxPercentSend).Quo(math.NewInt(100)) } + if minRateLimitAmount.GT(threshold) { + threshold = minRateLimitAmount + } + return amount.GT(threshold) } From a1b4281320b1587ec48016f8871425f13fd3510e Mon Sep 17 00:00:00 2001 From: GNaD Date: Wed, 16 Aug 2023 19:35:37 +0700 Subject: [PATCH 13/20] change min amount addRateLimitMsg instead of params --- proto/centauri/ratelimit/v1beta1/params.proto | 7 +- .../ratelimit/v1beta1/ratelimit.proto | 4 + proto/centauri/ratelimit/v1beta1/tx.proto | 12 +- scripts/proposalRateLimit.json | 18 ++ x/ratelimit/client/cli/query.go | 30 ++- x/ratelimit/keeper/msg_server.go | 8 + x/ratelimit/keeper/rate_limit.go | 19 +- x/ratelimit/relay_test.go | 44 ++-- x/ratelimit/types/msg.go | 8 + x/ratelimit/types/params.go | 31 +-- x/ratelimit/types/params.pb.go | 65 +----- x/ratelimit/types/ratelimit.pb.go | 122 +++++++---- x/ratelimit/types/tx.pb.go | 194 +++++++++++++----- 13 files changed, 352 insertions(+), 210 deletions(-) create mode 100644 scripts/proposalRateLimit.json diff --git a/proto/centauri/ratelimit/v1beta1/params.proto b/proto/centauri/ratelimit/v1beta1/params.proto index f3fddc98b..22186f8ac 100644 --- a/proto/centauri/ratelimit/v1beta1/params.proto +++ b/proto/centauri/ratelimit/v1beta1/params.proto @@ -7,9 +7,4 @@ import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; // Params holds parameters for the mint module. -message Params { - string min_rate_limit_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} +message Params {} diff --git a/proto/centauri/ratelimit/v1beta1/ratelimit.proto b/proto/centauri/ratelimit/v1beta1/ratelimit.proto index 26a2bb0f3..e7228fe0b 100644 --- a/proto/centauri/ratelimit/v1beta1/ratelimit.proto +++ b/proto/centauri/ratelimit/v1beta1/ratelimit.proto @@ -48,6 +48,10 @@ message RateLimit { Path path = 1; Quota quota = 2; Flow flow = 3; + string min_rate_limit_amount = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; } message WhitelistedAddressPair { diff --git a/proto/centauri/ratelimit/v1beta1/tx.proto b/proto/centauri/ratelimit/v1beta1/tx.proto index 4012cb04d..038361472 100755 --- a/proto/centauri/ratelimit/v1beta1/tx.proto +++ b/proto/centauri/ratelimit/v1beta1/tx.proto @@ -30,7 +30,11 @@ message MsgAddRateLimit { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - uint64 duration_hours = 6; + string min_rate_limit_amount = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + uint64 duration_hours = 7; } message MsgAddRateLimitResponse {} @@ -51,7 +55,11 @@ message MsgUpdateRateLimit { (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - uint64 duration_hours = 6; + string min_rate_limit_amount = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + uint64 duration_hours = 7; } message MsgUpdateRateLimitResponse {} diff --git a/scripts/proposalRateLimit.json b/scripts/proposalRateLimit.json new file mode 100644 index 000000000..75d5c7db0 --- /dev/null +++ b/scripts/proposalRateLimit.json @@ -0,0 +1,18 @@ +{ + "messages": [ + { + "@type": "/centauri.ratelimit.v1beta1.MsgAddRateLimit", + "authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq", + "denom": "stake", + "channel_id": "channel-0", + "max_percent_send": "5", + "max_percent_recv": "5", + "min_rate_limit_amount": "10000000000", + "duration_hours": 1 + } + ], + "metadata": "AQ==", + "deposit": "10000000stake", + "title": "Proposal Title", + "summary": "Proposal Summary" +} \ No newline at end of file diff --git a/x/ratelimit/client/cli/query.go b/x/ratelimit/client/cli/query.go index 6b0ff3087..c88e39a33 100644 --- a/x/ratelimit/client/cli/query.go +++ b/x/ratelimit/client/cli/query.go @@ -6,6 +6,7 @@ import ( "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" "github.com/notional-labs/centauri/v4/x/ratelimit/types" ) @@ -21,6 +22,33 @@ func GetQueryCmd() *cobra.Command { RunE: client.ValidateCmd, } - cmd.AddCommand() + cmd.AddCommand( + GetCmdQueryAllRateLimits(), + ) + return cmd +} + +// GetCmdQueryAllRateLimits return all available rate limits. +func GetCmdQueryAllRateLimits() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-rate-limits", + Short: "Query all rate limits", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + queryClient := types.NewQueryClient(clientCtx) + + req := &types.QueryAllRateLimitsRequest{} + res, err := queryClient.AllRateLimits(cmd.Context(), req) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + return cmd } diff --git a/x/ratelimit/keeper/msg_server.go b/x/ratelimit/keeper/msg_server.go index ece478fde..9048997ba 100644 --- a/x/ratelimit/keeper/msg_server.go +++ b/x/ratelimit/keeper/msg_server.go @@ -30,6 +30,10 @@ func (k Keeper) AddTransferRateLimit(goCtx context.Context, msg *types.MsgAddRat return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) } + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + err := k.AddRateLimit(ctx, msg) if err != nil { return nil, err @@ -45,6 +49,10 @@ func (k Keeper) UpdateTransferRateLimit(goCtx context.Context, msg *types.MsgUpd return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) } + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + err := k.UpdateRateLimit(ctx, msg) if err != nil { return nil, err diff --git a/x/ratelimit/keeper/rate_limit.go b/x/ratelimit/keeper/rate_limit.go index 3e385f63c..0909f44c5 100644 --- a/x/ratelimit/keeper/rate_limit.go +++ b/x/ratelimit/keeper/rate_limit.go @@ -42,12 +42,11 @@ func EmitTransferDeniedEvent(ctx sdk.Context, reason, denom, channelId string, d // Adds an amount to the flow in either the SEND or RECV direction func (k Keeper) UpdateFlow(ctx sdk.Context, rateLimit types.RateLimit, direction types.PacketDirection, amount math.Int) error { - minRateLimitAmount := k.GetParams(ctx).MinRateLimitAmount switch direction { case types.PACKET_SEND: - return rateLimit.Flow.AddOutflow(amount, *rateLimit.Quota, minRateLimitAmount) + return rateLimit.Flow.AddOutflow(amount, *rateLimit.Quota, rateLimit.MinRateLimitAmount) case types.PACKET_RECV: - return rateLimit.Flow.AddInflow(amount, *rateLimit.Quota, minRateLimitAmount) + return rateLimit.Flow.AddInflow(amount, *rateLimit.Quota, rateLimit.MinRateLimitAmount) default: return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "invalid packet direction (%s)", direction.String()) } @@ -219,9 +218,10 @@ func (k Keeper) AddRateLimit(ctx sdk.Context, msg *types.MsgAddRateLimit) error } k.SetRateLimit(ctx, types.RateLimit{ - Path: &path, - Quota: "a, - Flow: &flow, + Path: &path, + Quota: "a, + Flow: &flow, + MinRateLimitAmount: msg.MinRateLimitAmount, }) return nil @@ -262,9 +262,10 @@ func (k Keeper) UpdateRateLimit(ctx sdk.Context, msg *types.MsgUpdateRateLimit) } k.SetRateLimit(ctx, types.RateLimit{ - Path: &path, - Quota: "a, - Flow: &flow, + Path: &path, + Quota: "a, + Flow: &flow, + MinRateLimitAmount: msg.MinRateLimitAmount, }) return nil diff --git a/x/ratelimit/relay_test.go b/x/ratelimit/relay_test.go index 2c87eb44c..e23fd1fab 100644 --- a/x/ratelimit/relay_test.go +++ b/x/ratelimit/relay_test.go @@ -107,11 +107,12 @@ func (suite *RateLimitTestSuite) TestReceiveIBCToken() { // add rate limit chainBRateLimitKeeper := suite.chainB.RateLimit() msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ - Denom: nativeDenom, - ChannelId: path.EndpointB.ChannelID, - MaxPercentSend: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 - MaxPercentRecv: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 - DurationHours: 1, + Denom: nativeDenom, + ChannelId: path.EndpointB.ChannelID, + MaxPercentSend: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 + MaxPercentRecv: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 + MinRateLimitAmount: sdk.NewInt(10_000_000_000), + DurationHours: 1, } err = chainBRateLimitKeeper.AddRateLimit(suite.chainB.GetContext(), &msgAddRateLimit) suite.Require().NoError(err) @@ -218,11 +219,12 @@ func (suite *RateLimitTestSuite) TestSendIBCToken() { // add rate limit chainBRateLimitKeeper := suite.chainB.RateLimit() msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ - Denom: nativeDenom, - ChannelId: path.EndpointB.ChannelID, - MaxPercentSend: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 - MaxPercentRecv: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 - DurationHours: 1, + Denom: nativeDenom, + ChannelId: path.EndpointB.ChannelID, + MaxPercentSend: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 + MaxPercentRecv: sdk.NewInt(5), // 50_000_000_000 > minRateLimitAmount(10_000_000_000) => RateLimit = 50_000_000_000 + MinRateLimitAmount: sdk.NewInt(10_000_000_000), + DurationHours: 1, } err = chainBRateLimitKeeper.AddRateLimit(suite.chainB.GetContext(), &msgAddRateLimit) suite.Require().NoError(err) @@ -333,11 +335,12 @@ func (suite *RateLimitTestSuite) TestReceiveIBCTokenWithMinRateLimitAmount() { // add rate limit chainBRateLimitKeeper := suite.chainB.RateLimit() msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ - Denom: nativeDenom, - ChannelId: path.EndpointB.ChannelID, - MaxPercentSend: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 - MaxPercentRecv: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 - DurationHours: 1, + Denom: nativeDenom, + ChannelId: path.EndpointB.ChannelID, + MaxPercentSend: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 + MaxPercentRecv: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 + MinRateLimitAmount: sdk.NewInt(10_000_000_000), + DurationHours: 1, } err = chainBRateLimitKeeper.AddRateLimit(suite.chainB.GetContext(), &msgAddRateLimit) suite.Require().NoError(err) @@ -453,11 +456,12 @@ func (suite *RateLimitTestSuite) TestSendIBCTokenWithMinRateLimitAmount() { // add rate limit 5% chainBRateLimitKeeper := suite.chainB.RateLimit() msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ - Denom: nativeDenom, - ChannelId: path.EndpointB.ChannelID, - MaxPercentSend: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 - MaxPercentRecv: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 - DurationHours: 1, + Denom: nativeDenom, + ChannelId: path.EndpointB.ChannelID, + MaxPercentSend: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 + MaxPercentRecv: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 + MinRateLimitAmount: sdk.NewInt(10_000_000_000), + DurationHours: 1, } err = chainBRateLimitKeeper.AddRateLimit(suite.chainB.GetContext(), &msgAddRateLimit) suite.Require().NoError(err) diff --git a/x/ratelimit/types/msg.go b/x/ratelimit/types/msg.go index caaaf77d6..d0541e994 100644 --- a/x/ratelimit/types/msg.go +++ b/x/ratelimit/types/msg.go @@ -76,6 +76,10 @@ func (msg *MsgAddRateLimit) ValidateBasic() error { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "either the max send or max receive threshold must be greater than 0") } + if msg.MinRateLimitAmount.LTE(math.ZeroInt()) { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "mint rate limit amount must be greater than 0") + } + if msg.DurationHours == 0 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "duration can not be zero") } @@ -144,6 +148,10 @@ func (msg *MsgUpdateRateLimit) ValidateBasic() error { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "either the max send or max receive threshold must be greater than 0") } + if msg.MinRateLimitAmount.LTE(math.ZeroInt()) { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "mint rate limit amount must be greater than 0") + } + if msg.DurationHours == 0 { return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "duration can not be zero") } diff --git a/x/ratelimit/types/params.go b/x/ratelimit/types/params.go index 642cbaafe..3e59a8f77 100644 --- a/x/ratelimit/types/params.go +++ b/x/ratelimit/types/params.go @@ -1,55 +1,32 @@ package types import ( - fmt "fmt" - - "cosmossdk.io/math" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) var _ paramtypes.ParamSet = (*Params)(nil) -var ( - DefaultMinRateLimitAmount = math.NewIntFromUint64(10_000_000_000) -) - -// Param keys store keys -var ( - KeyMinRateLimitAmount = []byte("minratelimitamount") -) - // ParamKeyTable the param key table for launch module func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } // NewParams creates a new Params instance -func NewParams(minRateLimitAmount math.Int) Params { - return Params{MinRateLimitAmount: minRateLimitAmount} +func NewParams() Params { + return Params{} } // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams(DefaultMinRateLimitAmount) + return NewParams() } // Implements params.ParamSet. func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { - return paramtypes.ParamSetPairs{ - paramtypes.NewParamSetPair(KeyMinRateLimitAmount, &p.MinRateLimitAmount, validateMinRateLimitAmount), - } + return paramtypes.ParamSetPairs{} } // Validate validates the set of params func (p Params) Validate() error { return nil } - -func validateMinRateLimitAmount(i interface{}) error { - _, ok := i.(math.Int) - if !ok { - return fmt.Errorf("invalid parameter type string: %T", i) - } - - return nil -} diff --git a/x/ratelimit/types/params.pb.go b/x/ratelimit/types/params.pb.go index a620a9586..bc9bf28dc 100644 --- a/x/ratelimit/types/params.pb.go +++ b/x/ratelimit/types/params.pb.go @@ -6,7 +6,6 @@ package types import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -27,7 +26,6 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params holds parameters for the mint module. type Params struct { - MinRateLimitAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=min_rate_limit_amount,json=minRateLimitAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_rate_limit_amount"` } func (m *Params) Reset() { *m = Params{} } @@ -72,22 +70,17 @@ func init() { } var fileDescriptor_1b21f4042f9a3cfb = []byte{ - // 229 bytes of a gzipped FileDescriptorProto + // 152 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4f, 0x4e, 0xcd, 0x2b, 0x49, 0x2c, 0x2d, 0xca, 0xd4, 0x2f, 0x4a, 0x2c, 0x49, 0xcd, 0xc9, 0xcc, 0xcd, 0x2c, 0xd1, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x82, 0x29, 0xd4, 0x83, 0x2b, 0xd4, 0x83, 0x2a, 0x94, 0x12, 0x49, 0xcf, 0x4f, 0xcf, 0x07, 0x2b, 0xd3, 0x07, 0xb1, 0x20, 0x3a, 0xa4, 0x24, 0x93, 0xf3, 0x8b, 0x73, - 0xf3, 0x8b, 0xe3, 0x21, 0x12, 0x10, 0x0e, 0x44, 0x4a, 0x29, 0x9b, 0x8b, 0x2d, 0x00, 0x6c, 0xb8, - 0x50, 0x22, 0x97, 0x68, 0x6e, 0x66, 0x5e, 0x3c, 0xc8, 0xcc, 0x78, 0xb0, 0xa1, 0xf1, 0x89, 0xb9, - 0xf9, 0xa5, 0x79, 0x25, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x7a, 0x27, 0xee, 0xc9, 0x33, - 0xdc, 0xba, 0x27, 0xaf, 0x96, 0x9e, 0x59, 0x92, 0x51, 0x9a, 0xa4, 0x97, 0x9c, 0x9f, 0x0b, 0x35, - 0x09, 0x4a, 0xe9, 0x16, 0xa7, 0x64, 0xeb, 0x97, 0x54, 0x16, 0xa4, 0x16, 0xeb, 0x79, 0xe6, 0x95, - 0x04, 0x09, 0xe5, 0x66, 0xe6, 0x05, 0x25, 0x96, 0xa4, 0xfa, 0x80, 0x8c, 0x72, 0x04, 0x9b, 0xe4, - 0xa4, 0x7d, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, - 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x82, 0x15, 0x48, 0xbe, - 0x06, 0x1b, 0x92, 0xc4, 0x06, 0x76, 0xa0, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x7f, 0x43, 0x79, - 0x57, 0x18, 0x01, 0x00, 0x00, + 0xf3, 0x8b, 0xe3, 0x21, 0x12, 0x10, 0x0e, 0x44, 0x4a, 0x89, 0x83, 0x8b, 0x2d, 0x00, 0x6c, 0xb8, + 0x93, 0xf6, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, + 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x09, 0x56, 0x20, 0x39, + 0xa9, 0xa4, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, 0xac, 0xdb, 0x18, 0x10, 0x00, 0x00, 0xff, 0xff, + 0x91, 0xb5, 0x1b, 0x71, 0xb5, 0x00, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -110,16 +103,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.MinRateLimitAmount.Size() - i -= size - if _, err := m.MinRateLimitAmount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -140,8 +123,6 @@ func (m *Params) Size() (n int) { } var l int _ = l - l = m.MinRateLimitAmount.Size() - n += 1 + l + sovParams(uint64(l)) return n } @@ -180,40 +161,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinRateLimitAmount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.MinRateLimitAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/ratelimit/types/ratelimit.pb.go b/x/ratelimit/types/ratelimit.pb.go index af9923387..b52500264 100644 --- a/x/ratelimit/types/ratelimit.pb.go +++ b/x/ratelimit/types/ratelimit.pb.go @@ -187,9 +187,10 @@ func (m *Flow) XXX_DiscardUnknown() { var xxx_messageInfo_Flow proto.InternalMessageInfo type RateLimit struct { - Path *Path `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` - Quota *Quota `protobuf:"bytes,2,opt,name=quota,proto3" json:"quota,omitempty"` - Flow *Flow `protobuf:"bytes,3,opt,name=flow,proto3" json:"flow,omitempty"` + Path *Path `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + Quota *Quota `protobuf:"bytes,2,opt,name=quota,proto3" json:"quota,omitempty"` + Flow *Flow `protobuf:"bytes,3,opt,name=flow,proto3" json:"flow,omitempty"` + MinRateLimitAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=min_rate_limit_amount,json=minRateLimitAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_rate_limit_amount"` } func (m *RateLimit) Reset() { *m = RateLimit{} } @@ -312,40 +313,41 @@ func init() { } var fileDescriptor_825b72046a6cedeb = []byte{ - // 516 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xdd, 0x6a, 0x13, 0x41, - 0x14, 0xde, 0xb1, 0x69, 0x34, 0x27, 0xb6, 0x8d, 0x43, 0x29, 0x21, 0xe0, 0x36, 0x06, 0x94, 0x52, - 0x71, 0x43, 0xab, 0x20, 0xe2, 0x55, 0x7f, 0x52, 0x5a, 0x2c, 0x12, 0x37, 0x52, 0xc5, 0x9b, 0x30, - 0xd9, 0x39, 0x66, 0x87, 0x66, 0x77, 0xe2, 0xec, 0x6c, 0x1a, 0xdf, 0xc0, 0x4b, 0xdf, 0xc1, 0x17, - 0xf0, 0x31, 0x7a, 0xd9, 0x4b, 0xf1, 0xa2, 0x48, 0x72, 0xed, 0x3b, 0xc8, 0xcc, 0x6e, 0x6c, 0x11, - 0x54, 0xac, 0x57, 0xbb, 0xe7, 0x9b, 0xef, 0x7c, 0x33, 0xdf, 0xcc, 0x77, 0x60, 0x3d, 0xc0, 0x58, - 0xb3, 0x54, 0x89, 0xa6, 0x62, 0x1a, 0x07, 0x22, 0x12, 0xba, 0x39, 0xda, 0xe8, 0xa1, 0x66, 0x1b, - 0x17, 0x88, 0x37, 0x54, 0x52, 0x4b, 0x5a, 0x9b, 0x71, 0xbd, 0x8b, 0x95, 0x9c, 0x5b, 0x5b, 0xee, - 0xcb, 0xbe, 0xb4, 0xb4, 0xa6, 0xf9, 0xcb, 0x3a, 0x1a, 0x4f, 0xa1, 0xd0, 0x66, 0x3a, 0xa4, 0xcb, - 0x30, 0xcf, 0x31, 0x96, 0x51, 0x95, 0xd4, 0xc9, 0x5a, 0xc9, 0xcf, 0x0a, 0x7a, 0x1b, 0x20, 0x08, - 0x59, 0x1c, 0xe3, 0xa0, 0x2b, 0x78, 0xf5, 0x9a, 0x5d, 0x2a, 0xe5, 0xc8, 0x01, 0x6f, 0x4c, 0x08, - 0xcc, 0xbf, 0x48, 0xa5, 0x66, 0xf4, 0x35, 0x54, 0x22, 0x36, 0xee, 0x0e, 0x51, 0x99, 0x13, 0x74, - 0x13, 0x8c, 0x79, 0xa6, 0xb4, 0xed, 0x9d, 0x9e, 0xaf, 0x3a, 0x5f, 0xcf, 0x57, 0xef, 0xf5, 0x85, - 0x0e, 0xd3, 0x9e, 0x17, 0xc8, 0xa8, 0x19, 0xc8, 0x24, 0x92, 0x49, 0xfe, 0x79, 0x90, 0xf0, 0xe3, - 0xa6, 0x7e, 0x3f, 0xc4, 0xc4, 0x3b, 0x88, 0xb5, 0xbf, 0x18, 0xb1, 0x71, 0x3b, 0x93, 0xe9, 0x60, - 0xcc, 0x7f, 0x55, 0x56, 0x18, 0x8c, 0xb2, 0x83, 0xfc, 0x8f, 0xb2, 0x8f, 0xc1, 0x88, 0xde, 0x85, - 0x45, 0x9e, 0x2a, 0xa6, 0x85, 0x8c, 0xbb, 0xa1, 0x4c, 0x55, 0x52, 0x9d, 0xab, 0x93, 0xb5, 0x82, - 0xbf, 0x30, 0x43, 0xf7, 0x0d, 0xd8, 0xf8, 0x4e, 0xa0, 0xb0, 0x37, 0x90, 0x27, 0x74, 0x0f, 0x8a, - 0x22, 0x7e, 0x3b, 0x90, 0x27, 0x57, 0x74, 0x96, 0x77, 0xd3, 0x7d, 0xb8, 0x2e, 0x53, 0x6d, 0x85, - 0xae, 0x66, 0x64, 0xd6, 0x4e, 0x3b, 0xb0, 0x30, 0x7b, 0x9e, 0x11, 0x1b, 0xa4, 0x68, 0x0d, 0xfc, - 0xbb, 0xde, 0xcd, 0x5c, 0xe4, 0xc8, 0x68, 0x34, 0x3e, 0x13, 0x28, 0xf9, 0x4c, 0xe3, 0xa1, 0x49, - 0x0f, 0x7d, 0x04, 0x85, 0x21, 0xd3, 0xa1, 0xb5, 0x5c, 0xde, 0xac, 0x7b, 0xbf, 0x0f, 0x98, 0x67, - 0x72, 0xe4, 0x5b, 0x36, 0x7d, 0x0c, 0xf3, 0xef, 0x4c, 0x2e, 0xac, 0xc1, 0xf2, 0xe6, 0x9d, 0x3f, - 0xb5, 0xd9, 0x00, 0xf9, 0x19, 0xdf, 0x6c, 0x67, 0x2f, 0x66, 0xee, 0xef, 0xdb, 0x99, 0x37, 0xf1, - 0x2d, 0xbb, 0x71, 0x08, 0x2b, 0xaf, 0x42, 0x61, 0x08, 0x89, 0x46, 0xbe, 0xc5, 0xb9, 0xc2, 0x24, - 0x69, 0x33, 0xa1, 0xe8, 0x0a, 0x14, 0x4d, 0x16, 0x51, 0xe5, 0xb9, 0xce, 0x2b, 0x5a, 0x83, 0x1b, - 0x0a, 0x03, 0x14, 0x23, 0x54, 0x79, 0xac, 0x7f, 0xd6, 0xeb, 0x4f, 0x60, 0xa9, 0xcd, 0x82, 0x63, - 0xd4, 0xbb, 0x42, 0x61, 0x60, 0x82, 0x40, 0x97, 0xa0, 0xdc, 0xde, 0xda, 0x79, 0xd6, 0x7a, 0xd9, - 0xed, 0xb4, 0x9e, 0xef, 0x56, 0x9c, 0x4b, 0x80, 0xdf, 0xda, 0x39, 0xaa, 0x90, 0x5a, 0xe1, 0xc3, - 0x27, 0xd7, 0xd9, 0xbe, 0x7f, 0x3a, 0x71, 0xc9, 0xd9, 0xc4, 0x25, 0xdf, 0x26, 0x2e, 0xf9, 0x38, - 0x75, 0x9d, 0xb3, 0xa9, 0xeb, 0x7c, 0x99, 0xba, 0xce, 0x9b, 0x5b, 0xe3, 0x4b, 0xe3, 0x6b, 0xaf, - 0xbe, 0x57, 0xb4, 0x13, 0xf8, 0xf0, 0x47, 0x00, 0x00, 0x00, 0xff, 0xff, 0xac, 0xf5, 0x58, 0x11, - 0xe1, 0x03, 0x00, 0x00, + // 544 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xd1, 0x6a, 0x13, 0x4d, + 0x14, 0xde, 0x6d, 0x37, 0xf9, 0xff, 0x4c, 0x6c, 0x1b, 0x87, 0x5a, 0x42, 0xc0, 0x6d, 0x0c, 0x28, + 0xa5, 0xe2, 0x86, 0x56, 0x41, 0xc4, 0xab, 0xb4, 0x4d, 0x69, 0xb1, 0x48, 0xdc, 0x48, 0x15, 0x6f, + 0x96, 0xc9, 0xce, 0x31, 0x3b, 0x34, 0x3b, 0x13, 0x67, 0x67, 0xd3, 0xf8, 0x06, 0x5e, 0x0a, 0x3e, + 0x82, 0x2f, 0xd3, 0xcb, 0x5e, 0x8a, 0x17, 0x45, 0x92, 0x6b, 0xdf, 0x41, 0x66, 0x76, 0xd3, 0x16, + 0x41, 0xc5, 0x78, 0x95, 0x9c, 0x33, 0xdf, 0xf9, 0xe6, 0x7c, 0x67, 0xbe, 0xb3, 0x68, 0x33, 0x04, + 0xae, 0x48, 0x2a, 0x59, 0x53, 0x12, 0x05, 0x03, 0x16, 0x33, 0xd5, 0x1c, 0x6d, 0xf5, 0x40, 0x91, + 0xad, 0xab, 0x8c, 0x37, 0x94, 0x42, 0x09, 0x5c, 0x9b, 0x61, 0xbd, 0xab, 0x93, 0x1c, 0x5b, 0x5b, + 0xed, 0x8b, 0xbe, 0x30, 0xb0, 0xa6, 0xfe, 0x97, 0x55, 0x34, 0x9e, 0x22, 0xa7, 0x43, 0x54, 0x84, + 0x57, 0x51, 0x81, 0x02, 0x17, 0x71, 0xd5, 0xae, 0xdb, 0x1b, 0x25, 0x3f, 0x0b, 0xf0, 0x6d, 0x84, + 0xc2, 0x88, 0x70, 0x0e, 0x83, 0x80, 0xd1, 0xea, 0x82, 0x39, 0x2a, 0xe5, 0x99, 0x43, 0xda, 0x98, + 0xd8, 0xa8, 0xf0, 0x22, 0x15, 0x8a, 0xe0, 0xd7, 0xa8, 0x12, 0x93, 0x71, 0x30, 0x04, 0xa9, 0x3b, + 0x08, 0x12, 0xe0, 0x34, 0x63, 0xda, 0xf1, 0xce, 0x2e, 0xd6, 0xad, 0xaf, 0x17, 0xeb, 0xf7, 0xfa, + 0x4c, 0x45, 0x69, 0xcf, 0x0b, 0x45, 0xdc, 0x0c, 0x45, 0x12, 0x8b, 0x24, 0xff, 0x79, 0x90, 0xd0, + 0x93, 0xa6, 0x7a, 0x3f, 0x84, 0xc4, 0x3b, 0xe4, 0xca, 0x5f, 0x8e, 0xc9, 0xb8, 0x93, 0xd1, 0x74, + 0x81, 0xd3, 0x9f, 0x99, 0x25, 0x84, 0xa3, 0xac, 0x91, 0x7f, 0x61, 0xf6, 0x21, 0x1c, 0xe1, 0xbb, + 0x68, 0x99, 0xa6, 0x92, 0x28, 0x26, 0x78, 0x10, 0x89, 0x54, 0x26, 0xd5, 0xc5, 0xba, 0xbd, 0xe1, + 0xf8, 0x4b, 0xb3, 0xec, 0x81, 0x4e, 0x36, 0xbe, 0xdb, 0xc8, 0xd9, 0x1f, 0x88, 0x53, 0xbc, 0x8f, + 0x8a, 0x8c, 0xbf, 0x1d, 0x88, 0xd3, 0x39, 0x95, 0xe5, 0xd5, 0xf8, 0x00, 0xfd, 0x27, 0x52, 0x65, + 0x88, 0xe6, 0x13, 0x32, 0x2b, 0xc7, 0x5d, 0xb4, 0x34, 0x7b, 0x9e, 0x11, 0x19, 0xa4, 0x60, 0x04, + 0xfc, 0x3d, 0xdf, 0x8d, 0x9c, 0xe4, 0x58, 0x73, 0x34, 0x3e, 0x2d, 0xa0, 0x92, 0x4f, 0x14, 0x1c, + 0x69, 0xf7, 0xe0, 0x47, 0xc8, 0x19, 0x12, 0x15, 0x19, 0xc9, 0xe5, 0xed, 0xba, 0xf7, 0x6b, 0x83, + 0x79, 0xda, 0x47, 0xbe, 0x41, 0xe3, 0xc7, 0xa8, 0xf0, 0x4e, 0xfb, 0xc2, 0x08, 0x2c, 0x6f, 0xdf, + 0xf9, 0x5d, 0x99, 0x31, 0x90, 0x9f, 0xe1, 0xf5, 0x75, 0x66, 0x30, 0x8b, 0x7f, 0xbe, 0x4e, 0xbf, + 0x89, 0x6f, 0xd0, 0x98, 0xa0, 0x5b, 0x31, 0xe3, 0x81, 0xc6, 0x04, 0x06, 0x14, 0x90, 0x58, 0xa4, + 0x5c, 0x55, 0x9d, 0xb9, 0xe6, 0x81, 0x63, 0xc6, 0x2f, 0x27, 0xd0, 0x32, 0x4c, 0x8d, 0x23, 0xb4, + 0xf6, 0x2a, 0x62, 0xba, 0x87, 0x44, 0x01, 0x6d, 0x51, 0x2a, 0x21, 0x49, 0x3a, 0x84, 0x49, 0xbc, + 0x86, 0x8a, 0xda, 0xee, 0x20, 0xf3, 0xd5, 0xc9, 0x23, 0x5c, 0x43, 0xff, 0x4b, 0x08, 0x81, 0x8d, + 0x40, 0xe6, 0x9b, 0x73, 0x19, 0x6f, 0x3e, 0x41, 0x2b, 0x1d, 0x12, 0x9e, 0x80, 0xda, 0x63, 0x12, + 0x42, 0xed, 0x35, 0xbc, 0x82, 0xca, 0x9d, 0xd6, 0xee, 0xb3, 0xf6, 0xcb, 0xa0, 0xdb, 0x7e, 0xbe, + 0x57, 0xb1, 0xae, 0x25, 0xfc, 0xf6, 0xee, 0x71, 0xc5, 0xae, 0x39, 0x1f, 0x3e, 0xbb, 0xd6, 0xce, + 0xfd, 0xb3, 0x89, 0x6b, 0x9f, 0x4f, 0x5c, 0xfb, 0xdb, 0xc4, 0xb5, 0x3f, 0x4e, 0x5d, 0xeb, 0x7c, + 0xea, 0x5a, 0x5f, 0xa6, 0xae, 0xf5, 0xe6, 0xe6, 0xf8, 0xda, 0x17, 0xc2, 0xa8, 0xe9, 0x15, 0xcd, + 0x92, 0x3f, 0xfc, 0x11, 0x00, 0x00, 0xff, 0xff, 0x51, 0xff, 0x42, 0x9e, 0x44, 0x04, 0x00, 0x00, } func (m *Path) Marshal() (dAtA []byte, err error) { @@ -506,6 +508,16 @@ func (m *RateLimit) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.MinRateLimitAmount.Size() + i -= size + if _, err := m.MinRateLimitAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintRatelimit(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 if m.Flow != nil { { size, err := m.Flow.MarshalToSizedBuffer(dAtA[:i]) @@ -659,6 +671,8 @@ func (m *RateLimit) Size() (n int) { l = m.Flow.Size() n += 1 + l + sovRatelimit(uint64(l)) } + l = m.MinRateLimitAmount.Size() + n += 1 + l + sovRatelimit(uint64(l)) return n } @@ -1225,6 +1239,40 @@ func (m *RateLimit) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinRateLimitAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowRatelimit + } + 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 ErrInvalidLengthRatelimit + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthRatelimit + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinRateLimitAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipRatelimit(dAtA[iNdEx:]) diff --git a/x/ratelimit/types/tx.pb.go b/x/ratelimit/types/tx.pb.go index cc47a6df0..406ec70c4 100644 --- a/x/ratelimit/types/tx.pb.go +++ b/x/ratelimit/types/tx.pb.go @@ -33,12 +33,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type MsgAddRateLimit struct { // authority is the address that controls the module (defaults to x/gov unless // overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - MaxPercentSend github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=max_percent_send,json=maxPercentSend,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_send"` - MaxPercentRecv github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=max_percent_recv,json=maxPercentRecv,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_recv"` - DurationHours uint64 `protobuf:"varint,6,opt,name=duration_hours,json=durationHours,proto3" json:"duration_hours,omitempty"` + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + MaxPercentSend github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=max_percent_send,json=maxPercentSend,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_send"` + MaxPercentRecv github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=max_percent_recv,json=maxPercentRecv,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_recv"` + MinRateLimitAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=min_rate_limit_amount,json=minRateLimitAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_rate_limit_amount"` + DurationHours uint64 `protobuf:"varint,7,opt,name=duration_hours,json=durationHours,proto3" json:"duration_hours,omitempty"` } func (m *MsgAddRateLimit) Reset() { *m = MsgAddRateLimit{} } @@ -141,12 +142,13 @@ var xxx_messageInfo_MsgAddRateLimitResponse proto.InternalMessageInfo type MsgUpdateRateLimit struct { // authority is the address that controls the module (defaults to x/gov unless // overwritten). - Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` - MaxPercentSend github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=max_percent_send,json=maxPercentSend,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_send"` - MaxPercentRecv github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=max_percent_recv,json=maxPercentRecv,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_recv"` - DurationHours uint64 `protobuf:"varint,6,opt,name=duration_hours,json=durationHours,proto3" json:"duration_hours,omitempty"` + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + MaxPercentSend github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=max_percent_send,json=maxPercentSend,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_send"` + MaxPercentRecv github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=max_percent_recv,json=maxPercentRecv,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_recv"` + MinRateLimitAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=min_rate_limit_amount,json=minRateLimitAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_rate_limit_amount"` + DurationHours uint64 `protobuf:"varint,7,opt,name=duration_hours,json=durationHours,proto3" json:"duration_hours,omitempty"` } func (m *MsgUpdateRateLimit) Reset() { *m = MsgUpdateRateLimit{} } @@ -458,41 +460,43 @@ func init() { } var fileDescriptor_6b20911f56917b5f = []byte{ - // 534 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0xc1, 0x8a, 0xd3, 0x40, - 0x1c, 0xc6, 0x9b, 0xdd, 0xee, 0x42, 0x07, 0xac, 0xbb, 0x43, 0xb1, 0xd9, 0xa8, 0xe9, 0x12, 0x51, - 0x16, 0x97, 0x4d, 0xe8, 0x2e, 0x7a, 0xd8, 0xdb, 0xee, 0xc9, 0x05, 0x0b, 0x12, 0x15, 0xc4, 0x4b, - 0x99, 0x66, 0xc6, 0x34, 0xd8, 0xcc, 0x84, 0x99, 0x49, 0x48, 0x2f, 0x82, 0x5e, 0xbc, 0x28, 0xf8, - 0x28, 0x3e, 0xc6, 0x1e, 0xf7, 0x28, 0x1e, 0x8a, 0xb4, 0x88, 0x9e, 0x7d, 0x02, 0x49, 0xd2, 0xb4, - 0x6b, 0x42, 0x29, 0x45, 0x44, 0x0f, 0x9e, 0x26, 0x99, 0xff, 0x97, 0x6f, 0x7e, 0x33, 0xdf, 0x4c, - 0x06, 0xdc, 0x72, 0x08, 0x95, 0x28, 0xe4, 0x9e, 0xc5, 0x91, 0x24, 0x03, 0xcf, 0xf7, 0xa4, 0x15, - 0xb5, 0x7b, 0x44, 0xa2, 0xb6, 0x25, 0x63, 0x33, 0xe0, 0x4c, 0x32, 0xa8, 0xe5, 0x22, 0x73, 0x26, - 0x32, 0xa7, 0x22, 0xad, 0xe1, 0x32, 0x97, 0xa5, 0x32, 0x2b, 0x79, 0xca, 0xbe, 0xd0, 0x9a, 0x0e, - 0x13, 0x3e, 0x13, 0x96, 0x2f, 0x5c, 0x2b, 0x6a, 0x27, 0x4d, 0x56, 0x30, 0xbe, 0xae, 0x81, 0xab, - 0x1d, 0xe1, 0x9e, 0x60, 0x6c, 0x23, 0x49, 0x1e, 0x26, 0x56, 0xf0, 0x10, 0xd4, 0x50, 0x28, 0xfb, - 0x8c, 0x7b, 0x72, 0xa8, 0x2a, 0xbb, 0xca, 0x5e, 0xed, 0xb4, 0xf1, 0x63, 0xd4, 0xda, 0x1a, 0x22, - 0x7f, 0x70, 0x6c, 0xcc, 0x4a, 0x86, 0x3d, 0x97, 0xc1, 0x06, 0xd8, 0xc0, 0x84, 0x32, 0x5f, 0x5d, - 0x4b, 0xf4, 0x76, 0xf6, 0x02, 0x6f, 0x02, 0xe0, 0xf4, 0x11, 0xa5, 0x64, 0xd0, 0xf5, 0xb0, 0xba, - 0x9e, 0x96, 0x6a, 0xd3, 0x9e, 0x33, 0x0c, 0x9f, 0x81, 0x2d, 0x1f, 0xc5, 0xdd, 0x80, 0xf0, 0x64, - 0x42, 0x5d, 0x41, 0x28, 0x56, 0xab, 0xe9, 0x78, 0xe6, 0xf9, 0xa8, 0x55, 0xf9, 0x3c, 0x6a, 0xdd, - 0x71, 0x3d, 0xd9, 0x0f, 0x7b, 0xa6, 0xc3, 0x7c, 0x6b, 0x3a, 0x85, 0xac, 0x39, 0x10, 0xf8, 0xa5, - 0x25, 0x87, 0x01, 0x11, 0xe6, 0x19, 0x95, 0x76, 0xdd, 0x47, 0xf1, 0xa3, 0xcc, 0xe6, 0x31, 0xa1, - 0x25, 0x67, 0x4e, 0x9c, 0x48, 0xdd, 0xf8, 0x5d, 0x67, 0x9b, 0x38, 0x11, 0xbc, 0x0d, 0xea, 0x38, - 0xe4, 0x48, 0x7a, 0x8c, 0x76, 0xfb, 0x2c, 0xe4, 0x42, 0xdd, 0xdc, 0x55, 0xf6, 0xaa, 0xf6, 0x95, - 0xbc, 0xf7, 0x41, 0xd2, 0x79, 0x5c, 0x7f, 0xf3, 0xed, 0xe3, 0xdd, 0xf9, 0xfa, 0x18, 0x3b, 0xa0, - 0x59, 0x58, 0x66, 0x9b, 0x88, 0x80, 0x51, 0x41, 0x8c, 0xef, 0x6b, 0x00, 0x76, 0x84, 0xfb, 0x34, - 0xc0, 0x48, 0x92, 0xff, 0x29, 0xfc, 0xc9, 0x14, 0x6e, 0x00, 0xad, 0xbc, 0xd2, 0xb3, 0x20, 0xde, - 0x2b, 0x69, 0x10, 0x36, 0xf1, 0x59, 0xf4, 0x17, 0x82, 0x58, 0x40, 0x5b, 0xc0, 0x99, 0xd1, 0xbe, - 0x53, 0xc0, 0x76, 0x5a, 0x16, 0x44, 0xfe, 0x03, 0xb0, 0xd7, 0xc1, 0x4e, 0x89, 0x26, 0x67, 0x3d, - 0x7c, 0x5b, 0x05, 0xeb, 0x1d, 0xe1, 0xc2, 0x18, 0x34, 0x4e, 0x30, 0x7e, 0xc2, 0x11, 0x15, 0x2f, - 0x08, 0x9f, 0x53, 0xef, 0x9b, 0x8b, 0xff, 0x68, 0x66, 0xe1, 0xdc, 0x68, 0x47, 0x2b, 0x88, 0x73, - 0x02, 0xf8, 0x5a, 0x01, 0xcd, 0x2c, 0xf7, 0xf2, 0xe8, 0xe6, 0x12, 0xc3, 0xc2, 0x7e, 0xd1, 0xee, - 0xaf, 0xa6, 0xff, 0x85, 0x21, 0x4b, 0x73, 0x75, 0x86, 0xc2, 0x2e, 0x58, 0xca, 0xb0, 0x60, 0xd7, - 0xc0, 0x57, 0xe0, 0x5a, 0x9a, 0x51, 0x99, 0xe0, 0x60, 0xa9, 0xe3, 0xe5, 0x68, 0xb5, 0x7b, 0x2b, - 0xc9, 0xf3, 0xf1, 0x4f, 0xf7, 0xcf, 0xc7, 0xba, 0x72, 0x31, 0xd6, 0x95, 0x2f, 0x63, 0x5d, 0xf9, - 0x30, 0xd1, 0x2b, 0x17, 0x13, 0xbd, 0xf2, 0x69, 0xa2, 0x57, 0x9e, 0x6f, 0xc7, 0x97, 0xae, 0xbc, - 0xf4, 0xe4, 0xf7, 0x36, 0xd3, 0x3b, 0xea, 0xe8, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x59, - 0x49, 0x80, 0x15, 0x07, 0x00, 0x00, + // 561 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x95, 0x4d, 0x8b, 0x13, 0x31, + 0x1c, 0xc6, 0x3b, 0xb6, 0xbb, 0xd2, 0x80, 0x75, 0x37, 0x54, 0x3b, 0x3b, 0xea, 0x74, 0xa9, 0x28, + 0x8b, 0xcb, 0xce, 0xd0, 0x5d, 0xf4, 0xb0, 0xb7, 0xee, 0xc9, 0x05, 0x0b, 0x32, 0x2a, 0x88, 0x97, + 0x21, 0x9d, 0xc4, 0xe9, 0x60, 0x93, 0x94, 0x24, 0x53, 0xda, 0x8b, 0xa0, 0x17, 0x2f, 0x0a, 0x7e, + 0x14, 0x3f, 0x46, 0xc1, 0xcb, 0x1e, 0xc5, 0x43, 0x91, 0xf6, 0xe0, 0xdd, 0x4f, 0x20, 0x93, 0xe9, + 0xcb, 0xda, 0x52, 0x4a, 0xf5, 0xa0, 0xc2, 0x9e, 0x32, 0x93, 0xff, 0x33, 0x4f, 0x9e, 0xe4, 0x97, + 0x4c, 0xc0, 0xed, 0x80, 0x30, 0x85, 0x62, 0x11, 0xb9, 0x02, 0x29, 0xd2, 0x8a, 0x68, 0xa4, 0xdc, + 0x4e, 0xb5, 0x41, 0x14, 0xaa, 0xba, 0xaa, 0xeb, 0xb4, 0x05, 0x57, 0x1c, 0x5a, 0x13, 0x91, 0x33, + 0x15, 0x39, 0x63, 0x91, 0x55, 0x0c, 0x79, 0xc8, 0xb5, 0xcc, 0x4d, 0x9e, 0xd2, 0x2f, 0xac, 0x52, + 0xc0, 0x25, 0xe5, 0xd2, 0xa5, 0x32, 0x74, 0x3b, 0xd5, 0xa4, 0x49, 0x0b, 0x95, 0x7e, 0x16, 0x5c, + 0xad, 0xcb, 0xb0, 0x86, 0xb1, 0x87, 0x14, 0x79, 0x94, 0x58, 0xc1, 0x43, 0x90, 0x47, 0xb1, 0x6a, + 0x72, 0x11, 0xa9, 0x9e, 0x69, 0xec, 0x1a, 0x7b, 0xf9, 0x93, 0xe2, 0x8f, 0x41, 0x79, 0xab, 0x87, + 0x68, 0xeb, 0xb8, 0x32, 0x2d, 0x55, 0xbc, 0x99, 0x0c, 0x16, 0xc1, 0x06, 0x26, 0x8c, 0x53, 0xf3, + 0x52, 0xa2, 0xf7, 0xd2, 0x17, 0x78, 0x0b, 0x80, 0xa0, 0x89, 0x18, 0x23, 0x2d, 0x3f, 0xc2, 0x66, + 0x56, 0x97, 0xf2, 0xe3, 0x9e, 0x53, 0x0c, 0x9f, 0x83, 0x2d, 0x8a, 0xba, 0x7e, 0x9b, 0x88, 0x64, + 0x42, 0xbe, 0x24, 0x0c, 0x9b, 0x39, 0x3d, 0x9e, 0xd3, 0x1f, 0x94, 0x33, 0x5f, 0x07, 0xe5, 0xbb, + 0x61, 0xa4, 0x9a, 0x71, 0xc3, 0x09, 0x38, 0x75, 0xc7, 0x53, 0x48, 0x9b, 0x03, 0x89, 0x5f, 0xb9, + 0xaa, 0xd7, 0x26, 0xd2, 0x39, 0x65, 0xca, 0x2b, 0x50, 0xd4, 0x7d, 0x9c, 0xda, 0x3c, 0x21, 0x6c, + 0xc1, 0x59, 0x90, 0xa0, 0x63, 0x6e, 0xfc, 0xa9, 0xb3, 0x47, 0x82, 0x0e, 0x44, 0xe0, 0x1a, 0x8d, + 0x98, 0x9f, 0x2c, 0xbc, 0xaf, 0x57, 0xde, 0x47, 0x94, 0xc7, 0x4c, 0x99, 0x9b, 0xbf, 0x65, 0x0f, + 0x69, 0xc4, 0xa6, 0x2b, 0x5f, 0xd3, 0x4e, 0xf0, 0x0e, 0x28, 0xe0, 0x58, 0x20, 0x15, 0x71, 0xe6, + 0x37, 0x79, 0x2c, 0xa4, 0x79, 0x79, 0xd7, 0xd8, 0xcb, 0x79, 0x57, 0x26, 0xbd, 0x0f, 0x93, 0xce, + 0xe3, 0xc2, 0xdb, 0xef, 0x9f, 0xee, 0xcd, 0x10, 0x54, 0x76, 0x40, 0x69, 0x8e, 0xa4, 0x47, 0x64, + 0x9b, 0x33, 0x49, 0x2a, 0x9f, 0xb3, 0x00, 0xd6, 0x65, 0xf8, 0xac, 0x8d, 0x91, 0x22, 0x17, 0xa0, + 0xff, 0x73, 0xd0, 0x37, 0x81, 0xb5, 0x08, 0x73, 0xca, 0xfa, 0x83, 0xa1, 0x59, 0x7b, 0x84, 0xf2, + 0xce, 0x5f, 0x60, 0xbd, 0x24, 0xed, 0x5c, 0x9c, 0x69, 0xda, 0xf7, 0x06, 0xd8, 0xd6, 0x65, 0x49, + 0xd4, 0x3f, 0x10, 0xf6, 0x06, 0xd8, 0x59, 0x48, 0x33, 0xc9, 0x7a, 0xf8, 0x2e, 0x07, 0xb2, 0x75, + 0x19, 0xc2, 0x2e, 0x28, 0xd6, 0x30, 0x7e, 0x2a, 0x10, 0x93, 0x2f, 0x89, 0x98, 0xa5, 0xde, 0x77, + 0x96, 0xff, 0x97, 0x9d, 0xb9, 0xa3, 0x69, 0x1d, 0xad, 0x21, 0x9e, 0x24, 0x80, 0x6f, 0x0c, 0x50, + 0x4a, 0xb9, 0x2f, 0x8e, 0xee, 0xac, 0x30, 0x9c, 0xdb, 0x2f, 0xd6, 0x83, 0xf5, 0xf4, 0xbf, 0x64, + 0x48, 0x69, 0xae, 0x9f, 0x61, 0x6e, 0x17, 0xac, 0xcc, 0xb0, 0x64, 0xd7, 0xc0, 0xd7, 0xe0, 0xba, + 0x66, 0xb4, 0x98, 0xe0, 0x60, 0xa5, 0xe3, 0x79, 0xb4, 0xd6, 0xfd, 0xb5, 0xe4, 0x93, 0xf1, 0x4f, + 0xf6, 0xfb, 0x43, 0xdb, 0x38, 0x1b, 0xda, 0xc6, 0xb7, 0xa1, 0x6d, 0x7c, 0x1c, 0xd9, 0x99, 0xb3, + 0x91, 0x9d, 0xf9, 0x32, 0xb2, 0x33, 0x2f, 0xb6, 0xbb, 0xe7, 0x2e, 0x6e, 0x7d, 0xfa, 0x1b, 0x9b, + 0xfa, 0xa6, 0x3d, 0xfa, 0x19, 0x00, 0x00, 0xff, 0xff, 0x62, 0x2e, 0x80, 0x93, 0xdb, 0x07, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -706,8 +710,18 @@ func (m *MsgAddRateLimit) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.DurationHours != 0 { i = encodeVarintTx(dAtA, i, uint64(m.DurationHours)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x38 } + { + size := m.MinRateLimitAmount.Size() + i -= size + if _, err := m.MinRateLimitAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 { size := m.MaxPercentRecv.Size() i -= size @@ -798,8 +812,18 @@ func (m *MsgUpdateRateLimit) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.DurationHours != 0 { i = encodeVarintTx(dAtA, i, uint64(m.DurationHours)) i-- - dAtA[i] = 0x30 + dAtA[i] = 0x38 + } + { + size := m.MinRateLimitAmount.Size() + i -= size + if _, err := m.MinRateLimitAmount.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x32 { size := m.MaxPercentRecv.Size() i -= size @@ -1034,6 +1058,8 @@ func (m *MsgAddRateLimit) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.MaxPercentRecv.Size() n += 1 + l + sovTx(uint64(l)) + l = m.MinRateLimitAmount.Size() + n += 1 + l + sovTx(uint64(l)) if m.DurationHours != 0 { n += 1 + sovTx(uint64(m.DurationHours)) } @@ -1071,6 +1097,8 @@ func (m *MsgUpdateRateLimit) Size() (n int) { n += 1 + l + sovTx(uint64(l)) l = m.MaxPercentRecv.Size() n += 1 + l + sovTx(uint64(l)) + l = m.MinRateLimitAmount.Size() + n += 1 + l + sovTx(uint64(l)) if m.DurationHours != 0 { n += 1 + sovTx(uint64(m.DurationHours)) } @@ -1346,6 +1374,40 @@ func (m *MsgAddRateLimit) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinRateLimitAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinRateLimitAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DurationHours", wireType) } @@ -1629,6 +1691,40 @@ func (m *MsgUpdateRateLimit) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinRateLimitAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinRateLimitAmount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field DurationHours", wireType) } From 2037db5367d9dfc3af18e8cd40ad7d33a2651c66 Mon Sep 17 00:00:00 2001 From: GnaD | Notional <89174180+GNaD13@users.noreply.github.com> Date: Fri, 18 Aug 2023 16:00:09 +0700 Subject: [PATCH 14/20] fork v4_5_1 remove rate limit: (#225) * fork v5 remove rate limit: * add to Fork list --- app/app.go | 3 ++- app/upgrades/v4_5_1/constants.go | 18 ++++++++++++++++++ app/upgrades/v4_5_1/fork.go | 26 ++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 app/upgrades/v4_5_1/constants.go create mode 100644 app/upgrades/v4_5_1/fork.go diff --git a/app/app.go b/app/app.go index 17735a958..0cf2dbd9e 100644 --- a/app/app.go +++ b/app/app.go @@ -113,6 +113,7 @@ import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" v4_5 "github.com/notional-labs/centauri/v4/app/upgrades/v4_5" + v4_5_1 "github.com/notional-labs/centauri/v4/app/upgrades/v4_5_1" upgrades "github.com/notional-labs/centauri/v4/app/upgrades" ) @@ -133,7 +134,7 @@ var ( EnableSpecificProposals = "" Upgrades = []upgrades.Upgrade{v4.Upgrade} - Forks = []upgrades.Fork{v4_5.Fork} + Forks = []upgrades.Fork{v4_5.Fork, v4_5_1.Fork} ) // GetEnabledProposals parses the ProposalsEnabled / EnableSpecificProposals values to diff --git a/app/upgrades/v4_5_1/constants.go b/app/upgrades/v4_5_1/constants.go new file mode 100644 index 000000000..1194e342d --- /dev/null +++ b/app/upgrades/v4_5_1/constants.go @@ -0,0 +1,18 @@ +package v4_5_1 + +import "github.com/notional-labs/centauri/v4/app/upgrades" + +const ( + // UpgradeName defines the on-chain upgrade name for the Composable v5 upgrade. + UpgradeName = "v4_5_1" + + // UpgradeHeight defines the block height at which the Composable v6 upgrade is + // triggered. + UpgradeHeight = 1_117_000 +) + +var Fork = upgrades.Fork{ + UpgradeName: UpgradeName, + UpgradeHeight: UpgradeHeight, + BeginForkLogic: RunForkLogic, +} diff --git a/app/upgrades/v4_5_1/fork.go b/app/upgrades/v4_5_1/fork.go new file mode 100644 index 000000000..8298da52b --- /dev/null +++ b/app/upgrades/v4_5_1/fork.go @@ -0,0 +1,26 @@ +package v4_5_1 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/notional-labs/centauri/v4/app/keepers" + rateLimitKeeper "github.com/notional-labs/centauri/v4/x/ratelimit/keeper" +) + +func RunForkLogic(ctx sdk.Context, keepers *keepers.AppKeepers) { + ctx.Logger().Info("Applying v5 upgrade" + + "Remove Rate Limit", + ) +} + +func RemoveRateLimit(ctx sdk.Context, rlKeeper *rateLimitKeeper.Keeper) { + // Get all current rate limit + rateLimits := rlKeeper.GetAllRateLimits(ctx) + // Remove Rate limit + for _, rateLimit := range rateLimits { + err := rlKeeper.RemoveRateLimit(ctx, rateLimit.Path.Denom, rateLimit.Path.ChannelId) + if err != nil { + panic(err) + } + } +} From 314bead5e012e5d199d15897e6f4cc9ce3bca332 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 18 Aug 2023 16:06:54 +0700 Subject: [PATCH 15/20] add RemoveRateLimit into RunForkLogic --- app/upgrades/v4_5_1/fork.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/upgrades/v4_5_1/fork.go b/app/upgrades/v4_5_1/fork.go index 8298da52b..008d6d2fd 100644 --- a/app/upgrades/v4_5_1/fork.go +++ b/app/upgrades/v4_5_1/fork.go @@ -11,6 +11,8 @@ func RunForkLogic(ctx sdk.Context, keepers *keepers.AppKeepers) { ctx.Logger().Info("Applying v5 upgrade" + "Remove Rate Limit", ) + + RemoveRateLimit(ctx, &keepers.RatelimitKeeper) } func RemoveRateLimit(ctx sdk.Context, rlKeeper *rateLimitKeeper.Keeper) { From 19168dbdee844fc45f7690e861e43e1503ddd732 Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 18 Aug 2023 16:25:11 +0700 Subject: [PATCH 16/20] upgrade height --- app/upgrades/v4_5_1/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v4_5_1/constants.go b/app/upgrades/v4_5_1/constants.go index 1194e342d..6976f6a05 100644 --- a/app/upgrades/v4_5_1/constants.go +++ b/app/upgrades/v4_5_1/constants.go @@ -8,7 +8,7 @@ const ( // UpgradeHeight defines the block height at which the Composable v6 upgrade is // triggered. - UpgradeHeight = 1_117_000 + UpgradeHeight = 1127000 ) var Fork = upgrades.Fork{ From c07926515e2868898fb470e665f5627dd330e3db Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 21 Aug 2023 11:55:43 +0700 Subject: [PATCH 17/20] remove arm build --- .github/workflows/interchaintest.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/interchaintest.yml b/.github/workflows/interchaintest.yml index dff759f4d..c605eaf7f 100644 --- a/.github/workflows/interchaintest.yml +++ b/.github/workflows/interchaintest.yml @@ -12,8 +12,6 @@ jobs: steps: - name: Check out the repo uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Login to GitHub Container Registry @@ -29,7 +27,7 @@ jobs: file: Dockerfile context: . push: true - platforms: linux/amd64,linux/arm64 + platforms: linux/amd64 tags: | ghcr.io/notional-labs/centauri-ictest:latest test-start-cosmos-chain: From ce98d47133a9a4b3169fe87c43e548b2a71513ea Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Tue, 22 Aug 2023 15:36:59 +0700 Subject: [PATCH 18/20] channelID --- app/upgrades/v4_5_1/fork.go | 2 +- x/ratelimit/relay_test.go | 4 ++-- x/ratelimit/types/tx.pb.go | 4 ++-- x/transfermiddleware/keeper/keeper.go | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/upgrades/v4_5_1/fork.go b/app/upgrades/v4_5_1/fork.go index 008d6d2fd..5c2cf8a9f 100644 --- a/app/upgrades/v4_5_1/fork.go +++ b/app/upgrades/v4_5_1/fork.go @@ -20,7 +20,7 @@ func RemoveRateLimit(ctx sdk.Context, rlKeeper *rateLimitKeeper.Keeper) { rateLimits := rlKeeper.GetAllRateLimits(ctx) // Remove Rate limit for _, rateLimit := range rateLimits { - err := rlKeeper.RemoveRateLimit(ctx, rateLimit.Path.Denom, rateLimit.Path.ChannelId) + err := rlKeeper.RemoveRateLimit(ctx, rateLimit.Path.Denom, rateLimit.Path.ChannelID) if err != nil { panic(err) } diff --git a/x/ratelimit/relay_test.go b/x/ratelimit/relay_test.go index 95638e371..38817e94f 100644 --- a/x/ratelimit/relay_test.go +++ b/x/ratelimit/relay_test.go @@ -336,7 +336,7 @@ func (suite *RateLimitTestSuite) TestReceiveIBCTokenWithMinRateLimitAmount() { chainBRateLimitKeeper := suite.chainB.RateLimit() msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ Denom: nativeDenom, - ChannelId: path.EndpointB.ChannelID, + ChannelID: path.EndpointB.ChannelID, MaxPercentSend: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 MaxPercentRecv: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 MinRateLimitAmount: sdk.NewInt(10_000_000_000), @@ -457,7 +457,7 @@ func (suite *RateLimitTestSuite) TestSendIBCTokenWithMinRateLimitAmount() { chainBRateLimitKeeper := suite.chainB.RateLimit() msgAddRateLimit := ratelimittypes.MsgAddRateLimit{ Denom: nativeDenom, - ChannelId: path.EndpointB.ChannelID, + ChannelID: path.EndpointB.ChannelID, MaxPercentSend: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 MaxPercentRecv: sdk.NewInt(5), // 5_000_000_000 < minRateLimitAmount(10_000_000_000) => RateLimit = 10_000_000_000 MinRateLimitAmount: sdk.NewInt(10_000_000_000), diff --git a/x/ratelimit/types/tx.pb.go b/x/ratelimit/types/tx.pb.go index f583652e3..c4e7f9920 100644 --- a/x/ratelimit/types/tx.pb.go +++ b/x/ratelimit/types/tx.pb.go @@ -35,7 +35,7 @@ type MsgAddRateLimit struct { // overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + ChannelID string `protobuf:"bytes,3,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty"` MaxPercentSend github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=max_percent_send,json=maxPercentSend,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_send"` MaxPercentRecv github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=max_percent_recv,json=maxPercentRecv,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_recv"` MinRateLimitAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=min_rate_limit_amount,json=minRateLimitAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_rate_limit_amount"` @@ -144,7 +144,7 @@ type MsgUpdateRateLimit struct { // overwritten). Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty" yaml:"authority"` Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - ChannelId string `protobuf:"bytes,3,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + ChannelID string `protobuf:"bytes,3,opt,name=channel_id,json=channelID,proto3" json:"channel_id,omitempty"` MaxPercentSend github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=max_percent_send,json=maxPercentSend,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_send"` MaxPercentRecv github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=max_percent_recv,json=maxPercentRecv,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"max_percent_recv"` MinRateLimitAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=min_rate_limit_amount,json=minRateLimitAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_rate_limit_amount"` diff --git a/x/transfermiddleware/keeper/keeper.go b/x/transfermiddleware/keeper/keeper.go index 60d949d97..f3f8b1c41 100644 --- a/x/transfermiddleware/keeper/keeper.go +++ b/x/transfermiddleware/keeper/keeper.go @@ -203,8 +203,8 @@ func (keeper Keeper) GetNativeDenomByIBCDenomSecondaryIndex(ctx sdk.Context, ibc func (keeper Keeper) GetTotalEscrowedToken(ctx sdk.Context) (coins sdk.Coins) { keeper.IterateParaTokenInfos(ctx, func(index int64, info types.ParachainIBCTokenInfo) (stop bool) { - escrowIbcCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelId), info.IbcDenom) - escrowNativeCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelId), info.NativeDenom) + escrowIbcCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelID), info.IbcDenom) + escrowNativeCoin := keeper.bankKeeper.GetBalance(ctx, transfertypes.GetEscrowAddress(transfertypes.PortID, info.ChannelID), info.NativeDenom) coins = append(coins, escrowIbcCoin, escrowNativeCoin) return false }) From df216a7ec32afbd3d3c2816f539e06c73d89c10d Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 25 Aug 2023 15:18:02 +0700 Subject: [PATCH 19/20] v5 upgrade --- app/upgrades/v5/constants.go | 19 +++++++++++++++++++ app/upgrades/v5/upgrade.go | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 app/upgrades/v5/constants.go create mode 100644 app/upgrades/v5/upgrade.go diff --git a/app/upgrades/v5/constants.go b/app/upgrades/v5/constants.go new file mode 100644 index 000000000..1bc1c269e --- /dev/null +++ b/app/upgrades/v5/constants.go @@ -0,0 +1,19 @@ +package v5 + +import ( + store "github.com/cosmos/cosmos-sdk/store/types" + "github.com/notional-labs/centauri/v4/app/upgrades" +) + +const ( + // UpgradeName defines the on-chain upgrade name for the Centauri upgrade. + UpgradeName = "v5" +) + +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{ + Added: []string{}, + }, +} diff --git a/app/upgrades/v5/upgrade.go b/app/upgrades/v5/upgrade.go new file mode 100644 index 000000000..9bcbed994 --- /dev/null +++ b/app/upgrades/v5/upgrade.go @@ -0,0 +1,20 @@ +package v5 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/notional-labs/centauri/v4/app/keepers" + "github.com/notional-labs/centauri/v4/app/upgrades" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + bpm upgrades.BaseAppParamManager, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, configurator, vm) + } +} From 2685cdb54facb9460acb3d97c590efec7699d43e Mon Sep 17 00:00:00 2001 From: vuong177 Date: Fri, 25 Aug 2023 15:18:13 +0700 Subject: [PATCH 20/20] upgrade in app.go --- app/app.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/app.go b/app/app.go index 82cba475d..feb7ab114 100644 --- a/app/app.go +++ b/app/app.go @@ -34,6 +34,7 @@ import ( "github.com/notional-labs/centauri/v4/app/keepers" v4 "github.com/notional-labs/centauri/v4/app/upgrades/v4" + v5 "github.com/notional-labs/centauri/v4/app/upgrades/v5" // bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" @@ -133,7 +134,7 @@ var ( // https://github.com/CosmWasm/wasmd/blob/02a54d33ff2c064f3539ae12d75d027d9c665f05/x/wasm/internal/types/proposal.go#L28-L34 EnableSpecificProposals = "" - Upgrades = []upgrades.Upgrade{v4.Upgrade} + Upgrades = []upgrades.Upgrade{v4.Upgrade, v5.Upgrade} Forks = []upgrades.Fork{v4_5.Fork, v4_5_1.Fork} )