feat: add core module with app config support (#11914)

This commit is contained in:
Aaron Craelius 2022-05-10 14:41:52 -04:00 committed by GitHub
parent 40b59537eb
commit 90272e3b46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 3295 additions and 24 deletions

View File

@ -1617,10 +1617,8 @@ type ModuleDescriptor struct {
unknownFields protoimpl.UnknownFields
// go_import names the package that should be imported by an app to load the
// module in the runtime module registry. Either go_import must be defined here
// or the go_package option must be defined at the file level to indicate
// to users where to location the module implementation. go_import takes
// precedence over go_package when both are defined.
// module in the runtime module registry. It is required to make debugging
// of configuration errors easier for users.
GoImport string `protobuf:"bytes,1,opt,name=go_import,json=goImport,proto3" json:"go_import,omitempty"`
// use_package refers to a protobuf package that this module
// uses and exposes to the world. In an app, only one module should "use"

View File

@ -6282,7 +6282,9 @@ func (x *QueryModuleAccountsResponse) GetAccounts() []*anypb.Any {
return nil
}
// Bech32PrefixRequest is the request type for Bech32Prefix rpc method
// Bech32PrefixRequest is the request type for Bech32Prefix rpc method.
//
// Since: cosmos-sdk 0.46
type Bech32PrefixRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -6309,7 +6311,9 @@ func (*Bech32PrefixRequest) Descriptor() ([]byte, []int) {
return file_cosmos_auth_v1beta1_query_proto_rawDescGZIP(), []int{8}
}
// Bech32PrefixResponse is the response type for Bech32Prefix rpc method
// Bech32PrefixResponse is the response type for Bech32Prefix rpc method.
//
// Since: cosmos-sdk 0.46
type Bech32PrefixResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -6345,7 +6349,9 @@ func (x *Bech32PrefixResponse) GetBech32Prefix() string {
return ""
}
// AddressBytesToStringRequest is the request type for AddressString rpc method
// AddressBytesToStringRequest is the request type for AddressString rpc method.
//
// Since: cosmos-sdk 0.46
type AddressBytesToStringRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -6381,7 +6387,9 @@ func (x *AddressBytesToStringRequest) GetAddressBytes() []byte {
return nil
}
// AddressBytesToStringResponse is the response type for AddressString rpc method
// AddressBytesToStringResponse is the response type for AddressString rpc method.
//
// Since: cosmos-sdk 0.46
type AddressBytesToStringResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -6417,7 +6425,9 @@ func (x *AddressBytesToStringResponse) GetAddressString() string {
return ""
}
// AddressStringToBytesRequest is the request type for AccountBytes rpc method
// AddressStringToBytesRequest is the request type for AccountBytes rpc method.
//
// Since: cosmos-sdk 0.46
type AddressStringToBytesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -6453,7 +6463,9 @@ func (x *AddressStringToBytesRequest) GetAddressString() string {
return ""
}
// AddressStringToBytesResponse is the response type for AddressBytes rpc method
// AddressStringToBytesResponse is the response type for AddressBytes rpc method.
//
// Since: cosmos-sdk 0.46
type AddressStringToBytesResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache

View File

@ -32,11 +32,17 @@ type QueryClient interface {
Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
// ModuleAccounts returns all the existing module accounts.
ModuleAccounts(ctx context.Context, in *QueryModuleAccountsRequest, opts ...grpc.CallOption) (*QueryModuleAccountsResponse, error)
// Bech32 queries bech32Prefix
// Bech32Prefix queries bech32Prefix
//
// Since: cosmos-sdk 0.46
Bech32Prefix(ctx context.Context, in *Bech32PrefixRequest, opts ...grpc.CallOption) (*Bech32PrefixResponse, error)
// AddressBytesToString converts Account Address bytes to string
//
// Since: cosmos-sdk 0.46
AddressBytesToString(ctx context.Context, in *AddressBytesToStringRequest, opts ...grpc.CallOption) (*AddressBytesToStringResponse, error)
// AddressStringToBytes converts Address string to bytes
//
// Since: cosmos-sdk 0.46
AddressStringToBytes(ctx context.Context, in *AddressStringToBytesRequest, opts ...grpc.CallOption) (*AddressStringToBytesResponse, error)
}
@ -125,11 +131,17 @@ type QueryServer interface {
Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
// ModuleAccounts returns all the existing module accounts.
ModuleAccounts(context.Context, *QueryModuleAccountsRequest) (*QueryModuleAccountsResponse, error)
// Bech32 queries bech32Prefix
// Bech32Prefix queries bech32Prefix
//
// Since: cosmos-sdk 0.46
Bech32Prefix(context.Context, *Bech32PrefixRequest) (*Bech32PrefixResponse, error)
// AddressBytesToString converts Account Address bytes to string
//
// Since: cosmos-sdk 0.46
AddressBytesToString(context.Context, *AddressBytesToStringRequest) (*AddressBytesToStringResponse, error)
// AddressStringToBytes converts Address string to bytes
//
// Since: cosmos-sdk 0.46
AddressStringToBytes(context.Context, *AddressStringToBytesRequest) (*AddressStringToBytesResponse, error)
mustEmbedUnimplementedQueryServer()
}

View File

@ -39,6 +39,8 @@ type QueryClient interface {
// Since: cosmos-sdk 0.43
ModuleVersions(ctx context.Context, in *QueryModuleVersionsRequest, opts ...grpc.CallOption) (*QueryModuleVersionsResponse, error)
// Returns the account with authority to conduct upgrades
//
// Since: cosmos-sdk 0.46
Authority(ctx context.Context, in *QueryAuthorityRequest, opts ...grpc.CallOption) (*QueryAuthorityResponse, error)
}
@ -117,6 +119,8 @@ type QueryServer interface {
// Since: cosmos-sdk 0.43
ModuleVersions(context.Context, *QueryModuleVersionsRequest) (*QueryModuleVersionsResponse, error)
// Returns the account with authority to conduct upgrades
//
// Since: cosmos-sdk 0.46
Authority(context.Context, *QueryAuthorityRequest) (*QueryAuthorityResponse, error)
mustEmbedUnimplementedQueryServer()
}

2
core/Makefile Normal file
View File

@ -0,0 +1,2 @@
codegen:
(cd internal; buf generate)

11
core/README.md Normal file
View File

@ -0,0 +1,11 @@
# Cosmos SDK Core
The [cosmossdk.io/core](https://pkg.go.dev/cosmossdk.io/core) go module defines
"core" functionality for the Cosmos SDK.
Currently functionality for registering modules using the [appmodule](https://pkg.go.dev/cosmossdk.io/core/appmodule)
package and composing apps using the [appconfig](https://pkg.go.dev/cosmossdk.io/core/appconfig)
package is provided.
In the future core functionality for building Cosmos SDK app modules will be
provided in this go module.

111
core/appconfig/config.go Normal file
View File

@ -0,0 +1,111 @@
package appconfig
import (
"fmt"
"reflect"
"strings"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
"google.golang.org/protobuf/types/known/anypb"
"sigs.k8s.io/yaml"
"github.com/cosmos/cosmos-sdk/container"
appv1alpha1 "github.com/cosmos/cosmos-sdk/api/cosmos/app/v1alpha1"
"cosmossdk.io/core/internal"
)
// LoadJSON loads an app config in JSON format.
func LoadJSON(bz []byte) container.Option {
config := &appv1alpha1.Config{}
err := protojson.Unmarshal(bz, config)
if err != nil {
return container.Error(err)
}
return Compose(config)
}
// LoadYAML loads an app config in YAML format.
func LoadYAML(bz []byte) container.Option {
j, err := yaml.YAMLToJSON(bz)
if err != nil {
return container.Error(err)
}
return LoadJSON(j)
}
// Compose composes a v1alpha1 app config into a container option by resolving
// the required modules and composing their options.
func Compose(appConfig *appv1alpha1.Config) container.Option {
opts := []container.Option{
container.Supply(appConfig),
}
for _, module := range appConfig.Modules {
if module.Name == "" {
return container.Error(fmt.Errorf("module is missing name"))
}
if module.Config == nil {
return container.Error(fmt.Errorf("module %q is missing a config object", module.Name))
}
msgType, err := protoregistry.GlobalTypes.FindMessageByURL(module.Config.TypeUrl)
if err != nil {
return container.Error(err)
}
modules, err := internal.ModulesByProtoMessageName()
if err != nil {
return container.Error(err)
}
init, ok := modules[msgType.Descriptor().FullName()]
if !ok {
modDesc := proto.GetExtension(msgType.Descriptor().Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor)
if modDesc == nil {
return container.Error(fmt.Errorf("no module registered for type URL %s and that protobuf type does not have the option %s\n\n%s",
module.Config.TypeUrl, appv1alpha1.E_Module.TypeDescriptor().FullName(), dumpRegisteredModules(modules)))
}
return container.Error(fmt.Errorf("no module registered for type URL %s, did you forget to import %s\n\n%s",
module.Config.TypeUrl, modDesc.GoImport, dumpRegisteredModules(modules)))
}
config := init.ConfigProtoMessage.ProtoReflect().Type().New().Interface()
err = anypb.UnmarshalTo(module.Config, config, proto.UnmarshalOptions{})
if err != nil {
return container.Error(err)
}
opts = append(opts, container.Provide(container.ProviderDescriptor{
Inputs: nil,
Outputs: []container.ProviderOutput{{Type: init.ConfigGoType}},
Fn: func(values []reflect.Value) ([]reflect.Value, error) {
return []reflect.Value{reflect.ValueOf(config)}, nil
},
Location: container.LocationFromCaller(0),
}))
for _, provider := range init.Providers {
opts = append(opts, container.ProvideInModule(module.Name, provider))
}
}
return container.Options(opts...)
}
func dumpRegisteredModules(modules map[protoreflect.FullName]*internal.ModuleInitializer) string {
var mods []string
for name := range modules {
mods = append(mods, " "+string(name))
}
return fmt.Sprintf("registered modules are:\n%s", strings.Join(mods, "\n"))
}

View File

@ -0,0 +1,104 @@
package appconfig_test
import (
"bytes"
"reflect"
"testing"
"gotest.tools/v3/assert"
"github.com/cosmos/cosmos-sdk/container"
"cosmossdk.io/core/appconfig"
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/internal"
"cosmossdk.io/core/internal/testpb"
_ "cosmossdk.io/core/internal/testpb"
)
func expectContainerErrorContains(t *testing.T, option container.Option, contains string) {
t.Helper()
err := container.Build(option)
assert.ErrorContains(t, err, contains)
}
func TestCompose(t *testing.T) {
opt := appconfig.LoadJSON([]byte(`{"modules":[{}]}`))
expectContainerErrorContains(t, opt, "module is missing name")
opt = appconfig.LoadJSON([]byte(`{"modules":[{"name": "a"}]}`))
expectContainerErrorContains(t, opt, `module "a" is missing a config object`)
opt = appconfig.LoadYAML([]byte(`
modules:
- name: a
config:
"@type": testpb.ModuleFoo
`))
expectContainerErrorContains(t, opt, `unable to resolve`)
opt = appconfig.LoadYAML([]byte(`
modules:
- name: a
config:
"@type": cosmos.app.v1alpha1.Config # this is not actually a module config type!
`))
expectContainerErrorContains(t, opt, "does not have the option cosmos.app.v1alpha1.module")
expectContainerErrorContains(t, opt, "registered modules are")
expectContainerErrorContains(t, opt, "testpb.TestModuleA")
opt = appconfig.LoadYAML([]byte(`
modules:
- name: a
config:
"@type": testpb.TestUnregisteredModule
`))
expectContainerErrorContains(t, opt, "did you forget to import cosmossdk.io/core/internal/testpb")
expectContainerErrorContains(t, opt, "registered modules are")
expectContainerErrorContains(t, opt, "testpb.TestModuleA")
var app testpb.App
opt = appconfig.LoadYAML([]byte(`
modules:
- name: runtime
config:
"@type": testpb.TestRuntimeModule
- name: a
config:
"@type": testpb.TestModuleA
- name: b
config:
"@type": testpb.TestModuleB
`))
assert.NilError(t, container.Build(opt, &app))
buf := &bytes.Buffer{}
app(buf)
const expected = `got store key a
got store key b
running module handler a
result: hello
running module handler b
result: goodbye
`
assert.Equal(t, expected, buf.String())
// module registration failures:
appmodule.Register(&testpb.TestNoModuleOptionModule{})
opt = appconfig.LoadYAML([]byte(`
modules:
- name: a
config:
"@type": testpb.TestNoGoImportModule
`))
expectContainerErrorContains(t, opt, "module should have the option cosmos.app.v1alpha1.module")
internal.ModuleRegistry = map[reflect.Type]*internal.ModuleInitializer{} // reset module registry
appmodule.Register(&testpb.TestNoGoImportModule{})
opt = appconfig.LoadYAML([]byte(`
modules:
- name: a
config:
"@type": testpb.TestNoGoImportModule
`))
expectContainerErrorContains(t, opt, "module should have ModuleDescriptor.go_import specified")
}

3
core/appconfig/doc.go Normal file
View File

@ -0,0 +1,3 @@
// Package appconfig defines functionality for loading declarative Cosmos SDK
// app configurations.
package appconfig

5
core/appmodule/doc.go Normal file
View File

@ -0,0 +1,5 @@
// Package appmodule defines the functionality for registering Cosmos SDK app
// modules that are assembled using the github.com/cosmos/cosmos-sdk/container
// dependency injection system and the declarative app configuration format
// handled by the appconfig package.
package appmodule

35
core/appmodule/option.go Normal file
View File

@ -0,0 +1,35 @@
package appmodule
import (
"github.com/cosmos/cosmos-sdk/container"
"cosmossdk.io/core/internal"
)
// Option is a functional option for implementing modules.
type Option interface {
apply(*internal.ModuleInitializer) error
}
type funcOption func(initializer *internal.ModuleInitializer) error
func (f funcOption) apply(initializer *internal.ModuleInitializer) error {
return f(initializer)
}
// Provide registers providers with the dependency injection system that will be
// run within the module scope. See github.com/cosmos/cosmos-sdk/container for
// documentation on the dependency injection system.
func Provide(providers ...interface{}) Option {
return funcOption(func(initializer *internal.ModuleInitializer) error {
for _, provider := range providers {
desc, err := container.ExtractProviderDescriptor(provider)
if err != nil {
return err
}
initializer.Providers = append(initializer.Providers, desc)
}
return nil
})
}

View File

@ -0,0 +1,34 @@
package appmodule
import (
"reflect"
"google.golang.org/protobuf/proto"
"cosmossdk.io/core/internal"
)
// Register registers a module with the global module registry. The provided
// protobuf message is used only to uniquely identify the protobuf module config
// type. The instance of the protobuf message used in the actual configuration
// will be injected into the container and can be requested by a provider
// function. All module initialization should be handled by the provided options.
//
// Protobuf message types used for module configuration should define the
// cosmos.app.v1alpha.module option and must explicitly specify go_package
// to make debugging easier for users.
func Register(msg proto.Message, options ...Option) {
ty := reflect.TypeOf(msg)
init := &internal.ModuleInitializer{
ConfigProtoMessage: msg,
ConfigGoType: ty,
}
internal.ModuleRegistry[ty] = init
for _, option := range options {
init.Error = option.apply(init)
if init.Error != nil {
return
}
}
}

32
core/go.mod Normal file
View File

@ -0,0 +1,32 @@
module cosmossdk.io/core
go 1.18
require (
github.com/cosmos/cosmos-proto v1.0.0-alpha7
github.com/cosmos/cosmos-sdk/api v0.1.0
github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3
google.golang.org/protobuf v1.28.0
gotest.tools/v3 v3.2.0
sigs.k8s.io/yaml v1.3.0
)
require (
github.com/fogleman/gg v1.3.0 // indirect
github.com/goccy/go-graphviz v0.0.9 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect
golang.org/x/text v0.3.5 // indirect
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect
google.golang.org/grpc v1.46.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
replace github.com/cosmos/cosmos-sdk/api => ../api

190
core/go.sum Normal file
View File

@ -0,0 +1,190 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/corona10/goimagehash v1.0.2 h1:pUfB0LnsJASMPGEZLj7tGY251vF+qLGqOgEP4rUs6kA=
github.com/corona10/goimagehash v1.0.2/go.mod h1:/l9umBhvcHQXVtQO1V6Gp1yD20STawkhRnnX0D1bvVI=
github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0=
github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw=
github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3 h1:CC8p43RhsrtZdPOkT/Q5q8QkEGKCq3BbTr/wG/3vJ70=
github.com/cosmos/cosmos-sdk/container v1.0.0-alpha.3/go.mod h1:fd4VKEYJiPjjElIRm7xsjUFMh2ljTtooK1H/DJa0uPU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ=
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/goccy/go-graphviz v0.0.9 h1:s/FMMJ1Joj6La3S5ApO3Jk2cwM4LpXECC2muFx3IPQQ=
github.com/goccy/go-graphviz v0.0.9/go.mod h1:wXVsXxmyMQU6TN3zGRttjNn3h+iCAS7xQFC6TlNvLhk=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 h1:BvoENQQU+fZ9uukda/RzCAL/191HHwJA5b13R6diVlY=
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/image v0.0.0-20200119044424-58c23975cae1 h1:5h3ngYt7+vXCDZCup/HkCQgW5XwmSvR/nA2JmJ0RErg=
golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw=
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/grpc v1.46.0 h1:oCjezcn6g6A75TGoKYBPgKmVBLexhYLM6MebdrPApP8=
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.2.0 h1:I0DwBVMGAx26dttAj1BtJLAkVGncrkkUXfJLC4Flt/I=
gotest.tools/v3 v3.2.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=

View File

@ -0,0 +1,11 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: cosmossdk.io/core/internal
override:
buf.build/cosmos/cosmos-sdk: github.com/cosmos/cosmos-sdk/api
plugins:
- name: go-pulsar
out: .
opt: paths=source_relative

9
core/internal/buf.yaml Normal file
View File

@ -0,0 +1,9 @@
version: v1
lint:
use:
- DEFAULT
except:
- PACKAGE_VERSION_SUFFIX
breaking:
ignore:
- testpb

59
core/internal/registry.go Normal file
View File

@ -0,0 +1,59 @@
package internal
import (
"fmt"
"reflect"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
"github.com/cosmos/cosmos-sdk/container"
appv1alpha1 "github.com/cosmos/cosmos-sdk/api/cosmos/app/v1alpha1"
)
// ModuleRegistry is the registry of module initializers indexed by their golang
// type to avoid any issues with protobuf descriptor initialization.
var ModuleRegistry = map[reflect.Type]*ModuleInitializer{}
// ModuleInitializer describes how to initialize a module.
type ModuleInitializer struct {
ConfigGoType reflect.Type
ConfigProtoMessage proto.Message
Error error
Providers []container.ProviderDescriptor
}
// ModulesByProtoMessageName should be used to retrieve modules by their protobuf name.
// This is done lazily after module registration to deal with non-deterministic issues
// that can occur with respect to protobuf descriptor initialization.
func ModulesByProtoMessageName() (map[protoreflect.FullName]*ModuleInitializer, error) {
res := map[protoreflect.FullName]*ModuleInitializer{}
for _, initializer := range ModuleRegistry {
descriptor := initializer.ConfigProtoMessage.ProtoReflect().Descriptor()
fullName := descriptor.FullName()
if _, ok := res[fullName]; ok {
return nil, fmt.Errorf("duplicate module registratio for %s", fullName)
}
modDesc := proto.GetExtension(descriptor.Options(), appv1alpha1.E_Module).(*appv1alpha1.ModuleDescriptor)
if modDesc == nil {
return nil, fmt.Errorf(
"protobuf type %s registered as a module should have the option %s",
fullName,
appv1alpha1.E_Module.TypeDescriptor().FullName())
}
if modDesc.GoImport == "" {
return nil, fmt.Errorf(
"protobuf type %s registered as a module should have ModuleDescriptor.go_import specified",
fullName,
)
}
res[fullName] = initializer
}
return res, nil
}

View File

@ -0,0 +1,99 @@
package testpb
import (
"fmt"
"io"
"sort"
"github.com/cosmos/cosmos-sdk/container"
"cosmossdk.io/core/appmodule"
)
func init() {
appmodule.Register(&TestRuntimeModule{},
appmodule.Provide(provideRuntimeState, provideStoreKey, provideApp),
)
appmodule.Register(&TestModuleA{},
appmodule.Provide(provideModuleA),
)
appmodule.Register(&TestModuleB{},
appmodule.Provide(provideModuleB),
)
}
func provideRuntimeState() *runtimeState {
return &runtimeState{}
}
func provideStoreKey(key container.ModuleKey, state *runtimeState) StoreKey {
sk := StoreKey{name: key.Name()}
state.storeKeys = append(state.storeKeys, sk)
return sk
}
func provideApp(state *runtimeState, handlers map[string]Handler) App {
return func(w io.Writer) {
for _, key := range state.storeKeys {
_, _ = fmt.Fprintf(w, "got store key %s\n", key.name)
}
var modNames []string
for modName := range handlers {
modNames = append(modNames, modName)
}
sort.Strings(modNames)
for _, name := range modNames {
_, _ = fmt.Fprintf(w, "running module handler %s\n", name)
_, _ = fmt.Fprintf(w, "result: %s\n", handlers[name].DoSomething())
}
}
}
type App func(writer io.Writer)
type runtimeState struct {
storeKeys []StoreKey
}
type StoreKey struct{ name string }
type Handler struct {
DoSomething func() string
}
func (h Handler) IsOnePerModuleType() {}
func provideModuleA(key StoreKey) (KeeperA, Handler) {
return keeperA{key: key}, Handler{DoSomething: func() string {
return "hello"
}}
}
type keeperA struct {
key StoreKey
}
type KeeperA interface {
Foo()
}
func (k keeperA) Foo() {}
func provideModuleB(key StoreKey, a KeeperA) (KeeperB, Handler) {
return keeperB{key: key, a: a}, Handler{
DoSomething: func() string {
return "goodbye"
},
}
}
type keeperB struct {
key StoreKey
a KeeperA
}
type KeeperB interface{}

View File

@ -0,0 +1,35 @@
syntax = "proto3";
package testpb;
import "cosmos/app/v1alpha1/module.proto";
message TestRuntimeModule {
option (cosmos.app.v1alpha1.module) = {
go_import: "cosmossdk.io/core/internal/testpb"
};
}
message TestModuleA {
option (cosmos.app.v1alpha1.module) = {
go_import: "cosmossdk.io/core/internal/testpb"
};
}
message TestModuleB {
option (cosmos.app.v1alpha1.module) = {
go_import: "cosmossdk.io/core/internal/testpb"
};
}
message TestUnregisteredModule {
option (cosmos.app.v1alpha1.module) = {
go_import: "cosmossdk.io/core/internal/testpb"
};
}
message TestNoModuleOptionModule {}
message TestNoGoImportModule {
option (cosmos.app.v1alpha1.module) = {};
}

File diff suppressed because it is too large Load Diff

View File

@ -18,10 +18,8 @@ extend google.protobuf.MessageOptions {
// ModuleDescriptor describes an app module.
message ModuleDescriptor {
// go_import names the package that should be imported by an app to load the
// module in the runtime module registry. Either go_import must be defined here
// or the go_package option must be defined at the file level to indicate
// to users where to location the module implementation. go_import takes
// precedence over go_package when both are defined.
// module in the runtime module registry. It is required to make debugging
// of configuration errors easier for users.
string go_import = 1;
// use_package refers to a protobuf package that this module

View File

@ -387,7 +387,9 @@ func (m *QueryModuleAccountsResponse) GetAccounts() []*types.Any {
return nil
}
// Bech32PrefixRequest is the request type for Bech32Prefix rpc method
// Bech32PrefixRequest is the request type for Bech32Prefix rpc method.
//
// Since: cosmos-sdk 0.46
type Bech32PrefixRequest struct {
}
@ -424,7 +426,9 @@ func (m *Bech32PrefixRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_Bech32PrefixRequest proto.InternalMessageInfo
// Bech32PrefixResponse is the response type for Bech32Prefix rpc method
// Bech32PrefixResponse is the response type for Bech32Prefix rpc method.
//
// Since: cosmos-sdk 0.46
type Bech32PrefixResponse struct {
Bech32Prefix string `protobuf:"bytes,1,opt,name=bech32_prefix,json=bech32Prefix,proto3" json:"bech32_prefix,omitempty"`
}
@ -469,7 +473,9 @@ func (m *Bech32PrefixResponse) GetBech32Prefix() string {
return ""
}
// AddressBytesToStringRequest is the request type for AddressString rpc method
// AddressBytesToStringRequest is the request type for AddressString rpc method.
//
// Since: cosmos-sdk 0.46
type AddressBytesToStringRequest struct {
AddressBytes []byte `protobuf:"bytes,1,opt,name=address_bytes,json=addressBytes,proto3" json:"address_bytes,omitempty"`
}
@ -514,7 +520,9 @@ func (m *AddressBytesToStringRequest) GetAddressBytes() []byte {
return nil
}
// AddressBytesToStringResponse is the response type for AddressString rpc method
// AddressBytesToStringResponse is the response type for AddressString rpc method.
//
// Since: cosmos-sdk 0.46
type AddressBytesToStringResponse struct {
AddressString string `protobuf:"bytes,1,opt,name=address_string,json=addressString,proto3" json:"address_string,omitempty"`
}
@ -559,7 +567,9 @@ func (m *AddressBytesToStringResponse) GetAddressString() string {
return ""
}
// AddressStringToBytesRequest is the request type for AccountBytes rpc method
// AddressStringToBytesRequest is the request type for AccountBytes rpc method.
//
// Since: cosmos-sdk 0.46
type AddressStringToBytesRequest struct {
AddressString string `protobuf:"bytes,1,opt,name=address_string,json=addressString,proto3" json:"address_string,omitempty"`
}
@ -604,7 +614,9 @@ func (m *AddressStringToBytesRequest) GetAddressString() string {
return ""
}
// AddressStringToBytesResponse is the response type for AddressBytes rpc method
// AddressStringToBytesResponse is the response type for AddressBytes rpc method.
//
// Since: cosmos-sdk 0.46
type AddressStringToBytesResponse struct {
AddressBytes []byte `protobuf:"bytes,1,opt,name=address_bytes,json=addressBytes,proto3" json:"address_bytes,omitempty"`
}
@ -745,11 +757,17 @@ type QueryClient interface {
Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
// ModuleAccounts returns all the existing module accounts.
ModuleAccounts(ctx context.Context, in *QueryModuleAccountsRequest, opts ...grpc.CallOption) (*QueryModuleAccountsResponse, error)
// Bech32 queries bech32Prefix
// Bech32Prefix queries bech32Prefix
//
// Since: cosmos-sdk 0.46
Bech32Prefix(ctx context.Context, in *Bech32PrefixRequest, opts ...grpc.CallOption) (*Bech32PrefixResponse, error)
// AddressBytesToString converts Account Address bytes to string
//
// Since: cosmos-sdk 0.46
AddressBytesToString(ctx context.Context, in *AddressBytesToStringRequest, opts ...grpc.CallOption) (*AddressBytesToStringResponse, error)
// AddressStringToBytes converts Address string to bytes
//
// Since: cosmos-sdk 0.46
AddressStringToBytes(ctx context.Context, in *AddressStringToBytesRequest, opts ...grpc.CallOption) (*AddressStringToBytesResponse, error)
}
@ -836,11 +854,17 @@ type QueryServer interface {
Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
// ModuleAccounts returns all the existing module accounts.
ModuleAccounts(context.Context, *QueryModuleAccountsRequest) (*QueryModuleAccountsResponse, error)
// Bech32 queries bech32Prefix
// Bech32Prefix queries bech32Prefix
//
// Since: cosmos-sdk 0.46
Bech32Prefix(context.Context, *Bech32PrefixRequest) (*Bech32PrefixResponse, error)
// AddressBytesToString converts Account Address bytes to string
//
// Since: cosmos-sdk 0.46
AddressBytesToString(context.Context, *AddressBytesToStringRequest) (*AddressBytesToStringResponse, error)
// AddressStringToBytes converts Address string to bytes
//
// Since: cosmos-sdk 0.46
AddressStringToBytes(context.Context, *AddressStringToBytesRequest) (*AddressStringToBytesResponse, error)
}