Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ibc rate limit module NTRN-393 #706

Merged
merged 98 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
0d8817f
basic integration of ibc-rate-limit module
quasisamurai Sep 3, 2024
95f27b0
init ibc-rate-limit module
quasisamurai Sep 3, 2024
fcb1313
insert midlleware properly
quasisamurai Sep 3, 2024
9192032
set pfm & ibc rate middleware init earlier
quasisamurai Sep 3, 2024
03ddf4c
init modules in proper order
quasisamurai Sep 3, 2024
316a82f
wip adapting tests
quasisamurai Sep 3, 2024
829a63a
wip msg server
quasisamurai Sep 3, 2024
b2931d7
modify init once again
quasisamurai Sep 3, 2024
5e3a161
update testutil w some helpers
quasisamurai Sep 3, 2024
4523a1a
play w initialization 1 more time
quasisamurai Sep 3, 2024
b8725a5
upd tests
quasisamurai Sep 3, 2024
8a58c2d
fix hooks init)
quasisamurai Sep 3, 2024
8dc0bf9
wip
quasisamurai Sep 4, 2024
0e5e0b9
archeologic works on unit tests
quasisamurai Sep 4, 2024
0316a8a
rewrite kepeers & ibnc module init
quasisamurai Sep 4, 2024
3eb0a8f
add commit block, fix tests
quasisamurai Sep 4, 2024
aa66712
proper order of init once again
quasisamurai Sep 4, 2024
ddb904c
fix
pr0n00gler Sep 5, 2024
a3c7e8c
fix
pr0n00gler Sep 5, 2024
3c30c75
chain works
quasisamurai Sep 5, 2024
12353cc
Merge remote-tracking branch 'origin/feat/ibc-rate-limit' into feat/i…
quasisamurai Sep 5, 2024
1969117
some debug: contract addr set and exists in tests, but not exist on r…
quasisamurai Sep 5, 2024
ae40a29
finalize tests & app go: tests are passing
quasisamurai Sep 5, 2024
45e1993
proto-format
quasisamurai Sep 5, 2024
bf02dc6
init feekeeper before transfer keeper
quasisamurai Sep 5, 2024
b451f01
make all unit tests pass
quasisamurai Sep 5, 2024
f820184
Merge branch 'main' into feat/ibc-rate-limit
quasisamurai Sep 5, 2024
9c7588f
modify transfer stack order
quasisamurai Sep 5, 2024
2e0af84
upd comment
quasisamurai Sep 6, 2024
987a288
wip debug
quasisamurai Sep 6, 2024
65036e4
wip migration of neutron specific ibc-rate-limit changes
bonedaddy Sep 6, 2024
48edf99
rate-limiter: fix tests to work with 2.x of cosmwasm-std
bonedaddy Sep 7, 2024
aee1dde
rate-limit: update cargo.lock
bonedaddy Sep 7, 2024
b03a01f
wip debug
quasisamurai Sep 9, 2024
f64d22d
Merge branch 'main' into feat/ibc-rate-limit
quasisamurai Sep 9, 2024
8d11458
tidy
quasisamurai Sep 9, 2024
9ca43ad
ranme .cargo/config to .cargo/config.toml
bonedaddy Sep 9, 2024
8c20064
replace osmosis addresses in tests with neutron addresses
bonedaddy Sep 9, 2024
676c58e
update comments to reference neutron instead of osmosis where applicable
bonedaddy Sep 9, 2024
124320a
remove feature activation deprecated in cosmwasm-std 2
bonedaddy Sep 9, 2024
fd13486
rm debug logs
quasisamurai Sep 10, 2024
d0a672a
partial lint
quasisamurai Sep 10, 2024
b24769d
second iteration of lint
quasisamurai Sep 10, 2024
29109e6
final iteration of lint: gofumpt w -extra
quasisamurai Sep 10, 2024
051a12f
Merge branch 'main' into feat/ibc-rate-limit
quasisamurai Sep 10, 2024
c5f61f0
move .cargo folder to workspace root
bonedaddy Sep 11, 2024
4199b61
Merge remote-tracking branch 'origin/feat/ibc-rate-limit' into feat/i…
bonedaddy Sep 11, 2024
0148c5c
recompile rate limit wasm contract
bonedaddy Sep 11, 2024
3d01fec
remove unnecessary resolver set
bonedaddy Sep 11, 2024
44b08d0
prepare proto
quasisamurai Sep 11, 2024
e683d1d
regen proto & create necc files for keeper/msgserver
quasisamurai Sep 11, 2024
0017250
integrate keeper
quasisamurai Sep 11, 2024
226ed4e
wip
quasisamurai Sep 12, 2024
270a0a1
rate_limit: use grpc query helper when extracting channel value
bonedaddy Sep 12, 2024
008a2f8
rate-limit: recompile rate limiter contract
bonedaddy Sep 12, 2024
0c0dffb
Merge pull request #716 from rangesecurity/feat/ibc-rate-limit
pr0n00gler Sep 13, 2024
e0360d0
Merge branch 'feat/ibc-rate-limit' into feat/rate-limit-params
quasisamurai Sep 16, 2024
afd556c
register everything, add simulation etc
quasisamurai Sep 16, 2024
36117b4
rm unused
quasisamurai Sep 16, 2024
71477cc
lint
quasisamurai Sep 16, 2024
81f6303
return err on set params
quasisamurai Sep 16, 2024
d0c167f
Merge pull request #718 from neutron-org/feat/rate-limit-params
quasisamurai Sep 16, 2024
c3996f8
Merge branch 'main' into feat/ibc-rate-limit
quasisamurai Sep 16, 2024
f929592
resolve conflicts & gomodtidy
quasisamurai Sep 16, 2024
f782178
Update x/ibc-rate-limit/keeper/keeper.go
quasisamurai Sep 17, 2024
4212295
Update x/ibc-rate-limit/types/codec.go
quasisamurai Sep 17, 2024
25378cf
get rid of osmosis mentions & move proto to neutron folder
quasisamurai Sep 17, 2024
ff6fe4a
update code comments
quasisamurai Sep 17, 2024
d24b352
add more comments to app.go
quasisamurai Sep 17, 2024
b654088
modify ibcrl module to store pointers, should help avoid problems in …
quasisamurai Sep 17, 2024
9a44936
move max supported ibc reciever addr len to const
quasisamurai Sep 17, 2024
931cab8
whitelists rl update params
quasisamurai Sep 18, 2024
76a73d5
make contract address field nullable
quasisamurai Sep 18, 2024
37af5de
rm print from tests
quasisamurai Sep 19, 2024
166daf2
uncomment cli
quasisamurai Sep 19, 2024
9cb8580
rm contract code from module bc we have moved it to separate repo
quasisamurai Sep 19, 2024
7f205d3
some refactoring and new tests
quasisamurai Sep 26, 2024
743d590
regen proto & rm unused file
quasisamurai Sep 26, 2024
3c9e990
rm unoptimised file and right multi-quota init
quasisamurai Sep 27, 2024
be12fd8
move some values to constants, wrap some errors
quasisamurai Sep 27, 2024
437843a
modify readme to get rid of osmo mentions
quasisamurai Sep 27, 2024
460a742
rework module structure: unify it acc to rest modules
quasisamurai Sep 27, 2024
f7e6f63
use unoptimised wasm file bc optimised thow an err in tests
quasisamurai Sep 27, 2024
af15a0a
upd constants
quasisamurai Sep 27, 2024
4672c4b
avoid pure strings in code & store unoptimised wasm file bc optimised…
quasisamurai Sep 27, 2024
30f6557
add comment explaining stack
quasisamurai Sep 27, 2024
29b59ed
Merge branch 'main' into feat/ibc-rate-limit
quasisamurai Sep 27, 2024
a234457
upgrade rl to v5
quasisamurai Sep 27, 2024
2ec4d09
make channel constant
quasisamurai Sep 27, 2024
146dce5
ref: simple return instead of branching
quasisamurai Sep 30, 2024
cfa5400
add ibc rate limits into upgrade handler
pr0n00gler Sep 30, 2024
b1d32a8
use channel keeper instead of rl wrapper in wasm & ica
quasisamurai Sep 30, 2024
ef2d0b0
add ibc rate limit contract init to upgrade
quasisamurai Oct 1, 2024
e6aea28
Merge branch 'main' into feat/ibc-rate-limit
quasisamurai Oct 1, 2024
ddff618
aftermerge fix
quasisamurai Oct 1, 2024
c435888
rm prints. here we dont like prints
quasisamurai Oct 1, 2024
f15be55
check weekly used out as well + send 2untrn instead of 1
quasisamurai Oct 2, 2024
772156b
add upgrade test just in case
quasisamurai Oct 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ data
.mutagen.yml
vendor/
.testchains

