From dec703bd01256d0924286256a3de991aeb1c0b0e Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Sat, 1 Feb 2020 14:34:19 -0500 Subject: [PATCH 01/27] Migrate staking types to proto --- go.mod | 1 + .../proto/tendermint/abci/types/types.proto | 350 ++ .../tendermint/crypto/merkle/merkle.proto | 31 + .../proto/tendermint/libs/kv/types.proto | 29 + types/types.pb.go | 553 +- types/types.proto | 12 + x/staking/types/codec.go | 30 +- x/staking/types/commission.go | 38 +- x/staking/types/delegation.go | 207 +- x/staking/types/historical_info.go | 40 +- x/staking/types/params.go | 53 +- x/staking/types/types.pb.go | 4790 +++++++++++++++++ x/staking/types/types.proto | 273 + x/staking/types/validator.go | 193 +- 14 files changed, 6302 insertions(+), 298 deletions(-) create mode 100644 third_party/proto/tendermint/abci/types/types.proto create mode 100644 third_party/proto/tendermint/crypto/merkle/merkle.proto create mode 100644 third_party/proto/tendermint/libs/kv/types.proto create mode 100644 x/staking/types/types.pb.go create mode 100644 x/staking/types/types.proto diff --git a/go.mod b/go.mod index 6ebb9fdde282..77bb6bda0ee1 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( github.com/cosmos/ledger-cosmos-go v0.11.1 github.com/gogo/protobuf v1.3.1 github.com/golang/mock v1.3.1-0.20190508161146-9fa652df1129 + github.com/golang/protobuf v1.3.2 github.com/gorilla/mux v1.7.3 github.com/hashicorp/golang-lru v0.5.4 github.com/mattn/go-isatty v0.0.12 diff --git a/third_party/proto/tendermint/abci/types/types.proto b/third_party/proto/tendermint/abci/types/types.proto new file mode 100644 index 000000000000..eff32d4c5322 --- /dev/null +++ b/third_party/proto/tendermint/abci/types/types.proto @@ -0,0 +1,350 @@ +syntax = "proto3"; +package tendermint.abci.types; +option go_package = "github.com/tendermint/tendermint/abci/types"; + +// For more information on gogo.proto, see: +// https://github.com/gogo/protobuf/blob/master/extensions.md +import "third_party/proto/gogoproto/gogo.proto"; +import "third_party/proto/tendermint/crypto/merkle/merkle.proto"; +import "third_party/proto/tendermint/libs/kv/types.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; + +// This file is copied from http://github.com/tendermint/abci +// NOTE: When using custom types, mind the warnings. +// https://github.com/gogo/protobuf/blob/master/custom_types.md#warnings-and-issues + +option (gogoproto.marshaler_all) = true; +option (gogoproto.unmarshaler_all) = true; +option (gogoproto.sizer_all) = true; +option (gogoproto.goproto_registration) = true; + +// Generate tests +option (gogoproto.populate_all) = true; +option (gogoproto.equal_all) = true; +option (gogoproto.testgen_all) = true; + +//---------------------------------------- +// Request types + +message Request { + oneof value { + RequestEcho echo = 2; + RequestFlush flush = 3; + RequestInfo info = 4; + RequestSetOption set_option = 5; + RequestInitChain init_chain = 6; + RequestQuery query = 7; + RequestBeginBlock begin_block = 8; + RequestCheckTx check_tx = 9; + RequestDeliverTx deliver_tx = 19; + RequestEndBlock end_block = 11; + RequestCommit commit = 12; + } +} + +message RequestEcho { string message = 1; } + +message RequestFlush {} + +message RequestInfo { + string version = 1; + uint64 block_version = 2; + uint64 p2p_version = 3; +} + +// nondeterministic +message RequestSetOption { + string key = 1; + string value = 2; +} + +message RequestInitChain { + google.protobuf.Timestamp time = 1 + [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; + string chain_id = 2; + ConsensusParams consensus_params = 3; + repeated ValidatorUpdate validators = 4 [ (gogoproto.nullable) = false ]; + bytes app_state_bytes = 5; +} + +message RequestQuery { + bytes data = 1; + string path = 2; + int64 height = 3; + bool prove = 4; +} + +message RequestBeginBlock { + bytes hash = 1; + Header header = 2 [ (gogoproto.nullable) = false ]; + LastCommitInfo last_commit_info = 3 [ (gogoproto.nullable) = false ]; + repeated Evidence byzantine_validators = 4 [ (gogoproto.nullable) = false ]; +} + +enum CheckTxType { + New = 0; + Recheck = 1; +} + +message RequestCheckTx { + bytes tx = 1; + CheckTxType type = 2; +} + +message RequestDeliverTx { bytes tx = 1; } + +message RequestEndBlock { int64 height = 1; } + +message RequestCommit {} + +//---------------------------------------- +// Response types + +message Response { + oneof value { + ResponseException exception = 1; + ResponseEcho echo = 2; + ResponseFlush flush = 3; + ResponseInfo info = 4; + ResponseSetOption set_option = 5; + ResponseInitChain init_chain = 6; + ResponseQuery query = 7; + ResponseBeginBlock begin_block = 8; + ResponseCheckTx check_tx = 9; + ResponseDeliverTx deliver_tx = 10; + ResponseEndBlock end_block = 11; + ResponseCommit commit = 12; + } +} + +// nondeterministic +message ResponseException { string error = 1; } + +message ResponseEcho { string message = 1; } + +message ResponseFlush {} + +message ResponseInfo { + string data = 1; + + string version = 2; + uint64 app_version = 3; + + int64 last_block_height = 4; + bytes last_block_app_hash = 5; +} + +// nondeterministic +message ResponseSetOption { + uint32 code = 1; + // bytes data = 2; + string log = 3; + string info = 4; +} + +message ResponseInitChain { + ConsensusParams consensus_params = 1; + repeated ValidatorUpdate validators = 2 [ (gogoproto.nullable) = false ]; +} + +message ResponseQuery { + uint32 code = 1; + // bytes data = 2; // use "value" instead. + string log = 3; // nondeterministic + string info = 4; // nondeterministic + int64 index = 5; + bytes key = 6; + bytes value = 7; + tendermint.crypto.merkle.Proof proof = 8; + int64 height = 9; + string codespace = 10; +} + +message ResponseBeginBlock { + repeated Event events = 1 [ + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "events,omitempty" + ]; +} + +message ResponseCheckTx { + uint32 code = 1; + bytes data = 2; + string log = 3; // nondeterministic + string info = 4; // nondeterministic + int64 gas_wanted = 5; + int64 gas_used = 6; + repeated Event events = 7 [ + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "events,omitempty" + ]; + string codespace = 8; +} + +message ResponseDeliverTx { + uint32 code = 1; + bytes data = 2; + string log = 3; // nondeterministic + string info = 4; // nondeterministic + int64 gas_wanted = 5; + int64 gas_used = 6; + repeated Event events = 7 [ + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "events,omitempty" + ]; + string codespace = 8; +} + +message ResponseEndBlock { + repeated ValidatorUpdate validator_updates = 1 + [ (gogoproto.nullable) = false ]; + ConsensusParams consensus_param_updates = 2; + repeated Event events = 3 [ + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "events,omitempty" + ]; +} + +message ResponseCommit { + // reserve 1 + bytes data = 2; +} + +//---------------------------------------- +// Misc. + +// ConsensusParams contains all consensus-relevant parameters +// that can be adjusted by the abci app +message ConsensusParams { + BlockParams block = 1; + EvidenceParams evidence = 2; + ValidatorParams validator = 3; +} + +// BlockParams contains limits on the block size. +message BlockParams { + // Note: must be greater than 0 + int64 max_bytes = 1; + // Note: must be greater or equal to -1 + int64 max_gas = 2; +} + +message EvidenceParams { + // Note: must be greater than 0 + int64 max_age_num_blocks = 1; + google.protobuf.Duration max_age_duration = 2 + [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; +} + +// ValidatorParams contains limits on validators. +message ValidatorParams { repeated string pub_key_types = 1; } + +message LastCommitInfo { + int32 round = 1; + repeated VoteInfo votes = 2 [ (gogoproto.nullable) = false ]; +} + +message Event { + string type = 1; + repeated tendermint.libs.kv.Pair attributes = 2 [ + (gogoproto.nullable) = false, + (gogoproto.jsontag) = "attributes,omitempty" + ]; +} + +//---------------------------------------- +// Blockchain Types + +message Header { + // basic block info + Version version = 1 [ (gogoproto.nullable) = false ]; + string chain_id = 2 [ (gogoproto.customname) = "ChainID" ]; + int64 height = 3; + google.protobuf.Timestamp time = 4 + [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; + + // prev block info + BlockID last_block_id = 5 [ (gogoproto.nullable) = false ]; + + // hashes of block data + bytes last_commit_hash = 6; // commit from validators from the last block + bytes data_hash = 7; // transactions + + // hashes from the app output from the prev block + bytes validators_hash = 8; // validators for the current block + bytes next_validators_hash = 9; // validators for the next block + bytes consensus_hash = 10; // consensus params for current block + bytes app_hash = 11; // state after txs from the previous block + bytes last_results_hash = + 12; // root hash of all results from the txs from the previous block + + // consensus info + bytes evidence_hash = 13; // evidence included in the block + bytes proposer_address = 14; // original proposer of the block +} + +message Version { + uint64 Block = 1; + uint64 App = 2; +} + +message BlockID { + bytes hash = 1; + PartSetHeader parts_header = 2 [ (gogoproto.nullable) = false ]; +} + +message PartSetHeader { + int32 total = 1; + bytes hash = 2; +} + +// Validator +message Validator { + bytes address = 1; + // PubKey pub_key = 2 [(gogoproto.nullable)=false]; + int64 power = 3; +} + +// ValidatorUpdate +message ValidatorUpdate { + PubKey pub_key = 1 [ (gogoproto.nullable) = false ]; + int64 power = 2; +} + +// VoteInfo +message VoteInfo { + Validator validator = 1 [ (gogoproto.nullable) = false ]; + bool signed_last_block = 2; +} + +message PubKey { + string type = 1; + bytes data = 2; +} + +message Evidence { + string type = 1; + Validator validator = 2 [ (gogoproto.nullable) = false ]; + int64 height = 3; + google.protobuf.Timestamp time = 4 + [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; + int64 total_voting_power = 5; +} + +//---------------------------------------- +// Service Definition + +service ABCIApplication { + rpc Echo(RequestEcho) returns (ResponseEcho); + rpc Flush(RequestFlush) returns (ResponseFlush); + rpc Info(RequestInfo) returns (ResponseInfo); + rpc SetOption(RequestSetOption) returns (ResponseSetOption); + rpc DeliverTx(RequestDeliverTx) returns (ResponseDeliverTx); + rpc CheckTx(RequestCheckTx) returns (ResponseCheckTx); + rpc Query(RequestQuery) returns (ResponseQuery); + rpc Commit(RequestCommit) returns (ResponseCommit); + rpc InitChain(RequestInitChain) returns (ResponseInitChain); + rpc BeginBlock(RequestBeginBlock) returns (ResponseBeginBlock); + rpc EndBlock(RequestEndBlock) returns (ResponseEndBlock); +} diff --git a/third_party/proto/tendermint/crypto/merkle/merkle.proto b/third_party/proto/tendermint/crypto/merkle/merkle.proto new file mode 100644 index 000000000000..9dbb2be074e8 --- /dev/null +++ b/third_party/proto/tendermint/crypto/merkle/merkle.proto @@ -0,0 +1,31 @@ +syntax = "proto3"; +package tendermint.crypto.merkle; +option go_package = "github.com/tendermint/tendermint/crypto/merkle"; + +// For more information on gogo.proto, see: +// https://github.com/gogo/protobuf/blob/master/extensions.md +import "third_party/proto/gogoproto/gogo.proto"; + +option (gogoproto.marshaler_all) = true; +option (gogoproto.unmarshaler_all) = true; +option (gogoproto.sizer_all) = true; + +option (gogoproto.populate_all) = true; +option (gogoproto.equal_all) = true; + +//---------------------------------------- +// Message types + +// ProofOp defines an operation used for calculating Merkle root +// The data could be arbitrary format, providing nessecary data +// for example neighbouring node hash +message ProofOp { + string type = 1; + bytes key = 2; + bytes data = 3; +} + +// Proof is Merkle proof defined by the list of ProofOps +message Proof { + repeated ProofOp ops = 1 [(gogoproto.nullable)=false]; +} diff --git a/third_party/proto/tendermint/libs/kv/types.proto b/third_party/proto/tendermint/libs/kv/types.proto new file mode 100644 index 000000000000..247022798347 --- /dev/null +++ b/third_party/proto/tendermint/libs/kv/types.proto @@ -0,0 +1,29 @@ +syntax = "proto3"; +package tendermint.libs.kv; +option go_package = "github.com/tendermint/tendermint/libs/kv"; + +import "third_party/proto/gogoproto/gogo.proto"; + +option (gogoproto.marshaler_all) = true; +option (gogoproto.unmarshaler_all) = true; +option (gogoproto.sizer_all) = true; +option (gogoproto.goproto_registration) = true; +// Generate tests +option (gogoproto.populate_all) = true; +option (gogoproto.equal_all) = true; +option (gogoproto.testgen_all) = true; + +//---------------------------------------- +// Abstract types + +// Define these here for compatibility but use tmlibs/common.KVPair. +message Pair { + bytes key = 1; + bytes value = 2; +} + +// Define these here for compatibility but use tmlibs/common.KI64Pair. +message KI64Pair { + bytes key = 1; + int64 value = 2; +} diff --git a/types/types.pb.go b/types/types.pb.go index 4ea0bfeec523..2f7560431406 100644 --- a/types/types.pb.go +++ b/types/types.pb.go @@ -4,12 +4,15 @@ package types import ( + bytes "bytes" fmt "fmt" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" + reflect "reflect" + strings "strings" ) // Reference imports to suppress errors if they are not otherwise used. @@ -119,15 +122,115 @@ func (m *DecCoin) GetDenom() string { return "" } +// PublicKey defines a type to represent raw public key bytes. +type PublicKey struct { + // Types that are valid to be assigned to Pub: + // *PublicKey_Ed25519 + // *PublicKey_Secp256K1 + // *PublicKey_Sr25519 + Pub isPublicKey_Pub `protobuf_oneof:"pub"` +} + +func (m *PublicKey) Reset() { *m = PublicKey{} } +func (*PublicKey) ProtoMessage() {} +func (*PublicKey) Descriptor() ([]byte, []int) { + return fileDescriptor_2c0f90c600ad7e2e, []int{2} +} +func (m *PublicKey) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PublicKey.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *PublicKey) XXX_Merge(src proto.Message) { + xxx_messageInfo_PublicKey.Merge(m, src) +} +func (m *PublicKey) XXX_Size() int { + return m.Size() +} +func (m *PublicKey) XXX_DiscardUnknown() { + xxx_messageInfo_PublicKey.DiscardUnknown(m) +} + +var xxx_messageInfo_PublicKey proto.InternalMessageInfo + +type isPublicKey_Pub interface { + isPublicKey_Pub() + Equal(interface{}) bool + MarshalTo([]byte) (int, error) + Size() int +} + +type PublicKey_Ed25519 struct { + Ed25519 []byte `protobuf:"bytes,1,opt,name=ed25519,proto3,oneof" json:"ed25519,omitempty"` +} +type PublicKey_Secp256K1 struct { + Secp256K1 []byte `protobuf:"bytes,2,opt,name=secp256k1,proto3,oneof" json:"secp256k1,omitempty"` +} +type PublicKey_Sr25519 struct { + Sr25519 []byte `protobuf:"bytes,3,opt,name=sr25519,proto3,oneof" json:"sr25519,omitempty"` +} + +func (*PublicKey_Ed25519) isPublicKey_Pub() {} +func (*PublicKey_Secp256K1) isPublicKey_Pub() {} +func (*PublicKey_Sr25519) isPublicKey_Pub() {} + +func (m *PublicKey) GetPub() isPublicKey_Pub { + if m != nil { + return m.Pub + } + return nil +} + +func (m *PublicKey) GetEd25519() []byte { + if x, ok := m.GetPub().(*PublicKey_Ed25519); ok { + return x.Ed25519 + } + return nil +} + +func (m *PublicKey) GetSecp256K1() []byte { + if x, ok := m.GetPub().(*PublicKey_Secp256K1); ok { + return x.Secp256K1 + } + return nil +} + +func (m *PublicKey) GetSr25519() []byte { + if x, ok := m.GetPub().(*PublicKey_Sr25519); ok { + return x.Sr25519 + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*PublicKey) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*PublicKey_Ed25519)(nil), + (*PublicKey_Secp256K1)(nil), + (*PublicKey_Sr25519)(nil), + } +} + func init() { proto.RegisterType((*Coin)(nil), "cosmos_sdk.v1.Coin") proto.RegisterType((*DecCoin)(nil), "cosmos_sdk.v1.DecCoin") + proto.RegisterType((*PublicKey)(nil), "cosmos_sdk.v1.PublicKey") } func init() { proto.RegisterFile("types/types.proto", fileDescriptor_2c0f90c600ad7e2e) } var fileDescriptor_2c0f90c600ad7e2e = []byte{ - // 214 bytes of a gzipped FileDescriptorProto + // 293 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x07, 0x93, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xbc, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0xc5, 0x29, 0xd9, 0x7a, 0x65, 0x86, 0x52, 0x6a, 0x25, 0x19, 0x99, 0x45, 0x29, @@ -136,14 +239,121 @@ var fileDescriptor_2c0f90c600ad7e2e = []byte{ 0x5e, 0x7e, 0xae, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x84, 0x23, 0xa4, 0xcc, 0xc5, 0x96, 0x98, 0x9b, 0x5f, 0x9a, 0x57, 0x22, 0xc1, 0x04, 0x12, 0x76, 0xe2, 0x3e, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0x66, 0xcf, 0xbc, 0x92, 0x20, 0xa8, 0x94, 0x92, 0x0b, 0x17, 0xbb, 0x4b, 0x6a, - 0x32, 0x39, 0xa6, 0xb8, 0xa4, 0x26, 0xc3, 0x4c, 0x71, 0x72, 0xb9, 0xf1, 0x50, 0x8e, 0xa1, 0xe1, - 0x91, 0x1c, 0xc3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, - 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x29, 0xa5, 0x67, - 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x3c, 0x0b, 0xa5, 0x74, 0x8b, 0x53, - 0xb2, 0x21, 0x61, 0x91, 0xc4, 0x06, 0xf6, 0x95, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xc6, - 0x8c, 0x7d, 0x21, 0x01, 0x00, 0x00, + 0x32, 0x39, 0xa6, 0xb8, 0xa4, 0x26, 0xc3, 0x4d, 0x29, 0xe1, 0xe2, 0x0c, 0x28, 0x4d, 0xca, 0xc9, + 0x4c, 0xf6, 0x4e, 0xad, 0x14, 0x92, 0xe2, 0x62, 0x4f, 0x4d, 0x31, 0x32, 0x35, 0x35, 0xb4, 0x04, + 0x9b, 0xc4, 0xe3, 0xc1, 0x10, 0x04, 0x13, 0x10, 0x92, 0xe3, 0xe2, 0x2c, 0x4e, 0x4d, 0x2e, 0x30, + 0x32, 0x35, 0xcb, 0x36, 0x04, 0x1b, 0x08, 0x92, 0x45, 0x08, 0x81, 0xf4, 0x16, 0x17, 0x41, 0xf4, + 0x32, 0xc3, 0xf4, 0x42, 0x05, 0xac, 0x38, 0x5e, 0x2c, 0x90, 0x67, 0x6c, 0xb8, 0xa3, 0xc0, 0xe8, + 0xc4, 0xca, 0xc5, 0x5c, 0x50, 0x9a, 0xe4, 0xe4, 0x72, 0xe3, 0xa1, 0x1c, 0x43, 0xc3, 0x23, 0x39, + 0x86, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, + 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x52, 0x4a, 0xcf, 0x2c, 0xc9, + 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x04, 0x31, 0x94, 0xd2, 0x2d, 0x4e, 0xc9, 0x86, + 0xc4, 0x40, 0x12, 0x1b, 0x38, 0x2c, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x83, 0x31, 0xbe, + 0xbf, 0x97, 0x01, 0x00, 0x00, } +func (this *PublicKey) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PublicKey) + if !ok { + that2, ok := that.(PublicKey) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if that1.Pub == nil { + if this.Pub != nil { + return false + } + } else if this.Pub == nil { + return false + } else if !this.Pub.Equal(that1.Pub) { + return false + } + return true +} +func (this *PublicKey_Ed25519) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PublicKey_Ed25519) + if !ok { + that2, ok := that.(PublicKey_Ed25519) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.Ed25519, that1.Ed25519) { + return false + } + return true +} +func (this *PublicKey_Secp256K1) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PublicKey_Secp256K1) + if !ok { + that2, ok := that.(PublicKey_Secp256K1) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.Secp256K1, that1.Secp256K1) { + return false + } + return true +} +func (this *PublicKey_Sr25519) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*PublicKey_Sr25519) + if !ok { + that2, ok := that.(PublicKey_Sr25519) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.Sr25519, that1.Sr25519) { + return false + } + return true +} func (m *Coin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -224,6 +434,86 @@ func (m *DecCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PublicKey) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *PublicKey) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PublicKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pub != nil { + { + size := m.Pub.Size() + i -= size + if _, err := m.Pub.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *PublicKey_Ed25519) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PublicKey_Ed25519) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Ed25519 != nil { + i -= len(m.Ed25519) + copy(dAtA[i:], m.Ed25519) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Ed25519))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *PublicKey_Secp256K1) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PublicKey_Secp256K1) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Secp256K1 != nil { + i -= len(m.Secp256K1) + copy(dAtA[i:], m.Secp256K1) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Secp256K1))) + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *PublicKey_Sr25519) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PublicKey_Sr25519) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.Sr25519 != nil { + i -= len(m.Sr25519) + copy(dAtA[i:], m.Sr25519) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Sr25519))) + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -265,12 +555,109 @@ func (m *DecCoin) Size() (n int) { return n } +func (m *PublicKey) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pub != nil { + n += m.Pub.Size() + } + return n +} + +func (m *PublicKey_Ed25519) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Ed25519 != nil { + l = len(m.Ed25519) + n += 1 + l + sovTypes(uint64(l)) + } + return n +} +func (m *PublicKey_Secp256K1) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Secp256K1 != nil { + l = len(m.Secp256K1) + n += 1 + l + sovTypes(uint64(l)) + } + return n +} +func (m *PublicKey_Sr25519) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Sr25519 != nil { + l = len(m.Sr25519) + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (this *PublicKey) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PublicKey{`, + `Pub:` + fmt.Sprintf("%v", this.Pub) + `,`, + `}`, + }, "") + return s +} +func (this *PublicKey_Ed25519) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PublicKey_Ed25519{`, + `Ed25519:` + fmt.Sprintf("%v", this.Ed25519) + `,`, + `}`, + }, "") + return s +} +func (this *PublicKey_Secp256K1) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PublicKey_Secp256K1{`, + `Secp256K1:` + fmt.Sprintf("%v", this.Secp256K1) + `,`, + `}`, + }, "") + return s +} +func (this *PublicKey_Sr25519) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&PublicKey_Sr25519{`, + `Sr25519:` + fmt.Sprintf("%v", this.Sr25519) + `,`, + `}`, + }, "") + return s +} +func valueToStringTypes(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} func (m *Coin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -509,6 +896,158 @@ func (m *DecCoin) Unmarshal(dAtA []byte) error { } return nil } +func (m *PublicKey) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: PublicKey: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PublicKey: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ed25519", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := make([]byte, postIndex-iNdEx) + copy(v, dAtA[iNdEx:postIndex]) + m.Pub = &PublicKey_Ed25519{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Secp256K1", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := make([]byte, postIndex-iNdEx) + copy(v, dAtA[iNdEx:postIndex]) + m.Pub = &PublicKey_Secp256K1{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sr25519", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := make([]byte, postIndex-iNdEx) + copy(v, dAtA[iNdEx:postIndex]) + m.Pub = &PublicKey_Sr25519{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/types/types.proto b/types/types.proto index 49da4e5c69f9..a9b3dcb1ee62 100644 --- a/types/types.proto +++ b/types/types.proto @@ -24,3 +24,15 @@ message DecCoin { string denom = 1; string amount = 2 [ (gogoproto.customtype) = "Dec", (gogoproto.nullable) = false ]; } + +// PublicKey defines a type to represent raw public key bytes. +message PublicKey { + option (gogoproto.equal) = true; + option (gogoproto.stringer) = true; + + oneof pub { + bytes ed25519 = 1; + bytes secp256k1 = 2; + bytes sr25519 = 3; + } +} \ No newline at end of file diff --git a/x/staking/types/codec.go b/x/staking/types/codec.go index 6fadfd9a68f9..9832789b6971 100644 --- a/x/staking/types/codec.go +++ b/x/staking/types/codec.go @@ -4,7 +4,22 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// Register concrete types on codec codec +type Codec struct { + codec.Marshaler + + // Keep reference to the amino codec to allow backwards compatibility along + // with type, and interface registration. + amino *codec.Codec +} + +func NewCodec(amino *codec.Codec) *Codec { + return &Codec{Marshaler: codec.NewHybridCodec(amino), amino: amino} +} + +// ---------------------------------------------------------------------------- + +// RegisterCodec registers all the necessary staking module concrete types and +// interfaces with the provided codec reference. func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgCreateValidator{}, "cosmos-sdk/MsgCreateValidator", nil) cdc.RegisterConcrete(MsgEditValidator{}, "cosmos-sdk/MsgEditValidator", nil) @@ -13,12 +28,13 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgBeginRedelegate{}, "cosmos-sdk/MsgBeginRedelegate", nil) } -// generic sealed codec to be used throughout this module -var ModuleCdc *codec.Codec +// ModuleCdc defines a staking module global Amino codec. +var ModuleCdc *Codec func init() { - ModuleCdc = codec.New() - RegisterCodec(ModuleCdc) - codec.RegisterCrypto(ModuleCdc) - ModuleCdc.Seal() + ModuleCdc = NewCodec(codec.New()) + + RegisterCodec(ModuleCdc.amino) + codec.RegisterCrypto(ModuleCdc.amino) + ModuleCdc.amino.Seal() } diff --git a/x/staking/types/commission.go b/x/staking/types/commission.go index 38ab8e06a703..270670a744b5 100644 --- a/x/staking/types/commission.go +++ b/x/staking/types/commission.go @@ -1,26 +1,10 @@ package types import ( - "fmt" "time" sdk "github.com/cosmos/cosmos-sdk/types" -) - -type ( - // Commission defines a commission parameters for a given validator. - Commission struct { - CommissionRates `json:"commission_rates" yaml:"commission_rates"` - UpdateTime time.Time `json:"update_time" yaml:"update_time"` // the last time the commission rate was changed - } - - // CommissionRates defines the initial commission rates to be used for creating a - // validator. - CommissionRates struct { - Rate sdk.Dec `json:"rate" yaml:"rate"` // the commission rate charged to delegators, as a fraction - MaxRate sdk.Dec `json:"max_rate" yaml:"max_rate"` // maximum commission rate which validator can ever charge, as a fraction - MaxChangeRate sdk.Dec `json:"max_change_rate" yaml:"max_change_rate"` // maximum daily increase of the validator commission, as a fraction - } + yaml "gopkg.in/yaml.v2" ) // NewCommissionRates returns an initialized validator commission rates. @@ -49,20 +33,16 @@ func NewCommissionWithTime(rate, maxRate, maxChangeRate sdk.Dec, updatedAt time. } } -// Equal checks if the given Commission object is equal to the receiving -// Commission object. -func (c Commission) Equal(c2 Commission) bool { - return c.Rate.Equal(c2.Rate) && - c.MaxRate.Equal(c2.MaxRate) && - c.MaxChangeRate.Equal(c2.MaxChangeRate) && - c.UpdateTime.Equal(c2.UpdateTime) +// String implements the Stringer interface for a Commission object. +func (c Commission) String() string { + out, _ := yaml.Marshal(c) + return string(out) } -// String implements the Stringer interface for a Commission. -func (c Commission) String() string { - return fmt.Sprintf("rate: %s, maxRate: %s, maxChangeRate: %s, updateTime: %s", - c.Rate, c.MaxRate, c.MaxChangeRate, c.UpdateTime, - ) +// String implements the Stringer interface for a CommissionRates object. +func (cr CommissionRates) String() string { + out, _ := yaml.Marshal(cr) + return string(out) } // Validate performs basic sanity validation checks of initial commission diff --git a/x/staking/types/delegation.go b/x/staking/types/delegation.go index 672edd5a90ed..bdb3193ebe9c 100644 --- a/x/staking/types/delegation.go +++ b/x/staking/types/delegation.go @@ -1,7 +1,6 @@ package types import ( - "bytes" "encoding/json" "fmt" "strings" @@ -10,41 +9,26 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/exported" + yaml "gopkg.in/yaml.v2" ) -// DVPair is struct that just has a delegator-validator pair with no other data. -// It is intended to be used as a marshalable pointer. For example, a DVPair can be used to construct the -// key to getting an UnbondingDelegation from state. -type DVPair struct { - DelegatorAddress sdk.AccAddress - ValidatorAddress sdk.ValAddress -} - -// DVVTriplet is struct that just has a delegator-validator-validator triplet with no other data. -// It is intended to be used as a marshalable pointer. For example, a DVVTriplet can be used to construct the -// key to getting a Redelegation from state. -type DVVTriplet struct { - DelegatorAddress sdk.AccAddress - ValidatorSrcAddress sdk.ValAddress - ValidatorDstAddress sdk.ValAddress -} - // Implements Delegation interface var _ exported.DelegationI = Delegation{} -// Delegation represents the bond with tokens held by an account. It is -// owned by one delegator, and is associated with the voting power of one -// validator. -type Delegation struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` - Shares sdk.Dec `json:"shares" yaml:"shares"` +// String implements the Stringer interface for a DVPair object. +func (dv DVPair) String() string { + out, _ := yaml.Marshal(dv) + return string(out) } -// NewDelegation creates a new delegation object -func NewDelegation(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, - shares sdk.Dec) Delegation { +// String implements the Stringer interface for a DVVTriplet object. +func (dvv DVVTriplet) String() string { + out, _ := yaml.Marshal(dvv) + return string(out) +} +// NewDelegation creates a new delegation object +func NewDelegation(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, shares sdk.Dec) Delegation { return Delegation{ DelegatorAddress: delegatorAddr, ValidatorAddress: validatorAddr, @@ -53,13 +37,13 @@ func NewDelegation(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, } // MustMarshalDelegation returns the delegation bytes. Panics if fails -func MustMarshalDelegation(cdc *codec.Codec, delegation Delegation) []byte { - return cdc.MustMarshalBinaryLengthPrefixed(delegation) +func MustMarshalDelegation(cdc codec.Marshaler, delegation Delegation) []byte { + return cdc.MustMarshalBinaryLengthPrefixed(&delegation) } // MustUnmarshalDelegation return the unmarshaled delegation from bytes. // Panics if fails. -func MustUnmarshalDelegation(cdc *codec.Codec, value []byte) Delegation { +func MustUnmarshalDelegation(cdc codec.Marshaler, value []byte) Delegation { delegation, err := UnmarshalDelegation(cdc, value) if err != nil { panic(err) @@ -68,18 +52,11 @@ func MustUnmarshalDelegation(cdc *codec.Codec, value []byte) Delegation { } // return the delegation -func UnmarshalDelegation(cdc *codec.Codec, value []byte) (delegation Delegation, err error) { +func UnmarshalDelegation(cdc codec.Marshaler, value []byte) (delegation Delegation, err error) { err = cdc.UnmarshalBinaryLengthPrefixed(value, &delegation) return delegation, err } -// nolint -func (d Delegation) Equal(d2 Delegation) bool { - return bytes.Equal(d.DelegatorAddress, d2.DelegatorAddress) && - bytes.Equal(d.ValidatorAddress, d2.ValidatorAddress) && - d.Shares.Equal(d2.Shares) -} - // nolint - for Delegation func (d Delegation) GetDelegatorAddr() sdk.AccAddress { return d.DelegatorAddress } func (d Delegation) GetValidatorAddr() sdk.ValAddress { return d.ValidatorAddress } @@ -87,11 +64,8 @@ func (d Delegation) GetShares() sdk.Dec { return d.Shares } // String returns a human readable string representation of a Delegation. func (d Delegation) String() string { - return fmt.Sprintf(`Delegation: - Delegator: %s - Validator: %s - Shares: %s`, d.DelegatorAddress, - d.ValidatorAddress, d.Shares) + out, _ := yaml.Marshal(d) + return string(out) } // Delegations is a collection of delegations @@ -104,20 +78,19 @@ func (d Delegations) String() (out string) { return strings.TrimSpace(out) } -// UnbondingDelegation stores all of a single delegator's unbonding bonds -// for a single validator in an time-ordered list -type UnbondingDelegation struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // delegator - ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` // validator unbonding from operator addr - Entries []UnbondingDelegationEntry `json:"entries" yaml:"entries"` // unbonding delegation entries +func NewUnbondingDelegationEntry(creationHeight int64, completionTime time.Time, balance sdk.Int) UnbondingDelegationEntry { + return UnbondingDelegationEntry{ + CreationHeight: creationHeight, + CompletionTime: completionTime, + InitialBalance: balance, + Balance: balance, + } } -// UnbondingDelegationEntry - entry to an UnbondingDelegation -type UnbondingDelegationEntry struct { - CreationHeight int64 `json:"creation_height" yaml:"creation_height"` // height which the unbonding took place - CompletionTime time.Time `json:"completion_time" yaml:"completion_time"` // time at which the unbonding delegation will complete - InitialBalance sdk.Int `json:"initial_balance" yaml:"initial_balance"` // atoms initially scheduled to receive at completion - Balance sdk.Int `json:"balance" yaml:"balance"` // atoms to receive at completion +// String implements the stringer interface for a UnbondingDelegationEntry. +func (ubd UnbondingDelegationEntry) String() string { + out, _ := yaml.Marshal(ubd) + return string(out) } // IsMature - is the current entry mature @@ -126,34 +99,22 @@ func (e UnbondingDelegationEntry) IsMature(currentTime time.Time) bool { } // NewUnbondingDelegation - create a new unbonding delegation object -func NewUnbondingDelegation(delegatorAddr sdk.AccAddress, - validatorAddr sdk.ValAddress, creationHeight int64, minTime time.Time, - balance sdk.Int) UnbondingDelegation { +func NewUnbondingDelegation( + delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, + creationHeight int64, minTime time.Time, balance sdk.Int, +) UnbondingDelegation { - entry := NewUnbondingDelegationEntry(creationHeight, minTime, balance) return UnbondingDelegation{ DelegatorAddress: delegatorAddr, ValidatorAddress: validatorAddr, - Entries: []UnbondingDelegationEntry{entry}, - } -} - -// NewUnbondingDelegationEntry - create a new unbonding delegation object -func NewUnbondingDelegationEntry(creationHeight int64, completionTime time.Time, - balance sdk.Int) UnbondingDelegationEntry { - - return UnbondingDelegationEntry{ - CreationHeight: creationHeight, - CompletionTime: completionTime, - InitialBalance: balance, - Balance: balance, + Entries: []UnbondingDelegationEntry{ + NewUnbondingDelegationEntry(creationHeight, minTime, balance), + }, } } // AddEntry - append entry to the unbonding delegation -func (d *UnbondingDelegation) AddEntry(creationHeight int64, - minTime time.Time, balance sdk.Int) { - +func (d *UnbondingDelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int) { entry := NewUnbondingDelegationEntry(creationHeight, minTime, balance) d.Entries = append(d.Entries, entry) } @@ -164,12 +125,12 @@ func (d *UnbondingDelegation) RemoveEntry(i int64) { } // return the unbonding delegation -func MustMarshalUBD(cdc *codec.Codec, ubd UnbondingDelegation) []byte { - return cdc.MustMarshalBinaryLengthPrefixed(ubd) +func MustMarshalUBD(cdc codec.Marshaler, ubd UnbondingDelegation) []byte { + return cdc.MustMarshalBinaryLengthPrefixed(&ubd) } // unmarshal a unbonding delegation from a store value -func MustUnmarshalUBD(cdc *codec.Codec, value []byte) UnbondingDelegation { +func MustUnmarshalUBD(cdc codec.Marshaler, value []byte) UnbondingDelegation { ubd, err := UnmarshalUBD(cdc, value) if err != nil { panic(err) @@ -178,19 +139,11 @@ func MustUnmarshalUBD(cdc *codec.Codec, value []byte) UnbondingDelegation { } // unmarshal a unbonding delegation from a store value -func UnmarshalUBD(cdc *codec.Codec, value []byte) (ubd UnbondingDelegation, err error) { +func UnmarshalUBD(cdc codec.Marshaler, value []byte) (ubd UnbondingDelegation, err error) { err = cdc.UnmarshalBinaryLengthPrefixed(value, &ubd) return ubd, err } -// nolint -// inefficient but only used in testing -func (d UnbondingDelegation) Equal(d2 UnbondingDelegation) bool { - bz1 := ModuleCdc.MustMarshalBinaryLengthPrefixed(&d) - bz2 := ModuleCdc.MustMarshalBinaryLengthPrefixed(&d2) - return bytes.Equal(bz1, bz2) -} - // String returns a human readable string representation of an UnbondingDelegation. func (d UnbondingDelegation) String() string { out := fmt.Sprintf(`Unbonding Delegations between: @@ -217,46 +170,7 @@ func (ubds UnbondingDelegations) String() (out string) { return strings.TrimSpace(out) } -// Redelegation contains the list of a particular delegator's -// redelegating bonds from a particular source validator to a -// particular destination validator -type Redelegation struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` // delegator - ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address" yaml:"validator_src_address"` // validator redelegation source operator addr - ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address" yaml:"validator_dst_address"` // validator redelegation destination operator addr - Entries []RedelegationEntry `json:"entries" yaml:"entries"` // redelegation entries -} - -// RedelegationEntry - entry to a Redelegation -type RedelegationEntry struct { - CreationHeight int64 `json:"creation_height" yaml:"creation_height"` // height at which the redelegation took place - CompletionTime time.Time `json:"completion_time" yaml:"completion_time"` // time at which the redelegation will complete - InitialBalance sdk.Int `json:"initial_balance" yaml:"initial_balance"` // initial balance when redelegation started - SharesDst sdk.Dec `json:"shares_dst" yaml:"shares_dst"` // amount of destination-validator shares created by redelegation -} - -// NewRedelegation - create a new redelegation object -func NewRedelegation(delegatorAddr sdk.AccAddress, validatorSrcAddr, - validatorDstAddr sdk.ValAddress, creationHeight int64, - minTime time.Time, balance sdk.Int, - sharesDst sdk.Dec) Redelegation { - - entry := NewRedelegationEntry(creationHeight, - minTime, balance, sharesDst) - - return Redelegation{ - DelegatorAddress: delegatorAddr, - ValidatorSrcAddress: validatorSrcAddr, - ValidatorDstAddress: validatorDstAddr, - Entries: []RedelegationEntry{entry}, - } -} - -// NewRedelegationEntry - create a new redelegation object -func NewRedelegationEntry(creationHeight int64, - completionTime time.Time, balance sdk.Int, - sharesDst sdk.Dec) RedelegationEntry { - +func NewRedelegationEntry(creationHeight int64, completionTime time.Time, balance sdk.Int, sharesDst sdk.Dec) RedelegationEntry { return RedelegationEntry{ CreationHeight: creationHeight, CompletionTime: completionTime, @@ -265,11 +179,32 @@ func NewRedelegationEntry(creationHeight int64, } } +// String implements the Stringer interface for a RedelegationEntry object. +func (red RedelegationEntry) String() string { + out, _ := yaml.Marshal(red) + return string(out) +} + // IsMature - is the current entry mature func (e RedelegationEntry) IsMature(currentTime time.Time) bool { return !e.CompletionTime.After(currentTime) } +func NewRedelegation( + delegatorAddr sdk.AccAddress, validatorSrcAddr, validatorDstAddr sdk.ValAddress, + creationHeight int64, minTime time.Time, balance sdk.Int, sharesDst sdk.Dec, +) Redelegation { + + return Redelegation{ + DelegatorAddress: delegatorAddr, + ValidatorSrcAddress: validatorSrcAddr, + ValidatorDstAddress: validatorDstAddr, + Entries: []RedelegationEntry{ + NewRedelegationEntry(creationHeight, minTime, balance, sharesDst), + }, + } +} + // AddEntry - append entry to the unbonding delegation func (d *Redelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int, @@ -285,12 +220,12 @@ func (d *Redelegation) RemoveEntry(i int64) { } // MustMarshalRED returns the Redelegation bytes. Panics if fails. -func MustMarshalRED(cdc *codec.Codec, red Redelegation) []byte { - return cdc.MustMarshalBinaryLengthPrefixed(red) +func MustMarshalRED(cdc codec.Marshaler, red Redelegation) []byte { + return cdc.MustMarshalBinaryLengthPrefixed(&red) } // MustUnmarshalRED unmarshals a redelegation from a store value. Panics if fails. -func MustUnmarshalRED(cdc *codec.Codec, value []byte) Redelegation { +func MustUnmarshalRED(cdc codec.Marshaler, value []byte) Redelegation { red, err := UnmarshalRED(cdc, value) if err != nil { panic(err) @@ -299,19 +234,11 @@ func MustUnmarshalRED(cdc *codec.Codec, value []byte) Redelegation { } // UnmarshalRED unmarshals a redelegation from a store value -func UnmarshalRED(cdc *codec.Codec, value []byte) (red Redelegation, err error) { +func UnmarshalRED(cdc codec.Marshaler, value []byte) (red Redelegation, err error) { err = cdc.UnmarshalBinaryLengthPrefixed(value, &red) return red, err } -// nolint -// inefficient but only used in tests -func (d Redelegation) Equal(d2 Redelegation) bool { - bz1 := ModuleCdc.MustMarshalBinaryLengthPrefixed(&d) - bz2 := ModuleCdc.MustMarshalBinaryLengthPrefixed(&d2) - return bytes.Equal(bz1, bz2) -} - // String returns a human readable string representation of a Redelegation. func (d Redelegation) String() string { out := fmt.Sprintf(`Redelegations between: diff --git a/x/staking/types/historical_info.go b/x/staking/types/historical_info.go index 1c08caebcde6..58215b1eb53f 100644 --- a/x/staking/types/historical_info.go +++ b/x/staking/types/historical_info.go @@ -25,13 +25,37 @@ func NewHistoricalInfo(header abci.Header, valSet Validators) HistoricalInfo { } } +// ToProto converts a HistoricalInfo into a HistoricalInfoProto type. +func (hi HistoricalInfo) ToProto() HistoricalInfoProto { + valsetProto := make([]ValidatorProto, len(hi.ValSet)) + for i, val := range hi.ValSet { + valsetProto[i] = val.ToProto() + } + + return HistoricalInfoProto{ + Header: hi.Header, + Valset: valsetProto, + } +} + +// ToHistoricalInfo converts a HistoricalInfoProto to a HistoricalInfo type. +func (hip HistoricalInfoProto) ToHistoricalInfo() HistoricalInfo { + valset := make(Validators, len(hip.Valset)) + for i, valProto := range hip.Valset { + valset[i] = valProto.ToValidator() + } + + return NewHistoricalInfo(hip.Header, valset) +} + // MustMarshalHistoricalInfo wll marshal historical info and panic on error -func MustMarshalHistoricalInfo(cdc *codec.Codec, hi HistoricalInfo) []byte { - return cdc.MustMarshalBinaryLengthPrefixed(hi) +func MustMarshalHistoricalInfo(cdc codec.Marshaler, hi HistoricalInfo) []byte { + hiProto := hi.ToProto() + return cdc.MustMarshalBinaryLengthPrefixed(&hiProto) } // MustUnmarshalHistoricalInfo wll unmarshal historical info and panic on error -func MustUnmarshalHistoricalInfo(cdc *codec.Codec, value []byte) HistoricalInfo { +func MustUnmarshalHistoricalInfo(cdc codec.Marshaler, value []byte) HistoricalInfo { hi, err := UnmarshalHistoricalInfo(cdc, value) if err != nil { panic(err) @@ -40,9 +64,13 @@ func MustUnmarshalHistoricalInfo(cdc *codec.Codec, value []byte) HistoricalInfo } // UnmarshalHistoricalInfo will unmarshal historical info and return any error -func UnmarshalHistoricalInfo(cdc *codec.Codec, value []byte) (hi HistoricalInfo, err error) { - err = cdc.UnmarshalBinaryLengthPrefixed(value, &hi) - return hi, err +func UnmarshalHistoricalInfo(cdc codec.Marshaler, value []byte) (hi HistoricalInfo, err error) { + hip := HistoricalInfoProto{} + if err := cdc.UnmarshalBinaryLengthPrefixed(value, &hip); err != nil { + return HistoricalInfo{}, err + } + + return hip.ToHistoricalInfo(), nil } // ValidateBasic will ensure HistoricalInfo is not nil and sorted diff --git a/x/staking/types/params.go b/x/staking/types/params.go index f3aefb404899..ae3dd7cf8ae7 100644 --- a/x/staking/types/params.go +++ b/x/staking/types/params.go @@ -1,7 +1,6 @@ package types import ( - "bytes" "errors" "fmt" "strings" @@ -10,6 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/params" + yaml "gopkg.in/yaml.v2" ) // Staking params default values @@ -20,14 +20,14 @@ const ( DefaultUnbondingTime time.Duration = time.Hour * 24 * 7 * 3 // Default maximum number of bonded validators - DefaultMaxValidators uint16 = 100 + DefaultMaxValidators uint32 = 100 // Default maximum entries in a UBD/RED pair - DefaultMaxEntries uint16 = 7 + DefaultMaxEntries uint32 = 7 // DefaultHistorical entries is 0 since it must only be non-zero for // IBC connected chains - DefaultHistoricalEntries uint16 = 0 + DefaultHistoricalEntries uint32 = 0 ) // nolint - Keys for parameter access @@ -41,18 +41,10 @@ var ( var _ params.ParamSet = (*Params)(nil) -// Params defines the high level settings for staking -type Params struct { - UnbondingTime time.Duration `json:"unbonding_time" yaml:"unbonding_time"` // time duration of unbonding - MaxValidators uint16 `json:"max_validators" yaml:"max_validators"` // maximum number of validators (max uint16 = 65535) - MaxEntries uint16 `json:"max_entries" yaml:"max_entries"` // max entries for either unbonding delegation or redelegation (per pair/trio) - HistoricalEntries uint16 `json:"historical_entries" yaml:"historical_entries"` // number of historical entries to persist - BondDenom string `json:"bond_denom" yaml:"bond_denom"` // bondable coin denomination -} - // NewParams creates a new Params instance -func NewParams(unbondingTime time.Duration, maxValidators, maxEntries, historicalEntries uint16, - bondDenom string) Params { +func NewParams( + unbondingTime time.Duration, maxValidators, maxEntries, historicalEntries uint32, bondDenom string, +) Params { return Params{ UnbondingTime: unbondingTime, @@ -74,28 +66,21 @@ func (p *Params) ParamSetPairs() params.ParamSetPairs { } } -// Equal returns a boolean determining if two Param types are identical. -// TODO: This is slower than comparing struct fields directly -func (p Params) Equal(p2 Params) bool { - bz1 := ModuleCdc.MustMarshalBinaryLengthPrefixed(&p) - bz2 := ModuleCdc.MustMarshalBinaryLengthPrefixed(&p2) - return bytes.Equal(bz1, bz2) -} - // DefaultParams returns a default set of parameters. func DefaultParams() Params { - return NewParams(DefaultUnbondingTime, DefaultMaxValidators, DefaultMaxEntries, DefaultHistoricalEntries, sdk.DefaultBondDenom) + return NewParams( + DefaultUnbondingTime, + DefaultMaxValidators, + DefaultMaxEntries, + DefaultHistoricalEntries, + sdk.DefaultBondDenom, + ) } // String returns a human readable string representation of the parameters. func (p Params) String() string { - return fmt.Sprintf(`Params: - Unbonding Time: %s - Max Validators: %d - Max Entries: %d - Historical Entries: %d - Bonded Coin Denom: %s`, p.UnbondingTime, - p.MaxValidators, p.MaxEntries, p.HistoricalEntries, p.BondDenom) + out, _ := yaml.Marshal(p) + return string(out) } // unmarshal the current staking params value from store key or panic @@ -148,7 +133,7 @@ func validateUnbondingTime(i interface{}) error { } func validateMaxValidators(i interface{}) error { - v, ok := i.(uint16) + v, ok := i.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } @@ -161,7 +146,7 @@ func validateMaxValidators(i interface{}) error { } func validateMaxEntries(i interface{}) error { - v, ok := i.(uint16) + v, ok := i.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } @@ -174,7 +159,7 @@ func validateMaxEntries(i interface{}) error { } func validateHistoricalEntries(i interface{}) error { - _, ok := i.(uint16) + _, ok := i.(uint32) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } diff --git a/x/staking/types/types.pb.go b/x/staking/types/types.pb.go new file mode 100644 index 000000000000..55d2ae2322a7 --- /dev/null +++ b/x/staking/types/types.pb.go @@ -0,0 +1,4790 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/staking/types/types.proto + +package types + +import ( + bytes "bytes" + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types1 "github.com/cosmos/cosmos-sdk/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + _ "github.com/golang/protobuf/ptypes/duration" + _ "github.com/golang/protobuf/ptypes/timestamp" + types "github.com/tendermint/tendermint/abci/types" + io "io" + math "math" + math_bits "math/bits" + time "time" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf +var _ = time.Kitchen + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// HistoricalInfoProto contains the historical information that gets stored at +// each height. +type HistoricalInfoProto struct { + Header types.Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"` + Valset []ValidatorProto `protobuf:"bytes,2,rep,name=valset,proto3" json:"valset"` +} + +func (m *HistoricalInfoProto) Reset() { *m = HistoricalInfoProto{} } +func (m *HistoricalInfoProto) String() string { return proto.CompactTextString(m) } +func (*HistoricalInfoProto) ProtoMessage() {} +func (*HistoricalInfoProto) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{0} +} +func (m *HistoricalInfoProto) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HistoricalInfoProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HistoricalInfoProto.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *HistoricalInfoProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_HistoricalInfoProto.Merge(m, src) +} +func (m *HistoricalInfoProto) XXX_Size() int { + return m.Size() +} +func (m *HistoricalInfoProto) XXX_DiscardUnknown() { + xxx_messageInfo_HistoricalInfoProto.DiscardUnknown(m) +} + +var xxx_messageInfo_HistoricalInfoProto proto.InternalMessageInfo + +func (m *HistoricalInfoProto) GetHeader() types.Header { + if m != nil { + return m.Header + } + return types.Header{} +} + +func (m *HistoricalInfoProto) GetValset() []ValidatorProto { + if m != nil { + return m.Valset + } + return nil +} + +// CommissionRates defines the initial commission rates to be used for creating +// a validator. +type CommissionRates struct { + Rate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rate"` + MaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=max_rate,json=maxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_rate" yaml:"max_rate"` + MaxChangeRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=max_change_rate,json=maxChangeRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"max_change_rate" yaml:"max_change_rate"` +} + +func (m *CommissionRates) Reset() { *m = CommissionRates{} } +func (*CommissionRates) ProtoMessage() {} +func (*CommissionRates) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{1} +} +func (m *CommissionRates) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CommissionRates) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CommissionRates.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CommissionRates) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommissionRates.Merge(m, src) +} +func (m *CommissionRates) XXX_Size() int { + return m.Size() +} +func (m *CommissionRates) XXX_DiscardUnknown() { + xxx_messageInfo_CommissionRates.DiscardUnknown(m) +} + +var xxx_messageInfo_CommissionRates proto.InternalMessageInfo + +// Commission defines a commission parameters for a given validator. +type Commission struct { + CommissionRates `protobuf:"bytes,1,opt,name=commission_rates,json=commissionRates,proto3,embedded=commission_rates" json:"commission_rates"` + UpdateTime time.Time `protobuf:"bytes,2,opt,name=update_time,json=updateTime,proto3,stdtime" json:"update_time" yaml:"update_time"` +} + +func (m *Commission) Reset() { *m = Commission{} } +func (*Commission) ProtoMessage() {} +func (*Commission) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{2} +} +func (m *Commission) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Commission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Commission.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Commission) XXX_Merge(src proto.Message) { + xxx_messageInfo_Commission.Merge(m, src) +} +func (m *Commission) XXX_Size() int { + return m.Size() +} +func (m *Commission) XXX_DiscardUnknown() { + xxx_messageInfo_Commission.DiscardUnknown(m) +} + +var xxx_messageInfo_Commission proto.InternalMessageInfo + +func (m *Commission) GetUpdateTime() time.Time { + if m != nil { + return m.UpdateTime + } + return time.Time{} +} + +// Description defines a validator description. +type Description struct { + Moniker string `protobuf:"bytes,1,opt,name=moniker,proto3" json:"moniker,omitempty"` + Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + Website string `protobuf:"bytes,3,opt,name=website,proto3" json:"website,omitempty"` + SecurityContact string `protobuf:"bytes,4,opt,name=security_contact,json=securityContact,proto3" json:"security_contact,omitempty" yaml:"security_contact"` + Details string `protobuf:"bytes,5,opt,name=details,proto3" json:"details,omitempty"` +} + +func (m *Description) Reset() { *m = Description{} } +func (*Description) ProtoMessage() {} +func (*Description) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{3} +} +func (m *Description) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Description) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Description.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Description) XXX_Merge(src proto.Message) { + xxx_messageInfo_Description.Merge(m, src) +} +func (m *Description) XXX_Size() int { + return m.Size() +} +func (m *Description) XXX_DiscardUnknown() { + xxx_messageInfo_Description.DiscardUnknown(m) +} + +var xxx_messageInfo_Description proto.InternalMessageInfo + +func (m *Description) GetMoniker() string { + if m != nil { + return m.Moniker + } + return "" +} + +func (m *Description) GetIdentity() string { + if m != nil { + return m.Identity + } + return "" +} + +func (m *Description) GetWebsite() string { + if m != nil { + return m.Website + } + return "" +} + +func (m *Description) GetSecurityContact() string { + if m != nil { + return m.SecurityContact + } + return "" +} + +func (m *Description) GetDetails() string { + if m != nil { + return m.Details + } + return "" +} + +// ValidatorProto defines the Protocol buffer equivalent of the Validator type. +type ValidatorProto struct { + OperatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"operator_address,omitempty" yaml:"operator_address"` + // TODO: We can remove cosmos_sdk.v1.PublicKey in favor of the primitive bytes + // once Tendermint supports pubkeys as slices. + ConsensusPubkey types1.PublicKey `protobuf:"bytes,2,opt,name=consensus_pubkey,json=consensusPubkey,proto3" json:"consensus_pubkey" yaml:"consensus_pubkey"` + Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed,omitempty"` + Status []byte `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"` + Tokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=tokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"tokens"` + DelegatorShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=delegator_shares,json=delegatorShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"delegator_shares" yaml:"delegator_shares"` + Description Description `protobuf:"bytes,7,opt,name=description,proto3" json:"description"` + UnbondingHeight int64 `protobuf:"varint,8,opt,name=unbonding_height,json=unbondingHeight,proto3" json:"unbonding_height,omitempty" yaml:"unbonding_height"` + UnbondingTime time.Time `protobuf:"bytes,9,opt,name=unbonding_time,json=unbondingTime,proto3,stdtime" json:"unbonding_time" yaml:"unbonding_time"` + Commission Commission `protobuf:"bytes,10,opt,name=commission,proto3" json:"commission"` + MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation" yaml:"min_self_delegation"` +} + +func (m *ValidatorProto) Reset() { *m = ValidatorProto{} } +func (m *ValidatorProto) String() string { return proto.CompactTextString(m) } +func (*ValidatorProto) ProtoMessage() {} +func (*ValidatorProto) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{4} +} +func (m *ValidatorProto) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorProto.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ValidatorProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorProto.Merge(m, src) +} +func (m *ValidatorProto) XXX_Size() int { + return m.Size() +} +func (m *ValidatorProto) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorProto.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorProto proto.InternalMessageInfo + +func (m *ValidatorProto) GetOperatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.OperatorAddress + } + return nil +} + +func (m *ValidatorProto) GetConsensusPubkey() types1.PublicKey { + if m != nil { + return m.ConsensusPubkey + } + return types1.PublicKey{} +} + +func (m *ValidatorProto) GetJailed() bool { + if m != nil { + return m.Jailed + } + return false +} + +func (m *ValidatorProto) GetStatus() []byte { + if m != nil { + return m.Status + } + return nil +} + +func (m *ValidatorProto) GetDescription() Description { + if m != nil { + return m.Description + } + return Description{} +} + +func (m *ValidatorProto) GetUnbondingHeight() int64 { + if m != nil { + return m.UnbondingHeight + } + return 0 +} + +func (m *ValidatorProto) GetUnbondingTime() time.Time { + if m != nil { + return m.UnbondingTime + } + return time.Time{} +} + +func (m *ValidatorProto) GetCommission() Commission { + if m != nil { + return m.Commission + } + return Commission{} +} + +// DVPair is struct that just has a delegator-validator pair with no other data. +// It is intended to be used as a marshalable pointer. For example, a DVPair can +// be used to construct the key to getting an UnbondingDelegation from state. +type DVPair struct { + DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"validator_address"` +} + +func (m *DVPair) Reset() { *m = DVPair{} } +func (*DVPair) ProtoMessage() {} +func (*DVPair) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{5} +} +func (m *DVPair) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DVPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DVPair.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DVPair) XXX_Merge(src proto.Message) { + xxx_messageInfo_DVPair.Merge(m, src) +} +func (m *DVPair) XXX_Size() int { + return m.Size() +} +func (m *DVPair) XXX_DiscardUnknown() { + xxx_messageInfo_DVPair.DiscardUnknown(m) +} + +var xxx_messageInfo_DVPair proto.InternalMessageInfo + +func (m *DVPair) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *DVPair) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorAddress + } + return nil +} + +// DVVTriplet is struct that just has a delegator-validator-validator triplet +// with no other data. It is intended to be used as a marshalable pointer. For +// example, a DVVTriplet can be used to construct the key to getting a +// Redelegation from state. +type DVVTriplet struct { + DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorSrcAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_src_address,json=validatorSrcAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_src_address,omitempty" yaml:"validator_src_address"` + ValidatorDstAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,3,opt,name=validator_dst_address,json=validatorDstAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_dst_address,omitempty" yaml:"validator_dst_address"` +} + +func (m *DVVTriplet) Reset() { *m = DVVTriplet{} } +func (*DVVTriplet) ProtoMessage() {} +func (*DVVTriplet) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{6} +} +func (m *DVVTriplet) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DVVTriplet) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DVVTriplet.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DVVTriplet) XXX_Merge(src proto.Message) { + xxx_messageInfo_DVVTriplet.Merge(m, src) +} +func (m *DVVTriplet) XXX_Size() int { + return m.Size() +} +func (m *DVVTriplet) XXX_DiscardUnknown() { + xxx_messageInfo_DVVTriplet.DiscardUnknown(m) +} + +var xxx_messageInfo_DVVTriplet proto.InternalMessageInfo + +func (m *DVVTriplet) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *DVVTriplet) GetValidatorSrcAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorSrcAddress + } + return nil +} + +func (m *DVVTriplet) GetValidatorDstAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorDstAddress + } + return nil +} + +// Delegation represents the bond with tokens held by an account. It is +// owned by one delegator, and is associated with the voting power of one +// validator. +type Delegation struct { + DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"validator_address"` + Shares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=shares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"shares"` +} + +func (m *Delegation) Reset() { *m = Delegation{} } +func (*Delegation) ProtoMessage() {} +func (*Delegation) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{7} +} +func (m *Delegation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Delegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Delegation.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Delegation) XXX_Merge(src proto.Message) { + xxx_messageInfo_Delegation.Merge(m, src) +} +func (m *Delegation) XXX_Size() int { + return m.Size() +} +func (m *Delegation) XXX_DiscardUnknown() { + xxx_messageInfo_Delegation.DiscardUnknown(m) +} + +var xxx_messageInfo_Delegation proto.InternalMessageInfo + +func (m *Delegation) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *Delegation) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorAddress + } + return nil +} + +// UnbondingDelegation stores all of a single delegator's unbonding bonds +// for a single validator in an time-ordered list +type UnbondingDelegation struct { + DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"validator_address"` + Entries []UnbondingDelegationEntry `protobuf:"bytes,3,rep,name=entries,proto3" json:"entries"` +} + +func (m *UnbondingDelegation) Reset() { *m = UnbondingDelegation{} } +func (*UnbondingDelegation) ProtoMessage() {} +func (*UnbondingDelegation) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{8} +} +func (m *UnbondingDelegation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UnbondingDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UnbondingDelegation.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UnbondingDelegation) XXX_Merge(src proto.Message) { + xxx_messageInfo_UnbondingDelegation.Merge(m, src) +} +func (m *UnbondingDelegation) XXX_Size() int { + return m.Size() +} +func (m *UnbondingDelegation) XXX_DiscardUnknown() { + xxx_messageInfo_UnbondingDelegation.DiscardUnknown(m) +} + +var xxx_messageInfo_UnbondingDelegation proto.InternalMessageInfo + +func (m *UnbondingDelegation) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *UnbondingDelegation) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorAddress + } + return nil +} + +func (m *UnbondingDelegation) GetEntries() []UnbondingDelegationEntry { + if m != nil { + return m.Entries + } + return nil +} + +// UnbondingDelegationEntry defines an unbonding object with relevant metadata. +type UnbondingDelegationEntry struct { + CreationHeight int64 `protobuf:"varint,1,opt,name=creation_height,json=creationHeight,proto3" json:"creation_height,omitempty" yaml:"creation_height"` + CompletionTime time.Time `protobuf:"bytes,2,opt,name=completion_time,json=completionTime,proto3,stdtime" json:"completion_time" yaml:"completion_time"` + InitialBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=initial_balance,json=initialBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"initial_balance" yaml:"initial_balance"` + Balance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=balance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"balance"` +} + +func (m *UnbondingDelegationEntry) Reset() { *m = UnbondingDelegationEntry{} } +func (*UnbondingDelegationEntry) ProtoMessage() {} +func (*UnbondingDelegationEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{9} +} +func (m *UnbondingDelegationEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UnbondingDelegationEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UnbondingDelegationEntry.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *UnbondingDelegationEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_UnbondingDelegationEntry.Merge(m, src) +} +func (m *UnbondingDelegationEntry) XXX_Size() int { + return m.Size() +} +func (m *UnbondingDelegationEntry) XXX_DiscardUnknown() { + xxx_messageInfo_UnbondingDelegationEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_UnbondingDelegationEntry proto.InternalMessageInfo + +func (m *UnbondingDelegationEntry) GetCreationHeight() int64 { + if m != nil { + return m.CreationHeight + } + return 0 +} + +func (m *UnbondingDelegationEntry) GetCompletionTime() time.Time { + if m != nil { + return m.CompletionTime + } + return time.Time{} +} + +// RedelegationEntry defines a redelegation object with relevant metadata. +type RedelegationEntry struct { + CreationHeight int64 `protobuf:"varint,1,opt,name=creation_height,json=creationHeight,proto3" json:"creation_height,omitempty" yaml:"creation_height"` + CompletionTime time.Time `protobuf:"bytes,2,opt,name=completion_time,json=completionTime,proto3,stdtime" json:"completion_time" yaml:"completion_time"` + InitialBalance github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=initial_balance,json=initialBalance,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"initial_balance" yaml:"initial_balance"` + SharesDst github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=shares_dst,json=sharesDst,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"shares_dst"` +} + +func (m *RedelegationEntry) Reset() { *m = RedelegationEntry{} } +func (*RedelegationEntry) ProtoMessage() {} +func (*RedelegationEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{10} +} +func (m *RedelegationEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RedelegationEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RedelegationEntry.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RedelegationEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_RedelegationEntry.Merge(m, src) +} +func (m *RedelegationEntry) XXX_Size() int { + return m.Size() +} +func (m *RedelegationEntry) XXX_DiscardUnknown() { + xxx_messageInfo_RedelegationEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_RedelegationEntry proto.InternalMessageInfo + +func (m *RedelegationEntry) GetCreationHeight() int64 { + if m != nil { + return m.CreationHeight + } + return 0 +} + +func (m *RedelegationEntry) GetCompletionTime() time.Time { + if m != nil { + return m.CompletionTime + } + return time.Time{} +} + +// Redelegation contains the list of a particular delegator's redelegating bonds +// from a particular source validator to a particular destination validator. +type Redelegation struct { + DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorSrcAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_src_address,json=validatorSrcAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_src_address,omitempty" yaml:"validator_src_address"` + ValidatorDstAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,3,opt,name=validator_dst_address,json=validatorDstAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_dst_address,omitempty" yaml:"validator_dst_address"` + Entries []RedelegationEntry `protobuf:"bytes,4,rep,name=entries,proto3" json:"entries"` +} + +func (m *Redelegation) Reset() { *m = Redelegation{} } +func (*Redelegation) ProtoMessage() {} +func (*Redelegation) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{11} +} +func (m *Redelegation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Redelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Redelegation.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Redelegation) XXX_Merge(src proto.Message) { + xxx_messageInfo_Redelegation.Merge(m, src) +} +func (m *Redelegation) XXX_Size() int { + return m.Size() +} +func (m *Redelegation) XXX_DiscardUnknown() { + xxx_messageInfo_Redelegation.DiscardUnknown(m) +} + +var xxx_messageInfo_Redelegation proto.InternalMessageInfo + +func (m *Redelegation) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *Redelegation) GetValidatorSrcAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorSrcAddress + } + return nil +} + +func (m *Redelegation) GetValidatorDstAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorDstAddress + } + return nil +} + +func (m *Redelegation) GetEntries() []RedelegationEntry { + if m != nil { + return m.Entries + } + return nil +} + +// Params defines the parameters for the staking module. +type Params struct { + UnbondingTime time.Duration `protobuf:"bytes,1,opt,name=unbonding_time,json=unbondingTime,proto3,stdduration" json:"unbonding_time" yaml:"unbonding_time"` + MaxValidators uint32 `protobuf:"varint,2,opt,name=max_validators,json=maxValidators,proto3" json:"max_validators,omitempty" yaml:"max_validators"` + MaxEntries uint32 `protobuf:"varint,3,opt,name=max_entries,json=maxEntries,proto3" json:"max_entries,omitempty" yaml:"max_entries"` + HistoricalEntries uint32 `protobuf:"varint,4,opt,name=historical_entries,json=historicalEntries,proto3" json:"historical_entries,omitempty" yaml:"historical_entries"` + BondDenom string `protobuf:"bytes,5,opt,name=bond_denom,json=bondDenom,proto3" json:"bond_denom,omitempty" yaml:"bond_denom"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{12} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetUnbondingTime() time.Duration { + if m != nil { + return m.UnbondingTime + } + return 0 +} + +func (m *Params) GetMaxValidators() uint32 { + if m != nil { + return m.MaxValidators + } + return 0 +} + +func (m *Params) GetMaxEntries() uint32 { + if m != nil { + return m.MaxEntries + } + return 0 +} + +func (m *Params) GetHistoricalEntries() uint32 { + if m != nil { + return m.HistoricalEntries + } + return 0 +} + +func (m *Params) GetBondDenom() string { + if m != nil { + return m.BondDenom + } + return "" +} + +func init() { + proto.RegisterType((*HistoricalInfoProto)(nil), "cosmos_sdk.x.staking.v1.HistoricalInfoProto") + proto.RegisterType((*CommissionRates)(nil), "cosmos_sdk.x.staking.v1.CommissionRates") + proto.RegisterType((*Commission)(nil), "cosmos_sdk.x.staking.v1.Commission") + proto.RegisterType((*Description)(nil), "cosmos_sdk.x.staking.v1.Description") + proto.RegisterType((*ValidatorProto)(nil), "cosmos_sdk.x.staking.v1.ValidatorProto") + proto.RegisterType((*DVPair)(nil), "cosmos_sdk.x.staking.v1.DVPair") + proto.RegisterType((*DVVTriplet)(nil), "cosmos_sdk.x.staking.v1.DVVTriplet") + proto.RegisterType((*Delegation)(nil), "cosmos_sdk.x.staking.v1.Delegation") + proto.RegisterType((*UnbondingDelegation)(nil), "cosmos_sdk.x.staking.v1.UnbondingDelegation") + proto.RegisterType((*UnbondingDelegationEntry)(nil), "cosmos_sdk.x.staking.v1.UnbondingDelegationEntry") + proto.RegisterType((*RedelegationEntry)(nil), "cosmos_sdk.x.staking.v1.RedelegationEntry") + proto.RegisterType((*Redelegation)(nil), "cosmos_sdk.x.staking.v1.Redelegation") + proto.RegisterType((*Params)(nil), "cosmos_sdk.x.staking.v1.Params") +} + +func init() { proto.RegisterFile("x/staking/types/types.proto", fileDescriptor_c669c0a3ee1b124c) } + +var fileDescriptor_c669c0a3ee1b124c = []byte{ + // 1409 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0xcb, 0x6f, 0x1b, 0x45, + 0x18, 0xcf, 0xda, 0xc1, 0x49, 0xc6, 0x6d, 0x1c, 0x4f, 0xd4, 0xd6, 0x75, 0xa9, 0xb7, 0x2c, 0xa8, + 0x44, 0x88, 0xae, 0xd5, 0x16, 0x09, 0xa9, 0x5c, 0xa8, 0xe3, 0x56,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x46, 0x52, 0x74, 0x86, 0x75, 0xdc, 0x47, 0xfd, 0x75, 0x01, + 0x70, 0x8b, 0x57, 0x16, 0xef, 0x3f, 0xd0, 0xe7, 0x84, 0xc7, 0xbe, 0xd7, 0x00, 0x48, 0x3c, 0x06, + 0x3f, 0x02, 0x2b, 0xce, 0x78, 0x25, 0x74, 0xa9, 0x0a, 0xea, 0xda, 0xd4, 0xb8, 0x64, 0x1c, 0xde, + 0x58, 0xe4, 0xbb, 0x7e, 0x34, 0xd4, 0x35, 0xab, 0xe4, 0x64, 0x62, 0xf1, 0x01, 0x28, 0xf6, 0xba, + 0x2e, 0x62, 0xd8, 0xe6, 0xe9, 0x28, 0x5c, 0x59, 0xbc, 0x54, 0x35, 0x65, 0x2a, 0x9a, 0x71, 0x2a, + 0x9a, 0xb7, 0xe3, 0x5c, 0x6d, 0xd4, 0x38, 0xd7, 0x68, 0xa8, 0x43, 0x79, 0xae, 0x94, 0xb2, 0x71, + 0xef, 0x67, 0x5d, 0xb3, 0x80, 0x44, 0xb8, 0x42, 0xea, 0x50, 0xdf, 0x69, 0xa0, 0xd8, 0xc4, 0xd4, + 0x89, 0x48, 0x97, 0x67, 0x34, 0xac, 0x80, 0x05, 0x3f, 0x0c, 0xc8, 0x9e, 0xca, 0xd0, 0x25, 0x2b, + 0x5e, 0xc2, 0x2a, 0x58, 0x24, 0x2e, 0x0e, 0x18, 0x61, 0x03, 0x19, 0x58, 0x6b, 0xbc, 0xe6, 0x5a, + 0x77, 0x70, 0x8b, 0x92, 0x38, 0x1c, 0x56, 0xbc, 0x84, 0xd7, 0xc1, 0x0a, 0xc5, 0x4e, 0x2f, 0x22, + 0x6c, 0x60, 0x3b, 0x61, 0xc0, 0x90, 0xc3, 0x2a, 0xf3, 0x22, 0x62, 0x67, 0x46, 0x43, 0xfd, 0x94, + 0xdc, 0x6b, 0x56, 0xc2, 0xb0, 0x4a, 0x31, 0xb4, 0x2e, 0x11, 0x6e, 0xc1, 0xc5, 0x0c, 0x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x73, 0x67, 0xe7, 0x76, 0x44, 0xba, + 0x1e, 0x66, 0xff, 0xaa, 0x43, 0x3e, 0xd3, 0xc0, 0x89, 0xe4, 0xb8, 0x34, 0x72, 0x32, 0x5e, 0xb9, + 0x39, 0x1a, 0xea, 0x2f, 0x66, 0xbd, 0x92, 0x12, 0x3b, 0x84, 0x67, 0x56, 0xc7, 0x44, 0xb7, 0x22, + 0xe7, 0xe9, 0xfb, 0x70, 0x29, 0x1b, 0xef, 0x23, 0x3f, 0x7d, 0x1f, 0x29, 0xb1, 0x7f, 0xb4, 0x8f, + 0x26, 0x65, 0x93, 0x41, 0xfa, 0x21, 0x07, 0x40, 0x92, 0xc6, 0xff, 0xd7, 0xac, 0xe5, 0x13, 0x44, + 0xf5, 0xfb, 0xfc, 0xa1, 0x2e, 0x89, 0x4a, 0x3b, 0xe5, 0xd8, 0xdf, 0x72, 0x60, 0xf5, 0xbd, 0xb8, + 0xd7, 0x1d, 0x79, 0x18, 0xde, 0x04, 0x0b, 0x38, 0x60, 0x11, 0x11, 0x2e, 0xe6, 0xd7, 0xfc, 0x8b, + 0x53, 0xdb, 0xfc, 0x53, 0xdc, 0x76, 0x2d, 0x60, 0xd1, 0x40, 0x35, 0xfd, 0x98, 0x27, 0xe5, 0xec, + 0x2f, 0xf3, 0xa0, 0x32, 0x4d, 0x0b, 0xae, 0x83, 0x92, 0x13, 0x61, 0x01, 0xc4, 0x03, 0x51, 0x13, + 0x03, 0xb1, 0x9a, 0x5c, 0x97, 0x33, 0x02, 0x86, 0xb5, 0x1c, 0x23, 0x6a, 0x1c, 0xb6, 0x01, 0xbf, + 0xca, 0xf2, 0x46, 0xc6, 0xa5, 0x9e, 0xf3, 0xee, 0x6a, 0xa8, 0x79, 0x18, 0x1b, 0x39, 0x48, 0x20, + 0x07, 0xe2, 0x72, 0x82, 0x8a, 0x89, 0xf8, 0x09, 0x28, 0x91, 0x80, 0x30, 0x82, 0x3c, 0xbb, 0x85, + 0x3c, 0x14, 0x38, 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x65, 0x0c, 0xab, 0x9c, 0x80, 0x31, 0xdb, 0x1b, + 0x00, 0xf0, 0x73, 0xd9, 0x2e, 0x0e, 0x42, 0x5f, 0xbd, 0x52, 0x9e, 0x18, 0x0d, 0xf5, 0xb2, 0x64, + 0x49, 0x9e, 0x19, 0xd6, 0x12, 0x5f, 0x34, 0xf9, 0xef, 0xc4, 0xf1, 0x8d, 0xeb, 0x0f, 0x1f, 0xd7, + 0xb4, 0x47, 0x8f, 0x6b, 0xda, 0x2f, 0x8f, 0x6b, 0xda, 0xbd, 0x27, 0xb5, 0xb9, 0x47, 0x4f, 0x6a, + 0x73, 0x3f, 0x3e, 0xa9, 0xcd, 0xbd, 0xff, 0xfa, 0xdf, 0x26, 0x4b, 0xe6, 0x1b, 0x62, 0xab, 0x20, + 0xa2, 0x72, 0xf9, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8e, 0x7c, 0xff, 0xbb, 0x5d, 0x14, 0x00, + 0x00, +} + +func (this *HistoricalInfoProto) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*HistoricalInfoProto) + if !ok { + that2, ok := that.(HistoricalInfoProto) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Header.Equal(&that1.Header) { + return false + } + if len(this.Valset) != len(that1.Valset) { + return false + } + for i := range this.Valset { + if !this.Valset[i].Equal(&that1.Valset[i]) { + return false + } + } + return true +} +func (this *CommissionRates) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*CommissionRates) + if !ok { + that2, ok := that.(CommissionRates) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Rate.Equal(that1.Rate) { + return false + } + if !this.MaxRate.Equal(that1.MaxRate) { + return false + } + if !this.MaxChangeRate.Equal(that1.MaxChangeRate) { + return false + } + return true +} +func (this *Commission) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Commission) + if !ok { + that2, ok := that.(Commission) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.CommissionRates.Equal(&that1.CommissionRates) { + return false + } + if !this.UpdateTime.Equal(that1.UpdateTime) { + return false + } + return true +} +func (this *Description) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Description) + if !ok { + that2, ok := that.(Description) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Moniker != that1.Moniker { + return false + } + if this.Identity != that1.Identity { + return false + } + if this.Website != that1.Website { + return false + } + if this.SecurityContact != that1.SecurityContact { + return false + } + if this.Details != that1.Details { + return false + } + return true +} +func (this *ValidatorProto) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*ValidatorProto) + if !ok { + that2, ok := that.(ValidatorProto) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.OperatorAddress, that1.OperatorAddress) { + return false + } + if !this.ConsensusPubkey.Equal(&that1.ConsensusPubkey) { + return false + } + if this.Jailed != that1.Jailed { + return false + } + if !bytes.Equal(this.Status, that1.Status) { + return false + } + if !this.Tokens.Equal(that1.Tokens) { + return false + } + if !this.DelegatorShares.Equal(that1.DelegatorShares) { + return false + } + if !this.Description.Equal(&that1.Description) { + return false + } + if this.UnbondingHeight != that1.UnbondingHeight { + return false + } + if !this.UnbondingTime.Equal(that1.UnbondingTime) { + return false + } + if !this.Commission.Equal(&that1.Commission) { + return false + } + if !this.MinSelfDelegation.Equal(that1.MinSelfDelegation) { + return false + } + return true +} +func (this *DVPair) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DVPair) + if !ok { + that2, ok := that.(DVPair) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.DelegatorAddress, that1.DelegatorAddress) { + return false + } + if !bytes.Equal(this.ValidatorAddress, that1.ValidatorAddress) { + return false + } + return true +} +func (this *DVVTriplet) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DVVTriplet) + if !ok { + that2, ok := that.(DVVTriplet) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.DelegatorAddress, that1.DelegatorAddress) { + return false + } + if !bytes.Equal(this.ValidatorSrcAddress, that1.ValidatorSrcAddress) { + return false + } + if !bytes.Equal(this.ValidatorDstAddress, that1.ValidatorDstAddress) { + return false + } + return true +} +func (this *Delegation) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Delegation) + if !ok { + that2, ok := that.(Delegation) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.DelegatorAddress, that1.DelegatorAddress) { + return false + } + if !bytes.Equal(this.ValidatorAddress, that1.ValidatorAddress) { + return false + } + if !this.Shares.Equal(that1.Shares) { + return false + } + return true +} +func (this *UnbondingDelegation) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*UnbondingDelegation) + if !ok { + that2, ok := that.(UnbondingDelegation) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.DelegatorAddress, that1.DelegatorAddress) { + return false + } + if !bytes.Equal(this.ValidatorAddress, that1.ValidatorAddress) { + return false + } + if len(this.Entries) != len(that1.Entries) { + return false + } + for i := range this.Entries { + if !this.Entries[i].Equal(&that1.Entries[i]) { + return false + } + } + return true +} +func (this *UnbondingDelegationEntry) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*UnbondingDelegationEntry) + if !ok { + that2, ok := that.(UnbondingDelegationEntry) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.CreationHeight != that1.CreationHeight { + return false + } + if !this.CompletionTime.Equal(that1.CompletionTime) { + return false + } + if !this.InitialBalance.Equal(that1.InitialBalance) { + return false + } + if !this.Balance.Equal(that1.Balance) { + return false + } + return true +} +func (this *RedelegationEntry) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*RedelegationEntry) + if !ok { + that2, ok := that.(RedelegationEntry) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.CreationHeight != that1.CreationHeight { + return false + } + if !this.CompletionTime.Equal(that1.CompletionTime) { + return false + } + if !this.InitialBalance.Equal(that1.InitialBalance) { + return false + } + if !this.SharesDst.Equal(that1.SharesDst) { + return false + } + return true +} +func (this *Redelegation) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Redelegation) + if !ok { + that2, ok := that.(Redelegation) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !bytes.Equal(this.DelegatorAddress, that1.DelegatorAddress) { + return false + } + if !bytes.Equal(this.ValidatorSrcAddress, that1.ValidatorSrcAddress) { + return false + } + if !bytes.Equal(this.ValidatorDstAddress, that1.ValidatorDstAddress) { + return false + } + if len(this.Entries) != len(that1.Entries) { + return false + } + for i := range this.Entries { + if !this.Entries[i].Equal(&that1.Entries[i]) { + return false + } + } + return true +} +func (this *Params) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*Params) + if !ok { + that2, ok := that.(Params) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.UnbondingTime != that1.UnbondingTime { + return false + } + if this.MaxValidators != that1.MaxValidators { + return false + } + if this.MaxEntries != that1.MaxEntries { + return false + } + if this.HistoricalEntries != that1.HistoricalEntries { + return false + } + if this.BondDenom != that1.BondDenom { + return false + } + return true +} +func (m *HistoricalInfoProto) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HistoricalInfoProto) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HistoricalInfoProto) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Valset) > 0 { + for iNdEx := len(m.Valset) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Valset[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *CommissionRates) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CommissionRates) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommissionRates) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MaxChangeRate.Size() + i -= size + if _, err := m.MaxChangeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.MaxRate.Size() + i -= size + if _, err := m.MaxRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.Rate.Size() + i -= size + if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Commission) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Commission) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Commission) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdateTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdateTime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintTypes(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0x12 + { + size, err := m.CommissionRates.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Description) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Description) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Description) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Details) > 0 { + i -= len(m.Details) + copy(dAtA[i:], m.Details) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Details))) + i-- + dAtA[i] = 0x2a + } + if len(m.SecurityContact) > 0 { + i -= len(m.SecurityContact) + copy(dAtA[i:], m.SecurityContact) + i = encodeVarintTypes(dAtA, i, uint64(len(m.SecurityContact))) + i-- + dAtA[i] = 0x22 + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x1a + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x12 + } + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ValidatorProto) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ValidatorProto) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorProto) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MinSelfDelegation.Size() + i -= size + if _, err := m.MinSelfDelegation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + { + size, err := m.Commission.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UnbondingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UnbondingTime):]) + if err5 != nil { + return 0, err5 + } + i -= n5 + i = encodeVarintTypes(dAtA, i, uint64(n5)) + i-- + dAtA[i] = 0x4a + if m.UnbondingHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.UnbondingHeight)) + i-- + dAtA[i] = 0x40 + } + { + size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + { + size := m.DelegatorShares.Size() + i -= size + if _, err := m.DelegatorShares.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size := m.Tokens.Size() + i -= size + if _, err := m.Tokens.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + if len(m.Status) > 0 { + i -= len(m.Status) + copy(dAtA[i:], m.Status) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Status))) + i-- + dAtA[i] = 0x22 + } + if m.Jailed { + i-- + if m.Jailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + { + size, err := m.ConsensusPubkey.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.OperatorAddress) > 0 { + i -= len(m.OperatorAddress) + copy(dAtA[i:], m.OperatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.OperatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DVPair) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DVPair) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DVPair) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *DVVTriplet) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DVVTriplet) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DVVTriplet) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorDstAddress) > 0 { + i -= len(m.ValidatorDstAddress) + copy(dAtA[i:], m.ValidatorDstAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorDstAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.ValidatorSrcAddress) > 0 { + i -= len(m.ValidatorSrcAddress) + copy(dAtA[i:], m.ValidatorSrcAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorSrcAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Delegation) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Delegation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Delegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Shares.Size() + i -= size + if _, err := m.Shares.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UnbondingDelegation) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UnbondingDelegation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UnbondingDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Entries) > 0 { + for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *UnbondingDelegationEntry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *UnbondingDelegationEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UnbondingDelegationEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Balance.Size() + i -= size + if _, err := m.Balance.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.InitialBalance.Size() + i -= size + if _, err := m.InitialBalance.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + n8, err8 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime):]) + if err8 != nil { + return 0, err8 + } + i -= n8 + i = encodeVarintTypes(dAtA, i, uint64(n8)) + i-- + dAtA[i] = 0x12 + if m.CreationHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.CreationHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *RedelegationEntry) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RedelegationEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RedelegationEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.SharesDst.Size() + i -= size + if _, err := m.SharesDst.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size := m.InitialBalance.Size() + i -= size + if _, err := m.InitialBalance.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime):]) + if err9 != nil { + return 0, err9 + } + i -= n9 + i = encodeVarintTypes(dAtA, i, uint64(n9)) + i-- + dAtA[i] = 0x12 + if m.CreationHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.CreationHeight)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *Redelegation) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Redelegation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Redelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Entries) > 0 { + for iNdEx := len(m.Entries) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Entries[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + if len(m.ValidatorDstAddress) > 0 { + i -= len(m.ValidatorDstAddress) + copy(dAtA[i:], m.ValidatorDstAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorDstAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.ValidatorSrcAddress) > 0 { + i -= len(m.ValidatorSrcAddress) + copy(dAtA[i:], m.ValidatorSrcAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorSrcAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Params) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BondDenom) > 0 { + i -= len(m.BondDenom) + copy(dAtA[i:], m.BondDenom) + i = encodeVarintTypes(dAtA, i, uint64(len(m.BondDenom))) + i-- + dAtA[i] = 0x2a + } + if m.HistoricalEntries != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.HistoricalEntries)) + i-- + dAtA[i] = 0x20 + } + if m.MaxEntries != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.MaxEntries)) + i-- + dAtA[i] = 0x18 + } + if m.MaxValidators != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.MaxValidators)) + i-- + dAtA[i] = 0x10 + } + n10, err10 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingTime):]) + if err10 != nil { + return 0, err10 + } + i -= n10 + i = encodeVarintTypes(dAtA, i, uint64(n10)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *HistoricalInfoProto) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Header.Size() + n += 1 + l + sovTypes(uint64(l)) + if len(m.Valset) > 0 { + for _, e := range m.Valset { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *CommissionRates) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Rate.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.MaxRate.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.MaxChangeRate.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *Commission) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.CommissionRates.Size() + n += 1 + l + sovTypes(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdateTime) + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *Description) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Moniker) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Website) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.SecurityContact) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Details) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *ValidatorProto) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.OperatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.ConsensusPubkey.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.Jailed { + n += 2 + } + l = len(m.Status) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Tokens.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.DelegatorShares.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.Description.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.UnbondingHeight != 0 { + n += 1 + sovTypes(uint64(m.UnbondingHeight)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.UnbondingTime) + n += 1 + l + sovTypes(uint64(l)) + l = m.Commission.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.MinSelfDelegation.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *DVPair) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *DVVTriplet) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorSrcAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorDstAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Delegation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Shares.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *UnbondingDelegation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if len(m.Entries) > 0 { + for _, e := range m.Entries { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *UnbondingDelegationEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CreationHeight != 0 { + n += 1 + sovTypes(uint64(m.CreationHeight)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime) + n += 1 + l + sovTypes(uint64(l)) + l = m.InitialBalance.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.Balance.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *RedelegationEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CreationHeight != 0 { + n += 1 + sovTypes(uint64(m.CreationHeight)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime) + n += 1 + l + sovTypes(uint64(l)) + l = m.InitialBalance.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.SharesDst.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *Redelegation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorSrcAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorDstAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if len(m.Entries) > 0 { + for _, e := range m.Entries { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingTime) + n += 1 + l + sovTypes(uint64(l)) + if m.MaxValidators != 0 { + n += 1 + sovTypes(uint64(m.MaxValidators)) + } + if m.MaxEntries != 0 { + n += 1 + sovTypes(uint64(m.MaxEntries)) + } + if m.HistoricalEntries != 0 { + n += 1 + sovTypes(uint64(m.HistoricalEntries)) + } + l = len(m.BondDenom) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *HistoricalInfoProto) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: HistoricalInfoProto: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HistoricalInfoProto: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Valset", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Valset = append(m.Valset, ValidatorProto{}) + if err := m.Valset[len(m.Valset)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CommissionRates) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CommissionRates: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommissionRates: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxChangeRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MaxChangeRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Commission) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Commission: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Commission: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommissionRates", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommissionRates.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UpdateTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Description) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Description: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Description: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Moniker", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Moniker = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Website", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Website = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SecurityContact", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SecurityContact = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Details", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Details = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValidatorProto) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ValidatorProto: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorProto: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OperatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.OperatorAddress = append(m.OperatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.OperatorAddress == nil { + m.OperatorAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsensusPubkey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ConsensusPubkey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Jailed = bool(v != 0) + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Status = append(m.Status[:0], dAtA[iNdEx:postIndex]...) + if m.Status == nil { + m.Status = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tokens", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Tokens.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorShares", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DelegatorShares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingHeight", wireType) + } + m.UnbondingHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.UnbondingHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.UnbondingTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSelfDelegation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinSelfDelegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DVPair) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DVPair: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DVPair: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = append(m.DelegatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.DelegatorAddress == nil { + m.DelegatorAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = append(m.ValidatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorAddress == nil { + m.ValidatorAddress = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DVVTriplet) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DVVTriplet: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DVVTriplet: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = append(m.DelegatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.DelegatorAddress == nil { + m.DelegatorAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSrcAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorSrcAddress = append(m.ValidatorSrcAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorSrcAddress == nil { + m.ValidatorSrcAddress = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorDstAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorDstAddress = append(m.ValidatorDstAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorDstAddress == nil { + m.ValidatorDstAddress = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Delegation) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Delegation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Delegation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = append(m.DelegatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.DelegatorAddress == nil { + m.DelegatorAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = append(m.ValidatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorAddress == nil { + m.ValidatorAddress = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Shares", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Shares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UnbondingDelegation) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UnbondingDelegation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UnbondingDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = append(m.DelegatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.DelegatorAddress == nil { + m.DelegatorAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = append(m.ValidatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorAddress == nil { + m.ValidatorAddress = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Entries = append(m.Entries, UnbondingDelegationEntry{}) + if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *UnbondingDelegationEntry) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: UnbondingDelegationEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UnbondingDelegationEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreationHeight", wireType) + } + m.CreationHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreationHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CompletionTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CompletionTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitialBalance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InitialBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Balance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Balance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RedelegationEntry) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RedelegationEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RedelegationEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreationHeight", wireType) + } + m.CreationHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreationHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CompletionTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.CompletionTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InitialBalance", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.InitialBalance.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SharesDst", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.SharesDst.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Redelegation) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Redelegation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Redelegation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = append(m.DelegatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.DelegatorAddress == nil { + m.DelegatorAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSrcAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorSrcAddress = append(m.ValidatorSrcAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorSrcAddress == nil { + m.ValidatorSrcAddress = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorDstAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorDstAddress = append(m.ValidatorDstAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorDstAddress == nil { + m.ValidatorDstAddress = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Entries", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Entries = append(m.Entries, RedelegationEntry{}) + if err := m.Entries[len(m.Entries)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Params) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnbondingTime", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.UnbondingTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxValidators", wireType) + } + m.MaxValidators = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxValidators |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxEntries", wireType) + } + m.MaxEntries = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxEntries |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field HistoricalEntries", wireType) + } + m.HistoricalEntries = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.HistoricalEntries |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BondDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BondDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/staking/types/types.proto b/x/staking/types/types.proto new file mode 100644 index 000000000000..c4da8b6fbc45 --- /dev/null +++ b/x/staking/types/types.proto @@ -0,0 +1,273 @@ +syntax = "proto3"; +package cosmos_sdk.x.staking.v1; + +import "third_party/proto/gogoproto/gogo.proto"; +import "third_party/proto/tendermint/abci/types/types.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/duration.proto"; +import "types/types.proto"; + +option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; + +// HistoricalInfoProto contains the historical information that gets stored at +// each height. +message HistoricalInfoProto { + option (gogoproto.equal) = true; + + tendermint.abci.types.Header header = 1 [ (gogoproto.nullable) = false ]; + repeated ValidatorProto valset = 2 [ (gogoproto.nullable) = false ]; +} + +// CommissionRates defines the initial commission rates to be used for creating +// a validator. +message CommissionRates { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + string rate = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string max_rate = 2 [ + (gogoproto.moretags) = "yaml:\"max_rate\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string max_change_rate = 3 [ + (gogoproto.moretags) = "yaml:\"max_change_rate\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// Commission defines a commission parameters for a given validator. +message Commission { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + CommissionRates commission_rates = 1 + [ (gogoproto.embed) = true, (gogoproto.nullable) = false ]; + google.protobuf.Timestamp update_time = 2 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"update_time\"" + ]; +} + +// Description defines a validator description. +message Description { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + string moniker = 1; + string identity = 2; + string website = 3; + string security_contact = 4 + [ (gogoproto.moretags) = "yaml:\"security_contact\"" ]; + string details = 5; +} + +// ValidatorProto defines the Protocol buffer equivalent of the Validator type. +message ValidatorProto { + option (gogoproto.equal) = true; + + bytes operator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"operator_address\"" + ]; + // TODO: We can remove cosmos_sdk.v1.PublicKey in favor of the primitive bytes + // once Tendermint supports pubkeys as slices. + cosmos_sdk.v1.PublicKey consensus_pubkey = 2 [ + (gogoproto.moretags) = "yaml:\"consensus_pubkey\"", + (gogoproto.nullable) = false + ]; + bool jailed = 3; + bytes status = 4; + string tokens = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string delegator_shares = 6 [ + (gogoproto.moretags) = "yaml:\"delegator_shares\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + Description description = 7 [ (gogoproto.nullable) = false ]; + int64 unbonding_height = 8 + [ (gogoproto.moretags) = "yaml:\"unbonding_height\"" ]; + google.protobuf.Timestamp unbonding_time = 9 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"unbonding_time\"" + ]; + Commission commission = 10 [ (gogoproto.nullable) = false ]; + string min_self_delegation = 11 [ + (gogoproto.moretags) = "yaml:\"min_self_delegation\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +// DVPair is struct that just has a delegator-validator pair with no other data. +// It is intended to be used as a marshalable pointer. For example, a DVPair can +// be used to construct the key to getting an UnbondingDelegation from state. +message DVPair { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + bytes delegator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"delegator_address\"" + ]; + bytes validator_address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_address\"" + ]; +} + +// DVVTriplet is struct that just has a delegator-validator-validator triplet +// with no other data. It is intended to be used as a marshalable pointer. For +// example, a DVVTriplet can be used to construct the key to getting a +// Redelegation from state. +message DVVTriplet { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + bytes delegator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"delegator_address\"" + ]; + bytes validator_src_address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_src_address\"" + ]; + bytes validator_dst_address = 3 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_dst_address\"" + ]; +} + +// Delegation represents the bond with tokens held by an account. It is +// owned by one delegator, and is associated with the voting power of one +// validator. +message Delegation { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + bytes delegator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"delegator_address\"" + ]; + bytes validator_address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_address\"" + ]; + string shares = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// UnbondingDelegation stores all of a single delegator's unbonding bonds +// for a single validator in an time-ordered list +message UnbondingDelegation { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + bytes delegator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"delegator_address\"" + ]; + bytes validator_address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_address\"" + ]; + repeated UnbondingDelegationEntry entries = 3 + [ (gogoproto.nullable) = false ]; // unbonding delegation entries +} + +// UnbondingDelegationEntry defines an unbonding object with relevant metadata. +message UnbondingDelegationEntry { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + int64 creation_height = 1 + [ (gogoproto.moretags) = "yaml:\"creation_height\"" ]; + google.protobuf.Timestamp completion_time = 2 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"completion_time\"" + ]; + string initial_balance = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"initial_balance\"" + ]; + string balance = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; +} + +// RedelegationEntry defines a redelegation object with relevant metadata. +message RedelegationEntry { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + int64 creation_height = 1 + [ (gogoproto.moretags) = "yaml:\"creation_height\"" ]; + google.protobuf.Timestamp completion_time = 2 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"completion_time\"" + ]; + string initial_balance = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"initial_balance\"" + ]; + string shares_dst = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// Redelegation contains the list of a particular delegator's redelegating bonds +// from a particular source validator to a particular destination validator. +message Redelegation { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + bytes delegator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"delegator_address\"" + ]; + bytes validator_src_address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_src_address\"" + ]; + bytes validator_dst_address = 3 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_dst_address\"" + ]; + repeated RedelegationEntry entries = 4 + [ (gogoproto.nullable) = false ]; // redelegation entries +} + +// Params defines the parameters for the staking module. +message Params { + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + google.protobuf.Duration unbonding_time = 1 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"unbonding_time\"" + ]; + uint32 max_validators = 2 + [ (gogoproto.moretags) = "yaml:\"max_validators\"" ]; + uint32 max_entries = 3 [ (gogoproto.moretags) = "yaml:\"max_entries\"" ]; + uint32 historical_entries = 4 + [ (gogoproto.moretags) = "yaml:\"historical_entries\"" ]; + string bond_denom = 5 [ (gogoproto.moretags) = "yaml:\"bond_denom\"" ]; +} diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 855ed988d290..c981b4c97035 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -9,6 +9,9 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/tendermint/tendermint/crypto/sr25519" tmtypes "github.com/tendermint/tendermint/types" yaml "gopkg.in/yaml.v2" @@ -52,23 +55,105 @@ type Validator struct { MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` // validator's self declared minimum self delegation } -// custom marshal yaml function due to consensus pubkey -func (v Validator) MarshalYAML() (interface{}, error) { - bs, err := yaml.Marshal(struct { - OperatorAddress sdk.ValAddress - ConsPubKey string - Jailed bool - Status sdk.BondStatus - Tokens sdk.Int - DelegatorShares sdk.Dec - Description Description - UnbondingHeight int64 - UnbondingCompletionTime time.Time - Commission Commission - MinSelfDelegation sdk.Int - }{ +func NewValidator(operator sdk.ValAddress, pubKey crypto.PubKey, description Description) Validator { + return Validator{ + OperatorAddress: operator, + ConsPubKey: pubKey, + Jailed: false, + Status: sdk.Unbonded, + Tokens: sdk.ZeroInt(), + DelegatorShares: sdk.ZeroDec(), + Description: description, + UnbondingHeight: int64(0), + UnbondingCompletionTime: time.Unix(0, 0).UTC(), + Commission: NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + MinSelfDelegation: sdk.OneInt(), + } +} + +// ToProto converts a Validator into a ValidatorProto type. +func (v Validator) ToProto() ValidatorProto { + var pk sdk.PublicKey + + switch t := v.ConsPubKey.(type) { + case secp256k1.PubKeySecp256k1: + pk = sdk.PublicKey{ + Pub: &sdk.PublicKey_Secp256K1{t.Bytes()}, + } + + case ed25519.PubKeyEd25519: + pk = sdk.PublicKey{ + Pub: &sdk.PublicKey_Ed25519{t.Bytes()}, + } + + case sr25519.PubKeySr25519: + pk = sdk.PublicKey{ + Pub: &sdk.PublicKey_Sr25519{t.Bytes()}, + } + } + + return ValidatorProto{ + OperatorAddress: v.OperatorAddress, + ConsensusPubkey: pk, + Jailed: v.Jailed, + Status: []byte{byte(v.Status)}, + Tokens: v.Tokens, + DelegatorShares: v.DelegatorShares, + Description: v.Description, + UnbondingHeight: v.UnbondingHeight, + UnbondingTime: v.UnbondingCompletionTime, + Commission: v.Commission, + MinSelfDelegation: v.MinSelfDelegation, + } +} + +// ToValidator converts a ValidatorProto to a Validator type. +func (vp ValidatorProto) ToValidator() Validator { + var ( + pk crypto.PubKey + err error + ) + + switch t := vp.ConsensusPubkey.GetPub().(type) { + case *sdk.PublicKey_Secp256K1: + err = ModuleCdc.amino.UnmarshalBinaryBare(t.Secp256K1, &pk) + + case *sdk.PublicKey_Ed25519: + err = ModuleCdc.amino.UnmarshalBinaryBare(t.Ed25519, &pk) + + case *sdk.PublicKey_Sr25519: + err = ModuleCdc.amino.UnmarshalBinaryBare(t.Sr25519, &pk) + + default: + err = fmt.Errorf("unsupported public key type: %T", t) + } + + if err != nil { + panic(fmt.Errorf("failed to decode public key: %w", err)) + } + + return Validator{ + OperatorAddress: vp.OperatorAddress, + ConsPubKey: pk, + Jailed: vp.Jailed, + Status: sdk.BondStatus(vp.Status[0]), + Tokens: vp.Tokens, + DelegatorShares: vp.DelegatorShares, + Description: vp.Description, + UnbondingHeight: vp.UnbondingHeight, + UnbondingCompletionTime: vp.UnbondingTime, + Commission: vp.Commission, + MinSelfDelegation: vp.MinSelfDelegation, + } +} + +// String implements the Stringer interface for a Validator object. +func (v Validator) String() string { + bechConsPubKey, _ := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, v.ConsPubKey) + + bz, _ := yaml.Marshal(bechValidator{ OperatorAddress: v.OperatorAddress, - ConsPubKey: sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, v.ConsPubKey), + ConsPubKey: bechConsPubKey, Jailed: v.Jailed, Status: v.Status, Tokens: v.Tokens, @@ -79,11 +164,8 @@ func (v Validator) MarshalYAML() (interface{}, error) { Commission: v.Commission, MinSelfDelegation: v.MinSelfDelegation, }) - if err != nil { - return nil, err - } - return string(bs), nil + return string(bz) } // Validators is a collection of Validator @@ -135,30 +217,14 @@ func (v Validators) Swap(i, j int) { v[j] = it } -// NewValidator - initialize a new validator -func NewValidator(operator sdk.ValAddress, pubKey crypto.PubKey, description Description) Validator { - return Validator{ - OperatorAddress: operator, - ConsPubKey: pubKey, - Jailed: false, - Status: sdk.Unbonded, - Tokens: sdk.ZeroInt(), - DelegatorShares: sdk.ZeroDec(), - Description: description, - UnbondingHeight: int64(0), - UnbondingCompletionTime: time.Unix(0, 0).UTC(), - Commission: NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.OneInt(), - } -} - // return the redelegation -func MustMarshalValidator(cdc *codec.Codec, validator Validator) []byte { - return cdc.MustMarshalBinaryLengthPrefixed(validator) +func MustMarshalValidator(cdc codec.Marshaler, validator Validator) []byte { + valProto := validator.ToProto() + return cdc.MustMarshalBinaryLengthPrefixed(&valProto) } // unmarshal a redelegation from a store value -func MustUnmarshalValidator(cdc *codec.Codec, value []byte) Validator { +func MustUnmarshalValidator(cdc codec.Marshaler, value []byte) Validator { validator, err := UnmarshalValidator(cdc, value) if err != nil { panic(err) @@ -167,32 +233,13 @@ func MustUnmarshalValidator(cdc *codec.Codec, value []byte) Validator { } // unmarshal a redelegation from a store value -func UnmarshalValidator(cdc *codec.Codec, value []byte) (validator Validator, err error) { - err = cdc.UnmarshalBinaryLengthPrefixed(value, &validator) - return validator, err -} - -// String returns a human readable string representation of a validator. -func (v Validator) String() string { - bechConsPubKey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, v.ConsPubKey) - if err != nil { - panic(err) +func UnmarshalValidator(cdc codec.Marshaler, value []byte) (Validator, error) { + vp := ValidatorProto{} + if err := cdc.UnmarshalBinaryLengthPrefixed(value, &vp); err != nil { + return Validator{}, err } - return fmt.Sprintf(`Validator - Operator Address: %s - Validator Consensus Pubkey: %s - Jailed: %v - Status: %s - Tokens: %s - Delegator Shares: %s - Description: %s - Unbonding Height: %d - Unbonding Completion Time: %v - Minimum Self Delegation: %v - Commission: %s`, v.OperatorAddress, bechConsPubKey, - v.Jailed, v.Status, v.Tokens, - v.DelegatorShares, v.Description, - v.UnbondingHeight, v.UnbondingCompletionTime, v.MinSelfDelegation, v.Commission) + + return vp.ToValidator(), nil } // this is a helper struct used for JSON de- and encoding only @@ -292,16 +339,6 @@ func (v Validator) IsUnbonding() bool { // constant used in flags to indicate that description field should not be updated const DoNotModifyDesc = "[do-not-modify]" -// Description - description fields for a validator -type Description struct { - Moniker string `json:"moniker" yaml:"moniker"` // name - Identity string `json:"identity" yaml:"identity"` // optional identity signature (ex. UPort or Keybase) - Website string `json:"website" yaml:"website"` // optional website link - SecurityContact string `json:"security_contact" yaml:"security_contact"` // optional security contact info - Details string `json:"details" yaml:"details"` // optional details -} - -// NewDescription returns a new Description with the provided values. func NewDescription(moniker, identity, website, securityContact, details string) Description { return Description{ Moniker: moniker, @@ -312,6 +349,12 @@ func NewDescription(moniker, identity, website, securityContact, details string) } } +// String implements the Stringer interface for a Description object. +func (d Description) String() string { + out, _ := yaml.Marshal(d) + return string(out) +} + // UpdateDescription updates the fields of a given description. An error is // returned if the resulting description contains an invalid length. func (d Description) UpdateDescription(d2 Description) (Description, error) { From 31311cb19e41794ddbd3dc156c226b8bb4c55460 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 09:35:04 -0500 Subject: [PATCH 02/27] Use int32 for validator status --- x/staking/types/types.pb.go | 222 ++++++++++++++++------------------- x/staking/types/types.proto | 2 +- x/staking/types/validator.go | 10 +- 3 files changed, 108 insertions(+), 126 deletions(-) diff --git a/x/staking/types/types.pb.go b/x/staking/types/types.pb.go index 55d2ae2322a7..cf26d4124045 100644 --- a/x/staking/types/types.pb.go +++ b/x/staking/types/types.pb.go @@ -254,7 +254,7 @@ type ValidatorProto struct { // once Tendermint supports pubkeys as slices. ConsensusPubkey types1.PublicKey `protobuf:"bytes,2,opt,name=consensus_pubkey,json=consensusPubkey,proto3" json:"consensus_pubkey" yaml:"consensus_pubkey"` Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed,omitempty"` - Status []byte `protobuf:"bytes,4,opt,name=status,proto3" json:"status,omitempty"` + Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"` Tokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=tokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"tokens"` DelegatorShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=delegator_shares,json=delegatorShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"delegator_shares" yaml:"delegator_shares"` Description Description `protobuf:"bytes,7,opt,name=description,proto3" json:"description"` @@ -318,11 +318,11 @@ func (m *ValidatorProto) GetJailed() bool { return false } -func (m *ValidatorProto) GetStatus() []byte { +func (m *ValidatorProto) GetStatus() int32 { if m != nil { return m.Status } - return nil + return 0 } func (m *ValidatorProto) GetDescription() Description { @@ -858,96 +858,96 @@ func init() { func init() { proto.RegisterFile("x/staking/types/types.proto", fileDescriptor_c669c0a3ee1b124c) } var fileDescriptor_c669c0a3ee1b124c = []byte{ - // 1409 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0xcb, 0x6f, 0x1b, 0x45, - 0x18, 0xcf, 0xda, 0xc1, 0x49, 0xc6, 0x6d, 0x1c, 0x4f, 0xd4, 0xd6, 0x75, 0xa9, 0xb7, 0x2c, 0xa8, - 0x44, 0x88, 0xae, 0xd5, 0x16, 0x09, 0xa9, 0x5c, 0xa8, 0xe3, 0x56, 0x09, 0xa4, 0x52, 0xba, 0x2d, - 0x39, 0xf0, 0xd0, 0x6a, 0xbc, 0x3b, 0xb1, 0x87, 0xec, 0xc3, 0xec, 0x8c, 0x53, 0xbb, 0xe2, 0xca, - 0x05, 0x09, 0xd1, 0x63, 0x6f, 0x54, 0x9c, 0xb8, 0xf1, 0x6f, 0x94, 0x5b, 0xc5, 0x01, 0x21, 0x0e, - 0x06, 0xb5, 0x17, 0xc4, 0x09, 0xf9, 0xc0, 0x81, 0x13, 0x9a, 0xc7, 0x7a, 0x37, 0xeb, 0x9a, 0xd6, - 0xe1, 0x00, 0x12, 0xb9, 0x24, 0x9e, 0xdf, 0x7e, 0xdf, 0xef, 0x9b, 0xf9, 0x9e, 0xb3, 0x0b, 0xce, - 0xf4, 0xeb, 0x94, 0xa1, 0x3d, 0x12, 0xb4, 0xeb, 0x6c, 0xd0, 0xc5, 0x54, 0x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, 0xbd, 0xb8, - 0xd7, 0x1d, 0x79, 0x18, 0xde, 0x04, 0x0b, 0x38, 0x60, 0x11, 0x11, 0x2e, 0xe6, 0xd7, 0xfc, 0x8b, - 0x53, 0xdb, 0xfc, 0x53, 0xdc, 0x76, 0x2d, 0x60, 0xd1, 0x40, 0x35, 0xfd, 0x98, 0x27, 0xe5, 0xec, - 0x2f, 0xf3, 0xa0, 0x32, 0x4d, 0x0b, 0xae, 0x83, 0x92, 0x13, 0x61, 0x01, 0xc4, 0x03, 0x51, 0x13, - 0x03, 0xb1, 0x9a, 0x5c, 0x97, 0x33, 0x02, 0x86, 0xb5, 0x1c, 0x23, 0x6a, 0x1c, 0xb6, 0x01, 0xbf, - 0xca, 0xf2, 0x46, 0xc6, 0xa5, 0x9e, 0xf3, 0xee, 0x6a, 0xa8, 0x79, 0x18, 0x1b, 0x39, 0x48, 0x20, - 0x07, 0xe2, 0x72, 0x82, 0x8a, 0x89, 0xf8, 0x09, 0x28, 0x91, 0x80, 0x30, 0x82, 0x3c, 0xbb, 0x85, - 0x3c, 0x14, 0x38, 0x87, 0x79, 0x15, 0x90, 0x23, 0x4c, 0x99, 0xcd, 0xd0, 0x19, 0xd6, 0xb2, 0x42, - 0x1a, 0x12, 0x80, 0x1b, 0x60, 0x21, 0x36, 0x35, 0x7f, 0xa8, 0xfb, 0x53, 0xac, 0x9e, 0x8a, 0xc8, - 0x17, 0x79, 0x50, 0xb6, 0xb0, 0x7b, 0x14, 0x8a, 0xd9, 0x42, 0x71, 0x03, 0x00, 0xd9, 0x49, 0x78, - 0xd7, 0x3f, 0x44, 0x34, 0x78, 0x2f, 0x5a, 0x92, 0x0c, 0x4d, 0xca, 0x52, 0xf1, 0xf8, 0x3d, 0x0f, - 0x8e, 0xa5, 0xe3, 0x71, 0x34, 0x8e, 0xff, 0x3b, 0xe3, 0x18, 0xbe, 0x93, 0xf4, 0xc6, 0x79, 0xd1, - 0x1b, 0x5f, 0x9b, 0xda, 0x1b, 0x27, 0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0x7c, 0xff, 0xbb, 0x5d, 0x14, 0x00, - 0x00, + // 1410 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0xcd, 0x6f, 0x1b, 0x45, + 0x1b, 0xcf, 0xda, 0xa9, 0x93, 0x8c, 0xdb, 0x38, 0x9e, 0xa8, 0xad, 0xeb, 0xbe, 0xf5, 0xf6, 0x5d, + 0x50, 0x89, 0x10, 0x5d, 0xab, 0x2d, 0x12, 0x52, 0xb9, 0x50, 0xc7, 0xad, 0x12, 0x48, 0xa5, 0x74, + 0x5b, 0x72, 0xe0, 0x43, 0xab, 0xf1, 0xee, 0xc4, 0x1e, 0xb2, 0x1f, 0x66, 0x67, 0x9c, 0xda, 0x15, + 0x57, 0x2e, 0x48, 0x88, 0x1e, 0x7b, 0xa3, 0xe2, 0xc4, 0x8d, 0x7f, 0xa3, 0xdc, 0x2a, 0x0e, 0x08, + 0x71, 0x30, 0xa8, 0xbd, 0x20, 0x4e, 0xc8, 0x07, 0x0e, 0x9c, 0xd0, 0x7c, 0xac, 0x77, 0xb3, 0xae, + 0x69, 0x1d, 0x0e, 0x20, 0x91, 0x4b, 0xe2, 0xf9, 0xed, 0xf3, 0xfc, 0x9e, 0x99, 0xe7, 0x73, 0x76, + 0xc1, 0xd9, 0x7e, 0x9d, 0x32, 0xb4, 0x47, 0x82, 0x76, 0x9d, 0x0d, 0xba, 0x98, 0xca, 0xbf, 0x66, + 0x37, 0x0a, 0x59, 0x08, 0x4f, 0x3b, 0x21, 0xf5, 0x43, 0x6a, 0x53, 0x77, 0xcf, 0xec, 0x9b, 0x4a, + 0xce, 0xdc, 0xbf, 0x54, 0xbd, 0xc0, 0x3a, 0x24, 0x72, 0xed, 0x2e, 0x8a, 0xd8, 0xa0, 0x2e, 0x64, + 0xeb, 0xed, 0xb0, 0x1d, 0x26, 0xbf, 0x24, 0x41, 0xf5, 0xca, 0xa4, 0x1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xc5, 0x01, 0x23, 0x6c, 0x20, 0x03, 0x6b, 0x8d, 0xd7, + 0x5c, 0xeb, 0x2e, 0x6e, 0x51, 0x12, 0x87, 0xc3, 0x8a, 0x97, 0xf0, 0x06, 0x58, 0xa1, 0xd8, 0xe9, + 0x45, 0x84, 0x0d, 0x6c, 0x27, 0x0c, 0x18, 0x72, 0x58, 0x65, 0x5e, 0x44, 0xec, 0xec, 0x68, 0xa8, + 0x9f, 0x96, 0x7b, 0xcd, 0x4a, 0x18, 0x56, 0x29, 0x86, 0xd6, 0x25, 0xc2, 0x2d, 0xb8, 0x98, 0x21, + 0xe2, 0xd1, 0xca, 0x31, 0x69, 0x41, 0x2d, 0x53, 0x67, 0xf9, 0x7a, 0x01, 0x2c, 0x1f, 0xcc, 0x7c, + 0x78, 0x17, 0xac, 0x84, 0x5d, 0x1c, 0x71, 0xc0, 0x46, 0xae, 0x1b, 0x61, 0x2a, 0x83, 0x74, 0xbc, + 0xb1, 0x95, 0x98, 0xcf, 0x4a, 0x18, 0x7f, 0x0c, 0xf5, 0x8b, 0x2f, 0x90, 0x47, 0x3b, 0xc8, 0xbb, + 0x26, 0x35, 0xac, 0x52, 0xcc, 0xa1, 0x00, 0xe8, 0xf2, 0xec, 0x08, 0x28, 0x0e, 0x68, 0x8f, 0xda, + 0xdd, 0x5e, 0x6b, 0x0f, 0x0f, 0x54, 0x0c, 0x2b, 0xe9, 0xec, 0xd8, 0xbf, 0x64, 0x6e, 0xf7, 0x5a, + 0x1e, 0x71, 0xde, 0xc1, 0x83, 0x86, 0xae, 0x22, 0xa8, 0xb6, 0x95, 0xd5, 0x37, 0x78, 0x92, 0x28, + 0x68, 0x5b, 0x20, 0xf0, 0x14, 0x28, 0x7c, 0x84, 0x88, 0x87, 0x5d, 0xe1, 0xf6, 0x45, 0x4b, 0xad, + 0x38, 0x4e, 0x19, 0x62, 0x3d, 0x2a, 0x7c, 0x7d, 0xcc, 0x52, 0x2b, 0x78, 0x03, 0x14, 0x58, 0xb8, + 0x87, 0x03, 0xe5, 0xc4, 0x99, 0x4a, 0x7c, 0x33, 0x60, 0x96, 0xd2, 0x86, 0x0c, 0xac, 0xb8, 0xd8, + 0xc3, 0x6d, 0xe1, 0x35, 0xda, 0x41, 0x11, 0xa6, 0x95, 0x82, 0x60, 0xdc, 0x9c, 0xb9, 0x0e, 0xd5, + 0x69, 0xb3, 0x7c, 0x86, 0x55, 0x1a, 0x43, 0xb7, 0x05, 0x02, 0xb7, 0x40, 0xd1, 0x4d, 0x52, 0xb5, + 0xb2, 0x20, 0xdc, 0xf9, 0xf2, 0xd4, 0x62, 0x4b, 0xa5, 0xb5, 0xea, 0x80, 0x69, 0x75, 0x9e, 0x99, + 0xbd, 0xa0, 0x15, 0x06, 0x2e, 0x09, 0xda, 0x76, 0x07, 0x93, 0x76, 0x87, 0x55, 0x16, 0xcf, 0x6b, + 0x6b, 0xf9, 0x74, 0x66, 0x66, 0x25, 0x0c, 0xab, 0x34, 0x86, 0x36, 0x04, 0x02, 0x5d, 0xb0, 0x9c, + 0x48, 0x89, 0x5a, 0x5d, 0x7a, 0x6e, 0xad, 0xfe, 0x5f, 0x45, 0xfa, 0x64, 0xd6, 0x4a, 0x52, 0xae, + 0x27, 0xc6, 0x20, 0x57, 0x83, 0x9b, 0x00, 0x24, 0x1d, 0xa2, 0x02, 0x84, 0x85, 0x97, 0x5e, 0xa0, + 0xcf, 0xa8, 0x93, 0xa7, 0x94, 0xe1, 0x27, 0x60, 0xd5, 0x27, 0x81, 0x4d, 0xb1, 0xb7, 0x6b, 0x2b, + 0x17, 0x73, 0xce, 0xa2, 0x88, 0xdf, 0xd6, 0x6c, 0x19, 0x31, 0x1a, 0xea, 0x55, 0xd5, 0x47, 0x27, + 0x29, 0x0d, 0xab, 0xec, 0x93, 0xe0, 0x36, 0xf6, 0x76, 0x9b, 0x63, 0x4c, 0x4d, 0x9f, 0xcf, 0x72, + 0xa0, 0xd0, 0xdc, 0xd9, 0x46, 0x24, 0x82, 0xf7,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27, 0x1a, 0x67, 0x12, 0x96, 0x83, 0xcf, 0xe5, 0x47, 0x89, 0xf1, 0xab, + 0x2d, 0x85, 0x6f, 0x80, 0x22, 0x97, 0x48, 0xe6, 0x04, 0x57, 0x3f, 0x95, 0xbc, 0xfc, 0xa7, 0x1e, + 0x1a, 0x16, 0xf0, 0x51, 0xff, 0xba, 0x5c, 0xc0, 0x2d, 0x00, 0x3b, 0xe3, 0xcf, 0x52, 0x76, 0xe2, + 0x4b, 0xae, 0x7f, 0x6e, 0x34, 0xd4, 0xcf, 0x48, 0xfd, 0x49, 0x19, 0xc3, 0x2a, 0x27, 0x60, 0xcc, + 0xf6, 0x3a, 0x00, 0xfc, 0x5c, 0xb6, 0x8b, 0x83, 0xd0, 0x57, 0xaf, 0x94, 0x27, 0x47, 0x43, 0xbd, + 0x2c, 0x59, 0x92, 0x67, 0x86, 0xb5, 0xc4, 0x17, 0x4d, 0xfe, 0x3b, 0x71, 0x7c, 0xe3, 0xc6, 0xa3, + 0x27, 0x35, 0xed, 0xf1, 0x93, 0x9a, 0xf6, 0xf3, 0x93, 0x9a, 0x76, 0xff, 0x69, 0x6d, 0xee, 0xf1, + 0xd3, 0xda, 0xdc, 0x0f, 0x4f, 0x6b, 0x73, 0xef, 0xbd, 0xf6, 0x97, 0xc9, 0x92, 0xf9, 0x86, 0xd8, + 0x2a, 0x88, 0xa8, 0x5c, 0xf9, 0x33, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x6f, 0x88, 0x86, 0x5d, 0x14, + 0x00, 0x00, } func (this *HistoricalInfoProto) Equal(that interface{}) bool { @@ -1103,7 +1103,7 @@ func (this *ValidatorProto) Equal(that interface{}) bool { if this.Jailed != that1.Jailed { return false } - if !bytes.Equal(this.Status, that1.Status) { + if this.Status != that1.Status { return false } if !this.Tokens.Equal(that1.Tokens) { @@ -1673,12 +1673,10 @@ func (m *ValidatorProto) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x2a - if len(m.Status) > 0 { - i -= len(m.Status) - copy(dAtA[i:], m.Status) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Status))) + if m.Status != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Status)) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x20 } if m.Jailed { i-- @@ -2212,9 +2210,8 @@ func (m *ValidatorProto) Size() (n int) { if m.Jailed { n += 2 } - l = len(m.Status) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) + if m.Status != 0 { + n += 1 + sovTypes(uint64(m.Status)) } l = m.Tokens.Size() n += 1 + l + sovTypes(uint64(l)) @@ -3131,10 +3128,10 @@ func (m *ValidatorProto) Unmarshal(dAtA []byte) error { } m.Jailed = bool(v != 0) case 4: - if wireType != 2 { + if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } - var byteLen int + m.Status = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3144,26 +3141,11 @@ func (m *ValidatorProto) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + m.Status |= int32(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Status = append(m.Status[:0], dAtA[iNdEx:postIndex]...) - if m.Status == nil { - m.Status = []byte{} - } - iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Tokens", wireType) diff --git a/x/staking/types/types.proto b/x/staking/types/types.proto index c4da8b6fbc45..5ff36762df4d 100644 --- a/x/staking/types/types.proto +++ b/x/staking/types/types.proto @@ -82,7 +82,7 @@ message ValidatorProto { (gogoproto.nullable) = false ]; bool jailed = 3; - bytes status = 4; + int32 status = 4; string tokens = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index c981b4c97035..74a6b7b2b85c 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -78,17 +78,17 @@ func (v Validator) ToProto() ValidatorProto { switch t := v.ConsPubKey.(type) { case secp256k1.PubKeySecp256k1: pk = sdk.PublicKey{ - Pub: &sdk.PublicKey_Secp256K1{t.Bytes()}, + Pub: &sdk.PublicKey_Secp256K1{Secp256K1: t.Bytes()}, } case ed25519.PubKeyEd25519: pk = sdk.PublicKey{ - Pub: &sdk.PublicKey_Ed25519{t.Bytes()}, + Pub: &sdk.PublicKey_Ed25519{Ed25519: t.Bytes()}, } case sr25519.PubKeySr25519: pk = sdk.PublicKey{ - Pub: &sdk.PublicKey_Sr25519{t.Bytes()}, + Pub: &sdk.PublicKey_Sr25519{Sr25519: t.Bytes()}, } } @@ -96,7 +96,7 @@ func (v Validator) ToProto() ValidatorProto { OperatorAddress: v.OperatorAddress, ConsensusPubkey: pk, Jailed: v.Jailed, - Status: []byte{byte(v.Status)}, + Status: int32(v.Status), Tokens: v.Tokens, DelegatorShares: v.DelegatorShares, Description: v.Description, @@ -136,7 +136,7 @@ func (vp ValidatorProto) ToValidator() Validator { OperatorAddress: vp.OperatorAddress, ConsPubKey: pk, Jailed: vp.Jailed, - Status: sdk.BondStatus(vp.Status[0]), + Status: sdk.BondStatus(byte(vp.Status)), Tokens: vp.Tokens, DelegatorShares: vp.DelegatorShares, Description: vp.Description, From 0d2938ba1712ea05cba4135c824abf94575a36ef Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 14:39:40 -0500 Subject: [PATCH 03/27] Update staking types --- x/staking/types/errors.go | 1 + x/staking/types/historical_info.go | 47 +- x/staking/types/historical_info_test.go | 6 +- x/staking/types/msg.go | 138 +- x/staking/types/msg_test.go | 47 - x/staking/types/types.pb.go | 2647 +++++++++++++++++++---- x/staking/types/types.proto | 120 +- x/staking/types/validator.go | 260 +-- x/staking/types/validator_test.go | 52 +- 9 files changed, 2337 insertions(+), 981 deletions(-) diff --git a/x/staking/types/errors.go b/x/staking/types/errors.go index d3ccf0a9dac2..62fdd0725b90 100644 --- a/x/staking/types/errors.go +++ b/x/staking/types/errors.go @@ -56,4 +56,5 @@ var ( ErrNeitherShareMsgsGiven = sdkerrors.Register(ModuleName, 43, "neither shares amount nor shares percent provided") ErrInvalidHistoricalInfo = sdkerrors.Register(ModuleName, 44, "invalid historical info") ErrNoHistoricalInfo = sdkerrors.Register(ModuleName, 45, "no historical info found") + ErrEmptyValidatorPubKey = sdkerrors.Register(ModuleName, 46, "empty validator public key") ) diff --git a/x/staking/types/historical_info.go b/x/staking/types/historical_info.go index 58215b1eb53f..98f2ea86a5cd 100644 --- a/x/staking/types/historical_info.go +++ b/x/staking/types/historical_info.go @@ -9,49 +9,19 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// HistoricalInfo contains the historical information that gets stored at each height -type HistoricalInfo struct { - Header abci.Header `json:"header" yaml:"header"` - ValSet Validators `json:"valset" yaml:"valset"` -} - // NewHistoricalInfo will create a historical information struct from header and valset // it will first sort valset before inclusion into historical info func NewHistoricalInfo(header abci.Header, valSet Validators) HistoricalInfo { sort.Sort(valSet) return HistoricalInfo{ Header: header, - ValSet: valSet, - } -} - -// ToProto converts a HistoricalInfo into a HistoricalInfoProto type. -func (hi HistoricalInfo) ToProto() HistoricalInfoProto { - valsetProto := make([]ValidatorProto, len(hi.ValSet)) - for i, val := range hi.ValSet { - valsetProto[i] = val.ToProto() - } - - return HistoricalInfoProto{ - Header: hi.Header, - Valset: valsetProto, + Valset: valSet, } } -// ToHistoricalInfo converts a HistoricalInfoProto to a HistoricalInfo type. -func (hip HistoricalInfoProto) ToHistoricalInfo() HistoricalInfo { - valset := make(Validators, len(hip.Valset)) - for i, valProto := range hip.Valset { - valset[i] = valProto.ToValidator() - } - - return NewHistoricalInfo(hip.Header, valset) -} - // MustMarshalHistoricalInfo wll marshal historical info and panic on error func MustMarshalHistoricalInfo(cdc codec.Marshaler, hi HistoricalInfo) []byte { - hiProto := hi.ToProto() - return cdc.MustMarshalBinaryLengthPrefixed(&hiProto) + return cdc.MustMarshalBinaryLengthPrefixed(&hi) } // MustUnmarshalHistoricalInfo wll unmarshal historical info and panic on error @@ -65,21 +35,18 @@ func MustUnmarshalHistoricalInfo(cdc codec.Marshaler, value []byte) HistoricalIn // UnmarshalHistoricalInfo will unmarshal historical info and return any error func UnmarshalHistoricalInfo(cdc codec.Marshaler, value []byte) (hi HistoricalInfo, err error) { - hip := HistoricalInfoProto{} - if err := cdc.UnmarshalBinaryLengthPrefixed(value, &hip); err != nil { - return HistoricalInfo{}, err - } - - return hip.ToHistoricalInfo(), nil + err = cdc.UnmarshalBinaryLengthPrefixed(value, &hi) + return hi, err } // ValidateBasic will ensure HistoricalInfo is not nil and sorted func ValidateBasic(hi HistoricalInfo) error { - if len(hi.ValSet) == 0 { + if len(hi.Valset) == 0 { return sdkerrors.Wrap(ErrInvalidHistoricalInfo, "validator set is empty") } - if !sort.IsSorted(Validators(hi.ValSet)) { + if !sort.IsSorted(Validators(hi.Valset)) { return sdkerrors.Wrap(ErrInvalidHistoricalInfo, "validator set is not sorted by address") } + return nil } diff --git a/x/staking/types/historical_info_test.go b/x/staking/types/historical_info_test.go index f607ba15031c..32e149af56a9 100644 --- a/x/staking/types/historical_info_test.go +++ b/x/staking/types/historical_info_test.go @@ -23,7 +23,7 @@ var ( func TestHistoricalInfo(t *testing.T) { hi := NewHistoricalInfo(header, validators) - require.True(t, sort.IsSorted(Validators(hi.ValSet)), "Validators are not sorted") + require.True(t, sort.IsSorted(Validators(hi.Valset)), "Validators are not sorted") var value []byte require.NotPanics(t, func() { @@ -35,7 +35,7 @@ func TestHistoricalInfo(t *testing.T) { recv, err := UnmarshalHistoricalInfo(ModuleCdc, value) require.Nil(t, err, "Unmarshalling HistoricalInfo failed") require.Equal(t, hi, recv, "Unmarshalled HistoricalInfo is different from original") - require.True(t, sort.IsSorted(Validators(hi.ValSet)), "Validators are not sorted") + require.True(t, sort.IsSorted(Validators(hi.Valset)), "Validators are not sorted") } func TestValidateBasic(t *testing.T) { @@ -56,7 +56,7 @@ func TestValidateBasic(t *testing.T) { hi = HistoricalInfo{ Header: header, - ValSet: validators, + Valset: validators, } err = ValidateBasic(hi) require.Error(t, err, "ValidateBasic passed on unsorted ValSet") diff --git a/x/staking/types/msg.go b/x/staking/types/msg.go index 62d2295fce6f..18e0bac2dc13 100644 --- a/x/staking/types/msg.go +++ b/x/staking/types/msg.go @@ -2,16 +2,13 @@ package types import ( "bytes" - "encoding/json" "github.com/tendermint/tendermint/crypto" - yaml "gopkg.in/yaml.v2" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -// ensure Msg interface compliance at compile time var ( _ sdk.Msg = &MsgCreateValidator{} _ sdk.Msg = &MsgEditValidator{} @@ -20,29 +17,6 @@ var ( _ sdk.Msg = &MsgBeginRedelegate{} ) -//______________________________________________________________________ - -// MsgCreateValidator - struct for bonding transactions -type MsgCreateValidator struct { - Description Description `json:"description" yaml:"description"` - Commission CommissionRates `json:"commission" yaml:"commission"` - MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` - DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` - PubKey crypto.PubKey `json:"pubkey" yaml:"pubkey"` - Value sdk.Coin `json:"value" yaml:"value"` -} - -type msgCreateValidatorJSON struct { - Description Description `json:"description" yaml:"description"` - Commission CommissionRates `json:"commission" yaml:"commission"` - MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` - DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` - PubKey string `json:"pubkey" yaml:"pubkey"` - Value sdk.Coin `json:"value" yaml:"value"` -} - // NewMsgCreateValidator creates a new MsgCreateValidator instance. // Delegator address and validator address are the same. func NewMsgCreateValidator( @@ -50,11 +24,16 @@ func NewMsgCreateValidator( description Description, commission CommissionRates, minSelfDelegation sdk.Int, ) MsgCreateValidator { + var pkStr string + if pubKey != nil { + pkStr = sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pubKey) + } + return MsgCreateValidator{ Description: description, DelegatorAddress: sdk.AccAddress(valAddr), ValidatorAddress: valAddr, - PubKey: pubKey, + Pubkey: pkStr, Value: selfDelegation, Commission: commission, MinSelfDelegation: minSelfDelegation, @@ -81,70 +60,6 @@ func (msg MsgCreateValidator) GetSigners() []sdk.AccAddress { return addrs } -// MarshalJSON implements the json.Marshaler interface to provide custom JSON -// serialization of the MsgCreateValidator type. -func (msg MsgCreateValidator) MarshalJSON() ([]byte, error) { - return json.Marshal(msgCreateValidatorJSON{ - Description: msg.Description, - Commission: msg.Commission, - DelegatorAddress: msg.DelegatorAddress, - ValidatorAddress: msg.ValidatorAddress, - PubKey: sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, msg.PubKey), - Value: msg.Value, - MinSelfDelegation: msg.MinSelfDelegation, - }) -} - -// UnmarshalJSON implements the json.Unmarshaler interface to provide custom -// JSON deserialization of the MsgCreateValidator type. -func (msg *MsgCreateValidator) UnmarshalJSON(bz []byte) error { - var msgCreateValJSON msgCreateValidatorJSON - if err := json.Unmarshal(bz, &msgCreateValJSON); err != nil { - return err - } - - msg.Description = msgCreateValJSON.Description - msg.Commission = msgCreateValJSON.Commission - msg.DelegatorAddress = msgCreateValJSON.DelegatorAddress - msg.ValidatorAddress = msgCreateValJSON.ValidatorAddress - var err error - msg.PubKey, err = sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeConsPub, msgCreateValJSON.PubKey) - if err != nil { - return err - } - msg.Value = msgCreateValJSON.Value - msg.MinSelfDelegation = msgCreateValJSON.MinSelfDelegation - - return nil -} - -// MarshalYAML implements a custom marshal yaml function due to consensus pubkey. -func (msg MsgCreateValidator) MarshalYAML() (interface{}, error) { - bs, err := yaml.Marshal(struct { - Description Description - Commission CommissionRates - MinSelfDelegation sdk.Int - DelegatorAddress sdk.AccAddress - ValidatorAddress sdk.ValAddress - PubKey string - Value sdk.Coin - }{ - Description: msg.Description, - Commission: msg.Commission, - MinSelfDelegation: msg.MinSelfDelegation, - DelegatorAddress: msg.DelegatorAddress, - ValidatorAddress: msg.ValidatorAddress, - PubKey: sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, msg.PubKey), - Value: msg.Value, - }) - - if err != nil { - return nil, err - } - - return string(bs), nil -} - // GetSignBytes returns the message bytes to sign over. func (msg MsgCreateValidator) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) @@ -163,6 +78,9 @@ func (msg MsgCreateValidator) ValidateBasic() error { if !sdk.AccAddress(msg.ValidatorAddress).Equals(msg.DelegatorAddress) { return ErrBadValidatorAddr } + if msg.Pubkey == "" { + return ErrEmptyValidatorPubKey + } if !msg.Value.Amount.IsPositive() { return ErrBadDelegationAmount } @@ -185,20 +103,6 @@ func (msg MsgCreateValidator) ValidateBasic() error { return nil } -// MsgEditValidator - struct for editing a validator -type MsgEditValidator struct { - Description Description `json:"description" yaml:"description"` - ValidatorAddress sdk.ValAddress `json:"address" yaml:"address"` - - // We pass a reference to the new commission rate and min self delegation as it's not mandatory to - // update. If not updated, the deserialized rate will be zero with no way to - // distinguish if an update was intended. - // - // REF: #2373 - CommissionRate *sdk.Dec `json:"commission_rate" yaml:"commission_rate"` - MinSelfDelegation *sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` -} - // NewMsgEditValidator creates a new MsgEditValidator instance func NewMsgEditValidator(valAddr sdk.ValAddress, description Description, newRate *sdk.Dec, newMinSelfDelegation *sdk.Int) MsgEditValidator { return MsgEditValidator{ @@ -246,13 +150,6 @@ func (msg MsgEditValidator) ValidateBasic() error { return nil } -// MsgDelegate - struct for bonding transactions -type MsgDelegate struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` - Amount sdk.Coin `json:"amount" yaml:"amount"` -} - // NewMsgDelegate creates a new MsgDelegate instance. func NewMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) MsgDelegate { return MsgDelegate{ @@ -293,16 +190,6 @@ func (msg MsgDelegate) ValidateBasic() error { return nil } -//______________________________________________________________________ - -// MsgBeginRedelegate defines the attributes of a bonding transaction. -type MsgBeginRedelegate struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` - ValidatorSrcAddress sdk.ValAddress `json:"validator_src_address" yaml:"validator_src_address"` - ValidatorDstAddress sdk.ValAddress `json:"validator_dst_address" yaml:"validator_dst_address"` - Amount sdk.Coin `json:"amount" yaml:"amount"` -} - // NewMsgBeginRedelegate creates a new MsgBeginRedelegate instance. func NewMsgBeginRedelegate( delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, amount sdk.Coin, @@ -349,13 +236,6 @@ func (msg MsgBeginRedelegate) ValidateBasic() error { return nil } -// MsgUndelegate - struct for unbonding transactions -type MsgUndelegate struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` - Amount sdk.Coin `json:"amount" yaml:"amount"` -} - // NewMsgUndelegate creates a new MsgUndelegate instance. func NewMsgUndelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) MsgUndelegate { return MsgUndelegate{ diff --git a/x/staking/types/msg_test.go b/x/staking/types/msg_test.go index 784b653d2b8f..22914ec8aefa 100644 --- a/x/staking/types/msg_test.go +++ b/x/staking/types/msg_test.go @@ -1,11 +1,8 @@ package types import ( - "fmt" "testing" - yaml "gopkg.in/yaml.v2" - "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" @@ -157,47 +154,3 @@ func TestMsgUndelegate(t *testing.T) { } } } - -//test to validate if NewMsgCreateValidator implements yaml marshaller -func TestMsgMarshalYAML(t *testing.T) { - commission1 := NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) - tc := struct { - name, moniker, identity, website, securityContact, details string - CommissionRates CommissionRates - minSelfDelegation sdk.Int - validatorAddr sdk.ValAddress - pubkey crypto.PubKey - bond sdk.Coin - expectPass bool - }{"basic good", "a", "b", "c", "d", "e", commission1, sdk.OneInt(), valAddr1, pk1, coinPos, true} - - description := NewDescription(tc.moniker, tc.identity, tc.website, tc.securityContact, tc.details) - msg := NewMsgCreateValidator(tc.validatorAddr, tc.pubkey, tc.bond, description, tc.CommissionRates, tc.minSelfDelegation) - bs, err := yaml.Marshal(msg) - require.NoError(t, err) - bechifiedPub, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, msg.PubKey) - require.NoError(t, err) - - want := fmt.Sprintf(`| - description: - moniker: a - identity: b - website: c - security_contact: d - details: e - commission: - rate: "0.000000000000000000" - max_rate: "0.000000000000000000" - max_change_rate: "0.000000000000000000" - minselfdelegation: "1" - delegatoraddress: %s - validatoraddress: %s - pubkey: %s - value: - denom: stake - amount: "1000" -`, msg.DelegatorAddress, msg.ValidatorAddress, bechifiedPub) - - require.Equal(t, want, string(bs)) - -} diff --git a/x/staking/types/types.pb.go b/x/staking/types/types.pb.go index cf26d4124045..d84de519e7e2 100644 --- a/x/staking/types/types.pb.go +++ b/x/staking/types/types.pb.go @@ -7,13 +7,13 @@ import ( bytes "bytes" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types1 "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" _ "github.com/golang/protobuf/ptypes/duration" _ "github.com/golang/protobuf/ptypes/timestamp" - types "github.com/tendermint/tendermint/abci/types" + types1 "github.com/tendermint/tendermint/abci/types" io "io" math "math" math_bits "math/bits" @@ -32,25 +32,365 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// HistoricalInfoProto contains the historical information that gets stored at +// MsgCreateValidator defines an SDK message for creating a new validator. +type MsgCreateValidator struct { + Description Description `protobuf:"bytes,1,opt,name=description,proto3" json:"description"` + Commission CommissionRates `protobuf:"bytes,2,opt,name=commission,proto3" json:"commission"` + MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation" yaml:"min_self_delegation"` + DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,4,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,5,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"validator_address"` + Pubkey string `protobuf:"bytes,6,opt,name=pubkey,proto3" json:"pubkey,omitempty"` + Value types.Coin `protobuf:"bytes,7,opt,name=value,proto3" json:"value"` +} + +func (m *MsgCreateValidator) Reset() { *m = MsgCreateValidator{} } +func (m *MsgCreateValidator) String() string { return proto.CompactTextString(m) } +func (*MsgCreateValidator) ProtoMessage() {} +func (*MsgCreateValidator) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{0} +} +func (m *MsgCreateValidator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateValidator.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgCreateValidator) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateValidator.Merge(m, src) +} +func (m *MsgCreateValidator) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateValidator) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateValidator.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateValidator proto.InternalMessageInfo + +func (m *MsgCreateValidator) GetDescription() Description { + if m != nil { + return m.Description + } + return Description{} +} + +func (m *MsgCreateValidator) GetCommission() CommissionRates { + if m != nil { + return m.Commission + } + return CommissionRates{} +} + +func (m *MsgCreateValidator) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *MsgCreateValidator) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorAddress + } + return nil +} + +func (m *MsgCreateValidator) GetPubkey() string { + if m != nil { + return m.Pubkey + } + return "" +} + +func (m *MsgCreateValidator) GetValue() types.Coin { + if m != nil { + return m.Value + } + return types.Coin{} +} + +// MsgEditValidator defines an SDK message for editing an existing validator. +type MsgEditValidator struct { + Description Description `protobuf:"bytes,1,opt,name=description,proto3" json:"description"` + ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"address"` + // We pass a reference to the new commission rate and min self delegation as + // it's not mandatory to update. If not updated, the deserialized rate will be + // zero with no way to distinguish if an update was intended. + // + // REF: #2373 + CommissionRate *github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=commission_rate,json=commissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"commission_rate,omitempty" yaml:"commission_rate"` + MinSelfDelegation *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation,omitempty" yaml:"min_self_delegation"` +} + +func (m *MsgEditValidator) Reset() { *m = MsgEditValidator{} } +func (m *MsgEditValidator) String() string { return proto.CompactTextString(m) } +func (*MsgEditValidator) ProtoMessage() {} +func (*MsgEditValidator) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{1} +} +func (m *MsgEditValidator) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgEditValidator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgEditValidator.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgEditValidator) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgEditValidator.Merge(m, src) +} +func (m *MsgEditValidator) XXX_Size() int { + return m.Size() +} +func (m *MsgEditValidator) XXX_DiscardUnknown() { + xxx_messageInfo_MsgEditValidator.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgEditValidator proto.InternalMessageInfo + +func (m *MsgEditValidator) GetDescription() Description { + if m != nil { + return m.Description + } + return Description{} +} + +func (m *MsgEditValidator) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorAddress + } + return nil +} + +// MsgDelegate defines an SDK message for performing a delegation from a +// delegate to a validator. +type MsgDelegate struct { + DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"validator_address"` + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` +} + +func (m *MsgDelegate) Reset() { *m = MsgDelegate{} } +func (m *MsgDelegate) String() string { return proto.CompactTextString(m) } +func (*MsgDelegate) ProtoMessage() {} +func (*MsgDelegate) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{2} +} +func (m *MsgDelegate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDelegate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDelegate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDelegate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDelegate.Merge(m, src) +} +func (m *MsgDelegate) XXX_Size() int { + return m.Size() +} +func (m *MsgDelegate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDelegate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDelegate proto.InternalMessageInfo + +func (m *MsgDelegate) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *MsgDelegate) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorAddress + } + return nil +} + +func (m *MsgDelegate) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +// MsgBeginRedelegate defines an SDK message for performing a redelegation from +// a delegate and source validator to a destination validator. +type MsgBeginRedelegate struct { + DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorSrcAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_src_address,json=validatorSrcAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_src_address,omitempty" yaml:"validator_src_address"` + ValidatorDstAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,3,opt,name=validator_dst_address,json=validatorDstAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_dst_address,omitempty" yaml:"validator_dst_address"` + Amount types.Coin `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount"` +} + +func (m *MsgBeginRedelegate) Reset() { *m = MsgBeginRedelegate{} } +func (m *MsgBeginRedelegate) String() string { return proto.CompactTextString(m) } +func (*MsgBeginRedelegate) ProtoMessage() {} +func (*MsgBeginRedelegate) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{3} +} +func (m *MsgBeginRedelegate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBeginRedelegate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBeginRedelegate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgBeginRedelegate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBeginRedelegate.Merge(m, src) +} +func (m *MsgBeginRedelegate) XXX_Size() int { + return m.Size() +} +func (m *MsgBeginRedelegate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBeginRedelegate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBeginRedelegate proto.InternalMessageInfo + +func (m *MsgBeginRedelegate) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *MsgBeginRedelegate) GetValidatorSrcAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorSrcAddress + } + return nil +} + +func (m *MsgBeginRedelegate) GetValidatorDstAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorDstAddress + } + return nil +} + +func (m *MsgBeginRedelegate) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +// MsgUndelegate defines an SDK message for performing an undelegation from a +// delegate and a validator. +type MsgUndelegate struct { + DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"validator_address"` + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` +} + +func (m *MsgUndelegate) Reset() { *m = MsgUndelegate{} } +func (m *MsgUndelegate) String() string { return proto.CompactTextString(m) } +func (*MsgUndelegate) ProtoMessage() {} +func (*MsgUndelegate) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{4} +} +func (m *MsgUndelegate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUndelegate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUndelegate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUndelegate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUndelegate.Merge(m, src) +} +func (m *MsgUndelegate) XXX_Size() int { + return m.Size() +} +func (m *MsgUndelegate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUndelegate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUndelegate proto.InternalMessageInfo + +func (m *MsgUndelegate) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *MsgUndelegate) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorAddress + } + return nil +} + +func (m *MsgUndelegate) GetAmount() types.Coin { + if m != nil { + return m.Amount + } + return types.Coin{} +} + +// HistoricalInfo contains the historical information that gets stored at // each height. -type HistoricalInfoProto struct { - Header types.Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"` - Valset []ValidatorProto `protobuf:"bytes,2,rep,name=valset,proto3" json:"valset"` +type HistoricalInfo struct { + Header types1.Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header"` + Valset []Validator `protobuf:"bytes,2,rep,name=valset,proto3" json:"valset"` } -func (m *HistoricalInfoProto) Reset() { *m = HistoricalInfoProto{} } -func (m *HistoricalInfoProto) String() string { return proto.CompactTextString(m) } -func (*HistoricalInfoProto) ProtoMessage() {} -func (*HistoricalInfoProto) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{0} +func (m *HistoricalInfo) Reset() { *m = HistoricalInfo{} } +func (m *HistoricalInfo) String() string { return proto.CompactTextString(m) } +func (*HistoricalInfo) ProtoMessage() {} +func (*HistoricalInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{5} } -func (m *HistoricalInfoProto) XXX_Unmarshal(b []byte) error { +func (m *HistoricalInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *HistoricalInfoProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *HistoricalInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_HistoricalInfoProto.Marshal(b, m, deterministic) + return xxx_messageInfo_HistoricalInfo.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -60,26 +400,26 @@ func (m *HistoricalInfoProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *HistoricalInfoProto) XXX_Merge(src proto.Message) { - xxx_messageInfo_HistoricalInfoProto.Merge(m, src) +func (m *HistoricalInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_HistoricalInfo.Merge(m, src) } -func (m *HistoricalInfoProto) XXX_Size() int { +func (m *HistoricalInfo) XXX_Size() int { return m.Size() } -func (m *HistoricalInfoProto) XXX_DiscardUnknown() { - xxx_messageInfo_HistoricalInfoProto.DiscardUnknown(m) +func (m *HistoricalInfo) XXX_DiscardUnknown() { + xxx_messageInfo_HistoricalInfo.DiscardUnknown(m) } -var xxx_messageInfo_HistoricalInfoProto proto.InternalMessageInfo +var xxx_messageInfo_HistoricalInfo proto.InternalMessageInfo -func (m *HistoricalInfoProto) GetHeader() types.Header { +func (m *HistoricalInfo) GetHeader() types1.Header { if m != nil { return m.Header } - return types.Header{} + return types1.Header{} } -func (m *HistoricalInfoProto) GetValset() []ValidatorProto { +func (m *HistoricalInfo) GetValset() []Validator { if m != nil { return m.Valset } @@ -97,7 +437,7 @@ type CommissionRates struct { func (m *CommissionRates) Reset() { *m = CommissionRates{} } func (*CommissionRates) ProtoMessage() {} func (*CommissionRates) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{1} + return fileDescriptor_c669c0a3ee1b124c, []int{6} } func (m *CommissionRates) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -135,7 +475,7 @@ type Commission struct { func (m *Commission) Reset() { *m = Commission{} } func (*Commission) ProtoMessage() {} func (*Commission) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{2} + return fileDescriptor_c669c0a3ee1b124c, []int{7} } func (m *Commission) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -183,7 +523,7 @@ type Description struct { func (m *Description) Reset() { *m = Description{} } func (*Description) ProtoMessage() {} func (*Description) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{3} + return fileDescriptor_c669c0a3ee1b124c, []int{8} } func (m *Description) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -247,35 +587,38 @@ func (m *Description) GetDetails() string { return "" } -// ValidatorProto defines the Protocol buffer equivalent of the Validator type. -type ValidatorProto struct { - OperatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"operator_address,omitempty" yaml:"operator_address"` - // TODO: We can remove cosmos_sdk.v1.PublicKey in favor of the primitive bytes - // once Tendermint supports pubkeys as slices. - ConsensusPubkey types1.PublicKey `protobuf:"bytes,2,opt,name=consensus_pubkey,json=consensusPubkey,proto3" json:"consensus_pubkey" yaml:"consensus_pubkey"` - Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed,omitempty"` - Status int32 `protobuf:"varint,4,opt,name=status,proto3" json:"status,omitempty"` - Tokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=tokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"tokens"` - DelegatorShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=delegator_shares,json=delegatorShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"delegator_shares" yaml:"delegator_shares"` - Description Description `protobuf:"bytes,7,opt,name=description,proto3" json:"description"` - UnbondingHeight int64 `protobuf:"varint,8,opt,name=unbonding_height,json=unbondingHeight,proto3" json:"unbonding_height,omitempty" yaml:"unbonding_height"` - UnbondingTime time.Time `protobuf:"bytes,9,opt,name=unbonding_time,json=unbondingTime,proto3,stdtime" json:"unbonding_time" yaml:"unbonding_time"` - Commission Commission `protobuf:"bytes,10,opt,name=commission,proto3" json:"commission"` - MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation" yaml:"min_self_delegation"` -} - -func (m *ValidatorProto) Reset() { *m = ValidatorProto{} } -func (m *ValidatorProto) String() string { return proto.CompactTextString(m) } -func (*ValidatorProto) ProtoMessage() {} -func (*ValidatorProto) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{4} +// Validator defines the total amount of bond shares and their exchange rate to +// coins. Slashing results in a decrease in the exchange rate, allowing correct +// calculation of future undelegations without iterating over delegators. +// When coins are delegated to this validator, the validator is credited with a +// delegation whose number of bond shares is based on the amount of coins delegated +// divided by the current exchange rate. Voting power can be calculated as total +// bonded shares multiplied by exchange rate. +type Validator struct { + OperatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"operator_address,omitempty" yaml:"operator_address"` + ConsensusPubkey string `protobuf:"bytes,2,opt,name=consensus_pubkey,json=consensusPubkey,proto3" json:"consensus_pubkey,omitempty" yaml:"consensus_pubkey"` + Jailed bool `protobuf:"varint,3,opt,name=jailed,proto3" json:"jailed,omitempty"` + Status github_com_cosmos_cosmos_sdk_types.BondStatus `protobuf:"varint,4,opt,name=status,proto3,casttype=github.com/cosmos/cosmos-sdk/types.BondStatus" json:"status,omitempty"` + Tokens github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=tokens,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"tokens"` + DelegatorShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=delegator_shares,json=delegatorShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"delegator_shares" yaml:"delegator_shares"` + Description Description `protobuf:"bytes,7,opt,name=description,proto3" json:"description"` + UnbondingHeight int64 `protobuf:"varint,8,opt,name=unbonding_height,json=unbondingHeight,proto3" json:"unbonding_height,omitempty" yaml:"unbonding_height"` + UnbondingTime time.Time `protobuf:"bytes,9,opt,name=unbonding_time,json=unbondingTime,proto3,stdtime" json:"unbonding_time" yaml:"unbonding_time"` + Commission Commission `protobuf:"bytes,10,opt,name=commission,proto3" json:"commission"` + MinSelfDelegation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=min_self_delegation,json=minSelfDelegation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_self_delegation" yaml:"min_self_delegation"` +} + +func (m *Validator) Reset() { *m = Validator{} } +func (*Validator) ProtoMessage() {} +func (*Validator) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{9} } -func (m *ValidatorProto) XXX_Unmarshal(b []byte) error { +func (m *Validator) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ValidatorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Validator) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ValidatorProto.Marshal(b, m, deterministic) + return xxx_messageInfo_Validator.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -285,100 +628,44 @@ func (m *ValidatorProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return b[:n], nil } } -func (m *ValidatorProto) XXX_Merge(src proto.Message) { - xxx_messageInfo_ValidatorProto.Merge(m, src) +func (m *Validator) XXX_Merge(src proto.Message) { + xxx_messageInfo_Validator.Merge(m, src) } -func (m *ValidatorProto) XXX_Size() int { +func (m *Validator) XXX_Size() int { return m.Size() } -func (m *ValidatorProto) XXX_DiscardUnknown() { - xxx_messageInfo_ValidatorProto.DiscardUnknown(m) +func (m *Validator) XXX_DiscardUnknown() { + xxx_messageInfo_Validator.DiscardUnknown(m) } -var xxx_messageInfo_ValidatorProto proto.InternalMessageInfo +var xxx_messageInfo_Validator proto.InternalMessageInfo -func (m *ValidatorProto) GetOperatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { - if m != nil { - return m.OperatorAddress - } - return nil +// DVPair is struct that just has a delegator-validator pair with no other data. +// It is intended to be used as a marshalable pointer. For example, a DVPair can +// be used to construct the key to getting an UnbondingDelegation from state. +type DVPair struct { + DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` + ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"validator_address"` } -func (m *ValidatorProto) GetConsensusPubkey() types1.PublicKey { - if m != nil { - return m.ConsensusPubkey - } - return types1.PublicKey{} +func (m *DVPair) Reset() { *m = DVPair{} } +func (*DVPair) ProtoMessage() {} +func (*DVPair) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{10} } - -func (m *ValidatorProto) GetJailed() bool { - if m != nil { - return m.Jailed - } - return false +func (m *DVPair) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) } - -func (m *ValidatorProto) GetStatus() int32 { - if m != nil { - return m.Status - } - return 0 -} - -func (m *ValidatorProto) GetDescription() Description { - if m != nil { - return m.Description - } - return Description{} -} - -func (m *ValidatorProto) GetUnbondingHeight() int64 { - if m != nil { - return m.UnbondingHeight - } - return 0 -} - -func (m *ValidatorProto) GetUnbondingTime() time.Time { - if m != nil { - return m.UnbondingTime - } - return time.Time{} -} - -func (m *ValidatorProto) GetCommission() Commission { - if m != nil { - return m.Commission - } - return Commission{} -} - -// DVPair is struct that just has a delegator-validator pair with no other data. -// It is intended to be used as a marshalable pointer. For example, a DVPair can -// be used to construct the key to getting an UnbondingDelegation from state. -type DVPair struct { - DelegatorAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"delegator_address,omitempty" yaml:"delegator_address"` - ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"validator_address"` -} - -func (m *DVPair) Reset() { *m = DVPair{} } -func (*DVPair) ProtoMessage() {} -func (*DVPair) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{5} -} -func (m *DVPair) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DVPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DVPair.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil +func (m *DVPair) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DVPair.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil } } func (m *DVPair) XXX_Merge(src proto.Message) { @@ -420,7 +707,7 @@ type DVVTriplet struct { func (m *DVVTriplet) Reset() { *m = DVVTriplet{} } func (*DVVTriplet) ProtoMessage() {} func (*DVVTriplet) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{6} + return fileDescriptor_c669c0a3ee1b124c, []int{11} } func (m *DVVTriplet) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -482,7 +769,7 @@ type Delegation struct { func (m *Delegation) Reset() { *m = Delegation{} } func (*Delegation) ProtoMessage() {} func (*Delegation) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{7} + return fileDescriptor_c669c0a3ee1b124c, []int{12} } func (m *Delegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -536,7 +823,7 @@ type UnbondingDelegation struct { func (m *UnbondingDelegation) Reset() { *m = UnbondingDelegation{} } func (*UnbondingDelegation) ProtoMessage() {} func (*UnbondingDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{8} + return fileDescriptor_c669c0a3ee1b124c, []int{13} } func (m *UnbondingDelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -597,7 +884,7 @@ type UnbondingDelegationEntry struct { func (m *UnbondingDelegationEntry) Reset() { *m = UnbondingDelegationEntry{} } func (*UnbondingDelegationEntry) ProtoMessage() {} func (*UnbondingDelegationEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{9} + return fileDescriptor_c669c0a3ee1b124c, []int{14} } func (m *UnbondingDelegationEntry) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -651,7 +938,7 @@ type RedelegationEntry struct { func (m *RedelegationEntry) Reset() { *m = RedelegationEntry{} } func (*RedelegationEntry) ProtoMessage() {} func (*RedelegationEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{10} + return fileDescriptor_c669c0a3ee1b124c, []int{15} } func (m *RedelegationEntry) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -706,7 +993,7 @@ type Redelegation struct { func (m *Redelegation) Reset() { *m = Redelegation{} } func (*Redelegation) ProtoMessage() {} func (*Redelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{11} + return fileDescriptor_c669c0a3ee1b124c, []int{16} } func (m *Redelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -775,7 +1062,7 @@ type Params struct { func (m *Params) Reset() { *m = Params{} } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{12} + return fileDescriptor_c669c0a3ee1b124c, []int{17} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -840,11 +1127,16 @@ func (m *Params) GetBondDenom() string { } func init() { - proto.RegisterType((*HistoricalInfoProto)(nil), "cosmos_sdk.x.staking.v1.HistoricalInfoProto") + proto.RegisterType((*MsgCreateValidator)(nil), "cosmos_sdk.x.staking.v1.MsgCreateValidator") + proto.RegisterType((*MsgEditValidator)(nil), "cosmos_sdk.x.staking.v1.MsgEditValidator") + proto.RegisterType((*MsgDelegate)(nil), "cosmos_sdk.x.staking.v1.MsgDelegate") + proto.RegisterType((*MsgBeginRedelegate)(nil), "cosmos_sdk.x.staking.v1.MsgBeginRedelegate") + proto.RegisterType((*MsgUndelegate)(nil), "cosmos_sdk.x.staking.v1.MsgUndelegate") + proto.RegisterType((*HistoricalInfo)(nil), "cosmos_sdk.x.staking.v1.HistoricalInfo") proto.RegisterType((*CommissionRates)(nil), "cosmos_sdk.x.staking.v1.CommissionRates") proto.RegisterType((*Commission)(nil), "cosmos_sdk.x.staking.v1.Commission") proto.RegisterType((*Description)(nil), "cosmos_sdk.x.staking.v1.Description") - proto.RegisterType((*ValidatorProto)(nil), "cosmos_sdk.x.staking.v1.ValidatorProto") + proto.RegisterType((*Validator)(nil), "cosmos_sdk.x.staking.v1.Validator") proto.RegisterType((*DVPair)(nil), "cosmos_sdk.x.staking.v1.DVPair") proto.RegisterType((*DVVTriplet)(nil), "cosmos_sdk.x.staking.v1.DVVTriplet") proto.RegisterType((*Delegation)(nil), "cosmos_sdk.x.staking.v1.Delegation") @@ -858,106 +1150,120 @@ func init() { func init() { proto.RegisterFile("x/staking/types/types.proto", fileDescriptor_c669c0a3ee1b124c) } var fileDescriptor_c669c0a3ee1b124c = []byte{ - // 1410 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff,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, 0x58, 0xa1, 0xd8, 0xe9, - 0x45, 0x84, 0x0d, 0x6c, 0x27, 0x0c, 0x18, 0x72, 0x58, 0x65, 0x5e, 0x44, 0xec, 0xec, 0x68, 0xa8, - 0x9f, 0x96, 0x7b, 0xcd, 0x4a, 0x18, 0x56, 0x29, 0x86, 0xd6, 0x25, 0xc2, 0x2d, 0xb8, 0x98, 0x21, - 0xe2, 0xd1, 0xca, 0x31, 0x69, 0x41, 0x2d, 0x53, 0x67, 0xf9, 0x7a, 0x01, 0x2c, 0x1f, 0xcc, 0x7c, - 0x78, 0x17, 0xac, 0x84, 0x5d, 0x1c, 0x71, 0xc0, 0x46, 0xae, 0x1b, 0x61, 0x2a, 0x83, 0x74, 0xbc, - 0xb1, 0x95, 0x98, 0xcf, 0x4a, 0x18, 0x7f, 0x0c, 0xf5, 0x8b, 0x2f, 0x90, 0x47, 0x3b, 0xc8, 0xbb, - 0x26, 0x35, 0xac, 0x52, 0xcc, 0xa1, 0x00, 0xe8, 0xf2, 0xec, 0x08, 0x28, 0x0e, 0x68, 0x8f, 0xda, - 0xdd, 0x5e, 0x6b, 0x0f, 0x0f, 0x54, 0x0c, 0x2b, 0xe9, 0xec, 0xd8, 0xbf, 0x64, 0x6e, 0xf7, 0x5a, - 0x1e, 0x71, 0xde, 0xc1, 0x83, 0x86, 0xae, 0x22, 0xa8, 0xb6, 0x95, 0xd5, 0x37, 0x78, 0x92, 0x28, - 0x68, 0x5b, 0x20, 0xf0, 0x14, 0x28, 0x7c, 0x84, 0x88, 0x87, 0x5d, 0xe1, 0xf6, 0x45, 0x4b, 0xad, - 0x38, 0x4e, 0x19, 0x62, 0x3d, 0x2a, 0x7c, 0x7d, 0xcc, 0x52, 0x2b, 0x78, 0x03, 0x14, 0x58, 0xb8, - 0x87, 0x03, 0xe5, 0xc4, 0x99, 0x4a, 0x7c, 0x33, 0x60, 0x96, 0xd2, 0x86, 0x0c, 0xac, 0xb8, 0xd8, - 0xc3, 0x6d, 0xe1, 0x35, 0xda, 0x41, 0x11, 0xa6, 0x95, 0x82, 0x60, 0xdc, 0x9c, 0xb9, 0x0e, 0xd5, - 0x69, 0xb3, 0x7c, 0x86, 0x55, 0x1a, 0x43, 0xb7, 0x05, 0x02, 0xb7, 0x40, 0xd1, 0x4d, 0x52, 0xb5, - 0xb2, 0x20, 0xdc, 0xf9, 0xf2, 0xd4, 0x62, 0x4b, 0xa5, 0xb5, 0xea, 0x80, 0x69, 0x75, 0x9e, 0x99, - 0xbd, 0xa0, 0x15, 0x06, 0x2e, 0x09, 0xda, 0x76, 0x07, 0x93, 0x76, 0x87, 0x55, 0x16, 0xcf, 0x6b, - 0x6b, 0xf9, 0x74, 0x66, 0x66, 0x25, 0x0c, 0xab, 0x34, 0x86, 0x36, 0x04, 0x02, 0x5d, 0xb0, 0x9c, - 0x48, 0x89, 0x5a, 0x5d, 0x7a, 0x6e, 0xad, 0xfe, 0x5f, 0x45, 0xfa, 0x64, 0xd6, 0x4a, 0x52, 0xae, - 0x27, 0xc6, 0x20, 0x57, 0x83, 0x9b, 0x00, 0x24, 0x1d, 0xa2, 0x02, 0x84, 0x85, 0x97, 0x5e, 0xa0, - 0xcf, 0xa8, 0x93, 0xa7, 0x94, 0xe1, 0x27, 0x60, 0xd5, 0x27, 0x81, 0x4d, 0xb1, 0xb7, 0x6b, 0x2b, - 0x17, 0x73, 0xce, 0xa2, 0x88, 0xdf, 0xd6, 0x6c, 0x19, 0x31, 0x1a, 0xea, 0x55, 0xd5, 0x47, 0x27, - 0x29, 0x0d, 0xab, 0xec, 0x93, 0xe0, 0x36, 0xf6, 0x76, 0x9b, 0x63, 0x4c, 0x4d, 0x9f, 0xcf, 0x72, - 0xa0, 0xd0, 0xdc, 0xd9, 0x46, 0x24, 0x82, 0xf7, 0x40, 0x39, 0x89, 0xfd, 0xc1, 0x1a, 0xbd, 0x39, - 0x1a, 0xea, 0x95, 0x6c, 0x7a, 0xcc, 0x58, 0xa4, 0xd7, 0x1c, 0x27, 0x2e, 0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 0x3f, 0x95, 0xbc, 0xfc, 0xa7, 0x1e, - 0x1a, 0x16, 0xf0, 0x51, 0xff, 0xba, 0x5c, 0xc0, 0x2d, 0x00, 0x3b, 0xe3, 0xcf, 0x52, 0x76, 0xe2, - 0x4b, 0xae, 0x7f, 0x6e, 0x34, 0xd4, 0xcf, 0x48, 0xfd, 0x49, 0x19, 0xc3, 0x2a, 0x27, 0x60, 0xcc, - 0xf6, 0x3a, 0x00, 0xfc, 0x5c, 0xb6, 0x8b, 0x83, 0xd0, 0x57, 0xaf, 0x94, 0x27, 0x47, 0x43, 0xbd, - 0x2c, 0x59, 0x92, 0x67, 0x86, 0xb5, 0xc4, 0x17, 0x4d, 0xfe, 0x3b, 0x71, 0x7c, 0xe3, 0xc6, 0xa3, - 0x27, 0x35, 0xed, 0xf1, 0x93, 0x9a, 0xf6, 0xf3, 0x93, 0x9a, 0x76, 0xff, 0x69, 0x6d, 0xee, 0xf1, - 0xd3, 0xda, 0xdc, 0x0f, 0x4f, 0x6b, 0x73, 0xef, 0xbd, 0xf6, 0x97, 0xc9, 0x92, 0xf9, 0x86, 0xd8, - 0x2a, 0x88, 0xa8, 0x5c, 0xf9, 0x33, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x6f, 0x88, 0x86, 0x5d, 0x14, - 0x00, 0x00, -} - -func (this *HistoricalInfoProto) Equal(that interface{}) bool { + // 1633 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0xcd, 0x6f, 0xdb, 0x46, + 0x16, 0x37, 0x25, 0x45, 0xb6, 0x9f, 0x62, 0xc9, 0xa6, 0x11, 0x47, 0x71, 0x36, 0xa2, 0x97, 0xbb, + 0x08, 0x8c, 0xc5, 0x46, 0x82, 0x93, 0x05, 0x16, 0xf0, 0x5e, 0x12, 0x59, 0x31, 0xec, 0x85, 0xbd, + 0x48, 0xe8, 0xc4, 0x87, 0xfd, 0x80, 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 0x4d, 0x64, 0x9b, 0x38, 0x3e, 0x84, 0x36, 0x8e, 0xed, 0x64, 0x21, 0x72, 0x12, 0x83, 0x53, + 0xb5, 0x19, 0x0b, 0x75, 0xd7, 0x7c, 0x81, 0xe7, 0x71, 0x75, 0xea, 0xc1, 0x43, 0x65, 0xc2, 0x8f, + 0xd8, 0x67, 0x12, 0x40, 0x14, 0x31, 0xf9, 0x5f, 0x30, 0x9b, 0x18, 0x62, 0x54, 0xe4, 0x73, 0x7c, + 0xe6, 0x37, 0xe5, 0xad, 0xfa, 0x71, 0x4f, 0x91, 0xb4, 0x82, 0x9e, 0xc8, 0xc5, 0x3f, 0x20, 0xd7, + 0x69, 0x1b, 0x88, 0xe1, 0xba, 0x47, 0x82, 0x05, 0xa7, 0x5c, 0x2c, 0x73, 0x02, 0x5c, 0x0e, 0x08, + 0x70, 0xf9, 0x4e, 0xc0, 0x90, 0xab, 0x25, 0x0f, 0xab, 0xdf, 0x53, 0x64, 0xbe, 0xaf, 0x98, 0xb1, + 0x7a, 0xff, 0x6b, 0x45, 0xd2, 0x80, 0x4b, 0x3c, 0x83, 0xd8, 0xa6, 0x3e, 0x95, 0x20, 0x17, 0xa3, + 0x1a, 0x72, 0x11, 0x26, 0x2d, 0xc7, 0x26, 0xfb, 0xe2, 0x70, 0x4e, 0x6b, 0xc1, 0xa3, 0xbc, 0x08, + 0x53, 0xc4, 0xc0, 0x36, 0x23, 0xec, 0x90, 0x27, 0x56, 0x0b, 0x9f, 0x3d, 0xab, 0x7b, 0xb8, 0x41, + 0x49, 0x90, 0x0e, 0x2d, 0x78, 0x94, 0xd7, 0x61, 0x96, 0x62, 0xbd, 0xe3, 0x12, 0x76, 0x58, 0xd7, + 0x1d, 0x9b, 0x21, 0x9d, 0x89, 0x19, 0x7e, 0xb1, 0xdf, 0x53, 0xce, 0xf3, 0xb5, 0x26, 0x35, 0x54, + 0xad, 0x10, 0x88, 0xd6, 0xb8, 0xc4, 0xf3, 0x60, 0x60, 0x86, 0x48, 0x8b, 0xb3, 0xc1, 0x69, 0x2d, + 0x78, 0x8c, 0xed, 0xe5, 0x93, 0x49, 0x98, 0x8e, 0xf8, 0xd6, 0x3d, 0x98, 0x75, 0xda, 0xd8, 0x1d, + 0xd2, 0xa2, 0xb6, 0x22, 0xcf, 0x49, 0x8d, 0x13, 0x74, 0x89, 0x42, 0x80, 0x11, 0x34, 0x89, 0x75, + 0xef, 0x60, 0xd8, 0x14, 0xdb, 0xb4, 0x43, 0xeb, 0x82, 0x50, 0xa6, 0x92, 0x5b, 0x4e, 0x6a, 0xa8, + 0xde, 0x09, 0x10, 0xa2, 0x5b, 0x9c, 0x76, 0x2e, 0x40, 0xf6, 0xdf, 0x88, 0xb4, 0xb0, 0xe1, 0xc7, + 0x74, 0x4a, 0x13, 0x4f, 0xf2, 0x26, 0x64, 0x29, 0x43, 0xac, 0xc3, 0x39, 0xf9, 0x99, 0xea, 0xca, + 0x98, 0x6b, 0xae, 0x3a, 0xb6, 0xb1, 0xe3, 0x1b, 0x6a, 0x02, 0x40, 0x5e, 0x87, 0x2c, 0x73, 0xf6, + 0xb1, 0x2d, 0x82, 0x7a, 0xac, 0x92, 0xdf, 0xb4, 0x99, 0x26, 0xac, 0x65, 0x06, 0x51, 0x9f, 0xae, + 0xd3, 0x26, 0x72, 0x31, 0xe5, 0x1c, 0xba, 0xba, 0x79, 0xec, 0xba, 0x3c, 0x9f, 0x1c, 0x1e, 0x1c, + 0x4f, 0xd5, 0x0a, 0xa1, 0x68, 0xc7, 0x97, 0x24, 0x19, 0xf5, 0xe4, 0x8b, 0x31, 0xea, 0x75, 0x98, + 0xed, 0xd8, 0x0d, 0xc7, 0x36, 0x88, 0x6d, 0xd6, 0x9b, 0x98, 0x98, 0x4d, 0x56, 0x9c, 0x5a, 0x92, + 0x96, 0xd3, 0xf1, 0xb4, 0x25, 0x35, 0x54, 0xad, 0x10, 0x8a, 0x36, 0x7c, 0x89, 0x6c, 0x40, 0x3e, + 0xd2, 0xf2, 0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xaa, 0x06, 0x16, + 0xea, 0xde, 0xe4, 0x0f, 0xf2, 0x16, 0xc8, 0xcd, 0xf0, 0x92, 0xaa, 0x1e, 0xc5, 0xd2, 0xb3, 0xbf, + 0xd4, 0xef, 0x29, 0x17, 0xb8, 0xfd, 0xa0, 0x8e, 0xaa, 0xcd, 0x45, 0xc2, 0x00, 0xed, 0x4f, 0x00, + 0xde, 0xbe, 0xea, 0x06, 0xb6, 0x1d, 0x4b, 0x7c, 0x5a, 0x9e, 0xeb, 0xf7, 0x94, 0x39, 0x8e, 0x12, + 0xbd, 0x53, 0xb5, 0x69, 0xef, 0xa1, 0xe6, 0xfd, 0x1d, 0x05, 0xbe, 0xba, 0xfe, 0xe8, 0x49, 0x49, + 0x7a, 0xfc, 0xa4, 0x24, 0x7d, 0xf3, 0xa4, 0x24, 0xdd, 0x7f, 0x5a, 0x9a, 0x78, 0xfc, 0xb4, 0x34, + 0xf1, 0xe5, 0xd3, 0xd2, 0xc4, 0xdf, 0xff, 0xf8, 0xcc, 0xc3, 0x92, 0xf8, 0x45, 0xb3, 0x91, 0xf5, + 0xb3, 0x72, 0xed, 0xe7, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd8, 0xec, 0x27, 0x1d, 0xeb, 0x1c, 0x00, + 0x00, +} + +func (this *HistoricalInfo) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*HistoricalInfoProto) + that1, ok := that.(*HistoricalInfo) if !ok { - that2, ok := that.(HistoricalInfoProto) + that2, ok := that.(HistoricalInfo) if ok { that1 = &that2 } else { @@ -1075,14 +1381,14 @@ func (this *Description) Equal(that interface{}) bool { } return true } -func (this *ValidatorProto) Equal(that interface{}) bool { +func (this *Validator) Equal(that interface{}) bool { if that == nil { return this == nil } - that1, ok := that.(*ValidatorProto) + that1, ok := that.(*Validator) if !ok { - that2, ok := that.(ValidatorProto) + that2, ok := that.(Validator) if ok { that1 = &that2 } else { @@ -1097,7 +1403,7 @@ func (this *ValidatorProto) Equal(that interface{}) bool { if !bytes.Equal(this.OperatorAddress, that1.OperatorAddress) { return false } - if !this.ConsensusPubkey.Equal(&that1.ConsensusPubkey) { + if this.ConsensusPubkey != that1.ConsensusPubkey { return false } if this.Jailed != that1.Jailed { @@ -1391,7 +1697,7 @@ func (this *Params) Equal(that interface{}) bool { } return true } -func (m *HistoricalInfoProto) Marshal() (dAtA []byte, err error) { +func (m *MsgCreateValidator) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1401,32 +1707,69 @@ func (m *HistoricalInfoProto) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *HistoricalInfoProto) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgCreateValidator) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *HistoricalInfoProto) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgCreateValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Valset) > 0 { - for iNdEx := len(m.Valset) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Valset[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 + { + size, err := m.Value.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + if len(m.Pubkey) > 0 { + i -= len(m.Pubkey) + copy(dAtA[i:], m.Pubkey) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Pubkey))) + i-- + dAtA[i] = 0x32 + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x2a + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0x22 } { - size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + size := m.MinSelfDelegation.Size() + i -= size + if _, err := m.MinSelfDelegation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.Commission.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1438,7 +1781,7 @@ func (m *HistoricalInfoProto) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *CommissionRates) Marshal() (dAtA []byte, err error) { +func (m *MsgEditValidator) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1448,42 +1791,53 @@ func (m *CommissionRates) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *CommissionRates) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgEditValidator) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *CommissionRates) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgEditValidator) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - { - size := m.MaxChangeRate.Size() - i -= size - if _, err := m.MaxChangeRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if m.MinSelfDelegation != nil { + { + size := m.MinSelfDelegation.Size() + i -= size + if _, err := m.MinSelfDelegation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) } - i = encodeVarintTypes(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x22 } - i-- - dAtA[i] = 0x1a - { - size := m.MaxRate.Size() - i -= size - if _, err := m.MaxRate.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if m.CommissionRate != nil { + { + size := m.CommissionRate.Size() + i -= size + if _, err := m.CommissionRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) } - i = encodeVarintTypes(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x1a + } + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 { - size := m.Rate.Size() - i -= size - if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { + size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { return 0, err } + i -= size i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- @@ -1491,7 +1845,7 @@ func (m *CommissionRates) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Commission) Marshal() (dAtA []byte, err error) { +func (m *MsgDelegate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1501,26 +1855,18 @@ func (m *Commission) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Commission) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgDelegate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Commission) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgDelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdateTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdateTime):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintTypes(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0x12 { - size, err := m.CommissionRates.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1528,11 +1874,25 @@ func (m *Commission) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa + dAtA[i] = 0x1a + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } -func (m *Description) Marshal() (dAtA []byte, err error) { +func (m *MsgBeginRedelegate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1542,55 +1902,51 @@ func (m *Description) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Description) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgBeginRedelegate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Description) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgBeginRedelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Details) > 0 { - i -= len(m.Details) - copy(dAtA[i:], m.Details) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Details))) - i-- - dAtA[i] = 0x2a - } - if len(m.SecurityContact) > 0 { - i -= len(m.SecurityContact) - copy(dAtA[i:], m.SecurityContact) - i = encodeVarintTypes(dAtA, i, uint64(len(m.SecurityContact))) - i-- - dAtA[i] = 0x22 + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) } - if len(m.Website) > 0 { - i -= len(m.Website) - copy(dAtA[i:], m.Website) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x22 + if len(m.ValidatorDstAddress) > 0 { + i -= len(m.ValidatorDstAddress) + copy(dAtA[i:], m.ValidatorDstAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorDstAddress))) i-- dAtA[i] = 0x1a } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Identity))) + if len(m.ValidatorSrcAddress) > 0 { + i -= len(m.ValidatorSrcAddress) + copy(dAtA[i:], m.ValidatorSrcAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorSrcAddress))) i-- dAtA[i] = 0x12 } - if len(m.Moniker) > 0 { - i -= len(m.Moniker) - copy(dAtA[i:], m.Moniker) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Moniker))) + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DelegatorAddress))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *ValidatorProto) Marshal() (dAtA []byte, err error) { +func (m *MsgUndelegate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1600,28 +1956,18 @@ func (m *ValidatorProto) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ValidatorProto) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUndelegate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ValidatorProto) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUndelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l { - size := m.MinSelfDelegation.Size() - i -= size - if _, err := m.MinSelfDelegation.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTypes(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - { - size, err := m.Commission.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1629,22 +1975,278 @@ func (m *ValidatorProto) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTypes(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x52 - n5, err5 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UnbondingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UnbondingTime):]) - if err5 != nil { - return 0, err5 + dAtA[i] = 0x1a + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 } - i -= n5 - i = encodeVarintTypes(dAtA, i, uint64(n5)) - i-- - dAtA[i] = 0x4a - if m.UnbondingHeight != 0 { - i = encodeVarintTypes(dAtA, i, uint64(m.UnbondingHeight)) + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.DelegatorAddress))) i-- - dAtA[i] = 0x40 + dAtA[i] = 0xa } - { - size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) + return len(dAtA) - i, nil +} + +func (m *HistoricalInfo) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *HistoricalInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HistoricalInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Valset) > 0 { + for iNdEx := len(m.Valset) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Valset[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *CommissionRates) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CommissionRates) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommissionRates) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MaxChangeRate.Size() + i -= size + if _, err := m.MaxChangeRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.MaxRate.Size() + i -= size + if _, err := m.MaxRate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.Rate.Size() + i -= size + if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Commission) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Commission) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Commission) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UpdateTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UpdateTime):]) + if err9 != nil { + return 0, err9 + } + i -= n9 + i = encodeVarintTypes(dAtA, i, uint64(n9)) + i-- + dAtA[i] = 0x12 + { + size, err := m.CommissionRates.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *Description) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Description) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Description) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Details) > 0 { + i -= len(m.Details) + copy(dAtA[i:], m.Details) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Details))) + i-- + dAtA[i] = 0x2a + } + if len(m.SecurityContact) > 0 { + i -= len(m.SecurityContact) + copy(dAtA[i:], m.SecurityContact) + i = encodeVarintTypes(dAtA, i, uint64(len(m.SecurityContact))) + i-- + dAtA[i] = 0x22 + } + if len(m.Website) > 0 { + i -= len(m.Website) + copy(dAtA[i:], m.Website) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Website))) + i-- + dAtA[i] = 0x1a + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x12 + } + if len(m.Moniker) > 0 { + i -= len(m.Moniker) + copy(dAtA[i:], m.Moniker) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Moniker))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Validator) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *Validator) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Validator) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.MinSelfDelegation.Size() + i -= size + if _, err := m.MinSelfDelegation.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + { + size, err := m.Commission.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + n12, err12 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.UnbondingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.UnbondingTime):]) + if err12 != nil { + return 0, err12 + } + i -= n12 + i = encodeVarintTypes(dAtA, i, uint64(n12)) + i-- + dAtA[i] = 0x4a + if m.UnbondingHeight != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.UnbondingHeight)) + i-- + dAtA[i] = 0x40 + } + { + size, err := m.Description.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1688,16 +2290,13 @@ func (m *ValidatorProto) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x18 } - { - size, err := m.ConsensusPubkey.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTypes(dAtA, i, uint64(size)) + if len(m.ConsensusPubkey) > 0 { + i -= len(m.ConsensusPubkey) + copy(dAtA[i:], m.ConsensusPubkey) + i = encodeVarintTypes(dAtA, i, uint64(len(m.ConsensusPubkey))) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 if len(m.OperatorAddress) > 0 { i -= len(m.OperatorAddress) copy(dAtA[i:], m.OperatorAddress) @@ -1927,12 +2526,12 @@ func (m *UnbondingDelegationEntry) MarshalToSizedBuffer(dAtA []byte) (int, error } i-- dAtA[i] = 0x1a - n8, err8 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime):]) - if err8 != nil { - return 0, err8 + n14, err14 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime):]) + if err14 != nil { + return 0, err14 } - i -= n8 - i = encodeVarintTypes(dAtA, i, uint64(n8)) + i -= n14 + i = encodeVarintTypes(dAtA, i, uint64(n14)) i-- dAtA[i] = 0x12 if m.CreationHeight != 0 { @@ -1983,12 +2582,12 @@ func (m *RedelegationEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x1a - n9, err9 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime):]) - if err9 != nil { - return 0, err9 + n15, err15 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.CompletionTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime):]) + if err15 != nil { + return 0, err15 } - i -= n9 - i = encodeVarintTypes(dAtA, i, uint64(n9)) + i -= n15 + i = encodeVarintTypes(dAtA, i, uint64(n15)) i-- dAtA[i] = 0x12 if m.CreationHeight != 0 { @@ -2099,12 +2698,12 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - n10, err10 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingTime):]) - if err10 != nil { - return 0, err10 + n16, err16 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingTime):]) + if err16 != nil { + return 0, err16 } - i -= n10 - i = encodeVarintTypes(dAtA, i, uint64(n10)) + i -= n16 + i = encodeVarintTypes(dAtA, i, uint64(n16)) i-- dAtA[i] = 0xa return len(dAtA) - i, nil @@ -2121,7 +2720,120 @@ func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *HistoricalInfoProto) Size() (n int) { +func (m *MsgCreateValidator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Description.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.Commission.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.MinSelfDelegation.Size() + n += 1 + l + sovTypes(uint64(l)) + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Pubkey) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Value.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *MsgEditValidator) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Description.Size() + n += 1 + l + sovTypes(uint64(l)) + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if m.CommissionRate != nil { + l = m.CommissionRate.Size() + n += 1 + l + sovTypes(uint64(l)) + } + if m.MinSelfDelegation != nil { + l = m.MinSelfDelegation.Size() + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgDelegate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *MsgBeginRedelegate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorSrcAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorDstAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *MsgUndelegate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *HistoricalInfo) Size() (n int) { if m == nil { return 0 } @@ -2195,7 +2907,7 @@ func (m *Description) Size() (n int) { return n } -func (m *ValidatorProto) Size() (n int) { +func (m *Validator) Size() (n int) { if m == nil { return 0 } @@ -2205,8 +2917,10 @@ func (m *ValidatorProto) Size() (n int) { if l > 0 { n += 1 + l + sovTypes(uint64(l)) } - l = m.ConsensusPubkey.Size() - n += 1 + l + sovTypes(uint64(l)) + l = len(m.ConsensusPubkey) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } if m.Jailed { n += 2 } @@ -2308,103 +3022,1077 @@ func (m *UnbondingDelegation) Size() (n int) { n += 1 + l + sovTypes(uint64(l)) } } - return n -} - -func (m *UnbondingDelegationEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CreationHeight != 0 { - n += 1 + sovTypes(uint64(m.CreationHeight)) - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime) - n += 1 + l + sovTypes(uint64(l)) - l = m.InitialBalance.Size() - n += 1 + l + sovTypes(uint64(l)) - l = m.Balance.Size() - n += 1 + l + sovTypes(uint64(l)) - return n -} + return n +} + +func (m *UnbondingDelegationEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CreationHeight != 0 { + n += 1 + sovTypes(uint64(m.CreationHeight)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime) + n += 1 + l + sovTypes(uint64(l)) + l = m.InitialBalance.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.Balance.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *RedelegationEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.CreationHeight != 0 { + n += 1 + sovTypes(uint64(m.CreationHeight)) + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime) + n += 1 + l + sovTypes(uint64(l)) + l = m.InitialBalance.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.SharesDst.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *Redelegation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorSrcAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.ValidatorDstAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if len(m.Entries) > 0 { + for _, e := range m.Entries { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingTime) + n += 1 + l + sovTypes(uint64(l)) + if m.MaxValidators != 0 { + n += 1 + sovTypes(uint64(m.MaxValidators)) + } + if m.MaxEntries != 0 { + n += 1 + sovTypes(uint64(m.MaxEntries)) + } + if m.HistoricalEntries != 0 { + n += 1 + sovTypes(uint64(m.HistoricalEntries)) + } + l = len(m.BondDenom) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateValidator) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgCreateValidator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateValidator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Commission", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Commission.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSelfDelegation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinSelfDelegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = append(m.DelegatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.DelegatorAddress == nil { + m.DelegatorAddress = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = append(m.ValidatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorAddress == nil { + m.ValidatorAddress = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pubkey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pubkey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Value.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgEditValidator) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgEditValidator: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgEditValidator: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Description.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = append(m.ValidatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorAddress == nil { + m.ValidatorAddress = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommissionRate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_cosmos_cosmos_sdk_types.Dec + m.CommissionRate = &v + if err := m.CommissionRate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinSelfDelegation", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var v github_com_cosmos_cosmos_sdk_types.Int + m.MinSelfDelegation = &v + if err := m.MinSelfDelegation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDelegate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDelegate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDelegate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = append(m.DelegatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.DelegatorAddress == nil { + m.DelegatorAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = append(m.ValidatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorAddress == nil { + m.ValidatorAddress = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgBeginRedelegate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgBeginRedelegate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBeginRedelegate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = append(m.DelegatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.DelegatorAddress == nil { + m.DelegatorAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSrcAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorSrcAddress = append(m.ValidatorSrcAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorSrcAddress == nil { + m.ValidatorSrcAddress = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorDstAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorDstAddress = append(m.ValidatorDstAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorDstAddress == nil { + m.ValidatorDstAddress = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func (m *RedelegationEntry) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.CreationHeight != 0 { - n += 1 + sovTypes(uint64(m.CreationHeight)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.CompletionTime) - n += 1 + l + sovTypes(uint64(l)) - l = m.InitialBalance.Size() - n += 1 + l + sovTypes(uint64(l)) - l = m.SharesDst.Size() - n += 1 + l + sovTypes(uint64(l)) - return n + return nil } - -func (m *Redelegation) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.DelegatorAddress) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.ValidatorSrcAddress) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - l = len(m.ValidatorDstAddress) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) - } - if len(m.Entries) > 0 { - for _, e := range m.Entries { - l = e.Size() - n += 1 + l + sovTypes(uint64(l)) +func (m *MsgUndelegate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUndelegate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUndelegate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = append(m.DelegatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.DelegatorAddress == nil { + m.DelegatorAddress = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = append(m.ValidatorAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValidatorAddress == nil { + m.ValidatorAddress = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy } } - return n -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingTime) - n += 1 + l + sovTypes(uint64(l)) - if m.MaxValidators != 0 { - n += 1 + sovTypes(uint64(m.MaxValidators)) - } - if m.MaxEntries != 0 { - n += 1 + sovTypes(uint64(m.MaxEntries)) - } - if m.HistoricalEntries != 0 { - n += 1 + sovTypes(uint64(m.HistoricalEntries)) - } - l = len(m.BondDenom) - if l > 0 { - n += 1 + l + sovTypes(uint64(l)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - return n -} - -func sovTypes(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTypes(x uint64) (n int) { - return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *HistoricalInfoProto) Unmarshal(dAtA []byte) error { +func (m *HistoricalInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2427,10 +4115,10 @@ func (m *HistoricalInfoProto) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: HistoricalInfoProto: wiretype end group for non-group") + return fmt.Errorf("proto: HistoricalInfo: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: HistoricalInfoProto: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: HistoricalInfo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -2495,7 +4183,7 @@ func (m *HistoricalInfoProto) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Valset = append(m.Valset, ValidatorProto{}) + m.Valset = append(m.Valset, Validator{}) if err := m.Valset[len(m.Valset)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3011,7 +4699,7 @@ func (m *Description) Unmarshal(dAtA []byte) error { } return nil } -func (m *ValidatorProto) Unmarshal(dAtA []byte) error { +func (m *Validator) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3034,10 +4722,10 @@ func (m *ValidatorProto) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ValidatorProto: wiretype end group for non-group") + return fmt.Errorf("proto: Validator: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ValidatorProto: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: Validator: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3078,7 +4766,7 @@ func (m *ValidatorProto) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field ConsensusPubkey", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTypes @@ -3088,24 +4776,23 @@ func (m *ValidatorProto) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTypes } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTypes } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.ConsensusPubkey.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.ConsensusPubkey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 0 { @@ -3141,7 +4828,7 @@ func (m *ValidatorProto) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Status |= int32(b&0x7F) << shift + m.Status |= github_com_cosmos_cosmos_sdk_types.BondStatus(b&0x7F) << shift if b < 0x80 { break } diff --git a/x/staking/types/types.proto b/x/staking/types/types.proto index 5ff36762df4d..a1f063eec6f0 100644 --- a/x/staking/types/types.proto +++ b/x/staking/types/types.proto @@ -9,13 +9,103 @@ import "types/types.proto"; option go_package = "github.com/cosmos/cosmos-sdk/x/staking/types"; -// HistoricalInfoProto contains the historical information that gets stored at +// MsgCreateValidator defines an SDK message for creating a new validator. +message MsgCreateValidator { + Description description = 1 [ (gogoproto.nullable) = false ]; + CommissionRates commission = 2 [ (gogoproto.nullable) = false ]; + string min_self_delegation = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"min_self_delegation\"", + (gogoproto.nullable) = false + ]; + bytes delegator_address = 4 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"delegator_address\"" + ]; + bytes validator_address = 5 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_address\"" + ]; + string pubkey = 6; + cosmos_sdk.v1.Coin value = 7 [ (gogoproto.nullable) = false ]; +} + +// MsgEditValidator defines an SDK message for editing an existing validator. +message MsgEditValidator { + Description description = 1 [ (gogoproto.nullable) = false ]; + bytes validator_address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"address\"" + ]; + + // We pass a reference to the new commission rate and min self delegation as + // it's not mandatory to update. If not updated, the deserialized rate will be + // zero with no way to distinguish if an update was intended. + // + // REF: #2373 + string commission_rate = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"commission_rate\"" + ]; + string min_self_delegation = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.moretags) = "yaml:\"min_self_delegation\"" + ]; +} + +// MsgDelegate defines an SDK message for performing a delegation from a +// delegate to a validator. +message MsgDelegate { + bytes delegator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"delegator_address\"" + ]; + bytes validator_address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_address\"" + ]; + cosmos_sdk.v1.Coin amount = 3 [ (gogoproto.nullable) = false ]; +} + +// MsgBeginRedelegate defines an SDK message for performing a redelegation from +// a delegate and source validator to a destination validator. +message MsgBeginRedelegate { + bytes delegator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"delegator_address\"" + ]; + bytes validator_src_address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_src_address\"" + ]; + bytes validator_dst_address = 3 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_dst_address\"" + ]; + cosmos_sdk.v1.Coin amount = 4 [ (gogoproto.nullable) = false ]; +} + +// MsgUndelegate defines an SDK message for performing an undelegation from a +// delegate and a validator. +message MsgUndelegate { + bytes delegator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"delegator_address\"" + ]; + bytes validator_address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_address\"" + ]; + cosmos_sdk.v1.Coin amount = 3 [ (gogoproto.nullable) = false ]; +} + +// HistoricalInfo contains the historical information that gets stored at // each height. -message HistoricalInfoProto { +message HistoricalInfo { option (gogoproto.equal) = true; tendermint.abci.types.Header header = 1 [ (gogoproto.nullable) = false ]; - repeated ValidatorProto valset = 2 [ (gogoproto.nullable) = false ]; + repeated Validator valset = 2 [ (gogoproto.nullable) = false ]; } // CommissionRates defines the initial commission rates to be used for creating @@ -67,22 +157,28 @@ message Description { string details = 5; } -// ValidatorProto defines the Protocol buffer equivalent of the Validator type. -message ValidatorProto { +// Validator defines the total amount of bond shares and their exchange rate to +// coins. Slashing results in a decrease in the exchange rate, allowing correct +// calculation of future undelegations without iterating over delegators. +// When coins are delegated to this validator, the validator is credited with a +// delegation whose number of bond shares is based on the amount of coins delegated +// divided by the current exchange rate. Voting power can be calculated as total +// bonded shares multiplied by exchange rate. +message Validator { option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; bytes operator_address = 1 [ (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", (gogoproto.moretags) = "yaml:\"operator_address\"" ]; - // TODO: We can remove cosmos_sdk.v1.PublicKey in favor of the primitive bytes - // once Tendermint supports pubkeys as slices. - cosmos_sdk.v1.PublicKey consensus_pubkey = 2 [ - (gogoproto.moretags) = "yaml:\"consensus_pubkey\"", - (gogoproto.nullable) = false - ]; + string consensus_pubkey = 2 + [ (gogoproto.moretags) = "yaml:\"consensus_pubkey\"" ]; bool jailed = 3; - int32 status = 4; + int32 status = 4 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.BondStatus" + ]; string tokens = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 74a6b7b2b85c..d2b4a0a3b41c 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -9,9 +9,6 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/tendermint/tendermint/crypto/sr25519" tmtypes "github.com/tendermint/tendermint/types" yaml "gopkg.in/yaml.v2" @@ -31,141 +28,33 @@ const ( MaxDetailsLength = 280 ) -// Implements Validator interface var _ exported.ValidatorI = Validator{} -// Validator defines the total amount of bond shares and their exchange rate to -// coins. Slashing results in a decrease in the exchange rate, allowing correct -// calculation of future undelegations without iterating over delegators. -// When coins are delegated to this validator, the validator is credited with a -// delegation whose number of bond shares is based on the amount of coins delegated -// divided by the current exchange rate. Voting power can be calculated as total -// bonded shares multiplied by exchange rate. -type Validator struct { - OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` // address of the validator's operator; bech encoded in JSON - ConsPubKey crypto.PubKey `json:"consensus_pubkey" yaml:"consensus_pubkey"` // the consensus public key of the validator; bech encoded in JSON - Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from bonded status? - Status sdk.BondStatus `json:"status" yaml:"status"` // validator status (bonded/unbonding/unbonded) - Tokens sdk.Int `json:"tokens" yaml:"tokens"` // delegated tokens (incl. self-delegation) - DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` // total shares issued to a validator's delegators - Description Description `json:"description" yaml:"description"` // description terms for the validator - UnbondingHeight int64 `json:"unbonding_height" yaml:"unbonding_height"` // if unbonding, height at which this validator has begun unbonding - UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` // if unbonding, min time for the validator to complete unbonding - Commission Commission `json:"commission" yaml:"commission"` // commission parameters - MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` // validator's self declared minimum self delegation -} - func NewValidator(operator sdk.ValAddress, pubKey crypto.PubKey, description Description) Validator { - return Validator{ - OperatorAddress: operator, - ConsPubKey: pubKey, - Jailed: false, - Status: sdk.Unbonded, - Tokens: sdk.ZeroInt(), - DelegatorShares: sdk.ZeroDec(), - Description: description, - UnbondingHeight: int64(0), - UnbondingCompletionTime: time.Unix(0, 0).UTC(), - Commission: NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), - MinSelfDelegation: sdk.OneInt(), - } -} - -// ToProto converts a Validator into a ValidatorProto type. -func (v Validator) ToProto() ValidatorProto { - var pk sdk.PublicKey - - switch t := v.ConsPubKey.(type) { - case secp256k1.PubKeySecp256k1: - pk = sdk.PublicKey{ - Pub: &sdk.PublicKey_Secp256K1{Secp256K1: t.Bytes()}, - } - - case ed25519.PubKeyEd25519: - pk = sdk.PublicKey{ - Pub: &sdk.PublicKey_Ed25519{Ed25519: t.Bytes()}, - } - - case sr25519.PubKeySr25519: - pk = sdk.PublicKey{ - Pub: &sdk.PublicKey_Sr25519{Sr25519: t.Bytes()}, - } - } - - return ValidatorProto{ - OperatorAddress: v.OperatorAddress, - ConsensusPubkey: pk, - Jailed: v.Jailed, - Status: int32(v.Status), - Tokens: v.Tokens, - DelegatorShares: v.DelegatorShares, - Description: v.Description, - UnbondingHeight: v.UnbondingHeight, - UnbondingTime: v.UnbondingCompletionTime, - Commission: v.Commission, - MinSelfDelegation: v.MinSelfDelegation, - } -} - -// ToValidator converts a ValidatorProto to a Validator type. -func (vp ValidatorProto) ToValidator() Validator { - var ( - pk crypto.PubKey - err error - ) - - switch t := vp.ConsensusPubkey.GetPub().(type) { - case *sdk.PublicKey_Secp256K1: - err = ModuleCdc.amino.UnmarshalBinaryBare(t.Secp256K1, &pk) - - case *sdk.PublicKey_Ed25519: - err = ModuleCdc.amino.UnmarshalBinaryBare(t.Ed25519, &pk) - - case *sdk.PublicKey_Sr25519: - err = ModuleCdc.amino.UnmarshalBinaryBare(t.Sr25519, &pk) - - default: - err = fmt.Errorf("unsupported public key type: %T", t) - } - - if err != nil { - panic(fmt.Errorf("failed to decode public key: %w", err)) + var pkStr string + if pubKey != nil { + pkStr = sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pubKey) } return Validator{ - OperatorAddress: vp.OperatorAddress, - ConsPubKey: pk, - Jailed: vp.Jailed, - Status: sdk.BondStatus(byte(vp.Status)), - Tokens: vp.Tokens, - DelegatorShares: vp.DelegatorShares, - Description: vp.Description, - UnbondingHeight: vp.UnbondingHeight, - UnbondingCompletionTime: vp.UnbondingTime, - Commission: vp.Commission, - MinSelfDelegation: vp.MinSelfDelegation, + OperatorAddress: operator, + ConsensusPubkey: pkStr, + Jailed: false, + Status: sdk.Unbonded, + Tokens: sdk.ZeroInt(), + DelegatorShares: sdk.ZeroDec(), + Description: description, + UnbondingHeight: int64(0), + UnbondingTime: time.Unix(0, 0).UTC(), + Commission: NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()), + MinSelfDelegation: sdk.OneInt(), } } // String implements the Stringer interface for a Validator object. func (v Validator) String() string { - bechConsPubKey, _ := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, v.ConsPubKey) - - bz, _ := yaml.Marshal(bechValidator{ - OperatorAddress: v.OperatorAddress, - ConsPubKey: bechConsPubKey, - Jailed: v.Jailed, - Status: v.Status, - Tokens: v.Tokens, - DelegatorShares: v.DelegatorShares, - Description: v.Description, - UnbondingHeight: v.UnbondingHeight, - UnbondingCompletionTime: v.UnbondingCompletionTime, - Commission: v.Commission, - MinSelfDelegation: v.MinSelfDelegation, - }) - - return string(bz) + out, _ := yaml.Marshal(v) + return string(out) } // Validators is a collection of Validator @@ -219,8 +108,7 @@ func (v Validators) Swap(i, j int) { // return the redelegation func MustMarshalValidator(cdc codec.Marshaler, validator Validator) []byte { - valProto := validator.ToProto() - return cdc.MustMarshalBinaryLengthPrefixed(&valProto) + return cdc.MustMarshalBinaryLengthPrefixed(&validator) } // unmarshal a redelegation from a store value @@ -233,92 +121,9 @@ func MustUnmarshalValidator(cdc codec.Marshaler, value []byte) Validator { } // unmarshal a redelegation from a store value -func UnmarshalValidator(cdc codec.Marshaler, value []byte) (Validator, error) { - vp := ValidatorProto{} - if err := cdc.UnmarshalBinaryLengthPrefixed(value, &vp); err != nil { - return Validator{}, err - } - - return vp.ToValidator(), nil -} - -// this is a helper struct used for JSON de- and encoding only -type bechValidator struct { - OperatorAddress sdk.ValAddress `json:"operator_address" yaml:"operator_address"` // the bech32 address of the validator's operator - ConsPubKey string `json:"consensus_pubkey" yaml:"consensus_pubkey"` // the bech32 consensus public key of the validator - Jailed bool `json:"jailed" yaml:"jailed"` // has the validator been jailed from bonded status? - Status sdk.BondStatus `json:"status" yaml:"status"` // validator status (bonded/unbonding/unbonded) - Tokens sdk.Int `json:"tokens" yaml:"tokens"` // delegated tokens (incl. self-delegation) - DelegatorShares sdk.Dec `json:"delegator_shares" yaml:"delegator_shares"` // total shares issued to a validator's delegators - Description Description `json:"description" yaml:"description"` // description terms for the validator - UnbondingHeight int64 `json:"unbonding_height" yaml:"unbonding_height"` // if unbonding, height at which this validator has begun unbonding - UnbondingCompletionTime time.Time `json:"unbonding_time" yaml:"unbonding_time"` // if unbonding, min time for the validator to complete unbonding - Commission Commission `json:"commission" yaml:"commission"` // commission parameters - MinSelfDelegation sdk.Int `json:"min_self_delegation" yaml:"min_self_delegation"` // minimum self delegation -} - -// MarshalJSON marshals the validator to JSON using Bech32 -func (v Validator) MarshalJSON() ([]byte, error) { - bechConsPubKey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, v.ConsPubKey) - if err != nil { - return nil, err - } - - return codec.Cdc.MarshalJSON(bechValidator{ - OperatorAddress: v.OperatorAddress, - ConsPubKey: bechConsPubKey, - Jailed: v.Jailed, - Status: v.Status, - Tokens: v.Tokens, - DelegatorShares: v.DelegatorShares, - Description: v.Description, - UnbondingHeight: v.UnbondingHeight, - UnbondingCompletionTime: v.UnbondingCompletionTime, - MinSelfDelegation: v.MinSelfDelegation, - Commission: v.Commission, - }) -} - -// UnmarshalJSON unmarshals the validator from JSON using Bech32 -func (v *Validator) UnmarshalJSON(data []byte) error { - bv := &bechValidator{} - if err := codec.Cdc.UnmarshalJSON(data, bv); err != nil { - return err - } - consPubKey, err := sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeConsPub, bv.ConsPubKey) - if err != nil { - return err - } - *v = Validator{ - OperatorAddress: bv.OperatorAddress, - ConsPubKey: consPubKey, - Jailed: bv.Jailed, - Tokens: bv.Tokens, - Status: bv.Status, - DelegatorShares: bv.DelegatorShares, - Description: bv.Description, - UnbondingHeight: bv.UnbondingHeight, - UnbondingCompletionTime: bv.UnbondingCompletionTime, - Commission: bv.Commission, - MinSelfDelegation: bv.MinSelfDelegation, - } - return nil -} - -// only the vitals -func (v Validator) TestEquivalent(v2 Validator) bool { - return v.ConsPubKey.Equals(v2.ConsPubKey) && - bytes.Equal(v.OperatorAddress, v2.OperatorAddress) && - v.Status.Equal(v2.Status) && - v.Tokens.Equal(v2.Tokens) && - v.DelegatorShares.Equal(v2.DelegatorShares) && - v.Description == v2.Description && - v.Commission.Equal(v2.Commission) -} - -// return the TM validator address -func (v Validator) ConsAddress() sdk.ConsAddress { - return sdk.ConsAddress(v.ConsPubKey.Address()) +func UnmarshalValidator(cdc codec.Marshaler, value []byte) (v Validator, err error) { + err = cdc.UnmarshalBinaryLengthPrefixed(value, &v) + return v, err } // IsBonded checks if the validator status equals Bonded @@ -408,7 +213,7 @@ func (d Description) EnsureLength() (Description, error) { // with the full validator power func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate { return abci.ValidatorUpdate{ - PubKey: tmtypes.TM2PB.PubKey(v.ConsPubKey), + PubKey: tmtypes.TM2PB.PubKey(v.GetConsPubKey()), Power: v.ConsensusPower(), } } @@ -417,14 +222,14 @@ func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate { // with zero power used for validator updates. func (v Validator) ABCIValidatorUpdateZero() abci.ValidatorUpdate { return abci.ValidatorUpdate{ - PubKey: tmtypes.TM2PB.PubKey(v.ConsPubKey), + PubKey: tmtypes.TM2PB.PubKey(v.GetConsPubKey()), Power: 0, } } // ToTmValidator casts an SDK validator to a tendermint type Validator. func (v Validator) ToTmValidator() *tmtypes.Validator { - return tmtypes.NewValidator(v.ConsPubKey, v.ConsensusPower()) + return tmtypes.NewValidator(v.GetConsPubKey(), v.ConsensusPower()) } // SetInitialCommission attempts to set a validator's initial commission. An @@ -549,20 +354,19 @@ func (v Validator) RemoveTokens(tokens sdk.Int) Validator { // NOTE: because token fractions are left in the valiadator, // the exchange rate of future shares of this validator can increase. func (v Validator) RemoveDelShares(delShares sdk.Dec) (Validator, sdk.Int) { - remainingShares := v.DelegatorShares.Sub(delShares) + var issuedTokens sdk.Int if remainingShares.IsZero() { - // last delegation share gets any trimmings issuedTokens = v.Tokens v.Tokens = sdk.ZeroInt() } else { - // leave excess tokens in the validator // however fully use all the delegator shares issuedTokens = v.TokensFromShares(delShares).TruncateInt() v.Tokens = v.Tokens.Sub(issuedTokens) + if v.Tokens.IsNegative() { panic("attempting to remove more tokens than available in validator") } @@ -573,12 +377,14 @@ func (v Validator) RemoveDelShares(delShares sdk.Dec) (Validator, sdk.Int) { } // nolint - for ValidatorI -func (v Validator) IsJailed() bool { return v.Jailed } -func (v Validator) GetMoniker() string { return v.Description.Moniker } -func (v Validator) GetStatus() sdk.BondStatus { return v.Status } -func (v Validator) GetOperator() sdk.ValAddress { return v.OperatorAddress } -func (v Validator) GetConsPubKey() crypto.PubKey { return v.ConsPubKey } -func (v Validator) GetConsAddr() sdk.ConsAddress { return sdk.ConsAddress(v.ConsPubKey.Address()) } +func (v Validator) IsJailed() bool { return v.Jailed } +func (v Validator) GetMoniker() string { return v.Description.Moniker } +func (v Validator) GetStatus() sdk.BondStatus { return v.Status } +func (v Validator) GetOperator() sdk.ValAddress { return v.OperatorAddress } +func (v Validator) GetConsPubKey() crypto.PubKey { + return sdk.MustGetPubKeyFromBech32(sdk.Bech32PubKeyTypeConsPub, v.ConsensusPubkey) +} +func (v Validator) GetConsAddr() sdk.ConsAddress { return sdk.ConsAddress(v.GetConsPubKey().Address()) } func (v Validator) GetTokens() sdk.Int { return v.Tokens } func (v Validator) GetBondedTokens() sdk.Int { return v.BondedTokens() } func (v Validator) GetConsensusPower() int64 { return v.ConsensusPower() } diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index b8a572444e0c..54e0c7ebb639 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -1,7 +1,6 @@ package types import ( - "fmt" "math/rand" "reflect" "sort" @@ -11,7 +10,6 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" tmtypes "github.com/tendermint/tendermint/types" - yaml "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -21,12 +19,12 @@ func TestValidatorTestEquivalent(t *testing.T) { val1 := NewValidator(valAddr1, pk1, Description{}) val2 := NewValidator(valAddr1, pk1, Description{}) - ok := val1.TestEquivalent(val2) + ok := val1.Equal(val2) require.True(t, ok) val2 = NewValidator(valAddr2, pk2, Description{}) - ok = val1.TestEquivalent(val2) + ok = val1.Equal(val2) require.False(t, ok) } @@ -63,7 +61,7 @@ func TestABCIValidatorUpdate(t *testing.T) { validator := NewValidator(valAddr1, pk1, Description{}) abciVal := validator.ABCIValidatorUpdate() - require.Equal(t, tmtypes.TM2PB.PubKey(validator.ConsPubKey), abciVal.PubKey) + require.Equal(t, tmtypes.TM2PB.PubKey(validator.GetConsPubKey()), abciVal.PubKey) require.Equal(t, validator.BondedTokens().Int64(), abciVal.Power) } @@ -71,14 +69,14 @@ func TestABCIValidatorUpdateZero(t *testing.T) { validator := NewValidator(valAddr1, pk1, Description{}) abciVal := validator.ABCIValidatorUpdateZero() - require.Equal(t, tmtypes.TM2PB.PubKey(validator.ConsPubKey), abciVal.PubKey) + require.Equal(t, tmtypes.TM2PB.PubKey(validator.GetConsPubKey()), abciVal.PubKey) require.Equal(t, int64(0), abciVal.Power) } func TestShareTokens(t *testing.T) { validator := Validator{ OperatorAddress: valAddr1, - ConsPubKey: pk1, + ConsensusPubkey: sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pk1), Status: sdk.Bonded, Tokens: sdk.NewInt(100), DelegatorShares: sdk.NewDec(100), @@ -96,7 +94,7 @@ func TestRemoveTokens(t *testing.T) { validator := Validator{ OperatorAddress: valAddr, - ConsPubKey: valPubKey, + ConsensusPubkey: sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, valPubKey), Status: sdk.Bonded, Tokens: sdk.NewInt(100), DelegatorShares: sdk.NewDec(100), @@ -152,7 +150,7 @@ func TestAddTokensValidatorUnbonded(t *testing.T) { func TestRemoveDelShares(t *testing.T) { valA := Validator{ OperatorAddress: sdk.ValAddress(pk1.Address().Bytes()), - ConsPubKey: pk1, + ConsensusPubkey: sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pk1), Status: sdk.Bonded, Tokens: sdk.NewInt(100), DelegatorShares: sdk.NewDec(100), @@ -169,7 +167,7 @@ func TestRemoveDelShares(t *testing.T) { delShares := sdk.NewDec(115) validator := Validator{ OperatorAddress: sdk.ValAddress(pk1.Address().Bytes()), - ConsPubKey: pk1, + ConsensusPubkey: sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pk1), Status: sdk.Bonded, Tokens: poolTokens, DelegatorShares: delShares, @@ -218,7 +216,7 @@ func TestPossibleOverflow(t *testing.T) { delShares := sdk.NewDec(391432570689183511).Quo(sdk.NewDec(40113011844664)) validator := Validator{ OperatorAddress: sdk.ValAddress(pk1.Address().Bytes()), - ConsPubKey: pk1, + ConsensusPubkey: sdk.MustBech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pk1), Status: sdk.Bonded, Tokens: sdk.NewInt(2159), DelegatorShares: delShares, @@ -276,38 +274,6 @@ func TestValidatorSetInitialCommission(t *testing.T) { } } -func TestValidatorMarshalYAML(t *testing.T) { - validator := NewValidator(valAddr1, pk1, Description{}) - bechifiedPub, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, validator.ConsPubKey) - require.NoError(t, err) - bs, err := yaml.Marshal(validator) - require.NoError(t, err) - want := fmt.Sprintf(`| - operatoraddress: %s - conspubkey: %s - jailed: false - status: 0 - tokens: "0" - delegatorshares: "0.000000000000000000" - description: - moniker: "" - identity: "" - website: "" - security_contact: "" - details: "" - unbondingheight: 0 - unbondingcompletiontime: 1970-01-01T00:00:00Z - commission: - commission_rates: - rate: "0.000000000000000000" - max_rate: "0.000000000000000000" - max_change_rate: "0.000000000000000000" - update_time: 1970-01-01T00:00:00Z - minselfdelegation: "1" -`, validator.OperatorAddress.String(), bechifiedPub) - require.Equal(t, want, string(bs)) -} - // Check that sort will create deterministic ordering of validators func TestValidatorsSortDeterminism(t *testing.T) { vals := make([]Validator, 10) From 60dc3672dc0a699de437b8de00185ef69abd28b6 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 14:40:01 -0500 Subject: [PATCH 04/27] Add benchmarks for bech32 pubkey funcs --- types/address_bench_test.go | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 types/address_bench_test.go diff --git a/types/address_bench_test.go b/types/address_bench_test.go new file mode 100644 index 000000000000..8e438a81dacd --- /dev/null +++ b/types/address_bench_test.go @@ -0,0 +1,48 @@ +package types_test + +import ( + "math/rand" + "testing" + "time" + + "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" + + "github.com/tendermint/tendermint/crypto/ed25519" +) + +func BenchmarkBech32ifyPubKey(b *testing.B) { + var pk ed25519.PubKeyEd25519 + rng := rand.New(rand.NewSource(time.Now().Unix())) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + b.StopTimer() + rng.Read(pk[:]) + b.StartTimer() + + _, err := types.Bech32ifyPubKey(types.Bech32PubKeyTypeConsPub, pk) + require.NoError(b, err) + } +} + +func BenchmarkGetPubKeyFromBech32(b *testing.B) { + var pk ed25519.PubKeyEd25519 + rng := rand.New(rand.NewSource(time.Now().Unix())) + + b.ResetTimer() + + for i := 0; i < b.N; i++ { + b.StopTimer() + rng.Read(pk[:]) + + pkStr, err := types.Bech32ifyPubKey(types.Bech32PubKeyTypeConsPub, pk) + require.NoError(b, err) + + b.StartTimer() + pk2, err := types.GetPubKeyFromBech32(types.Bech32PubKeyTypeConsPub, pkStr) + require.NoError(b, err) + require.Equal(b, pk, pk2) + } +} From f0f6f50ff55ddb57e8e78ed31795f31c93a876f5 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 14:40:17 -0500 Subject: [PATCH 05/27] Update BondStatus type alias to int32 --- types/staking.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/types/staking.go b/types/staking.go index 9f623b3575e6..91c7601386d6 100644 --- a/types/staking.go +++ b/types/staking.go @@ -36,13 +36,13 @@ func TokensFromConsensusPower(power int64) Int { } // BondStatus is the status of a validator -type BondStatus byte +type BondStatus int32 // staking constants const ( - Unbonded BondStatus = 0x00 - Unbonding BondStatus = 0x01 - Bonded BondStatus = 0x02 + Unbonded BondStatus = 1 + Unbonding BondStatus = 2 + Bonded BondStatus = 3 BondStatusUnbonded = "Unbonded" BondStatusUnbonding = "Unbonding" @@ -57,12 +57,15 @@ func (b BondStatus) Equal(b2 BondStatus) bool { // String implements the Stringer interface for BondStatus. func (b BondStatus) String() string { switch b { - case 0x00: + case Unbonded: return BondStatusUnbonded - case 0x01: + + case Unbonding: return BondStatusUnbonding - case 0x02: + + case Bonded: return BondStatusBonded + default: panic("invalid bond status") } From c268a9e539766aa1e704f31ab54f1dccfede4706 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 14:40:50 -0500 Subject: [PATCH 06/27] Remove PubKey proto type --- types/types.pb.go | 553 +--------------------------------------------- types/types.proto | 12 - 2 files changed, 7 insertions(+), 558 deletions(-) diff --git a/types/types.pb.go b/types/types.pb.go index 2f7560431406..4ea0bfeec523 100644 --- a/types/types.pb.go +++ b/types/types.pb.go @@ -4,15 +4,12 @@ package types import ( - bytes "bytes" fmt "fmt" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" math_bits "math/bits" - reflect "reflect" - strings "strings" ) // Reference imports to suppress errors if they are not otherwise used. @@ -122,115 +119,15 @@ func (m *DecCoin) GetDenom() string { return "" } -// PublicKey defines a type to represent raw public key bytes. -type PublicKey struct { - // Types that are valid to be assigned to Pub: - // *PublicKey_Ed25519 - // *PublicKey_Secp256K1 - // *PublicKey_Sr25519 - Pub isPublicKey_Pub `protobuf_oneof:"pub"` -} - -func (m *PublicKey) Reset() { *m = PublicKey{} } -func (*PublicKey) ProtoMessage() {} -func (*PublicKey) Descriptor() ([]byte, []int) { - return fileDescriptor_2c0f90c600ad7e2e, []int{2} -} -func (m *PublicKey) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *PublicKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_PublicKey.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *PublicKey) XXX_Merge(src proto.Message) { - xxx_messageInfo_PublicKey.Merge(m, src) -} -func (m *PublicKey) XXX_Size() int { - return m.Size() -} -func (m *PublicKey) XXX_DiscardUnknown() { - xxx_messageInfo_PublicKey.DiscardUnknown(m) -} - -var xxx_messageInfo_PublicKey proto.InternalMessageInfo - -type isPublicKey_Pub interface { - isPublicKey_Pub() - Equal(interface{}) bool - MarshalTo([]byte) (int, error) - Size() int -} - -type PublicKey_Ed25519 struct { - Ed25519 []byte `protobuf:"bytes,1,opt,name=ed25519,proto3,oneof" json:"ed25519,omitempty"` -} -type PublicKey_Secp256K1 struct { - Secp256K1 []byte `protobuf:"bytes,2,opt,name=secp256k1,proto3,oneof" json:"secp256k1,omitempty"` -} -type PublicKey_Sr25519 struct { - Sr25519 []byte `protobuf:"bytes,3,opt,name=sr25519,proto3,oneof" json:"sr25519,omitempty"` -} - -func (*PublicKey_Ed25519) isPublicKey_Pub() {} -func (*PublicKey_Secp256K1) isPublicKey_Pub() {} -func (*PublicKey_Sr25519) isPublicKey_Pub() {} - -func (m *PublicKey) GetPub() isPublicKey_Pub { - if m != nil { - return m.Pub - } - return nil -} - -func (m *PublicKey) GetEd25519() []byte { - if x, ok := m.GetPub().(*PublicKey_Ed25519); ok { - return x.Ed25519 - } - return nil -} - -func (m *PublicKey) GetSecp256K1() []byte { - if x, ok := m.GetPub().(*PublicKey_Secp256K1); ok { - return x.Secp256K1 - } - return nil -} - -func (m *PublicKey) GetSr25519() []byte { - if x, ok := m.GetPub().(*PublicKey_Sr25519); ok { - return x.Sr25519 - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*PublicKey) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*PublicKey_Ed25519)(nil), - (*PublicKey_Secp256K1)(nil), - (*PublicKey_Sr25519)(nil), - } -} - func init() { proto.RegisterType((*Coin)(nil), "cosmos_sdk.v1.Coin") proto.RegisterType((*DecCoin)(nil), "cosmos_sdk.v1.DecCoin") - proto.RegisterType((*PublicKey)(nil), "cosmos_sdk.v1.PublicKey") } func init() { proto.RegisterFile("types/types.proto", fileDescriptor_2c0f90c600ad7e2e) } var fileDescriptor_2c0f90c600ad7e2e = []byte{ - // 293 bytes of a gzipped FileDescriptorProto + // 214 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x07, 0x93, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xbc, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0xc5, 0x29, 0xd9, 0x7a, 0x65, 0x86, 0x52, 0x6a, 0x25, 0x19, 0x99, 0x45, 0x29, @@ -239,121 +136,14 @@ var fileDescriptor_2c0f90c600ad7e2e = []byte{ 0x5e, 0x7e, 0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x94, 0xd2, 0x2d, 0x4e, 0xc9, 0x86, - 0xc4, 0x40, 0x12, 0x1b, 0x38, 0x2c, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x83, 0x31, 0xbe, - 0xbf, 0x97, 0x01, 0x00, 0x00, + 0x32, 0x39, 0xa6, 0xb8, 0xa4, 0x26, 0xc3, 0x4c, 0x71, 0x72, 0xb9, 0xf1, 0x50, 0x8e, 0xa1, 0xe1, + 0x91, 0x1c, 0xc3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, + 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x29, 0xa5, 0x67, + 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x3c, 0x0b, 0xa5, 0x74, 0x8b, 0x53, + 0xb2, 0x21, 0x61, 0x91, 0xc4, 0x06, 0xf6, 0x95, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xc6, + 0x8c, 0x7d, 0x21, 0x01, 0x00, 0x00, } -func (this *PublicKey) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PublicKey) - if !ok { - that2, ok := that.(PublicKey) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if that1.Pub == nil { - if this.Pub != nil { - return false - } - } else if this.Pub == nil { - return false - } else if !this.Pub.Equal(that1.Pub) { - return false - } - return true -} -func (this *PublicKey_Ed25519) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PublicKey_Ed25519) - if !ok { - that2, ok := that.(PublicKey_Ed25519) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !bytes.Equal(this.Ed25519, that1.Ed25519) { - return false - } - return true -} -func (this *PublicKey_Secp256K1) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PublicKey_Secp256K1) - if !ok { - that2, ok := that.(PublicKey_Secp256K1) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !bytes.Equal(this.Secp256K1, that1.Secp256K1) { - return false - } - return true -} -func (this *PublicKey_Sr25519) Equal(that interface{}) bool { - if that == nil { - return this == nil - } - - that1, ok := that.(*PublicKey_Sr25519) - if !ok { - that2, ok := that.(PublicKey_Sr25519) - if ok { - that1 = &that2 - } else { - return false - } - } - if that1 == nil { - return this == nil - } else if this == nil { - return false - } - if !bytes.Equal(this.Sr25519, that1.Sr25519) { - return false - } - return true -} func (m *Coin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -434,86 +224,6 @@ func (m *DecCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *PublicKey) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *PublicKey) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PublicKey) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pub != nil { - { - size := m.Pub.Size() - i -= size - if _, err := m.Pub.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *PublicKey_Ed25519) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PublicKey_Ed25519) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Ed25519 != nil { - i -= len(m.Ed25519) - copy(dAtA[i:], m.Ed25519) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Ed25519))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *PublicKey_Secp256K1) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PublicKey_Secp256K1) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Secp256K1 != nil { - i -= len(m.Secp256K1) - copy(dAtA[i:], m.Secp256K1) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Secp256K1))) - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *PublicKey_Sr25519) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *PublicKey_Sr25519) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Sr25519 != nil { - i -= len(m.Sr25519) - copy(dAtA[i:], m.Sr25519) - i = encodeVarintTypes(dAtA, i, uint64(len(m.Sr25519))) - i-- - dAtA[i] = 0x1a - } - return len(dAtA) - i, nil -} func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -555,109 +265,12 @@ func (m *DecCoin) Size() (n int) { return n } -func (m *PublicKey) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pub != nil { - n += m.Pub.Size() - } - return n -} - -func (m *PublicKey_Ed25519) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Ed25519 != nil { - l = len(m.Ed25519) - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *PublicKey_Secp256K1) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Secp256K1 != nil { - l = len(m.Secp256K1) - n += 1 + l + sovTypes(uint64(l)) - } - return n -} -func (m *PublicKey_Sr25519) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Sr25519 != nil { - l = len(m.Sr25519) - n += 1 + l + sovTypes(uint64(l)) - } - return n -} - func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (this *PublicKey) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&PublicKey{`, - `Pub:` + fmt.Sprintf("%v", this.Pub) + `,`, - `}`, - }, "") - return s -} -func (this *PublicKey_Ed25519) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&PublicKey_Ed25519{`, - `Ed25519:` + fmt.Sprintf("%v", this.Ed25519) + `,`, - `}`, - }, "") - return s -} -func (this *PublicKey_Secp256K1) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&PublicKey_Secp256K1{`, - `Secp256K1:` + fmt.Sprintf("%v", this.Secp256K1) + `,`, - `}`, - }, "") - return s -} -func (this *PublicKey_Sr25519) String() string { - if this == nil { - return "nil" - } - s := strings.Join([]string{`&PublicKey_Sr25519{`, - `Sr25519:` + fmt.Sprintf("%v", this.Sr25519) + `,`, - `}`, - }, "") - return s -} -func valueToStringTypes(v interface{}) string { - rv := reflect.ValueOf(v) - if rv.IsNil() { - return "nil" - } - pv := reflect.Indirect(rv).Interface() - return fmt.Sprintf("*%v", pv) -} func (m *Coin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -896,158 +509,6 @@ func (m *DecCoin) Unmarshal(dAtA []byte) error { } return nil } -func (m *PublicKey) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: PublicKey: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: PublicKey: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ed25519", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.Pub = &PublicKey_Ed25519{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Secp256K1", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.Pub = &PublicKey_Secp256K1{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sr25519", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTypes - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthTypes - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthTypes - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := make([]byte, postIndex-iNdEx) - copy(v, dAtA[iNdEx:postIndex]) - m.Pub = &PublicKey_Sr25519{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipTypes(dAtA[iNdEx:]) - if err != nil { - return err - } - if skippy < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) < 0 { - return ErrInvalidLengthTypes - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/types/types.proto b/types/types.proto index a9b3dcb1ee62..49da4e5c69f9 100644 --- a/types/types.proto +++ b/types/types.proto @@ -24,15 +24,3 @@ message DecCoin { string denom = 1; string amount = 2 [ (gogoproto.customtype) = "Dec", (gogoproto.nullable) = false ]; } - -// PublicKey defines a type to represent raw public key bytes. -message PublicKey { - option (gogoproto.equal) = true; - option (gogoproto.stringer) = true; - - oneof pub { - bytes ed25519 = 1; - bytes secp256k1 = 2; - bytes sr25519 = 3; - } -} \ No newline at end of file From 95edc79af9418460d9b63cd167852dcd33d7ec83 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 14:48:16 -0500 Subject: [PATCH 07/27] Fix unit test --- x/staking/types/msg_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/staking/types/msg_test.go b/x/staking/types/msg_test.go index 22914ec8aefa..99866b11ca65 100644 --- a/x/staking/types/msg_test.go +++ b/x/staking/types/msg_test.go @@ -32,7 +32,7 @@ func TestMsgCreateValidator(t *testing.T) { {"partial description", "", "", "c", "", "", commission1, sdk.OneInt(), valAddr1, pk1, coinPos, true}, {"empty description", "", "", "", "", "", commission2, sdk.OneInt(), valAddr1, pk1, coinPos, false}, {"empty address", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), emptyAddr, pk1, coinPos, false}, - {"empty pubkey", "a", "b", "c", "d", "e", commission1, sdk.OneInt(), valAddr1, emptyPubkey, coinPos, true}, + {"empty pubkey", "a", "b", "c", "d", "e", commission1, sdk.OneInt(), valAddr1, emptyPubkey, coinPos, false}, {"empty bond", "a", "b", "c", "d", "e", commission2, sdk.OneInt(), valAddr1, pk1, coinZero, false}, {"zero min self delegation", "a", "b", "c", "d", "e", commission1, sdk.ZeroInt(), valAddr1, pk1, coinPos, false}, {"negative min self delegation", "a", "b", "c", "d", "e", commission1, sdk.NewInt(-1), valAddr1, pk1, coinPos, false}, From 46be4b4c4d6cf08e9b427fbca0b61b5610921c73 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 15:58:26 -0500 Subject: [PATCH 08/27] Update staking keeper --- codec/amino.go | 8 +- types/decimal.go | 4 + types/int.go | 4 + types/types.pb.go | 554 ++++++++++++++++++++++++- types/types.proto | 25 +- x/staking/alias.go | 1 + x/staking/keeper/delegation.go | 36 +- x/staking/keeper/keeper.go | 20 +- x/staking/keeper/params.go | 6 +- x/staking/keeper/query_utils.go | 28 +- x/staking/keeper/val_state_change.go | 10 +- x/staking/keeper/validator.go | 56 ++- x/staking/types/expected_keepers.go | 2 +- x/staking/types/types.pb.go | 600 ++++++++++++++++++++++----- x/staking/types/types.proto | 19 +- 15 files changed, 1175 insertions(+), 198 deletions(-) diff --git a/codec/amino.go b/codec/amino.go index b2300aef6cc3..3393ba4da717 100644 --- a/codec/amino.go +++ b/codec/amino.go @@ -45,8 +45,8 @@ func RegisterEvidences(cdc *Codec) { // MarshalJSONIndent provides a utility for indented JSON encoding of an object // via an Amino codec. It returns an error if it cannot serialize or indent as // JSON. -func MarshalJSONIndent(cdc *Codec, obj interface{}) ([]byte, error) { - bz, err := cdc.MarshalJSON(obj) +func MarshalJSONIndent(m Marshaler, obj interface{}) ([]byte, error) { + bz, err := m.MarshalJSON(obj) if err != nil { return nil, err } @@ -60,8 +60,8 @@ func MarshalJSONIndent(cdc *Codec, obj interface{}) ([]byte, error) { } // MustMarshalJSONIndent executes MarshalJSONIndent except it panics upon failure. -func MustMarshalJSONIndent(cdc *Codec, obj interface{}) []byte { - bz, err := MarshalJSONIndent(cdc, obj) +func MustMarshalJSONIndent(m Marshaler, obj interface{}) []byte { + bz, err := MarshalJSONIndent(m, obj) if err != nil { panic(fmt.Sprintf("failed to marshal JSON: %s", err)) } diff --git a/types/decimal.go b/types/decimal.go index d6917182b66c..c1cfc25bcc08 100644 --- a/types/decimal.go +++ b/types/decimal.go @@ -750,6 +750,10 @@ func (d *Dec) Size() int { func (d Dec) MarshalAmino() ([]byte, error) { return d.Marshal() } func (d *Dec) UnmarshalAmino(bz []byte) error { return d.Unmarshal(bz) } +func (dp DecProto) String() string { + return dp.Dec.String() +} + //___________________________________________________________________________________ // helpers diff --git a/types/int.go b/types/int.go index 9cc99a013263..4326a3ee9931 100644 --- a/types/int.go +++ b/types/int.go @@ -417,3 +417,7 @@ func (i *Int) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) } func IntEq(t *testing.T, exp, got Int) (*testing.T, bool, string, string, string) { return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() } + +func (ip IntProto) String() string { + return ip.Int.String() +} diff --git a/types/types.pb.go b/types/types.pb.go index 4ea0bfeec523..4d2136c0a030 100644 --- a/types/types.pb.go +++ b/types/types.pb.go @@ -10,6 +10,8 @@ import ( io "io" math "math" math_bits "math/bits" + reflect "reflect" + strings "strings" ) // Reference imports to suppress errors if they are not otherwise used. @@ -119,15 +121,136 @@ func (m *DecCoin) GetDenom() string { return "" } +// IntProto defines a Protobuf wrapper around an Int object. +type IntProto struct { + Int Int `protobuf:"bytes,1,opt,name=int,proto3,customtype=Int" json:"int"` +} + +func (m *IntProto) Reset() { *m = IntProto{} } +func (*IntProto) ProtoMessage() {} +func (*IntProto) Descriptor() ([]byte, []int) { + return fileDescriptor_2c0f90c600ad7e2e, []int{2} +} +func (m *IntProto) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *IntProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_IntProto.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *IntProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_IntProto.Merge(m, src) +} +func (m *IntProto) XXX_Size() int { + return m.Size() +} +func (m *IntProto) XXX_DiscardUnknown() { + xxx_messageInfo_IntProto.DiscardUnknown(m) +} + +var xxx_messageInfo_IntProto proto.InternalMessageInfo + +// DecProto defines a Protobuf wrapper around a Dec object. +type DecProto struct { + Dec Dec `protobuf:"bytes,1,opt,name=dec,proto3,customtype=Dec" json:"dec"` +} + +func (m *DecProto) Reset() { *m = DecProto{} } +func (*DecProto) ProtoMessage() {} +func (*DecProto) Descriptor() ([]byte, []int) { + return fileDescriptor_2c0f90c600ad7e2e, []int{3} +} +func (m *DecProto) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DecProto) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DecProto.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DecProto) XXX_Merge(src proto.Message) { + xxx_messageInfo_DecProto.Merge(m, src) +} +func (m *DecProto) XXX_Size() int { + return m.Size() +} +func (m *DecProto) XXX_DiscardUnknown() { + xxx_messageInfo_DecProto.DiscardUnknown(m) +} + +var xxx_messageInfo_DecProto proto.InternalMessageInfo + +// ValAddresses defines a repeated set of validator addresses. +type ValAddresses struct { + Addresses []ValAddress `protobuf:"bytes,1,rep,name=addresses,proto3,casttype=ValAddress" json:"addresses,omitempty"` +} + +func (m *ValAddresses) Reset() { *m = ValAddresses{} } +func (*ValAddresses) ProtoMessage() {} +func (*ValAddresses) Descriptor() ([]byte, []int) { + return fileDescriptor_2c0f90c600ad7e2e, []int{4} +} +func (m *ValAddresses) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValAddresses) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValAddresses.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ValAddresses) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValAddresses.Merge(m, src) +} +func (m *ValAddresses) XXX_Size() int { + return m.Size() +} +func (m *ValAddresses) XXX_DiscardUnknown() { + xxx_messageInfo_ValAddresses.DiscardUnknown(m) +} + +var xxx_messageInfo_ValAddresses proto.InternalMessageInfo + +func (m *ValAddresses) GetAddresses() []ValAddress { + if m != nil { + return m.Addresses + } + return nil +} + func init() { proto.RegisterType((*Coin)(nil), "cosmos_sdk.v1.Coin") proto.RegisterType((*DecCoin)(nil), "cosmos_sdk.v1.DecCoin") + proto.RegisterType((*IntProto)(nil), "cosmos_sdk.v1.IntProto") + proto.RegisterType((*DecProto)(nil), "cosmos_sdk.v1.DecProto") + proto.RegisterType((*ValAddresses)(nil), "cosmos_sdk.v1.ValAddresses") } func init() { proto.RegisterFile("types/types.proto", fileDescriptor_2c0f90c600ad7e2e) } var fileDescriptor_2c0f90c600ad7e2e = []byte{ - // 214 bytes of a gzipped FileDescriptorProto + // 298 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0xa9, 0x2c, 0x48, 0x2d, 0xd6, 0x07, 0x93, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xbc, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0xf1, 0xc5, 0x29, 0xd9, 0x7a, 0x65, 0x86, 0x52, 0x6a, 0x25, 0x19, 0x99, 0x45, 0x29, @@ -136,12 +259,17 @@ var fileDescriptor_2c0f90c600ad7e2e = []byte{ 0x5e, 0x7e, 0xae, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x84, 0x23, 0xa4, 0xcc, 0xc5, 0x96, 0x98, 0x9b, 0x5f, 0x9a, 0x57, 0x22, 0xc1, 0x04, 0x12, 0x76, 0xe2, 0x3e, 0x71, 0x4f, 0x9e, 0xe1, 0xd6, 0x3d, 0x79, 0x66, 0xcf, 0xbc, 0x92, 0x20, 0xa8, 0x94, 0x92, 0x0b, 0x17, 0xbb, 0x4b, 0x6a, - 0x32, 0x39, 0xa6, 0xb8, 0xa4, 0x26, 0xc3, 0x4c, 0x71, 0x72, 0xb9, 0xf1, 0x50, 0x8e, 0xa1, 0xe1, - 0x91, 0x1c, 0xc3, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, - 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x29, 0xa5, 0x67, - 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, 0x3c, 0x0b, 0xa5, 0x74, 0x8b, 0x53, - 0xb2, 0x21, 0x61, 0x91, 0xc4, 0x06, 0xf6, 0x95, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x8d, 0xc6, - 0x8c, 0x7d, 0x21, 0x01, 0x00, 0x00, + 0x32, 0x39, 0xa6, 0xb8, 0xa4, 0x26, 0xc3, 0x4d, 0xd1, 0xe4, 0xe2, 0xf0, 0xcc, 0x2b, 0x09, 0x00, + 0xfb, 0x45, 0x96, 0x8b, 0x39, 0x33, 0xaf, 0x04, 0x62, 0x08, 0xaa, 0x9d, 0x20, 0x71, 0x90, 0x52, + 0x97, 0xd4, 0x64, 0xb8, 0xd2, 0x94, 0xd4, 0x64, 0x74, 0xa5, 0x20, 0x83, 0x41, 0xe2, 0x4a, 0x4e, + 0x5c, 0x3c, 0x61, 0x89, 0x39, 0x8e, 0x29, 0x29, 0x45, 0xa9, 0xc5, 0xc5, 0xa9, 0xc5, 0x42, 0x3a, + 0x5c, 0x9c, 0x89, 0x30, 0x8e, 0x04, 0xa3, 0x02, 0xb3, 0x06, 0x8f, 0x13, 0xdf, 0xaf, 0x7b, 0xf2, + 0x5c, 0x08, 0x45, 0x41, 0x08, 0x05, 0x56, 0x2c, 0x0d, 0x77, 0x14, 0x18, 0x9d, 0x5c, 0x6e, 0x3c, + 0x94, 0x63, 0x68, 0x78, 0x24, 0xc7, 0x70, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, + 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, + 0x51, 0x4a, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0x90, 0x68, 0x80, + 0x52, 0xba, 0xc5, 0x29, 0xd9, 0x90, 0x58, 0x4a, 0x62, 0x03, 0x87, 0xb7, 0x31, 0x20, 0x00, 0x00, + 0xff, 0xff, 0xd6, 0x08, 0x09, 0x0f, 0xbb, 0x01, 0x00, 0x00, } func (m *Coin) Marshal() (dAtA []byte, err error) { @@ -224,6 +352,104 @@ func (m *DecCoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *IntProto) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IntProto) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *IntProto) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Int.Size() + i -= size + if _, err := m.Int.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *DecProto) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DecProto) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DecProto) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Dec.Size() + i -= size + if _, err := m.Dec.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *ValAddresses) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ValAddresses) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValAddresses) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Addresses) > 0 { + for iNdEx := len(m.Addresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Addresses[iNdEx]) + copy(dAtA[i:], m.Addresses[iNdEx]) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Addresses[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { offset -= sovTypes(v) base := offset @@ -265,12 +491,67 @@ func (m *DecCoin) Size() (n int) { return n } +func (m *IntProto) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Int.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *DecProto) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Dec.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *ValAddresses) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Addresses) > 0 { + for _, b := range m.Addresses { + l = len(b) + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + func sovTypes(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } func sozTypes(x uint64) (n int) { return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (this *ValAddresses) String() string { + if this == nil { + return "nil" + } + s := strings.Join([]string{`&ValAddresses{`, + `Addresses:` + fmt.Sprintf("%v", this.Addresses) + `,`, + `}`, + }, "") + return s +} +func valueToStringTypes(v interface{}) string { + rv := reflect.ValueOf(v) + if rv.IsNil() { + return "nil" + } + pv := reflect.Indirect(rv).Interface() + return fmt.Sprintf("*%v", pv) +} func (m *Coin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -509,6 +790,265 @@ func (m *DecCoin) Unmarshal(dAtA []byte) error { } return nil } +func (m *IntProto) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: IntProto: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: IntProto: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Int", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Int.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DecProto) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DecProto: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DecProto: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Dec", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Dec.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ValAddresses) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ValAddresses: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValAddresses: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Addresses", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Addresses = append(m.Addresses, make([]byte, postIndex-iNdEx)) + copy(m.Addresses[len(m.Addresses)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTypes(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/types/types.proto b/types/types.proto index 49da4e5c69f9..590d21ccd9be 100644 --- a/types/types.proto +++ b/types/types.proto @@ -13,7 +13,8 @@ option (gogoproto.stringer_all) = false; // signatures required by gogoproto. message Coin { string denom = 1; - string amount = 2 [ (gogoproto.customtype) = "Int", (gogoproto.nullable) = false ]; + string amount = 2 + [ (gogoproto.customtype) = "Int", (gogoproto.nullable) = false ]; } // DecCoin defines a token with a denomination and a decimal amount. @@ -22,5 +23,25 @@ message Coin { // signatures required by gogoproto. message DecCoin { string denom = 1; - string amount = 2 [ (gogoproto.customtype) = "Dec", (gogoproto.nullable) = false ]; + string amount = 2 + [ (gogoproto.customtype) = "Dec", (gogoproto.nullable) = false ]; } + +// IntProto defines a Protobuf wrapper around an Int object. +message IntProto { + string int = 1 + [ (gogoproto.customtype) = "Int", (gogoproto.nullable) = false ]; +} + +// DecProto defines a Protobuf wrapper around a Dec object. +message DecProto { + string dec = 1 + [ (gogoproto.customtype) = "Dec", (gogoproto.nullable) = false ]; +} + +// ValAddresses defines a repeated set of validator addresses. +message ValAddresses { + option (gogoproto.stringer) = true; + + repeated bytes addresses = 1 [ (gogoproto.casttype) = "ValAddress" ]; +} \ No newline at end of file diff --git a/x/staking/alias.go b/x/staking/alias.go index 51c7eecc7087..1b7c78772f73 100644 --- a/x/staking/alias.go +++ b/x/staking/alias.go @@ -123,6 +123,7 @@ var ( ErrNeitherShareMsgsGiven = types.ErrNeitherShareMsgsGiven ErrInvalidHistoricalInfo = types.ErrInvalidHistoricalInfo ErrNoHistoricalInfo = types.ErrNoHistoricalInfo + ErrEmptyValidatorPubKey = types.ErrEmptyValidatorPubKey NewGenesisState = types.NewGenesisState DefaultGenesisState = types.DefaultGenesisState NewMultiStakingHooks = types.NewMultiStakingHooks diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 219beef71271..375fad90313b 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -218,14 +218,16 @@ func (k Keeper) GetUBDQueueTimeSlice(ctx sdk.Context, timestamp time.Time) (dvPa if bz == nil { return []types.DVPair{} } - k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &dvPairs) - return dvPairs + + pairs := types.DVPairs{} + k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &pairs) + return pairs.Pairs } // Sets a specific unbonding queue timeslice. func (k Keeper) SetUBDQueueTimeSlice(ctx sdk.Context, timestamp time.Time, keys []types.DVPair) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshalBinaryLengthPrefixed(keys) + bz := k.cdc.MustMarshalBinaryLengthPrefixed(&types.DVPairs{Pairs: keys}) store.Set(types.GetUnbondingDelegationTimeKey(timestamp), bz) } @@ -252,19 +254,20 @@ func (k Keeper) UBDQueueIterator(ctx sdk.Context, endTime time.Time) sdk.Iterato // Returns a concatenated list of all the timeslices inclusively previous to // currTime, and deletes the timeslices from the queue -func (k Keeper) DequeueAllMatureUBDQueue(ctx sdk.Context, - currTime time.Time) (matureUnbonds []types.DVPair) { - +func (k Keeper) DequeueAllMatureUBDQueue(ctx sdk.Context, currTime time.Time) (matureUnbonds []types.DVPair) { store := ctx.KVStore(k.storeKey) + // gets an iterator for all timeslices from time 0 until the current Blockheader time unbondingTimesliceIterator := k.UBDQueueIterator(ctx, ctx.BlockHeader().Time) for ; unbondingTimesliceIterator.Valid(); unbondingTimesliceIterator.Next() { - timeslice := []types.DVPair{} + timeslice := types.DVPairs{} value := unbondingTimesliceIterator.Value() k.cdc.MustUnmarshalBinaryLengthPrefixed(value, ×lice) - matureUnbonds = append(matureUnbonds, timeslice...) + + matureUnbonds = append(matureUnbonds, timeslice.Pairs...) store.Delete(unbondingTimesliceIterator.Key()) } + return matureUnbonds } @@ -404,14 +407,16 @@ func (k Keeper) GetRedelegationQueueTimeSlice(ctx sdk.Context, timestamp time.Ti if bz == nil { return []types.DVVTriplet{} } - k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &dvvTriplets) - return dvvTriplets + + triplets := types.DVVTriplets{} + k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &triplets) + return triplets.Triplets } // Sets a specific redelegation queue timeslice. func (k Keeper) SetRedelegationQueueTimeSlice(ctx sdk.Context, timestamp time.Time, keys []types.DVVTriplet) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshalBinaryLengthPrefixed(keys) + bz := k.cdc.MustMarshalBinaryLengthPrefixed(&types.DVVTriplets{Triplets: keys}) store.Set(types.GetRedelegationTimeKey(timestamp), bz) } @@ -443,15 +448,18 @@ func (k Keeper) RedelegationQueueIterator(ctx sdk.Context, endTime time.Time) sd // currTime, and deletes the timeslices from the queue func (k Keeper) DequeueAllMatureRedelegationQueue(ctx sdk.Context, currTime time.Time) (matureRedelegations []types.DVVTriplet) { store := ctx.KVStore(k.storeKey) + // gets an iterator for all timeslices from time 0 until the current Blockheader time redelegationTimesliceIterator := k.RedelegationQueueIterator(ctx, ctx.BlockHeader().Time) for ; redelegationTimesliceIterator.Valid(); redelegationTimesliceIterator.Next() { - timeslice := []types.DVVTriplet{} + timeslice := types.DVVTriplets{} value := redelegationTimesliceIterator.Value() k.cdc.MustUnmarshalBinaryLengthPrefixed(value, ×lice) - matureRedelegations = append(matureRedelegations, timeslice...) + + matureRedelegations = append(matureRedelegations, timeslice.Triplets...) store.Delete(redelegationTimesliceIterator.Key()) } + return matureRedelegations } @@ -618,7 +626,7 @@ func (k Keeper) getBeginInfo( return completionTime, height, true case validator.IsUnbonding(): - return validator.UnbondingCompletionTime, validator.UnbondingHeight, false + return validator.UnbondingTime, validator.UnbondingHeight, false default: panic(fmt.Sprintf("unknown validator status: %s", validator.Status)) diff --git a/x/staking/keeper/keeper.go b/x/staking/keeper/keeper.go index 412f6a3a8464..ef7aab43557f 100644 --- a/x/staking/keeper/keeper.go +++ b/x/staking/keeper/keeper.go @@ -23,7 +23,7 @@ var _ types.DelegationSet = Keeper{} // keeper of the staking store type Keeper struct { storeKey sdk.StoreKey - cdc *codec.Codec + cdc codec.Marshaler bankKeeper types.BankKeeper supplyKeeper types.SupplyKeeper hooks types.StakingHooks @@ -34,7 +34,7 @@ type Keeper struct { // NewKeeper creates a new staking Keeper instance func NewKeeper( - cdc *codec.Codec, key sdk.StoreKey, bk types.BankKeeper, sk types.SupplyKeeper, ps params.Subspace, + cdc codec.Marshaler, key sdk.StoreKey, bk types.BankKeeper, sk types.SupplyKeeper, ps params.Subspace, ) Keeper { // ensure bonded and not bonded module accounts are set @@ -73,19 +73,21 @@ func (k *Keeper) SetHooks(sh types.StakingHooks) *Keeper { } // Load the last total validator power. -func (k Keeper) GetLastTotalPower(ctx sdk.Context) (power sdk.Int) { +func (k Keeper) GetLastTotalPower(ctx sdk.Context) sdk.Int { store := ctx.KVStore(k.storeKey) - b := store.Get(types.LastTotalPowerKey) - if b == nil { + bz := store.Get(types.LastTotalPowerKey) + if bz == nil { return sdk.ZeroInt() } - k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &power) - return + + ip := sdk.IntProto{} + k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &ip) + return ip.Int } // Set the last total validator power. func (k Keeper) SetLastTotalPower(ctx sdk.Context, power sdk.Int) { store := ctx.KVStore(k.storeKey) - b := k.cdc.MustMarshalBinaryLengthPrefixed(power) - store.Set(types.LastTotalPowerKey, b) + bz := k.cdc.MustMarshalBinaryLengthPrefixed(&sdk.IntProto{Int: power}) + store.Set(types.LastTotalPowerKey, bz) } diff --git a/x/staking/keeper/params.go b/x/staking/keeper/params.go index 11f4b57bc55b..e50e6ccd6455 100644 --- a/x/staking/keeper/params.go +++ b/x/staking/keeper/params.go @@ -25,21 +25,21 @@ func (k Keeper) UnbondingTime(ctx sdk.Context) (res time.Duration) { } // MaxValidators - Maximum number of validators -func (k Keeper) MaxValidators(ctx sdk.Context) (res uint16) { +func (k Keeper) MaxValidators(ctx sdk.Context) (res uint32) { k.paramstore.Get(ctx, types.KeyMaxValidators, &res) return } // MaxEntries - Maximum number of simultaneous unbonding // delegations or redelegations (per pair/trio) -func (k Keeper) MaxEntries(ctx sdk.Context) (res uint16) { +func (k Keeper) MaxEntries(ctx sdk.Context) (res uint32) { k.paramstore.Get(ctx, types.KeyMaxEntries, &res) return } // HistoricalEntries = number of historical info entries // to persist in store -func (k Keeper) HistoricalEntries(ctx sdk.Context) (res uint16) { +func (k Keeper) HistoricalEntries(ctx sdk.Context) (res uint32) { k.paramstore.Get(ctx, types.KeyHistoricalEntries, &res) return } diff --git a/x/staking/keeper/query_utils.go b/x/staking/keeper/query_utils.go index 336bb842ab9e..ae7cf634600a 100644 --- a/x/staking/keeper/query_utils.go +++ b/x/staking/keeper/query_utils.go @@ -6,9 +6,11 @@ import ( ) // Return all validators that a delegator is bonded to. If maxRetrieve is supplied, the respective amount will be returned. -func (k Keeper) GetDelegatorValidators(ctx sdk.Context, delegatorAddr sdk.AccAddress, - maxRetrieve uint16) (validators []types.Validator) { - validators = make([]types.Validator, maxRetrieve) +func (k Keeper) GetDelegatorValidators( + ctx sdk.Context, delegatorAddr sdk.AccAddress, maxRetrieve uint32, +) []types.Validator { + + validators := make([]types.Validator, maxRetrieve) store := ctx.KVStore(k.storeKey) delegatorPrefixKey := types.GetDelegationsKey(delegatorAddr) @@ -23,15 +25,18 @@ func (k Keeper) GetDelegatorValidators(ctx sdk.Context, delegatorAddr sdk.AccAdd if !found { panic(types.ErrNoValidatorFound) } + validators[i] = validator i++ } + return validators[:i] // trim } // return a validator that a delegator is bonded to -func (k Keeper) GetDelegatorValidator(ctx sdk.Context, delegatorAddr sdk.AccAddress, - validatorAddr sdk.ValAddress) (validator types.Validator, err error) { +func (k Keeper) GetDelegatorValidator( + ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, +) (validator types.Validator, err error) { delegation, found := k.GetDelegation(ctx, delegatorAddr, validatorAddr) if !found { @@ -42,7 +47,8 @@ func (k Keeper) GetDelegatorValidator(ctx sdk.Context, delegatorAddr sdk.AccAddr if !found { panic(types.ErrNoValidatorFound) } - return + + return validator, nil } //_____________________________________________________________________________________ @@ -85,9 +91,9 @@ func (k Keeper) GetAllUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAdd } // return all redelegations for a delegator -func (k Keeper) GetAllRedelegations(ctx sdk.Context, delegator sdk.AccAddress, - srcValAddress, dstValAddress sdk.ValAddress) ( - redelegations []types.Redelegation) { +func (k Keeper) GetAllRedelegations( + ctx sdk.Context, delegator sdk.AccAddress, srcValAddress, dstValAddress sdk.ValAddress, +) ([]types.Redelegation) { store := ctx.KVStore(k.storeKey) delegatorPrefixKey := types.GetREDsKey(delegator) @@ -97,6 +103,8 @@ func (k Keeper) GetAllRedelegations(ctx sdk.Context, delegator sdk.AccAddress, srcValFilter := !(srcValAddress.Empty()) dstValFilter := !(dstValAddress.Empty()) + redelegations := []types.Redelegation{} + for ; iterator.Valid(); iterator.Next() { redelegation := types.MustUnmarshalRED(k.cdc, iterator.Value()) if srcValFilter && !(srcValAddress.Equals(redelegation.ValidatorSrcAddress)) { @@ -105,7 +113,9 @@ func (k Keeper) GetAllRedelegations(ctx sdk.Context, delegator sdk.AccAddress, if dstValFilter && !(dstValAddress.Equals(redelegation.ValidatorDstAddress)) { continue } + redelegations = append(redelegations, redelegation) } + return redelegations } diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index 101bc139215a..c132100b8434 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -137,7 +137,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab oldPowerBytes, found := last[valAddrBytes] newPower := validator.ConsensusPower() - newPowerBytes := k.cdc.MustMarshalBinaryLengthPrefixed(newPower) + newPowerBytes := k.cdc.MustMarshalBinaryLengthPrefixed(&sdk.IntProto{Int: sdk.NewInt(newPower)}) // update the validator set if power has changed if !found || !bytes.Equal(oldPowerBytes, newPowerBytes) { @@ -240,7 +240,6 @@ func (k Keeper) unjailValidator(ctx sdk.Context, validator types.Validator) { // perform all the store operations for when a validator status becomes bonded func (k Keeper) bondValidator(ctx sdk.Context, validator types.Validator) types.Validator { - // delete the validator by power index, as the key will change k.DeleteValidatorByPowerIndex(ctx, validator) @@ -254,14 +253,13 @@ func (k Keeper) bondValidator(ctx sdk.Context, validator types.Validator) types. k.DeleteValidatorQueue(ctx, validator) // trigger hook - k.AfterValidatorBonded(ctx, validator.ConsAddress(), validator.OperatorAddress) + k.AfterValidatorBonded(ctx, validator.GetConsAddr(), validator.OperatorAddress) return validator } // perform all the store operations for when a validator begins unbonding func (k Keeper) beginUnbondingValidator(ctx sdk.Context, validator types.Validator) types.Validator { - params := k.GetParams(ctx) // delete the validator by power index, as the key will change @@ -275,7 +273,7 @@ func (k Keeper) beginUnbondingValidator(ctx sdk.Context, validator types.Validat validator = validator.UpdateStatus(sdk.Unbonding) // set the unbonding completion time and completion height appropriately - validator.UnbondingCompletionTime = ctx.BlockHeader().Time.Add(params.UnbondingTime) + validator.UnbondingTime = ctx.BlockHeader().Time.Add(params.UnbondingTime) validator.UnbondingHeight = ctx.BlockHeader().Height // save the now unbonded validator record and power index @@ -286,7 +284,7 @@ func (k Keeper) beginUnbondingValidator(ctx sdk.Context, validator types.Validat k.InsertValidatorQueue(ctx, validator) // trigger hook - k.AfterValidatorBeginUnbonding(ctx, validator.ConsAddress(), validator.OperatorAddress) + k.AfterValidatorBeginUnbonding(ctx, validator.GetConsAddr(), validator.OperatorAddress) return validator } diff --git a/x/staking/keeper/validator.go b/x/staking/keeper/validator.go index 48ecbb384313..71c78631b391 100644 --- a/x/staking/keeper/validator.go +++ b/x/staking/keeper/validator.go @@ -94,8 +94,7 @@ func (k Keeper) SetValidator(ctx sdk.Context, validator types.Validator) { // validator index func (k Keeper) SetValidatorByConsAddr(ctx sdk.Context, validator types.Validator) { store := ctx.KVStore(k.storeKey) - consAddr := sdk.ConsAddress(validator.ConsPubKey.Address()) - store.Set(types.GetValidatorByConsAddrKey(consAddr), validator.OperatorAddress) + store.Set(types.GetValidatorByConsAddrKey(validator.GetConsAddr()), validator.OperatorAddress) } // validator index @@ -191,14 +190,16 @@ func (k Keeper) RemoveValidator(ctx sdk.Context, address sdk.ValAddress) { panic("validator being removed should never have positive tokens") } + valConsAddr := validator.GetConsAddr() + // delete the old validator record store := ctx.KVStore(k.storeKey) store.Delete(types.GetValidatorKey(address)) - store.Delete(types.GetValidatorByConsAddrKey(sdk.ConsAddress(validator.ConsPubKey.Address()))) + store.Delete(types.GetValidatorByConsAddrKey(valConsAddr)) store.Delete(types.GetValidatorsByPowerIndexKey(validator)) // call hooks - k.AfterValidatorRemoved(ctx, validator.ConsAddress(), validator.OperatorAddress) + k.AfterValidatorRemoved(ctx, valConsAddr, validator.OperatorAddress) } // get groups of validators @@ -213,6 +214,7 @@ func (k Keeper) GetAllValidators(ctx sdk.Context) (validators []types.Validator) validator := types.MustUnmarshalValidator(k.cdc, iterator.Value()) validators = append(validators, validator) } + return validators } @@ -271,14 +273,16 @@ func (k Keeper) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) if bz == nil { return 0 } - k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &power) - return + + ip := sdk.IntProto{} + k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &ip) + return ip.Int.Int64() } // Set the last validator power. func (k Keeper) SetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress, power int64) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshalBinaryLengthPrefixed(power) + bz := k.cdc.MustMarshalBinaryLengthPrefixed(&sdk.IntProto{Int: sdk.NewInt(power)}) store.Set(types.GetLastValidatorPowerKey(operator), bz) } @@ -302,9 +306,10 @@ func (k Keeper) IterateLastValidatorPowers(ctx sdk.Context, handler func(operato defer iter.Close() for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(iter.Key()[len(types.LastValidatorPowerKey):]) - var power int64 - k.cdc.MustUnmarshalBinaryLengthPrefixed(iter.Value(), &power) - if handler(addr, power) { + ip := sdk.IntProto{} + + k.cdc.MustUnmarshalBinaryLengthPrefixed(iter.Value(), &ip) + if handler(addr, ip.Int.Int64()) { break } } @@ -342,20 +347,22 @@ func (k Keeper) GetLastValidators(ctx sdk.Context) (validators []types.Validator // gets a specific validator queue timeslice. A timeslice is a slice of ValAddresses corresponding to unbonding validators // that expire at a certain time. -func (k Keeper) GetValidatorQueueTimeSlice(ctx sdk.Context, timestamp time.Time) (valAddrs []sdk.ValAddress) { +func (k Keeper) GetValidatorQueueTimeSlice(ctx sdk.Context, timestamp time.Time) []sdk.ValAddress { store := ctx.KVStore(k.storeKey) bz := store.Get(types.GetValidatorQueueTimeKey(timestamp)) if bz == nil { return []sdk.ValAddress{} } - k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &valAddrs) - return valAddrs + + va := sdk.ValAddresses{} + k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &va) + return va.Addresses } // Sets a specific validator queue timeslice. func (k Keeper) SetValidatorQueueTimeSlice(ctx sdk.Context, timestamp time.Time, keys []sdk.ValAddress) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshalBinaryLengthPrefixed(keys) + bz := k.cdc.MustMarshalBinaryLengthPrefixed(&sdk.ValAddresses{Addresses: keys}) store.Set(types.GetValidatorQueueTimeKey(timestamp), bz) } @@ -367,24 +374,25 @@ func (k Keeper) DeleteValidatorQueueTimeSlice(ctx sdk.Context, timestamp time.Ti // Insert an validator address to the appropriate timeslice in the validator queue func (k Keeper) InsertValidatorQueue(ctx sdk.Context, val types.Validator) { - timeSlice := k.GetValidatorQueueTimeSlice(ctx, val.UnbondingCompletionTime) + timeSlice := k.GetValidatorQueueTimeSlice(ctx, val.UnbondingTime) timeSlice = append(timeSlice, val.OperatorAddress) - k.SetValidatorQueueTimeSlice(ctx, val.UnbondingCompletionTime, timeSlice) + k.SetValidatorQueueTimeSlice(ctx, val.UnbondingTime, timeSlice) } // Delete a validator address from the validator queue func (k Keeper) DeleteValidatorQueue(ctx sdk.Context, val types.Validator) { - timeSlice := k.GetValidatorQueueTimeSlice(ctx, val.UnbondingCompletionTime) + timeSlice := k.GetValidatorQueueTimeSlice(ctx, val.UnbondingTime) newTimeSlice := []sdk.ValAddress{} for _, addr := range timeSlice { if !bytes.Equal(addr, val.OperatorAddress) { newTimeSlice = append(newTimeSlice, addr) } } + if len(newTimeSlice) == 0 { - k.DeleteValidatorQueueTimeSlice(ctx, val.UnbondingCompletionTime) + k.DeleteValidatorQueueTimeSlice(ctx, val.UnbondingTime) } else { - k.SetValidatorQueueTimeSlice(ctx, val.UnbondingCompletionTime, newTimeSlice) + k.SetValidatorQueueTimeSlice(ctx, val.UnbondingTime, newTimeSlice) } } @@ -401,9 +409,10 @@ func (k Keeper) GetAllMatureValidatorQueue(ctx sdk.Context, currTime time.Time) defer validatorTimesliceIterator.Close() for ; validatorTimesliceIterator.Valid(); validatorTimesliceIterator.Next() { - timeslice := []sdk.ValAddress{} + timeslice := sdk.ValAddresses{} k.cdc.MustUnmarshalBinaryLengthPrefixed(validatorTimesliceIterator.Value(), ×lice) - matureValsAddrs = append(matureValsAddrs, timeslice...) + + matureValsAddrs = append(matureValsAddrs, timeslice.Addresses...) } return matureValsAddrs @@ -416,10 +425,10 @@ func (k Keeper) UnbondAllMatureValidatorQueue(ctx sdk.Context) { defer validatorTimesliceIterator.Close() for ; validatorTimesliceIterator.Valid(); validatorTimesliceIterator.Next() { - timeslice := []sdk.ValAddress{} + timeslice := sdk.ValAddresses{} k.cdc.MustUnmarshalBinaryLengthPrefixed(validatorTimesliceIterator.Value(), ×lice) - for _, valAddr := range timeslice { + for _, valAddr := range timeslice.Addresses { val, found := k.GetValidator(ctx, valAddr) if !found { panic("validator in the unbonding queue was not found") @@ -428,6 +437,7 @@ func (k Keeper) UnbondAllMatureValidatorQueue(ctx sdk.Context) { if !val.IsUnbonding() { panic("unexpected validator in unbonding queue; status was not unbonding") } + val = k.unbondingToUnbonded(ctx, val) if val.GetDelegatorShares().IsZero() { k.RemoveValidator(ctx, val.OperatorAddress) diff --git a/x/staking/types/expected_keepers.go b/x/staking/types/expected_keepers.go index c9e69b9018bb..331840468142 100644 --- a/x/staking/types/expected_keepers.go +++ b/x/staking/types/expected_keepers.go @@ -74,7 +74,7 @@ type ValidatorSet interface { Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingexported.DelegationI // MaxValidators returns the maximum amount of bonded validators - MaxValidators(sdk.Context) uint16 + MaxValidators(sdk.Context) uint32 } // DelegationSet expected properties for the set of all delegations for a particular (noalias) diff --git a/x/staking/types/types.pb.go b/x/staking/types/types.pb.go index d84de519e7e2..78da36fae466 100644 --- a/x/staking/types/types.pb.go +++ b/x/staking/types/types.pb.go @@ -591,9 +591,9 @@ func (m *Description) GetDetails() string { // coins. Slashing results in a decrease in the exchange rate, allowing correct // calculation of future undelegations without iterating over delegators. // When coins are delegated to this validator, the validator is credited with a -// delegation whose number of bond shares is based on the amount of coins delegated -// divided by the current exchange rate. Voting power can be calculated as total -// bonded shares multiplied by exchange rate. +// delegation whose number of bond shares is based on the amount of coins +// delegated divided by the current exchange rate. Voting power can be +// calculated as total bonded shares multiplied by exchange rate. type Validator struct { OperatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,1,opt,name=operator_address,json=operatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"operator_address,omitempty" yaml:"operator_address"` ConsensusPubkey string `protobuf:"bytes,2,opt,name=consensus_pubkey,json=consensusPubkey,proto3" json:"consensus_pubkey,omitempty" yaml:"consensus_pubkey"` @@ -694,6 +694,51 @@ func (m *DVPair) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAdd return nil } +// DVPairs defines an array of DVPair objects. +type DVPairs struct { + Pairs []DVPair `protobuf:"bytes,1,rep,name=pairs,proto3" json:"pairs"` +} + +func (m *DVPairs) Reset() { *m = DVPairs{} } +func (m *DVPairs) String() string { return proto.CompactTextString(m) } +func (*DVPairs) ProtoMessage() {} +func (*DVPairs) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{11} +} +func (m *DVPairs) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DVPairs) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DVPairs.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DVPairs) XXX_Merge(src proto.Message) { + xxx_messageInfo_DVPairs.Merge(m, src) +} +func (m *DVPairs) XXX_Size() int { + return m.Size() +} +func (m *DVPairs) XXX_DiscardUnknown() { + xxx_messageInfo_DVPairs.DiscardUnknown(m) +} + +var xxx_messageInfo_DVPairs proto.InternalMessageInfo + +func (m *DVPairs) GetPairs() []DVPair { + if m != nil { + return m.Pairs + } + return nil +} + // DVVTriplet is struct that just has a delegator-validator-validator triplet // with no other data. It is intended to be used as a marshalable pointer. For // example, a DVVTriplet can be used to construct the key to getting a @@ -707,7 +752,7 @@ type DVVTriplet struct { func (m *DVVTriplet) Reset() { *m = DVVTriplet{} } func (*DVVTriplet) ProtoMessage() {} func (*DVVTriplet) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{11} + return fileDescriptor_c669c0a3ee1b124c, []int{12} } func (m *DVVTriplet) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -757,6 +802,51 @@ func (m *DVVTriplet) GetValidatorDstAddress() github_com_cosmos_cosmos_sdk_types return nil } +// DVVTriplets defines an array of DVVTriplet objects. +type DVVTriplets struct { + Triplets []DVVTriplet `protobuf:"bytes,1,rep,name=triplets,proto3" json:"triplets"` +} + +func (m *DVVTriplets) Reset() { *m = DVVTriplets{} } +func (m *DVVTriplets) String() string { return proto.CompactTextString(m) } +func (*DVVTriplets) ProtoMessage() {} +func (*DVVTriplets) Descriptor() ([]byte, []int) { + return fileDescriptor_c669c0a3ee1b124c, []int{13} +} +func (m *DVVTriplets) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DVVTriplets) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DVVTriplets.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DVVTriplets) XXX_Merge(src proto.Message) { + xxx_messageInfo_DVVTriplets.Merge(m, src) +} +func (m *DVVTriplets) XXX_Size() int { + return m.Size() +} +func (m *DVVTriplets) XXX_DiscardUnknown() { + xxx_messageInfo_DVVTriplets.DiscardUnknown(m) +} + +var xxx_messageInfo_DVVTriplets proto.InternalMessageInfo + +func (m *DVVTriplets) GetTriplets() []DVVTriplet { + if m != nil { + return m.Triplets + } + return nil +} + // Delegation represents the bond with tokens held by an account. It is // owned by one delegator, and is associated with the voting power of one // validator. @@ -769,7 +859,7 @@ type Delegation struct { func (m *Delegation) Reset() { *m = Delegation{} } func (*Delegation) ProtoMessage() {} func (*Delegation) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{12} + return fileDescriptor_c669c0a3ee1b124c, []int{14} } func (m *Delegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -823,7 +913,7 @@ type UnbondingDelegation struct { func (m *UnbondingDelegation) Reset() { *m = UnbondingDelegation{} } func (*UnbondingDelegation) ProtoMessage() {} func (*UnbondingDelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{13} + return fileDescriptor_c669c0a3ee1b124c, []int{15} } func (m *UnbondingDelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -884,7 +974,7 @@ type UnbondingDelegationEntry struct { func (m *UnbondingDelegationEntry) Reset() { *m = UnbondingDelegationEntry{} } func (*UnbondingDelegationEntry) ProtoMessage() {} func (*UnbondingDelegationEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{14} + return fileDescriptor_c669c0a3ee1b124c, []int{16} } func (m *UnbondingDelegationEntry) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -938,7 +1028,7 @@ type RedelegationEntry struct { func (m *RedelegationEntry) Reset() { *m = RedelegationEntry{} } func (*RedelegationEntry) ProtoMessage() {} func (*RedelegationEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{15} + return fileDescriptor_c669c0a3ee1b124c, []int{17} } func (m *RedelegationEntry) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -993,7 +1083,7 @@ type Redelegation struct { func (m *Redelegation) Reset() { *m = Redelegation{} } func (*Redelegation) ProtoMessage() {} func (*Redelegation) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{16} + return fileDescriptor_c669c0a3ee1b124c, []int{18} } func (m *Redelegation) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1062,7 +1152,7 @@ type Params struct { func (m *Params) Reset() { *m = Params{} } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_c669c0a3ee1b124c, []int{17} + return fileDescriptor_c669c0a3ee1b124c, []int{19} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1138,7 +1228,9 @@ func init() { proto.RegisterType((*Description)(nil), "cosmos_sdk.x.staking.v1.Description") proto.RegisterType((*Validator)(nil), "cosmos_sdk.x.staking.v1.Validator") proto.RegisterType((*DVPair)(nil), "cosmos_sdk.x.staking.v1.DVPair") + proto.RegisterType((*DVPairs)(nil), "cosmos_sdk.x.staking.v1.DVPairs") proto.RegisterType((*DVVTriplet)(nil), "cosmos_sdk.x.staking.v1.DVVTriplet") + proto.RegisterType((*DVVTriplets)(nil), "cosmos_sdk.x.staking.v1.DVVTriplets") proto.RegisterType((*Delegation)(nil), "cosmos_sdk.x.staking.v1.Delegation") proto.RegisterType((*UnbondingDelegation)(nil), "cosmos_sdk.x.staking.v1.UnbondingDelegation") proto.RegisterType((*UnbondingDelegationEntry)(nil), "cosmos_sdk.x.staking.v1.UnbondingDelegationEntry") @@ -1150,110 +1242,112 @@ func init() { func init() { proto.RegisterFile("x/staking/types/types.proto", fileDescriptor_c669c0a3ee1b124c) } var fileDescriptor_c669c0a3ee1b124c = []byte{ - // 1633 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0xcd, 0x6f, 0xdb, 0x46, - 0x16, 0x37, 0x25, 0x45, 0xb6, 0x9f, 0x62, 0xc9, 0xa6, 0x11, 0x47, 0x71, 0x36, 0xa2, 0x97, 0xbb, - 0x08, 0x8c, 0xc5, 0x46, 0x82, 0x93, 0x05, 0x16, 0xf0, 0x5e, 0x12, 0x59, 0x31, 0xec, 0x85, 0xbd, - 0x48, 0xe8, 0xc4, 0x87, 0xfd, 0x80, 0x30, 0x22, 0xc7, 0xd4, 0xac, 0x45, 0x52, 0xcb, 0x19, 0x39, - 0xf2, 0x62, 0xaf, 0x0b, 0x14, 0x05, 0x8a, 0xe6, 0x52, 0x20, 0xc7, 0xa0, 0xff, 0x40, 0xaf, 0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0x5c, 0x47, 0x7a, 0xf4, 0x3a, 0x62, 0x6a, 0x2f, 0xb4, 0x8e, 0x1a, 0x65, 0x83, 0x59, - 0xcd, 0x8c, 0x9b, 0xd5, 0x8f, 0x52, 0x30, 0xb3, 0x4d, 0xcd, 0xbb, 0xb6, 0x71, 0x5a, 0x12, 0xc7, - 0x2e, 0x89, 0xf7, 0x24, 0xc8, 0x6f, 0x10, 0xca, 0x1c, 0x97, 0xe8, 0xa8, 0xb5, 0x69, 0xef, 0x39, - 0xf2, 0x5f, 0x20, 0xdb, 0xc4, 0xc8, 0xc0, 0xae, 0x18, 0x02, 0x97, 0xca, 0x11, 0x35, 0x2a, 0x7b, - 0xd4, 0xa8, 0xcc, 0x97, 0xb2, 0xe1, 0x2b, 0x05, 0x78, 0xdc, 0x44, 0xbe, 0x0e, 0xd9, 0x03, 0xd4, - 0xa2, 0x98, 0x15, 0x53, 0x4b, 0xe9, 0xe5, 0xdc, 0x55, 0x75, 0xe4, 0x04, 0x09, 0x47, 0x4f, 0x80, - 0xc0, 0xed, 0x56, 0x33, 0xdf, 0x3e, 0x54, 0x24, 0xf5, 0x83, 0x14, 0x14, 0x12, 0x44, 0x44, 0xae, - 0x42, 0xc6, 0xef, 0xeb, 0x92, 0xdf, 0x64, 0xcb, 0xc7, 0xe0, 0x19, 0x35, 0xac, 0x6b, 0xbe, 0xad, - 0xfc, 0x4f, 0x98, 0xb2, 0x50, 0x97, 0xcf, 0x87, 0x94, 0x8f, 0x73, 0xe3, 0x78, 0x38, 0xfd, 0x9e, - 0x52, 0x10, 0x0d, 0x5b, 0xe0, 0xa8, 0xda, 0xa4, 0x85, 0xba, 0xfe, 0x54, 0x68, 0x43, 0xc1, 0x93, - 0xea, 0x4d, 0x64, 0x9b, 0x38, 0x3e, 0x84, 0x36, 0x8e, 0xed, 0x64, 0x21, 0x72, 0x12, 0x83, 0x53, - 0xb5, 0x19, 0x0b, 0x75, 0xd7, 0x7c, 0x81, 0xe7, 0x71, 0x75, 0xea, 0xc1, 0x43, 0x65, 0xc2, 0x8f, - 0xd8, 0x67, 0x12, 0x40, 0x14, 0x31, 0xf9, 0x5f, 0x30, 0x9b, 0x18, 0x62, 0x54, 0xe4, 0x73, 0x7c, - 0xe6, 0x37, 0xe5, 0xad, 0xfa, 0x71, 0x4f, 0x91, 0xb4, 0x82, 0x9e, 0xc8, 0xc5, 0x3f, 0x20, 0xd7, - 0x69, 0x1b, 0x88, 0xe1, 0xba, 0x47, 0x82, 0x05, 0xa7, 0x5c, 0x2c, 0x73, 0x02, 0x5c, 0x0e, 0x08, - 0x70, 0xf9, 0x4e, 0xc0, 0x90, 0xab, 0x25, 0x0f, 0xab, 0xdf, 0x53, 0x64, 0xbe, 0xaf, 0x98, 0xb1, - 0x7a, 0xff, 0x6b, 0x45, 0xd2, 0x80, 0x4b, 0x3c, 0x83, 0xd8, 0xa6, 0x3e, 0x95, 0x20, 0x17, 0xa3, - 0x1a, 0x72, 0x11, 0x26, 0x2d, 0xc7, 0x26, 0xfb, 0xe2, 0x70, 0x4e, 0x6b, 0xc1, 0xa3, 0xbc, 0x08, - 0x53, 0xc4, 0xc0, 0x36, 0x23, 0xec, 0x90, 0x27, 0x56, 0x0b, 0x9f, 0x3d, 0xab, 0x7b, 0xb8, 0x41, - 0x49, 0x90, 0x0e, 0x2d, 0x78, 0x94, 0xd7, 0x61, 0x96, 0x62, 0xbd, 0xe3, 0x12, 0x76, 0x58, 0xd7, - 0x1d, 0x9b, 0x21, 0x9d, 0x89, 0x19, 0x7e, 0xb1, 0xdf, 0x53, 0xce, 0xf3, 0xb5, 0x26, 0x35, 0x54, - 0xad, 0x10, 0x88, 0xd6, 0xb8, 0xc4, 0xf3, 0x60, 0x60, 0x86, 0x48, 0x8b, 0xb3, 0xc1, 0x69, 0x2d, - 0x78, 0x8c, 0xed, 0xe5, 0x93, 0x49, 0x98, 0x8e, 0xf8, 0xd6, 0x3d, 0x98, 0x75, 0xda, 0xd8, 0x1d, - 0xd2, 0xa2, 0x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fd, 0xa0, 0x8e, 0xaa, 0xcd, 0x45, 0xc2, 0x00, 0xed, 0x4f, 0x00, - 0xde, 0xbe, 0xea, 0x06, 0xb6, 0x1d, 0x4b, 0x7c, 0x5a, 0x9e, 0xeb, 0xf7, 0x94, 0x39, 0x8e, 0x12, - 0xbd, 0x53, 0xb5, 0x69, 0xef, 0xa1, 0xe6, 0xfd, 0x1d, 0x05, 0xbe, 0xba, 0xfe, 0xe8, 0x49, 0x49, - 0x7a, 0xfc, 0xa4, 0x24, 0x7d, 0xf3, 0xa4, 0x24, 0xdd, 0x7f, 0x5a, 0x9a, 0x78, 0xfc, 0xb4, 0x34, - 0xf1, 0xe5, 0xd3, 0xd2, 0xc4, 0xdf, 0xff, 0xf8, 0xcc, 0xc3, 0x92, 0xf8, 0x45, 0xb3, 0x91, 0xf5, - 0xb3, 0x72, 0xed, 0xe7, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd8, 0xec, 0x27, 0x1d, 0xeb, 0x1c, 0x00, - 0x00, + // 1678 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x59, 0xcd, 0x6f, 0x23, 0x49, + 0x15, 0x4f, 0xdb, 0x8e, 0x9d, 0x3c, 0x4f, 0xec, 0xa4, 0xa3, 0xc9, 0x78, 0xb2, 0xac, 0x3b, 0xf4, + 0xa2, 0x55, 0x84, 0x58, 0x5b, 0xd9, 0x45, 0x42, 0xca, 0x5e, 0x76, 0x1c, 0x27, 0x4a, 0x50, 0x82, + 0x66, 0x3b, 0xb3, 0x39, 0xf0, 0x21, 0xab, 0xdc, 0x5d, 0x69, 0x17, 0x71, 0x77, 0x9b, 0xae, 0x72, + 0xd6, 0x41, 0x5c, 0x91, 0x10, 0x12, 0x62, 0x2f, 0x48, 0x73, 0x1c, 0xf1, 0x0f, 0x70, 0x45, 0x70, + 0xe1, 0x38, 0xdc, 0x46, 0x20, 0x21, 0xc4, 0x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b, 0x2e, 0x33, 0xe8, 0x46, 0x29, 0xa4, 0xc8, 0xa6, 0x6d, 0xf3, 0xc7, 0xad, 0x20, 0x67, 0x02, + 0xae, 0x19, 0x27, 0x6e, 0x5d, 0x76, 0xed, 0xf8, 0x49, 0x2b, 0x09, 0x20, 0xda, 0x76, 0x29, 0xa6, + 0xf2, 0xbe, 0xfd, 0x03, 0x28, 0x13, 0x97, 0x30, 0x82, 0xba, 0xad, 0x36, 0xea, 0x22, 0xd7, 0xbc, + 0xce, 0x05, 0x46, 0x34, 0x5a, 0xa9, 0x36, 0x05, 0xa7, 0x1b, 0x25, 0x49, 0x69, 0x08, 0x82, 0xba, + 0x0f, 0x85, 0x50, 0x55, 0xee, 0x5a, 0x53, 0x5e, 0x28, 0x9e, 0xf0, 0xc8, 0xcf, 0xb2, 0xb0, 0x12, + 0x3d, 0xf0, 0xdc, 0xb8, 0x62, 0x56, 0x57, 0x1c, 0x01, 0x88, 0x4a, 0x12, 0xf4, 0x92, 0x6b, 0x78, + 0x23, 0xa8, 0x45, 0x8b, 0x02, 0xa1, 0x49, 0x59, 0xc2, 0x1f, 0xff, 0xcc, 0xc2, 0xad, 0xa4, 0x3f, + 0x6e, 0x9a, 0xfc, 0x1b, 0xf4, 0xe4, 0xf6, 0xcd, 0xb8, 0x36, 0xe6, 0x78, 0x6d, 0xfc, 0xea, 0xd4, + 0xda, 0x38, 0x96, 0x53, 0xd3, 0x8b, 0xe2, 0xbf, 0x33, 0x90, 0xbf, 0x8f, 0x7c, 0xe4, 0x50, 0xd5, + 0x1c, 0xbb, 0x72, 0x88, 0x87, 0x88, 0xbb, 0x63, 0x19, 0xd3, 0x94, 0x7f, 0x2f, 0x7b, 0xc1, 0x8d, + 0xe3, 0xe1, 0x84, 0x1b, 0xc7, 0x27, 0x50, 0x72, 0xd0, 0xa0, 0x15, 0x1d, 0x50, 0x78, 0x73, 0xa9, + 0x71, 0x37, 0x46, 0xb9, 0xfc, 0x5d, 0x3c, 0xa5, 0x44, 0x17, 0x72, 0xaa, 0x7e, 0x03, 0x8a, 0x01, + 0x47, 0xdc, 0x27, 0x02, 0xf1, 0xb5, 0xf8, 0xc9, 0x22, 0xf1, 0x51, 0x37, 0xc0, 0x41, 0x83, 0x5d, + 0xb1, 0x50, 0x0f, 0x41, 0xed, 0x44, 0x4f, 0x68, 0xad, 0xd8, 0x96, 0x81, 0xfc, 0xbb, 0xa3, 0xa1, + 0x76, 0x57, 0xc8, 0x8f, 0xf3, 0xe8, 0xc6, 0x4a, 0x4c, 0x0c, 0xd1, 0xbe, 0x0e, 0x10, 0x9c, 0xab, + 0x65, 0x61, 0xd7, 0x73, 0xe4, 0xc5, 0xf7, 0xf6, 0x68, 0xa8, 0xad, 0x08, 0x94, 0xf8, 0x9b, 0x6e, + 0x2c, 0x06, 0x8b, 0x66, 0xf0, 0x3b, 0x36, 0x7c, 0x63, 0xef, 0xf1, 0xd3, 0xaa, 0xf2, 0xe4, 0x69, + 0x55, 0xf9, 0xdb, 0xd3, 0xaa, 0xf2, 0xc5, 0xb3, 0xea, 0xdc, 0x93, 0x67, 0xd5, 0xb9, 0x3f, 0x3f, + 0xab, 0xce, 0x7d, 0xfb, 0x6b, 0xcf, 0x0d, 0x96, 0xd4, 0xdf, 0x5b, 0xdb, 0x79, 0xee, 0x95, 0x8f, + 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x62, 0xe9, 0xa4, 0xfa, 0x89, 0x1d, 0x00, 0x00, } func (this *HistoricalInfo) Equal(that interface{}) bool { @@ -2344,6 +2438,43 @@ func (m *DVPair) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *DVPairs) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DVPairs) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DVPairs) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Pairs) > 0 { + for iNdEx := len(m.Pairs) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Pairs[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *DVVTriplet) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2388,6 +2519,43 @@ func (m *DVVTriplet) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *DVVTriplets) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DVVTriplets) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DVVTriplets) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Triplets) > 0 { + for iNdEx := len(m.Triplets) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Triplets[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *Delegation) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2962,6 +3130,21 @@ func (m *DVPair) Size() (n int) { return n } +func (m *DVPairs) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Pairs) > 0 { + for _, e := range m.Pairs { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + func (m *DVVTriplet) Size() (n int) { if m == nil { return 0 @@ -2983,6 +3166,21 @@ func (m *DVVTriplet) Size() (n int) { return n } +func (m *DVVTriplets) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Triplets) > 0 { + for _, e := range m.Triplets { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + func (m *Delegation) Size() (n int) { if m == nil { return 0 @@ -5198,6 +5396,93 @@ func (m *DVPair) Unmarshal(dAtA []byte) error { } return nil } +func (m *DVPairs) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DVPairs: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DVPairs: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pairs", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Pairs = append(m.Pairs, DVPair{}) + if err := m.Pairs[len(m.Pairs)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *DVVTriplet) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -5353,6 +5638,93 @@ func (m *DVVTriplet) Unmarshal(dAtA []byte) error { } return nil } +func (m *DVVTriplets) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DVVTriplets: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DVVTriplets: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Triplets", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Triplets = append(m.Triplets, DVVTriplet{}) + if err := m.Triplets[len(m.Triplets)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *Delegation) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/staking/types/types.proto b/x/staking/types/types.proto index a1f063eec6f0..e2b064310ec8 100644 --- a/x/staking/types/types.proto +++ b/x/staking/types/types.proto @@ -161,9 +161,9 @@ message Description { // coins. Slashing results in a decrease in the exchange rate, allowing correct // calculation of future undelegations without iterating over delegators. // When coins are delegated to this validator, the validator is credited with a -// delegation whose number of bond shares is based on the amount of coins delegated -// divided by the current exchange rate. Voting power can be calculated as total -// bonded shares multiplied by exchange rate. +// delegation whose number of bond shares is based on the amount of coins +// delegated divided by the current exchange rate. Voting power can be +// calculated as total bonded shares multiplied by exchange rate. message Validator { option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; @@ -176,9 +176,8 @@ message Validator { string consensus_pubkey = 2 [ (gogoproto.moretags) = "yaml:\"consensus_pubkey\"" ]; bool jailed = 3; - int32 status = 4 [ - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.BondStatus" - ]; + int32 status = 4 [ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.BondStatus" ]; string tokens = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false @@ -221,6 +220,9 @@ message DVPair { ]; } +// DVPairs defines an array of DVPair objects. +message DVPairs { repeated DVPair pairs = 1 [ (gogoproto.nullable) = false ]; } + // DVVTriplet is struct that just has a delegator-validator-validator triplet // with no other data. It is intended to be used as a marshalable pointer. For // example, a DVVTriplet can be used to construct the key to getting a @@ -243,6 +245,11 @@ message DVVTriplet { ]; } +// DVVTriplets defines an array of DVVTriplet objects. +message DVVTriplets { + repeated DVVTriplet triplets = 1 [ (gogoproto.nullable) = false ]; +} + // Delegation represents the bond with tokens held by an account. It is // owned by one delegator, and is associated with the voting power of one // validator. From 7503396a8a37ffb1a5457e9b45ff1f4b991a9923 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 16:33:02 -0500 Subject: [PATCH 09/27] Fix staking keeper tests --- codec/amino.go | 4 ++-- codec/codec.go | 4 ++++ x/staking/keeper/delegation_test.go | 16 +++++++------- x/staking/keeper/historical_info_test.go | 7 +++--- x/staking/keeper/test_common.go | 8 ++++--- x/staking/keeper/validator.go | 3 ++- x/staking/keeper/validator_test.go | 27 ++++++++++++------------ x/staking/simulation/genesis.go | 8 +++---- x/staking/types/validator.go | 12 +++++++++++ 9 files changed, 53 insertions(+), 36 deletions(-) diff --git a/codec/amino.go b/codec/amino.go index 3393ba4da717..c0936e70460b 100644 --- a/codec/amino.go +++ b/codec/amino.go @@ -45,7 +45,7 @@ func RegisterEvidences(cdc *Codec) { // MarshalJSONIndent provides a utility for indented JSON encoding of an object // via an Amino codec. It returns an error if it cannot serialize or indent as // JSON. -func MarshalJSONIndent(m Marshaler, obj interface{}) ([]byte, error) { +func MarshalJSONIndent(m JSONMarshaler, obj interface{}) ([]byte, error) { bz, err := m.MarshalJSON(obj) if err != nil { return nil, err @@ -60,7 +60,7 @@ func MarshalJSONIndent(m Marshaler, obj interface{}) ([]byte, error) { } // MustMarshalJSONIndent executes MarshalJSONIndent except it panics upon failure. -func MustMarshalJSONIndent(m Marshaler, obj interface{}) []byte { +func MustMarshalJSONIndent(m JSONMarshaler, obj interface{}) []byte { bz, err := MarshalJSONIndent(m, obj) if err != nil { panic(fmt.Sprintf("failed to marshal JSON: %s", err)) diff --git a/codec/codec.go b/codec/codec.go index 203a1ec1bbb6..323d2607c851 100644 --- a/codec/codec.go +++ b/codec/codec.go @@ -30,6 +30,10 @@ type ( UnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) error MustUnmarshalBinaryLengthPrefixed(bz []byte, ptr ProtoMarshaler) + JSONMarshaler + } + + JSONMarshaler interface { MarshalJSON(o interface{}) ([]byte, error) // nolint: stdmethods MustMarshalJSON(o interface{}) []byte diff --git a/x/staking/keeper/delegation_test.go b/x/staking/keeper/delegation_test.go index f2832dd498d2..eda1a550cd67 100644 --- a/x/staking/keeper/delegation_test.go +++ b/x/staking/keeper/delegation_test.go @@ -233,7 +233,7 @@ func TestUnbondingDelegationsMaxEntries(t *testing.T) { // should all pass var completionTime time.Time - for i := uint16(0); i < maxEntries; i++ { + for i := uint32(0); i < maxEntries; i++ { var err error completionTime, err = keeper.Undelegate(ctx, addrDels[0], addrVals[0], sdk.NewDec(1)) require.NoError(t, err) @@ -414,7 +414,7 @@ func TestUndelegateFromUnbondingValidator(t *testing.T) { require.True(t, found) require.Equal(t, blockHeight, validator.UnbondingHeight) params := keeper.GetParams(ctx) - require.True(t, blockTime.Add(params.UnbondingTime).Equal(validator.UnbondingCompletionTime)) + require.True(t, blockTime.Add(params.UnbondingTime).Equal(validator.UnbondingTime)) blockHeight2 := int64(20) blockTime2 := time.Unix(444, 0).UTC() @@ -489,10 +489,10 @@ func TestUndelegateFromUnbondedValidator(t *testing.T) { require.True(t, found) require.Equal(t, ctx.BlockHeight(), validator.UnbondingHeight) params := keeper.GetParams(ctx) - require.True(t, ctx.BlockHeader().Time.Add(params.UnbondingTime).Equal(validator.UnbondingCompletionTime)) + require.True(t, ctx.BlockHeader().Time.Add(params.UnbondingTime).Equal(validator.UnbondingTime)) // unbond the validator - ctx = ctx.WithBlockTime(validator.UnbondingCompletionTime) + ctx = ctx.WithBlockTime(validator.UnbondingTime) keeper.UnbondAllMatureValidatorQueue(ctx) // Make sure validator is still in state because there is still an outstanding delegation @@ -579,7 +579,7 @@ func TestUnbondingAllDelegationFromValidator(t *testing.T) { require.Equal(t, validator.Status, sdk.Unbonding) // unbond the validator - ctx = ctx.WithBlockTime(validator.UnbondingCompletionTime) + ctx = ctx.WithBlockTime(validator.UnbondingTime) keeper.UnbondAllMatureValidatorQueue(ctx) // validator should now be deleted from state @@ -733,7 +733,7 @@ func TestRedelegationMaxEntries(t *testing.T) { // redelegations should pass var completionTime time.Time - for i := uint16(0); i < maxEntries; i++ { + for i := uint32(0); i < maxEntries; i++ { var err error completionTime, err = keeper.BeginRedelegation(ctx, val0AccAddr, addrVals[0], addrVals[1], sdk.NewDec(1)) require.NoError(t, err) @@ -863,7 +863,7 @@ func TestRedelegateFromUnbondingValidator(t *testing.T) { require.True(t, found) require.Equal(t, blockHeight, validator.UnbondingHeight) params := keeper.GetParams(ctx) - require.True(t, blockTime.Add(params.UnbondingTime).Equal(validator.UnbondingCompletionTime)) + require.True(t, blockTime.Add(params.UnbondingTime).Equal(validator.UnbondingTime)) //change the context header = ctx.BlockHeader() @@ -940,7 +940,7 @@ func TestRedelegateFromUnbondedValidator(t *testing.T) { require.True(t, found) require.Equal(t, ctx.BlockHeight(), validator.UnbondingHeight) params := keeper.GetParams(ctx) - require.True(t, ctx.BlockHeader().Time.Add(params.UnbondingTime).Equal(validator.UnbondingCompletionTime)) + require.True(t, ctx.BlockHeader().Time.Add(params.UnbondingTime).Equal(validator.UnbondingTime)) // unbond the validator keeper.unbondingToUnbonded(ctx, validator) diff --git a/x/staking/keeper/historical_info_test.go b/x/staking/keeper/historical_info_test.go index 574d0c9dd9af..db372bce2cae 100644 --- a/x/staking/keeper/historical_info_test.go +++ b/x/staking/keeper/historical_info_test.go @@ -4,12 +4,11 @@ import ( "sort" "testing" - abci "github.com/tendermint/tendermint/abci/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" ) func TestHistoricalInfo(t *testing.T) { @@ -27,7 +26,7 @@ func TestHistoricalInfo(t *testing.T) { recv, found := keeper.GetHistoricalInfo(ctx, 2) require.True(t, found, "HistoricalInfo not found after set") require.Equal(t, hi, recv, "HistoricalInfo not equal") - require.True(t, sort.IsSorted(types.Validators(recv.ValSet)), "HistoricalInfo validators is not sorted") + require.True(t, sort.IsSorted(types.Validators(recv.Valset)), "HistoricalInfo validators is not sorted") keeper.DeleteHistoricalInfo(ctx, 2) @@ -91,7 +90,7 @@ func TestTrackHistoricalInfo(t *testing.T) { // Check HistoricalInfo at height 10 is persisted expected := types.HistoricalInfo{ Header: header, - ValSet: vals, + Valset: vals, } recv, found = k.GetHistoricalInfo(ctx, 10) require.True(t, found, "GetHistoricalInfo failed after BeginBlock") diff --git a/x/staking/keeper/test_common.go b/x/staking/keeper/test_common.go index 65efabe4e25c..d24365084221 100644 --- a/x/staking/keeper/test_common.go +++ b/x/staking/keeper/test_common.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" @@ -50,7 +49,7 @@ var ( // intended to be used with require/assert: require.True(ValEq(...)) func ValEq(t *testing.T, exp, got types.Validator) (*testing.T, bool, string, types.Validator, types.Validator) { - return t, exp.TestEquivalent(got), "expected:\t%v\ngot:\t\t%v", exp, got + return t, exp.MinEqual(got), "expected:\n%v\ngot:\n%v", exp, got } //_______________________________________________________________________________________ @@ -147,7 +146,7 @@ func CreateTestInput(t *testing.T, isCheckTx bool, initPower int64) (sdk.Context supplyKeeper.SetSupply(ctx, supply.NewSupply(totalSupply)) - keeper := NewKeeper(cdc, keyStaking, bk, supplyKeeper, pk.Subspace(DefaultParamspace)) + keeper := NewKeeper(types.ModuleCdc, keyStaking, bk, supplyKeeper, pk.Subspace(DefaultParamspace)) keeper.SetParams(ctx, types.DefaultParams()) // set module accounts @@ -273,12 +272,15 @@ func TestingUpdateValidator(keeper Keeper, ctx sdk.Context, validator types.Vali } return validator } + cachectx, _ := ctx.CacheContext() keeper.ApplyAndReturnValidatorSetUpdates(cachectx) + validator, found := keeper.GetValidator(cachectx, validator.OperatorAddress) if !found { panic("validator expected but not found") } + return validator } diff --git a/x/staking/keeper/validator.go b/x/staking/keeper/validator.go index 71c78631b391..a09d72ea8d0f 100644 --- a/x/staking/keeper/validator.go +++ b/x/staking/keeper/validator.go @@ -219,7 +219,7 @@ func (k Keeper) GetAllValidators(ctx sdk.Context) (validators []types.Validator) } // return a given amount of all the validators -func (k Keeper) GetValidators(ctx sdk.Context, maxRetrieve uint16) (validators []types.Validator) { +func (k Keeper) GetValidators(ctx sdk.Context, maxRetrieve uint32) (validators []types.Validator) { store := ctx.KVStore(k.storeKey) validators = make([]types.Validator, maxRetrieve) @@ -232,6 +232,7 @@ func (k Keeper) GetValidators(ctx sdk.Context, maxRetrieve uint16) (validators [ validators[i] = validator i++ } + return validators[:i] // trim if the array length < maxRetrieve } diff --git a/x/staking/keeper/validator_test.go b/x/staking/keeper/validator_test.go index ae2552fe8373..1b4d8f6a5ac8 100644 --- a/x/staking/keeper/validator_test.go +++ b/x/staking/keeper/validator_test.go @@ -5,13 +5,12 @@ import ( "testing" "time" - abci "github.com/tendermint/tendermint/abci/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + abci "github.com/tendermint/tendermint/abci/types" ) //_______________________________________________________ @@ -117,7 +116,7 @@ func TestUpdateBondedValidatorsDecreaseCliff(t *testing.T) { // create keeper parameters params := keeper.GetParams(ctx) - params.MaxValidators = uint16(maxVals) + params.MaxValidators = uint32(maxVals) keeper.SetParams(ctx, params) // create a random pool @@ -437,7 +436,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) { // set max validators to 2 params := keeper.GetParams(ctx) - nMax := uint16(2) + nMax := uint32(2) params.MaxValidators = nMax keeper.SetParams(ctx, params) @@ -461,7 +460,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) { // ensure that the first two bonded validators are the largest validators resValidators := keeper.GetBondedValidatorsByPower(ctx) - require.Equal(t, nMax, uint16(len(resValidators))) + require.Equal(t, nMax, uint32(len(resValidators))) assert.True(ValEq(t, validators[2], resValidators[0])) assert.True(ValEq(t, validators[3], resValidators[1])) @@ -481,7 +480,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) { // b) validator 2 with 400 tokens (delegated before validator 3) validators[0] = TestingUpdateValidator(keeper, ctx, validators[0], true) resValidators = keeper.GetBondedValidatorsByPower(ctx) - require.Equal(t, nMax, uint16(len(resValidators))) + require.Equal(t, nMax, uint32(len(resValidators))) assert.True(ValEq(t, validators[0], resValidators[0])) assert.True(ValEq(t, validators[2], resValidators[1])) @@ -509,7 +508,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) { validators[3] = TestingUpdateValidator(keeper, ctx, validators[3], true) resValidators = keeper.GetBondedValidatorsByPower(ctx) - require.Equal(t, nMax, uint16(len(resValidators))) + require.Equal(t, nMax, uint32(len(resValidators))) assert.True(ValEq(t, validators[0], resValidators[0])) assert.True(ValEq(t, validators[3], resValidators[1])) @@ -525,7 +524,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) { validators[3] = TestingUpdateValidator(keeper, ctx, validators[3], true) resValidators = keeper.GetBondedValidatorsByPower(ctx) - require.Equal(t, nMax, uint16(len(resValidators))) + require.Equal(t, nMax, uint32(len(resValidators))) assert.True(ValEq(t, validators[0], resValidators[0])) assert.True(ValEq(t, validators[2], resValidators[1])) @@ -540,7 +539,7 @@ func TestGetValidatorsEdgeCases(t *testing.T) { validators[3] = TestingUpdateValidator(keeper, ctx, validators[3], true) resValidators = keeper.GetBondedValidatorsByPower(ctx) - require.Equal(t, nMax, uint16(len(resValidators))) + require.Equal(t, nMax, uint32(len(resValidators))) assert.True(ValEq(t, validators[0], resValidators[0])) assert.True(ValEq(t, validators[2], resValidators[1])) _, exists := keeper.GetValidator(ctx, validators[3].OperatorAddress) @@ -577,7 +576,7 @@ func TestValidatorBondHeight(t *testing.T) { validators[2] = TestingUpdateValidator(keeper, ctx, validators[2], true) resValidators := keeper.GetBondedValidatorsByPower(ctx) - require.Equal(t, uint16(len(resValidators)), params.MaxValidators) + require.Equal(t, uint32(len(resValidators)), params.MaxValidators) assert.True(ValEq(t, validators[0], resValidators[0])) assert.True(ValEq(t, validators[1], resValidators[1])) @@ -588,7 +587,7 @@ func TestValidatorBondHeight(t *testing.T) { validators[2], _ = validators[2].AddTokensFromDel(delTokens) validators[2] = TestingUpdateValidator(keeper, ctx, validators[2], true) resValidators = keeper.GetBondedValidatorsByPower(ctx) - require.Equal(t, params.MaxValidators, uint16(len(resValidators))) + require.Equal(t, params.MaxValidators, uint32(len(resValidators))) validators[1] = TestingUpdateValidator(keeper, ctx, validators[1], true) assert.True(ValEq(t, validators[0], resValidators[0])) assert.True(ValEq(t, validators[2], resValidators[1])) @@ -598,7 +597,7 @@ func TestFullValidatorSetPowerChange(t *testing.T) { ctx, _, _, keeper, _ := CreateTestInput(t, false, 1000) params := keeper.GetParams(ctx) max := 2 - params.MaxValidators = uint16(2) + params.MaxValidators = uint32(2) keeper.SetParams(ctx, params) // initialize some validators into the state @@ -881,7 +880,7 @@ func TestApplyAndReturnValidatorSetUpdatesPowerDecrease(t *testing.T) { func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) { ctx, _, _, keeper, _ := CreateTestInput(t, false, 1000) params := keeper.GetParams(ctx) - params.MaxValidators = uint16(3) + params.MaxValidators = uint32(3) keeper.SetParams(ctx, params) @@ -962,7 +961,7 @@ func TestApplyAndReturnValidatorSetUpdatesNewValidator(t *testing.T) { func TestApplyAndReturnValidatorSetUpdatesBondTransition(t *testing.T) { ctx, _, _, keeper, _ := CreateTestInput(t, false, 1000) params := keeper.GetParams(ctx) - params.MaxValidators = uint16(2) + params.MaxValidators = uint32(2) keeper.SetParams(ctx, params) diff --git a/x/staking/simulation/genesis.go b/x/staking/simulation/genesis.go index cca02bee8cc9..1ce83be9ef18 100644 --- a/x/staking/simulation/genesis.go +++ b/x/staking/simulation/genesis.go @@ -27,8 +27,8 @@ func GenUnbondingTime(r *rand.Rand) (ubdTime time.Duration) { } // GenMaxValidators randomized MaxValidators -func GenMaxValidators(r *rand.Rand) (maxValidators uint16) { - return uint16(r.Intn(250) + 1) +func GenMaxValidators(r *rand.Rand) (maxValidators uint32) { + return uint32(r.Intn(250) + 1) } // RandomizedGenState generates a random GenesisState for staking @@ -40,7 +40,7 @@ func RandomizedGenState(simState *module.SimulationState) { func(r *rand.Rand) { unbondTime = GenUnbondingTime(r) }, ) - var maxValidators uint16 + var maxValidators uint32 simState.AppParams.GetOrGenerate( simState.Cdc, MaxValidators, &maxValidators, simState.Rand, func(r *rand.Rand) { maxValidators = GenMaxValidators(r) }, @@ -82,6 +82,6 @@ func RandomizedGenState(simState *module.SimulationState) { stakingGenesis := types.NewGenesisState(params, validators, delegations) - fmt.Printf("Selected randomly generated staking parameters:\n%s\n", codec.MustMarshalJSONIndent(simState.Cdc, stakingGenesis.Params)) + fmt.Printf("Selected randomly generated staking parameters:\n%s\n", codec.MustMarshalJSONIndent(types.ModuleCdc, stakingGenesis.Params)) simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(stakingGenesis) } diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index d2b4a0a3b41c..2304596ae2b9 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -376,6 +376,18 @@ func (v Validator) RemoveDelShares(delShares sdk.Dec) (Validator, sdk.Int) { return v, issuedTokens } +// MinEqual defines a more minimum set of equality conditions when comparing two +// validators. +func (v Validator) MinEqual(other Validator) bool { + return v.ConsensusPubkey == other.ConsensusPubkey && + bytes.Equal(v.OperatorAddress, other.OperatorAddress) && + v.Status.Equal(other.Status) && + v.Tokens.Equal(other.Tokens) && + v.DelegatorShares.Equal(other.DelegatorShares) && + v.Description == other.Description && + v.Commission.Equal(other.Commission) +} + // nolint - for ValidatorI func (v Validator) IsJailed() bool { return v.Jailed } func (v Validator) GetMoniker() string { return v.Description.Moniker } From 97ac0b5827b7012cb5f60bdc2e95ebcb3a4d7dee Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 16:39:44 -0500 Subject: [PATCH 10/27] Update query client --- x/staking/client/cli/query.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/x/staking/client/cli/query.go b/x/staking/client/cli/query.go index 14a60c49bc04..a38c004fde42 100644 --- a/x/staking/client/cli/query.go +++ b/x/staking/client/cli/query.go @@ -77,7 +77,12 @@ $ %s query staking validator cosmosvaloper1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhff return fmt.Errorf("no validator found with address %s", addr) } - return cliCtx.PrintOutput(types.MustUnmarshalValidator(cdc, res)) + validator, err := types.UnmarshalValidator(types.ModuleCdc, res) + if err != nil { + return err + } + + return cliCtx.PrintOutput(validator) }, } } @@ -107,7 +112,12 @@ $ %s query staking validators var validators types.Validators for _, kv := range resKVs { - validators = append(validators, types.MustUnmarshalValidator(cdc, kv.Value)) + validator, err := types.UnmarshalValidator(types.ModuleCdc, kv.Value) + if err != nil { + return err + } + + validators = append(validators, validator) } return cliCtx.PrintOutput(validators) @@ -380,7 +390,12 @@ $ %s query staking unbonding-delegation cosmos1gghjut3ccd8ay0zduzj64hwre2fxs9ld7 return err } - return cliCtx.PrintOutput(types.MustUnmarshalUBD(cdc, res)) + ubd, err := types.UnmarshalUBD(types.ModuleCdc, res) + if err != nil { + return err + } + + return cliCtx.PrintOutput(ubd) }, } } From 8e84801e6f2861191b4fd5f7cc756f2d3410b5c7 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 16:51:29 -0500 Subject: [PATCH 11/27] Update staking genesis and app_test --- x/staking/app_test.go | 2 +- x/staking/genesis.go | 9 ++++++--- x/staking/genesis_test.go | 10 ++++++++-- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/x/staking/app_test.go b/x/staking/app_test.go index 586b5d95d757..28bd943edce0 100644 --- a/x/staking/app_test.go +++ b/x/staking/app_test.go @@ -42,7 +42,7 @@ func getMockApp(t *testing.T) (*mock.App, Keeper) { types.BondedPoolName: {supply.Burner, supply.Staking}, } supplyKeeper := supply.NewKeeper(mApp.Cdc, keySupply, mApp.AccountKeeper, mApp.BankKeeper, maccPerms) - keeper := NewKeeper(mApp.Cdc, keyStaking, mApp.BankKeeper, supplyKeeper, mApp.ParamsKeeper.Subspace(DefaultParamspace)) + keeper := NewKeeper(ModuleCdc, keyStaking, mApp.BankKeeper, supplyKeeper, mApp.ParamsKeeper.Subspace(DefaultParamspace)) mApp.Router().AddRoute(RouterKey, NewHandler(keeper)) mApp.SetEndBlocker(getEndBlocker(keeper)) diff --git a/x/staking/genesis.go b/x/staking/genesis.go index 5c558ca4259b..8a2ecce10740 100644 --- a/x/staking/genesis.go +++ b/x/staking/genesis.go @@ -210,17 +210,20 @@ func validateGenesisStateValidators(validators []types.Validator) (err error) { addrMap := make(map[string]bool, len(validators)) for i := 0; i < len(validators); i++ { val := validators[i] - strKey := string(val.ConsPubKey.Bytes()) + strKey := string(val.GetConsPubKey().Bytes()) + if _, ok := addrMap[strKey]; ok { - return fmt.Errorf("duplicate validator in genesis state: moniker %v, address %v", val.Description.Moniker, val.ConsAddress()) + return fmt.Errorf("duplicate validator in genesis state: moniker %v, address %v", val.Description.Moniker, val.GetConsAddr()) } if val.Jailed && val.IsBonded() { - return fmt.Errorf("validator is bonded and jailed in genesis state: moniker %v, address %v", val.Description.Moniker, val.ConsAddress()) + return fmt.Errorf("validator is bonded and jailed in genesis state: moniker %v, address %v", val.Description.Moniker, val.GetConsAddr()) } if val.DelegatorShares.IsZero() && !val.IsUnbonding() { return fmt.Errorf("bonded/unbonded genesis validator cannot have zero delegator shares, validator: %v", val) } + addrMap[strKey] = true } + return } diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index 4f3a7f1d05bf..551239185fca 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -25,15 +25,21 @@ func TestInitGenesis(t *testing.T) { validators := make([]Validator, 2) var delegations []Delegation + pk0, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, keep.PKs[0]) + require.NoError(t, err) + + pk1, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, keep.PKs[1]) + require.NoError(t, err) + // initialize the validators validators[0].OperatorAddress = sdk.ValAddress(keep.Addrs[0]) - validators[0].ConsPubKey = keep.PKs[0] + validators[0].ConsensusPubkey = pk0 validators[0].Description = NewDescription("hoop", "", "", "", "") validators[0].Status = sdk.Bonded validators[0].Tokens = valTokens validators[0].DelegatorShares = valTokens.ToDec() validators[1].OperatorAddress = sdk.ValAddress(keep.Addrs[1]) - validators[1].ConsPubKey = keep.PKs[1] + validators[1].ConsensusPubkey = pk1 validators[1].Description = NewDescription("bloop", "", "", "", "") validators[1].Status = sdk.Bonded validators[1].Tokens = valTokens From c35939adaf1ad5ea2456e17005aea1e7791fb58b Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 22:10:40 -0500 Subject: [PATCH 12/27] Update staking handler --- x/staking/handler.go | 31 +++++++++++++---- x/staking/handler_test.go | 71 ++++++++++++++++++++++++++++----------- 2 files changed, 75 insertions(+), 27 deletions(-) diff --git a/x/staking/handler.go b/x/staking/handler.go index 180bb8008672..e6ed8e3b57c3 100644 --- a/x/staking/handler.go +++ b/x/staking/handler.go @@ -3,6 +3,7 @@ package staking import ( "time" + gogotypes "github.com/gogo/protobuf/types" tmstrings "github.com/tendermint/tendermint/libs/strings" tmtypes "github.com/tendermint/tendermint/types" @@ -47,7 +48,12 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k return nil, ErrValidatorOwnerExists } - if _, found := k.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(msg.PubKey)); found { + pk, err := sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeConsPub, msg.Pubkey) + if err != nil { + return nil, err + } + + if _, found := k.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(pk)); found { return nil, ErrValidatorPubKeyExists } @@ -60,21 +66,22 @@ func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k k } if ctx.ConsensusParams() != nil { - tmPubKey := tmtypes.TM2PB.PubKey(msg.PubKey) + tmPubKey := tmtypes.TM2PB.PubKey(pk) if !tmstrings.StringInSlice(tmPubKey.Type, ctx.ConsensusParams().Validator.PubKeyTypes) { return nil, sdkerrors.Wrapf( ErrValidatorPubKeyTypeNotSupported, - "got: %s, valid: %s", tmPubKey.Type, ctx.ConsensusParams().Validator.PubKeyTypes, + "got: %s, expected: %s", tmPubKey.Type, ctx.ConsensusParams().Validator.PubKeyTypes, ) } } - validator := NewValidator(msg.ValidatorAddress, msg.PubKey, msg.Description) + validator := NewValidator(msg.ValidatorAddress, pk, msg.Description) commission := NewCommissionWithTime( msg.Commission.Rate, msg.Commission.MaxRate, msg.Commission.MaxChangeRate, ctx.BlockHeader().Time, ) - validator, err := validator.SetInitialCommission(commission) + + validator, err = validator.SetInitialCommission(commission) if err != nil { return nil, err } @@ -217,7 +224,12 @@ func handleMsgUndelegate(ctx sdk.Context, msg types.MsgUndelegate, k keeper.Keep return nil, err } - completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(completionTime) + ts, err := gogotypes.TimestampProto(completionTime) + if err != nil { + return nil, ErrBadRedelegationAddr + } + + completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(ts) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeUnbond, @@ -254,7 +266,12 @@ func handleMsgBeginRedelegate(ctx sdk.Context, msg types.MsgBeginRedelegate, k k return nil, err } - completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(completionTime) + ts, err := gogotypes.TimestampProto(completionTime) + if err != nil { + return nil, ErrBadRedelegationAddr + } + + completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(ts) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeRedelegate, diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index 75e9242e07c7..64a5d579f99d 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -5,9 +5,9 @@ import ( "testing" "time" + gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto/secp256k1" tmtypes "github.com/tendermint/tendermint/types" @@ -90,8 +90,11 @@ func TestValidatorByPowerIndex(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) - var finishTime time.Time - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, &finishTime) + ts := &gogotypes.Timestamp{} + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + + finishTime, err := gogotypes.TimestampFromProto(ts) + require.NoError(t, err) ctx = ctx.WithBlockTime(finishTime) EndBlocker(ctx, keeper) @@ -121,7 +124,7 @@ func TestDuplicatesMsgCreateValidator(t *testing.T) { require.True(t, found) assert.Equal(t, sdk.Bonded, validator.Status) assert.Equal(t, addr1, validator.OperatorAddress) - assert.Equal(t, pk1, validator.ConsPubKey) + assert.Equal(t, pk1, validator.GetConsPubKey()) assert.Equal(t, valTokens, validator.BondedTokens()) assert.Equal(t, valTokens.ToDec(), validator.DelegatorShares) assert.Equal(t, Description{}, validator.Description) @@ -153,7 +156,7 @@ func TestDuplicatesMsgCreateValidator(t *testing.T) { require.True(t, found) assert.Equal(t, sdk.Bonded, validator.Status) assert.Equal(t, addr2, validator.OperatorAddress) - assert.Equal(t, pk2, validator.ConsPubKey) + assert.Equal(t, pk2, validator.GetConsPubKey()) assert.True(sdk.IntEq(t, valTokens, validator.Tokens)) assert.True(sdk.DecEq(t, valTokens.ToDec(), validator.DelegatorShares)) assert.Equal(t, Description{}, validator.Description) @@ -225,8 +228,12 @@ func TestLegacyValidatorDelegations(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) - var finishTime time.Time - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, &finishTime) + ts := &gogotypes.Timestamp{} + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + + finishTime, err := gogotypes.TimestampFromProto(ts) + require.NoError(t, err) + ctx = ctx.WithBlockTime(finishTime) EndBlocker(ctx, keeper) @@ -459,8 +466,11 @@ func TestIncrementsMsgUnbond(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) - var finishTime time.Time - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, &finishTime) + ts := &gogotypes.Timestamp{} + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + + finishTime, err := gogotypes.TimestampFromProto(ts) + require.NoError(t, err) ctx = ctx.WithBlockTime(finishTime) EndBlocker(ctx, keeper) @@ -572,8 +582,11 @@ func TestMultipleMsgCreateValidator(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) - var finishTime time.Time - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, &finishTime) + ts := &gogotypes.Timestamp{} + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + + _, err = gogotypes.TimestampFromProto(ts) + require.NoError(t, err) // adds validator into unbonding queue EndBlocker(ctx, keeper) @@ -626,8 +639,11 @@ func TestMultipleMsgDelegate(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) - var finishTime time.Time - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, &finishTime) + ts := &gogotypes.Timestamp{} + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + + finishTime, err := gogotypes.TimestampFromProto(ts) + require.NoError(t, err) ctx = ctx.WithBlockTime(finishTime) EndBlocker(ctx, keeper) @@ -661,8 +677,11 @@ func TestJailValidator(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) - var finishTime time.Time - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, &finishTime) + ts := &gogotypes.Timestamp{} + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + + finishTime, err := gogotypes.TimestampFromProto(ts) + require.NoError(t, err) ctx = ctx.WithBlockTime(finishTime) EndBlocker(ctx, keeper) @@ -677,7 +696,12 @@ func TestJailValidator(t *testing.T) { res, err = handleMsgUndelegate(ctx, msgUndelegateDelegator, keeper) require.NoError(t, err) require.NotNil(t, res) - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, &finishTime) + + ts = &gogotypes.Timestamp{} + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + + finishTime, err = gogotypes.TimestampFromProto(ts) + require.NoError(t, err) ctx = ctx.WithBlockTime(finishTime) EndBlocker(ctx, keeper) @@ -720,8 +744,11 @@ func TestValidatorQueue(t *testing.T) { require.NoError(t, err) require.NotNil(t, res) - var finishTime time.Time - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, &finishTime) + ts := &gogotypes.Timestamp{} + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + + finishTime, err := gogotypes.TimestampFromProto(ts) + require.NoError(t, err) ctx = ctx.WithBlockTime(finishTime) EndBlocker(ctx, keeper) @@ -821,8 +848,12 @@ func TestUnbondingFromUnbondingValidator(t *testing.T) { require.NotNil(t, res) // change the ctx to Block Time one second before the validator would have unbonded - var finishTime time.Time - types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, &finishTime) + ts := &gogotypes.Timestamp{} + types.ModuleCdc.MustUnmarshalBinaryLengthPrefixed(res.Data, ts) + + finishTime, err := gogotypes.TimestampFromProto(ts) + require.NoError(t, err) + ctx = ctx.WithBlockTime(finishTime.Add(time.Second * -1)) // unbond the delegator from the validator From febaae81dfd8f5325d6a211cbdce78c39e2e83fa Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 22:11:05 -0500 Subject: [PATCH 13/27] Use Int64Value instead of IntProto --- x/staking/keeper/val_state_change.go | 3 ++- x/staking/keeper/validator.go | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/x/staking/keeper/val_state_change.go b/x/staking/keeper/val_state_change.go index c132100b8434..e05182e92876 100644 --- a/x/staking/keeper/val_state_change.go +++ b/x/staking/keeper/val_state_change.go @@ -5,6 +5,7 @@ import ( "fmt" "sort" + gogotypes "github.com/gogo/protobuf/types" abci "github.com/tendermint/tendermint/abci/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -137,7 +138,7 @@ func (k Keeper) ApplyAndReturnValidatorSetUpdates(ctx sdk.Context) (updates []ab oldPowerBytes, found := last[valAddrBytes] newPower := validator.ConsensusPower() - newPowerBytes := k.cdc.MustMarshalBinaryLengthPrefixed(&sdk.IntProto{Int: sdk.NewInt(newPower)}) + newPowerBytes := k.cdc.MustMarshalBinaryLengthPrefixed(&gogotypes.Int64Value{Value: newPower}) // update the validator set if power has changed if !found || !bytes.Equal(oldPowerBytes, newPowerBytes) { diff --git a/x/staking/keeper/validator.go b/x/staking/keeper/validator.go index a09d72ea8d0f..56db3181c096 100644 --- a/x/staking/keeper/validator.go +++ b/x/staking/keeper/validator.go @@ -5,6 +5,8 @@ import ( "fmt" "time" + gogotypes "github.com/gogo/protobuf/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -275,15 +277,15 @@ func (k Keeper) GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) return 0 } - ip := sdk.IntProto{} - k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &ip) - return ip.Int.Int64() + intV := gogotypes.Int64Value{} + k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &intV) + return intV.GetValue() } // Set the last validator power. func (k Keeper) SetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress, power int64) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshalBinaryLengthPrefixed(&sdk.IntProto{Int: sdk.NewInt(power)}) + bz := k.cdc.MustMarshalBinaryLengthPrefixed(&gogotypes.Int64Value{Value: power}) store.Set(types.GetLastValidatorPowerKey(operator), bz) } From 5b83d9bf3c1634245dac8ff436d257b8f30109fd Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 22:28:09 -0500 Subject: [PATCH 14/27] Updates tests and APIs --- simapp/app.go | 2 +- x/distribution/keeper/test_common.go | 2 +- x/distribution/types/expected_keepers.go | 2 +- x/gov/keeper/tally_test.go | 2 +- x/gov/keeper/test_common.go | 2 +- x/gov/test_common.go | 2 +- x/slashing/app_test.go | 4 ++-- x/slashing/internal/keeper/test_common.go | 2 +- x/slashing/internal/types/expected_keepers.go | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index e3a589adb877..7dc5a8b5de87 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -180,7 +180,7 @@ func NewSimApp( app.cdc, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms, ) stakingKeeper := staking.NewKeeper( - app.cdc, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName], + staking.ModuleCdc, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName], ) app.MintKeeper = mint.NewKeeper( app.cdc, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper, diff --git a/x/distribution/keeper/test_common.go b/x/distribution/keeper/test_common.go index e049c3bbc57a..2fe0e22b36ab 100644 --- a/x/distribution/keeper/test_common.go +++ b/x/distribution/keeper/test_common.go @@ -139,7 +139,7 @@ func CreateTestInputAdvanced( } supplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bankKeeper, maccPerms) - sk := staking.NewKeeper(cdc, keyStaking, bankKeeper, supplyKeeper, pk.Subspace(staking.DefaultParamspace)) + sk := staking.NewKeeper(staking.ModuleCdc, keyStaking, bankKeeper, supplyKeeper, pk.Subspace(staking.DefaultParamspace)) sk.SetParams(ctx, staking.DefaultParams()) keeper := NewKeeper(cdc, keyDistr, pk.Subspace(types.DefaultParamspace), bankKeeper, sk, supplyKeeper, auth.FeeCollectorName, blacklistedAddrs) diff --git a/x/distribution/types/expected_keepers.go b/x/distribution/types/expected_keepers.go index 1f9d0a51a348..d7c909bacec0 100644 --- a/x/distribution/types/expected_keepers.go +++ b/x/distribution/types/expected_keepers.go @@ -49,7 +49,7 @@ type StakingKeeper interface { Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingexported.DelegationI // MaxValidators returns the maximum amount of bonded validators - MaxValidators(sdk.Context) uint16 + MaxValidators(sdk.Context) uint32 IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation stakingexported.DelegationI) (stop bool)) diff --git a/x/gov/keeper/tally_test.go b/x/gov/keeper/tally_test.go index 52812793c951..e93f6b387e6b 100644 --- a/x/gov/keeper/tally_test.go +++ b/x/gov/keeper/tally_test.go @@ -375,7 +375,7 @@ func TestTallyJailedValidator(t *testing.T) { _ = staking.EndBlocker(ctx, sk) - sk.Jail(ctx, sdk.ConsAddress(val2.ConsPubKey.Address())) + sk.Jail(ctx, sdk.ConsAddress(val2.GetConsPubKey().Address())) tp := TestProposal proposal, err := keeper.SubmitProposal(ctx, tp) diff --git a/x/gov/keeper/test_common.go b/x/gov/keeper/test_common.go index 897ad8b05da5..bb57f7ab0275 100644 --- a/x/gov/keeper/test_common.go +++ b/x/gov/keeper/test_common.go @@ -151,7 +151,7 @@ func createTestInput( bankKeeper := bank.NewBaseKeeper(cdc, keyBank, accountKeeper, pk.Subspace(bank.DefaultParamspace), blacklistedAddrs) supplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bankKeeper, maccPerms) - sk := staking.NewKeeper(cdc, keyStaking, bankKeeper, supplyKeeper, pk.Subspace(staking.DefaultParamspace)) + sk := staking.NewKeeper(staking.ModuleCdc, keyStaking, bankKeeper, supplyKeeper, pk.Subspace(staking.DefaultParamspace)) sk.SetParams(ctx, staking.DefaultParams()) rtr := types.NewRouter(). diff --git a/x/gov/test_common.go b/x/gov/test_common.go index c6fe5d7fcbba..a01a79c6566d 100644 --- a/x/gov/test_common.go +++ b/x/gov/test_common.go @@ -81,7 +81,7 @@ func getMockApp( bk := mApp.BankKeeper supplyKeeper := supply.NewKeeper(mApp.Cdc, keySupply, mApp.AccountKeeper, bk, maccPerms) sk := staking.NewKeeper( - mApp.Cdc, keyStaking, bk, supplyKeeper, pk.Subspace(staking.DefaultParamspace), + staking.ModuleCdc, keyStaking, bk, supplyKeeper, pk.Subspace(staking.DefaultParamspace), ) keeper := keep.NewKeeper( diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index 88ae3bb0b75a..b62d5dcb1385 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -55,7 +55,7 @@ func getMockApp(t *testing.T) (*mock.App, staking.Keeper, Keeper) { staking.BondedPoolName: {supply.Burner, supply.Staking}, } supplyKeeper := supply.NewKeeper(mapp.Cdc, keySupply, mapp.AccountKeeper, mapp.BankKeeper, maccPerms) - stakingKeeper := staking.NewKeeper(mapp.Cdc, keyStaking, mapp.BankKeeper, supplyKeeper, mapp.ParamsKeeper.Subspace(staking.DefaultParamspace)) + stakingKeeper := staking.NewKeeper(staking.ModuleCdc, keyStaking, mapp.BankKeeper, supplyKeeper, mapp.ParamsKeeper.Subspace(staking.DefaultParamspace)) keeper := NewKeeper(mapp.Cdc, keySlashing, stakingKeeper, mapp.ParamsKeeper.Subspace(DefaultParamspace)) mapp.Router().AddRoute(staking.RouterKey, staking.NewHandler(stakingKeeper)) mapp.Router().AddRoute(RouterKey, NewHandler(keeper)) @@ -158,7 +158,7 @@ func TestSlashingMsgs(t *testing.T) { require.Equal(t, sdk.ValAddress(addr1), validator.OperatorAddress) require.Equal(t, sdk.Bonded, validator.Status) require.True(sdk.IntEq(t, bondTokens, validator.BondedTokens())) - unjailMsg := MsgUnjail{ValidatorAddr: sdk.ValAddress(validator.ConsPubKey.Address())} + unjailMsg := MsgUnjail{ValidatorAddr: sdk.ValAddress(validator.GetConsPubKey().Address())} // no signing info yet checkValidatorSigningInfo(t, mapp, keeper, sdk.ConsAddress(addr1), false) diff --git a/x/slashing/internal/keeper/test_common.go b/x/slashing/internal/keeper/test_common.go index 79a436b2e1df..128c7438a7f9 100644 --- a/x/slashing/internal/keeper/test_common.go +++ b/x/slashing/internal/keeper/test_common.go @@ -104,7 +104,7 @@ func CreateTestInput(t *testing.T, defaults types.Params) (sdk.Context, bank.Kee totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, InitTokens.MulRaw(int64(len(Addrs))))) supplyKeeper.SetSupply(ctx, supply.NewSupply(totalSupply)) - sk := staking.NewKeeper(cdc, keyStaking, bk, supplyKeeper, paramsKeeper.Subspace(staking.DefaultParamspace)) + sk := staking.NewKeeper(staking.ModuleCdc, keyStaking, bk, supplyKeeper, paramsKeeper.Subspace(staking.DefaultParamspace)) genesis := staking.DefaultGenesisState() // set module accounts diff --git a/x/slashing/internal/types/expected_keepers.go b/x/slashing/internal/types/expected_keepers.go index bf09731a03e6..fe5695eebbf2 100644 --- a/x/slashing/internal/types/expected_keepers.go +++ b/x/slashing/internal/types/expected_keepers.go @@ -51,7 +51,7 @@ type StakingKeeper interface { Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) stakingexported.DelegationI // MaxValidators returns the maximum amount of bonded validators - MaxValidators(sdk.Context) uint16 + MaxValidators(sdk.Context) uint32 } // StakingHooks event hooks for staking validator object (noalias) From 0a904f15db0ecf930e88416ca80e1fb5871dfe99 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Mon, 3 Feb 2020 22:35:51 -0500 Subject: [PATCH 15/27] Fix iteration --- x/staking/keeper/validator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/staking/keeper/validator.go b/x/staking/keeper/validator.go index 56db3181c096..efc0ff517e9d 100644 --- a/x/staking/keeper/validator.go +++ b/x/staking/keeper/validator.go @@ -309,10 +309,10 @@ func (k Keeper) IterateLastValidatorPowers(ctx sdk.Context, handler func(operato defer iter.Close() for ; iter.Valid(); iter.Next() { addr := sdk.ValAddress(iter.Key()[len(types.LastValidatorPowerKey):]) - ip := sdk.IntProto{} + intV := &gogotypes.Int64Value{} - k.cdc.MustUnmarshalBinaryLengthPrefixed(iter.Value(), &ip) - if handler(addr, ip.Int.Int64()) { + k.cdc.MustUnmarshalBinaryLengthPrefixed(iter.Value(), intV) + if handler(addr, intV.GetValue()) { break } } From 245040983eecdebf57ec6966bf511bf6c7a28b97 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 4 Feb 2020 11:00:31 -0500 Subject: [PATCH 16/27] Linting --- x/staking/keeper/delegation.go | 8 +++++--- x/staking/keeper/query_utils.go | 2 +- x/staking/types/delegation.go | 5 +---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 375fad90313b..00d108079dfa 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -194,9 +194,10 @@ func (k Keeper) RemoveUnbondingDelegation(ctx sdk.Context, ubd types.UnbondingDe // SetUnbondingDelegationEntry adds an entry to the unbonding delegation at // the given addresses. It creates the unbonding delegation if it does not exist -func (k Keeper) SetUnbondingDelegationEntry(ctx sdk.Context, - delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, - creationHeight int64, minTime time.Time, balance sdk.Int) types.UnbondingDelegation { +func (k Keeper) SetUnbondingDelegationEntry( + ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, + creationHeight int64, minTime time.Time, balance sdk.Int, +) types.UnbondingDelegation { ubd, found := k.GetUnbondingDelegation(ctx, delegatorAddr, validatorAddr) if found { @@ -204,6 +205,7 @@ func (k Keeper) SetUnbondingDelegationEntry(ctx sdk.Context, } else { ubd = types.NewUnbondingDelegation(delegatorAddr, validatorAddr, creationHeight, minTime, balance) } + k.SetUnbondingDelegation(ctx, ubd) return ubd } diff --git a/x/staking/keeper/query_utils.go b/x/staking/keeper/query_utils.go index ae7cf634600a..e29e73c899ef 100644 --- a/x/staking/keeper/query_utils.go +++ b/x/staking/keeper/query_utils.go @@ -93,7 +93,7 @@ func (k Keeper) GetAllUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAdd // return all redelegations for a delegator func (k Keeper) GetAllRedelegations( ctx sdk.Context, delegator sdk.AccAddress, srcValAddress, dstValAddress sdk.ValAddress, -) ([]types.Redelegation) { +) []types.Redelegation { store := ctx.KVStore(k.storeKey) delegatorPrefixKey := types.GetREDsKey(delegator) diff --git a/x/staking/types/delegation.go b/x/staking/types/delegation.go index bdb3193ebe9c..f3d7289242ec 100644 --- a/x/staking/types/delegation.go +++ b/x/staking/types/delegation.go @@ -206,10 +206,7 @@ func NewRedelegation( } // AddEntry - append entry to the unbonding delegation -func (d *Redelegation) AddEntry(creationHeight int64, - minTime time.Time, balance sdk.Int, - sharesDst sdk.Dec) { - +func (d *Redelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int, sharesDst sdk.Dec) { entry := NewRedelegationEntry(creationHeight, minTime, balance, sharesDst) d.Entries = append(d.Entries, entry) } From 97148e220075ee014118f1ad2653d3a0b5f9ffcc Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 4 Feb 2020 12:03:16 -0500 Subject: [PATCH 17/27] Fix linting --- .golangci.yml | 3 +++ x/staking/keeper/delegation.go | 5 +++-- x/staking/types/commission.go | 14 ++++++------- x/staking/types/delegation.go | 36 +++++++++++++++++----------------- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9d790040dbcc..203c19b32648 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -47,6 +47,9 @@ issues: - text: "ST1003:" linters: - stylecheck + - text: "ST1016:" + linters: + - stylecheck linters-settings: dogsled: diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 00d108079dfa..9524c4feffa8 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -120,8 +120,9 @@ func (k Keeper) GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddres } // return a unbonding delegation -func (k Keeper) GetUnbondingDelegation(ctx sdk.Context, - delAddr sdk.AccAddress, valAddr sdk.ValAddress) (ubd types.UnbondingDelegation, found bool) { +func (k Keeper) GetUnbondingDelegation( + ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, +) (ubd types.UnbondingDelegation, found bool) { store := ctx.KVStore(k.storeKey) key := types.GetUBDKey(delAddr, valAddr) diff --git a/x/staking/types/commission.go b/x/staking/types/commission.go index 270670a744b5..9a58210f612e 100644 --- a/x/staking/types/commission.go +++ b/x/staking/types/commission.go @@ -47,29 +47,29 @@ func (cr CommissionRates) String() string { // Validate performs basic sanity validation checks of initial commission // parameters. If validation fails, an SDK error is returned. -func (c CommissionRates) Validate() error { +func (cr CommissionRates) Validate() error { switch { - case c.MaxRate.IsNegative(): + case cr.MaxRate.IsNegative(): // max rate cannot be negative return ErrCommissionNegative - case c.MaxRate.GT(sdk.OneDec()): + case cr.MaxRate.GT(sdk.OneDec()): // max rate cannot be greater than 1 return ErrCommissionHuge - case c.Rate.IsNegative(): + case cr.Rate.IsNegative(): // rate cannot be negative return ErrCommissionNegative - case c.Rate.GT(c.MaxRate): + case cr.Rate.GT(cr.MaxRate): // rate cannot be greater than the max rate return ErrCommissionGTMaxRate - case c.MaxChangeRate.IsNegative(): + case cr.MaxChangeRate.IsNegative(): // change rate cannot be negative return ErrCommissionChangeRateNegative - case c.MaxChangeRate.GT(c.MaxRate): + case cr.MaxChangeRate.GT(cr.MaxRate): // change rate cannot be greater than the max rate return ErrCommissionChangeRateGTMaxRate } diff --git a/x/staking/types/delegation.go b/x/staking/types/delegation.go index f3d7289242ec..f25aaac7b22a 100644 --- a/x/staking/types/delegation.go +++ b/x/staking/types/delegation.go @@ -88,8 +88,8 @@ func NewUnbondingDelegationEntry(creationHeight int64, completionTime time.Time, } // String implements the stringer interface for a UnbondingDelegationEntry. -func (ubd UnbondingDelegationEntry) String() string { - out, _ := yaml.Marshal(ubd) +func (e UnbondingDelegationEntry) String() string { + out, _ := yaml.Marshal(e) return string(out) } @@ -114,14 +114,14 @@ func NewUnbondingDelegation( } // AddEntry - append entry to the unbonding delegation -func (d *UnbondingDelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int) { +func (ubd *UnbondingDelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int) { entry := NewUnbondingDelegationEntry(creationHeight, minTime, balance) - d.Entries = append(d.Entries, entry) + ubd.Entries = append(ubd.Entries, entry) } // RemoveEntry - remove entry at index i to the unbonding delegation -func (d *UnbondingDelegation) RemoveEntry(i int64) { - d.Entries = append(d.Entries[:i], d.Entries[i+1:]...) +func (ubd *UnbondingDelegation) RemoveEntry(i int64) { + ubd.Entries = append(ubd.Entries[:i], ubd.Entries[i+1:]...) } // return the unbonding delegation @@ -145,12 +145,12 @@ func UnmarshalUBD(cdc codec.Marshaler, value []byte) (ubd UnbondingDelegation, e } // String returns a human readable string representation of an UnbondingDelegation. -func (d UnbondingDelegation) String() string { +func (ubd UnbondingDelegation) String() string { out := fmt.Sprintf(`Unbonding Delegations between: Delegator: %s Validator: %s - Entries:`, d.DelegatorAddress, d.ValidatorAddress) - for i, entry := range d.Entries { + Entries:`, ubd.DelegatorAddress, ubd.ValidatorAddress) + for i, entry := range ubd.Entries { out += fmt.Sprintf(` Unbonding Delegation %d: Creation Height: %v Min time to unbond (unix): %v @@ -180,8 +180,8 @@ func NewRedelegationEntry(creationHeight int64, completionTime time.Time, balanc } // String implements the Stringer interface for a RedelegationEntry object. -func (red RedelegationEntry) String() string { - out, _ := yaml.Marshal(red) +func (e RedelegationEntry) String() string { + out, _ := yaml.Marshal(e) return string(out) } @@ -206,14 +206,14 @@ func NewRedelegation( } // AddEntry - append entry to the unbonding delegation -func (d *Redelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int, sharesDst sdk.Dec) { +func (red *Redelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int, sharesDst sdk.Dec) { entry := NewRedelegationEntry(creationHeight, minTime, balance, sharesDst) - d.Entries = append(d.Entries, entry) + red.Entries = append(red.Entries, entry) } // RemoveEntry - remove entry at index i to the unbonding delegation -func (d *Redelegation) RemoveEntry(i int64) { - d.Entries = append(d.Entries[:i], d.Entries[i+1:]...) +func (red *Redelegation) RemoveEntry(i int64) { + red.Entries = append(red.Entries[:i], red.Entries[i+1:]...) } // MustMarshalRED returns the Redelegation bytes. Panics if fails. @@ -237,17 +237,17 @@ func UnmarshalRED(cdc codec.Marshaler, value []byte) (red Redelegation, err erro } // String returns a human readable string representation of a Redelegation. -func (d Redelegation) String() string { +func (red Redelegation) String() string { out := fmt.Sprintf(`Redelegations between: Delegator: %s Source Validator: %s Destination Validator: %s Entries: `, - d.DelegatorAddress, d.ValidatorSrcAddress, d.ValidatorDstAddress, + red.DelegatorAddress, red.ValidatorSrcAddress, red.ValidatorDstAddress, ) - for i, entry := range d.Entries { + for i, entry := range red.Entries { out += fmt.Sprintf(` Redelegation Entry #%d: Creation height: %v Min time to unbond (unix): %v From 11a0d8b90e3aa54da140216757e8e9b1b5f819f7 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 4 Feb 2020 13:58:39 -0500 Subject: [PATCH 18/27] Add changelog entry --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc45a176b45d..89ce5c7afa04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,13 @@ balances or a single balance by denom when the `denom` query parameter is presen * Callers to `NewBaseVestingAccount` are responsible for verifying account balance in relation to the original vesting amount. * The `SendKeeper` and `ViewKeeper` interfaces in `x/bank` have been modified to account for changes. +* (staking) [\#5600](https://github.com/cosmos/cosmos-sdk/pull/5600) Migrate the `x/staking` module to use Protocol Buffer for state +serialization instead of Amino. + * `BondStatus` is now of type `int32` instead of `byte`. + * Types of `int16` in the `Params` type are now of type `int32`. + * Every reference of `crypto.Pubkey` in context of a `Validator` is now of type string. `GetPubKeyFromBech32` must be used to get the `crypto.Pubkey`. + * The `Keeper` constructor now takes a `codec.Marshaler` instead of a concrete Amino codec. This exact type + provided is specified by `ModuleCdc`. ### Improvements From db45cfcf1b623354825ff313945d8e94ff057927 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 4 Feb 2020 13:59:55 -0500 Subject: [PATCH 19/27] Update changelog entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89ce5c7afa04..4241c20905a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,7 +60,8 @@ balances or a single balance by denom when the `denom` query parameter is presen the original vesting amount. * The `SendKeeper` and `ViewKeeper` interfaces in `x/bank` have been modified to account for changes. * (staking) [\#5600](https://github.com/cosmos/cosmos-sdk/pull/5600) Migrate the `x/staking` module to use Protocol Buffer for state -serialization instead of Amino. +serialization instead of Amino. The exact codec used is `codec.HybridCodec` which utilizes Protobuf for binary encoding and Amino +for JSON encoding. * `BondStatus` is now of type `int32` instead of `byte`. * Types of `int16` in the `Params` type are now of type `int32`. * Every reference of `crypto.Pubkey` in context of a `Validator` is now of type string. `GetPubKeyFromBech32` must be used to get the `crypto.Pubkey`. From d31577c659c92db66cceb4338fc055566d5f9685 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 5 Feb 2020 14:01:44 -0500 Subject: [PATCH 20/27] Start boilerplate for app-level codec --- simapp/app.go | 16 ++++------------ simapp/codec.go | 40 ++++++++++++++++++++++++++++++++++++++++ x/staking/alias.go | 2 ++ 3 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 simapp/codec.go diff --git a/simapp/app.go b/simapp/app.go index 7dc5a8b5de87..721c1ff6bd80 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -16,7 +16,6 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" - "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/bank" "github.com/cosmos/cosmos-sdk/x/crisis" distr "github.com/cosmos/cosmos-sdk/x/distribution" @@ -79,16 +78,6 @@ var ( } ) -// MakeCodec - custom tx codec -func MakeCodec() *codec.Codec { - var cdc = codec.New() - ModuleBasics.RegisterCodec(cdc) - vesting.RegisterCodec(cdc) - sdk.RegisterCodec(cdc) - codec.RegisterCrypto(cdc) - return cdc -} - // Verify app interface at compile time var _ App = (*SimApp)(nil) @@ -135,6 +124,9 @@ func NewSimApp( invCheckPeriod uint, baseAppOptions ...func(*bam.BaseApp), ) *SimApp { + appCodec := NewAppCodec() + + // TODO: Remove cdc in favor of appCodec once all modules are migrated. cdc := MakeCodec() bApp := bam.NewBaseApp(appName, logger, db, auth.DefaultTxDecoder(cdc), baseAppOptions...) @@ -180,7 +172,7 @@ func NewSimApp( app.cdc, keys[supply.StoreKey], app.AccountKeeper, app.BankKeeper, maccPerms, ) stakingKeeper := staking.NewKeeper( - staking.ModuleCdc, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName], + appCodec.Staking, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName], ) app.MintKeeper = mint.NewKeeper( app.cdc, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper, diff --git a/simapp/codec.go b/simapp/codec.go new file mode 100644 index 000000000000..8f87e7e324b1 --- /dev/null +++ b/simapp/codec.go @@ -0,0 +1,40 @@ +package simapp + +import ( + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/vesting" + "github.com/cosmos/cosmos-sdk/x/staking" +) + +// AppCodec defines the application-level codec. This codec contains all the +// required module-specific codecs that are to be provided upon initialization. +type AppCodec struct { + amino *codec.Codec + + Staking *staking.Codec +} + +func NewAppCodec() *AppCodec { + amino := MakeCodec() + + return &AppCodec{ + amino: amino, + Staking: staking.NewCodec(amino), + } +} + +// MakeCodec creates and returns a reference to an Amino codec that has all the +// necessary types and interfaces registered. This codec is provided to all the +// modules the application depends on. +// +// NOTE: This codec will be deprecated in favor of AppCodec once all modules are +// migrated. +func MakeCodec() *codec.Codec { + var cdc = codec.New() + ModuleBasics.RegisterCodec(cdc) + vesting.RegisterCodec(cdc) + sdk.RegisterCodec(cdc) + codec.RegisterCrypto(cdc) + return cdc +} diff --git a/x/staking/alias.go b/x/staking/alias.go index 1b7c78772f73..445ead018e15 100644 --- a/x/staking/alias.go +++ b/x/staking/alias.go @@ -176,6 +176,7 @@ var ( NewDescription = types.NewDescription // variable aliases + NewCodec = types.NewCodec ModuleCdc = types.ModuleCdc LastValidatorPowerKey = types.LastValidatorPowerKey LastTotalPowerKey = types.LastTotalPowerKey @@ -200,6 +201,7 @@ var ( type ( Keeper = keeper.Keeper + Codec = types.Codec Commission = types.Commission CommissionRates = types.CommissionRates DVPair = types.DVPair From beade6d743ee15a4edb7f1061c8e75b5c35a2273 Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Thu, 6 Feb 2020 15:05:35 +0100 Subject: [PATCH 21/27] init of params --- x/params/alias.go | 1 + x/params/commmon_test.go | 2 +- x/params/keeper.go | 4 +- x/params/proposal_handler_test.go | 2 +- x/params/subspace/subspace.go | 4 +- x/params/subspace/subspace_test.go | 7 +- x/params/types/codec.go | 21 +- x/params/types/proposal.go | 24 - x/params/types/types.pb.go | 699 +++++++++++++++++++++++++++++ x/params/types/types.proto | 28 ++ 10 files changed, 755 insertions(+), 37 deletions(-) create mode 100644 x/params/types/types.pb.go create mode 100644 x/params/types/types.proto diff --git a/x/params/alias.go b/x/params/alias.go index 1198e93cede3..a9f9f2e07cf1 100644 --- a/x/params/alias.go +++ b/x/params/alias.go @@ -30,6 +30,7 @@ var ( NewParameterChangeProposal = types.NewParameterChangeProposal NewParamChange = types.NewParamChange ValidateChanges = types.ValidateChanges + NewCodec = types.NewCodec // variable aliases ModuleCdc = types.ModuleCdc diff --git a/x/params/commmon_test.go b/x/params/commmon_test.go index ecebf8eb2e60..ddfcfbfb1982 100644 --- a/x/params/commmon_test.go +++ b/x/params/commmon_test.go @@ -43,7 +43,7 @@ func testComponents() (*codec.Codec, sdk.Context, sdk.StoreKey, sdk.StoreKey, Ke mkey := sdk.NewKVStoreKey("test") tkey := sdk.NewTransientStoreKey("transient_test") ctx := defaultContext(mkey, tkey) - keeper := NewKeeper(cdc, mkey, tkey) + keeper := NewKeeper(ModuleCdc, mkey, tkey) return cdc, ctx, mkey, tkey, keeper } diff --git a/x/params/keeper.go b/x/params/keeper.go index c3532f32834f..a290e6561270 100644 --- a/x/params/keeper.go +++ b/x/params/keeper.go @@ -13,14 +13,14 @@ import ( // Keeper of the global paramstore type Keeper struct { - cdc *codec.Codec + cdc codec.Marshaler key sdk.StoreKey tkey sdk.StoreKey spaces map[string]*Subspace } // NewKeeper constructs a params keeper -func NewKeeper(cdc *codec.Codec, key, tkey sdk.StoreKey) Keeper { +func NewKeeper(cdc codec.Marshaler, key, tkey sdk.StoreKey) Keeper { return Keeper{ cdc: cdc, key: key, diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index 9d83975c1020..b0444f32abc6 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -74,7 +74,7 @@ func newTestInput(t *testing.T) testInput { err := cms.LoadLatestVersion() require.Nil(t, err) - keeper := params.NewKeeper(cdc, keyParams, tKeyParams) + keeper := params.NewKeeper(types.ModuleCdc, keyParams, tKeyParams) ctx := sdk.NewContext(cms, abci.Header{}, false, log.NewNopLogger()) return testInput{ctx, cdc, keeper} diff --git a/x/params/subspace/subspace.go b/x/params/subspace/subspace.go index 94533f9451f1..bb2cbb22e100 100644 --- a/x/params/subspace/subspace.go +++ b/x/params/subspace/subspace.go @@ -22,7 +22,7 @@ const ( // Transient store persists for a block, so we use it for // recording whether the parameter has been changed or not type Subspace struct { - cdc *codec.Codec + cdc codec.Marshaler key sdk.StoreKey // []byte -> []byte, stores parameter tkey sdk.StoreKey // []byte -> bool, stores parameter change name []byte @@ -30,7 +30,7 @@ type Subspace struct { } // NewSubspace constructs a store with namestore -func NewSubspace(cdc *codec.Codec, key sdk.StoreKey, tkey sdk.StoreKey, name string) Subspace { +func NewSubspace(cdc codec.Marshaler, key sdk.StoreKey, tkey sdk.StoreKey, name string) Subspace { return Subspace{ cdc: cdc, key: key, diff --git a/x/params/subspace/subspace_test.go b/x/params/subspace/subspace_test.go index 05707097d478..3a1e56ae6bc4 100644 --- a/x/params/subspace/subspace_test.go +++ b/x/params/subspace/subspace_test.go @@ -14,18 +14,19 @@ import ( "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/params/subspace" + "github.com/cosmos/cosmos-sdk/x/params/types" ) type SubspaceTestSuite struct { suite.Suite - cdc *codec.Codec + cdc codec.Marshaler ctx sdk.Context ss subspace.Subspace } func (suite *SubspaceTestSuite) SetupTest() { - cdc := codec.New() + cdc := types.ModuleCdc db := dbm.NewMemDB() ms := store.NewCommitMultiStore(db) @@ -46,7 +47,7 @@ func (suite *SubspaceTestSuite) TestKeyTable() { suite.ss.WithKeyTable(paramKeyTable()) }) suite.Require().NotPanics(func() { - ss := subspace.NewSubspace(codec.New(), key, tkey, "testsubspace2") + ss := subspace.NewSubspace(types.ModuleCdc, key, tkey, "testsubspace2") ss = ss.WithKeyTable(paramKeyTable()) }) } diff --git a/x/params/types/codec.go b/x/params/types/codec.go index 525836346f90..a9436062cb10 100644 --- a/x/params/types/codec.go +++ b/x/params/types/codec.go @@ -4,13 +4,26 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) +type Codec struct { + codec.Marshaler + + // Keep reference to the amino codec to allow backwards compatibility along + // with type, and interface registration. + amino *codec.Codec +} + +func NewCodec(amino *codec.Codec) *Codec { + return &Codec{Marshaler: codec.NewHybridCodec(amino), amino: amino} +} + // module codec -var ModuleCdc *codec.Codec +var ModuleCdc *Codec func init() { - ModuleCdc = codec.New() - RegisterCodec(ModuleCdc) - ModuleCdc.Seal() + ModuleCdc = NewCodec(codec.New()) + + RegisterCodec(ModuleCdc.amino) + ModuleCdc.amino.Seal() } // RegisterCodec registers all necessary param module types with a given codec. diff --git a/x/params/types/proposal.go b/x/params/types/proposal.go index 78f200d143e9..4476817a4897 100644 --- a/x/params/types/proposal.go +++ b/x/params/types/proposal.go @@ -20,14 +20,6 @@ func init() { govtypes.RegisterProposalTypeCodec(ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal") } -// ParameterChangeProposal defines a proposal which contains multiple parameter -// changes. -type ParameterChangeProposal struct { - Title string `json:"title" yaml:"title"` - Description string `json:"description" yaml:"description"` - Changes []ParamChange `json:"changes" yaml:"changes"` -} - func NewParameterChangeProposal(title, description string, changes []ParamChange) ParameterChangeProposal { return ParameterChangeProposal{title, description, changes} } @@ -75,26 +67,10 @@ func (pcp ParameterChangeProposal) String() string { return b.String() } -// ParamChange defines a parameter change. -type ParamChange struct { - Subspace string `json:"subspace" yaml:"subspace"` - Key string `json:"key" yaml:"key"` - Value string `json:"value" yaml:"value"` -} - func NewParamChange(subspace, key, value string) ParamChange { return ParamChange{subspace, key, value} } -// String implements the Stringer interface. -func (pc ParamChange) String() string { - return fmt.Sprintf(`Param Change: - Subspace: %s - Key: %s - Value: %X -`, pc.Subspace, pc.Key, pc.Value) -} - // ValidateChanges performs basic validation checks over a set of ParamChange. It // returns an error if any ParamChange is invalid. func ValidateChanges(changes []ParamChange) error { diff --git a/x/params/types/types.pb.go b/x/params/types/types.pb.go new file mode 100644 index 000000000000..5b36bece670c --- /dev/null +++ b/x/params/types/types.pb.go @@ -0,0 +1,699 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/params/types/types.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// ParameterChangeProposal defines a proposal which contains multiple parameter +// changes. +type ParameterChangeProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` + Changes []ParamChange `protobuf:"bytes,3,rep,name=changes,proto3" json:"changes" yaml:"changes"` +} + +func (m *ParameterChangeProposal) Reset() { *m = ParameterChangeProposal{} } +func (*ParameterChangeProposal) ProtoMessage() {} +func (*ParameterChangeProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_ed04c33aa1766c78, []int{0} +} +func (m *ParameterChangeProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParameterChangeProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParameterChangeProposal.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ParameterChangeProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParameterChangeProposal.Merge(m, src) +} +func (m *ParameterChangeProposal) XXX_Size() int { + return m.Size() +} +func (m *ParameterChangeProposal) XXX_DiscardUnknown() { + xxx_messageInfo_ParameterChangeProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_ParameterChangeProposal proto.InternalMessageInfo + +// ParamChange defines a parameter change. +type ParamChange struct { + Subspace string `protobuf:"bytes,1,opt,name=subspace,proto3" json:"subspace,omitempty" yaml:"subspace"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty" yaml:"key"` + Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty" yaml:"value"` +} + +func (m *ParamChange) Reset() { *m = ParamChange{} } +func (m *ParamChange) String() string { return proto.CompactTextString(m) } +func (*ParamChange) ProtoMessage() {} +func (*ParamChange) Descriptor() ([]byte, []int) { + return fileDescriptor_ed04c33aa1766c78, []int{1} +} +func (m *ParamChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParamChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParamChange.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ParamChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParamChange.Merge(m, src) +} +func (m *ParamChange) XXX_Size() int { + return m.Size() +} +func (m *ParamChange) XXX_DiscardUnknown() { + xxx_messageInfo_ParamChange.DiscardUnknown(m) +} + +var xxx_messageInfo_ParamChange proto.InternalMessageInfo + +func (m *ParamChange) GetSubspace() string { + if m != nil { + return m.Subspace + } + return "" +} + +func (m *ParamChange) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + +func (m *ParamChange) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +func init() { + proto.RegisterType((*ParameterChangeProposal)(nil), "cosmos_sdk.x.params.v1.ParameterChangeProposal") + proto.RegisterType((*ParamChange)(nil), "cosmos_sdk.x.params.v1.ParamChange") +} + +func init() { proto.RegisterFile("x/params/types/types.proto", fileDescriptor_ed04c33aa1766c78) } + +var fileDescriptor_ed04c33aa1766c78 = []byte{ + // 346 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00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xd4, 0xfb, 0x67, 0xe8, 0x5a, + 0x91, 0x63, 0x64, 0xe9, 0x13, 0x91, 0x44, 0xa7, 0x28, 0x7a, 0x86, 0x67, 0xb1, 0x79, 0x53, 0x79, + 0x6e, 0xc3, 0x6d, 0x55, 0xee, 0x6f, 0x83, 0xbf, 0xf3, 0x04, 0x66, 0x46, 0x3b, 0x5f, 0xa7, 0xb6, + 0xce, 0xb1, 0x53, 0xe4, 0xb8, 0x6a, 0xed, 0x0f, 0x0e, 0x24, 0x3a, 0x7a, 0xb5, 0xcb, 0xcb, 0x15, + 0x76, 0xde, 0x56, 0xd8, 0x21, 0x4b, 0x00, 0x2b, 0x27, 0xad, 0x28, 0x84, 0x65, 0x35, 0xeb, 0x2b, + 0x41, 0xe3, 0x63, 0xaa, 0xeb, 0x22, 0xc7, 0x97, 0xd6, 0xe8, 0xa8, 0x90, 0xe8, 0x1b, 0x42, 0x0d, + 0xe8, 0x8e, 0x59, 0x76, 0xc8, 0x54, 0x2d, 0x72, 0x0c, 0x2d, 0x3b, 0x66, 0x19, 0x89, 0xf6, 0xd2, + 0x7e, 0x4b, 0x73, 0x9a, 0xce, 0x98, 0xe7, 0xfe, 0xde, 0x92, 0x29, 0x93, 0xc8, 0xca, 0x1d, 0xbc, + 0xde, 0xfa, 0x60, 0xb3, 0xf5, 0xc1, 0xe7, 0xd6, 0x07, 0xaf, 0x3b, 0xdf, 0xd9, 0xec, 0x7c, 0xe7, + 0x7d, 0xe7, 0x3b, 0x2f, 0x25, 0x73, 0xd0, 0xfe, 0x7f, 0x73, 0x91, 0x87, 0xaf, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xb9, 0x2f, 0xb9, 0xf8, 0xef, 0x01, 0x00, 0x00, +} + +func (m *ParameterChangeProposal) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ParameterChangeProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParameterChangeProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Changes) > 0 { + for iNdEx := len(m.Changes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Changes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ParamChange) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ParamChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParamChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Value))) + i-- + dAtA[i] = 0x1a + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0x12 + } + if len(m.Subspace) > 0 { + i -= len(m.Subspace) + copy(dAtA[i:], m.Subspace) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Subspace))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTypes(dAtA []byte, offset int, v uint64) int { + offset -= sovTypes(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ParameterChangeProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if len(m.Changes) > 0 { + for _, e := range m.Changes { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *ParamChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Subspace) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Key) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func sovTypes(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTypes(x uint64) (n int) { + return sovTypes(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ParameterChangeProposal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ParameterChangeProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParameterChangeProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Changes", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Changes = append(m.Changes, ParamChange{}) + if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ParamChange) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ParamChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Subspace", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Subspace = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTypes + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTypes + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTypes(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthTypes + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTypes(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTypes + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTypes + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTypes + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTypes + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTypes = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTypes = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTypes = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/params/types/types.proto b/x/params/types/types.proto new file mode 100644 index 000000000000..bdac70f043e4 --- /dev/null +++ b/x/params/types/types.proto @@ -0,0 +1,28 @@ +syntax = "proto3"; +package cosmos_sdk.x.params.v1; + +option go_package = "types"; + +import "third_party/proto/gogoproto/gogo.proto"; + + +// ParameterChangeProposal defines a proposal which contains multiple parameter +// changes. +message ParameterChangeProposal { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; + string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; + repeated ParamChange changes = 3 [ + (gogoproto.moretags) = "yaml:\"changes\"", + (gogoproto.nullable) = false + ]; +} + +// ParamChange defines a parameter change. +message ParamChange { + string subspace = 1 [(gogoproto.moretags) = "yaml:\"subspace\""]; + string key = 2 [(gogoproto.moretags) = "yaml:\"key\""]; + string value = 3 [(gogoproto.moretags) = "yaml:\"value\""]; +} \ No newline at end of file From 1b78d6572ef1257c3b127f80625a046e8523db88 Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Thu, 6 Feb 2020 15:45:12 +0100 Subject: [PATCH 22/27] change to app codec for params, still have one test failing --- simapp/app.go | 2 +- simapp/codec.go | 3 +++ x/distribution/keeper/test_common.go | 2 +- x/gov/keeper/test_common.go | 2 +- x/mock/app.go | 2 +- x/params/alias.go | 1 + x/slashing/internal/keeper/test_common.go | 2 +- x/staking/keeper/test_common.go | 2 +- 8 files changed, 10 insertions(+), 6 deletions(-) diff --git a/simapp/app.go b/simapp/app.go index 721c1ff6bd80..4871a4230200 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -150,7 +150,7 @@ func NewSimApp( } // init params keeper and subspaces - app.ParamsKeeper = params.NewKeeper(app.cdc, keys[params.StoreKey], tkeys[params.TStoreKey]) + app.ParamsKeeper = params.NewKeeper(appCodec.Params, keys[params.StoreKey], tkeys[params.TStoreKey]) app.subspaces[auth.ModuleName] = app.ParamsKeeper.Subspace(auth.DefaultParamspace) app.subspaces[bank.ModuleName] = app.ParamsKeeper.Subspace(bank.DefaultParamspace) app.subspaces[staking.ModuleName] = app.ParamsKeeper.Subspace(staking.DefaultParamspace) diff --git a/simapp/codec.go b/simapp/codec.go index 8f87e7e324b1..5aced4772f1c 100644 --- a/simapp/codec.go +++ b/simapp/codec.go @@ -4,6 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/vesting" + "github.com/cosmos/cosmos-sdk/x/params" "github.com/cosmos/cosmos-sdk/x/staking" ) @@ -13,6 +14,7 @@ type AppCodec struct { amino *codec.Codec Staking *staking.Codec + Params *params.Codec } func NewAppCodec() *AppCodec { @@ -21,6 +23,7 @@ func NewAppCodec() *AppCodec { return &AppCodec{ amino: amino, Staking: staking.NewCodec(amino), + Params: params.NewCodec(amino), } } diff --git a/x/distribution/keeper/test_common.go b/x/distribution/keeper/test_common.go index 2fe0e22b36ab..5f5153a1a8ff 100644 --- a/x/distribution/keeper/test_common.go +++ b/x/distribution/keeper/test_common.go @@ -126,7 +126,7 @@ func CreateTestInputAdvanced( blacklistedAddrs[distrAcc.GetAddress().String()] = true cdc := MakeTestCodec() - pk := params.NewKeeper(cdc, keyParams, tkeyParams) + pk := params.NewKeeper(params.ModuleCdc, keyParams, tkeyParams) ctx := sdk.NewContext(ms, abci.Header{ChainID: "foochainid"}, isCheckTx, log.NewNopLogger()) accountKeeper := auth.NewAccountKeeper(cdc, keyAcc, pk.Subspace(auth.DefaultParamspace), auth.ProtoBaseAccount) diff --git a/x/gov/keeper/test_common.go b/x/gov/keeper/test_common.go index bb57f7ab0275..42fe87626bcf 100644 --- a/x/gov/keeper/test_common.go +++ b/x/gov/keeper/test_common.go @@ -146,7 +146,7 @@ func createTestInput( blacklistedAddrs[notBondedPool.GetAddress().String()] = true blacklistedAddrs[bondPool.GetAddress().String()] = true - pk := params.NewKeeper(cdc, keyParams, tkeyParams) + pk := params.NewKeeper(params.ModuleCdc, keyParams, tkeyParams) accountKeeper := auth.NewAccountKeeper(cdc, keyAcc, pk.Subspace(auth.DefaultParamspace), auth.ProtoBaseAccount) bankKeeper := bank.NewBaseKeeper(cdc, keyBank, accountKeeper, pk.Subspace(bank.DefaultParamspace), blacklistedAddrs) supplyKeeper := supply.NewKeeper(cdc, keySupply, accountKeeper, bankKeeper, maccPerms) diff --git a/x/mock/app.go b/x/mock/app.go index 3afccc555df9..a021be7b8da8 100644 --- a/x/mock/app.go +++ b/x/mock/app.go @@ -69,7 +69,7 @@ func NewApp() *App { TotalCoinsSupply: sdk.NewCoins(), } - app.ParamsKeeper = params.NewKeeper(app.Cdc, app.KeyParams, app.TKeyParams) + app.ParamsKeeper = params.NewKeeper(params.ModuleCdc, app.KeyParams, app.TKeyParams) app.AccountKeeper = auth.NewAccountKeeper( app.Cdc, app.KeyAccount, diff --git a/x/params/alias.go b/x/params/alias.go index a9f9f2e07cf1..668056267e62 100644 --- a/x/params/alias.go +++ b/x/params/alias.go @@ -37,6 +37,7 @@ var ( ) type ( + Codec = types.Codec ParamSetPair = subspace.ParamSetPair ParamSetPairs = subspace.ParamSetPairs ParamSet = subspace.ParamSet diff --git a/x/slashing/internal/keeper/test_common.go b/x/slashing/internal/keeper/test_common.go index 128c7438a7f9..60dc3946043e 100644 --- a/x/slashing/internal/keeper/test_common.go +++ b/x/slashing/internal/keeper/test_common.go @@ -90,7 +90,7 @@ func CreateTestInput(t *testing.T, defaults types.Params) (sdk.Context, bank.Kee blacklistedAddrs[notBondedPool.GetAddress().String()] = true blacklistedAddrs[bondPool.GetAddress().String()] = true - paramsKeeper := params.NewKeeper(cdc, keyParams, tkeyParams) + paramsKeeper := params.NewKeeper(params.ModuleCdc, keyParams, tkeyParams) accountKeeper := auth.NewAccountKeeper(cdc, keyAcc, paramsKeeper.Subspace(auth.DefaultParamspace), auth.ProtoBaseAccount) bk := bank.NewBaseKeeper(cdc, keyBank, accountKeeper, paramsKeeper.Subspace(bank.DefaultParamspace), blacklistedAddrs) diff --git a/x/staking/keeper/test_common.go b/x/staking/keeper/test_common.go index d24365084221..005cfbfb1ffa 100644 --- a/x/staking/keeper/test_common.go +++ b/x/staking/keeper/test_common.go @@ -116,7 +116,7 @@ func CreateTestInput(t *testing.T, isCheckTx bool, initPower int64) (sdk.Context blacklistedAddrs[notBondedPool.GetAddress().String()] = true blacklistedAddrs[bondPool.GetAddress().String()] = true - pk := params.NewKeeper(cdc, keyParams, tkeyParams) + pk := params.NewKeeper(params.ModuleCdc, keyParams, tkeyParams) accountKeeper := auth.NewAccountKeeper( cdc, // amino codec From 86d5991b58f58d68aa516f70944e3407e507382f Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Thu, 6 Feb 2020 18:03:10 +0100 Subject: [PATCH 23/27] bump buf to 0.7 --- contrib/devtools/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/devtools/Makefile b/contrib/devtools/Makefile index 993d1b7b7436..51194db7789c 100644 --- a/contrib/devtools/Makefile +++ b/contrib/devtools/Makefile @@ -48,7 +48,7 @@ UNAME_M ?= $(shell uname -m) GOPATH ?= $(shell $(GO) env GOPATH) GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com -BUF_VERSION ?= 0.4.0 +BUF_VERSION ?= 0.7.0 TOOLS_DESTDIR ?= $(GOPATH)/bin STATIK = $(TOOLS_DESTDIR)/statik From 47cf6a3afa4cc9f58e2594e5ae683585e7a0d9aa Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 12 Feb 2020 09:57:52 -0500 Subject: [PATCH 24/27] Update x/params proto --- x/params/types/proposal.go | 8 ++++++ x/params/types/types.pb.go | 59 +++++++++++++++++--------------------- x/params/types/types.proto | 22 +++++++------- 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/x/params/types/proposal.go b/x/params/types/proposal.go index 4476817a4897..b61b59d25cf3 100644 --- a/x/params/types/proposal.go +++ b/x/params/types/proposal.go @@ -4,6 +4,8 @@ import ( "fmt" "strings" + "gopkg.in/yaml.v2" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -71,6 +73,12 @@ func NewParamChange(subspace, key, value string) ParamChange { return ParamChange{subspace, key, value} } +// String implements the Stringer interface. +func (pc ParamChange) String() string { + out, _ := yaml.Marshal(pc) + return string(out) +} + // ValidateChanges performs basic validation checks over a set of ParamChange. It // returns an error if any ParamChange is invalid. func ValidateChanges(changes []ParamChange) error { diff --git a/x/params/types/types.pb.go b/x/params/types/types.pb.go index 5b36bece670c..5f27a306bde2 100644 --- a/x/params/types/types.pb.go +++ b/x/params/types/types.pb.go @@ -26,9 +26,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // ParameterChangeProposal defines a proposal which contains multiple parameter // changes. type ParameterChangeProposal struct { - Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty" yaml:"title"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty" yaml:"description"` - Changes []ParamChange `protobuf:"bytes,3,rep,name=changes,proto3" json:"changes" yaml:"changes"` + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Changes []ParamChange `protobuf:"bytes,3,rep,name=changes,proto3" json:"changes"` } func (m *ParameterChangeProposal) Reset() { *m = ParameterChangeProposal{} } @@ -65,14 +65,13 @@ var xxx_messageInfo_ParameterChangeProposal proto.InternalMessageInfo // ParamChange defines a parameter change. type ParamChange struct { - Subspace string `protobuf:"bytes,1,opt,name=subspace,proto3" json:"subspace,omitempty" yaml:"subspace"` - Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty" yaml:"key"` - Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty" yaml:"value"` + Subspace string `protobuf:"bytes,1,opt,name=subspace,proto3" json:"subspace,omitempty"` + Key string `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` + Value string `protobuf:"bytes,3,opt,name=value,proto3" json:"value,omitempty"` } -func (m *ParamChange) Reset() { *m = ParamChange{} } -func (m *ParamChange) String() string { return proto.CompactTextString(m) } -func (*ParamChange) ProtoMessage() {} +func (m *ParamChange) Reset() { *m = ParamChange{} } +func (*ParamChange) ProtoMessage() {} func (*ParamChange) Descriptor() ([]byte, []int) { return fileDescriptor_ed04c33aa1766c78, []int{1} } @@ -132,29 +131,25 @@ func init() { func init() { proto.RegisterFile("x/params/types/types.proto", fileDescriptor_ed04c33aa1766c78) } var fileDescriptor_ed04c33aa1766c78 = []byte{ - // 346 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x91, 0xc1, 0x6a, 0xf2, 0x40, - 0x14, 0x85, 0x33, 0x7f, 0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67, 0xb1, 0x79, 0x53, 0x79, - 0x6e, 0xc3, 0x6d, 0x55, 0xee, 0x6f, 0x83, 0xbf, 0xf3, 0x04, 0x66, 0x46, 0x3b, 0x5f, 0xa7, 0xb6, - 0xce, 0xb1, 0x53, 0xe4, 0xb8, 0x6a, 0xed, 0x0f, 0x0e, 0x24, 0x3a, 0x7a, 0xb5, 0xcb, 0xcb, 0x15, - 0x76, 0xde, 0x56, 0xd8, 0x21, 0x4b, 0x00, 0x2b, 0x27, 0xad, 0x28, 0x84, 0x65, 0x35, 0xeb, 0x2b, - 0x41, 0xe3, 0x63, 0xaa, 0xeb, 0x22, 0xc7, 0x97, 0xd6, 0xe8, 0xa8, 0x90, 0xe8, 0x1b, 0x42, 0x0d, - 0xe8, 0x8e, 0x59, 0x76, 0xc8, 0x54, 0x2d, 0x72, 0x0c, 0x2d, 0x3b, 0x66, 0x19, 0x89, 0xf6, 0xd2, - 0x7e, 0x4b, 0x73, 0x9a, 0xce, 0x98, 0xe7, 0xfe, 0xde, 0x92, 0x29, 0x93, 0xc8, 0xca, 0x1d, 0xbc, - 0xde, 0xfa, 0x60, 0xb3, 0xf5, 0xc1, 0xe7, 0xd6, 0x07, 0xaf, 0x3b, 0xdf, 0xd9, 0xec, 0x7c, 0xe7, - 0x7d, 0xe7, 0x3b, 0x2f, 0x25, 0x73, 0xd0, 0xfe, 0x7f, 0x73, 0x91, 0x87, 0xaf, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xb9, 0x2f, 0xb9, 0xf8, 0xef, 0x01, 0x00, 0x00, + // 287 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xaa, 0xd0, 0x2f, 0x48, + 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2f, 0xa9, 0x2c, 0x48, 0x85, 0x92, 0x7a, 0x05, 0x45, 0xf9, 0x25, + 0xf9, 0x42, 0x62, 0xc9, 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 0x7e, 0x28, 0x4b, 0xcc, + 0x29, 0x4d, 0x95, 0x60, 0x86, 0xf8, 0x01, 0xcc, 0xb1, 0x62, 0x01, 0x19, 0xec, 0x24, 0x7f, 0xe2, + 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, + 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0xac, 0xe0, 0x20, 0x4e, 0x62, 0x03, 0x87, + 0x91, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x83, 0x64, 0xb6, 0xa5, 0x81, 0x01, 0x00, 0x00, } func (m *ParameterChangeProposal) Marshal() (dAtA []byte, err error) { diff --git a/x/params/types/types.proto b/x/params/types/types.proto index bdac70f043e4..74f25fe097ee 100644 --- a/x/params/types/types.proto +++ b/x/params/types/types.proto @@ -5,24 +5,22 @@ option go_package = "types"; import "third_party/proto/gogoproto/gogo.proto"; - // ParameterChangeProposal defines a proposal which contains multiple parameter // changes. message ParameterChangeProposal { - option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; - string title = 1 [(gogoproto.moretags) = "yaml:\"title\""]; - string description = 2 [(gogoproto.moretags) = "yaml:\"description\""]; - repeated ParamChange changes = 3 [ - (gogoproto.moretags) = "yaml:\"changes\"", - (gogoproto.nullable) = false - ]; + string title = 1; + string description = 2; + repeated ParamChange changes = 3 [(gogoproto.nullable) = false]; } // ParamChange defines a parameter change. message ParamChange { - string subspace = 1 [(gogoproto.moretags) = "yaml:\"subspace\""]; - string key = 2 [(gogoproto.moretags) = "yaml:\"key\""]; - string value = 3 [(gogoproto.moretags) = "yaml:\"value\""]; -} \ No newline at end of file + option (gogoproto.goproto_stringer) = false; + + string subspace = 1; + string key = 2; + string value = 3; +} From d079f66d18f64c720adf7b3546fb14ba0c089a02 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 12 Feb 2020 10:23:31 -0500 Subject: [PATCH 25/27] Fix params test harness --- x/params/commmon_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/x/params/commmon_test.go b/x/params/commmon_test.go index ddfcfbfb1982..c1d4bd0242ae 100644 --- a/x/params/commmon_test.go +++ b/x/params/commmon_test.go @@ -17,12 +17,12 @@ type s struct { I int } -func createTestCodec() *codec.Codec { +func createTestCodec() codec.Marshaler { cdc := codec.New() sdk.RegisterCodec(cdc) cdc.RegisterConcrete(s{}, "test/s", nil) cdc.RegisterConcrete(invalid{}, "test/invalid", nil) - return cdc + return NewCodec(cdc) } func defaultContext(key sdk.StoreKey, tkey sdk.StoreKey) sdk.Context { @@ -38,12 +38,12 @@ func defaultContext(key sdk.StoreKey, tkey sdk.StoreKey) sdk.Context { return ctx } -func testComponents() (*codec.Codec, sdk.Context, sdk.StoreKey, sdk.StoreKey, Keeper) { +func testComponents() (codec.Marshaler, sdk.Context, sdk.StoreKey, sdk.StoreKey, Keeper) { cdc := createTestCodec() mkey := sdk.NewKVStoreKey("test") tkey := sdk.NewTransientStoreKey("transient_test") ctx := defaultContext(mkey, tkey) - keeper := NewKeeper(ModuleCdc, mkey, tkey) + keeper := NewKeeper(cdc, mkey, tkey) return cdc, ctx, mkey, tkey, keeper } From 3a7cfdfd9c7bcbe58a62b27210235df37e8075c5 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 12 Feb 2020 10:23:44 -0500 Subject: [PATCH 26/27] Call s.checkType on Get --- x/params/subspace/subspace.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/params/subspace/subspace.go b/x/params/subspace/subspace.go index bb2cbb22e100..90dc143ebbe8 100644 --- a/x/params/subspace/subspace.go +++ b/x/params/subspace/subspace.go @@ -99,6 +99,8 @@ func (s Subspace) Validate(ctx sdk.Context, key []byte, value interface{}) error // Get queries for a parameter by key from the Subspace's KVStore and sets the // value to the provided pointer. If the value does not exist, it will panic. func (s Subspace) Get(ctx sdk.Context, key []byte, ptr interface{}) { + s.checkType(key, ptr) + store := s.kvStore(ctx) bz := store.Get(key) From 15481e72c9dcaee2b9b55e4b3d3d51ace4d73bb6 Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Wed, 12 Feb 2020 10:27:03 -0500 Subject: [PATCH 27/27] Add changelog entry --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5151296590c8..54274ff56728 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ balances or a single balance by denom when the `denom` query parameter is presen ### API Breaking Changes +* (x/params) [\#5619](https://github.com/cosmos/cosmos-sdk/pull/5619) The `x/params` keeper now accepts a `codec.Marshaller` instead of +a reference to an amino codec. Amino is still used for JSON serialization. * (types) [\#5579](https://github.com/cosmos/cosmos-sdk/pull/5579) The `keepRecent` field has been removed from the `PruningOptions` type. The `PruningOptions` type now only includes fields `KeepEvery` and `SnapshotEvery`, where `KeepEvery` determines which committed heights are flushed to disk and `SnapshotEvery` determines which of these