Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into chore/better_dex_tx_a…
Browse files Browse the repository at this point in the history
…ttrs
  • Loading branch information
jcompagni10 committed Sep 24, 2024
2 parents 078ef5f + 0ff43e4 commit c92445f
Show file tree
Hide file tree
Showing 37 changed files with 7,913 additions and 3,355 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ test: test-unit
test-all: check test-race test-cover

test-unit:
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock' `go list ./... | grep -v dex`
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock' ./...

test-race:
@VERSION=$(VERSION) go test -mod=readonly -race -tags='ledger test_ledger_mock' ./...
Expand Down
4 changes: 3 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
servicemetrics "github.com/skip-mev/slinky/service/metrics"

v401 "github.com/neutron-org/neutron/v4/app/upgrades/v4.0.1"
v500 "github.com/neutron-org/neutron/v4/app/upgrades/v5.0.0"
"github.com/neutron-org/neutron/v4/x/globalfee"
globalfeetypes "github.com/neutron-org/neutron/v4/x/globalfee/types"

Expand Down Expand Up @@ -221,7 +222,7 @@ const (
)

var (
Upgrades = []upgrades.Upgrade{v401.Upgrade}
Upgrades = []upgrades.Upgrade{v401.Upgrade, v500.Upgrade}

// DefaultNodeHome default home directories for the application daemon
DefaultNodeHome string
Expand Down Expand Up @@ -1396,6 +1397,7 @@ func (app *App) setupUpgradeHandlers() {
MarketmapKeeper: app.MarketMapKeeper,
FeeMarketKeeper: app.FeeMarkerKeeper,
DynamicfeesKeeper: app.DynamicFeesKeeper,
DexKeeper: &app.DexKeeper,
GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName),
CcvConsumerSubspace: app.GetSubspace(ccvconsumertypes.ModuleName),
},
Expand Down
2 changes: 2 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

contractmanagerkeeper "github.com/neutron-org/neutron/v4/x/contractmanager/keeper"
cronkeeper "github.com/neutron-org/neutron/v4/x/cron/keeper"
dexkeeper "github.com/neutron-org/neutron/v4/x/dex/keeper"

Check failure on line 24 in app/upgrades/types.go

View workflow job for this annotation

GitHub Actions / lint

could not import github.com/neutron-org/neutron/v4/x/dex/keeper (-: # github.com/neutron-org/neutron/v4/x/dex/keeper
feeburnerkeeper "github.com/neutron-org/neutron/v4/x/feeburner/keeper"
icqkeeper "github.com/neutron-org/neutron/v4/x/interchainqueries/keeper"
tokenfactorykeeper "github.com/neutron-org/neutron/v4/x/tokenfactory/keeper"
Expand Down Expand Up @@ -64,6 +65,7 @@ type UpgradeKeepers struct {
MarketmapKeeper *marketmapkeeper.Keeper
FeeMarketKeeper *feemarketkeeper.Keeper
DynamicfeesKeeper *dynamicfeeskeeper.Keeper
DexKeeper *dexkeeper.Keeper
// subspaces
GlobalFeeSubspace paramtypes.Subspace
CcvConsumerSubspace paramtypes.Subspace
Expand Down
20 changes: 20 additions & 0 deletions app/upgrades/v5.0.0/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package v400

import (
storetypes "cosmossdk.io/store/types"

"github.com/neutron-org/neutron/v4/app/upgrades"
)

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

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
StoreUpgrades: storetypes.StoreUpgrades{
Added: []string{},
},
}
60 changes: 60 additions & 0 deletions app/upgrades/v5.0.0/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package v400

import (
"context"
"fmt"

upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"

"github.com/neutron-org/neutron/v4/app/upgrades"
dexkeeper "github.com/neutron-org/neutron/v4/x/dex/keeper"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
keepers *upgrades.UpgradeKeepers,
_ upgrades.StoreKeys,
_ codec.Codec,
) upgradetypes.UpgradeHandler {
return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)

ctx.Logger().Info("Starting module migrations...")
vm, err := mm.RunMigrations(ctx, configurator, vm)
if err != nil {
return vm, err
}

ctx.Logger().Info("Running dex upgrades...")
// Only pause dex for mainnet
if ctx.ChainID() == "neutron-1" {
err = upgradeDexPause(ctx, *keepers.DexKeeper)
if err != nil {
return nil, err
}
}

ctx.Logger().Info(fmt.Sprintf("Migration {%s} applied", UpgradeName))
return vm, nil
}
}

func upgradeDexPause(ctx sdk.Context, k dexkeeper.Keeper) error {
// Set the dex to paused
ctx.Logger().Info("Pausing dex...")

params := k.GetParams(ctx)
params.Paused = true

if err := k.SetParams(ctx, params); err != nil {
return err
}

ctx.Logger().Info("Dex is paused")

return nil
}
65 changes: 65 additions & 0 deletions app/upgrades/v5.0.0/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package v400_test

import (
"testing"

"cosmossdk.io/math"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/stretchr/testify/suite"

v500 "github.com/neutron-org/neutron/v4/app/upgrades/v5.0.0"
"github.com/neutron-org/neutron/v4/testutil/common/sample"

"github.com/neutron-org/neutron/v4/testutil"
dexkeeper "github.com/neutron-org/neutron/v4/x/dex/keeper"
dextypes "github.com/neutron-org/neutron/v4/x/dex/types"
)