x/ibc-rate-limit/contracts/rate-limiter/target/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are these paths and what generates [files in] them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contract code was stored and built right in a module, this is a rudiment


x/ibc-rate-limit/target/
213 changes: 127 additions & 86 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (
"path/filepath"
"time"

"github.com/neutron-org/neutron/v4/x/dynamicfees"
dynamicfeestypes "github.com/neutron-org/neutron/v4/x/dynamicfees/types"

"github.com/skip-mev/feemarket/x/feemarket"
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"

"github.com/neutron-org/neutron/v4/x/dynamicfees"
dynamicfeestypes "github.com/neutron-org/neutron/v4/x/dynamicfees/types"
"github.com/neutron-org/neutron/v4/x/ibc-rate-limit/ibcratelimitmodule"

"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec"
Expand Down Expand Up @@ -131,6 +132,9 @@ import (
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"

ibcratelimit "github.com/neutron-org/neutron/v4/x/ibc-rate-limit"
ibcratelimitkeeper "github.com/neutron-org/neutron/v4/x/ibc-rate-limit/keeper"
ibcratelimittypes "github.com/neutron-org/neutron/v4/x/ibc-rate-limit/types"
//nolint:staticcheck
ibcporttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/v8/modules/core/exported"
Expand Down Expand Up @@ -268,6 +272,7 @@ var (
),
ibchooks.AppModuleBasic{},
packetforward.AppModuleBasic{},
ibcratelimitmodule.AppModuleBasic{},
auction.AppModuleBasic{},
globalfee.AppModule{},
feemarket.AppModuleBasic{},
Expand Down Expand Up @@ -368,8 +373,10 @@ type App struct {

PFMModule packetforward.AppModule

HooksTransferIBCModule *ibchooks.IBCMiddleware
HooksICS4Wrapper ibchooks.ICS4Middleware
TransferStack *ibchooks.IBCMiddleware
Ics20WasmHooks *ibchooks.WasmHooks
RateLimitingICS4Wrapper *ibcratelimit.ICS4Wrapper
HooksICS4Wrapper ibchooks.ICS4Middleware

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand All @@ -384,7 +391,8 @@ type App struct {

ConsensusParamsKeeper consensusparamkeeper.Keeper

WasmKeeper wasmkeeper.Keeper
WasmKeeper wasmkeeper.Keeper
ContractKeeper *wasmkeeper.PermissionedKeeper

// slinky
MarketMapKeeper *marketmapkeeper.Keeper
Expand Down Expand Up @@ -475,7 +483,7 @@ func New(
icahosttypes.StoreKey, capabilitytypes.StoreKey,
interchainqueriesmoduletypes.StoreKey, contractmanagermoduletypes.StoreKey, interchaintxstypes.StoreKey, wasmtypes.StoreKey, feetypes.StoreKey,
feeburnertypes.StoreKey, adminmoduletypes.StoreKey, ccvconsumertypes.StoreKey, tokenfactorytypes.StoreKey, pfmtypes.StoreKey,
crontypes.StoreKey, ibchookstypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, dextypes.StoreKey, auctiontypes.StoreKey,
crontypes.StoreKey, ibcratelimittypes.ModuleName, ibchookstypes.StoreKey, consensusparamtypes.StoreKey, crisistypes.StoreKey, dextypes.StoreKey, auctiontypes.StoreKey,
oracletypes.StoreKey, marketmaptypes.StoreKey, feemarkettypes.StoreKey, dynamicfeestypes.StoreKey, globalfeetypes.StoreKey,
)
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey, dextypes.TStoreKey)
Expand Down Expand Up @@ -507,6 +515,7 @@ func New(
scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName)
scopedICAHostKeeper := app.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName)
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
app.ScopedTransferKeeper = scopedTransferKeeper
scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName)
scopedInterTxKeeper := app.CapabilityKeeper.ScopeToModule(interchaintxstypes.ModuleName)
scopedCCVConsumerKeeper := app.CapabilityKeeper.ScopeToModule(ccvconsumertypes.ModuleName)
Expand Down Expand Up @@ -588,41 +597,45 @@ func New(
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), &app.ConsumerKeeper, app.UpgradeKeeper, scopedIBCKeeper, authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)

