Skip to content

Commit

Permalink
remove ratelimit handler
Browse files Browse the repository at this point in the history
  • Loading branch information
vuong177 committed Oct 23, 2023
1 parent b186de5 commit 806065b
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 158 deletions.
158 changes: 0 additions & 158 deletions app/upgrades/v6/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package v6

import (
"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/cosmos/cosmos-sdk/codec"
Expand All @@ -21,19 +20,9 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/notional-labs/composable/v6/x/ratelimit/types"

"github.com/notional-labs/composable/v6/bech32-migration/utils"
)

const (
// https://github.com/cosmos/chain-registry/blob/master/composable/assetlist.json
uatom = "ibc/EF48E6B1A1A19F47ECAEA62F5670C37C0580E86A9E88498B7E393EB6F49F33C0"
dot = "ibc/3CC19CEC7E5A3E90E78A5A9ECC5A0E2F8F826A375CF1E096F4515CF09DA3E366"
ksm = "ibc/EE9046745AEC0E8302CB7ED9D5AD67F528FB3B7AE044B247FB0FB293DBDA35E9"
usdt = "ibc/F3EC9F834E57DF704FA3AEAF14E8391C2E58397FE56960AD70E67562990D8265"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
Expand Down Expand Up @@ -62,153 +51,6 @@ func CreateUpgradeHandler(
return false
})

// update rate limit to 50k
rlKeeper := keepers.RatelimitKeeper
// add uatom
uatomRateLimit, found := rlKeeper.GetRateLimit(ctx, uatom, "channel-2")
if !found {
channelValue := rlKeeper.GetChannelValue(ctx, uatom)
// Create and store the rate limit object
path := types.Path{
Denom: uatom,
ChannelID: "channel-2",
}
quota := types.Quota{
MaxPercentSend: sdk.NewInt(30),
MaxPercentRecv: sdk.NewInt(30),
DurationHours: 1,
}
flow := types.Flow{
Inflow: math.ZeroInt(),
Outflow: math.ZeroInt(),
ChannelValue: channelValue,
}
uatomRateLimit = types.RateLimit{
Path: &path,
Quota: &quota,
Flow: &flow,
MinRateLimitAmount: sdk.NewInt(1282_000_000 * 5), // 1282_000_000 * 5
}
rlKeeper.SetRateLimit(ctx, uatomRateLimit)
} else {
quota := types.Quota{
MaxPercentSend: sdk.NewInt(30),
MaxPercentRecv: sdk.NewInt(30),
DurationHours: 1,
}
uatomRateLimit.Quota = &quota
uatomRateLimit.MinRateLimitAmount = sdk.NewInt(1282_000_000 * 5)
rlKeeper.SetRateLimit(ctx, uatomRateLimit)
}
// add dot
dotRateLimit, found := rlKeeper.GetRateLimit(ctx, dot, "channel-2")
if !found {
channelValue := rlKeeper.GetChannelValue(ctx, dot)
// Create and store the rate limit object
path := types.Path{
Denom: dot,
ChannelID: "channel-2",
}
quota := types.Quota{
MaxPercentSend: sdk.NewInt(30),
MaxPercentRecv: sdk.NewInt(30),
DurationHours: 1,
}
flow := types.Flow{
Inflow: math.ZeroInt(),
Outflow: math.ZeroInt(),
ChannelValue: channelValue,
}
dotRateLimit = types.RateLimit{
Path: &path,
Quota: &quota,
Flow: &flow,
MinRateLimitAmount: sdk.NewInt(22_670_000_000_000 * 5), // 22_670_000_000_000 * 5
}
rlKeeper.SetRateLimit(ctx, dotRateLimit)
} else {
quota := types.Quota{
MaxPercentSend: sdk.NewInt(30),
MaxPercentRecv: sdk.NewInt(30),
DurationHours: 1,
}
dotRateLimit.Quota = &quota
dotRateLimit.MinRateLimitAmount = sdk.NewInt(22_670_000_000_000 * 5)
rlKeeper.SetRateLimit(ctx, dotRateLimit)
}
// add ksm
ksmRateLimit, found := rlKeeper.GetRateLimit(ctx, ksm, "channel-2")
if !found {
channelValue := rlKeeper.GetChannelValue(ctx, ksm)
// Create and store the rate limit object
path := types.Path{
Denom: ksm,
ChannelID: "channel-2",
}
quota := types.Quota{
MaxPercentSend: sdk.NewInt(30),
MaxPercentRecv: sdk.NewInt(30),
DurationHours: 1,
}
flow := types.Flow{
Inflow: math.ZeroInt(),
Outflow: math.ZeroInt(),
ChannelValue: channelValue,
}
ksmRateLimit = types.RateLimit{
Path: &path,
Quota: &quota,
Flow: &flow,
MinRateLimitAmount: sdk.NewInt(510_000_000_000_000 * 5), // 510_000_000_000_000*5
}
rlKeeper.SetRateLimit(ctx, ksmRateLimit)
} else {
quota := types.Quota{
MaxPercentSend: sdk.NewInt(30),
MaxPercentRecv: sdk.NewInt(30),
DurationHours: 1,
}
ksmRateLimit.Quota = &quota
ksmRateLimit.MinRateLimitAmount = sdk.NewInt(510_000_000_000_000 * 5)
rlKeeper.SetRateLimit(ctx, ksmRateLimit)
}
// add usdt
usdtRateLimit, found := rlKeeper.GetRateLimit(ctx, usdt, "channel-2")
if !found {
channelValue := rlKeeper.GetChannelValue(ctx, usdt)
// Create and store the rate limit object
path := types.Path{
Denom: usdt,
ChannelID: "channel-2",
}
quota := types.Quota{
MaxPercentSend: sdk.NewInt(30),
MaxPercentRecv: sdk.NewInt(30),
DurationHours: 1,
}
flow := types.Flow{
Inflow: math.ZeroInt(),
Outflow: math.ZeroInt(),
ChannelValue: channelValue,
}
usdtRateLimit = types.RateLimit{
Path: &path,
Quota: &quota,
Flow: &flow,
MinRateLimitAmount: sdk.NewInt(10_000_000_000 * 5), // 10_000_000_000 * 5
}
rlKeeper.SetRateLimit(ctx, usdtRateLimit)
} else {
quota := types.Quota{
MaxPercentSend: sdk.NewInt(30),
MaxPercentRecv: sdk.NewInt(30),
DurationHours: 1,
}
usdtRateLimit.Quota = &quota
usdtRateLimit.MinRateLimitAmount = sdk.NewInt(10_000_000_000 * 5)
rlKeeper.SetRateLimit(ctx, usdtRateLimit)
}

