Documentation ¶
Index ¶
- func EmitTransferDeniedEvent(ctx sdk.Context, reason, denom, channelId string, ...)
- func GetRateLimitItemKey(denom string, channelId string) []byte
- func ParseDenomFromRecvPacket(packet channeltypes.Packet, packetData transfertypes.FungibleTokenPacketData) (denom string)
- func ParseDenomFromSendPacket(packet transfertypes.FungibleTokenPacketData) (denom string)
- type Hooks
- type Keeper
- func (k Keeper) AddDenomToBlacklist(ctx sdk.Context, denom string)
- func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
- func (k Keeper) AllRateLimits(c context.Context, req *types.QueryAllRateLimitsRequest) (*types.QueryAllRateLimitsResponse, error)
- func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
- func (k Keeper) CheckRateLimitAndUpdateFlow(ctx sdk.Context, direction types.PacketDirection, denom string, ...) error
- func (k Keeper) GetAllBlacklistedDenoms(ctx sdk.Context) []string
- func (k Keeper) GetAllRateLimits(ctx sdk.Context) []types.RateLimit
- func (k Keeper) GetAppVersion(ctx sdk.Context, portID, channelID string) (string, bool)
- func (k Keeper) GetChannelValue(ctx sdk.Context, denom string) sdkmath.Int
- func (k Keeper) GetParams(ctx sdk.Context) types.Params
- func (k Keeper) GetRateLimit(ctx sdk.Context, denom string, channelId string) (rateLimit types.RateLimit, found bool)
- func (k Keeper) Hooks() Hooks
- func (k Keeper) IsDenomBlacklisted(ctx sdk.Context, denom string) bool
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) RateLimit(c context.Context, req *types.QueryRateLimitRequest) (*types.QueryRateLimitResponse, error)
- func (k Keeper) RateLimitsByChainId(c context.Context, req *types.QueryRateLimitsByChainIdRequest) (*types.QueryRateLimitsByChainIdResponse, error)
- func (k Keeper) RateLimitsByChannelId(c context.Context, req *types.QueryRateLimitsByChannelIdRequest) (*types.QueryRateLimitsByChannelIdResponse, error)
- func (k Keeper) ReceiveRateLimitedPacket(ctx sdk.Context, packet channeltypes.Packet) error
- func (k Keeper) RemoveDenomFromBlacklist(ctx sdk.Context, denom string)
- func (k Keeper) RemoveRateLimit(ctx sdk.Context, denom string, channelId string)
- func (k Keeper) ResetRateLimit(ctx sdk.Context, denom string, channelId string) error
- func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, ...) error
- func (k Keeper) SendRateLimitedPacket(ctx sdk.Context, packet ibcexported.PacketI) error
- func (k Keeper) SetParams(ctx sdk.Context, params types.Params)
- func (k Keeper) SetRateLimit(ctx sdk.Context, rateLimit types.RateLimit)
- func (k Keeper) UpdateFlow(rateLimit types.RateLimit, direction types.PacketDirection, amount sdkmath.Int) error
- func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EmitTransferDeniedEvent ¶
func EmitTransferDeniedEvent(ctx sdk.Context, reason, denom, channelId string, direction types.PacketDirection, amount sdkmath.Int, err error)
If the rate limit is exceeded or the denom is blacklisted, we emit an event
func GetRateLimitItemKey ¶
Get the rate limit byte key built from the denom and channelId
func ParseDenomFromRecvPacket ¶
func ParseDenomFromRecvPacket(packet channeltypes.Packet, packetData transfertypes.FungibleTokenPacketData) (denom string)
Parse the denom from the Recv Packet that will be used by the rate limit module The denom that the rate limiter will use for a RECEIVE packet depends on whether it was a source or sink
Sink: The token moves forward, to a chain different than its previous hop The new port and channel are APPENDED to the denom trace. (e.g. A -> B, B is a sink) (e.g. A -> B -> C, C is a sink) Source: The token moves backwards (i.e. revisits the last chain it was sent from) The port and channel are REMOVED from the denom trace - undoing the last hop. (e.g. A -> B -> A, A is a source) (e.g. A -> B -> C -> B, B is a source) If the chain is acting as a SINK: We add on the Stride port and channel and hash it Ex1: uosmo sent from Osmosis to Stride Packet Denom: uosmo -> Add Prefix: transfer/channel-X/uosmo -> Hash: ibc/... Ex2: ujuno sent from Osmosis to Stride PacketDenom: transfer/channel-Y/ujuno (channel-Y is the Juno <> Osmosis channel) -> Add Prefix: transfer/channel-X/transfer/channel-Y/ujuno -> Hash: ibc/... If the chain is acting as a SOURCE: First, remove the prefix. Then if there is still a denom trace, hash it Ex1: ustrd sent back to Stride from Osmosis Packet Denom: transfer/channel-X/ustrd -> Remove Prefix: ustrd -> Leave as is: ustrd Ex2: juno was sent to Stride, then to Osmosis, then back to Stride Packet Denom: transfer/channel-X/transfer/channel-Z/ujuno -> Remove Prefix: transfer/channel-Z/ujuno -> Hash: ibc/...
func ParseDenomFromSendPacket ¶
func ParseDenomFromSendPacket(packet transfertypes.FungibleTokenPacketData) (denom string)
Parse the denom from the Send Packet that will be used by the rate limit module The denom that the rate limiter will use for a SEND packet depends on whether
it was a NATIVE token (e.g. ustrd, stuatom, etc.) or NON-NATIVE token (e.g. ibc/...)...
We can identify if the token is native or not by parsing the trace denom from the packet If the token is NATIVE, it will not have a prefix (e.g. ustrd),
and if it is NON-NATIVE, it will have a prefix (e.g. transfer/channel-2/uosmo)
For NATIVE denoms, return as is (e.g. ustrd) For NON-NATIVE denoms, take the ibc hash (e.g. hash "transfer/channel-2/usoms" into "ibc/...")
Types ¶
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
func (Hooks) AfterEpochEnd ¶
func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
func (Hooks) BeforeEpochStart ¶
func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func NewKeeper ¶
func NewKeeper( cdc codec.BinaryCodec, key storetypes.StoreKey, ps paramtypes.Subspace, bankKeeper types.BankKeeper, channelKeeper types.ChannelKeeper, ics4Wrapper types.ICS4Wrapper, ) *Keeper
func (Keeper) AddDenomToBlacklist ¶
Adds a denom to a blacklist to prevent all IBC transfers with this denom
func (Keeper) AfterEpochEnd ¶
func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
func (Keeper) AllRateLimits ¶
func (k Keeper) AllRateLimits(c context.Context, req *types.QueryAllRateLimitsRequest) (*types.QueryAllRateLimitsResponse, error)
Query all rate limits
func (Keeper) BeforeEpochStart ¶
func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochInfo epochstypes.EpochInfo)
Before each hour epoch, check if any of the rate limits have expired,
and reset them if they have
func (Keeper) CheckRateLimitAndUpdateFlow ¶
func (k Keeper) CheckRateLimitAndUpdateFlow(ctx sdk.Context, direction types.PacketDirection, denom string, channelId string, amount sdkmath.Int) error
Checks whether the given packet will exceed the rate limit Called by OnRecvPacket and OnSendPacket
func (Keeper) GetAllBlacklistedDenoms ¶
Get all the blacklisted denoms
func (Keeper) GetAllRateLimits ¶
Returns all rate limits stored
func (Keeper) GetAppVersion ¶
GetAppVersion wraps IBC ChannelKeeper's GetAppVersion function
func (Keeper) GetChannelValue ¶
The total value on a given path (aka, the denominator in the percentage calculation) is the total supply of the given denom
func (Keeper) GetRateLimit ¶
func (k Keeper) GetRateLimit(ctx sdk.Context, denom string, channelId string) (rateLimit types.RateLimit, found bool)
Grabs and returns a rate limit object from the store using denom and channel-id
func (Keeper) IsDenomBlacklisted ¶
Check if a denom is currently blacklistec
func (Keeper) RateLimit ¶
func (k Keeper) RateLimit(c context.Context, req *types.QueryRateLimitRequest) (*types.QueryRateLimitResponse, error)
Query a rate limit by denom and channelId
func (Keeper) RateLimitsByChainId ¶
func (k Keeper) RateLimitsByChainId(c context.Context, req *types.QueryRateLimitsByChainIdRequest) (*types.QueryRateLimitsByChainIdResponse, error)
Query all rate limits for a given chain
func (Keeper) RateLimitsByChannelId ¶
func (k Keeper) RateLimitsByChannelId(c context.Context, req *types.QueryRateLimitsByChannelIdRequest) (*types.QueryRateLimitsByChannelIdResponse, error)
Query all rate limits for a given channel
func (Keeper) ReceiveRateLimitedPacket ¶
Middleware implementation for RecvPacket with rate limiting
func (Keeper) RemoveDenomFromBlacklist ¶
Removes a denom from a blacklist to re-enable IBC transfers for that denom
func (Keeper) RemoveRateLimit ¶
Removes a rate limit object from the store using denom and channel-id
func (Keeper) ResetRateLimit ¶
Reset the rate limit after expiration The inflow and outflow should get reset to 1 and the channelValue should be updated
func (Keeper) SendPacket ¶
func (k Keeper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI) error
SendPacket wraps IBC ChannelKeeper's SendPacket function If the packet does not get rate limited, it passes the packet to the IBC Channel keeper
func (Keeper) SendRateLimitedPacket ¶
Middleware implementation for SendPacket with rate limiting
func (Keeper) SetRateLimit ¶
Stores/Updates a rate limit object in the store
func (Keeper) UpdateFlow ¶
func (k Keeper) UpdateFlow(rateLimit types.RateLimit, direction types.PacketDirection, amount sdkmath.Int) error
Adds an amount to the flow in either the SEND or RECV direction
func (Keeper) WriteAcknowledgement ¶
func (k Keeper) WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error
WriteAcknowledgement wraps IBC ChannelKeeper's WriteAcknowledgement function