Skip to content

Commit

Permalink
rl address for testnet
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0n00gler committed Oct 14, 2024
1 parent e3ce643 commit b001948
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 21 deletions.
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"

"github.com/neutron-org/neutron/v5/x/dynamicfees"
"github.com/neutron-org/neutron/v5/x/ibc-rate-limit"
ibcratelimit "github.com/neutron-org/neutron/v5/x/ibc-rate-limit"

"cosmossdk.io/client/v2/autocli"
"cosmossdk.io/core/appmodule"
Expand Down Expand Up @@ -135,6 +135,7 @@ import (

ibcratelimitkeeper "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/keeper"
ibcratelimittypes "github.com/neutron-org/neutron/v5/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
3 changes: 2 additions & 1 deletion app/proposals_allowlisting.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ 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"

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

dynamicfeestypes "github.com/neutron-org/neutron/v5/x/dynamicfees/types"
globalfeetypes "github.com/neutron-org/neutron/v5/x/globalfee/types"

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,13 @@ 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"
ibcratelimitkeeper "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/keeper"

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

contractmanagerkeeper "github.com/neutron-org/neutron/v5/x/contractmanager/keeper"
Expand Down
8 changes: 6 additions & 2 deletions app/upgrades/v5.0.0/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ const (
UpgradeName = "v5.0.0"

MarketMapAuthorityMultisig = "neutron1anjpluecd0tdc0n8xzc3l5hua4h93wyq0x7v56"
// RateLimitContract defines the RL contract addr which we set as a contract address in ibc-rate-limit middleware
// MainnetRateLimitContract 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"
MainnetRateLimitContract = "neutron15aqgplxcavqhurr0g5wwtdw6025dknkqwkfh0n46gp2qjl6236cs2yd3nl"

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

var Upgrade = upgrades.Upgrade{
Expand Down
23 changes: 15 additions & 8 deletions app/upgrades/v5.0.0/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ func CreateUpgradeHandler(
}

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
}

err = upgradeIbcRateLimitSetContract(ctx, *keepers.IbcRateLimitKeeper)
if err != nil {
return nil, err
}

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))
Expand Down Expand Up @@ -83,8 +81,17 @@ func upgradeIbcRateLimitSetContract(ctx sdk.Context, k ibcratelimitkeeper.Keeper
// 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
switch ctx.ChainID() {
case "neutron-1":
if err := k.SetParams(ctx, ibcratelimittypes.Params{ContractAddress: MainnetRateLimitContract}); err != nil {
return err
}
case "pion-1":
if err := k.SetParams(ctx, ibcratelimittypes.Params{ContractAddress: TestnetRateLimitContract}); err != nil {
return err
}
default:
return fmt.Errorf("unknown chain id %s", ctx.ChainID())
}

ctx.Logger().Info("Rate limit contract is set")
Expand Down
47 changes: 44 additions & 3 deletions app/upgrades/v5.0.0/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v500_test

import (
"fmt"
"testing"

"cosmossdk.io/math"
Expand Down Expand Up @@ -30,7 +31,7 @@ func (suite *UpgradeTestSuite) SetupTest() {

func (suite *UpgradeTestSuite) TestOracleUpgrade() {
app := suite.GetNeutronZoneApp(suite.ChainA)
ctx := suite.ChainA.GetContext()
ctx := suite.ChainA.GetContext().WithChainID("neutron-1")
t := suite.T()

upgrade := upgradetypes.Plan{
Expand Down Expand Up @@ -84,7 +85,7 @@ func (suite *UpgradeTestSuite) TestUpgradeDexPause() {
suite.ErrorIs(err, dextypes.ErrDexPaused)
}

func (suite *UpgradeTestSuite) TestUpgradeSetRateLimitContract() {
func (suite *UpgradeTestSuite) TestUpgradeSetRateLimitContractMainnet() {
var (
app = suite.GetNeutronZoneApp(suite.ChainA)
ctx = suite.ChainA.GetContext().WithChainID("neutron-1")
Expand All @@ -103,5 +104,45 @@ func (suite *UpgradeTestSuite) TestUpgradeSetRateLimitContract() {

params = app.RateLimitingICS4Wrapper.IbcratelimitKeeper.GetParams(ctx)

suite.Equal(params.ContractAddress, v500.RateLimitContract)
suite.Equal(params.ContractAddress, v500.MainnetRateLimitContract)
}

func (suite *UpgradeTestSuite) TestUpgradeSetRateLimitContractTestnet() {
var (
app = suite.GetNeutronZoneApp(suite.ChainA)
ctx = suite.ChainA.GetContext().WithChainID("pion-1")
)

params := app.RateLimitingICS4Wrapper.IbcratelimitKeeper.GetParams(ctx)

suite.Equal(params.ContractAddress, "")

upgrade := upgradetypes.Plan{
Name: v500.UpgradeName,
Info: "some text here",
Height: 100,
}
suite.NoError(app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade))

params = app.RateLimitingICS4Wrapper.IbcratelimitKeeper.GetParams(ctx)

suite.Equal(params.ContractAddress, v500.TestnetRateLimitContract)
}

func (suite *UpgradeTestSuite) TestUpgradeSetRateLimitContractUnknownChain() {
var (
app = suite.GetNeutronZoneApp(suite.ChainA)
ctx = suite.ChainA.GetContext().WithChainID("unknown-chain")
)

params := app.RateLimitingICS4Wrapper.IbcratelimitKeeper.GetParams(ctx)

suite.Equal(params.ContractAddress, "")

upgrade := upgradetypes.Plan{
Name: v500.UpgradeName,
Info: "some text here",
Height: 100,
}
suite.EqualError(app.UpgradeKeeper.ApplyUpgrade(ctx, upgrade), fmt.Sprintf("unknown chain id %s", ctx.ChainID()))
}
3 changes: 2 additions & 1 deletion x/ibc-rate-limit/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types"
"github.com/spf13/cobra"

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

// GetQueryCmd returns the cli query commands for this module
Expand Down
3 changes: 2 additions & 1 deletion x/ibc-rate-limit/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"testing"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types"
"github.com/stretchr/testify/suite"

"github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types"

"github.com/neutron-org/neutron/v5/testutil/apptesting"
)

Expand Down
3 changes: 2 additions & 1 deletion x/ibc-rate-limit/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
sdkmath "cosmossdk.io/math"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types"
"github.com/neutron-org/neutron/v5/testutil"
"github.com/stretchr/testify/require"
"golang.org/x/exp/slices"

"github.com/neutron-org/neutron/v5/testutil"

bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"

abci "github.com/cometbft/cometbft/abci/types"
Expand Down
3 changes: 2 additions & 1 deletion x/ibc-rate-limit/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"fmt"

"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/neutron-org/neutron/v5/x/ibc-rate-limit/keeper"
"github.com/spf13/cobra"

"github.com/neutron-org/neutron/v5/x/ibc-rate-limit/keeper"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand Down
1 change: 1 addition & 0 deletions x/ibc-rate-limit/module_simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"

"github.com/neutron-org/neutron/v5/testutil/common/sample"
ibcratelimitsimulation "github.com/neutron-org/neutron/v5/x/ibc-rate-limit/simulation"
"github.com/neutron-org/neutron/v5/x/ibc-rate-limit/types"
Expand Down

0 comments on commit b001948

Please sign in to comment.