From 3c296c39b0a493c86a3c171e7c372f0ca23ab275 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Tue, 7 Feb 2023 05:48:22 +0000 Subject: [PATCH] Release v1.4.0-rc4 (#290) * x/interchainstaking/keeper: preallocate slice capacity in CalculateDeltas Given that types.ValidatorIntents is already a slice, this change just extracts its length and uses that as a slice capacity hint to improve performance. Fixes #97 * x/interchainstaking/keeper: use .IncrementBalanceWaitgroup() instead of naked ++ Instead of using a naked increment for an exported struct, this change uses its .IncrementBalanceWaitgroup() which helps in logical checks. Fixes #98 * x/interchainstaking/keeper: add fuzzers Adds fuzzers that we've written to help find vulnerabilities. While here, using go test -short to skip fuzzing being run in regular tests per `make test`. Updates #90 * bump proto-gen container to v0.9.0, to support go 1.19 * add channel close/reopen proposals * lint/gofumpt * regen proto files with additional comments * error catching epochs added * fixed test cases * lint fix * codecov secrets * add no-op upgrade handler for v1.3.0 * added check for deposit addr (#281) * Release/v1.3.2 (#285) * UpdateWithdrawAddress callback patched * added pagination fix * keeper-tests added * add deposit interval test * add adjacent verification; add deposit callback tests; * remove ibc/ prefix check from validateBasic * gofumpt * add rts functionality; enable/disable unbonding and deposits per zone; store decimals in zone struct; store first_seen and complete timestamps against receipts; add upgrade handler to migrate zones * rebase fixes * store added for self-consensus-state * handle submission of PR claims against Quicksilver * [WIP] verifying self claims * added delete method * claim from local chain * lint fix * update epoch hooks in cm * update zone struct in tests * support v0.47.x balances returned by kvstore lookup * lint fix * fix: harcoded prefix * feature: [TG-420] add stats to zone(s) endpoints * lint fixes * use correct token in error message; fixes i#118 * gofumpt * remove pedantic error checking in allocateLockupRewards * defensive check against negative validator vp * check for nil value in sdkAmount * make errors deterministic * improve error handling by propogating error * be super defensive and check for negative values, not just zero equality * reject nil value coins * set the quick prefix in the correct place * revert backwards incompatible changes to zones and related props * fix lint * tests and fixes for TG-416 slash withdrawal fix * bump tenermint version * bump tendermint to v0.34.25 * allow port to be reopened via tx * pr fixes * verbose logging * skip zone allocations for zones with no price information * lint * extended upgrade handler to clear uni-5 records * more verbose logging on unbonding satisfaction * added logic to burn uqjunox * other records removed and test case added * lint fix * check for innuendo specific upgrade-handler * Deprecation warning fix and testchain included for upgradehandler * imports tidy * errors.Register deprecation fix * deprecation fixes * lint fix * fix self consensus state store/delete fns * ensure cm hooks are registered * add pebble into default build --------- Co-authored-by: Emmanuel T Odeke Co-authored-by: Ajaz Ahmed Ansari --- Dockerfile | 2 +- Makefile | 2 +- app/app.go | 1 + x/claimsmanager/keeper/keeper.go | 6 +++--- .../keeper/self_consensus_state.go | 15 ++++++++------ .../keeper/self_consensus_state_test.go | 20 +++++++++++++++++++ 6 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 x/claimsmanager/keeper/self_consensus_state_test.go 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) +}