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

Sommelier v8 Upgrade #318

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 19 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ import (
icaexported "github.com/cosmos/ibc-go/v7/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper"
"github.com/gorilla/mux"
"github.com/peggyjv/gravity-bridge/module/v4/x/gravity"
gravityclient "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/client"
gravitykeeper "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/keeper"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
"github.com/peggyjv/gravity-bridge/module/v5/x/gravity"
gravityclient "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/client"
gravitykeeper "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/keeper"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
appParams "github.com/peggyjv/sommelier/v7/app/params"
v8 "github.com/peggyjv/sommelier/v7/app/upgrades/v8"
"github.com/peggyjv/sommelier/v7/x/addresses"
addresseskeeper "github.com/peggyjv/sommelier/v7/x/addresses/keeper"
addressestypes "github.com/peggyjv/sommelier/v7/x/addresses/types"
Expand Down Expand Up @@ -1025,13 +1026,25 @@ func (app *SommelierApp) setupUpgradeStoreLoaders() {

var storeUpgrades *storetypes.StoreUpgrades = nil

// TODO: Add v8 store loader when writing upgrade handler
if upgradeInfo.Name == v8.UpgradeName {
// Is this correct?
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{addressestypes.ModuleName},
}
}

if storeUpgrades != nil {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, storeUpgrades))
}
}

func (app *SommelierApp) setupUpgradeHandlers() {
// TODO: Add v8 upgrade handler
// TODO: Add v8 upgrade handle
app.UpgradeKeeper.SetUpgradeHandler(
v8.UpgradeName,
v8.CreateUpgradeHandler(
app.mm,
app.configurator,
),
)
}
2 changes: 1 addition & 1 deletion app/upgrades/v4/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
cellarfeestypes "github.com/peggyjv/sommelier/v7/x/cellarfees/types"
corktypes "github.com/peggyjv/sommelier/v7/x/cork/types"
)
Expand Down
10 changes: 10 additions & 0 deletions app/upgrades/v8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# v8 upgrade

This upgrade moves Sommelier to major version 8.

## Summary of changes

* Add the addresses module for mapping cosmos/evm addresses
* Update the cellarfees module to start fee auctions based on the accrued USD value of a particular denom
* Update the auction module to allow a portion of SOMM proceeds earned by auctions to be burned
* Upgrade the gravity module to v5
5 changes: 5 additions & 0 deletions app/upgrades/v8/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package v8

const (
UpgradeName = "v8"
)
18 changes: 18 additions & 0 deletions app/upgrades/v8/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v8

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("v8 upgrade: entering handler and running migrations")

return mm.RunMigrations(ctx, configurator, vm)
}
}
2 changes: 1 addition & 1 deletion cmd/sommelier/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/spf13/cast"
"github.com/spf13/cobra"

bridgecmd "github.com/peggyjv/gravity-bridge/module/v4/cmd/gravity/cmd"
bridgecmd "github.com/peggyjv/gravity-bridge/module/v5/cmd/gravity/cmd"
"github.com/peggyjv/sommelier/v7/app"
"github.com/peggyjv/sommelier/v7/app/params"
)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ require (
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
github.com/ory/dockertest/v3 v3.10.0
github.com/peggyjv/gravity-bridge/module/v4 v4.0.2-0.20240507144821-c36490e18116
github.com/peggyjv/gravity-bridge/module/v5 v5.0.0-20241009165118-198cad613f2f
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
github.com/spf13/cast v1.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1412,8 +1412,8 @@ github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0Mw
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/paulbellamy/ratecounter v0.2.0/go.mod h1:Hfx1hDpSGoqxkVVpBi/IlYD7kChlfo5C6hzIHwPqfFE=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
github.com/peggyjv/gravity-bridge/module/v4 v4.0.2-0.20240507144821-c36490e18116 h1:WmtdxpmEWGv4hWpTZfFAR8SIFeoBlOjvkN4pixwYMZk=
github.com/peggyjv/gravity-bridge/module/v4 v4.0.2-0.20240507144821-c36490e18116/go.mod h1:tlA4IAHXoDRK8zgQ2PP111hBkHOZLcH6tgz2Kh/EBoI=
github.com/peggyjv/gravity-bridge/module/v5 v5.0.0-20241009165118-198cad613f2f h1:UAzrovsM6zdTIPsAfMjLjyzOXUJdMrBTJThSL0mO5TA=
github.com/peggyjv/gravity-bridge/module/v5 v5.0.0-20241009165118-198cad613f2f/go.mod h1:/vcYmGnfzHn2d7Ptxq1PLLC3gpuMJz46r2tZXFSCC6k=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
ibctransfer "github.com/cosmos/ibc-go/v7/modules/apps/transfer"
ibc "github.com/cosmos/ibc-go/v7/modules/core"
gravityclient "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/client"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravityclient "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/client"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
"github.com/peggyjv/sommelier/v7/app"
"github.com/peggyjv/sommelier/v7/app/params"
)
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/ethereum.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
ethereumtypes "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethclient"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
)

type EthereumConfig struct {
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/scheduled_cork_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
gbtypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gbtypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
types "github.com/peggyjv/sommelier/v7/x/cork/types/v2"
pubsubtypes "github.com/peggyjv/sommelier/v7/x/pubsub/types"
)
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
"github.com/peggyjv/sommelier/v7/app/params"
addressestypes "github.com/peggyjv/sommelier/v7/x/addresses/types"
auctiontypes "github.com/peggyjv/sommelier/v7/x/auction/types"
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/ethereum/go-ethereum/crypto"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v4/x/gravity/types"
gravitytypes "github.com/peggyjv/gravity-bridge/module/v5/x/gravity/types"
"github.com/peggyjv/sommelier/v7/app"
)

Expand Down
21 changes: 21 additions & 0 deletions x/auction/keeper/migrations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
v1 "github.com/peggyjv/sommelier/v7/x/auction/migrations/v1"
)

// Migrator is a struct for handling in-place store migrations.
type Migrator struct {
keeper Keeper
}

// NewMigrator returns a new Migrator.
func NewMigrator(keeper Keeper) Migrator {
return Migrator{keeper: keeper}
}

// Migrate1to2 migrates from consensus version 1 to 2.
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
return v1.MigrateParamStore(ctx, m.keeper.paramSpace)
}
18 changes: 18 additions & 0 deletions x/auction/migrations/v1/store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package v1

import (
sdk "github.com/cosmos/cosmos-sdk/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/peggyjv/sommelier/v7/x/auction/types"
)

func MigrateParamStore(ctx sdk.Context, subspace paramstypes.Subspace) error {
ctx.Logger().Info("auction v1 to v2: Migrating params")

if !subspace.Has(ctx, types.KeyAuctionBurnRate) {
subspace.Set(ctx, types.KeyAuctionBurnRate, types.DefaultParams().AuctionBurnRate)
}

ctx.Logger().Info("auction v1 to v2: Params migration complete")
return nil
}
Loading
Loading