diff --git a/Dockerfile b/Dockerfile index d2fb2fcf0..06753f267 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN --mount=type=cache,target=/root/.cache/go-build \ COMMIT=$(git log -1 --format='%H') && \ go build \ -mod=readonly \ - -tags "netgo,ledger,muslc" \ + -tags "netgo,ledger,muslc,pebbledb" \ -ldflags "-X github.com/cosmos/cosmos-sdk/version.Name="quicksilver" \ -X github.com/cosmos/cosmos-sdk/version.AppName="quicksilverd" \ -X github.com/cosmos/cosmos-sdk/version.Version=$VERSION \ diff --git a/Makefile b/Makefile index 48bcc548b..0deaa55b7 100755 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ #!/usr/bin/make -f DOCKER_BUILDKIT=1 -COSMOS_BUILD_OPTIONS ?= "" +COSMOS_BUILD_OPTIONS ?= "pebbledb" PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation') PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') VERSION=$(shell git describe --tags | head -n1) diff --git a/app/app.go b/app/app.go index 0c313e1a3..40c58c1d3 100644 --- a/app/app.go +++ b/app/app.go @@ -532,6 +532,7 @@ func NewQuicksilver( app.EpochsKeeper = *epochsKeeper.SetHooks( epochstypes.NewMultiEpochHooks( app.MintKeeper.Hooks(), + app.ClaimsManagerKeeper.Hooks(), app.InterchainstakingKeeper.Hooks(), app.ParticipationRewardsKeeper.Hooks(), ), diff --git a/x/claimsmanager/keeper/keeper.go b/x/claimsmanager/keeper/keeper.go index fa38fed8c..690e2d643 100644 --- a/x/claimsmanager/keeper/keeper.go +++ b/x/claimsmanager/keeper/keeper.go @@ -60,11 +60,11 @@ func (k Keeper) StoreSelfConsensusState(ctx sdk.Context, key string) error { } state := selfConsState.(*ibctmtypes.ConsensusState) - k.SetSelfConsensusState(ctx, key, *state) + k.SetSelfConsensusState(ctx, key, state) } else { // ONLY FOR TESTING - ibctesting module chains donot follow standard [chainname]-[num] structure height := ibcclienttypes.Height{ - RevisionNumber: 1, + RevisionNumber: 0, // revision number for testchain1 is 0 (because parseChainId splits on '-') RevisionHeight: uint64(ctx.BlockHeight() - 1), } @@ -75,7 +75,7 @@ func (k Keeper) StoreSelfConsensusState(ctx sdk.Context, key string) error { } state := selfConsState.(*ibctmtypes.ConsensusState) - k.SetSelfConsensusState(ctx, key, *state) + k.SetSelfConsensusState(ctx, key, state) } return nil diff --git a/x/claimsmanager/keeper/self_consensus_state.go b/x/claimsmanager/keeper/self_consensus_state.go index f0929b951..e5859db61 100644 --- a/x/claimsmanager/keeper/self_consensus_state.go +++ b/x/claimsmanager/keeper/self_consensus_state.go @@ -9,21 +9,24 @@ import ( // GetSelfConsensusState returns consensus state stored every epoch func (k Keeper) GetSelfConsensusState(ctx sdk.Context, key string) (ibctmtypes.ConsensusState, bool) { store := ctx.KVStore(k.storeKey) - var selfConsensusState ibctmtypes.ConsensusState - k.cdc.MustUnmarshal(store.Get(append(types.KeySelfConsensusState, []byte(key)...)), &selfConsensusState) + bz := store.Get(append(types.KeySelfConsensusState, []byte(key)...)) + if bz == nil { + return selfConsensusState, false + } + k.cdc.MustUnmarshal(bz, &selfConsensusState) return selfConsensusState, true } // SetSelfConsensusState sets the self consensus state -func (k Keeper) SetSelfConsensusState(ctx sdk.Context, key string, consState ibctmtypes.ConsensusState) { +func (k Keeper) SetSelfConsensusState(ctx sdk.Context, key string, consState *ibctmtypes.ConsensusState) { store := ctx.KVStore(k.storeKey) - store.Set(store.Get(append(types.KeySelfConsensusState, []byte(key)...)), k.cdc.MustMarshal(&consState)) + store.Set(append(types.KeySelfConsensusState, []byte(key)...), k.cdc.MustMarshal(consState)) } // DeleteSelfConsensusState deletes the self consensus state -func (k Keeper) DeleteSelfConsensusState(ctx sdk.Context, key string, consState ibctmtypes.ConsensusState) { +func (k Keeper) DeleteSelfConsensusState(ctx sdk.Context, key string) { store := ctx.KVStore(k.storeKey) - store.Delete(store.Get(append(types.KeySelfConsensusState, []byte(key)...))) + store.Delete(append(types.KeySelfConsensusState, []byte(key)...)) } diff --git a/x/claimsmanager/keeper/self_consensus_state_test.go b/x/claimsmanager/keeper/self_consensus_state_test.go new file mode 100644 index 000000000..4c261889b --- /dev/null +++ b/x/claimsmanager/keeper/self_consensus_state_test.go @@ -0,0 +1,20 @@ +package keeper_test + +func (s *KeeperTestSuite) TestGetSetDelete() { + k := s.GetQuicksilverApp(s.chainA).ClaimsManagerKeeper + ctx := s.chainA.GetContext() + + _, found := k.GetSelfConsensusState(ctx, "test") + s.Require().False(found) + + err := k.StoreSelfConsensusState(ctx, "test") + s.Require().NoError(err) + + _, found = k.GetSelfConsensusState(ctx, "test") + s.Require().True(found) + + k.DeleteSelfConsensusState(ctx, "test") + + _, found = k.GetSelfConsensusState(ctx, "test") + s.Require().False(found) +}