Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(indexer): the issues during simapp v1 integration #22413

Merged
merged 8 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions collections/codec/indexing.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func ValueSchemaCodec[V any](cdc ValueCodec[V]) (SchemaCodec[V], error) {

// FallbackSchemaCodec returns a fallback schema codec for T when one isn't explicitly
// specified with HasSchemaCodec. It maps all simple types directly to schema kinds
// and converts everything else to JSON.
// and converts everything else to String.
func FallbackSchemaCodec[T any]() SchemaCodec[T] {
var t T
kind := schema.KindForGoValue(t)
Expand All @@ -81,20 +81,20 @@ func FallbackSchemaCodec[T any]() SchemaCodec[T] {
FromSchemaType: nil,
}
} else {
// we default to encoding everything to JSON
// we default to encoding everything to String
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to a JSON string

return SchemaCodec[T]{
Fields: []schema.Field{{Kind: schema.JSONKind}},
Fields: []schema.Field{{Kind: schema.StringKind}},
ToSchemaType: func(t T) (any, error) {
bz, err := json.Marshal(t)
return json.RawMessage(bz), err
return string(json.RawMessage(bz)), err
},
FromSchemaType: func(a any) (T, error) {
var t T
bz, ok := a.(json.RawMessage)
sz, ok := a.(string)
if !ok {
return t, fmt.Errorf("expected json.RawMessage, got %T", a)
return t, fmt.Errorf("expected string, got %T", a)
}
err := json.Unmarshal(bz, &t)
err := json.Unmarshal([]byte(sz), &t)
return t, err
},
}
Expand Down
4 changes: 2 additions & 2 deletions collections/indexes/reverse_pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ func NewReversePair[Value, K1, K2 any](
}
if o.uncheckedValue {
return &ReversePair[K1, K2, Value]{
refKeys: collections.NewKeySet(sb, prefix, name, collections.PairKeyCodec(pkc.KeyCodec2(), pkc.KeyCodec1()), collections.WithKeySetUncheckedValue()),
refKeys: collections.NewKeySet(sb, prefix, name, collections.PairKeyCodec(pkc.KeyCodec2(), pkc.KeyCodec1()), collections.WithKeySetUncheckedValue(), collections.WithKeySetSecondaryIndex()),
}
}

mi := &ReversePair[K1, K2, Value]{
refKeys: collections.NewKeySet(sb, prefix, name, collections.PairKeyCodec(pkc.KeyCodec2(), pkc.KeyCodec1())),
refKeys: collections.NewKeySet(sb, prefix, name, collections.PairKeyCodec(pkc.KeyCodec2(), pkc.KeyCodec1()), collections.WithKeySetSecondaryIndex()),
}

return mi
Expand Down
3 changes: 3 additions & 0 deletions collections/indexing.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ func (c collectionImpl[K, V]) schemaCodec() (*collectionSchemaCodec, error) {
if err != nil {
return nil, err
}
if keyDecoder.ToSchemaType == nil {
return x, nil
}
return keyDecoder.ToSchemaType(x)
}
ensureFieldNames(c.m.kc, "key", res.objectType.KeyFields)
Expand Down
14 changes: 12 additions & 2 deletions collections/keyset.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ func WithKeySetUncheckedValue() func(opt *keySetOptions) {
}
}

type keySetOptions struct{ uncheckedValue bool }
// WithKeySetSecondaryIndex changes the behavior of the KeySet to be a secondary index.
func WithKeySetSecondaryIndex() func(opt *keySetOptions) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be public?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, used in indexes/reverse_pair.go

return func(opt *keySetOptions) {
opt.isSecondaryIndex = true
}
}

type keySetOptions struct {
uncheckedValue bool
isSecondaryIndex bool
}

// KeySet builds on top of a Map and represents a collection retaining only a set
// of keys and no value. It can be used, for example, in an allow list.
Expand All @@ -44,7 +54,7 @@ func NewKeySet[K any](
if o.uncheckedValue {
vc = codec.NewAltValueCodec(vc, func(_ []byte) (NoValue, error) { return NoValue{}, nil })
}
return (KeySet[K])(NewMap(schema, prefix, name, keyCodec, vc))
return (KeySet[K])(NewMap(schema, prefix, name, keyCodec, vc, withMapSecondaryIndex(o.isSecondaryIndex)))
}

