Skip to content

Commit

Permalink
chore: remove state breaking changes (will be included in different PR)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbreithecker committed Jul 7, 2023
1 parent 2985563 commit f6706d6
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 151 deletions.
20 changes: 4 additions & 16 deletions app/upgrades/v1_3/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,16 @@
package v1_3

import (
bundlesKeeper "github.com/KYVENetwork/chain/x/bundles/keeper"
bundlesTypes "github.com/KYVENetwork/chain/x/bundles/types"
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 {
func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
) upgradeTypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradeTypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
// TODO UpdateBundlesVersionMap(bundlesKeeper, ctx)

return mm.RunMigrations(ctx, configurator, vm)
}
}

func UpdateBundlesVersionMap(keeper bundlesKeeper.Keeper, ctx sdk.Context) {
keeper.SetBundleVersionMap(ctx, bundlesTypes.BundleVersionMap{
Versions: []*bundlesTypes.BundleVersionEntry{
{
Height: uint64(ctx.BlockHeight()),
Version: 2,
},
},
})
}
3 changes: 1 addition & 2 deletions proto/kyve/bundles/v1beta1/bundles.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ message FinalizedBundle {
uint32 storage_provider_id = 12;
// compression_id the id of the compression type with which the data was compressed
uint32 compression_id = 13;
// stake_security
StakeSecurity stake_security = 14;
}

// FinalizedAt ...
Expand Down Expand Up @@ -124,3 +122,4 @@ message BundleVersionMap {
// versions ...
repeated BundleVersionEntry versions = 1;
}

27 changes: 21 additions & 6 deletions testutil/integration/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package integration

import (
"github.com/KYVENetwork/chain/x/bundles"
bundlesTypes "github.com/KYVENetwork/chain/x/bundles/types"
"github.com/KYVENetwork/chain/x/delegation"
delegationtypes "github.com/KYVENetwork/chain/x/delegation/types"
globalTypes "github.com/KYVENetwork/chain/x/global/types"
Expand Down Expand Up @@ -262,6 +263,23 @@ func (suite *KeeperTestSuite) VerifyStakersGenesisImportExport() {
// bundles module checks
// =====================

func checkFinalizedBundle(queryBundle querytypes.FinalizedBundle, rawBundle bundlesTypes.FinalizedBundle) {
Expect(queryBundle.Id).To(Equal(rawBundle.Id))
Expect(queryBundle.PoolId).To(Equal(rawBundle.PoolId))
Expect(queryBundle.StorageId).To(Equal(rawBundle.StorageId))
Expect(queryBundle.Uploader).To(Equal(rawBundle.Uploader))
Expect(queryBundle.FromIndex).To(Equal(rawBundle.FromIndex))
Expect(queryBundle.ToIndex).To(Equal(rawBundle.ToIndex))
Expect(queryBundle.ToKey).To(Equal(rawBundle.ToKey))
Expect(queryBundle.BundleSummary).To(Equal(rawBundle.BundleSummary))
Expect(queryBundle.DataHash).To(Equal(rawBundle.DataHash))
Expect(queryBundle.FinalizedAt.Height).To(Equal(rawBundle.FinalizedAt.Height))
Expect(queryBundle.FinalizedAt.Timestamp).To(Equal(rawBundle.FinalizedAt.Timestamp))
Expect(queryBundle.FromKey).To(Equal(rawBundle.FromKey))
Expect(queryBundle.StorageProviderId).To(Equal(uint64(rawBundle.StorageProviderId)))
Expect(queryBundle.CompressionId).To(Equal(uint64(rawBundle.CompressionId)))
}

func (suite *KeeperTestSuite) VerifyBundlesQueries() {
pools := suite.App().PoolKeeper.GetAllPools(suite.Ctx())

Expand All @@ -275,18 +293,15 @@ func (suite *KeeperTestSuite) VerifyBundlesQueries() {
Expect(finalizedBundlesQuery.FinalizedBundles).To(HaveLen(len(finalizedBundlesState)))

for i := range finalizedBundlesState {
// TODO adjust tests to support new bundle schema
// Expect(finalizedBundlesQuery.FinalizedBundles[i]).To(Equal(finalizedBundlesState[i]))

finalizedBundleQuery, finalizedBundleQueryErr := suite.App().QueryKeeper.FinalizedBundleQuery(sdk.WrapSDKContext(suite.Ctx()), &querytypes.QueryFinalizedBundleRequest{
finalizedBundle, finalizedBundleQueryErr := suite.App().QueryKeeper.FinalizedBundleQuery(sdk.WrapSDKContext(suite.Ctx()), &querytypes.QueryFinalizedBundleRequest{
PoolId: pool.Id,
Id: finalizedBundlesState[i].Id,
})

Expect(finalizedBundleQueryErr).To(BeNil())
// TODO adjust tests to support new bundle schema
_ = finalizedBundleQuery
// Expect(finalizedBundleQuery.FinalizedBundles.).To(Equal(finalizedBundlesState[i]))

checkFinalizedBundle(*finalizedBundle, finalizedBundlesState[i])
}
}
}
Expand Down
10 changes: 2 additions & 8 deletions x/bundles/keeper/getters_bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"encoding/binary"
"fmt"

cosmossdk_io_math "cosmossdk.io/math"

queryTypes "github.com/KYVENetwork/chain/x/query/types"
storeTypes "github.com/cosmos/cosmos-sdk/store/types"

Expand Down Expand Up @@ -141,13 +139,9 @@ func RawBundleToQueryBundle(rawFinalizedBundle types.FinalizedBundle, versionMap
TotalVotePower: nil,
},
}

// Check for version 2
if rawFinalizedBundle.FinalizedAt.Height >= versionMap[2] {
validPower := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.StakeSecurity.ValidVotePower))
totalPower := cosmossdk_io_math.NewInt(int64(rawFinalizedBundle.StakeSecurity.TotalVotePower))
finalizedBundle.StakeSecurity.ValidVotePower = &validPower
finalizedBundle.StakeSecurity.TotalVotePower = &totalPower
}
// TODO will be done by separate PR

return finalizedBundle
}
Expand Down
4 changes: 0 additions & 4 deletions x/bundles/keeper/logic_bundles.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,6 @@ func (k Keeper) finalizeCurrentBundleProposal(ctx sdk.Context, poolId uint64, vo
DataHash: bundleProposal.DataHash,
StorageProviderId: bundleProposal.StorageProviderId,
CompressionId: bundleProposal.CompressionId,
StakeSecurity: &types.StakeSecurity{
ValidVotePower: voteDistribution.Valid,
TotalVotePower: voteDistribution.Total,
},
}

k.SetFinalizedBundle(ctx, finalizedBundle)
Expand Down
167 changes: 52 additions & 115 deletions x/bundles/types/bundles.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f6706d6

Please sign in to comment.