From 364f03db75734a724a4897e1cc000ba355a07bad Mon Sep 17 00:00:00 2001 From: Jim Fasarakis-Hilliard Date: Thu, 28 Sep 2023 12:31:46 +0300 Subject: [PATCH 1/2] Save gas on capability IsInitialized (#4770) (cherry picked from commit 7f36e0ad08345204b4a49812fb98ba27016166a4) --- modules/capability/keeper/keeper.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/capability/keeper/keeper.go b/modules/capability/keeper/keeper.go index 3283449b5aa..0b641df3db7 100644 --- a/modules/capability/keeper/keeper.go +++ b/modules/capability/keeper/keeper.go @@ -148,7 +148,7 @@ func (k *Keeper) InitMemStore(ctx sdk.Context) { // IsInitialized returns true if the keeper is properly initialized, and false otherwise. func (k *Keeper) IsInitialized(ctx sdk.Context) bool { memStore := ctx.KVStore(k.memKey) - return memStore.Get(types.KeyMemInitialized) != nil + return memStore.Has(types.KeyMemInitialized) } // InitializeIndex sets the index to one (or greater) in InitChain according From 131a79f8c51474635103a01f0bacd382768dc94c Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Thu, 28 Sep 2023 11:39:04 +0200 Subject: [PATCH 2/2] chore: adding changelog entry for IsInitialized gas consumption --- modules/capability/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/capability/CHANGELOG.md b/modules/capability/CHANGELOG.md index cf6d1b30cae..472e0e358ed 100644 --- a/modules/capability/CHANGELOG.md +++ b/modules/capability/CHANGELOG.md @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements * [\#4068](https://github.com/cosmos/ibc-go/pull/4068) Various improvements made to testing to reduce the dependency tree and use new cosmos-sdk test utils. +* [\#4770](https://github.com/cosmos/ibc-go/pull/4770) Save gas on `IsInitialized`, use `Has` in favour of `Get`. ### Features