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 #1692

Merged
merged 101 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
a2488b0
Add protos from osmosis ibc-rate-limit module and convert them to pro…
Sep 26, 2023
504c4b4
Add ibc-rate-limit module from osmosis. It has not been converted yet.
Sep 26, 2023
a3e9d18
Add update to README about forking.
Sep 26, 2023
4aab780
Convert a majority of the code to Provenance. Still need to fix some …
Sep 26, 2023
091a46c
Fix remaining imports so and work. Need to still usages and ensure …
Sep 26, 2023
71ef6e5
Fix SendPacket signature for newer ibc.
Sep 27, 2023
2cc6569
Fix dependencies for module.go
Sep 27, 2023
9c7d569
Add missing files for osmoutils and fix dependencies.
Sep 27, 2023
5eff379
Add middleware to transfer stack.
Sep 28, 2023
3804fd0
Fix most imports and test code, except for GetSupplyWithOffset.
Sep 28, 2023
0008513
Replace GetSupplyOffset with GetSupply.
Sep 28, 2023
2c954eb
Lint code and added ibcratelimit to different stores and lifecycle ho…
Sep 28, 2023
a7c8c7f
Fix not setting app for testing.
Sep 28, 2023
55018a8
Fix remaining test cases to get tests working again.
Sep 28, 2023
a9c4980
Add missing AppModuleBasic.
Sep 28, 2023
0565cc7
Merge branch 'main' into taztingo/1498-ibc-rate-limit
Sep 28, 2023
ad4fd50
Add fix to get test passing. I'm not entirely sure why the Supply is …
Oct 2, 2023
10d4255
Add fix to other tests to get them passing. I'm still unsure why Supp…
Oct 2, 2023
f33d4fa
Change the tests back to transferring only 2 tokens to exceed. Discov…
Oct 3, 2023
6e1a252
Update osmosis code to be lint compliant.
Oct 3, 2023
e64c15c
Fix more linting issues.
Oct 3, 2023
6a43635
Removed target directory.
Oct 4, 2023
3162770
Start adding simulation code back.
Oct 5, 2023
b5c663c
Start conversion to provwasm. Still had some issues with optimize.
Oct 6, 2023
4685ed2
More standardization.
Oct 18, 2023
29caf95
Fix optimization issue on arm64.
Oct 19, 2023
f60da25
fix contracts to correctly build and optimize with provwasm.
Oct 19, 2023
5628163
Add x86 version of provwasm converted smart contract.
Oct 19, 2023
eff09e5
Merge in main.
Oct 24, 2023
af131e1
Create keeper
Oct 25, 2023
c24de94
Starting to refactor. Create keeper and hook up new query server. Sti…
Oct 25, 2023
3daa3d0
Remove osmocli because it is no longer needed.
Oct 25, 2023
ad82475
Move contract files into contracts/rate-limiter.
Oct 25, 2023
205efc7
Moved osmosis packages into their own directory.
Oct 25, 2023
1fae84f
Introduce new Middleware that replaces IBCModule and ICS4Wrapper.
Oct 25, 2023
50a515c
Fix tests to work with refactor.
Oct 25, 2023
e40f461
Rename module directory in ibcratelimit.
Oct 25, 2023
191ee92
Remove useless paramstate content that is no longer needed.
Oct 25, 2023
a403804
Move rate limit logic into keeper.
Oct 26, 2023
43b39c9
Move errors into ibcratelimit.
Oct 26, 2023
ef6d781
Extract out types into packet.go
Oct 26, 2023
78859b5
Extract out packet validation into packet.go
Oct 26, 2023
4a8188e
Add function comments and move packet functions around.
Oct 26, 2023
cf76436
Update function comments and change events to typed events.
Oct 26, 2023
5e4b8fc
Fix typo in protobuf. Add expected_keepers and replace wasm permissio…
Oct 26, 2023
860eae0
Remove type package and move all types including generated files into…
Oct 26, 2023
4cac613
Setup tests for every function. Just need to add logic to tests.
Oct 26, 2023
d7ec311
Add missing test skeleton for packet.
Oct 26, 2023
398b3e6
Finish tests for params.
Oct 26, 2023
3e53632
Add tests for genesis test.
Oct 26, 2023
96e3996
Remove no longer needed osmosmath dependency, and fix genesis test.
Oct 27, 2023
ad2e0d9
Remove generic_helper and slice_helper since they are no longer needed.
Oct 27, 2023
7435ab6
Remove some more osmosis work and create new ibc file to contain ibc …
Oct 27, 2023
b79d7cc
Remove final osmosis package pieces and instead use testutil testchai…
Oct 27, 2023
1398928
Move ibcratelimit tests to ibcratelimit_test package. Write tests for…
Oct 27, 2023
f17d62e
Add tests for packet, and add mocks to mocks_test.
Oct 27, 2023
4986501
Start adding keeper tests.
Oct 30, 2023
b53db5e
Update genesis to use Assert.
Oct 30, 2023
e67287e
Add tests for CheckAndUpdateRateLimits. Create mocks. Fix nil case in…
Oct 30, 2023
1d01aac
Add tests for UndoSendRateLimit.
Oct 30, 2023
140e744
Add tests for RevertSentPacket.
Oct 30, 2023
e81588d
Move ibc and ibc_test to internal/ibc. They are helper functions that…
Oct 30, 2023
5e311be
Lint code.
Oct 30, 2023
220e9b3
Convert osmosis tests to use suite.Assert() since ours do that.
Oct 30, 2023
5bc07e3
Add comments and remove unused constants.
Oct 30, 2023
5699d81
Add comments to mocks and osmosis test helper functions.
Oct 30, 2023
e2d0375
Merge branch 'main' into taztingo/1498-ibc-rate-limit
Oct 31, 2023
2b35fc4
Fix typo in sim genesis.
Oct 31, 2023
9e437e4
Remove commented out code.
Oct 31, 2023
d9060c8
Change name of ContractConfigured to IsContractConfigured.
Oct 31, 2023
2c0a4e9
Add to temporary upgrade handler.
Nov 1, 2023
3f4226b
Remove temporary upgrade handler because it will be easier to add later.
Nov 1, 2023
cb4e7f9
Update events to have and use constructors. Start preparing for Upgra…
Nov 1, 2023
0a76892
Finish endpoint and tests for GovUpdateParams.
Nov 1, 2023
523a628
Rename event.go to events.go to match standard.
Nov 1, 2023
6f8788a
Add transaction to submit gov proposal.
Nov 1, 2023
0c4be27
Add tests for msgs, and simplify ValidateBasic.
Nov 1, 2023
a90c5ea
Fix format.
Nov 1, 2023
cd1e077
Add tests for cli.
Nov 1, 2023
ae5471e
Merge branch 'main' into taztingo/1498-ibc-rate-limit
Nov 1, 2023
53b66f4
Rename query_server to grpc_query.
Nov 1, 2023
fba96b2
Merge branch 'main' into taztingo/1498-ibc-rate-limit
Nov 1, 2023
592074f
Add PinContract to testutil for future testing.
Nov 3, 2023
ee947f1
Remove return on error since we still want the transfer protocol to f…
Nov 3, 2023
9b72702
Add decoder and decoder tests for simulation.
Nov 6, 2023
be58295
Add genesis sim tests.
Nov 6, 2023
9f3b6d7
Add operations test and fix genesis test.
Nov 6, 2023
c6be160
Fix linting issues.
Nov 7, 2023
858d429
Merge branch 'main' into taztingo/1498-ibc-rate-limit
Nov 7, 2023
aff5d86
Merge branch 'main' into taztingo/1498-ibc-rate-limit
Nov 7, 2023
f667f9f
Update CHANGELOG.
Nov 8, 2023
ea818b0
Merge in main.
Nov 20, 2023
23642f7
Add ibcratelimit to upgrade handler.
Nov 20, 2023
9d74585
Merge in main. Still have to update changelog for 1.17.1
Nov 21, 2023
435dd69
Merge branch 'main' into taztingo/1498-ibc-rate-limit
Nov 27, 2023
e682c5e
Merge branch 'main' into taztingo/1498-ibc-rate-limit
iramiller Nov 28, 2023
3ed2dd9
Move Added in upgrades.go
Nov 28, 2023
d0ce1be
Remove incorrect additional arg in Require.
Nov 28, 2023
b57ec74
Updated WithIBCModule comment.
Nov 28, 2023
bdf97f9
Updated receiver to be a pointer receiver.
Nov 28, 2023
78217fc
Updated comment that had wrong module name.
Nov 28, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* Add the ibcratelimit module [#1498](https://github.com/provenance-io/provenance/issues/1498).
* Add CLI commands for the exchange module endpoints and queries [#1701](https://github.com/provenance-io/provenance/issues/1701).
* Add CLI command to generate autocomplete shell scripts [#1762](https://github.com/provenance-io/provenance/pull/1762).
* Create CLI commands for adding a market to a genesis file [#1757](https://github.com/provenance-io/provenance/issues/1757).
Expand Down
32 changes: 25 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ import (
"github.com/provenance-io/provenance/x/ibchooks"
ibchookskeeper "github.com/provenance-io/provenance/x/ibchooks/keeper"
ibchookstypes "github.com/provenance-io/provenance/x/ibchooks/types"
ibcratelimit "github.com/provenance-io/provenance/x/ibcratelimit"
ibcratelimitkeeper "github.com/provenance-io/provenance/x/ibcratelimit/keeper"
ibcratelimitmodule "github.com/provenance-io/provenance/x/ibcratelimit/module"
"github.com/provenance-io/provenance/x/marker"
markerkeeper "github.com/provenance-io/provenance/x/marker/keeper"
markertypes "github.com/provenance-io/provenance/x/marker/types"
Expand Down Expand Up @@ -218,6 +221,7 @@ var (
ica.AppModuleBasic{},
icq.AppModuleBasic{},
ibchooks.AppModuleBasic{},
ibcratelimitmodule.AppModuleBasic{},

marker.AppModuleBasic{},
attribute.AppModuleBasic{},
Expand Down Expand Up @@ -310,11 +314,12 @@ type App struct {
TriggerKeeper triggerkeeper.Keeper
OracleKeeper oraclekeeper.Keeper

IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCHooksKeeper *ibchookskeeper.Keeper
ICAHostKeeper *icahostkeeper.Keeper
TransferKeeper *ibctransferkeeper.Keeper
ICQKeeper icqkeeper.Keeper
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
IBCHooksKeeper *ibchookskeeper.Keeper
ICAHostKeeper *icahostkeeper.Keeper
TransferKeeper *ibctransferkeeper.Keeper
ICQKeeper icqkeeper.Keeper
RateLimitingKeeper *ibcratelimitkeeper.Keeper

MarkerKeeper markerkeeper.Keeper
MetadataKeeper metadatakeeper.Keeper
Expand Down Expand Up @@ -392,6 +397,7 @@ func New(
icahosttypes.StoreKey,
icqtypes.StoreKey,
ibchookstypes.StoreKey,
ibcratelimit.StoreKey,

metadatatypes.StoreKey,
markertypes.StoreKey,
Expand Down Expand Up @@ -527,12 +533,16 @@ func New(
app.IbcHooks,
)

rateLimtingKeeper := ibcratelimitkeeper.NewKeeper(appCodec, keys[ibcratelimit.StoreKey], nil)
app.RateLimitingKeeper = &rateLimtingKeeper

// Create Transfer Keepers
rateLimitingTransferModule := ibcratelimitmodule.NewIBCMiddleware(nil, app.HooksICS4Wrapper, app.RateLimitingKeeper)
transferKeeper := ibctransferkeeper.NewKeeper(
appCodec,
keys[ibctransfertypes.StoreKey],
app.GetSubspace(ibctransfertypes.ModuleName),
app.HooksICS4Wrapper,
&rateLimitingTransferModule,
app.IBCKeeper.ChannelKeeper,
&app.IBCKeeper.PortKeeper,
app.AccountKeeper,
Expand All @@ -541,7 +551,8 @@ func New(
)
app.TransferKeeper = &transferKeeper
transferModule := ibctransfer.NewIBCModule(*app.TransferKeeper)
hooksTransferModule := ibchooks.NewIBCMiddleware(transferModule, &app.HooksICS4Wrapper)
rateLimitingTransferModule = *rateLimitingTransferModule.WithIBCModule(transferModule)
hooksTransferModule := ibchooks.NewIBCMiddleware(&rateLimitingTransferModule, &app.HooksICS4Wrapper)
app.TransferStack = &hooksTransferModule

app.NameKeeper = namekeeper.NewKeeper(
Expand Down Expand Up @@ -660,6 +671,7 @@ func New(
app.Ics20WasmHooks.ContractKeeper = app.WasmKeeper // app.ContractKeeper -- this changes in the next version of wasm to a permissioned keeper
app.IBCHooksKeeper.ContractKeeper = app.ContractKeeper
app.Ics20MarkerHooks.MarkerKeeper = &app.MarkerKeeper
app.RateLimitingKeeper.PermissionedKeeper = app.ContractKeeper

app.IbcHooks.SendPacketPreProcessors = []ibchookstypes.PreSendPacketDataProcessingFn{app.Ics20MarkerHooks.SetupMarkerMemoFn, app.Ics20WasmHooks.GetWasmSendPacketPreProcessor}

Expand Down Expand Up @@ -766,6 +778,7 @@ func New(

// IBC
ibc.NewAppModule(app.IBCKeeper),
ibcratelimitmodule.NewAppModule(appCodec, *app.RateLimitingKeeper, app.AccountKeeper, app.BankKeeper),
ibchooks.NewAppModule(app.AccountKeeper, *app.IBCHooksKeeper),
ibctransfer.NewAppModule(*app.TransferKeeper),
icqModule,
Expand Down Expand Up @@ -805,6 +818,7 @@ func New(
metadatatypes.ModuleName,
oracletypes.ModuleName,
wasm.ModuleName,
ibcratelimit.ModuleName,
ibchookstypes.ModuleName,
ibctransfertypes.ModuleName,
icqtypes.ModuleName,
Expand Down Expand Up @@ -835,6 +849,7 @@ func New(
nametypes.ModuleName,
genutiltypes.ModuleName,
ibchost.ModuleName,
ibcratelimit.ModuleName,
ibchookstypes.ModuleName,
ibctransfertypes.ModuleName,
icqtypes.ModuleName,
Expand Down Expand Up @@ -891,6 +906,7 @@ func New(
ibctransfertypes.ModuleName,
icqtypes.ModuleName,
icatypes.ModuleName,
ibcratelimit.ModuleName,
ibchookstypes.ModuleName,
// wasm after ibc transfer
wasm.ModuleName,
Expand Down Expand Up @@ -928,6 +944,7 @@ func New(
hold.ModuleName,
exchange.ModuleName,

ibcratelimit.ModuleName,
ibchookstypes.ModuleName,
icatypes.ModuleName,
icqtypes.ModuleName,
Expand Down Expand Up @@ -982,6 +999,7 @@ func New(

// IBC
ibc.NewAppModule(app.IBCKeeper),
ibcratelimitmodule.NewAppModule(appCodec, *app.RateLimitingKeeper, app.AccountKeeper, app.BankKeeper),
ibchooks.NewAppModule(app.AccountKeeper, *app.IBCHooksKeeper),
ibctransfer.NewAppModule(*app.TransferKeeper),
icaModule,
Expand Down
2 changes: 2 additions & 0 deletions app/params/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ const (
// Oracle
DefaultWeightUpdateOracle int = 25
DefaultWeightSendOracleQuery int = 75
// Rate Limiter
DefaultWeightGovUpdateParams int = 100
)
3 changes: 3 additions & 0 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/provenance-io/provenance/x/exchange"
"github.com/provenance-io/provenance/x/hold"
ibchookstypes "github.com/provenance-io/provenance/x/ibchooks/types"
ibcratelimit "github.com/provenance-io/provenance/x/ibcratelimit"
markertypes "github.com/provenance-io/provenance/x/marker/types"
msgfeetypes "github.com/provenance-io/provenance/x/msgfees/types"
oracletypes "github.com/provenance-io/provenance/x/oracle/types"
Expand Down Expand Up @@ -174,6 +175,7 @@ var upgrades = map[string]appUpgrade{
Added: []string{icqtypes.ModuleName, oracletypes.ModuleName, ibchookstypes.StoreKey, hold.ModuleName, exchange.ModuleName},
},
"tourmaline-rc1": { // upgrade for v1.18.0-rc1
Added: []string{ibcratelimit.ModuleName},
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error
vm, err = runModuleMigrations(ctx, app, vm)
Expand All @@ -185,6 +187,7 @@ var upgrades = map[string]appUpgrade{
},
},
"tourmaline": { // upgrade for v1.18.0
Added: []string{ibcratelimit.ModuleName},
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error
vm, err = runModuleMigrations(ctx, app, vm)
Expand Down
Loading
Loading