merged in master
This commit is contained in:
+69
-40
@@ -7,14 +7,17 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec/legacy"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
"github.com/cosmos/cosmos-sdk/internal/conv"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
"github.com/cosmos/cosmos-sdk/types/bech32"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/hashicorp/golang-lru/simplelru"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,13 +29,16 @@ const (
|
||||
// config.SetBech32PrefixForAccount(yourBech32PrefixAccAddr, yourBech32PrefixAccPub)
|
||||
// config.SetBech32PrefixForValidator(yourBech32PrefixValAddr, yourBech32PrefixValPub)
|
||||
// config.SetBech32PrefixForConsensusNode(yourBech32PrefixConsAddr, yourBech32PrefixConsPub)
|
||||
// config.SetPurpose(yourPurpose)
|
||||
// config.SetCoinType(yourCoinType)
|
||||
// config.SetFullFundraiserPath(yourFullFundraiserPath)
|
||||
// config.Seal()
|
||||
|
||||
// Bech32MainPrefix defines the main SDK Bech32 prefix of an account's address
|
||||
Bech32MainPrefix = "cosmos"
|
||||
|
||||
// Purpose is the ATOM purpose as defined in SLIP44 (https://github.com/satoshilabs/slips/blob/master/slip-0044.md)
|
||||
Purpose = 44
|
||||
|
||||
// CoinType is the ATOM coin type as defined in SLIP44 (https://github.com/satoshilabs/slips/blob/master/slip-0044.md)
|
||||
CoinType = 118
|
||||
|
||||
@@ -68,6 +74,33 @@ const (
|
||||
Bech32PrefixConsPub = Bech32MainPrefix + PrefixValidator + PrefixConsensus + PrefixPublic
|
||||
)
|
||||
|
||||
// cache variables
|
||||
var (
|
||||
// AccAddress.String() is expensive and if unoptimized dominantly showed up in profiles,
|
||||
// yet has no mechanisms to trivially cache the result given that AccAddress is a []byte type.
|
||||
accAddrMu sync.RWMutex
|
||||
accAddrCache *simplelru.LRU
|
||||
consAddrMu sync.RWMutex
|
||||
consAddrCache *simplelru.LRU
|
||||
valAddrMu sync.RWMutex
|
||||
valAddrCache *simplelru.LRU
|
||||
)
|
||||
|
||||
func init() {
|
||||
var err error
|
||||
// in total the cache size is 61k entries. Key is 32 bytes and value is around 50-70 bytes.
|
||||
// That will make around 92 * 61k * 2 (LRU) bytes ~ 11 MB
|
||||
if accAddrCache, err = simplelru.NewLRU(60000, nil); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if consAddrCache, err = simplelru.NewLRU(500, nil); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if valAddrCache, err = simplelru.NewLRU(500, nil); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// Address is a common interface for different types of addresses used by the SDK
|
||||
type Address interface {
|
||||
Equals(Address) bool
|
||||
@@ -154,12 +187,7 @@ func (aa AccAddress) Equals(aa2 Address) bool {
|
||||
|
||||
// Returns boolean for whether an AccAddress is empty
|
||||
func (aa AccAddress) Empty() bool {
|
||||
if aa == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
aa2 := AccAddress{}
|
||||
return bytes.Equal(aa.Bytes(), aa2.Bytes())
|
||||
return aa == nil || len(aa) == 0
|
||||
}
|
||||
|
||||
// Marshal returns the raw address bytes. It is needed for protobuf
|
||||
@@ -239,14 +267,14 @@ func (aa AccAddress) String() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
bech32PrefixAccAddr := GetConfig().GetBech32AccountAddrPrefix()
|
||||
|
||||
bech32Addr, err := bech32.ConvertAndEncode(bech32PrefixAccAddr, aa.Bytes())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
var key = conv.UnsafeBytesToStr(aa)
|
||||
accAddrMu.RLock()
|
||||
addr, ok := accAddrCache.Get(key)
|
||||
accAddrMu.RUnlock()
|
||||
if ok {
|
||||
return addr.(string)
|
||||
}
|
||||
|
||||
return bech32Addr
|
||||
return cacheBech32Addr(GetConfig().GetBech32AccountAddrPrefix(), aa, accAddrCache, key, &accAddrMu)
|
||||
}
|
||||
|
||||
// Format implements the fmt.Formatter interface.
|
||||
@@ -308,12 +336,7 @@ func (va ValAddress) Equals(va2 Address) bool {
|
||||
|
||||
// Returns boolean for whether an AccAddress is empty
|
||||
func (va ValAddress) Empty() bool {
|
||||
if va == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
va2 := ValAddress{}
|
||||
return bytes.Equal(va.Bytes(), va2.Bytes())
|
||||
return va == nil || len(va) == 0
|
||||
}
|
||||
|
||||
// Marshal returns the raw address bytes. It is needed for protobuf
|
||||
@@ -394,14 +417,14 @@ func (va ValAddress) String() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
bech32PrefixValAddr := GetConfig().GetBech32ValidatorAddrPrefix()
|
||||
|
||||
bech32Addr, err := bech32.ConvertAndEncode(bech32PrefixValAddr, va.Bytes())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
var key = conv.UnsafeBytesToStr(va)
|
||||
valAddrMu.RLock()
|
||||
addr, ok := valAddrCache.Get(key)
|
||||
valAddrMu.RUnlock()
|
||||
if ok {
|
||||
return addr.(string)
|
||||
}
|
||||
|
||||
return bech32Addr
|
||||
return cacheBech32Addr(GetConfig().GetBech32ValidatorAddrPrefix(), va, valAddrCache, key, &valAddrMu)
|
||||
}
|
||||
|
||||
// Format implements the fmt.Formatter interface.
|
||||
@@ -468,12 +491,7 @@ func (ca ConsAddress) Equals(ca2 Address) bool {
|
||||
|
||||
// Returns boolean for whether an ConsAddress is empty
|
||||
func (ca ConsAddress) Empty() bool {
|
||||
if ca == nil {
|
||||
return true
|
||||
}
|
||||
|
||||
ca2 := ConsAddress{}
|
||||
return bytes.Equal(ca.Bytes(), ca2.Bytes())
|
||||
return ca == nil || len(ca) == 0
|
||||
}
|
||||
|
||||
// Marshal returns the raw address bytes. It is needed for protobuf
|
||||
@@ -554,14 +572,14 @@ func (ca ConsAddress) String() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
bech32PrefixConsAddr := GetConfig().GetBech32ConsensusAddrPrefix()
|
||||
|
||||
bech32Addr, err := bech32.ConvertAndEncode(bech32PrefixConsAddr, ca.Bytes())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
var key = conv.UnsafeBytesToStr(ca)
|
||||
consAddrMu.RLock()
|
||||
addr, ok := consAddrCache.Get(key)
|
||||
consAddrMu.RUnlock()
|
||||
if ok {
|
||||
return addr.(string)
|
||||
}
|
||||
|
||||
return bech32Addr
|
||||
return cacheBech32Addr(GetConfig().GetBech32ConsensusAddrPrefix(), ca, consAddrCache, key, &consAddrMu)
|
||||
}
|
||||
|
||||
// Bech32ifyAddressBytes returns a bech32 representation of address bytes.
|
||||
@@ -706,3 +724,14 @@ func addressBytesFromHexString(address string) ([]byte, error) {
|
||||
|
||||
return hex.DecodeString(address)
|
||||
}
|
||||
|
||||
func cacheBech32Addr(prefix string, addr []byte, cache *simplelru.LRU, cacheKey string, m sync.Locker) string {
|
||||
bech32Addr, err := bech32.ConvertAndEncode(prefix, addr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
m.Lock()
|
||||
cache.Add(cacheKey, bech32Addr)
|
||||
m.Unlock()
|
||||
return bech32Addr
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# Account
|
||||
|
||||
This package defines Cosmos SDK address related functions.
|
||||
|
||||
## References
|
||||
|
||||
+ [ADR-028](../../docs/architecture/adr-028-public-key-addresses.md)
|
||||
@@ -0,0 +1,64 @@
|
||||
package address
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"sort"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/internal/conv"
|
||||
"github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
// Len is the length of base addresses
|
||||
const Len = sha256.Size
|
||||
|
||||
type Addressable interface {
|
||||
Address() []byte
|
||||
}
|
||||
|
||||
// Hash creates a new address from address type and key
|
||||
func Hash(typ string, key []byte) []byte {
|
||||
hasher := sha256.New()
|
||||
hasher.Write(conv.UnsafeStrToBytes(typ))
|
||||
th := hasher.Sum(nil)
|
||||
|
||||
hasher.Reset()
|
||||
_, err := hasher.Write(th)
|
||||
// the error always nil, it's here only to satisfy the io.Writer interface
|
||||
errors.AssertNil(err)
|
||||
_, err = hasher.Write(key)
|
||||
errors.AssertNil(err)
|
||||
return hasher.Sum(nil)
|
||||
}
|
||||
|
||||
// NewComposed creates a new address based on sub addresses.
|
||||
func NewComposed(typ string, subAddresses []Addressable) ([]byte, error) {
|
||||
as := make([][]byte, len(subAddresses))
|
||||
totalLen := 0
|
||||
var err error
|
||||
for i := range subAddresses {
|
||||
a := subAddresses[i].Address()
|
||||
as[i], err = LengthPrefix(a)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("not compatible sub-adddress=%v at index=%d [%w]", a, i, err)
|
||||
}
|
||||
totalLen += len(as[i])
|
||||
}
|
||||
|
||||
sort.Slice(as, func(i, j int) bool { return bytes.Compare(as[i], as[j]) <= 0 })
|
||||
key := make([]byte, totalLen)
|
||||
offset := 0
|
||||
for i := range as {
|
||||
copy(key[offset:], as[i])
|
||||
offset += len(as[i])
|
||||
}
|
||||
return Hash(typ, key), nil
|
||||
}
|
||||
|
||||
// Module is a specialized version of a composed address for modules. Each module account
|
||||
// is constructed from a module name and module account key.
|
||||
func Module(moduleName string, key []byte) []byte {
|
||||
mKey := append([]byte(moduleName), 0)
|
||||
return Hash("module", append(mKey, key...))
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package address
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
func TestAddressSuite(t *testing.T) {
|
||||
suite.Run(t, new(AddressSuite))
|
||||
}
|
||||
|
||||
type AddressSuite struct{ suite.Suite }
|
||||
|
||||
func (suite *AddressSuite) TestHash() {
|
||||
assert := suite.Assert()
|
||||
typ := "1"
|
||||
key := []byte{1}
|
||||
part1 := sha256.Sum256([]byte(typ))
|
||||
expected := sha256.Sum256(append(part1[:], key...))
|
||||
received := Hash(typ, key)
|
||||
assert.Equal(expected[:], received, "must create a correct address")
|
||||
|
||||
received = Hash("other", key)
|
||||
assert.NotEqual(expected[:], received, "must create a correct address")
|
||||
assert.Len(received, Len, "must have correct length")
|
||||
}
|
||||
|
||||
func (suite *AddressSuite) TestComposed() {
|
||||
assert := suite.Assert()
|
||||
a1 := addrMock{[]byte{11, 12}}
|
||||
a2 := addrMock{[]byte{21, 22}}
|
||||
|
||||
typ := "multisig"
|
||||
ac, err := NewComposed(typ, []Addressable{a1, a2})
|
||||
assert.NoError(err)
|
||||
assert.Len(ac, Len)
|
||||
|
||||
// check if optimizations work
|
||||
checkingKey := append([]byte{}, a1.AddressWithLen(suite.T())...)
|
||||
checkingKey = append(checkingKey, a2.AddressWithLen(suite.T())...)
|
||||
ac2 := Hash(typ, checkingKey)
|
||||
assert.Equal(ac, ac2, "NewComposed works correctly")
|
||||
|
||||
// changing order of addresses shouldn't impact a composed address
|
||||
ac2, err = NewComposed(typ, []Addressable{a2, a1})
|
||||
assert.NoError(err)
|
||||
assert.Len(ac2, Len)
|
||||
assert.Equal(ac, ac2, "NewComposed is not sensitive for order")
|
||||
|
||||
// changing a type should change composed address
|
||||
ac2, err = NewComposed(typ+"other", []Addressable{a2, a1})
|
||||
assert.NoError(err)
|
||||
assert.NotEqual(ac, ac2, "NewComposed must be sensitive to type")
|
||||
|
||||
// changing order of addresses shouldn't impact a composed address
|
||||
ac2, err = NewComposed(typ, []Addressable{a1, addrMock{make([]byte, 300, 300)}})
|
||||
assert.Error(err)
|
||||
assert.Contains(err.Error(), "should be max 255 bytes, got 300")
|
||||
}
|
||||
|
||||
func (suite *AddressSuite) TestModule() {
|
||||
assert := suite.Assert()
|
||||
var modName, key = "myModule", []byte{1, 2}
|
||||
addr := Module(modName, key)
|
||||
assert.Len(addr, Len, "must have address length")
|
||||
|
||||
addr2 := Module("myModule2", key)
|
||||
assert.NotEqual(addr, addr2, "changing module name must change address")
|
||||
|
||||
addr3 := Module(modName, []byte{1, 2, 3})
|
||||
assert.NotEqual(addr, addr3, "changing key must change address")
|
||||
assert.NotEqual(addr2, addr3, "changing key must change address")
|
||||
}
|
||||
|
||||
type addrMock struct {
|
||||
Addr []byte
|
||||
}
|
||||
|
||||
func (a addrMock) Address() []byte {
|
||||
return a.Addr
|
||||
}
|
||||
|
||||
func (a addrMock) AddressWithLen(t *testing.T) []byte {
|
||||
addr, err := LengthPrefix(a.Addr)
|
||||
assert.NoError(t, err)
|
||||
return addr
|
||||
}
|
||||
@@ -3,12 +3,19 @@ package address_test
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
)
|
||||
|
||||
func TestLengthPrefixedAddressStoreKey(t *testing.T) {
|
||||
func TestStoreKeySuite(t *testing.T) {
|
||||
suite.Run(t, new(StoreKeySuite))
|
||||
}
|
||||
|
||||
type StoreKeySuite struct{ suite.Suite }
|
||||
|
||||
func (suite *StoreKeySuite) TestLengthPrefix() {
|
||||
require := suite.Require()
|
||||
addr10byte := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
|
||||
addr20byte := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19}
|
||||
addr256byte := make([]byte, 256)
|
||||
@@ -23,15 +30,16 @@ func TestLengthPrefixedAddressStoreKey(t *testing.T) {
|
||||
{"20-byte address", addr20byte, append([]byte{byte(20)}, addr20byte...), false},
|
||||
{"256-byte address (too long)", addr256byte, nil, true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
suite.Run(tt.name, func() {
|
||||
storeKey, err := address.LengthPrefix(tt.addr)
|
||||
if tt.expErr {
|
||||
require.Error(t, err)
|
||||
require.Error(err)
|
||||
} else {
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, tt.expStoreKey, storeKey)
|
||||
require.NoError(err)
|
||||
require.Equal(tt.expStoreKey, storeKey)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -11,6 +11,25 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
func BenchmarkAccAddressString(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
pkBz := make([]byte, ed25519.PubKeySize)
|
||||
pk := &ed25519.PubKey{Key: pkBz}
|
||||
a := pk.Address()
|
||||
pk2 := make([]byte, ed25519.PubKeySize)
|
||||
for i := 1; i < ed25519.PubKeySize; i++ {
|
||||
pk2[i] = byte(i)
|
||||
}
|
||||
a2 := pk.Address()
|
||||
var str, str2 string
|
||||
for i := 0; i < b.N; i++ {
|
||||
str = a.String()
|
||||
str2 = a2.String()
|
||||
}
|
||||
require.NotEmpty(b, str)
|
||||
require.NotEmpty(b, str2)
|
||||
}
|
||||
|
||||
func BenchmarkBech32ifyPubKey(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
pkBz := make([]byte, ed25519.PubKeySize)
|
||||
|
||||
@@ -28,3 +28,53 @@ func BenchmarkParseCoin(b *testing.B) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkUintMarshal(b *testing.B) {
|
||||
var values = []uint64{
|
||||
0,
|
||||
1,
|
||||
1 << 10,
|
||||
1<<10 - 3,
|
||||
1<<63 - 1,
|
||||
1<<32 - 7,
|
||||
1<<22 - 8,
|
||||
}
|
||||
|
||||
var scratch [20]byte
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, value := range values {
|
||||
u := types.NewUint(value)
|
||||
n, err := u.MarshalTo(scratch[:])
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
b.SetBytes(int64(n))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkIntMarshal(b *testing.B) {
|
||||
var values = []int64{
|
||||
0,
|
||||
1,
|
||||
1 << 10,
|
||||
1<<10 - 3,
|
||||
1<<63 - 1,
|
||||
1<<32 - 7,
|
||||
1<<22 - 8,
|
||||
}
|
||||
|
||||
var scratch [20]byte
|
||||
b.ReportAllocs()
|
||||
for i := 0; i < b.N; i++ {
|
||||
for _, value := range values {
|
||||
in := types.NewInt(value)
|
||||
n, err := in.MarshalTo(scratch[:])
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
b.SetBytes(int64(n))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-2
@@ -5,6 +5,13 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec/types"
|
||||
)
|
||||
|
||||
const (
|
||||
// MsgInterfaceProtoName defines the protobuf name of the cosmos Msg interface
|
||||
MsgInterfaceProtoName = "cosmos.base.v1beta1.Msg"
|
||||
// ServiceMsgInterfaceProtoName defines the protobuf name of the cosmos MsgRequest interface
|
||||
ServiceMsgInterfaceProtoName = "cosmos.base.v1beta1.ServiceMsg"
|
||||
)
|
||||
|
||||
// RegisterLegacyAminoCodec registers the sdk message type.
|
||||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
cdc.RegisterInterface((*Msg)(nil), nil)
|
||||
@@ -13,8 +20,8 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
|
||||
// RegisterInterfaces registers the sdk message type.
|
||||
func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
registry.RegisterInterface("cosmos.base.v1beta1.Msg", (*Msg)(nil))
|
||||
registry.RegisterInterface(MsgInterfaceProtoName, (*Msg)(nil))
|
||||
// the interface name for MsgRequest is ServiceMsg because this is most useful for clients
|
||||
// to understand - it will be the way for clients to introspect on available Msg service methods
|
||||
registry.RegisterInterface("cosmos.base.v1beta1.ServiceMsg", (*MsgRequest)(nil))
|
||||
registry.RegisterInterface(ServiceMsgInterfaceProtoName, (*MsgRequest)(nil))
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ func BenchmarkCoinsAdditionIntersect(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) {
|
||||
return func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
coinsA := Coins(make([]Coin, numCoinsA))
|
||||
coinsB := Coins(make([]Coin, numCoinsB))
|
||||
|
||||
@@ -43,6 +44,7 @@ func BenchmarkCoinsAdditionNoIntersect(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) {
|
||||
return func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
coinsA := Coins(make([]Coin, numCoinsA))
|
||||
coinsB := Coins(make([]Coin, numCoinsB))
|
||||
|
||||
|
||||
+38
-11
@@ -2,6 +2,7 @@ package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
@@ -18,9 +19,13 @@ type Config struct {
|
||||
txEncoder TxEncoder
|
||||
addressVerifier func([]byte) error
|
||||
mtx sync.RWMutex
|
||||
coinType uint32
|
||||
sealed bool
|
||||
sealedch chan struct{}
|
||||
|
||||
// SLIP-44 related
|
||||
purpose uint32
|
||||
coinType uint32
|
||||
|
||||
sealed bool
|
||||
sealedch chan struct{}
|
||||
}
|
||||
|
||||
// cosmos-sdk wide global singleton
|
||||
@@ -41,9 +46,11 @@ func NewConfig() *Config {
|
||||
"validator_pub": Bech32PrefixValPub,
|
||||
"consensus_pub": Bech32PrefixConsPub,
|
||||
},
|
||||
coinType: CoinType,
|
||||
fullFundraiserPath: FullFundraiserPath,
|
||||
txEncoder: nil,
|
||||
|
||||
purpose: Purpose,
|
||||
coinType: CoinType,
|
||||
txEncoder: nil,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,18 +119,26 @@ func (config *Config) SetAddressVerifier(addressVerifier func([]byte) error) {
|
||||
config.addressVerifier = addressVerifier
|
||||
}
|
||||
|
||||
// Set the FullFundraiserPath (BIP44Prefix) on the config.
|
||||
//
|
||||
// Deprecated: This method is supported for backward compatibility only and will be removed in a future release. Use SetPurpose and SetCoinType instead.
|
||||
func (config *Config) SetFullFundraiserPath(fullFundraiserPath string) {
|
||||
config.assertNotSealed()
|
||||
config.fullFundraiserPath = fullFundraiserPath
|
||||
}
|
||||
|
||||
// Set the BIP-0044 Purpose code on the config
|
||||
func (config *Config) SetPurpose(purpose uint32) {
|
||||
config.assertNotSealed()
|
||||
config.purpose = purpose
|
||||
}
|
||||
|
||||
// Set the BIP-0044 CoinType code on the config
|
||||
func (config *Config) SetCoinType(coinType uint32) {
|
||||
config.assertNotSealed()
|
||||
config.coinType = coinType
|
||||
}
|
||||
|
||||
// Set the FullFundraiserPath (BIP44Prefix) on the config
|
||||
func (config *Config) SetFullFundraiserPath(fullFundraiserPath string) {
|
||||
config.assertNotSealed()
|
||||
config.fullFundraiserPath = fullFundraiserPath
|
||||
}
|
||||
|
||||
// Seal seals the config such that the config state could not be modified further
|
||||
func (config *Config) Seal() *Config {
|
||||
config.mtx.Lock()
|
||||
@@ -181,16 +196,28 @@ func (config *Config) GetAddressVerifier() func([]byte) error {
|
||||
return config.addressVerifier
|
||||
}
|
||||
|
||||
// GetPurpose returns the BIP-0044 Purpose code on the config.
|
||||
func (config *Config) GetPurpose() uint32 {
|
||||
return config.purpose
|
||||
}
|
||||
|
||||
// GetCoinType returns the BIP-0044 CoinType code on the config.
|
||||
func (config *Config) GetCoinType() uint32 {
|
||||
return config.coinType
|
||||
}
|
||||
|
||||
// GetFullFundraiserPath returns the BIP44Prefix.
|
||||
//
|
||||
// Deprecated: This method is supported for backward compatibility only and will be removed in a future release. Use GetFullBIP44Path instead.
|
||||
func (config *Config) GetFullFundraiserPath() string {
|
||||
return config.fullFundraiserPath
|
||||
}
|
||||
|
||||
// GetFullBIP44Path returns the BIP44Prefix.
|
||||
func (config *Config) GetFullBIP44Path() string {
|
||||
return fmt.Sprintf("m/%d'/%d'/0'/0/0", config.purpose, config.coinType)
|
||||
}
|
||||
|
||||
func KeyringServiceName() string {
|
||||
if len(version.Name) == 0 {
|
||||
return DefaultKeyringServiceName
|
||||
|
||||
@@ -17,6 +17,18 @@ func TestConfigTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(configTestSuite))
|
||||
}
|
||||
|
||||
func (s *contextTestSuite) TestConfig_SetPurpose() {
|
||||
config := sdk.NewConfig()
|
||||
config.SetPurpose(44)
|
||||
s.Require().Equal(uint32(44), config.GetPurpose())
|
||||
|
||||
config.SetPurpose(0)
|
||||
s.Require().Equal(uint32(0), config.GetPurpose())
|
||||
|
||||
config.Seal()
|
||||
s.Require().Panics(func() { config.SetPurpose(10) })
|
||||
}
|
||||
|
||||
func (s *configTestSuite) TestConfig_SetCoinType() {
|
||||
config := sdk.NewConfig()
|
||||
config.SetCoinType(1)
|
||||
|
||||
+3
-14
@@ -8,13 +8,11 @@ import (
|
||||
"github.com/golang/mock/gomock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
dbm "github.com/tendermint/tm-db"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
"github.com/cosmos/cosmos-sdk/tests/mocks"
|
||||
"github.com/cosmos/cosmos-sdk/testutil"
|
||||
"github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
@@ -26,15 +24,6 @@ func TestContextTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(contextTestSuite))
|
||||
}
|
||||
|
||||
func (s *contextTestSuite) defaultContext(key types.StoreKey) types.Context {
|
||||
db := dbm.NewMemDB()
|
||||
cms := store.NewCommitMultiStore(db)
|
||||
cms.MountStoreWithDB(key, types.StoreTypeIAVL, db)
|
||||
s.Require().NoError(cms.LoadLatestVersion())
|
||||
ctx := types.NewContext(cms, tmproto.Header{}, false, log.NewNopLogger())
|
||||
return ctx
|
||||
}
|
||||
|
||||
func (s *contextTestSuite) TestCacheContext() {
|
||||
key := types.NewKVStoreKey(s.T().Name() + "_TestCacheContext")
|
||||
k1 := []byte("hello")
|
||||
@@ -42,7 +31,7 @@ func (s *contextTestSuite) TestCacheContext() {
|
||||
k2 := []byte("key")
|
||||
v2 := []byte("value")
|
||||
|
||||
ctx := s.defaultContext(key)
|
||||
ctx := testutil.DefaultContext(key, types.NewTransientStoreKey("transient_"+s.T().Name()))
|
||||
store := ctx.KVStore(key)
|
||||
store.Set(k1, v1)
|
||||
s.Require().Equal(v1, store.Get(k1))
|
||||
@@ -64,7 +53,7 @@ func (s *contextTestSuite) TestCacheContext() {
|
||||
|
||||
func (s *contextTestSuite) TestLogContext() {
|
||||
key := types.NewKVStoreKey(s.T().Name())
|
||||
ctx := s.defaultContext(key)
|
||||
ctx := testutil.DefaultContext(key, types.NewTransientStoreKey("transient_"+s.T().Name()))
|
||||
ctrl := gomock.NewController(s.T())
|
||||
s.T().Cleanup(ctrl.Finish)
|
||||
|
||||
|
||||
+2
-13
@@ -80,8 +80,6 @@ func precisionMultiplier(prec int64) *big.Int {
|
||||
return precisionMultipliers[prec]
|
||||
}
|
||||
|
||||
//______________________________________________________________________________________________
|
||||
|
||||
// create a new Dec from integer assuming whole number
|
||||
func NewDec(i int64) Dec {
|
||||
return NewDecWithPrec(i, 0)
|
||||
@@ -195,8 +193,6 @@ func MustNewDecFromStr(s string) Dec {
|
||||
return dec
|
||||
}
|
||||
|
||||
//______________________________________________________________________________________________
|
||||
//nolint
|
||||
func (d Dec) IsNil() bool { return d.i == nil } // is decimal nil
|
||||
func (d Dec) IsZero() bool { return (d.i).Sign() == 0 } // is equal to zero
|
||||
func (d Dec) IsNegative() bool { return (d.i).Sign() == -1 } // is negative
|
||||
@@ -215,8 +211,8 @@ func (d Dec) BigInt() *big.Int {
|
||||
return nil
|
||||
}
|
||||
|
||||
copy := new(big.Int)
|
||||
return copy.Set(d.i)
|
||||
cp := new(big.Int)
|
||||
return cp.Set(d.i)
|
||||
}
|
||||
|
||||
// addition
|
||||
@@ -561,8 +557,6 @@ func (d Dec) RoundInt() Int {
|
||||
return NewIntFromBigInt(chopPrecisionAndRoundNonMutative(d.i))
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
|
||||
// similar to chopPrecisionAndRound, but always rounds down
|
||||
func chopPrecisionAndTruncate(d *big.Int) *big.Int {
|
||||
return d.Quo(d, precisionReuse)
|
||||
@@ -612,8 +606,6 @@ func (d Dec) Ceil() Dec {
|
||||
return NewDecFromBigInt(quo.Add(quo, oneInt))
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
|
||||
// MaxSortableDec is the largest Dec that can be passed into SortableDecBytes()
|
||||
// Its negative form is the least Dec that can be passed in.
|
||||
var MaxSortableDec = OneDec().Quo(SmallestDec())
|
||||
@@ -648,8 +640,6 @@ func SortableDecBytes(dec Dec) []byte {
|
||||
return []byte(fmt.Sprintf(fmt.Sprintf("%%0%ds", Precision*2+1), dec.String()))
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
|
||||
// reuse nil values
|
||||
var nilJSON []byte
|
||||
|
||||
@@ -758,7 +748,6 @@ func (dp DecProto) String() string {
|
||||
return dp.Dec.String()
|
||||
}
|
||||
|
||||
//___________________________________________________________________________________
|
||||
// helpers
|
||||
|
||||
// test if two decimal arrays are equal
|
||||
|
||||
@@ -29,8 +29,6 @@ func (s *decimalTestSuite) mustNewDecFromStr(str string) (d sdk.Dec) {
|
||||
return d
|
||||
}
|
||||
|
||||
//_______________________________________
|
||||
|
||||
func (s *decimalTestSuite) TestNewDecFromStr() {
|
||||
largeBigInt, success := new(big.Int).SetString("3144605511029693144278234343371835", 10)
|
||||
s.Require().True(success)
|
||||
|
||||
@@ -15,7 +15,6 @@ const UndefinedCodespace = "undefined"
|
||||
|
||||
var (
|
||||
// errInternal should never be exposed, but we reserve this code for non-specified errors
|
||||
//nolint
|
||||
errInternal = Register(UndefinedCodespace, 1, "internal")
|
||||
|
||||
// ErrTxDecode is returned if we cannot parse a transaction
|
||||
@@ -258,6 +257,14 @@ func (e *Error) Is(err error) bool {
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap extends this error with an additional information.
|
||||
// It's a handy function to call Wrap with sdk errors.
|
||||
func (e Error) Wrap(desc string) error { return Wrap(e, desc) }
|
||||
|
||||
// Wrapf extends this error with an additional information.
|
||||
// It's a handy function to call Wrapf with sdk errors.
|
||||
func (e Error) Wrapf(desc string, args ...interface{}) error { return Wrapf(e, desc, args...) }
|
||||
|
||||
func isNilErr(err error) bool {
|
||||
// Reflect usage is necessary to correctly compare with
|
||||
// a nil implementation of an error.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package errors
|
||||
|
||||
import "fmt"
|
||||
|
||||
// AssertNil panics on error
|
||||
// Should be only used with interface methods, which require return error, but the
|
||||
// error is always nil
|
||||
func AssertNil(err error) {
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("logic error - this should never happen. %w", err))
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -375,7 +375,7 @@ func (i *Int) MarshalTo(data []byte) (n int, err error) {
|
||||
if i.i == nil {
|
||||
i.i = new(big.Int)
|
||||
}
|
||||
if len(i.i.Bytes()) == 0 {
|
||||
if i.i.BitLen() == 0 { // The value 0
|
||||
copy(data, []byte{0x30})
|
||||
return 1, nil
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
@@ -385,3 +386,36 @@ func (s *intTestSuite) TestIntEq() {
|
||||
_, resp, _, _, _ = sdk.IntEq(s.T(), sdk.OneInt(), sdk.ZeroInt())
|
||||
s.Require().False(resp)
|
||||
}
|
||||
|
||||
func TestRoundTripMarshalToInt(t *testing.T) {
|
||||
var values = []int64{
|
||||
0,
|
||||
1,
|
||||
1 << 10,
|
||||
1<<10 - 3,
|
||||
1<<63 - 1,
|
||||
1<<32 - 7,
|
||||
1<<22 - 8,
|
||||
}
|
||||
|
||||
for _, value := range values {
|
||||
value := value
|
||||
t.Run(fmt.Sprintf("%d", value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var scratch [20]byte
|
||||
iv := sdk.NewInt(value)
|
||||
n, err := iv.MarshalTo(scratch[:])
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rt := new(sdk.Int)
|
||||
if err := rt.Unmarshal(scratch[:n]); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !rt.Equal(iv) {
|
||||
t.Fatalf("roundtrip=%q != original=%q", rt, iv)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -23,4 +23,6 @@ func (kvs Pairs) Less(i, j int) bool {
|
||||
}
|
||||
|
||||
func (kvs Pairs) Swap(i, j int) { kvs.Pairs[i], kvs.Pairs[j] = kvs.Pairs[j], kvs.Pairs[i] }
|
||||
func (kvs Pairs) Sort() { sort.Sort(kvs) }
|
||||
|
||||
// Sort invokes sort.Sort on kvs.
|
||||
func (kvs Pairs) Sort() { sort.Sort(kvs) }
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
package kv
|
||||
|
||||
// This code was copied from golang.org/pkg/container/list, but specially adapted
|
||||
// for use with kv.Pair to avoid the type assertion CPU expense of using Value with
|
||||
// an interface, per https://github.com/cosmos/cosmos-sdk/issues/8810
|
||||
//
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Element is an element of a linked list.
|
||||
type Element struct {
|
||||
// Next and previous pointers in the doubly-linked list of elements.
|
||||
// To simplify the implementation, internally a list l is implemented
|
||||
// as a ring, such that &l.root is both the next element of the last
|
||||
// list element (l.Back()) and the previous element of the first list
|
||||
// element (l.Front()).
|
||||
next, prev *Element
|
||||
|
||||
// The list to which this element belongs.
|
||||
list *List
|
||||
|
||||
// The value stored with this element.
|
||||
Value *Pair
|
||||
}
|
||||
|
||||
// Next returns the next list element or nil.
|
||||
func (e *Element) Next() *Element {
|
||||
if p := e.next; e.list != nil && p != &e.list.root {
|
||||
return p
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Prev returns the previous list element or nil.
|
||||
func (e *Element) Prev() *Element {
|
||||
if p := e.prev; e.list != nil && p != &e.list.root {
|
||||
return p
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// List represents a doubly linked list.
|
||||
// The zero value for List is an empty list ready to use.
|
||||
type List struct {
|
||||
root Element // sentinel list element, only &root, root.prev, and root.next are used
|
||||
len int // current list length excluding (this) sentinel element
|
||||
}
|
||||
|
||||
// Init initializes or clears list l.
|
||||
func (l *List) Init() *List {
|
||||
l.root.next = &l.root
|
||||
l.root.prev = &l.root
|
||||
l.len = 0
|
||||
return l
|
||||
}
|
||||
|
||||
// NewList returns an initialized list.
|
||||
func NewList() *List { return new(List).Init() }
|
||||
|
||||
// Len returns the number of elements of list l.
|
||||
// The complexity is O(1).
|
||||
func (l *List) Len() int { return l.len }
|
||||
|
||||
// Front returns the first element of list l or nil if the list is empty.
|
||||
func (l *List) Front() *Element {
|
||||
if l.len == 0 {
|
||||
return nil
|
||||
}
|
||||
return l.root.next
|
||||
}
|
||||
|
||||
// Back returns the last element of list l or nil if the list is empty.
|
||||
func (l *List) Back() *Element {
|
||||
if l.len == 0 {
|
||||
return nil
|
||||
}
|
||||
return l.root.prev
|
||||
}
|
||||
|
||||
// lazyInit lazily initializes a zero List value.
|
||||
func (l *List) lazyInit() {
|
||||
if l.root.next == nil {
|
||||
l.Init()
|
||||
}
|
||||
}
|
||||
|
||||
// insert inserts e after at, increments l.len, and returns e.
|
||||
func (l *List) insert(e, at *Element) *Element {
|
||||
e.prev = at
|
||||
e.next = at.next
|
||||
e.prev.next = e
|
||||
e.next.prev = e
|
||||
e.list = l
|
||||
l.len++
|
||||
return e
|
||||
}
|
||||
|
||||
// insertValue is a convenience wrapper for insert(&Element{Value: v}, at).
|
||||
func (l *List) insertValue(v *Pair, at *Element) *Element {
|
||||
return l.insert(&Element{Value: v}, at)
|
||||
}
|
||||
|
||||
// remove removes e from its list, decrements l.len, and returns e.
|
||||
func (l *List) remove(e *Element) *Element {
|
||||
e.prev.next = e.next
|
||||
e.next.prev = e.prev
|
||||
e.next = nil // avoid memory leaks
|
||||
e.prev = nil // avoid memory leaks
|
||||
e.list = nil
|
||||
l.len--
|
||||
return e
|
||||
}
|
||||
|
||||
// move moves e to next to at and returns e.
|
||||
// nolint: unparam
|
||||
func (l *List) move(e, at *Element) *Element {
|
||||
if e == at {
|
||||
return e
|
||||
}
|
||||
e.prev.next = e.next
|
||||
e.next.prev = e.prev
|
||||
|
||||
e.prev = at
|
||||
e.next = at.next
|
||||
e.prev.next = e
|
||||
e.next.prev = e
|
||||
|
||||
return e
|
||||
}
|
||||
|
||||
// Remove removes e from l if e is an element of list l.
|
||||
// It returns the element value e.Value.
|
||||
// The element must not be nil.
|
||||
func (l *List) Remove(e *Element) *Pair {
|
||||
if e.list == l {
|
||||
// if e.list == l, l must have been initialized when e was inserted
|
||||
// in l or l == nil (e is a zero Element) and l.remove will crash
|
||||
l.remove(e)
|
||||
}
|
||||
return e.Value
|
||||
}
|
||||
|
||||
// PushFront inserts a new element e with value v at the front of list l and returns e.
|
||||
func (l *List) PushFront(v *Pair) *Element {
|
||||
l.lazyInit()
|
||||
return l.insertValue(v, &l.root)
|
||||
}
|
||||
|
||||
// PushBack inserts a new element e with value v at the back of list l and returns e.
|
||||
func (l *List) PushBack(v *Pair) *Element {
|
||||
l.lazyInit()
|
||||
return l.insertValue(v, l.root.prev)
|
||||
}
|
||||
|
||||
// InsertBefore inserts a new element e with value v immediately before mark and returns e.
|
||||
// If mark is not an element of l, the list is not modified.
|
||||
// The mark must not be nil.
|
||||
func (l *List) InsertBefore(v *Pair, mark *Element) *Element {
|
||||
if mark.list != l {
|
||||
return nil
|
||||
}
|
||||
// see comment in List.Remove about initialization of l
|
||||
return l.insertValue(v, mark.prev)
|
||||
}
|
||||
|
||||
// InsertAfter inserts a new element e with value v immediately after mark and returns e.
|
||||
// If mark is not an element of l, the list is not modified.
|
||||
// The mark must not be nil.
|
||||
func (l *List) InsertAfter(v *Pair, mark *Element) *Element {
|
||||
if mark.list != l {
|
||||
return nil
|
||||
}
|
||||
// see comment in List.Remove about initialization of l
|
||||
return l.insertValue(v, mark)
|
||||
}
|
||||
|
||||
// MoveToFront moves element e to the front of list l.
|
||||
// If e is not an element of l, the list is not modified.
|
||||
// The element must not be nil.
|
||||
func (l *List) MoveToFront(e *Element) {
|
||||
if e.list != l || l.root.next == e {
|
||||
return
|
||||
}
|
||||
// see comment in List.Remove about initialization of l
|
||||
l.move(e, &l.root)
|
||||
}
|
||||
|
||||
// MoveToBack moves element e to the back of list l.
|
||||
// If e is not an element of l, the list is not modified.
|
||||
// The element must not be nil.
|
||||
func (l *List) MoveToBack(e *Element) {
|
||||
if e.list != l || l.root.prev == e {
|
||||
return
|
||||
}
|
||||
// see comment in List.Remove about initialization of l
|
||||
l.move(e, l.root.prev)
|
||||
}
|
||||
|
||||
// MoveBefore moves element e to its new position before mark.
|
||||
// If e or mark is not an element of l, or e == mark, the list is not modified.
|
||||
// The element and mark must not be nil.
|
||||
func (l *List) MoveBefore(e, mark *Element) {
|
||||
if e.list != l || e == mark || mark.list != l {
|
||||
return
|
||||
}
|
||||
l.move(e, mark.prev)
|
||||
}
|
||||
|
||||
// MoveAfter moves element e to its new position after mark.
|
||||
// If e or mark is not an element of l, or e == mark, the list is not modified.
|
||||
// The element and mark must not be nil.
|
||||
func (l *List) MoveAfter(e, mark *Element) {
|
||||
if e.list != l || e == mark || mark.list != l {
|
||||
return
|
||||
}
|
||||
l.move(e, mark)
|
||||
}
|
||||
|
||||
// PushBackList inserts a copy of another list at the back of list l.
|
||||
// The lists l and other may be the same. They must not be nil.
|
||||
func (l *List) PushBackList(other *List) {
|
||||
l.lazyInit()
|
||||
for i, e := other.Len(), other.Front(); i > 0; i, e = i-1, e.Next() {
|
||||
l.insertValue(e.Value, l.root.prev)
|
||||
}
|
||||
}
|
||||
|
||||
// PushFrontList inserts a copy of another list at the front of list l.
|
||||
// The lists l and other may be the same. They must not be nil.
|
||||
func (l *List) PushFrontList(other *List) {
|
||||
l.lazyInit()
|
||||
for i, e := other.Len(), other.Back(); i > 0; i, e = i-1, e.Prev() {
|
||||
l.insertValue(e.Value, &l.root)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
package module
|
||||
|
||||
import "github.com/gogo/protobuf/grpc"
|
||||
import (
|
||||
"github.com/gogo/protobuf/grpc"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
// Configurator provides the hooks to allow modules to configure and register
|
||||
// their services in the RegisterServices method. It is designed to eventually
|
||||
@@ -15,16 +20,34 @@ type Configurator interface {
|
||||
// QueryServer returns a grpc.Server instance which allows registering services
|
||||
// that will be exposed as gRPC services as well as ABCI query handlers.
|
||||
QueryServer() grpc.Server
|
||||
|
||||
// RegisterMigration registers an in-place store migration for a module. The
|
||||
// handler is a migration script to perform in-place migrations from version
|
||||
// `forVersion` to version `forVersion+1`.
|
||||
//
|
||||
// EACH TIME a module's ConsensusVersion increments, a new migration MUST
|
||||
// be registered using this function. If a migration handler is missing for
|
||||
// a particular function, the upgrade logic (see RunMigrations function)
|
||||
// will panic. If the ConsensusVersion bump does not introduce any store
|
||||
// changes, then a no-op function must be registered here.
|
||||
RegisterMigration(moduleName string, forVersion uint64, handler MigrationHandler) error
|
||||
}
|
||||
|
||||
type configurator struct {
|
||||
msgServer grpc.Server
|
||||
queryServer grpc.Server
|
||||
|
||||
// migrations is a map of moduleName -> forVersion -> migration script handler
|
||||
migrations map[string]map[uint64]MigrationHandler
|
||||
}
|
||||
|
||||
// NewConfigurator returns a new Configurator instance
|
||||
func NewConfigurator(msgServer grpc.Server, queryServer grpc.Server) Configurator {
|
||||
return configurator{msgServer: msgServer, queryServer: queryServer}
|
||||
return configurator{
|
||||
msgServer: msgServer,
|
||||
queryServer: queryServer,
|
||||
migrations: map[string]map[uint64]MigrationHandler{},
|
||||
}
|
||||
}
|
||||
|
||||
var _ Configurator = configurator{}
|
||||
@@ -38,3 +61,51 @@ func (c configurator) MsgServer() grpc.Server {
|
||||
func (c configurator) QueryServer() grpc.Server {
|
||||
return c.queryServer
|
||||
}
|
||||
|
||||
// RegisterMigration implements the Configurator.RegisterMigration method
|
||||
func (c configurator) RegisterMigration(moduleName string, forVersion uint64, handler MigrationHandler) error {
|
||||
if forVersion == 0 {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidVersion, "module migration versions should start at 1")
|
||||
}
|
||||
|
||||
if c.migrations[moduleName] == nil {
|
||||
c.migrations[moduleName] = map[uint64]MigrationHandler{}
|
||||
}
|
||||
|
||||
if c.migrations[moduleName][forVersion] != nil {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrLogic, "another migration for module %s and version %d already exists", moduleName, forVersion)
|
||||
}
|
||||
|
||||
c.migrations[moduleName][forVersion] = handler
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// runModuleMigrations runs all in-place store migrations for one given module from a
|
||||
// version to another version.
|
||||
func (c configurator) runModuleMigrations(ctx sdk.Context, moduleName string, fromVersion, toVersion uint64) error {
|
||||
// No-op if toVersion is the initial version.
|
||||
if toVersion <= 1 {
|
||||
return nil
|
||||
}
|
||||
|
||||
moduleMigrationsMap, found := c.migrations[moduleName]
|
||||
if !found {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "no migrations found for module %s", moduleName)
|
||||
}
|
||||
|
||||
// Run in-place migrations for the module sequentially until toVersion.
|
||||
for i := fromVersion; i < toVersion; i++ {
|
||||
migrateFn, found := moduleMigrationsMap[i]
|
||||
if !found {
|
||||
return sdkerrors.Wrapf(sdkerrors.ErrNotFound, "no migration found for module %s from version %d to version %d", moduleName, i, i+1)
|
||||
}
|
||||
|
||||
err := migrateFn(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
+48
-8
@@ -40,10 +40,9 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
//__________________________________________________________________________________________
|
||||
|
||||
// AppModuleBasic is the standard form for basic non-dependant elements of an application module.
|
||||
type AppModuleBasic interface {
|
||||
Name() string
|
||||
@@ -145,8 +144,6 @@ func (bm BasicManager) AddQueryCommands(rootQueryCmd *cobra.Command) {
|
||||
}
|
||||
}
|
||||
|
||||
//_________________________________________________________
|
||||
|
||||
// AppModuleGenesis is the standard form for an application module genesis functions
|
||||
type AppModuleGenesis interface {
|
||||
AppModuleBasic
|
||||
@@ -174,13 +171,17 @@ type AppModule interface {
|
||||
// RegisterServices allows a module to register services
|
||||
RegisterServices(Configurator)
|
||||
|
||||
// ConsensusVersion is a sequence number for state-breaking change of the
|
||||
// module. It should be incremented on each consensus-breaking change
|
||||
// introduced by the module. To avoid wrong/empty versions, the initial version
|
||||
// should be set to 1.
|
||||
ConsensusVersion() uint64
|
||||
|
||||
// ABCI
|
||||
BeginBlock(sdk.Context, abci.RequestBeginBlock)
|
||||
EndBlock(sdk.Context, abci.RequestEndBlock) []abci.ValidatorUpdate
|
||||
}
|
||||
|
||||
//___________________________
|
||||
|
||||
// GenesisOnlyAppModule is an AppModule that only has import/export functionality
|
||||
type GenesisOnlyAppModule struct {
|
||||
AppModuleGenesis
|
||||
@@ -208,6 +209,9 @@ func (gam GenesisOnlyAppModule) LegacyQuerierHandler(*codec.LegacyAmino) sdk.Que
|
||||
// RegisterServices registers all services.
|
||||
func (gam GenesisOnlyAppModule) RegisterServices(Configurator) {}
|
||||
|
||||
// ConsensusVersion implements AppModule/ConsensusVersion.
|
||||
func (gam GenesisOnlyAppModule) ConsensusVersion() uint64 { return 1 }
|
||||
|
||||
// BeginBlock returns an empty module begin-block
|
||||
func (gam GenesisOnlyAppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {}
|
||||
|
||||
@@ -216,8 +220,6 @@ func (GenesisOnlyAppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []ab
|
||||
return []abci.ValidatorUpdate{}
|
||||
}
|
||||
|
||||
//____________________________________________________________________________
|
||||
|
||||
// Manager defines a module manager that provides the high level utility for managing and executing
|
||||
// operations for a group of modules
|
||||
type Manager struct {
|
||||
@@ -328,6 +330,32 @@ func (m *Manager) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) map[st
|
||||
return genesisData
|
||||
}
|
||||
|
||||
// MigrationHandler is the migration function that each module registers.
|
||||
type MigrationHandler func(sdk.Context) error
|
||||
|
||||
// VersionMap is a map of moduleName -> version, where version denotes the
|
||||
// version from which we should perform the migration for each module.
|
||||
type VersionMap map[string]uint64
|
||||
|
||||
// RunMigrations performs in-place store migrations for all modules.
|
||||
func (m Manager) RunMigrations(ctx sdk.Context, cfg Configurator, fromVM VersionMap) (VersionMap, error) {
|
||||
c, ok := cfg.(configurator)
|
||||
if !ok {
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "expected %T, got %T", configurator{}, cfg)
|
||||
}
|
||||
|
||||
updatedVM := make(VersionMap)
|
||||
for moduleName, module := range m.Modules {
|
||||
err := c.runModuleMigrations(ctx, moduleName, fromVM[moduleName], module.ConsensusVersion())
|
||||
updatedVM[moduleName] = module.ConsensusVersion()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return updatedVM, nil
|
||||
}
|
||||
|
||||
// BeginBlock performs begin block functionality for all modules. It creates a
|
||||
// child context with an event manager to aggregate events emitted from all
|
||||
// modules.
|
||||
@@ -369,3 +397,15 @@ func (m *Manager) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
|
||||
Events: ctx.EventManager().ABCIEvents(),
|
||||
}
|
||||
}
|
||||
|
||||
// GetVersionMap gets consensus version from all modules
|
||||
func (m *Manager) GetVersionMap() VersionMap {
|
||||
vermap := make(VersionMap)
|
||||
for _, v := range m.Modules {
|
||||
version := v.ConsensusVersion()
|
||||
name := v.Name()
|
||||
vermap[name] = version
|
||||
}
|
||||
|
||||
return vermap
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
@@ -28,11 +28,12 @@ func (s *paginationTestSuite) TestFilteredPaginations() {
|
||||
balances = append(balances, sdk.NewInt64Coin(denom, 250))
|
||||
}
|
||||
|
||||
balances = balances.Sort()
|
||||
addr1 := sdk.AccAddress([]byte("addr1"))
|
||||
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
|
||||
app.AccountKeeper.SetAccount(ctx, acc1)
|
||||
s.Require().NoError(app.BankKeeper.SetBalances(ctx, addr1, balances))
|
||||
store := ctx.KVStore(app.GetKey(authtypes.StoreKey))
|
||||
s.Require().NoError(simapp.FundAccount(app, ctx, addr1, balances))
|
||||
store := ctx.KVStore(app.GetKey(types.StoreKey))
|
||||
|
||||
// verify pagination with limit > total values
|
||||
pageReq := &query.PageRequest{Key: nil, Limit: 5, CountTotal: true}
|
||||
@@ -101,16 +102,18 @@ func ExampleFilteredPaginate() {
|
||||
denom := fmt.Sprintf("test%ddenom", i)
|
||||
balances = append(balances, sdk.NewInt64Coin(denom, 250))
|
||||
}
|
||||
|
||||
balances = balances.Sort()
|
||||
addr1 := sdk.AccAddress([]byte("addr1"))
|
||||
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
|
||||
app.AccountKeeper.SetAccount(ctx, acc1)
|
||||
err := app.BankKeeper.SetBalances(ctx, addr1, balances)
|
||||
err := simapp.FundAccount(app, ctx, addr1, balances)
|
||||
if err != nil { // should return no error
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
pageReq := &query.PageRequest{Key: nil, Limit: 1, CountTotal: true}
|
||||
store := ctx.KVStore(app.GetKey(authtypes.StoreKey))
|
||||
store := ctx.KVStore(app.GetKey(types.StoreKey))
|
||||
balancesStore := prefix.NewStore(store, types.BalancesPrefix)
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
|
||||
|
||||
@@ -19,9 +19,6 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
@@ -76,10 +73,11 @@ func (s *paginationTestSuite) TestPagination() {
|
||||
balances = append(balances, sdk.NewInt64Coin(denom, 100))
|
||||
}
|
||||
|
||||
balances = balances.Sort()
|
||||
addr1 := sdk.AccAddress(secp256k1.GenPrivKey().PubKey().Address())
|
||||
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
|
||||
app.AccountKeeper.SetAccount(ctx, acc1)
|
||||
s.Require().NoError(app.BankKeeper.SetBalances(ctx, addr1, balances))
|
||||
s.Require().NoError(simapp.FundAccount(app, ctx, addr1, balances))
|
||||
|
||||
s.T().Log("verify empty page request results a max of defaultLimit records and counts total records")
|
||||
pageReq := &query.PageRequest{}
|
||||
@@ -181,18 +179,19 @@ func ExamplePaginate() {
|
||||
balances = append(balances, sdk.NewInt64Coin(denom, 100))
|
||||
}
|
||||
|
||||
balances = balances.Sort()
|
||||
addr1 := sdk.AccAddress([]byte("addr1"))
|
||||
acc1 := app.AccountKeeper.NewAccountWithAddress(ctx, addr1)
|
||||
app.AccountKeeper.SetAccount(ctx, acc1)
|
||||
err := app.BankKeeper.SetBalances(ctx, addr1, balances)
|
||||
if err != nil {
|
||||
err := simapp.FundAccount(app, ctx, addr1, balances)
|
||||
if err != nil { // should return no error
|
||||
fmt.Println(err)
|
||||
}
|
||||
// Paginate example
|
||||
pageReq := &query.PageRequest{Key: nil, Limit: 1, CountTotal: true}
|
||||
request := types.NewQueryAllBalancesRequest(addr1, pageReq)
|
||||
balResult := sdk.NewCoins()
|
||||
authStore := ctx.KVStore(app.GetKey(authtypes.StoreKey))
|
||||
authStore := ctx.KVStore(app.GetKey(types.StoreKey))
|
||||
balancesStore := prefix.NewStore(authStore, types.BalancesPrefix)
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
pageRes, err := query.Paginate(accountStore, request.Pagination, func(key []byte, value []byte) error {
|
||||
@@ -222,20 +221,5 @@ func setupTest() (*simapp.SimApp, sdk.Context, codec.Marshaler) {
|
||||
|
||||
ms.LoadLatestVersion()
|
||||
|
||||
maccPerms := simapp.GetMaccPerms()
|
||||
maccPerms[holder] = nil
|
||||
maccPerms[authtypes.Burner] = []string{authtypes.Burner}
|
||||
maccPerms[authtypes.Minter] = []string{authtypes.Minter}
|
||||
maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking}
|
||||
maccPerms[randomPerm] = []string{"random"}
|
||||
app.AccountKeeper = authkeeper.NewAccountKeeper(
|
||||
appCodec, app.GetKey(authtypes.StoreKey), app.GetSubspace(authtypes.ModuleName),
|
||||
authtypes.ProtoBaseAccount, maccPerms,
|
||||
)
|
||||
app.BankKeeper = bankkeeper.NewBaseKeeper(
|
||||
appCodec, app.GetKey(authtypes.StoreKey), app.AccountKeeper,
|
||||
app.GetSubspace(types.ModuleName), make(map[string]bool),
|
||||
)
|
||||
|
||||
return app, ctx, appCodec
|
||||
}
|
||||
|
||||
+14
-2
@@ -1,6 +1,8 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
)
|
||||
|
||||
@@ -18,7 +20,7 @@ type MsgRequest interface {
|
||||
}
|
||||
|
||||
// ServiceMsg is the struct into which an Any whose typeUrl matches a service
|
||||
// method format (ex. `/cosmos.gov.Msg/SubmitProposal`) unpacks.
|
||||
// method format (ex. `/cosmos.gov.v1beta1.Msg/SubmitProposal`) unpacks.
|
||||
type ServiceMsg struct {
|
||||
// MethodName is the fully-qualified service method name.
|
||||
MethodName string
|
||||
@@ -44,7 +46,17 @@ func (msg ServiceMsg) ValidateBasic() error {
|
||||
|
||||
// GetSignBytes implements Msg.GetSignBytes method.
|
||||
func (msg ServiceMsg) GetSignBytes() []byte {
|
||||
panic("ServiceMsg does not have a GetSignBytes method")
|
||||
// Here, we're gracefully supporting Amino JSON for service
|
||||
// Msgs.
|
||||
// ref: https://github.com/cosmos/cosmos-sdk/issues/8346
|
||||
// If `msg` is a service Msg, then we cast its `Request` to a sdk.Msg
|
||||
// and call GetSignBytes on the `Request`.
|
||||
msgRequest, ok := msg.Request.(Msg)
|
||||
if !ok {
|
||||
panic(fmt.Errorf("cannot convert ServiceMsg request to sdk.Msg, got %T", msgRequest))
|
||||
}
|
||||
|
||||
return msgRequest.GetSignBytes()
|
||||
}
|
||||
|
||||
// GetSigners implements Msg.GetSigners method.
|
||||
|
||||
@@ -6,8 +6,8 @@ type Config struct {
|
||||
ParamsFile string // custom simulation params file which overrides any random params; cannot be used with genesis
|
||||
|
||||
ExportParamsPath string // custom file path to save the exported params JSON
|
||||
ExportParamsHeight int //height to which export the randomly generated params
|
||||
ExportStatePath string //custom file path to save the exported app state JSON
|
||||
ExportParamsHeight int // height to which export the randomly generated params
|
||||
ExportStatePath string // custom file path to save the exported app state JSON
|
||||
ExportStatsPath string // custom file path to save the exported simulation statistics JSON
|
||||
|
||||
Seed int64 // simulation random seed
|
||||
|
||||
@@ -125,8 +125,6 @@ func (om OperationMsg) LogEvent(eventLogger func(route, op, evResult string)) {
|
||||
eventLogger(om.Route, om.Name, pass)
|
||||
}
|
||||
|
||||
//________________________________________________________________________
|
||||
|
||||
// FutureOperation is an operation which will be ran at the beginning of the
|
||||
// provided BlockHeight. If both a BlockHeight and BlockTime are specified, it
|
||||
// will use the BlockHeight. In the (likely) event that multiple operations
|
||||
|
||||
+136
-48
@@ -11,6 +11,7 @@ import (
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
golang_proto "github.com/golang/protobuf/proto"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
@@ -22,6 +23,7 @@ import (
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = golang_proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
@@ -31,6 +33,38 @@ var _ = math.Inf
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// OrderBy defines the sorting order
|
||||
type OrderBy int32
|
||||
|
||||
const (
|
||||
// ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case.
|
||||
OrderBy_ORDER_BY_UNSPECIFIED OrderBy = 0
|
||||
// ORDER_BY_ASC defines ascending order
|
||||
OrderBy_ORDER_BY_ASC OrderBy = 1
|
||||
// ORDER_BY_DESC defines descending order
|
||||
OrderBy_ORDER_BY_DESC OrderBy = 2
|
||||
)
|
||||
|
||||
var OrderBy_name = map[int32]string{
|
||||
0: "ORDER_BY_UNSPECIFIED",
|
||||
1: "ORDER_BY_ASC",
|
||||
2: "ORDER_BY_DESC",
|
||||
}
|
||||
|
||||
var OrderBy_value = map[string]int32{
|
||||
"ORDER_BY_UNSPECIFIED": 0,
|
||||
"ORDER_BY_ASC": 1,
|
||||
"ORDER_BY_DESC": 2,
|
||||
}
|
||||
|
||||
func (x OrderBy) String() string {
|
||||
return proto.EnumName(OrderBy_name, int32(x))
|
||||
}
|
||||
|
||||
func (OrderBy) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_e0b00a618705eca7, []int{0}
|
||||
}
|
||||
|
||||
// BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method.
|
||||
type BroadcastMode int32
|
||||
|
||||
@@ -67,7 +101,7 @@ func (x BroadcastMode) String() string {
|
||||
}
|
||||
|
||||
func (BroadcastMode) EnumDescriptor() ([]byte, []int) {
|
||||
return fileDescriptor_e0b00a618705eca7, []int{0}
|
||||
return fileDescriptor_e0b00a618705eca7, []int{1}
|
||||
}
|
||||
|
||||
// GetTxsEventRequest is the request type for the Service.TxsByEvents
|
||||
@@ -77,6 +111,7 @@ type GetTxsEventRequest struct {
|
||||
Events []string `protobuf:"bytes,1,rep,name=events,proto3" json:"events,omitempty"`
|
||||
// pagination defines an pagination for the request.
|
||||
Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
|
||||
OrderBy OrderBy `protobuf:"varint,3,opt,name=order_by,json=orderBy,proto3,enum=cosmos.tx.v1beta1.OrderBy" json:"order_by,omitempty"`
|
||||
}
|
||||
|
||||
func (m *GetTxsEventRequest) Reset() { *m = GetTxsEventRequest{} }
|
||||
@@ -126,6 +161,13 @@ func (m *GetTxsEventRequest) GetPagination() *query.PageRequest {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *GetTxsEventRequest) GetOrderBy() OrderBy {
|
||||
if m != nil {
|
||||
return m.OrderBy
|
||||
}
|
||||
return OrderBy_ORDER_BY_UNSPECIFIED
|
||||
}
|
||||
|
||||
// GetTxsEventResponse is the response type for the Service.TxsByEvents
|
||||
// RPC method.
|
||||
type GetTxsEventResponse struct {
|
||||
@@ -499,67 +541,86 @@ func (m *GetTxResponse) GetTxResponse() *types.TxResponse {
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("cosmos.tx.v1beta1.OrderBy", OrderBy_name, OrderBy_value)
|
||||
golang_proto.RegisterEnum("cosmos.tx.v1beta1.OrderBy", OrderBy_name, OrderBy_value)
|
||||
proto.RegisterEnum("cosmos.tx.v1beta1.BroadcastMode", BroadcastMode_name, BroadcastMode_value)
|
||||
golang_proto.RegisterEnum("cosmos.tx.v1beta1.BroadcastMode", BroadcastMode_name, BroadcastMode_value)
|
||||
proto.RegisterType((*GetTxsEventRequest)(nil), "cosmos.tx.v1beta1.GetTxsEventRequest")
|
||||
golang_proto.RegisterType((*GetTxsEventRequest)(nil), "cosmos.tx.v1beta1.GetTxsEventRequest")
|
||||
proto.RegisterType((*GetTxsEventResponse)(nil), "cosmos.tx.v1beta1.GetTxsEventResponse")
|
||||
golang_proto.RegisterType((*GetTxsEventResponse)(nil), "cosmos.tx.v1beta1.GetTxsEventResponse")
|
||||
proto.RegisterType((*BroadcastTxRequest)(nil), "cosmos.tx.v1beta1.BroadcastTxRequest")
|
||||
golang_proto.RegisterType((*BroadcastTxRequest)(nil), "cosmos.tx.v1beta1.BroadcastTxRequest")
|
||||
proto.RegisterType((*BroadcastTxResponse)(nil), "cosmos.tx.v1beta1.BroadcastTxResponse")
|
||||
golang_proto.RegisterType((*BroadcastTxResponse)(nil), "cosmos.tx.v1beta1.BroadcastTxResponse")
|
||||
proto.RegisterType((*SimulateRequest)(nil), "cosmos.tx.v1beta1.SimulateRequest")
|
||||
golang_proto.RegisterType((*SimulateRequest)(nil), "cosmos.tx.v1beta1.SimulateRequest")
|
||||
proto.RegisterType((*SimulateResponse)(nil), "cosmos.tx.v1beta1.SimulateResponse")
|
||||
golang_proto.RegisterType((*SimulateResponse)(nil), "cosmos.tx.v1beta1.SimulateResponse")
|
||||
proto.RegisterType((*GetTxRequest)(nil), "cosmos.tx.v1beta1.GetTxRequest")
|
||||
golang_proto.RegisterType((*GetTxRequest)(nil), "cosmos.tx.v1beta1.GetTxRequest")
|
||||
proto.RegisterType((*GetTxResponse)(nil), "cosmos.tx.v1beta1.GetTxResponse")
|
||||
golang_proto.RegisterType((*GetTxResponse)(nil), "cosmos.tx.v1beta1.GetTxResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("cosmos/tx/v1beta1/service.proto", fileDescriptor_e0b00a618705eca7) }
|
||||
func init() {
|
||||
golang_proto.RegisterFile("cosmos/tx/v1beta1/service.proto", fileDescriptor_e0b00a618705eca7)
|
||||
}
|
||||
|
||||
var fileDescriptor_e0b00a618705eca7 = []byte{
|
||||
// 737 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcd, 0x4f, 0x13, 0x41,
|
||||
0x14, 0xef, 0xb6, 0xc8, 0xc7, 0x2b, 0x68, 0x1d, 0x10, 0x6b, 0xd1, 0xa5, 0x2c, 0x16, 0x08, 0x89,
|
||||
0xbb, 0xa1, 0x7a, 0x20, 0xc6, 0xc4, 0xd0, 0x52, 0x08, 0x51, 0x3e, 0xb2, 0xc5, 0x83, 0xc6, 0xa4,
|
||||
0x99, 0xb6, 0xc3, 0xb2, 0x91, 0xee, 0x94, 0xce, 0x94, 0x2c, 0x01, 0x62, 0xe2, 0xd1, 0x93, 0x89,
|
||||
0xff, 0x94, 0x47, 0x12, 0x2f, 0x1e, 0x0d, 0xf8, 0x47, 0x78, 0x34, 0x3b, 0x3b, 0x6d, 0xb7, 0x65,
|
||||
0x0b, 0xc4, 0x13, 0x33, 0xcc, 0xef, 0xfd, 0x3e, 0xde, 0x9b, 0x9d, 0xc2, 0x74, 0x85, 0xb2, 0x1a,
|
||||
0x65, 0x06, 0x77, 0x8d, 0xa3, 0xa5, 0x32, 0xe1, 0x78, 0xc9, 0x60, 0xa4, 0x71, 0x64, 0x57, 0x88,
|
||||
0x5e, 0x6f, 0x50, 0x4e, 0xd1, 0x7d, 0x1f, 0xa0, 0x73, 0x57, 0x97, 0x80, 0xd4, 0x63, 0x8b, 0x52,
|
||||
0xeb, 0x80, 0x18, 0xb8, 0x6e, 0x1b, 0xd8, 0x71, 0x28, 0xc7, 0xdc, 0xa6, 0x0e, 0xf3, 0x0b, 0x52,
|
||||
0xb3, 0x92, 0xb1, 0x8c, 0x19, 0x31, 0x70, 0xb9, 0x62, 0xb7, 0x89, 0xbd, 0x8d, 0x04, 0xa5, 0xae,
|
||||
0xca, 0x72, 0x57, 0x9e, 0x4d, 0x58, 0xd4, 0xa2, 0x62, 0x69, 0x78, 0x2b, 0xf9, 0xdf, 0xc5, 0x20,
|
||||
0xed, 0x61, 0x93, 0x34, 0x8e, 0xdb, 0x95, 0x75, 0x6c, 0xd9, 0x8e, 0xf0, 0xe0, 0x63, 0x35, 0x0e,
|
||||
0x68, 0x9d, 0xf0, 0x5d, 0x97, 0x15, 0x8e, 0x88, 0xc3, 0x4d, 0x72, 0xd8, 0x24, 0x8c, 0xa3, 0x49,
|
||||
0x18, 0x24, 0xde, 0x9e, 0x25, 0x95, 0x74, 0x6c, 0x61, 0xc4, 0x94, 0x3b, 0xb4, 0x06, 0xd0, 0x61,
|
||||
0x48, 0x46, 0xd3, 0xca, 0x42, 0x3c, 0x3b, 0xa7, 0xcb, 0xd8, 0x9e, 0x9c, 0x2e, 0xe4, 0x5a, 0xf1,
|
||||
0xf5, 0x1d, 0x6c, 0x11, 0xc9, 0x69, 0x06, 0x2a, 0xb5, 0x73, 0x05, 0xc6, 0xbb, 0x64, 0x59, 0x9d,
|
||||
0x3a, 0x8c, 0xa0, 0x79, 0x88, 0x71, 0xd7, 0x17, 0x8d, 0x67, 0x1f, 0xe8, 0x57, 0xfa, 0xa9, 0xef,
|
||||
0xba, 0xa6, 0x87, 0x40, 0xeb, 0x30, 0xca, 0xdd, 0x52, 0x43, 0xd6, 0xb1, 0x64, 0x54, 0x54, 0x3c,
|
||||
0xed, 0xb2, 0x22, 0x7a, 0x18, 0x28, 0x94, 0x60, 0x33, 0xce, 0xdb, 0x6b, 0x8f, 0x28, 0x98, 0x28,
|
||||
0x26, 0x12, 0xcd, 0xdf, 0x98, 0x48, 0x32, 0x05, 0x23, 0x11, 0x40, 0xb9, 0x06, 0xc5, 0xd5, 0x0a,
|
||||
0x66, 0xdc, 0x13, 0xf3, 0x1b, 0xf9, 0x08, 0x86, 0xb9, 0x5b, 0x2a, 0x1f, 0x73, 0xe2, 0xa5, 0x52,
|
||||
0x16, 0x46, 0xcd, 0x21, 0xee, 0xe6, 0xbc, 0x2d, 0x7a, 0x01, 0x03, 0x35, 0x5a, 0x25, 0xa2, 0x8b,
|
||||
0x77, 0xb3, 0xe9, 0x90, 0xb0, 0x6d, 0xbe, 0x4d, 0x5a, 0x25, 0xa6, 0x40, 0x6b, 0x1f, 0x61, 0xbc,
|
||||
0x4b, 0x46, 0x36, 0xae, 0x00, 0xf1, 0x40, 0x3f, 0x84, 0xd4, 0x6d, 0xdb, 0x01, 0x9d, 0x76, 0x68,
|
||||
0xcb, 0x70, 0xaf, 0x68, 0xd7, 0x9a, 0x07, 0x98, 0xb7, 0xc6, 0x86, 0x32, 0x10, 0xe5, 0xae, 0x24,
|
||||
0xec, 0x33, 0x91, 0x28, 0x77, 0xb5, 0xaf, 0x0a, 0x24, 0x3a, 0xa5, 0xd2, 0xd5, 0x2b, 0x18, 0xb6,
|
||||
0x30, 0x2b, 0xd9, 0xce, 0x1e, 0x95, 0x0c, 0x33, 0xfd, 0x2d, 0xad, 0x63, 0xb6, 0xe1, 0xec, 0x51,
|
||||
0x73, 0xc8, 0xf2, 0x17, 0x68, 0x19, 0x06, 0x1b, 0x84, 0x35, 0x0f, 0xb8, 0xbc, 0x68, 0xe9, 0xfe,
|
||||
0xb5, 0xa6, 0xc0, 0x99, 0x12, 0xaf, 0x69, 0x30, 0x2a, 0x6e, 0x57, 0x2b, 0x03, 0x82, 0x81, 0x7d,
|
||||
0xcc, 0xf6, 0x85, 0x87, 0x11, 0x53, 0xac, 0xb5, 0x33, 0x18, 0x93, 0x18, 0x69, 0xf6, 0x76, 0x41,
|
||||
0x7b, 0x3b, 0x1d, 0xfd, 0xbf, 0x4e, 0x2f, 0x9e, 0xc2, 0x58, 0xd7, 0x78, 0x91, 0x0a, 0xa9, 0x9c,
|
||||
0xb9, 0xbd, 0xb2, 0x9a, 0x5f, 0x29, 0xee, 0x96, 0x36, 0xb7, 0x57, 0x0b, 0xa5, 0x77, 0x5b, 0xc5,
|
||||
0x9d, 0x42, 0x7e, 0x63, 0x6d, 0xa3, 0xb0, 0x9a, 0x88, 0xa0, 0x24, 0x4c, 0xf4, 0x9c, 0xe7, 0xde,
|
||||
0x6e, 0xe7, 0xdf, 0x24, 0x14, 0xf4, 0x10, 0xc6, 0x7b, 0x4e, 0x8a, 0xef, 0xb7, 0xf2, 0x89, 0x68,
|
||||
0x48, 0xc9, 0x8a, 0x38, 0x89, 0x65, 0xff, 0xc6, 0x60, 0xa8, 0xe8, 0xbf, 0x5d, 0xe8, 0x04, 0x86,
|
||||
0x5b, 0x83, 0x43, 0x5a, 0x48, 0xee, 0x9e, 0x0b, 0x91, 0x9a, 0xbd, 0x16, 0x23, 0x2f, 0xd2, 0xdc,
|
||||
0x97, 0x9f, 0x7f, 0xbe, 0x47, 0xd3, 0xda, 0x94, 0x11, 0xf2, 0x68, 0x4a, 0xf0, 0x4b, 0x65, 0x11,
|
||||
0x1d, 0xc2, 0x1d, 0x31, 0x05, 0x34, 0x1d, 0xc2, 0x1a, 0x9c, 0x61, 0x2a, 0xdd, 0x1f, 0x20, 0x35,
|
||||
0x33, 0x42, 0x73, 0x1a, 0x3d, 0x31, 0xc2, 0x5e, 0x4c, 0x66, 0x9c, 0x78, 0x73, 0x3f, 0x43, 0x9f,
|
||||
0x21, 0x1e, 0xf8, 0x82, 0x50, 0xe6, 0xba, 0x0f, 0xaf, 0x23, 0x3f, 0x77, 0x13, 0x4c, 0x9a, 0x98,
|
||||
0x11, 0x26, 0xa6, 0xb4, 0xc9, 0x70, 0x13, 0x5e, 0xe6, 0x53, 0x88, 0x07, 0xde, 0xbe, 0x50, 0x03,
|
||||
0x57, 0x9f, 0xe4, 0x50, 0x03, 0x21, 0x4f, 0xa8, 0xa6, 0x0a, 0x03, 0x49, 0xd4, 0xc7, 0x40, 0xee,
|
||||
0xf5, 0x8f, 0x0b, 0x55, 0x39, 0xbf, 0x50, 0x95, 0xdf, 0x17, 0xaa, 0xf2, 0xed, 0x52, 0x8d, 0x9c,
|
||||
0x5f, 0xaa, 0x91, 0x5f, 0x97, 0x6a, 0xe4, 0x43, 0xc6, 0xb2, 0xf9, 0x7e, 0xb3, 0xac, 0x57, 0x68,
|
||||
0xad, 0x55, 0xeb, 0xff, 0x79, 0xc6, 0xaa, 0x9f, 0x0c, 0x7e, 0x5c, 0x27, 0x1e, 0x59, 0x79, 0x50,
|
||||
0xfc, 0x70, 0x3c, 0xff, 0x17, 0x00, 0x00, 0xff, 0xff, 0x96, 0xba, 0xfb, 0xcb, 0x0f, 0x07, 0x00,
|
||||
// 817 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcf, 0x6f, 0xe3, 0x44,
|
||||
0x14, 0x8e, 0x9d, 0xa5, 0xc9, 0xbe, 0xa4, 0x4b, 0x76, 0x5a, 0x96, 0x90, 0x05, 0x37, 0xeb, 0x25,
|
||||
0x6d, 0x14, 0x09, 0x5b, 0x0d, 0x20, 0x55, 0x88, 0x4b, 0x7e, 0xb5, 0x54, 0xd0, 0xa6, 0x72, 0xca,
|
||||
0xa1, 0x08, 0x29, 0x72, 0x92, 0xa9, 0x6b, 0xd1, 0x78, 0x52, 0xcf, 0xa4, 0x72, 0xd4, 0x56, 0x48,
|
||||
0x1c, 0x39, 0x21, 0xf1, 0x67, 0xf0, 0x4f, 0x70, 0xe4, 0x58, 0x89, 0x0b, 0x47, 0xd4, 0xf0, 0x47,
|
||||
0x70, 0x44, 0x1e, 0x4f, 0x12, 0x27, 0x75, 0xda, 0x8a, 0x53, 0xde, 0x64, 0xbe, 0xf7, 0xbd, 0xef,
|
||||
0x7d, 0xf3, 0x66, 0x0c, 0x1b, 0x5d, 0x42, 0xfb, 0x84, 0xea, 0xcc, 0xd3, 0x2f, 0xb7, 0x3b, 0x98,
|
||||
0x99, 0xdb, 0x3a, 0xc5, 0xee, 0xa5, 0xdd, 0xc5, 0xda, 0xc0, 0x25, 0x8c, 0xa0, 0x97, 0x01, 0x40,
|
||||
0x63, 0x9e, 0x26, 0x00, 0xb9, 0x0f, 0x2d, 0x42, 0xac, 0x73, 0xac, 0x9b, 0x03, 0x5b, 0x37, 0x1d,
|
||||
0x87, 0x30, 0x93, 0xd9, 0xc4, 0xa1, 0x41, 0x42, 0xee, 0xad, 0x60, 0xec, 0x98, 0x14, 0xeb, 0x66,
|
||||
0xa7, 0x6b, 0x4f, 0x89, 0xfd, 0x85, 0x00, 0xe5, 0xee, 0x97, 0x65, 0x9e, 0xd8, 0x5b, 0xb7, 0x88,
|
||||
0x45, 0x78, 0xa8, 0xfb, 0x91, 0xf8, 0xb7, 0x14, 0xa6, 0xbd, 0x18, 0x62, 0x77, 0x34, 0xcd, 0x1c,
|
||||
0x98, 0x96, 0xed, 0x70, 0x0d, 0x01, 0x56, 0xfd, 0x4d, 0x02, 0xb4, 0x87, 0xd9, 0xb1, 0x47, 0x1b,
|
||||
0x97, 0xd8, 0x61, 0x06, 0xbe, 0x18, 0x62, 0xca, 0xd0, 0x2b, 0x58, 0xc1, 0xfe, 0x9a, 0x66, 0xa5,
|
||||
0x7c, 0xbc, 0xf8, 0xdc, 0x10, 0x2b, 0xb4, 0x0b, 0x30, 0xa3, 0xc8, 0xca, 0x79, 0xa9, 0x98, 0x2a,
|
||||
0x6f, 0x6a, 0xa2, 0x6f, 0xbf, 0x9e, 0xc6, 0xeb, 0x4d, 0xfa, 0xd7, 0x8e, 0x4c, 0x0b, 0x0b, 0x4e,
|
||||
0x23, 0x94, 0x89, 0x3e, 0x87, 0x24, 0x71, 0x7b, 0xd8, 0x6d, 0x77, 0x46, 0xd9, 0x78, 0x5e, 0x2a,
|
||||
0xbe, 0x28, 0xe7, 0xb4, 0x7b, 0xee, 0x69, 0x4d, 0x1f, 0x52, 0x1d, 0x19, 0x09, 0x12, 0x04, 0xea,
|
||||
0xad, 0x04, 0x6b, 0x73, 0x6a, 0xe9, 0x80, 0x38, 0x14, 0xa3, 0x2d, 0x88, 0x33, 0x2f, 0xd0, 0x9a,
|
||||
0x2a, 0xbf, 0x17, 0xc1, 0x74, 0xec, 0x19, 0x3e, 0x02, 0xed, 0x41, 0x9a, 0x79, 0x6d, 0x57, 0xe4,
|
||||
0xd1, 0xac, 0xcc, 0x33, 0x3e, 0x9e, 0xeb, 0x80, 0x7b, 0x1f, 0x4a, 0x14, 0x60, 0x23, 0xc5, 0xa6,
|
||||
0xb1, 0x4f, 0x14, 0x36, 0x22, 0xce, 0x8d, 0xd8, 0x7a, 0xd4, 0x08, 0xc1, 0x14, 0x4a, 0x55, 0x31,
|
||||
0xa0, 0xaa, 0x4b, 0xcc, 0x5e, 0xd7, 0xa4, 0xcc, 0x2f, 0x16, 0xf8, 0xff, 0x01, 0x24, 0x99, 0xd7,
|
||||
0xee, 0x8c, 0x18, 0xf6, 0xbb, 0x92, 0x8a, 0x69, 0x23, 0xc1, 0xbc, 0xaa, 0xbf, 0x44, 0x9f, 0xc1,
|
||||
0xb3, 0x3e, 0xe9, 0x61, 0x6e, 0xfe, 0x8b, 0x72, 0x3e, 0xa2, 0xd9, 0x29, 0xdf, 0x01, 0xe9, 0x61,
|
||||
0x83, 0xa3, 0xd5, 0xef, 0x61, 0x6d, 0xae, 0x8c, 0x30, 0xae, 0x01, 0xa9, 0x90, 0x1f, 0xbc, 0xd4,
|
||||
0x53, 0xed, 0x80, 0x99, 0x1d, 0xea, 0x0e, 0xbc, 0xdb, 0xb2, 0xfb, 0xc3, 0x73, 0x93, 0x4d, 0x4e,
|
||||
0x1b, 0x15, 0x40, 0x66, 0x9e, 0x20, 0x5c, 0x72, 0x22, 0x32, 0xf3, 0xd4, 0x9f, 0x25, 0xc8, 0xcc,
|
||||
0x52, 0x85, 0xaa, 0x2f, 0x21, 0x69, 0x99, 0xb4, 0x6d, 0x3b, 0xa7, 0x44, 0x30, 0xbc, 0x59, 0x2e,
|
||||
0x69, 0xcf, 0xa4, 0xfb, 0xce, 0x29, 0x31, 0x12, 0x56, 0x10, 0xa0, 0x1d, 0x58, 0x71, 0x31, 0x1d,
|
||||
0x9e, 0x33, 0x31, 0x9f, 0xf9, 0xe5, 0xb9, 0x06, 0xc7, 0x19, 0x02, 0xaf, 0xaa, 0x90, 0xe6, 0xd3,
|
||||
0x35, 0xe9, 0x01, 0xc1, 0xb3, 0x33, 0x93, 0x9e, 0x71, 0x0d, 0xcf, 0x0d, 0x1e, 0xab, 0x37, 0xb0,
|
||||
0x2a, 0x30, 0x42, 0xec, 0xd3, 0x1a, 0x5d, 0x74, 0x5a, 0xfe, 0x7f, 0x4e, 0x97, 0xbe, 0x82, 0x84,
|
||||
0xb8, 0x15, 0x28, 0x0b, 0xeb, 0x4d, 0xa3, 0xde, 0x30, 0xda, 0xd5, 0x93, 0xf6, 0xb7, 0x87, 0xad,
|
||||
0xa3, 0x46, 0x6d, 0x7f, 0x77, 0xbf, 0x51, 0xcf, 0xc4, 0x50, 0x06, 0xd2, 0xd3, 0x9d, 0x4a, 0xab,
|
||||
0x96, 0x91, 0xd0, 0x4b, 0x58, 0x9d, 0xfe, 0x53, 0x6f, 0xb4, 0x6a, 0x19, 0xb9, 0x74, 0x0d, 0xab,
|
||||
0x73, 0x83, 0x82, 0x14, 0xc8, 0x55, 0x8d, 0x66, 0xa5, 0x5e, 0xab, 0xb4, 0x8e, 0xdb, 0x07, 0xcd,
|
||||
0x7a, 0x63, 0x81, 0x35, 0x0b, 0xeb, 0x0b, 0xfb, 0xd5, 0x6f, 0x9a, 0xb5, 0xaf, 0x33, 0x12, 0x7a,
|
||||
0x1f, 0xd6, 0x16, 0x76, 0x5a, 0x27, 0x87, 0xb5, 0x8c, 0x1c, 0x91, 0x52, 0xe1, 0x3b, 0xf1, 0xf2,
|
||||
0xbf, 0x71, 0x48, 0xb4, 0x82, 0xd7, 0x13, 0x5d, 0x41, 0x72, 0x32, 0x02, 0x48, 0x8d, 0x70, 0x70,
|
||||
0x61, 0xb4, 0x72, 0x6f, 0x1f, 0xc4, 0x88, 0x91, 0xdc, 0xfc, 0xe9, 0xcf, 0x7f, 0x7e, 0x95, 0xf3,
|
||||
0xea, 0x6b, 0x3d, 0xe2, 0xd9, 0x16, 0xe0, 0x2f, 0xa4, 0x12, 0xba, 0x80, 0x77, 0xf8, 0x79, 0xa2,
|
||||
0x8d, 0x08, 0xd6, 0xf0, 0x34, 0xe4, 0xf2, 0xcb, 0x01, 0xa2, 0x66, 0x81, 0xd7, 0xdc, 0x40, 0x1f,
|
||||
0xe9, 0x51, 0x6f, 0x36, 0xd5, 0xaf, 0xfc, 0x09, 0xba, 0x41, 0x3f, 0x42, 0x2a, 0x74, 0x17, 0x51,
|
||||
0xe1, 0xa1, 0x2b, 0x3c, 0x2b, 0xbf, 0xf9, 0x18, 0x4c, 0x88, 0x78, 0xc3, 0x45, 0xbc, 0x56, 0x5f,
|
||||
0x45, 0x8b, 0xf0, 0x7b, 0xbe, 0x86, 0x54, 0xe8, 0x15, 0x8d, 0x14, 0x70, 0xff, 0x9b, 0x10, 0x29,
|
||||
0x20, 0xe2, 0x31, 0x56, 0x15, 0x2e, 0x20, 0x8b, 0x96, 0x08, 0xa8, 0xd6, 0xfe, 0xb8, 0x53, 0xa4,
|
||||
0xdb, 0x3b, 0x45, 0xfa, 0xfb, 0x4e, 0x91, 0x7e, 0x19, 0x2b, 0xb1, 0xdf, 0xc7, 0x8a, 0x74, 0x3b,
|
||||
0x56, 0x62, 0x7f, 0x8d, 0x95, 0xd8, 0x77, 0x05, 0xcb, 0x66, 0x67, 0xc3, 0x8e, 0xd6, 0x25, 0xfd,
|
||||
0x49, 0x7e, 0xf0, 0xf3, 0x09, 0xed, 0xfd, 0xa0, 0xb3, 0xd1, 0x00, 0xfb, 0x84, 0x9d, 0x15, 0xfe,
|
||||
0xf9, 0xfa, 0xf4, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x64, 0xf5, 0xff, 0x95, 0x07, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
@@ -779,6 +840,11 @@ func (m *GetTxsEventRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.OrderBy != 0 {
|
||||
i = encodeVarintService(dAtA, i, uint64(m.OrderBy))
|
||||
i--
|
||||
dAtA[i] = 0x18
|
||||
}
|
||||
if m.Pagination != nil {
|
||||
{
|
||||
size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i])
|
||||
@@ -1122,6 +1188,9 @@ func (m *GetTxsEventRequest) Size() (n int) {
|
||||
l = m.Pagination.Size()
|
||||
n += 1 + l + sovService(uint64(l))
|
||||
}
|
||||
if m.OrderBy != 0 {
|
||||
n += 1 + sovService(uint64(m.OrderBy))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@@ -1342,6 +1411,25 @@ func (m *GetTxsEventRequest) Unmarshal(dAtA []byte) error {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field OrderBy", wireType)
|
||||
}
|
||||
m.OrderBy = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowService
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.OrderBy |= OrderBy(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipService(dAtA[iNdEx:])
|
||||
|
||||
@@ -400,13 +400,13 @@ func RegisterServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, cl
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Service_Simulate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "tx", "v1beta1", "simulate"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Service_Simulate_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "tx", "v1beta1", "simulate"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Service_GetTx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "tx", "v1beta1", "txs", "hash"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Service_GetTx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "tx", "v1beta1", "txs", "hash"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Service_BroadcastTx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "tx", "v1beta1", "txs"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Service_BroadcastTx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "tx", "v1beta1", "txs"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
|
||||
pattern_Service_GetTxsEvent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "tx", "v1beta1", "txs"}, "", runtime.AssumeColonVerbOpt(true)))
|
||||
pattern_Service_GetTxsEvent_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "tx", "v1beta1", "txs"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
+1
-3
@@ -161,7 +161,7 @@ func (u *Uint) MarshalTo(data []byte) (n int, err error) {
|
||||
if u.i == nil {
|
||||
u.i = new(big.Int)
|
||||
}
|
||||
if len(u.i.Bytes()) == 0 {
|
||||
if u.i.BitLen() == 0 { // The value 0
|
||||
copy(data, []byte{0x30})
|
||||
return 1, nil
|
||||
}
|
||||
@@ -207,8 +207,6 @@ func (u *Uint) Size() int {
|
||||
func (u Uint) MarshalAmino() ([]byte, error) { return u.Marshal() }
|
||||
func (u *Uint) UnmarshalAmino(bz []byte) error { return u.Unmarshal(bz) }
|
||||
|
||||
//__________________________________________________________________________
|
||||
|
||||
// UintOverflow returns true if a given unsigned integer overflows and false
|
||||
// otherwise.
|
||||
func UintOverflow(i *big.Int) error {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package types_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
@@ -290,3 +291,36 @@ func maxuint(i1, i2 uint64) uint64 {
|
||||
}
|
||||
return i2
|
||||
}
|
||||
|
||||
func TestRoundTripMarshalToUint(t *testing.T) {
|
||||
var values = []uint64{
|
||||
0,
|
||||
1,
|
||||
1 << 10,
|
||||
1<<10 - 3,
|
||||
1<<63 - 1,
|
||||
1<<32 - 7,
|
||||
1<<22 - 8,
|
||||
}
|
||||
|
||||
for _, value := range values {
|
||||
value := value
|
||||
t.Run(fmt.Sprintf("%d", value), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
var scratch [20]byte
|
||||
uv := sdk.NewUint(value)
|
||||
n, err := uv.MarshalTo(scratch[:])
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
rt := new(sdk.Uint)
|
||||
if err := rt.Unmarshal(scratch[:n]); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !rt.Equal(uv) {
|
||||
t.Fatalf("roundtrip=%q != original=%q", rt, uv)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user