// Feekeeper needs to be initialized before middlewares injection
app.FeeKeeper = feekeeper.NewKeeper(
appCodec,
keys[feetypes.StoreKey],
memKeys[feetypes.MemStoreKey],
app.IBCKeeper.ChannelKeeper,
app.BankKeeper,
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)
feeModule := feerefunder.NewAppModule(appCodec, *app.FeeKeeper, app.AccountKeeper, app.BankKeeper)

app.ContractManagerKeeper = *contractmanagermodulekeeper.NewKeeper(
appCodec,
keys[contractmanagermoduletypes.StoreKey],
keys[contractmanagermoduletypes.MemStoreKey],
&app.WasmKeeper,
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)

app.WireICS20PreWasmKeeper(appCodec)
app.PFMModule = packetforward.NewAppModule(app.PFMKeeper, app.GetSubspace(pfmtypes.ModuleName))

app.ICAControllerKeeper = icacontrollerkeeper.NewKeeper(
appCodec, keys[icacontrollertypes.StoreKey], app.GetSubspace(icacontrollertypes.SubModuleName),
app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 feerefunder
app.RateLimitingICS4Wrapper, // defiened in wireisc20
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
app.RateLimitingICS4Wrapper, // defiened in wireisc20
app.RateLimitingICS4Wrapper, // defined in wireisc20

app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper,
scopedICAControllerKeeper, app.MsgServiceRouter(),
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)

