Skip to content

Commit

Permalink
Merge branch 'main' into kirill/1171-add-gauge-fee
Browse files Browse the repository at this point in the history
  • Loading branch information
keruch committed Sep 12, 2024
2 parents c28e8f1 + e670723 commit 9c43bec
Show file tree
Hide file tree
Showing 92 changed files with 8,853 additions and 1,725 deletions.
2 changes: 2 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ func (a *AppKeepers) InitKeepers(
)

a.StreamerKeeper = *streamermodulekeeper.NewKeeper(
appCodec,
a.keys[streamermoduletypes.StoreKey],
a.GetSubspace(streamermoduletypes.ModuleName),
a.BankKeeper,
Expand Down Expand Up @@ -568,6 +569,7 @@ func (a *AppKeepers) SetupHooks() {
a.TxFeesKeeper.Hooks(),
a.DelayedAckKeeper.GetEpochHooks(),
a.DymNSKeeper.GetEpochHooks(),
a.RollappKeeper.GetEpochHooks(),
),
)

Expand Down
2 changes: 1 addition & 1 deletion app/keepers/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,12 +361,12 @@ var InitGenesis = []string{
rollappmoduletypes.ModuleName,
sequencertypes.ModuleName,
sponsorshiptypes.ModuleName,
streamermoduletypes.ModuleName,
denommetadatamoduletypes.ModuleName, // must after `x/bank` to trigger hooks
delayedacktypes.ModuleName,
eibcmoduletypes.ModuleName,
dymnstypes.ModuleName,
epochstypes.ModuleName,
streamermoduletypes.ModuleName, // must be after x/epochs to fill epoch pointers
lockuptypes.ModuleName,
gammtypes.ModuleName,
poolmanagertypes.ModuleName,
Expand Down
17 changes: 17 additions & 0 deletions app/upgrades/v4/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package v4
import (
"github.com/cometbft/cometbft/crypto"
"github.com/cosmos/cosmos-sdk/baseapp"
epochskeeper "github.com/osmosis-labs/osmosis/v15/x/epochs/keeper"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
Expand Down Expand Up @@ -35,6 +36,8 @@ import (
rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
sequencerkeeper "github.com/dymensionxyz/dymension/v3/x/sequencer/keeper"
sequencertypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types"
streamerkeeper "github.com/dymensionxyz/dymension/v3/x/streamer/keeper"
streamertypes "github.com/dymensionxyz/dymension/v3/x/streamer/types"
)

// CreateUpgradeHandler creates an SDK upgrade handler for v4
Expand All @@ -58,6 +61,9 @@ func CreateUpgradeHandler(

migrateSequencers(ctx, keepers.SequencerKeeper)
migrateRollappLightClients(ctx, keepers.RollappKeeper, keepers.LightClientKeeper, keepers.IBCKeeper.ChannelKeeper)
if err := migrateStreamer(ctx, keepers.StreamerKeeper, keepers.EpochsKeeper); err != nil {
return nil, err
}
migrateIncentivesParams(ctx, keepers.IncentivesKeeper)

// TODO: create rollapp gauges for each existing rollapp (https://github.com/dymensionxyz/dymension/issues/1005)
Expand Down Expand Up @@ -176,6 +182,17 @@ func migrateRollappLightClients(ctx sdk.Context, rollappkeeper *rollappkeeper.Ke
}
}

// migrateStreamer creates epoch pointers for all epoch infos.
func migrateStreamer(ctx sdk.Context, sk streamerkeeper.Keeper, ek *epochskeeper.Keeper) error {
for _, epoch := range ek.AllEpochInfos(ctx) {
err := sk.SaveEpochPointer(ctx, streamertypes.NewEpochPointer(epoch.Identifier, epoch.Duration))
if err != nil {
return err
}
}
return nil
}

func migrateIncentivesParams(ctx sdk.Context, ik *incentiveskeeper.Keeper) {
params := ik.GetParams(ctx)
defaultParams := incentivestypes.DefaultParams()
Expand Down
18 changes: 18 additions & 0 deletions app/upgrades/v4/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/dymensionxyz/dymension/v3/testutil/sample"
rollapptypes "github.com/dymensionxyz/dymension/v3/x/rollapp/types"
sequencertypes "github.com/dymensionxyz/dymension/v3/x/sequencer/types"
streamertypes "github.com/dymensionxyz/dymension/v3/x/streamer/types"
)

// UpgradeTestSuite defines the structure for the upgrade test suite
Expand Down Expand Up @@ -120,6 +121,8 @@ func (s *UpgradeTestSuite) TestUpgrade() {
return
}

s.validateStreamerMigration()

// TODO: check for rollapp gauges creation

return
Expand Down Expand Up @@ -228,6 +231,21 @@ func (s *UpgradeTestSuite) validateSequencersMigration(numSeq int) error {
return nil
}

func (s *UpgradeTestSuite) validateStreamerMigration() {
epochInfos := s.App.EpochsKeeper.AllEpochInfos(s.Ctx)

pointers, err := s.App.StreamerKeeper.GetAllEpochPointers(s.Ctx)
s.Require().NoError(err)

var expected []streamertypes.EpochPointer
for _, info := range epochInfos {
expected = append(expected, streamertypes.NewEpochPointer(info.Identifier, info.Duration))
}

// Equal also checks the order of pointers
s.Require().Equal(expected, pointers)
}

func (s *UpgradeTestSuite) seedAndStoreRollapps(numRollapps int) {
for _, rollapp := range s.seedRollapps(numRollapps) {
s.App.RollappKeeper.SetRollapp(s.Ctx, rollapp)
Expand Down
Loading

0 comments on commit 9c43bec

Please sign in to comment.