// Set adds the key to the KeySet. Errors on encoding problems.
Expand Down
27 changes: 22 additions & 5 deletions collections/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ type Map[K, V any] struct {
isSecondaryIndex bool
}

// withMapSecondaryIndex changes the behavior of the Map to be a secondary index.
func withMapSecondaryIndex(isSecondaryIndex bool) func(opt *mapOptions) {
return func(opt *mapOptions) {
opt.isSecondaryIndex = isSecondaryIndex
}
}

type mapOptions struct {
isSecondaryIndex bool
}

// NewMap returns a Map given a StoreKey, a Prefix, human-readable name and the relative value and key encoders.
// Name and prefix must be unique within the schema and name must match the format specified by NameRegex, or
// else this method will panic.
Expand All @@ -36,13 +47,19 @@ func NewMap[K, V any](
name string,
keyCodec codec.KeyCodec[K],
valueCodec codec.ValueCodec[V],
options ...func(opt *mapOptions),
) Map[K, V] {
o := new(mapOptions)
for _, opt := range options {
opt(o)
}
m := Map[K, V]{
kc: keyCodec,
vc: valueCodec,
sa: schemaBuilder.schema.storeAccessor,
prefix: prefix.Bytes(),
name: name,
kc: keyCodec,
vc: valueCodec,
sa: schemaBuilder.schema.storeAccessor,
prefix: prefix.Bytes(),
name: name,
isSecondaryIndex: o.isSecondaryIndex,
}
schemaBuilder.addCollection(collectionImpl[K, V]{m})
return m
Expand Down
5 changes: 5 additions & 0 deletions collections/pair.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ func (p Pair[K1, K2]) K2() (k2 K2) {
return *p.key2
}

// Keys returns key1 and key2 as a slice.
func (p Pair[K1, K2]) Keys() []interface{} {
return []interface{}{p.K1(), p.K2()}
}

// Join creates a new Pair instance composed of the two provided keys, in order.
func Join[K1, K2 any](key1 K1, key2 K2) Pair[K1, K2] {
return Pair[K1, K2]{
Expand Down
5 changes: 5 additions & 0 deletions collections/quad.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ func (t Quad[K1, K2, K3, K4]) K4() (x K4) {
return x
}

// Keys returns key1, key2, key3 and key4 as a slice.
func (t Quad[K1, K2, K3, K4]) Keys() []interface{} {
return []interface{}{t.K1(), t.K2(), t.K3(), t.K4()}
}

// QuadPrefix creates a new Quad instance composed only of the first part of the key.
func QuadPrefix[K1, K2, K3, K4 any](k1 K1) Quad[K1, K2, K3, K4] {
return Quad[K1, K2, K3, K4]{k1: &k1}
Expand Down
5 changes: 5 additions & 0 deletions collections/triple.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ func (t Triple[K1, K2, K3]) K3() (x K3) {
return x
}

// Keys returns key1, key2 and key3 as a slice.
func (t Triple[K1, K2, K3]) Keys() []interface{} {
return []interface{}{t.K1(), t.K2(), t.K3()}
}

// TriplePrefix creates a new Triple instance composed only of the first part of the key.
func TriplePrefix[K1, K2, K3 any](k1 K1) Triple[K1, K2, K3] {
return Triple[K1, K2, K3]{k1: &k1}
Expand Down
8 changes: 8 additions & 0 deletions indexer/postgres/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
"cosmossdk.io/schema"
)

type keyCollection interface {
// Keys returns the key fields for the collection.
Keys() []interface{}
}

// bindKeyParams binds the key to the key columns.
func (tm *objectIndexer) bindKeyParams(key interface{}) ([]interface{}, []string, error) {
n := len(tm.typ.KeyFields)
Expand All @@ -17,6 +22,9 @@ func (tm *objectIndexer) bindKeyParams(key interface{}) ([]interface{}, []string
} else if n == 1 {
return tm.bindParams(tm.typ.KeyFields, []interface{}{key})
} else {
if kc, ok := key.(keyCollection); ok {
return tm.bindParams(tm.typ.KeyFields, kc.Keys())
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to change anything in indexer here. This breaks the schema specification. Instead we need to make sure that pair, triple, etc in collections decode correctly to what schema expects. This would be part of the codec implementation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SchemaCodec method of PairKeyCodec, etc is what needs to be fixed. I didn't complete the encoding/decoding there properly. Apologies that this wasn't clear.

key, ok := key.([]interface{})
if !ok {
return nil, nil, errors.New("expected key to be a slice")
Expand Down
9 changes: 8 additions & 1 deletion runtime/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,14 @@ func (a *AppBuilder) registerIndexer() error {
if indexerOpts := a.appOptions.Get("indexer"); indexerOpts != nil {
moduleSet := map[string]any{}
for modName, mod := range a.app.ModuleManager.Modules {
moduleSet[modName] = mod
storeKey := modName
for _, cfg := range a.app.config.OverrideStoreKeys {
if cfg.ModuleName == modName {
storeKey = cfg.KvStoreKey
break
}
}
moduleSet[storeKey] = mod
}

return a.app.EnableIndexer(indexerOpts, a.kvStoreKeys(), moduleSet)
Expand Down
3 changes: 3 additions & 0 deletions simapp/app_di.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import (
"fmt"
"io"

_ "github.com/jackc/pgx/v5/stdlib" // Import and register pgx driver

clienthelpers "cosmossdk.io/client/v2/helpers"
"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/registry"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/depinject"
_ "cosmossdk.io/indexer/postgres" // register the postgres indexer
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Missing required PostgreSQL indexer dependency in go.mod

The PostgreSQL indexer is imported and used in the code, but its dependency is not properly declared in go.mod. This could lead to build issues or version inconsistencies.

  • Add cosmossdk.io/indexer/postgres to the required dependencies in go.mod
🔗 Analysis chain

LGTM: PostgreSQL indexer import is correctly added.

The import of the Postgres indexer module with the blank identifier follows the correct pattern for registering the indexer.

Let's verify that the required dependencies are properly declared in go.mod:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the required PostgreSQL dependencies are declared in go.mod

# Test: Check for pgx dependency
echo "Checking for pgx dependency..."
rg "github.com/jackc/pgx/v5" go.mod

# Test: Check for postgres indexer dependency
echo "Checking for postgres indexer dependency..."
rg "cosmossdk.io/indexer/postgres" go.mod

Length of output: 245


Script:

#!/bin/bash
# Let's try a different approach to check the dependencies

# Check the entire go.mod content
echo "=== Checking go.mod content ==="
cat go.mod

# Check if there are any indirect dependencies related to postgres
echo -e "\n=== Checking for any postgres-related dependencies ==="
rg -i "postgres" go.mod

# Check if the indexer package is imported anywhere else
echo -e "\n=== Checking for indexer usage across the codebase ==="
rg "cosmossdk.io/indexer" --type go

Length of output: 10219

"cosmossdk.io/log"
"cosmossdk.io/x/accounts"
basedepinject "cosmossdk.io/x/accounts/defaults/base/depinject"
Expand Down
7 changes: 7 additions & 0 deletions simapp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require (
cosmossdk.io/core v1.0.0-alpha.5
cosmossdk.io/core/testing v0.0.0-20240923163230-04da382a9f29
cosmossdk.io/depinject v1.0.0
cosmossdk.io/indexer/postgres v0.1.0
cosmossdk.io/log v1.4.1
cosmossdk.io/math v1.3.0
cosmossdk.io/store v1.1.1
Expand Down Expand Up @@ -49,6 +50,8 @@ require (
google.golang.org/protobuf v1.35.1
)

require github.com/jackc/pgx/v5 v5.7.1

require (
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.35.1-20240701160653-fedbb9acfd2f.1 // indirect
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.35.1-20240130113600-88ef6483f90f.1 // indirect
Expand Down Expand Up @@ -147,6 +150,9 @@ require (
github.com/huandu/skiplist v1.2.1 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
Expand Down Expand Up @@ -240,6 +246,7 @@ replace (
cosmossdk.io/api => ../api
cosmossdk.io/client/v2 => ../client/v2
cosmossdk.io/collections => ../collections
cosmossdk.io/indexer/postgres => ../indexer/postgres
cosmossdk.io/store => ../store
cosmossdk.io/tools/confix => ../tools/confix
cosmossdk.io/x/accounts => ../x/accounts
Expand Down
9 changes: 9 additions & 0 deletions simapp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc=
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
Expand Down Expand Up @@ -600,6 +601,14 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94=
github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
Expand Down
6 changes: 6 additions & 0 deletions tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ require (
cloud.google.com/go/storage v1.43.0 // indirect
cosmossdk.io/client/v2 v2.0.0-20230630094428-02b760776860 // indirect
cosmossdk.io/errors v1.0.1 // indirect
cosmossdk.io/indexer/postgres v0.1.0 // indirect
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac // indirect
cosmossdk.io/x/circuit v0.0.0-20230613133644-0a778132a60f // indirect
cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337 // indirect
Expand Down Expand Up @@ -151,6 +152,10 @@ require (
github.com/huandu/skiplist v1.2.1 // indirect
github.com/iancoleman/strcase v0.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/pgx/v5 v5.7.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
Expand Down Expand Up @@ -237,6 +242,7 @@ replace (
cosmossdk.io/api => ../api
cosmossdk.io/client/v2 => ../client/v2
cosmossdk.io/collections => ../collections
cosmossdk.io/indexer/postgres => ../indexer/postgres
cosmossdk.io/store => ../store
cosmossdk.io/x/accounts => ../x/accounts
cosmossdk.io/x/accounts/defaults/base => ../x/accounts/defaults/base
Expand Down
9 changes: 9 additions & 0 deletions tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ cosmossdk.io/log v1.4.1 h1:wKdjfDRbDyZRuWa8M+9nuvpVYxrEOwbD/CA8hvhU8QM=
cosmossdk.io/log v1.4.1/go.mod h1:k08v0Pyq+gCP6phvdI6RCGhLf/r425UT6Rk/m+o74rU=
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
cosmossdk.io/schema v0.3.0/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac h1:3joNZZWZ3k7fMsrBDL1ktuQ2xQwYLZOaDhkruadDFmc=
cosmossdk.io/schema v0.3.1-0.20241010135032-192601639cac/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
Expand Down Expand Up @@ -595,6 +596,14 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
github.com/jhump/protoreflect v1.17.0 h1:qOEr613fac2lOuTgWN4tPAtLL7fUSbuJL5X5XumQh94=
github.com/jhump/protoreflect v1.17.0/go.mod h1:h9+vUUL38jiBzck8ck+6G/aeMX8Z4QUY/NiJPwPNi+8=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
Expand Down
7 changes: 0 additions & 7 deletions x/bank/keeper/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"cosmossdk.io/core/appmodule"
errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
"cosmossdk.io/schema"
"cosmossdk.io/x/bank/types"

"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -257,9 +256,3 @@ func (k BaseViewKeeper) ValidateBalance(ctx context.Context, addr sdk.AccAddress

return nil
}

// ModuleCodec implements `schema.HasModuleCodec` interface.
// It allows the indexer to decode the module's KVPairUpdate.
func (k BaseViewKeeper) ModuleCodec() (schema.ModuleCodec, error) {
return k.Schema.ModuleCodec(collections.IndexingOptions{})
}
8 changes: 8 additions & 0 deletions x/bank/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (
"github.com/spf13/cobra"
"google.golang.org/grpc"

"cosmossdk.io/collections"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/registry"
"cosmossdk.io/schema"
"cosmossdk.io/x/bank/client/cli"
"cosmossdk.io/x/bank/keeper"
"cosmossdk.io/x/bank/simulation"
Expand Down Expand Up @@ -175,3 +177,9 @@ func (am AppModule) WeightedOperationsX(weights simsx.WeightSource, reg simsx.Re
reg.Add(weights.Get("msg_send", 100), simulation.MsgSendFactory())
reg.Add(weights.Get("msg_multisend", 10), simulation.MsgMultiSendFactory())
}

// ModuleCodec implements `schema.HasModuleCodec` interface.
// It allows the indexer to decode the module's KVPairUpdate.
func (am AppModule) ModuleCodec() (schema.ModuleCodec, error) {
return am.keeper.(keeper.BaseKeeper).Schema.ModuleCodec(collections.IndexingOptions{})
}
Loading