app.ICAHostKeeper = icahostkeeper.NewKeeper(
appCodec, keys[icahosttypes.StoreKey], app.GetSubspace(icahosttypes.SubModuleName),
app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 feerefunder
app.RateLimitingICS4Wrapper, // defiened in wireisc20
app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper,
app.AccountKeeper, scopedICAHostKeeper, app.MsgServiceRouter(),
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)
app.ICAHostKeeper.WithQueryRouter(app.GRPCQueryRouter())

app.ContractManagerKeeper = *contractmanagermodulekeeper.NewKeeper(
appCodec,
keys[contractmanagermoduletypes.StoreKey],
keys[contractmanagermoduletypes.MemStoreKey],
&app.WasmKeeper,
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)

app.FeeKeeper = feekeeper.NewKeeper(
appCodec,
keys[feetypes.StoreKey],
memKeys[feetypes.MemStoreKey],
app.IBCKeeper.ChannelKeeper,
app.BankKeeper,
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)
feeModule := feerefunder.NewAppModule(appCodec, *app.FeeKeeper, app.AccountKeeper, app.BankKeeper)

app.FeeBurnerKeeper = feeburnerkeeper.NewKeeper(
appCodec,
keys[feeburnertypes.StoreKey],
Expand All @@ -635,44 +648,6 @@ func New(

app.GlobalFeeKeeper = globalfeekeeper.NewKeeper(appCodec, keys[globalfeetypes.StoreKey], authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String())

// PFMKeeper must be created before TransferKeeper
app.PFMKeeper = pfmkeeper.NewKeeper(
appCodec,
app.keys[pfmtypes.StoreKey],
app.TransferKeeper.Keeper,
app.IBCKeeper.ChannelKeeper,
app.FeeBurnerKeeper,
&app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)
wasmHooks := ibchooks.NewWasmHooks(nil, sdk.GetConfig().GetBech32AccountAddrPrefix()) // The contract keeper needs to be set later
app.HooksICS4Wrapper = ibchooks.NewICS4Middleware(
app.IBCKeeper.ChannelKeeper,
app.PFMKeeper,
&wasmHooks,
)

// Create Transfer Keepers
app.TransferKeeper = wrapkeeper.NewKeeper(
appCodec,
keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
app.HooksICS4Wrapper, // essentially still app.IBCKeeper.ChannelKeeper under the hood because no hook overrides
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
app.AccountKeeper,
&app.BankKeeper,
scopedTransferKeeper,
app.FeeKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)

app.PFMKeeper.SetTransferKeeper(app.TransferKeeper.Keeper)

transferModule := transferSudo.NewAppModule(app.TransferKeeper)

// Create evidence Keeper for to register the IBC light client misbehaviour evidence route
evidenceKeeper := evidencekeeper.NewKeeper(
appCodec, runtime.NewKVStoreService(keys[evidencetypes.StoreKey]), &app.ConsumerKeeper, app.SlashingKeeper,
Expand Down Expand Up @@ -846,7 +821,7 @@ func New(
&app.BankKeeper,
nil,
nil,
app.IBCKeeper.ChannelKeeper, // may be replaced with middleware such as ics29 feerefunder
app.RateLimitingICS4Wrapper, // defiened in wireisc20
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
scopedWasmKeeper,
Expand All @@ -859,19 +834,10 @@ func New(
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
wasmOpts...,
)
wasmHooks.ContractKeeper = &app.WasmKeeper

app.CronKeeper.WasmMsgServer = wasmkeeper.NewMsgServerImpl(&app.WasmKeeper)
cronModule := cron.NewAppModule(appCodec, app.CronKeeper)

transferIBCModule := transferSudo.NewIBCModule(
app.TransferKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
)
// receive call order: wasmHooks#OnRecvPacketOverride(transferIbcModule#OnRecvPacket())
ibcHooksMiddleware := ibchooks.NewIBCMiddleware(&transferIBCModule, &app.HooksICS4Wrapper)
app.HooksTransferIBCModule = &ibcHooksMiddleware

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()

Expand All @@ -893,23 +859,18 @@ func New(
)
interchainTxsModule := interchaintxs.NewAppModule(appCodec, app.InterchainTxsKeeper, app.AccountKeeper, app.BankKeeper)
contractManagerModule := contractmanager.NewAppModule(appCodec, app.ContractManagerKeeper)
ibcRateLimitmodule := ibcratelimitmodule.NewAppModule(appCodec, app.RateLimitingICS4Wrapper.IbcratelimitKeeper, app.RateLimitingICS4Wrapper)
ibcHooksModule := ibchooks.NewAppModule(app.AccountKeeper)

app.PFMModule = packetforward.NewAppModule(app.PFMKeeper, app.GetSubspace(pfmtypes.ModuleName))

var ibcStack ibcporttypes.IBCModule = packetforward.NewIBCMiddleware(
app.HooksTransferIBCModule,
app.PFMKeeper,
0,
pfmkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
pfmkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)
transferModule := transferSudo.NewAppModule(app.TransferKeeper)
app.ContractKeeper = wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper)

ibcStack = gmpmiddleware.NewIBCMiddleware(ibcStack)
app.RateLimitingICS4Wrapper.ContractKeeper = app.ContractKeeper
app.Ics20WasmHooks.ContractKeeper = &app.WasmKeeper

ibcRouter.AddRoute(icacontrollertypes.SubModuleName, icaControllerStack).
AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
AddRoute(ibctransfertypes.ModuleName, ibcStack).
AddRoute(ibctransfertypes.ModuleName, app.TransferStack).
AddRoute(interchaintxstypes.ModuleName, icaControllerStack).
AddRoute(wasmtypes.ModuleName, wasm.NewIBCHandler(app.WasmKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper)).
AddRoute(ccvconsumertypes.ModuleName, consumerModule)
Expand Down Expand Up @@ -949,6 +910,7 @@ func New(
feeBurnerModule,
contractManagerModule,
adminModule,
ibcRateLimitmodule,
ibcHooksModule,
tokenfactory.NewAppModule(appCodec, *app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper),
cronModule,
Expand Down Expand Up @@ -997,6 +959,7 @@ func New(
feetypes.ModuleName,
feeburnertypes.ModuleName,
adminmoduletypes.ModuleName,
ibcratelimittypes.ModuleName,
ibchookstypes.ModuleName,
pfmtypes.ModuleName,
crontypes.ModuleName,
Expand Down Expand Up @@ -1033,6 +996,7 @@ func New(
feetypes.ModuleName,
feeburnertypes.ModuleName,
adminmoduletypes.ModuleName,
ibcratelimittypes.ModuleName,
ibchookstypes.ModuleName,
pfmtypes.ModuleName,
crontypes.ModuleName,
Expand Down Expand Up @@ -1074,6 +1038,7 @@ func New(
feetypes.ModuleName,
feeburnertypes.ModuleName,
adminmoduletypes.ModuleName,
ibcratelimittypes.ModuleName,
ibchookstypes.ModuleName, // after auth keeper
pfmtypes.ModuleName,
crontypes.ModuleName,
Expand Down Expand Up @@ -1108,6 +1073,7 @@ func New(
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
transferModule,
ibcRateLimitmodule,
consumerModule,
icaModule,
app.PFMModule,
Expand Down Expand Up @@ -1673,3 +1639,78 @@ func overrideWasmVariables() {
wasmtypes.MaxWasmSize = 1_677_722 // ~1.6 mb (1024 * 1024 * 1.6)
wasmtypes.MaxProposalWasmSize = wasmtypes.MaxWasmSize
}

func (app *App) WireICS20PreWasmKeeper(
appCodec codec.Codec,
) {
// PFMKeeper must be created before TransferKeeper
app.PFMKeeper = pfmkeeper.NewKeeper(
appCodec,
app.keys[pfmtypes.StoreKey],
app.TransferKeeper.Keeper, // set later
app.IBCKeeper.ChannelKeeper,
app.FeeBurnerKeeper,
&app.BankKeeper,
app.IBCKeeper.ChannelKeeper,
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)

wasmHooks := ibchooks.NewWasmHooks(nil, sdk.GetConfig().GetBech32AccountAddrPrefix()) // The contract keeper needs to be set later
app.Ics20WasmHooks = &wasmHooks
app.HooksICS4Wrapper = ibchooks.NewICS4Middleware(
app.IBCKeeper.ChannelKeeper,
app.PFMKeeper,
&wasmHooks,
)

ibcratelimitKeeper := ibcratelimitkeeper.NewKeeper(appCodec, app.keys[ibcratelimittypes.ModuleName], authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String())
// ChannelKeeper wrapper for rate limiting SendPacket(). The wasmKeeper needs to be added after it's created
rateLimitingICS4Wrapper := ibcratelimit.NewICS4Middleware(
app.HooksICS4Wrapper,
&app.AccountKeeper,
// wasm keeper we set later, right after wasmkeeper init. line 868
nil,
&app.BankKeeper,
&ibcratelimitKeeper,
)
app.RateLimitingICS4Wrapper = &rateLimitingICS4Wrapper

// Create Transfer Keepers
app.TransferKeeper = wrapkeeper.NewKeeper(
appCodec,
app.keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
app.RateLimitingICS4Wrapper,
app.IBCKeeper.ChannelKeeper,
app.IBCKeeper.PortKeeper,
app.AccountKeeper,
&app.BankKeeper,
app.ScopedTransferKeeper,
app.FeeKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(),
)

app.PFMKeeper.SetTransferKeeper(app.TransferKeeper.Keeper)

// Packet Forward Middleware
// Initialize packet forward middleware router
var ibcStack ibcporttypes.IBCModule = packetforward.NewIBCMiddleware(
transferSudo.NewIBCModule(
app.TransferKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
),
app.PFMKeeper,
0,
pfmkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
pfmkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)

ibcStack = gmpmiddleware.NewIBCMiddleware(ibcStack)
// RateLimiting IBC Middleware
rateLimitingTransferModule := ibcratelimit.NewIBCModule(ibcStack, app.RateLimitingICS4Wrapper)

// Hooks Middleware
hooksTransferModule := ibchooks.NewIBCMiddleware(&rateLimitingTransferModule, &app.HooksICS4Wrapper)
app.TransferStack = &hooksTransferModule
}
4 changes: 3 additions & 1 deletion app/proposals_allowlisting.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck
ccvconsumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types"
ibcratelimittypes "github.com/neutron-org/neutron/v4/x/ibc-rate-limit/types"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"
marketmaptypes "github.com/skip-mev/slinky/x/marketmap/types"

Expand Down Expand Up @@ -93,7 +94,8 @@ func isSdkMessageWhitelisted(msg sdk.Msg) bool {
*feemarkettypes.MsgParams,
*dynamicfeestypes.MsgUpdateParams,
*ibctransfertypes.MsgUpdateParams,
*globalfeetypes.MsgUpdateParams:
*globalfeetypes.MsgUpdateParams,
*ibcratelimittypes.MsgUpdateParams:
return true
}
return false
Expand Down
Loading
Loading