Skip to content

Commit

Permalink
Merge branch 'main' into julien/simplify-signing-pkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Jan 21, 2025
2 parents 2b9ba06 + f40f820 commit 836178f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
28 changes: 22 additions & 6 deletions simapp/v2/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ var (
accounts.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
// bankv2types.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
Expand All @@ -174,7 +173,28 @@ var (
},
// When ExportGenesis is not specified, the export genesis module order
// is equal to the init genesis order
// ExportGenesis: []string{},
ExportGenesis: []string{
consensustypes.ModuleName,
accounts.ModuleName,
authtypes.ModuleName,
pooltypes.ModuleName, // Must be exported before bank
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
slashingtypes.ModuleName,
govtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
evidencetypes.ModuleName,
authz.ModuleName,
feegrant.ModuleName,
nft.ModuleName,
group.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
circuittypes.ModuleName,
epochstypes.ModuleName,
},
// Uncomment if you want to set a custom migration order here.
// OrderMigrations: []string{},
// TODO GasConfig was added to the config in runtimev2. Where/how was it set in v1?
Expand Down Expand Up @@ -298,10 +318,6 @@ var (
Name: epochstypes.ModuleName,
Config: appconfig.WrapAny(&epochsmodulev1.Module{}),
},
// {
// Name: bankv2types.ModuleName,
// Config: appconfig.WrapAny(&bankmodulev2.Module{}),
// },
},
}
)
15 changes: 15 additions & 0 deletions x/protocolpool/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ func (k Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error
}

func (k Keeper) ExportGenesis(ctx context.Context) (*types.GenesisState, error) {
// refresh all funds
if err := k.IterateAndUpdateFundsDistribution(ctx); err != nil {
return nil, err
}

// withdraw all rewards before exporting genesis
if err := k.RecipientFundDistribution.Walk(ctx, nil, func(key sdk.AccAddress, value types.DistributionAmount) (stop bool, err error) {
if _, err := k.withdrawRecipientFunds(ctx, key.Bytes()); err != nil {
return true, err
}
return false, nil
}); err != nil {
return nil, err
}

var cf []*types.ContinuousFund
err := k.ContinuousFund.Walk(ctx, nil, func(key sdk.AccAddress, value types.ContinuousFund) (stop bool, err error) {
recipient, err := k.authKeeper.AddressCodec().BytesToString(key)
Expand Down
9 changes: 7 additions & 2 deletions x/protocolpool/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@ package keeper_test
import (
"time"

"go.uber.org/mock/gomock"

"cosmossdk.io/math"
"cosmossdk.io/x/protocolpool/types"

sdk "github.com/cosmos/cosmos-sdk/types"
)

func (suite *KeeperTestSuite) TestInitGenesis() {
func (suite *KeeperTestSuite) TestInitExportGenesis() {
suite.bankKeeper.EXPECT().SendCoinsFromModuleToModule(gomock.Any(), types.ProtocolPoolDistrAccount, gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
suite.bankKeeper.EXPECT().SendCoinsFromModuleToAccount(gomock.Any(), types.StreamAccount, gomock.Any(), gomock.Any()).Return(nil).AnyTimes()

hour := time.Hour
gs := types.NewGenesisState(
[]*types.ContinuousFund{
Expand Down Expand Up @@ -49,5 +54,5 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
suite.Require().NoError(err)
suite.Require().Equal(gs.ContinuousFund, exportedGenState.ContinuousFund)
suite.Require().Equal(gs.Budget, exportedGenState.Budget)
suite.Require().Equal(math.NewInt(101), exportedGenState.LastBalance.Amount.AmountOf("stake"))
suite.Require().Equal(math.ZeroInt(), exportedGenState.LastBalance.Amount.AmountOf("stake"))
}

0 comments on commit 836178f

Please sign in to comment.