return mm.RunMigrations(ctx, configurator, vm)
}
}
86 changes: 86 additions & 0 deletions proposal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"body": {
"messages": [
{
"@type": "/cosmos.gov.v1.MsgSubmitProposal",
"messages": [
{
"@type": "/centauri.ratelimit.v1beta1.MsgUpdateRateLimit",
"authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq",
"denom": "ibc/EF48E6B1A1A19F47ECAEA62F5670C37C0580E86A9E88498B7E393EB6F49F33C0",
"min_rate_limit_amount": "30410000000",
"channel_id": "channel-2",
"max_percent_send": "30",
"max_percent_recv": "30",
"duration_hours": "1"
},
{
"@type": "/centauri.ratelimit.v1beta1.MsgUpdateRateLimit",
"authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq",
"denom": "ibc/3CC19CEC7E5A3E90E78A5A9ECC5A0E2F8F826A375CF1E096F4515CF09DA3E366",
"min_rate_limit_amount": "513350000000000",
"channel_id": "channel-2",
"max_percent_send": "30",
"max_percent_recv": "30",
"duration_hours": "1"
},
{
"@type": "/centauri.ratelimit.v1beta1.MsgUpdateRateLimit",
"authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq",
"denom": "ibc/EE9046745AEC0E8302CB7ED9D5AD67F528FB3B7AE044B247FB0FB293DBDA35E9",
"channel_id": "channel-2",
"max_percent_send": "30",
"max_percent_recv": "30",
"min_rate_limit_amount": "12550000000000000",
"duration_hours": "1"
},
{
"@type": "/centauri.ratelimit.v1beta1.MsgUpdateRateLimit",
"authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq",
"denom": "ibc/F3EC9F834E57DF704FA3AEAF14E8391C2E58397FE56960AD70E67562990D8265",
"min_rate_limit_amount": "250000000000",
"channel_id": "channel-2",
"max_percent_send": "30",
"max_percent_recv": "30",
"duration_hours": "1"
},
{
"@type": "/centauri.ratelimit.v1beta1.MsgUpdateRateLimit",
"authority": "centauri10d07y265gmmuvt4z0w9aw880jnsr700j7g7ejq",
"denom": "ibc/47BD209179859CDE4A2806763D7189B6E6FE13A17880FE2B42DE1E6C1E329E23",
"min_rate_limit_amount": "1",
"channel_id": "channel-2",
"max_percent_send": "30",
"max_percent_recv": "30",
"duration_hours": "1"
}
],
"initial_deposit": [
{
"denom": "ppica",
"amount": "500000000000000000"
}
],
"proposer": "centauri10556m38z4x6pqalr9rl5ytf3cff8q46nk85k9m",
"metadata": "Update Transfer RateLimit",
"title": "Update Transfer RateLimit",
"summary": "Update Transfer RateLimit : change the duration to 1 hour "
}
],
"memo": "",
"timeout_height": "0",
"extension_options": [],
"non_critical_extension_options": []
},
"auth_info": {
"signer_infos": [],
"fee": {
"amount": [],
"gas_limit": "2000000",
"payer": "",
"granter": ""
},
"tip": null
},
"signatures": []
}

0 comments on commit 806065b

Please sign in to comment.