diff --git a/x/state-verifier/keeper/keeper.go b/x/state-verifier/keeper/keeper.go index 8b558b1da..f70a7d1b8 100644 --- a/x/state-verifier/keeper/keeper.go +++ b/x/state-verifier/keeper/keeper.go @@ -2,7 +2,6 @@ package keeper import ( "fmt" - "strconv" "cosmossdk.io/core/comet" "cosmossdk.io/core/header" @@ -143,11 +142,7 @@ func (k *Keeper) GetAllConsensusStates(ctx sdk.Context) ([]*types.ConsensusState for ; iterator.Valid(); iterator.Next() { cs := tendermint.ConsensusState{} k.cdc.MustUnmarshal(iterator.Value(), &cs) - height, err := strconv.ParseInt(string(iterator.Key()), 10, 64) - if err != nil { - return nil, errors.Wrapf(err, "failed to extract height from consensus state key") - } - + height := int64(sdk.BigEndianToUint64(iterator.Key())) states = append(states, &types.ConsensusState{ Height: height, Cs: &cs, diff --git a/x/state-verifier/types/keys.go b/x/state-verifier/types/keys.go index 0df1de90a..fbe933b08 100644 --- a/x/state-verifier/types/keys.go +++ b/x/state-verifier/types/keys.go @@ -1,6 +1,8 @@ package types -import "strconv" +import ( + "github.com/cosmos/cosmos-sdk/types" +) const ( // ModuleName defines the module name @@ -17,5 +19,5 @@ const ( var ConsensusStateKey = []byte{prefixConsensusStateKey} func GetConsensusStateKey(height int64) []byte { - return append(ConsensusStateKey, []byte(strconv.FormatInt(height, 10))...) + return append(ConsensusStateKey, types.Uint64ToBigEndian(uint64(height))...) }