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 95 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
222 changes: 138 additions & 84 deletions app/app.go

Large diffs are not rendered by default.

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/v5/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
5 changes: 3 additions & 2 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import (
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
capabilitykeeper "github.com/cosmos/ibc-go/modules/capability/keeper"
ccvconsumerkeeper "github.com/cosmos/interchain-security/v5/x/ccv/consumer/keeper"
dexkeeper "github.com/neutron-org/neutron/v5/x/dex/keeper"
ibcratelimitkeeper "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/keeper"
auctionkeeper "github.com/skip-mev/block-sdk/v2/x/auction/keeper"
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
marketmapkeeper "github.com/skip-mev/slinky/x/marketmap/keeper"

dexkeeper "github.com/neutron-org/neutron/v5/x/dex/keeper"

dynamicfeeskeeper "github.com/neutron-org/neutron/v5/x/dynamicfees/keeper"

contractmanagerkeeper "github.com/neutron-org/neutron/v5/x/contractmanager/keeper"
Expand Down Expand Up @@ -67,6 +67,7 @@ type UpgradeKeepers struct {
FeeMarketKeeper *feemarketkeeper.Keeper
DynamicfeesKeeper *dynamicfeeskeeper.Keeper
DexKeeper *dexkeeper.Keeper
IbcRateLimitKeeper *ibcratelimitkeeper.Keeper
// subspaces
GlobalFeeSubspace paramtypes.Subspace
CcvConsumerSubspace paramtypes.Subspace
Expand Down
6 changes: 5 additions & 1 deletion app/upgrades/v5.0.0/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ import (
storetypes "cosmossdk.io/store/types"

"github.com/neutron-org/neutron/v5/app/upgrades"
ibcratelimittypes "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types"
)

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v5.0.0"

MarketMapAuthorityMultisig = "neutron1anjpluecd0tdc0n8xzc3l5hua4h93wyq0x7v56"
// RateLimitContract defines the RL contract addr which we set as a contract address in ibc-rate-limit middleware
// https://neutron.celat.one/neutron-1/contracts/neutron15aqgplxcavqhurr0g5wwtdw6025dknkqwkfh0n46gp2qjl6236cs2yd3nl
RateLimitContract = "neutron15aqgplxcavqhurr0g5wwtdw6025dknkqwkfh0n46gp2qjl6236cs2yd3nl"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{
Added: []string{},
Added: []string{ibcratelimittypes.ModuleName},
},
}
24 changes: 24 additions & 0 deletions app/upgrades/v5.0.0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (

"github.com/neutron-org/neutron/v5/app/upgrades"
dexkeeper "github.com/neutron-org/neutron/v5/x/dex/keeper"
ibcratelimitkeeper "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/keeper"
ibcratelimittypes "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types"
)

func CreateUpgradeHandler(
Expand Down Expand Up @@ -47,6 +49,15 @@ func CreateUpgradeHandler(
return nil, err
}

ctx.Logger().Info("Running ibc-rate-limit upgrades...")
// Only set rate limit contract for mainnet
if ctx.ChainID() == "neutron-1" {
err = upgradeIbcRateLimitSetContract(ctx, *keepers.IbcRateLimitKeeper)
if err != nil {
return nil, err
}
}

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))
return vm, nil
}
Expand All @@ -68,6 +79,19 @@ func upgradeDexPause(ctx sdk.Context, k dexkeeper.Keeper) error {
return nil
}

func upgradeIbcRateLimitSetContract(ctx sdk.Context, k ibcratelimitkeeper.Keeper) error {
// Set the dex to paused
ctx.Logger().Info("Setting ibc rate limiting contract...")

if err := k.SetParams(ctx, ibcratelimittypes.Params{ContractAddress: RateLimitContract}); err != nil {
return err
}

ctx.Logger().Info("Rate limit contract is set")

return nil
}

func setMarketMapParams(ctx sdk.Context, marketmapKeeper *marketmapkeeper.Keeper) error {
marketmapParams := marketmaptypes.Params{
MarketAuthorities: []string{authtypes.NewModuleAddress(adminmoduletypes.ModuleName).String(), MarketMapAuthorityMultisig},
Expand Down
15 changes: 15 additions & 0 deletions proto/neutron/ibcratelimit/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
syntax = "proto3";
package neutron.ibcratelimit.v1beta1;

import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "neutron/ibcratelimit/v1beta1/params.proto";

option go_package = "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types";

// GenesisState defines the ibc-rate-limit module's genesis state.
message GenesisState {
// params are all the parameters of the module
Params params = 1 [(gogoproto.nullable) = false];
}
14 changes: 14 additions & 0 deletions proto/neutron/ibcratelimit/v1beta1/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
syntax = "proto3";
package neutron.ibcratelimit.v1beta1;

import "gogoproto/gogo.proto";

option go_package = "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types";

// Params defines the parameters for the ibc-rate-limit module.
message Params {
string contract_address = 1 [
(gogoproto.moretags) = "yaml:\"contract_address\"",
(gogoproto.nullable) = true
];
}
27 changes: 27 additions & 0 deletions proto/neutron/ibcratelimit/v1beta1/query.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
syntax = "proto3";
package neutron.ibcratelimit.v1beta1;

import "cosmos/base/query/v1beta1/pagination.proto";
import "gogoproto/gogo.proto";
import "google/api/annotations.proto";
import "neutron/ibcratelimit/v1beta1/params.proto";

option go_package = "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types";

// Query defines the gRPC querier service.
service Query {
// Params defines a gRPC query method that returns the ibc-rate-limit module's
// parameters.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/neutron/ibc-rate-limit/v1beta1/params";
}
}

// ParamsRequest is the request type for the Query/Params RPC method.
message QueryParamsRequest {}

// aramsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
// params defines the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
}
43 changes: 43 additions & 0 deletions proto/neutron/ibcratelimit/v1beta1/tx.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
syntax = "proto3";
package neutron.ibcratelimit.v1beta1;

import "amino/amino.proto";
import "cosmos/bank/v1beta1/bank.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "neutron/ibcratelimit/v1beta1/params.proto";

option go_package = "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types";

// Msg defines the tokefactory module's gRPC message service.
service Msg {
option (cosmos.msg.v1.service) = true;
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

// MsgUpdateParams is the MsgUpdateParams request type.
//
// Since: 0.47
message MsgUpdateParams {
option (amino.name) = "neutron/ibc-rate-limit/MsgUpdateParams";
option (cosmos.msg.v1.signer) = "authority";

// Authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// params defines the x/tokenfactory parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
}

// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: 0.47
message MsgUpdateParamsResponse {}
Loading
Loading