type UpgradeTestSuite struct {
testutil.IBCConnectionTestSuite
}

func TestKeeperTestSuite(t *testing.T) {
suite.Run(t, new(UpgradeTestSuite))
}

func (suite *UpgradeTestSuite) SetupTest() {
suite.IBCConnectionTestSuite.SetupTest()
}

func (suite *UpgradeTestSuite) TestUpgradeDexPause() {
var (
app = suite.GetNeutronZoneApp(suite.ChainA)
ctx = suite.ChainA.GetContext().WithChainID("neutron-1")
msgServer = dexkeeper.NewMsgServerImpl(app.DexKeeper)
)

params := app.DexKeeper.GetParams(ctx)

suite.False(params.Paused)

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

params = app.DexKeeper.GetParams(ctx)

suite.True(params.Paused)

_, err := msgServer.Deposit(ctx, &dextypes.MsgDeposit{
Creator: sample.AccAddress(),
Receiver: sample.AccAddress(),
TokenA: "TokenA",
TokenB: "TokenB",
TickIndexesAToB: []int64{1},
Fees: []uint64{1},
AmountsA: []math.Int{math.OneInt()},
AmountsB: []math.Int{math.ZeroInt()},
Options: []*dextypes.DepositOptions{{}},
})

suite.ErrorIs(err, dextypes.ErrDexPaused)
}
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
cosmossdk.io/x/tx v0.13.5
cosmossdk.io/x/upgrade v0.1.4
github.com/CosmWasm/wasmd v0.51.0
github.com/CosmWasm/wasmvm/v2 v2.1.2
github.com/CosmWasm/wasmvm/v2 v2.1.3
github.com/cometbft/cometbft v0.38.11
github.com/cosmos/admin-module/v2 v2.0.0-20240430142959-8b3328d1b1a2
github.com/cosmos/cosmos-db v1.0.2
Expand Down Expand Up @@ -46,7 +46,7 @@ require (
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142
google.golang.org/grpc v1.66.2
google.golang.org/grpc v1.67.0
google.golang.org/protobuf v1.34.2
gopkg.in/yaml.v2 v2.4.0
)
Expand All @@ -55,7 +55,7 @@ require (
cloud.google.com/go v0.115.0 // indirect
cloud.google.com/go/auth v0.6.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/compute/metadata v0.5.0 // indirect
cloud.google.com/go/iam v1.1.9 // indirect
cloud.google.com/go/storage v1.41.0 // indirect
cosmossdk.io/api v0.7.5 // indirect
Expand Down Expand Up @@ -112,7 +112,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/googleapis v1.4.1 // indirect
github.com/golang/glog v1.2.1 // indirect
github.com/golang/glog v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb // indirect
github.com/google/btree v1.1.2 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz
cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU=
cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U=
cloud.google.com/go/compute v1.10.0/go.mod h1:ER5CLbMxl90o2jtNbGSbtfOpQKR0t15FOtRsugnLrlU=
cloud.google.com/go/compute/metadata v0.3.0 h1:Tz+eQXMEqDIKRsmY3cHTL6FVaynIjX2QxYC4trgAKZc=
cloud.google.com/go/compute/metadata v0.3.0/go.mod h1:zFmK7XCadkQkj6TtorcaGlCW1hT1fIilQDwofLpJ20k=
cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY=
cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY=
cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I=
cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4=
cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0=
Expand Down Expand Up @@ -225,8 +225,8 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/CosmWasm/wasmvm/v2 v2.1.2 h1:GkJ5bAsRlLHfIQVg/FY1VHwLyBwlCjAhDea0B8L+e20=
github.com/CosmWasm/wasmvm/v2 v2.1.2/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg=
github.com/CosmWasm/wasmvm/v2 v2.1.3 h1:CSJTauZqkHyb9yic6JVYCjiGUgxI2MJV2QzfSu8m49c=
github.com/CosmWasm/wasmvm/v2 v2.1.3/go.mod h1:bMhLQL4Yp9CzJi9A83aR7VO9wockOsSlZbT4ztOl6bg=
github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
Expand Down Expand Up @@ -520,8 +520,8 @@ github.com/gogo/googleapis v1.4.1-0.20201022092350-68b0159b7869/go.mod h1:5YRNX2
github.com/gogo/googleapis v1.4.1 h1:1Yx4Myt7BxzvUr5ldGSbwYiZG6t9wGBZ+8/fX3Wvtq0=
github.com/gogo/googleapis v1.4.1/go.mod h1:2lpHqI5OcWCtVElxXnPt+s8oJvMpySlOyM6xDCrzib4=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v1.2.1 h1:OptwRhECazUx5ix5TTWC3EZhsZEHWcYWY4FQHTIubm4=
github.com/golang/glog v1.2.1/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY=
github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w=
github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -1676,8 +1676,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu
google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo=
google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y=
google.golang.org/grpc v1.67.0 h1:IdH9y6PF5MPSdAntIcpjQ+tXO41pcQsfZV2RxtQgVcw=
google.golang.org/grpc v1.67.0/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
Expand Down
Loading

0 comments on commit c92445f

Please sign in to comment.