fix(x/tx): default to using gogoproto.HybridResolver wherever possible (#19845)
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
This commit is contained in:
parent
ea7bdd1724
commit
adc3432ba2
@ -18,7 +18,7 @@ type Reader interface {
|
||||
//
|
||||
// Note: <key> is safe to modify and read after calling Get.
|
||||
// The returned byte slice is safe to read, but cannot be modified.
|
||||
Get(storeKey []byte, key []byte) ([]byte, error)
|
||||
Get(storeKey, key []byte) ([]byte, error)
|
||||
}
|
||||
|
||||
// Writer wraps the Set method of a backing data store.
|
||||
@ -26,12 +26,12 @@ type Writer interface {
|
||||
// Set inserts the given value into the key-value data store.
|
||||
//
|
||||
// Note: <key, value> are safe to modify and read after calling Set.
|
||||
Set(storeKey []byte, key, value []byte) error
|
||||
Set(storeKey, key, value []byte) error
|
||||
|
||||
// Delete removes the key from the backing key-value data store.
|
||||
//
|
||||
// Note: <key> is safe to modify and read after calling Delete.
|
||||
Delete(storeKey []byte, key []byte) error
|
||||
Delete(storeKey, key []byte) error
|
||||
}
|
||||
|
||||
// Database contains all the methods required to allow handling different
|
||||
|
||||
@ -3,8 +3,9 @@ package encoding
|
||||
import (
|
||||
"testing"
|
||||
|
||||
corestore "cosmossdk.io/core/store"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
corestore "cosmossdk.io/core/store"
|
||||
)
|
||||
|
||||
func TestChangesetMarshal(t *testing.T) {
|
||||
|
||||
@ -57,11 +57,11 @@ func (b *Batch) set(storeKey []byte, tombstone uint64, key, value []byte) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Batch) Set(storeKey []byte, key, value []byte) error {
|
||||
func (b *Batch) Set(storeKey, key, value []byte) error {
|
||||
return b.set(storeKey, 0, key, value)
|
||||
}
|
||||
|
||||
func (b *Batch) Delete(storeKey []byte, key []byte) error {
|
||||
func (b *Batch) Delete(storeKey, key []byte) error {
|
||||
return b.set(storeKey, b.version, key, []byte(tombstoneVal))
|
||||
}
|
||||
|
||||
|
||||
@ -319,7 +319,7 @@ func storePrefix(storeKey []byte) []byte {
|
||||
return append([]byte(StorePrefixTpl), storeKey...)
|
||||
}
|
||||
|
||||
func prependStoreKey(storeKey []byte, key []byte) []byte {
|
||||
func prependStoreKey(storeKey, key []byte) []byte {
|
||||
return append(storePrefix(storeKey), key...)
|
||||
}
|
||||
|
||||
@ -362,7 +362,7 @@ func valTombstoned(value []byte) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func getMVCCSlice(db *pebble.DB, storeKey []byte, key []byte, version uint64) ([]byte, error) {
|
||||
func getMVCCSlice(db *pebble.DB, storeKey, key []byte, version uint64) ([]byte, error) {
|
||||
// end domain is exclusive, so we need to increment the version by 1
|
||||
if version < math.MaxUint64 {
|
||||
version++
|
||||
|
||||
@ -62,13 +62,13 @@ func (b *Batch) Reset() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Batch) Set(storeKey []byte, key, value []byte) error {
|
||||
func (b *Batch) Set(storeKey, key, value []byte) error {
|
||||
b.size += len(key) + len(value)
|
||||
b.ops = append(b.ops, batchOp{action: batchActionSet, storeKey: storeKey, key: key, value: value})
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Batch) Delete(storeKey []byte, key []byte) error {
|
||||
func (b *Batch) Delete(storeKey, key []byte) error {
|
||||
b.size += len(key)
|
||||
b.ops = append(b.ops, batchOp{action: batchActionDel, storeKey: storeKey, key: key})
|
||||
return nil
|
||||
|
||||
@ -13,9 +13,7 @@ import (
|
||||
"cosmossdk.io/store/v2/storage"
|
||||
)
|
||||
|
||||
var (
|
||||
storeKey1 = []byte("store1")
|
||||
)
|
||||
var storeKey1 = []byte("store1")
|
||||
|
||||
func TestStorageTestSuite(t *testing.T) {
|
||||
s := &storage.StorageTestSuite{
|
||||
|
||||
@ -31,6 +31,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Improvments
|
||||
|
||||
* [#19845](https://github.com/cosmos/cosmos-sdk/pull/19845) Use hybrid resolver instead of only protov2 registry
|
||||
|
||||
## v0.13.1
|
||||
|
||||
### Features
|
||||
@ -113,18 +117,18 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
### Improvements
|
||||
|
||||
* [#15871](https://github.com/cosmos/cosmos-sdk/pull/15871)
|
||||
* `HandlerMap` now has a `DefaultMode()` getter method
|
||||
* Textual types use `signing.ProtoFileResolver` instead of `protoregistry.Files`
|
||||
* `HandlerMap` now has a `DefaultMode()` getter method
|
||||
* Textual types use `signing.ProtoFileResolver` instead of `protoregistry.Files`
|
||||
|
||||
## v0.6.0
|
||||
|
||||
### API Breaking
|
||||
|
||||
* [#15709](https://github.com/cosmos/cosmos-sdk/pull/15709):
|
||||
* `GetSignersContext` has been renamed to `signing.Context`
|
||||
* `GetSigners` now returns `[][]byte` instead of `[]string`
|
||||
* `GetSignersOptions` has been renamed to `signing.Options` and requires `address.Codec`s for account and validator addresses
|
||||
* `GetSignersOptions.ProtoFiles` has been renamed to `signing.Options.FileResolver`
|
||||
* `GetSignersContext` has been renamed to `signing.Context`
|
||||
* `GetSigners` now returns `[][]byte` instead of `[]string`
|
||||
* `GetSignersOptions` has been renamed to `signing.Options` and requires `address.Codec`s for account and validator addresses
|
||||
* `GetSignersOptions.ProtoFiles` has been renamed to `signing.Options.FileResolver`
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
|
||||
signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
|
||||
@ -31,7 +32,7 @@ type SignModeHandlerOptions struct {
|
||||
func NewSignModeHandler(options SignModeHandlerOptions) *SignModeHandler {
|
||||
h := &SignModeHandler{}
|
||||
if options.FileResolver == nil {
|
||||
h.fileResolver = protoregistry.GlobalFiles
|
||||
h.fileResolver = gogoproto.HybridResolver
|
||||
} else {
|
||||
h.fileResolver = options.FileResolver
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"io"
|
||||
"sort"
|
||||
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
"github.com/pkg/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
@ -55,7 +56,7 @@ type Encoder struct {
|
||||
// rules.
|
||||
func NewEncoder(options EncoderOptions) Encoder {
|
||||
if options.FileResolver == nil {
|
||||
options.FileResolver = protoregistry.GlobalFiles
|
||||
options.FileResolver = gogoproto.HybridResolver
|
||||
}
|
||||
if options.TypeResolver == nil {
|
||||
options.TypeResolver = protoregistry.GlobalTypes
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
cosmos_proto "github.com/cosmos/cosmos-proto"
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protodesc"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
@ -79,7 +80,7 @@ type ProtoFileResolver interface {
|
||||
func NewContext(options Options) (*Context, error) {
|
||||
protoFiles := options.FileResolver
|
||||
if protoFiles == nil {
|
||||
protoFiles = protoregistry.GlobalFiles
|
||||
protoFiles = gogoproto.HybridResolver
|
||||
}
|
||||
|
||||
protoTypes := options.TypeResolver
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
cosmos_proto "github.com/cosmos/cosmos-proto"
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
@ -71,7 +72,7 @@ func NewSignModeHandler(o SignModeOptions) (*SignModeHandler, error) {
|
||||
return nil, errors.New("coinMetadataQuerier must be non-empty")
|
||||
}
|
||||
if o.FileResolver == nil {
|
||||
o.FileResolver = protoregistry.GlobalFiles
|
||||
o.FileResolver = gogoproto.HybridResolver
|
||||
}
|
||||
if o.TypeResolver == nil {
|
||||
o.TypeResolver = protoregistry.GlobalTypes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user