diff --git a/CHANGELOG.md b/CHANGELOG.md index 12e798c23615..aff20cb2eb1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,15 @@ for JSON encoding. * 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`. +* (distr) [\#5610](https://github.com/cosmos/cosmos-sdk/pull/5610) Migrate the `x/distribution` module to use Protocol Buffer for state +serialization instead of Amino. The exact codec used is `codec.HybridCodec` which utilizes Protobuf for binary encoding and Amino +for JSON encoding. + * `ValidatorHistoricalRewards.ReferenceCount` is now of types `uint32` instead of `uint16`. + * `ValidatorSlashEvents` is now a struct with `slashevents`. + * `ValidatorOutstandingRewards` is now a struct with `rewards`. + * `ValidatorAccumulatedCommission` is now a struct with `commission`. + * The `Keeper` constructor now takes a `codec.Marshaler` instead of a concrete Amino codec. This exact type + provided is specified by `ModuleCdc`. ### Improvements diff --git a/Makefile b/Makefile index 2e5984dd3ad8..2cf897fe985a 100644 --- a/Makefile +++ b/Makefile @@ -238,4 +238,25 @@ proto-lint: proto-check-breaking: @buf check breaking --against-input '.git#branch=master' -.PHONY: proto-all proto-gen proto-lint proto-check-breaking +# Origin +# TODO: Update to the version of Tendermint that is being used in go.mod +version_branch = v0.33.0 +tendermint = https://raw.githubusercontent.com/tendermint/tendermint/$(version_branch) + +# Outputs +tmkv = third_party/proto/tendermint/libs/kv/types.proto +tmmerkle = third_party/proto/tendermint/crypto/merkle/merkle.proto +tmabci = third_party/proto/tendermint/abci/types/types.proto + +# You *only* need to run this to rebuild protobufs from the tendermint source +proto-update-tendermint: + @curl $(tendermint)/abci/types/types.proto > $(tmabci) + sed -i '' '8,9 s|github.com/tendermint|third_party/proto|g' $(tmabci) + sed -i '' '7 s|github.com/gogo/protobuf|third_party/proto|' $(tmabci) + @curl $(tendermint)/libs/kv/types.proto > $(tmkv) + sed -i '' 's|github.com/gogo/protobuf|third_party/proto|' $(tmkv) + @curl $(tendermint)/crypto/merkle/merkle.proto > $(tmmerkle) + sed -i '' '7 s|github.com/gogo/protobuf|third_party/proto|' $(tmmerkle) + + +.PHONY: proto-all proto-gen proto-lint proto-check-breaking proto-update-tendermint 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 diff --git a/simapp/app.go b/simapp/app.go index 721c1ff6bd80..dff6ab5b9f18 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -179,7 +179,7 @@ func NewSimApp( app.SupplyKeeper, auth.FeeCollectorName, ) app.DistrKeeper = distr.NewKeeper( - app.cdc, keys[distr.StoreKey], app.subspaces[distr.ModuleName], app.BankKeeper, &stakingKeeper, + appCodec.Distribution, keys[distr.StoreKey], app.subspaces[distr.ModuleName], app.BankKeeper, &stakingKeeper, app.SupplyKeeper, auth.FeeCollectorName, app.ModuleAccountAddrs(), ) app.SlashingKeeper = slashing.NewKeeper( diff --git a/simapp/codec.go b/simapp/codec.go index 8f87e7e324b1..96b2d6a70a15 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" + distr "github.com/cosmos/cosmos-sdk/x/distribution" "github.com/cosmos/cosmos-sdk/x/staking" ) @@ -12,15 +13,17 @@ import ( type AppCodec struct { amino *codec.Codec - Staking *staking.Codec + Staking *staking.Codec + Distribution *distr.Codec } func NewAppCodec() *AppCodec { amino := MakeCodec() return &AppCodec{ - amino: amino, - Staking: staking.NewCodec(amino), + amino: amino, + Staking: staking.NewCodec(amino), + Distribution: distr.NewCodec(amino), } } diff --git a/simapp/export.go b/simapp/export.go index 01b1424032cf..39cf18586f10 100644 --- a/simapp/export.go +++ b/simapp/export.go @@ -87,9 +87,8 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailWhiteList []str // reinitialize all validators app.StakingKeeper.IterateValidators(ctx, func(_ int64, val exported.ValidatorI) (stop bool) { - // donate any unwithdrawn outstanding reward fraction tokens to the community pool - scraps := app.DistrKeeper.GetValidatorOutstandingRewards(ctx, val.GetOperator()) + scraps := app.DistrKeeper.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) feePool := app.DistrKeeper.GetFeePool(ctx) feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) app.DistrKeeper.SetFeePool(ctx, feePool) diff --git a/third_party/proto/tendermint/abci/types/types.proto b/third_party/proto/tendermint/abci/types/types.proto index eff32d4c5322..6c65444b0755 100644 --- a/third_party/proto/tendermint/abci/types/types.proto +++ b/third_party/proto/tendermint/abci/types/types.proto @@ -18,7 +18,6 @@ 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; @@ -43,9 +42,12 @@ message Request { } } -message RequestEcho { string message = 1; } +message RequestEcho { + string message = 1; +} -message RequestFlush {} +message RequestFlush { +} message RequestInfo { string version = 1; @@ -60,11 +62,10 @@ message RequestSetOption { } message RequestInitChain { - google.protobuf.Timestamp time = 1 - [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; + 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 ]; + repeated ValidatorUpdate validators = 4 [(gogoproto.nullable)=false]; bytes app_state_bytes = 5; } @@ -77,9 +78,9 @@ message RequestQuery { 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 ]; + Header header = 2 [(gogoproto.nullable)=false]; + LastCommitInfo last_commit_info = 3 [(gogoproto.nullable)=false]; + repeated Evidence byzantine_validators = 4 [(gogoproto.nullable)=false]; } enum CheckTxType { @@ -92,11 +93,16 @@ message RequestCheckTx { CheckTxType type = 2; } -message RequestDeliverTx { bytes tx = 1; } +message RequestDeliverTx { + bytes tx = 1; +} -message RequestEndBlock { int64 height = 1; } +message RequestEndBlock { + int64 height = 1; +} -message RequestCommit {} +message RequestCommit { +} //---------------------------------------- // Response types @@ -119,11 +125,16 @@ message Response { } // nondeterministic -message ResponseException { string error = 1; } +message ResponseException { + string error = 1; +} -message ResponseEcho { string message = 1; } +message ResponseEcho { + string message = 1; +} -message ResponseFlush {} +message ResponseFlush { +} message ResponseInfo { string data = 1; @@ -145,13 +156,13 @@ message ResponseSetOption { message ResponseInitChain { ConsensusParams consensus_params = 1; - repeated ValidatorUpdate validators = 2 [ (gogoproto.nullable) = false ]; + repeated ValidatorUpdate validators = 2 [(gogoproto.nullable)=false]; } message ResponseQuery { uint32 code = 1; // bytes data = 2; // use "value" instead. - string log = 3; // nondeterministic + string log = 3; // nondeterministic string info = 4; // nondeterministic int64 index = 5; bytes key = 6; @@ -162,48 +173,35 @@ message ResponseQuery { } message ResponseBeginBlock { - repeated Event events = 1 [ - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "events,omitempty" - ]; + repeated Event events = 1 [(gogoproto.nullable)=false, (gogoproto.jsontag)="events,omitempty"]; } message ResponseCheckTx { uint32 code = 1; bytes data = 2; - string log = 3; // nondeterministic + string log = 3; // nondeterministic string info = 4; // nondeterministic - int64 gas_wanted = 5; + int64 gas_wanted = 5; int64 gas_used = 6; - repeated Event events = 7 [ - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "events,omitempty" - ]; + 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 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" - ]; + repeated Event events = 7 [(gogoproto.nullable)=false, (gogoproto.jsontag)="events,omitempty"]; string codespace = 8; } message ResponseEndBlock { - repeated ValidatorUpdate validator_updates = 1 - [ (gogoproto.nullable) = false ]; + repeated ValidatorUpdate validator_updates = 1 [(gogoproto.nullable)=false]; ConsensusParams consensus_param_updates = 2; - repeated Event events = 3 [ - (gogoproto.nullable) = false, - (gogoproto.jsontag) = "events,omitempty" - ]; + repeated Event events = 3 [(gogoproto.nullable)=false, (gogoproto.jsontag)="events,omitempty"]; } message ResponseCommit { @@ -233,24 +231,22 @@ message BlockParams { 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 ]; + 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 ValidatorParams { + repeated string pub_key_types = 1; +} message LastCommitInfo { int32 round = 1; - repeated VoteInfo votes = 2 [ (gogoproto.nullable) = false ]; + 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" - ]; + repeated tendermint.libs.kv.Pair attributes = 2 [(gogoproto.nullable)=false, (gogoproto.jsontag)="attributes,omitempty"]; } //---------------------------------------- @@ -258,26 +254,24 @@ message Event { message Header { // basic block info - Version version = 1 [ (gogoproto.nullable) = false ]; - string chain_id = 2 [ (gogoproto.customname) = "ChainID" ]; + 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 ]; + google.protobuf.Timestamp time = 4 [(gogoproto.nullable)=false, (gogoproto.stdtime)=true]; // prev block info - BlockID last_block_id = 5 [ (gogoproto.nullable) = false ]; + 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 + 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 @@ -289,9 +283,10 @@ message Version { uint64 App = 2; } + message BlockID { bytes hash = 1; - PartSetHeader parts_header = 2 [ (gogoproto.nullable) = false ]; + PartSetHeader parts_header = 2 [(gogoproto.nullable)=false]; } message PartSetHeader { @@ -302,33 +297,32 @@ message PartSetHeader { // Validator message Validator { bytes address = 1; - // PubKey pub_key = 2 [(gogoproto.nullable)=false]; + //PubKey pub_key = 2 [(gogoproto.nullable)=false]; int64 power = 3; } // ValidatorUpdate message ValidatorUpdate { - PubKey pub_key = 1 [ (gogoproto.nullable) = false ]; + PubKey pub_key = 1 [(gogoproto.nullable)=false]; int64 power = 2; } // VoteInfo message VoteInfo { - Validator validator = 1 [ (gogoproto.nullable) = false ]; + Validator validator = 1 [(gogoproto.nullable)=false]; bool signed_last_block = 2; } message PubKey { string type = 1; - bytes data = 2; + bytes data = 2; } message Evidence { string type = 1; - Validator validator = 2 [ (gogoproto.nullable) = false ]; + Validator validator = 2 [(gogoproto.nullable)=false]; int64 height = 3; - google.protobuf.Timestamp time = 4 - [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; + google.protobuf.Timestamp time = 4 [(gogoproto.nullable)=false, (gogoproto.stdtime)=true]; int64 total_voting_power = 5; } @@ -336,7 +330,7 @@ message Evidence { // Service Definition service ABCIApplication { - rpc Echo(RequestEcho) returns (ResponseEcho); + rpc Echo(RequestEcho) returns (ResponseEcho) ; rpc Flush(RequestFlush) returns (ResponseFlush); rpc Info(RequestInfo) returns (ResponseInfo); rpc SetOption(RequestSetOption) returns (ResponseSetOption); diff --git a/x/crisis/internal/types/codec.go b/x/crisis/internal/types/codec.go index 92aeb130bce8..fc9178eb386b 100644 --- a/x/crisis/internal/types/codec.go +++ b/x/crisis/internal/types/codec.go @@ -4,17 +4,32 @@ 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 crisis module concrete types and +// interfaces with the provided codec reference. func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgVerifyInvariant{}, "cosmos-sdk/MsgVerifyInvariant", nil) } -// generic sealed codec to be used throughout module -var ModuleCdc *codec.Codec +// ModuleCdc defines a crisis 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/crisis/internal/types/msgs.go b/x/crisis/internal/types/msgs.go index f496df636b60..49698c1ca943 100644 --- a/x/crisis/internal/types/msgs.go +++ b/x/crisis/internal/types/msgs.go @@ -4,13 +4,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// MsgVerifyInvariant - message struct to verify a particular invariance -type MsgVerifyInvariant struct { - Sender sdk.AccAddress `json:"sender" yaml:"sender"` - InvariantModuleName string `json:"invariant_module_name" yaml:"invariant_module_name"` - InvariantRoute string `json:"invariant_route" yaml:"invariant_route"` -} - // ensure Msg interface compliance at compile time var _ sdk.Msg = &MsgVerifyInvariant{} diff --git a/x/crisis/internal/types/types.pb.go b/x/crisis/internal/types/types.pb.go new file mode 100644 index 000000000000..bf584c384409 --- /dev/null +++ b/x/crisis/internal/types/types.pb.go @@ -0,0 +1,435 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/crisis/internal/types/types.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "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 + +// MsgVerifyInvariant - message struct to verify a particular invariance +type MsgVerifyInvariant struct { + Sender github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=sender,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"sender,omitempty"` + InvariantModuleName string `protobuf:"bytes,2,opt,name=invariant_module_name,json=invariantModuleName,proto3" json:"invariant_module_name,omitempty" yaml:"invariant_module_name"` + InvariantRoute string `protobuf:"bytes,3,opt,name=invariant_route,json=invariantRoute,proto3" json:"invariant_route,omitempty" yaml:"invariant_route"` +} + +func (m *MsgVerifyInvariant) Reset() { *m = MsgVerifyInvariant{} } +func (m *MsgVerifyInvariant) String() string { return proto.CompactTextString(m) } +func (*MsgVerifyInvariant) ProtoMessage() {} +func (*MsgVerifyInvariant) Descriptor() ([]byte, []int) { + return fileDescriptor_df1c0b8e580cce76, []int{0} +} +func (m *MsgVerifyInvariant) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgVerifyInvariant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgVerifyInvariant.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 *MsgVerifyInvariant) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgVerifyInvariant.Merge(m, src) +} +func (m *MsgVerifyInvariant) XXX_Size() int { + return m.Size() +} +func (m *MsgVerifyInvariant) XXX_DiscardUnknown() { + xxx_messageInfo_MsgVerifyInvariant.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgVerifyInvariant proto.InternalMessageInfo + +func (m *MsgVerifyInvariant) GetSender() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Sender + } + return nil +} + +func (m *MsgVerifyInvariant) GetInvariantModuleName() string { + if m != nil { + return m.InvariantModuleName + } + return "" +} + +func (m *MsgVerifyInvariant) GetInvariantRoute() string { + if m != nil { + return m.InvariantRoute + } + return "" +} + +func init() { + proto.RegisterType((*MsgVerifyInvariant)(nil), "cosmos_sdk.x.crisis.v1.MsgVerifyInvariant") +} + +func init() { + proto.RegisterFile("x/crisis/internal/types/types.proto", fileDescriptor_df1c0b8e580cce76) +} + +var fileDescriptor_df1c0b8e580cce76 = []byte{ + // 301 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0xcf, 0x4a, 0xfb, 0x30, + 0x00, 0x80, 0x97, 0xdf, 0x0f, 0x07, 0x16, 0x51, 0xa8, 0x38, 0xc6, 0x90, 0x74, 0x54, 0x90, 0x5d, + 0xd6, 0x30, 0xbc, 0x79, 0xdb, 0x3c, 0xed, 0x30, 0x0f, 0x45, 0x3c, 0x78, 0x29, 0x59, 0x13, 0xbb, + 0xb0, 0x25, 0x29, 0x49, 0x3a, 0xd6, 0xb7, 0xf0, 0xb1, 0x3c, 0xee, 0xe8, 0xa9, 0x48, 0xfb, 0x06, + 0x3b, 0xee, 0x24, 0xa6, 0x75, 0x03, 0xf1, 0x92, 0x84, 0x8f, 0x2f, 0x5f, 0xfe, 0x38, 0x37, 0x1b, + 0x14, 0x2b, 0xa6, 0x99, 0x46, 0x4c, 0x18, 0xaa, 0x04, 0x5e, 0x21, 0x93, 0xa7, 0x54, 0xd7, 0x63, + 0x90, 0x2a, 0x69, 0xa4, 0xdb, 0x89, 0xa5, 0xe6, 0x52, 0x47, 0x9a, 0x2c, 0x83, 0x4d, 0x50, 0xfb, + 0xc1, 0x7a, 0xd4, 0xbb, 0x35, 0x0b, 0xa6, 0x48, 0x94, 0x62, 0x65, 0x72, 0x64, 0x55, 0x94, 0xc8, + 0x44, 0x1e, 0x57, 0xf5, 0x7e, 0x7f, 0x0f, 0x1c, 0x77, 0xa6, 0x93, 0x67, 0xaa, 0xd8, 0x6b, 0x3e, + 0x15, 0x6b, 0xac, 0x18, 0x16, 0xc6, 0x9d, 0x3a, 0x6d, 0x4d, 0x05, 0xa1, 0xaa, 0x0b, 0xfa, 0x60, + 0x70, 0x36, 0x19, 0xed, 0x0b, 0x6f, 0x98, 0x30, 0xb3, 0xc8, 0xe6, 0x41, 0x2c, 0x39, 0xaa, 0x4f, + 0x6d, 0xa6, 0xa1, 0x26, 0xcb, 0xe6, 0x52, 0xe3, 0x38, 0x1e, 0x13, 0xa2, 0xa8, 0xd6, 0x61, 0x13, + 0x70, 0x9f, 0x9c, 0x2b, 0xf6, 0xd3, 0x8d, 0xb8, 0x24, 0xd9, 0x8a, 0x46, 0x02, 0x73, 0xda, 0xfd, + 0xd7, 0x07, 0x83, 0xd3, 0x49, 0x7f, 0x57, 0x78, 0xd7, 0x39, 0xe6, 0xab, 0x7b, 0xff, 0x4f, 0xcd, + 0x0f, 0x2f, 0x0f, 0x7c, 0x66, 0xf1, 0x23, 0xe6, 0xd4, 0x7d, 0x70, 0x2e, 0x8e, 0xba, 0x92, 0x99, + 0xa1, 0xdd, 0xff, 0xb6, 0xd7, 0xdb, 0x15, 0x5e, 0xe7, 0x77, 0xcf, 0x0a, 0x7e, 0x78, 0x7e, 0x20, + 0xe1, 0x37, 0x98, 0x78, 0xef, 0x25, 0x04, 0xdb, 0x12, 0x82, 0xcf, 0x12, 0x82, 0xb7, 0x0a, 0xb6, + 0xb6, 0x15, 0x6c, 0x7d, 0x54, 0xb0, 0xf5, 0x72, 0x62, 0x9f, 0x33, 0x6f, 0xdb, 0x4f, 0xba, 0xfb, + 0x0a, 0x00, 0x00, 0xff, 0xff, 0xa7, 0xed, 0x2c, 0x98, 0x8b, 0x01, 0x00, 0x00, +} + +func (m *MsgVerifyInvariant) 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 *MsgVerifyInvariant) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgVerifyInvariant) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.InvariantRoute) > 0 { + i -= len(m.InvariantRoute) + copy(dAtA[i:], m.InvariantRoute) + i = encodeVarintTypes(dAtA, i, uint64(len(m.InvariantRoute))) + i-- + dAtA[i] = 0x1a + } + if len(m.InvariantModuleName) > 0 { + i -= len(m.InvariantModuleName) + copy(dAtA[i:], m.InvariantModuleName) + i = encodeVarintTypes(dAtA, i, uint64(len(m.InvariantModuleName))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Sender))) + 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 *MsgVerifyInvariant) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.InvariantModuleName) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + l = len(m.InvariantRoute) + 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 *MsgVerifyInvariant) 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: MsgVerifyInvariant: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgVerifyInvariant: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = append(m.Sender[:0], dAtA[iNdEx:postIndex]...) + if m.Sender == nil { + m.Sender = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InvariantModuleName", 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.InvariantModuleName = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InvariantRoute", 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.InvariantRoute = 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/crisis/internal/types/types.proto b/x/crisis/internal/types/types.proto new file mode 100644 index 000000000000..64b4c5fc60e8 --- /dev/null +++ b/x/crisis/internal/types/types.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package cosmos_sdk.x.crisis.v1; + +option go_package = "types"; + +import "third_party/proto/gogoproto/gogo.proto"; + +// MsgVerifyInvariant - message struct to verify a particular invariance +message MsgVerifyInvariant { + bytes sender = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + string invariant_module_name = 2 [(gogoproto.moretags) = "yaml:\"invariant_module_name\""]; + string invariant_route = 3 [(gogoproto.moretags) = "yaml:\"invariant_route\""]; +} diff --git a/x/distribution/alias.go b/x/distribution/alias.go index 47143d995cbb..ba16c5f47f28 100644 --- a/x/distribution/alias.go +++ b/x/distribution/alias.go @@ -111,6 +111,7 @@ var ( ParamStoreKeyBonusProposerReward = types.ParamStoreKeyBonusProposerReward ParamStoreKeyWithdrawAddrEnabled = types.ParamStoreKeyWithdrawAddrEnabled ModuleCdc = types.ModuleCdc + NewCodec = types.NewCodec EventTypeSetWithdrawAddress = types.EventTypeSetWithdrawAddress EventTypeRewards = types.EventTypeRewards EventTypeCommission = types.EventTypeCommission @@ -155,4 +156,5 @@ type ( ValidatorSlashEvent = types.ValidatorSlashEvent ValidatorSlashEvents = types.ValidatorSlashEvents ValidatorOutstandingRewards = types.ValidatorOutstandingRewards + Codec = types.Codec ) diff --git a/x/distribution/genesis.go b/x/distribution/genesis.go index 9e00aeba2b7c..2e05a85556f6 100644 --- a/x/distribution/genesis.go +++ b/x/distribution/genesis.go @@ -19,7 +19,7 @@ func InitGenesis(ctx sdk.Context, bk types.BankKeeper, supplyKeeper types.Supply } keeper.SetPreviousProposerConsAddr(ctx, data.PreviousProposer) for _, rew := range data.OutstandingRewards { - keeper.SetValidatorOutstandingRewards(ctx, rew.ValidatorAddress, rew.OutstandingRewards) + keeper.SetValidatorOutstandingRewards(ctx, rew.ValidatorAddress, types.ValidatorOutstandingRewards{Rewards: rew.OutstandingRewards}) moduleHoldings = moduleHoldings.Add(rew.OutstandingRewards...) } for _, acc := range data.ValidatorAccumulatedCommissions { @@ -76,7 +76,7 @@ func ExportGenesis(ctx sdk.Context, keeper Keeper) types.GenesisState { func(addr sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool) { outstanding = append(outstanding, types.ValidatorOutstandingRewardsRecord{ ValidatorAddress: addr, - OutstandingRewards: rewards, + OutstandingRewards: rewards.Rewards, }) return false }, diff --git a/x/distribution/keeper/alias_functions.go b/x/distribution/keeper/alias_functions.go index a02d2f2a0b4d..392881c7491b 100644 --- a/x/distribution/keeper/alias_functions.go +++ b/x/distribution/keeper/alias_functions.go @@ -8,7 +8,7 @@ import ( // get outstanding rewards func (k Keeper) GetValidatorOutstandingRewardsCoins(ctx sdk.Context, val sdk.ValAddress) sdk.DecCoins { - return k.GetValidatorOutstandingRewards(ctx, val) + return k.GetValidatorOutstandingRewards(ctx, val).Rewards } // get the community coins diff --git a/x/distribution/keeper/allocation.go b/x/distribution/keeper/allocation.go index 533aaac43858..385da6b00efd 100644 --- a/x/distribution/keeper/allocation.go +++ b/x/distribution/keeper/allocation.go @@ -114,7 +114,7 @@ func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val exported.Validato ), ) currentCommission := k.GetValidatorAccumulatedCommission(ctx, val.GetOperator()) - currentCommission = currentCommission.Add(commission...) + currentCommission.Commission = currentCommission.Commission.Add(commission...) k.SetValidatorAccumulatedCommission(ctx, val.GetOperator(), currentCommission) // update current rewards @@ -131,6 +131,6 @@ func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val exported.Validato ), ) outstanding := k.GetValidatorOutstandingRewards(ctx, val.GetOperator()) - outstanding = outstanding.Add(tokens...) + outstanding.Rewards = outstanding.Rewards.Add(tokens...) k.SetValidatorOutstandingRewards(ctx, val.GetOperator(), outstanding) } diff --git a/x/distribution/keeper/allocation_test.go b/x/distribution/keeper/allocation_test.go index 61513a02dca3..9628b74597fa 100644 --- a/x/distribution/keeper/allocation_test.go +++ b/x/distribution/keeper/allocation_test.go @@ -37,7 +37,7 @@ func TestAllocateTokensToValidatorWithCommission(t *testing.T) { expected := sdk.DecCoins{ {Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(5)}, } - require.Equal(t, expected, k.GetValidatorAccumulatedCommission(ctx, val.GetOperator())) + require.Equal(t, expected, k.GetValidatorAccumulatedCommission(ctx, val.GetOperator()).Commission) // check current rewards require.Equal(t, expected, k.GetValidatorCurrentRewards(ctx, val.GetOperator()).Rewards) @@ -75,11 +75,11 @@ func TestAllocateTokensToManyValidators(t *testing.T) { } // assert initial state: zero outstanding rewards, zero community pool, zero commission, zero current rewards - require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr1).IsZero()) - require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr2).IsZero()) + require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr1).Rewards.IsZero()) + require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr2).Rewards.IsZero()) require.True(t, k.GetFeePool(ctx).CommunityPool.IsZero()) - require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).IsZero()) - require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr2).IsZero()) + require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission.IsZero()) + require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr2).Commission.IsZero()) require.True(t, k.GetValidatorCurrentRewards(ctx, valOpAddr1).Rewards.IsZero()) require.True(t, k.GetValidatorCurrentRewards(ctx, valOpAddr2).Rewards.IsZero()) @@ -105,14 +105,14 @@ func TestAllocateTokensToManyValidators(t *testing.T) { k.AllocateTokens(ctx, 200, 200, valConsAddr2, votes) // 98 outstanding rewards (100 less 2 to community pool) - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecWithPrec(465, 1)}}, k.GetValidatorOutstandingRewards(ctx, valOpAddr1)) - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecWithPrec(515, 1)}}, k.GetValidatorOutstandingRewards(ctx, valOpAddr2)) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecWithPrec(465, 1)}}, k.GetValidatorOutstandingRewards(ctx, valOpAddr1).Rewards) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecWithPrec(515, 1)}}, k.GetValidatorOutstandingRewards(ctx, valOpAddr2).Rewards) // 2 community pool coins require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(2)}}, k.GetFeePool(ctx).CommunityPool) // 50% commission for first proposer, (0.5 * 93%) * 100 / 2 = 23.25 - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecWithPrec(2325, 2)}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1)) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecWithPrec(2325, 2)}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission) // zero commission for second proposer - require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr2).IsZero()) + require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr2).Commission.IsZero()) // just staking.proportional for first proposer less commission = (0.5 * 93%) * 100 / 2 = 23.25 require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDecWithPrec(2325, 2)}}, k.GetValidatorCurrentRewards(ctx, valOpAddr1).Rewards) // proposer reward + staking.proportional for second proposer = (5 % + 0.5 * (93%)) * 100 = 51.5 @@ -162,12 +162,12 @@ func TestAllocateTokensTruncation(t *testing.T) { } // assert initial state: zero outstanding rewards, zero community pool, zero commission, zero current rewards - require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr1).IsZero()) - require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr2).IsZero()) - require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr3).IsZero()) + require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr1).Rewards.IsZero()) + require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr2).Rewards.IsZero()) + require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr3).Rewards.IsZero()) require.True(t, k.GetFeePool(ctx).CommunityPool.IsZero()) - require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).IsZero()) - require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr2).IsZero()) + require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission.IsZero()) + require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr2).Commission.IsZero()) require.True(t, k.GetValidatorCurrentRewards(ctx, valOpAddr1).Rewards.IsZero()) require.True(t, k.GetValidatorCurrentRewards(ctx, valOpAddr2).Rewards.IsZero()) @@ -198,7 +198,7 @@ func TestAllocateTokensTruncation(t *testing.T) { } k.AllocateTokens(ctx, 31, 31, valConsAddr2, votes) - require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr1).IsValid()) - require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr2).IsValid()) - require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr3).IsValid()) + require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr1).Rewards.IsValid()) + require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr2).Rewards.IsValid()) + require.True(t, k.GetValidatorOutstandingRewards(ctx, valOpAddr3).Rewards.IsValid()) } diff --git a/x/distribution/keeper/delegation.go b/x/distribution/keeper/delegation.go index 7d79a35b40b9..48f474e5c570 100644 --- a/x/distribution/keeper/delegation.go +++ b/x/distribution/keeper/delegation.go @@ -145,7 +145,7 @@ func (k Keeper) withdrawDelegationRewards(ctx sdk.Context, val exported.Validato // end current period and calculate rewards endingPeriod := k.incrementValidatorPeriod(ctx, val) rewardsRaw := k.calculateDelegationRewards(ctx, val, del, endingPeriod) - outstanding := k.GetValidatorOutstandingRewards(ctx, del.GetValidatorAddr()) + outstanding := k.GetValidatorOutstandingRewardsCoins(ctx, del.GetValidatorAddr()) // defensive edge case may happen on the very final digits // of the decCoins due to operation order of the distribution mechanism. @@ -171,7 +171,7 @@ func (k Keeper) withdrawDelegationRewards(ctx sdk.Context, val exported.Validato // update the outstanding rewards and the community pool only if the // transaction was successful - k.SetValidatorOutstandingRewards(ctx, del.GetValidatorAddr(), outstanding.Sub(rewards)) + k.SetValidatorOutstandingRewards(ctx, del.GetValidatorAddr(), types.ValidatorOutstandingRewards{Rewards: outstanding.Sub(rewards)}) feePool := k.GetFeePool(ctx) feePool.CommunityPool = feePool.CommunityPool.Add(remainder...) k.SetFeePool(ctx, feePool) diff --git a/x/distribution/keeper/delegation_test.go b/x/distribution/keeper/delegation_test.go index 7f593fd5ecd6..a297eb5ba3a1 100644 --- a/x/distribution/keeper/delegation_test.go +++ b/x/distribution/keeper/delegation_test.go @@ -63,7 +63,7 @@ func TestCalculateRewardsBasic(t *testing.T) { require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, rewards) // commission should be the other half - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1)) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission) } func TestCalculateRewardsAfterSlash(t *testing.T) { @@ -128,7 +128,7 @@ func TestCalculateRewardsAfterSlash(t *testing.T) { // commission should be the other half require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.QuoRaw(2).ToDec()}}, - k.GetValidatorAccumulatedCommission(ctx, valOpAddr1)) + k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission) } func TestCalculateRewardsAfterManySlashes(t *testing.T) { @@ -205,7 +205,7 @@ func TestCalculateRewardsAfterManySlashes(t *testing.T) { // commission should be the other half require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.ToDec()}}, - k.GetValidatorAccumulatedCommission(ctx, valOpAddr1)) + k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission) } func TestCalculateRewardsMultiDelegator(t *testing.T) { @@ -273,7 +273,7 @@ func TestCalculateRewardsMultiDelegator(t *testing.T) { require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial * 1 / 4)}}, rewards) // commission should be equal to initial (50% twice) - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial)}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1)) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial)}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission) } func TestWithdrawDelegationRewardsBasic(t *testing.T) { @@ -419,7 +419,7 @@ func TestCalculateRewardsAfterManySlashesInSameBlock(t *testing.T) { require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}, rewards) // commission should be the other half - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1)) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission) } func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { @@ -501,7 +501,7 @@ func TestCalculateRewardsMultiDelegatorMultiSlash(t *testing.T) { require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial.QuoInt64(3)}}, rewards) // commission should be equal to initial (twice 50% commission, unaffected by slashing) - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1)) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: initial}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission) } func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { @@ -592,7 +592,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { require.True(t, rewards.IsZero()) // commission should be zero - require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).IsZero()) + require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission.IsZero()) // next block ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) @@ -619,7 +619,7 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 4)}}, rewards) // commission should be half initial - require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1)) + require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission) // next block ctx = ctx.WithBlockHeight(ctx.BlockHeight() + 1) @@ -646,5 +646,5 @@ func TestCalculateRewardsMultiDelegatorMultWithdraw(t *testing.T) { require.Equal(t, sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(initial / 2)}}, rewards) // commission should be zero - require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).IsZero()) + require.True(t, k.GetValidatorAccumulatedCommission(ctx, valOpAddr1).Commission.IsZero()) } diff --git a/x/distribution/keeper/hooks.go b/x/distribution/keeper/hooks.go index e7f843dd2bd7..c68b5909f734 100644 --- a/x/distribution/keeper/hooks.go +++ b/x/distribution/keeper/hooks.go @@ -24,12 +24,11 @@ func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) { // cleanup for after validator is removed func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress) { - // fetch outstanding - outstanding := h.k.GetValidatorOutstandingRewards(ctx, valAddr) + outstanding := h.k.GetValidatorOutstandingRewardsCoins(ctx, valAddr) // force-withdraw commission - commission := h.k.GetValidatorAccumulatedCommission(ctx, valAddr) + commission := h.k.GetValidatorAccumulatedCommission(ctx, valAddr).Commission if !commission.IsZero() { // subtract from outstanding outstanding = outstanding.Sub(commission) diff --git a/x/distribution/keeper/invariants.go b/x/distribution/keeper/invariants.go index cfafe1b11b27..45534b622e50 100644 --- a/x/distribution/keeper/invariants.go +++ b/x/distribution/keeper/invariants.go @@ -47,7 +47,7 @@ func NonNegativeOutstandingInvariant(k Keeper) sdk.Invariant { var outstanding sdk.DecCoins k.IterateValidatorOutstandingRewards(ctx, func(addr sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool) { - outstanding = rewards + outstanding = rewards.GetRewards() if outstanding.IsAnyNegative() { count++ msg += fmt.Sprintf("\t%v has negative outstanding coins: %v\n", addr, outstanding) @@ -89,7 +89,7 @@ func CanWithdrawInvariant(k Keeper) sdk.Invariant { } } - remaining = k.GetValidatorOutstandingRewards(ctx, val.GetOperator()) + remaining = k.GetValidatorOutstandingRewardsCoins(ctx, val.GetOperator()) if len(remaining) > 0 && remaining[0].Amount.IsNegative() { return true } @@ -140,7 +140,7 @@ func ModuleAccountInvariant(k Keeper) sdk.Invariant { var expectedCoins sdk.DecCoins k.IterateValidatorOutstandingRewards(ctx, func(_ sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool) { - expectedCoins = expectedCoins.Add(rewards...) + expectedCoins = expectedCoins.Add(rewards.Rewards...) return false }) diff --git a/x/distribution/keeper/keeper.go b/x/distribution/keeper/keeper.go index 5cce89d0c33f..0074f84042a6 100644 --- a/x/distribution/keeper/keeper.go +++ b/x/distribution/keeper/keeper.go @@ -15,7 +15,7 @@ import ( // Keeper of the distribution store type Keeper struct { storeKey sdk.StoreKey - cdc *codec.Codec + cdc codec.Marshaler paramSpace params.Subspace bankKeeper types.BankKeeper stakingKeeper types.StakingKeeper @@ -28,7 +28,7 @@ type Keeper struct { // NewKeeper creates a new distribution Keeper instance func NewKeeper( - cdc *codec.Codec, key sdk.StoreKey, paramSpace params.Subspace, bk types.BankKeeper, + cdc codec.Marshaler, key sdk.StoreKey, paramSpace params.Subspace, bk types.BankKeeper, sk types.StakingKeeper, supplyKeeper types.SupplyKeeper, feeCollectorName string, blacklistedAddrs map[string]bool, ) Keeper { @@ -116,16 +116,16 @@ func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddres func (k Keeper) WithdrawValidatorCommission(ctx sdk.Context, valAddr sdk.ValAddress) (sdk.Coins, error) { // fetch validator accumulated commission accumCommission := k.GetValidatorAccumulatedCommission(ctx, valAddr) - if accumCommission.IsZero() { + if accumCommission.Commission.IsZero() { return nil, types.ErrNoValidatorCommission } - commission, remainder := accumCommission.TruncateDecimal() - k.SetValidatorAccumulatedCommission(ctx, valAddr, remainder) // leave remainder to withdraw later + commission, remainder := accumCommission.Commission.TruncateDecimal() + k.SetValidatorAccumulatedCommission(ctx, valAddr, types.ValidatorAccumulatedCommission{Commission: remainder}) // leave remainder to withdraw later // update outstanding - outstanding := k.GetValidatorOutstandingRewards(ctx, valAddr) - k.SetValidatorOutstandingRewards(ctx, valAddr, outstanding.Sub(sdk.NewDecCoinsFromCoins(commission...))) + outstanding := k.GetValidatorOutstandingRewards(ctx, valAddr).Rewards + k.SetValidatorOutstandingRewards(ctx, valAddr, types.ValidatorOutstandingRewards{Rewards: outstanding.Sub(sdk.NewDecCoinsFromCoins(commission...))}) if !commission.IsZero() { accAddr := sdk.AccAddress(valAddr) @@ -150,7 +150,7 @@ func (k Keeper) WithdrawValidatorCommission(ctx sdk.Context, valAddr sdk.ValAddr func (k Keeper) GetTotalRewards(ctx sdk.Context) (totalRewards sdk.DecCoins) { k.IterateValidatorOutstandingRewards(ctx, func(_ sdk.ValAddress, rewards types.ValidatorOutstandingRewards) (stop bool) { - totalRewards = totalRewards.Add(rewards...) + totalRewards = totalRewards.Add(rewards.Rewards...) return false }, ) diff --git a/x/distribution/keeper/keeper_test.go b/x/distribution/keeper/keeper_test.go index 17d809becc91..f4846e61e2fa 100644 --- a/x/distribution/keeper/keeper_test.go +++ b/x/distribution/keeper/keeper_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/distribution/types" ) func TestSetWithdrawAddr(t *testing.T) { @@ -53,10 +54,10 @@ func TestWithdrawValidatorCommission(t *testing.T) { require.Equal(t, expCoins, balance) // set outstanding rewards - keeper.SetValidatorOutstandingRewards(ctx, valOpAddr3, valCommission) + keeper.SetValidatorOutstandingRewards(ctx, valOpAddr3, types.ValidatorOutstandingRewards{Rewards: valCommission}) // set commission - keeper.SetValidatorAccumulatedCommission(ctx, valOpAddr3, valCommission) + keeper.SetValidatorAccumulatedCommission(ctx, valOpAddr3, types.ValidatorAccumulatedCommission{Commission: valCommission}) // withdraw commission keeper.WithdrawValidatorCommission(ctx, valOpAddr3) @@ -69,7 +70,7 @@ func TestWithdrawValidatorCommission(t *testing.T) { ), balance) // check remainder - remainder := keeper.GetValidatorAccumulatedCommission(ctx, valOpAddr3) + remainder := keeper.GetValidatorAccumulatedCommission(ctx, valOpAddr3).Commission require.Equal(t, sdk.DecCoins{ sdk.NewDecCoinFromDec("mytoken", sdk.NewDec(1).Quo(sdk.NewDec(4))), sdk.NewDecCoinFromDec("stake", sdk.NewDec(1).Quo(sdk.NewDec(2))), @@ -86,8 +87,8 @@ func TestGetTotalRewards(t *testing.T) { sdk.NewDecCoinFromDec("stake", sdk.NewDec(3).Quo(sdk.NewDec(2))), } - keeper.SetValidatorOutstandingRewards(ctx, valOpAddr1, valCommission) - keeper.SetValidatorOutstandingRewards(ctx, valOpAddr2, valCommission) + keeper.SetValidatorOutstandingRewards(ctx, valOpAddr1, types.ValidatorOutstandingRewards{Rewards: valCommission}) + keeper.SetValidatorOutstandingRewards(ctx, valOpAddr2, types.ValidatorOutstandingRewards{Rewards: valCommission}) expectedRewards := valCommission.MulDec(sdk.NewDec(2)) totalRewards := keeper.GetTotalRewards(ctx) diff --git a/x/distribution/keeper/querier.go b/x/distribution/keeper/querier.go index 4757ea5ffe3e..77d4c6520971 100644 --- a/x/distribution/keeper/querier.go +++ b/x/distribution/keeper/querier.go @@ -67,8 +67,8 @@ func queryValidatorOutstandingRewards(ctx sdk.Context, path []string, req abci.R } rewards := k.GetValidatorOutstandingRewards(ctx, params.ValidatorAddress) - if rewards == nil { - rewards = sdk.DecCoins{} + if rewards.GetRewards() == nil { + rewards.Rewards = sdk.DecCoins{} } bz, err := codec.MarshalJSONIndent(k.cdc, rewards) @@ -87,8 +87,8 @@ func queryValidatorCommission(ctx sdk.Context, path []string, req abci.RequestQu } commission := k.GetValidatorAccumulatedCommission(ctx, params.ValidatorAddress) - if commission == nil { - commission = sdk.DecCoins{} + if commission.Commission == nil { + commission.Commission = sdk.DecCoins{} } bz, err := codec.MarshalJSONIndent(k.cdc, commission) diff --git a/x/distribution/keeper/querier_test.go b/x/distribution/keeper/querier_test.go index ed87f42edd78..7d032a6ccd95 100644 --- a/x/distribution/keeper/querier_test.go +++ b/x/distribution/keeper/querier_test.go @@ -27,7 +27,7 @@ func getQueriedParams(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier s return params } -func getQueriedValidatorOutstandingRewards(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier sdk.Querier, validatorAddr sdk.ValAddress) (outstandingRewards sdk.DecCoins) { +func getQueriedValidatorOutstandingRewards(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier sdk.Querier, validatorAddr sdk.ValAddress) sdk.DecCoins { query := abci.RequestQuery{ Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryValidatorOutstandingRewards}, "/"), Data: cdc.MustMarshalJSON(types.NewQueryValidatorOutstandingRewardsParams(validatorAddr)), @@ -35,12 +35,13 @@ func getQueriedValidatorOutstandingRewards(t *testing.T, ctx sdk.Context, cdc *c bz, err := querier(ctx, []string{types.QueryValidatorOutstandingRewards}, query) require.Nil(t, err) + outstandingRewards := types.ValidatorOutstandingRewards{} require.Nil(t, cdc.UnmarshalJSON(bz, &outstandingRewards)) - return + return outstandingRewards.GetRewards() } -func getQueriedValidatorCommission(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier sdk.Querier, validatorAddr sdk.ValAddress) (validatorCommission sdk.DecCoins) { +func getQueriedValidatorCommission(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier sdk.Querier, validatorAddr sdk.ValAddress) sdk.DecCoins { query := abci.RequestQuery{ Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryValidatorCommission}, "/"), Data: cdc.MustMarshalJSON(types.NewQueryValidatorCommissionParams(validatorAddr)), @@ -48,9 +49,10 @@ func getQueriedValidatorCommission(t *testing.T, ctx sdk.Context, cdc *codec.Cod bz, err := querier(ctx, []string{types.QueryValidatorCommission}, query) require.Nil(t, err) + validatorCommission := types.ValidatorAccumulatedCommission{} require.Nil(t, cdc.UnmarshalJSON(bz, &validatorCommission)) - return + return validatorCommission.GetCommission() } func getQueriedValidatorSlashes(t *testing.T, ctx sdk.Context, cdc *codec.Codec, querier sdk.Querier, validatorAddr sdk.ValAddress, startHeight uint64, endHeight uint64) (slashes []types.ValidatorSlashEvent) { @@ -130,13 +132,13 @@ func TestQueries(t *testing.T) { // test outstanding rewards query outstandingRewards := sdk.DecCoins{{Denom: "mytoken", Amount: sdk.NewDec(3)}, {Denom: "myothertoken", Amount: sdk.NewDecWithPrec(3, 7)}} - keeper.SetValidatorOutstandingRewards(ctx, valOpAddr1, outstandingRewards) + keeper.SetValidatorOutstandingRewards(ctx, valOpAddr1, types.ValidatorOutstandingRewards{Rewards: outstandingRewards}) retOutstandingRewards := getQueriedValidatorOutstandingRewards(t, ctx, cdc, querier, valOpAddr1) require.Equal(t, outstandingRewards, retOutstandingRewards) // test validator commission query commission := sdk.DecCoins{{Denom: "token1", Amount: sdk.NewDec(4)}, {Denom: "token2", Amount: sdk.NewDec(2)}} - keeper.SetValidatorAccumulatedCommission(ctx, valOpAddr1, commission) + keeper.SetValidatorAccumulatedCommission(ctx, valOpAddr1, types.ValidatorAccumulatedCommission{Commission: commission}) retCommission := getQueriedValidatorCommission(t, ctx, cdc, querier, valOpAddr1) require.Equal(t, commission, retCommission) diff --git a/x/distribution/keeper/store.go b/x/distribution/keeper/store.go index e1a1c50d4343..ffdd807163ed 100644 --- a/x/distribution/keeper/store.go +++ b/x/distribution/keeper/store.go @@ -1,6 +1,8 @@ package keeper import ( + gogotypes "github.com/gogo/protobuf/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/distribution/types" ) @@ -55,26 +57,29 @@ func (k Keeper) GetFeePool(ctx sdk.Context) (feePool types.FeePool) { // set the global fee pool distribution info func (k Keeper) SetFeePool(ctx sdk.Context, feePool types.FeePool) { store := ctx.KVStore(k.storeKey) - b := k.cdc.MustMarshalBinaryLengthPrefixed(feePool) + b := k.cdc.MustMarshalBinaryLengthPrefixed(&feePool) store.Set(types.FeePoolKey, b) } -// get the proposer public key for this block -func (k Keeper) GetPreviousProposerConsAddr(ctx sdk.Context) (consAddr sdk.ConsAddress) { +// GetPreviousProposerConsAddr returns the proposer consensus address for the +// current block. +func (k Keeper) GetPreviousProposerConsAddr(ctx sdk.Context) sdk.ConsAddress { store := ctx.KVStore(k.storeKey) - b := store.Get(types.ProposerKey) - if b == nil { - panic("Previous proposer not set") + bz := store.Get(types.ProposerKey) + if bz == nil { + panic("previous proposer not set") } - k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &consAddr) - return + + addrValue := gogotypes.BytesValue{} + k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &addrValue) + return sdk.ConsAddress(addrValue.GetValue()) } // set the proposer public key for this block func (k Keeper) SetPreviousProposerConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) { store := ctx.KVStore(k.storeKey) - b := k.cdc.MustMarshalBinaryLengthPrefixed(consAddr) - store.Set(types.ProposerKey, b) + bz := k.cdc.MustMarshalBinaryLengthPrefixed(&gogotypes.BytesValue{Value: consAddr}) + store.Set(types.ProposerKey, bz) } // get the starting info associated with a delegator @@ -88,7 +93,7 @@ func (k Keeper) GetDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, de // set the starting info associated with a delegator func (k Keeper) SetDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress, period types.DelegatorStartingInfo) { store := ctx.KVStore(k.storeKey) - b := k.cdc.MustMarshalBinaryLengthPrefixed(period) + b := k.cdc.MustMarshalBinaryLengthPrefixed(&period) store.Set(types.GetDelegatorStartingInfoKey(val, del), b) } @@ -130,7 +135,7 @@ func (k Keeper) GetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddres // set historical rewards for a particular period func (k Keeper) SetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress, period uint64, rewards types.ValidatorHistoricalRewards) { store := ctx.KVStore(k.storeKey) - b := k.cdc.MustMarshalBinaryLengthPrefixed(rewards) + b := k.cdc.MustMarshalBinaryLengthPrefixed(&rewards) store.Set(types.GetValidatorHistoricalRewardsKey(val, period), b) } @@ -199,7 +204,7 @@ func (k Keeper) GetValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress) // set current rewards for a validator func (k Keeper) SetValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress, rewards types.ValidatorCurrentRewards) { store := ctx.KVStore(k.storeKey) - b := k.cdc.MustMarshalBinaryLengthPrefixed(rewards) + b := k.cdc.MustMarshalBinaryLengthPrefixed(&rewards) store.Set(types.GetValidatorCurrentRewardsKey(val), b) } @@ -240,10 +245,10 @@ func (k Keeper) SetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAd var bz []byte store := ctx.KVStore(k.storeKey) - if commission.IsZero() { - bz = k.cdc.MustMarshalBinaryLengthPrefixed(types.InitialValidatorAccumulatedCommission()) + if commission.Commission.IsZero() { + bz = k.cdc.MustMarshalBinaryLengthPrefixed(&types.ValidatorAccumulatedCommission{}) } else { - bz = k.cdc.MustMarshalBinaryLengthPrefixed(commission) + bz = k.cdc.MustMarshalBinaryLengthPrefixed(&commission) } store.Set(types.GetValidatorAccumulatedCommissionKey(val), bz) @@ -273,15 +278,15 @@ func (k Keeper) IterateValidatorAccumulatedCommissions(ctx sdk.Context, handler // get validator outstanding rewards func (k Keeper) GetValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress) (rewards types.ValidatorOutstandingRewards) { store := ctx.KVStore(k.storeKey) - b := store.Get(types.GetValidatorOutstandingRewardsKey(val)) - k.cdc.MustUnmarshalBinaryLengthPrefixed(b, &rewards) + bz := store.Get(types.GetValidatorOutstandingRewardsKey(val)) + k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &rewards) return } // set validator outstanding rewards func (k Keeper) SetValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress, rewards types.ValidatorOutstandingRewards) { store := ctx.KVStore(k.storeKey) - b := k.cdc.MustMarshalBinaryLengthPrefixed(rewards) + b := k.cdc.MustMarshalBinaryLengthPrefixed(&rewards) store.Set(types.GetValidatorOutstandingRewardsKey(val), b) } @@ -297,7 +302,7 @@ func (k Keeper) IterateValidatorOutstandingRewards(ctx sdk.Context, handler func iter := sdk.KVStorePrefixIterator(store, types.ValidatorOutstandingRewardsPrefix) defer iter.Close() for ; iter.Valid(); iter.Next() { - var rewards types.ValidatorOutstandingRewards + rewards := types.ValidatorOutstandingRewards{} k.cdc.MustUnmarshalBinaryLengthPrefixed(iter.Value(), &rewards) addr := types.GetValidatorOutstandingRewardsAddress(iter.Key()) if handler(addr, rewards) { @@ -320,7 +325,7 @@ func (k Keeper) GetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, heig // set slash event for height func (k Keeper) SetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, height, period uint64, event types.ValidatorSlashEvent) { store := ctx.KVStore(k.storeKey) - b := k.cdc.MustMarshalBinaryLengthPrefixed(event) + b := k.cdc.MustMarshalBinaryLengthPrefixed(&event) store.Set(types.GetValidatorSlashEventKey(val, height, period), b) } diff --git a/x/distribution/keeper/test_common.go b/x/distribution/keeper/test_common.go index 2fe0e22b36ab..dae0734c8d39 100644 --- a/x/distribution/keeper/test_common.go +++ b/x/distribution/keeper/test_common.go @@ -142,7 +142,7 @@ func CreateTestInputAdvanced( 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) + keeper := NewKeeper(types.ModuleCdc, keyDistr, pk.Subspace(types.DefaultParamspace), bankKeeper, sk, supplyKeeper, auth.FeeCollectorName, blacklistedAddrs) initCoins := sdk.NewCoins(sdk.NewCoin(sk.BondDenom(ctx), initTokens)) totalSupply := sdk.NewCoins(sdk.NewCoin(sk.BondDenom(ctx), initTokens.MulRaw(int64(len(TestAddrs))))) diff --git a/x/distribution/keeper/validator.go b/x/distribution/keeper/validator.go index ccedb7ede163..6b9711a76443 100644 --- a/x/distribution/keeper/validator.go +++ b/x/distribution/keeper/validator.go @@ -21,7 +21,7 @@ func (k Keeper) initializeValidator(ctx sdk.Context, val exported.ValidatorI) { k.SetValidatorAccumulatedCommission(ctx, val.GetOperator(), types.InitialValidatorAccumulatedCommission()) // set outstanding rewards - k.SetValidatorOutstandingRewards(ctx, val.GetOperator(), sdk.DecCoins{}) + k.SetValidatorOutstandingRewards(ctx, val.GetOperator(), types.ValidatorOutstandingRewards{Rewards: sdk.DecCoins{}}) } // increment validator period, returning the period just ended @@ -38,7 +38,7 @@ func (k Keeper) incrementValidatorPeriod(ctx sdk.Context, val exported.Validator feePool := k.GetFeePool(ctx) outstanding := k.GetValidatorOutstandingRewards(ctx, val.GetOperator()) feePool.CommunityPool = feePool.CommunityPool.Add(rewards.Rewards...) - outstanding = outstanding.Sub(rewards.Rewards) + outstanding.Rewards = outstanding.GetRewards().Sub(rewards.Rewards) k.SetFeePool(ctx, feePool) k.SetValidatorOutstandingRewards(ctx, val.GetOperator(), outstanding) diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index d8c6d719ce9e..059c2d625afd 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -36,8 +36,8 @@ func TestDecodeDistributionStore(t *testing.T) { feePool := types.InitialFeePool() feePool.CommunityPool = decCoins info := types.NewDelegatorStartingInfo(2, sdk.OneDec(), 200) - outstanding := types.ValidatorOutstandingRewards{decCoins[0]} - commission := types.ValidatorAccumulatedCommission{decCoins[0]} + outstanding := types.ValidatorOutstandingRewards{Rewards: decCoins} + commission := types.ValidatorAccumulatedCommission{Commission: decCoins} historicalRewards := types.NewValidatorHistoricalRewards(decCoins, 100) currentRewards := types.NewValidatorCurrentRewards(decCoins, 5) slashEvent := types.NewValidatorSlashEvent(10, sdk.OneDec()) diff --git a/x/distribution/simulation/operations.go b/x/distribution/simulation/operations.go index cb30376ab429..f134861ab139 100644 --- a/x/distribution/simulation/operations.go +++ b/x/distribution/simulation/operations.go @@ -177,7 +177,7 @@ func SimulateMsgWithdrawValidatorCommission(ak types.AccountKeeper, bk types.Ban } commission := k.GetValidatorAccumulatedCommission(ctx, validator.GetOperator()) - if commission.IsZero() { + if commission.Commission.IsZero() { return simulation.NoOpMsg(types.ModuleName), nil, nil } diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index a2d4bf11eaae..85412d65c77e 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/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 crisis module concrete types and +// interfaces with the provided codec reference. func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward", nil) cdc.RegisterConcrete(MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValidatorCommission", nil) @@ -13,11 +28,11 @@ func RegisterCodec(cdc *codec.Codec) { } // generic sealed codec to be used throughout module -var ModuleCdc *codec.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/distribution/types/delegator.go b/x/distribution/types/delegator.go index 8c9e0b9933ce..850878660780 100644 --- a/x/distribution/types/delegator.go +++ b/x/distribution/types/delegator.go @@ -4,19 +4,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// starting info for a delegator reward period -// tracks the previous validator period, the delegation's amount -// of staking token, and the creation height (to check later on -// if any slashes have occurred) -// NOTE that even though validators are slashed to whole staking tokens, the -// delegators within the validator may be left with less than a full token, -// thus sdk.Dec is used -type DelegatorStartingInfo struct { - PreviousPeriod uint64 `json:"previous_period" yaml:"previous_period"` // period at which the delegation should withdraw starting from - Stake sdk.Dec `json:"stake" yaml:"stake"` // amount of staking token delegated - Height uint64 `json:"creation_height" yaml:"creation_height"` // height at which delegation was created -} - // create a new DelegatorStartingInfo func NewDelegatorStartingInfo(previousPeriod uint64, stake sdk.Dec, height uint64) DelegatorStartingInfo { return DelegatorStartingInfo{ diff --git a/x/distribution/types/fee_pool.go b/x/distribution/types/fee_pool.go index b542ced7be24..645afd401a33 100644 --- a/x/distribution/types/fee_pool.go +++ b/x/distribution/types/fee_pool.go @@ -6,11 +6,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// global fee pool for distribution -type FeePool struct { - CommunityPool sdk.DecCoins `json:"community_pool" yaml:"community_pool"` // pool for community funds yet to be spent -} - // zero fee pool func InitialFeePool() FeePool { return FeePool{ diff --git a/x/distribution/types/msg.go b/x/distribution/types/msg.go index 2068caef149e..4641c95663e9 100644 --- a/x/distribution/types/msg.go +++ b/x/distribution/types/msg.go @@ -9,12 +9,6 @@ import ( // Verify interface at compile time var _, _, _ sdk.Msg = &MsgSetWithdrawAddress{}, &MsgWithdrawDelegatorReward{}, &MsgWithdrawValidatorCommission{} -// msg struct for changing the withdraw address for a delegator (or validator self-delegation) -type MsgSetWithdrawAddress struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` - WithdrawAddress sdk.AccAddress `json:"withdraw_address" yaml:"withdraw_address"` -} - func NewMsgSetWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) MsgSetWithdrawAddress { return MsgSetWithdrawAddress{ DelegatorAddress: delAddr, @@ -48,12 +42,6 @@ func (msg MsgSetWithdrawAddress) ValidateBasic() error { return nil } -// msg struct for delegation withdraw from a single validator -type MsgWithdrawDelegatorReward struct { - DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"delegator_address"` - ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` -} - func NewMsgWithdrawDelegatorReward(delAddr sdk.AccAddress, valAddr sdk.ValAddress) MsgWithdrawDelegatorReward { return MsgWithdrawDelegatorReward{ DelegatorAddress: delAddr, @@ -86,11 +74,6 @@ func (msg MsgWithdrawDelegatorReward) ValidateBasic() error { return nil } -// msg struct for validator withdraw -type MsgWithdrawValidatorCommission struct { - ValidatorAddress sdk.ValAddress `json:"validator_address" yaml:"validator_address"` -} - func NewMsgWithdrawValidatorCommission(valAddr sdk.ValAddress) MsgWithdrawValidatorCommission { return MsgWithdrawValidatorCommission{ ValidatorAddress: valAddr, @@ -121,13 +104,6 @@ func (msg MsgWithdrawValidatorCommission) ValidateBasic() error { const TypeMsgFundCommunityPool = "fund_community_pool" -// MsgFundCommunityPool defines a Msg type that allows an account to directly -// fund the community pool. -type MsgFundCommunityPool struct { - Amount sdk.Coins `json:"amount" yaml:"amount"` - Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"` -} - // NewMsgFundCommunityPool returns a new MsgFundCommunityPool with a sender and // a funding amount. func NewMsgFundCommunityPool(amount sdk.Coins, depositor sdk.AccAddress) MsgFundCommunityPool { diff --git a/x/distribution/types/params.go b/x/distribution/types/params.go index f4530dd81c3b..12daed847d47 100644 --- a/x/distribution/types/params.go +++ b/x/distribution/types/params.go @@ -22,14 +22,6 @@ var ( ParamStoreKeyWithdrawAddrEnabled = []byte("withdrawaddrenabled") ) -// Params defines the set of distribution parameters. -type Params struct { - CommunityTax sdk.Dec `json:"community_tax" yaml:"community_tax"` - BaseProposerReward sdk.Dec `json:"base_proposer_reward" yaml:"base_proposer_reward"` - BonusProposerReward sdk.Dec `json:"bonus_proposer_reward" yaml:"bonus_proposer_reward"` - WithdrawAddrEnabled bool `json:"withdraw_addr_enabled" yaml:"withdraw_addr_enabled"` -} - // ParamKeyTable returns the parameter key table. func ParamKeyTable() params.KeyTable { return params.NewKeyTable().RegisterParamSet(&Params{}) diff --git a/x/distribution/types/proposal.go b/x/distribution/types/proposal.go index 931e111ba719..db65da94286e 100644 --- a/x/distribution/types/proposal.go +++ b/x/distribution/types/proposal.go @@ -21,14 +21,6 @@ func init() { govtypes.RegisterProposalTypeCodec(CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal") } -// CommunityPoolSpendProposal spends from the community pool -type CommunityPoolSpendProposal struct { - Title string `json:"title" yaml:"title"` - Description string `json:"description" yaml:"description"` - Recipient sdk.AccAddress `json:"recipient" yaml:"recipient"` - Amount sdk.Coins `json:"amount" yaml:"amount"` -} - // NewCommunityPoolSpendProposal creates a new community pool spned proposal. func NewCommunityPoolSpendProposal(title, description string, recipient sdk.AccAddress, amount sdk.Coins) CommunityPoolSpendProposal { return CommunityPoolSpendProposal{title, description, recipient, amount} diff --git a/x/distribution/types/types.pb.go b/x/distribution/types/types.pb.go new file mode 100644 index 000000000000..21a6dfbee38d --- /dev/null +++ b/x/distribution/types/types.pb.go @@ -0,0 +1,3343 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: x/distribution/types/types.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "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 + +// msg struct for changing the withdraw address for a delegator (or validator self-delegation) +type MsgSetWithdrawAddress 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"` + WithdrawAddress github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=withdraw_address,json=withdrawAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"withdraw_address,omitempty" yaml:"withdraw_address"` +} + +func (m *MsgSetWithdrawAddress) Reset() { *m = MsgSetWithdrawAddress{} } +func (m *MsgSetWithdrawAddress) String() string { return proto.CompactTextString(m) } +func (*MsgSetWithdrawAddress) ProtoMessage() {} +func (*MsgSetWithdrawAddress) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{0} +} +func (m *MsgSetWithdrawAddress) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetWithdrawAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetWithdrawAddress.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 *MsgSetWithdrawAddress) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetWithdrawAddress.Merge(m, src) +} +func (m *MsgSetWithdrawAddress) XXX_Size() int { + return m.Size() +} +func (m *MsgSetWithdrawAddress) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetWithdrawAddress.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetWithdrawAddress proto.InternalMessageInfo + +func (m *MsgSetWithdrawAddress) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *MsgSetWithdrawAddress) GetWithdrawAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.WithdrawAddress + } + return nil +} + +// msg struct for delegation withdraw from a single validator +type MsgWithdrawDelegatorReward 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 *MsgWithdrawDelegatorReward) Reset() { *m = MsgWithdrawDelegatorReward{} } +func (m *MsgWithdrawDelegatorReward) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawDelegatorReward) ProtoMessage() {} +func (*MsgWithdrawDelegatorReward) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{1} +} +func (m *MsgWithdrawDelegatorReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawDelegatorReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawDelegatorReward.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 *MsgWithdrawDelegatorReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawDelegatorReward.Merge(m, src) +} +func (m *MsgWithdrawDelegatorReward) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawDelegatorReward) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawDelegatorReward.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawDelegatorReward proto.InternalMessageInfo + +func (m *MsgWithdrawDelegatorReward) GetDelegatorAddress() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.DelegatorAddress + } + return nil +} + +func (m *MsgWithdrawDelegatorReward) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorAddress + } + return nil +} + +// msg struct for validator withdraw +type MsgWithdrawValidatorCommission struct { + ValidatorAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,1,opt,name=validator_address,json=validatorAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"validator_address,omitempty" yaml:"validator_address"` +} + +func (m *MsgWithdrawValidatorCommission) Reset() { *m = MsgWithdrawValidatorCommission{} } +func (m *MsgWithdrawValidatorCommission) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawValidatorCommission) ProtoMessage() {} +func (*MsgWithdrawValidatorCommission) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{2} +} +func (m *MsgWithdrawValidatorCommission) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawValidatorCommission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawValidatorCommission.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 *MsgWithdrawValidatorCommission) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawValidatorCommission.Merge(m, src) +} +func (m *MsgWithdrawValidatorCommission) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawValidatorCommission) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawValidatorCommission.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawValidatorCommission proto.InternalMessageInfo + +func (m *MsgWithdrawValidatorCommission) GetValidatorAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValidatorAddress + } + return nil +} + +// MsgFundCommunityPool defines a Msg type that allows an account to directly +// fund the community pool. +type MsgFundCommunityPool struct { + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` + Depositor github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=depositor,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"depositor,omitempty"` +} + +func (m *MsgFundCommunityPool) Reset() { *m = MsgFundCommunityPool{} } +func (m *MsgFundCommunityPool) String() string { return proto.CompactTextString(m) } +func (*MsgFundCommunityPool) ProtoMessage() {} +func (*MsgFundCommunityPool) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{3} +} +func (m *MsgFundCommunityPool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgFundCommunityPool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgFundCommunityPool.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 *MsgFundCommunityPool) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgFundCommunityPool.Merge(m, src) +} +func (m *MsgFundCommunityPool) XXX_Size() int { + return m.Size() +} +func (m *MsgFundCommunityPool) XXX_DiscardUnknown() { + xxx_messageInfo_MsgFundCommunityPool.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgFundCommunityPool proto.InternalMessageInfo + +func (m *MsgFundCommunityPool) GetAmount() github_com_cosmos_cosmos_sdk_types.Coins { + if m != nil { + return m.Amount + } + return nil +} + +func (m *MsgFundCommunityPool) GetDepositor() github_com_cosmos_cosmos_sdk_types.AccAddress { + if m != nil { + return m.Depositor + } + return nil +} + +// Params defines the set of distribution parameters. +type Params struct { + CommunityTax github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=community_tax,json=communityTax,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"community_tax" yaml:"community_tax"` + BaseProposerReward github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=base_proposer_reward,json=baseProposerReward,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"base_proposer_reward" yaml:"base_proposer_reward"` + BonusProposerReward github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=bonus_proposer_reward,json=bonusProposerReward,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"bonus_proposer_reward" yaml:"bonus_proposer_reward"` + WithdrawAddrEnabled bool `protobuf:"varint,4,opt,name=withdraw_addr_enabled,json=withdrawAddrEnabled,proto3" json:"withdraw_addr_enabled,omitempty" yaml:"withdraw_addr_enabled"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{4} +} +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) GetWithdrawAddrEnabled() bool { + if m != nil { + return m.WithdrawAddrEnabled + } + return false +} + +// historical rewards for a validator +// height is implicit within the store key +// cumulative reward ratio is the sum from the zeroeth period +// until this period of rewards / tokens, per the spec +// The reference count indicates the number of objects +// which might need to reference this historical entry +// at any point. +// ReferenceCount = +// number of outstanding delegations which ended the associated period (and might need to read +// that record) +// + number of slashes which ended the associated period (and might need to read that record) +// + one per validator for the zeroeth period, set on initialization +type ValidatorHistoricalRewards struct { + CumulativeRewardRatio github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=cumulative_reward_ratio,json=cumulativeRewardRatio,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"cumulative_reward_ratio" yaml:"cumulative_reward_ratio"` + ReferenceCount uint32 `protobuf:"varint,2,opt,name=reference_count,json=referenceCount,proto3" json:"reference_count,omitempty" yaml:"reference_count"` +} + +func (m *ValidatorHistoricalRewards) Reset() { *m = ValidatorHistoricalRewards{} } +func (m *ValidatorHistoricalRewards) String() string { return proto.CompactTextString(m) } +func (*ValidatorHistoricalRewards) ProtoMessage() {} +func (*ValidatorHistoricalRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{5} +} +func (m *ValidatorHistoricalRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorHistoricalRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorHistoricalRewards.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 *ValidatorHistoricalRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorHistoricalRewards.Merge(m, src) +} +func (m *ValidatorHistoricalRewards) XXX_Size() int { + return m.Size() +} +func (m *ValidatorHistoricalRewards) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorHistoricalRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorHistoricalRewards proto.InternalMessageInfo + +func (m *ValidatorHistoricalRewards) GetCumulativeRewardRatio() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.CumulativeRewardRatio + } + return nil +} + +func (m *ValidatorHistoricalRewards) GetReferenceCount() uint32 { + if m != nil { + return m.ReferenceCount + } + return 0 +} + +// current rewards and current period for a validator +// kept as a running counter and incremented each block +// as long as the validator's tokens remain constant +type ValidatorCurrentRewards struct { + Rewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=rewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"rewards"` + Period uint64 `protobuf:"varint,2,opt,name=period,proto3" json:"period,omitempty"` +} + +func (m *ValidatorCurrentRewards) Reset() { *m = ValidatorCurrentRewards{} } +func (m *ValidatorCurrentRewards) String() string { return proto.CompactTextString(m) } +func (*ValidatorCurrentRewards) ProtoMessage() {} +func (*ValidatorCurrentRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{6} +} +func (m *ValidatorCurrentRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorCurrentRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorCurrentRewards.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 *ValidatorCurrentRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorCurrentRewards.Merge(m, src) +} +func (m *ValidatorCurrentRewards) XXX_Size() int { + return m.Size() +} +func (m *ValidatorCurrentRewards) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorCurrentRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorCurrentRewards proto.InternalMessageInfo + +func (m *ValidatorCurrentRewards) GetRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Rewards + } + return nil +} + +func (m *ValidatorCurrentRewards) GetPeriod() uint64 { + if m != nil { + return m.Period + } + return 0 +} + +// accumulated commission for a validator +// kept as a running counter, can be withdrawn at any time +type ValidatorAccumulatedCommission struct { + Commission github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=commission,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"commission"` +} + +func (m *ValidatorAccumulatedCommission) Reset() { *m = ValidatorAccumulatedCommission{} } +func (m *ValidatorAccumulatedCommission) String() string { return proto.CompactTextString(m) } +func (*ValidatorAccumulatedCommission) ProtoMessage() {} +func (*ValidatorAccumulatedCommission) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{7} +} +func (m *ValidatorAccumulatedCommission) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorAccumulatedCommission) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorAccumulatedCommission.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 *ValidatorAccumulatedCommission) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorAccumulatedCommission.Merge(m, src) +} +func (m *ValidatorAccumulatedCommission) XXX_Size() int { + return m.Size() +} +func (m *ValidatorAccumulatedCommission) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorAccumulatedCommission.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorAccumulatedCommission proto.InternalMessageInfo + +func (m *ValidatorAccumulatedCommission) GetCommission() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Commission + } + return nil +} + +// outstanding (un-withdrawn) rewards for a validator +// inexpensive to track, allows simple sanity checks +type ValidatorOutstandingRewards struct { + Rewards github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=rewards,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"rewards" yaml:"rewards"` +} + +func (m *ValidatorOutstandingRewards) Reset() { *m = ValidatorOutstandingRewards{} } +func (m *ValidatorOutstandingRewards) String() string { return proto.CompactTextString(m) } +func (*ValidatorOutstandingRewards) ProtoMessage() {} +func (*ValidatorOutstandingRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{8} +} +func (m *ValidatorOutstandingRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorOutstandingRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorOutstandingRewards.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 *ValidatorOutstandingRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorOutstandingRewards.Merge(m, src) +} +func (m *ValidatorOutstandingRewards) XXX_Size() int { + return m.Size() +} +func (m *ValidatorOutstandingRewards) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorOutstandingRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorOutstandingRewards proto.InternalMessageInfo + +func (m *ValidatorOutstandingRewards) GetRewards() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.Rewards + } + return nil +} + +// validator slash event +// height is implicit within the store key +// needed to calculate appropriate amounts of staking token +// for delegations which withdraw after a slash has occurred +type ValidatorSlashEvent struct { + ValidatorPeriod uint64 `protobuf:"varint,1,opt,name=validator_period,json=validatorPeriod,proto3" json:"validator_period,omitempty" yaml:"validator_period"` + Fraction github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=fraction,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fraction"` +} + +func (m *ValidatorSlashEvent) Reset() { *m = ValidatorSlashEvent{} } +func (m *ValidatorSlashEvent) String() string { return proto.CompactTextString(m) } +func (*ValidatorSlashEvent) ProtoMessage() {} +func (*ValidatorSlashEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{9} +} +func (m *ValidatorSlashEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorSlashEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorSlashEvent.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 *ValidatorSlashEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorSlashEvent.Merge(m, src) +} +func (m *ValidatorSlashEvent) XXX_Size() int { + return m.Size() +} +func (m *ValidatorSlashEvent) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorSlashEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorSlashEvent proto.InternalMessageInfo + +func (m *ValidatorSlashEvent) GetValidatorPeriod() uint64 { + if m != nil { + return m.ValidatorPeriod + } + return 0 +} + +// ValidatorSlashEvents is a collection of ValidatorSlashEvent +type ValidatorSlashEvents struct { + ValidatorSlashEvents []ValidatorSlashEvent `protobuf:"bytes,1,rep,name=validator_slash_events,json=validatorSlashEvents,proto3" json:"validator_slash_events" yaml:"validator_slash_events"` +} + +func (m *ValidatorSlashEvents) Reset() { *m = ValidatorSlashEvents{} } +func (*ValidatorSlashEvents) ProtoMessage() {} +func (*ValidatorSlashEvents) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{10} +} +func (m *ValidatorSlashEvents) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ValidatorSlashEvents) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ValidatorSlashEvents.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 *ValidatorSlashEvents) XXX_Merge(src proto.Message) { + xxx_messageInfo_ValidatorSlashEvents.Merge(m, src) +} +func (m *ValidatorSlashEvents) XXX_Size() int { + return m.Size() +} +func (m *ValidatorSlashEvents) XXX_DiscardUnknown() { + xxx_messageInfo_ValidatorSlashEvents.DiscardUnknown(m) +} + +var xxx_messageInfo_ValidatorSlashEvents proto.InternalMessageInfo + +func (m *ValidatorSlashEvents) GetValidatorSlashEvents() []ValidatorSlashEvent { + if m != nil { + return m.ValidatorSlashEvents + } + return nil +} + +// global fee pool for distribution +type FeePool struct { + CommunityPool github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=community_pool,json=communityPool,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"community_pool" yaml:"community_pool"` +} + +func (m *FeePool) Reset() { *m = FeePool{} } +func (m *FeePool) String() string { return proto.CompactTextString(m) } +func (*FeePool) ProtoMessage() {} +func (*FeePool) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{11} +} +func (m *FeePool) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *FeePool) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_FeePool.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 *FeePool) XXX_Merge(src proto.Message) { + xxx_messageInfo_FeePool.Merge(m, src) +} +func (m *FeePool) XXX_Size() int { + return m.Size() +} +func (m *FeePool) XXX_DiscardUnknown() { + xxx_messageInfo_FeePool.DiscardUnknown(m) +} + +var xxx_messageInfo_FeePool proto.InternalMessageInfo + +func (m *FeePool) GetCommunityPool() github_com_cosmos_cosmos_sdk_types.DecCoins { + if m != nil { + return m.CommunityPool + } + return nil +} + +// CommunityPoolSpendProposal spends from the community pool +type CommunityPoolSpendProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + Recipient github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,3,opt,name=recipient,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"recipient,omitempty"` + Amount github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,4,rep,name=amount,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"amount"` +} + +func (m *CommunityPoolSpendProposal) Reset() { *m = CommunityPoolSpendProposal{} } +func (*CommunityPoolSpendProposal) ProtoMessage() {} +func (*CommunityPoolSpendProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{12} +} +func (m *CommunityPoolSpendProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CommunityPoolSpendProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CommunityPoolSpendProposal.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 *CommunityPoolSpendProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_CommunityPoolSpendProposal.Merge(m, src) +} +func (m *CommunityPoolSpendProposal) XXX_Size() int { + return m.Size() +} +func (m *CommunityPoolSpendProposal) XXX_DiscardUnknown() { + xxx_messageInfo_CommunityPoolSpendProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_CommunityPoolSpendProposal proto.InternalMessageInfo + +// starting info for a delegator reward period +// tracks the previous validator period, the delegation's amount +// of staking token, and the creation height (to check later on +// if any slashes have occurred) +// NOTE that even though validators are slashed to whole staking tokens, the +// delegators within the validator may be left with less than a full token, +// thus sdk.Dec is used +type DelegatorStartingInfo struct { + PreviousPeriod uint64 `protobuf:"varint,1,opt,name=previous_period,json=previousPeriod,proto3" json:"previous_period,omitempty" yaml:"previous_period"` + Stake github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=stake,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stake" yaml:"stake"` + Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"creation_height" yaml:"creation_height"` +} + +func (m *DelegatorStartingInfo) Reset() { *m = DelegatorStartingInfo{} } +func (m *DelegatorStartingInfo) String() string { return proto.CompactTextString(m) } +func (*DelegatorStartingInfo) ProtoMessage() {} +func (*DelegatorStartingInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_9fddf2a8e4a90b09, []int{13} +} +func (m *DelegatorStartingInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DelegatorStartingInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DelegatorStartingInfo.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 *DelegatorStartingInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_DelegatorStartingInfo.Merge(m, src) +} +func (m *DelegatorStartingInfo) XXX_Size() int { + return m.Size() +} +func (m *DelegatorStartingInfo) XXX_DiscardUnknown() { + xxx_messageInfo_DelegatorStartingInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_DelegatorStartingInfo proto.InternalMessageInfo + +func (m *DelegatorStartingInfo) GetPreviousPeriod() uint64 { + if m != nil { + return m.PreviousPeriod + } + return 0 +} + +func (m *DelegatorStartingInfo) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func init() { + proto.RegisterType((*MsgSetWithdrawAddress)(nil), "cosmos_sdk.x.ditribution.v1.MsgSetWithdrawAddress") + proto.RegisterType((*MsgWithdrawDelegatorReward)(nil), "cosmos_sdk.x.ditribution.v1.MsgWithdrawDelegatorReward") + proto.RegisterType((*MsgWithdrawValidatorCommission)(nil), "cosmos_sdk.x.ditribution.v1.MsgWithdrawValidatorCommission") + proto.RegisterType((*MsgFundCommunityPool)(nil), "cosmos_sdk.x.ditribution.v1.MsgFundCommunityPool") + proto.RegisterType((*Params)(nil), "cosmos_sdk.x.ditribution.v1.Params") + proto.RegisterType((*ValidatorHistoricalRewards)(nil), "cosmos_sdk.x.ditribution.v1.ValidatorHistoricalRewards") + proto.RegisterType((*ValidatorCurrentRewards)(nil), "cosmos_sdk.x.ditribution.v1.ValidatorCurrentRewards") + proto.RegisterType((*ValidatorAccumulatedCommission)(nil), "cosmos_sdk.x.ditribution.v1.ValidatorAccumulatedCommission") + proto.RegisterType((*ValidatorOutstandingRewards)(nil), "cosmos_sdk.x.ditribution.v1.ValidatorOutstandingRewards") + proto.RegisterType((*ValidatorSlashEvent)(nil), "cosmos_sdk.x.ditribution.v1.ValidatorSlashEvent") + proto.RegisterType((*ValidatorSlashEvents)(nil), "cosmos_sdk.x.ditribution.v1.ValidatorSlashEvents") + proto.RegisterType((*FeePool)(nil), "cosmos_sdk.x.ditribution.v1.FeePool") + proto.RegisterType((*CommunityPoolSpendProposal)(nil), "cosmos_sdk.x.ditribution.v1.CommunityPoolSpendProposal") + proto.RegisterType((*DelegatorStartingInfo)(nil), "cosmos_sdk.x.ditribution.v1.DelegatorStartingInfo") +} + +func init() { proto.RegisterFile("x/distribution/types/types.proto", fileDescriptor_9fddf2a8e4a90b09) } + +var fileDescriptor_9fddf2a8e4a90b09 = []byte{ + // 1110 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x57, 0xcf, 0x6f, 0x1b, 0x45, + 0x1b, 0xf6, 0x38, 0x4e, 0x9a, 0x4c, 0xd3, 0xa4, 0xd9, 0xd8, 0x49, 0xe4, 0x7c, 0x9f, 0xd7, 0x1a, + 0x89, 0x2a, 0x12, 0x8a, 0xd3, 0xd0, 0x5b, 0x0e, 0x48, 0x71, 0x7e, 0x08, 0x50, 0x43, 0xa3, 0x4d, + 0x28, 0x12, 0x12, 0x5a, 0x8d, 0x77, 0x27, 0xf6, 0x28, 0xeb, 0x9d, 0xd5, 0xcc, 0xd8, 0x4e, 0x7a, + 0x41, 0xe2, 0x04, 0x82, 0x22, 0x0e, 0x08, 0x7a, 0xe0, 0xd0, 0x0b, 0x07, 0x2a, 0xfe, 0x0e, 0xd4, + 0x63, 0x6f, 0x20, 0x0e, 0x2e, 0x4a, 0x6e, 0x1c, 0x73, 0x83, 0x13, 0xda, 0x9d, 0xd9, 0x5d, 0xc7, + 0xb1, 0xa8, 0x1d, 0xa9, 0x70, 0x49, 0x32, 0xef, 0xbc, 0xf3, 0x3c, 0xcf, 0x3c, 0x33, 0xf3, 0xbe, + 0x1b, 0x58, 0x3e, 0x59, 0x73, 0xa9, 0x90, 0x9c, 0xd6, 0x5a, 0x92, 0x32, 0x7f, 0x4d, 0x9e, 0x06, + 0x44, 0xa8, 0x9f, 0x95, 0x80, 0x33, 0xc9, 0x8c, 0x65, 0x87, 0x89, 0x26, 0x13, 0xb6, 0x70, 0x8f, + 0x2b, 0x27, 0x15, 0x97, 0x26, 0xb9, 0x95, 0xf6, 0x7a, 0xf1, 0x8e, 0x6c, 0x50, 0xee, 0xda, 0x01, + 0xe6, 0xf2, 0x74, 0x2d, 0xca, 0x5f, 0xab, 0xb3, 0x3a, 0x4b, 0xff, 0x52, 0x20, 0xc5, 0xb9, 0x2b, + 0xb8, 0xe8, 0xcb, 0x2c, 0x2c, 0xec, 0x89, 0xfa, 0x01, 0x91, 0x1f, 0x52, 0xd9, 0x70, 0x39, 0xee, + 0x6c, 0xba, 0x2e, 0x27, 0x42, 0x18, 0x8f, 0xe0, 0x9c, 0x4b, 0x3c, 0x52, 0xc7, 0x92, 0x71, 0x1b, + 0xab, 0xe0, 0x12, 0x28, 0x83, 0x95, 0xe9, 0xea, 0xde, 0x45, 0xd7, 0x5c, 0x3a, 0xc5, 0x4d, 0x6f, + 0x03, 0x5d, 0x49, 0x41, 0x7f, 0x75, 0xcd, 0xd5, 0x3a, 0x95, 0x8d, 0x56, 0xad, 0xe2, 0xb0, 0xe6, + 0x9a, 0xd2, 0xad, 0x7f, 0xad, 0x0a, 0xf7, 0x58, 0xd3, 0x6f, 0x3a, 0x8e, 0x66, 0xb2, 0x6e, 0x27, + 0x20, 0x31, 0x77, 0x07, 0xde, 0xee, 0x68, 0x39, 0x09, 0x75, 0x36, 0xa2, 0xbe, 0x7f, 0xd1, 0x35, + 0x17, 0x15, 0x75, 0x7f, 0xc6, 0x35, 0x98, 0x67, 0x3b, 0x97, 0x37, 0x8d, 0xbe, 0xc9, 0xc2, 0xe2, + 0x9e, 0xa8, 0xc7, 0x5e, 0x6c, 0xc7, 0xc2, 0x2c, 0xd2, 0xc1, 0xdc, 0xfd, 0x4f, 0x3d, 0x79, 0x04, + 0xe7, 0xda, 0xd8, 0xa3, 0xee, 0x25, 0xee, 0x6c, 0x3f, 0xf7, 0x95, 0x94, 0x61, 0xb9, 0x1f, 0x62, + 0x2f, 0xe1, 0x4e, 0x40, 0x62, 0x5b, 0xbe, 0x07, 0xb0, 0xd4, 0x63, 0xcb, 0xc3, 0x78, 0x7e, 0x8b, + 0x35, 0x9b, 0x54, 0x08, 0xca, 0xfc, 0xc1, 0xf2, 0xc0, 0xbf, 0x23, 0xef, 0x67, 0x00, 0xf3, 0x7b, + 0xa2, 0xbe, 0xdb, 0xf2, 0xdd, 0x50, 0x51, 0xcb, 0xa7, 0xf2, 0x74, 0x9f, 0x31, 0xcf, 0xf8, 0x18, + 0x4e, 0xe0, 0x26, 0x6b, 0xf9, 0x72, 0x09, 0x94, 0xc7, 0x56, 0x6e, 0xbe, 0x35, 0x5f, 0xe9, 0x79, + 0x46, 0xed, 0xf5, 0xca, 0x16, 0xa3, 0x7e, 0xf5, 0xee, 0xf3, 0xae, 0x99, 0x79, 0xf6, 0xd2, 0x5c, + 0x19, 0x42, 0x46, 0xb8, 0x40, 0x58, 0x1a, 0xd4, 0x78, 0x00, 0xa7, 0x5c, 0x12, 0x30, 0x41, 0x25, + 0xe3, 0xfa, 0x28, 0xd6, 0x47, 0x3f, 0xea, 0x14, 0x03, 0xfd, 0x32, 0x06, 0x27, 0xf6, 0x31, 0xc7, + 0x4d, 0x61, 0x1c, 0xc3, 0x5b, 0x4e, 0xbc, 0x17, 0x5b, 0xe2, 0x93, 0xc8, 0xcb, 0xa9, 0xea, 0x6e, + 0x28, 0xf6, 0xb7, 0xae, 0x79, 0x67, 0x08, 0x8e, 0x6d, 0xe2, 0x5c, 0x74, 0xcd, 0xbc, 0x72, 0xfe, + 0x12, 0x18, 0xb2, 0xa6, 0x93, 0xf1, 0x21, 0x3e, 0x31, 0x3e, 0x81, 0xf9, 0x1a, 0x16, 0xc4, 0x0e, + 0x38, 0x0b, 0x98, 0x20, 0xdc, 0xe6, 0xd1, 0x7d, 0x8f, 0xf6, 0x34, 0x55, 0xdd, 0x1b, 0x99, 0x73, + 0x59, 0x71, 0x0e, 0xc2, 0x44, 0x96, 0x11, 0x86, 0xf7, 0x75, 0x54, 0x3f, 0xac, 0x4f, 0x01, 0x2c, + 0xd4, 0x98, 0xdf, 0x12, 0x57, 0x24, 0x8c, 0x45, 0x12, 0xde, 0x1f, 0x59, 0xc2, 0xff, 0xb4, 0x84, + 0x41, 0xa0, 0xc8, 0x9a, 0x8f, 0xe2, 0x7d, 0x22, 0x0e, 0x61, 0xe1, 0x52, 0x4d, 0xb1, 0x89, 0x8f, + 0x6b, 0x1e, 0x71, 0x97, 0x72, 0x65, 0xb0, 0x32, 0x59, 0x2d, 0xa7, 0xa8, 0x03, 0xd3, 0x90, 0x35, + 0xdf, 0x5b, 0x4e, 0x76, 0x54, 0x74, 0x23, 0xf7, 0xe4, 0xa9, 0x99, 0x41, 0x9f, 0x67, 0x61, 0x31, + 0x79, 0x36, 0xef, 0x50, 0x21, 0x19, 0xa7, 0x0e, 0xf6, 0x14, 0xb3, 0x30, 0x7e, 0x00, 0x70, 0xd1, + 0x69, 0x35, 0x5b, 0x1e, 0x96, 0xb4, 0x4d, 0xb4, 0x4c, 0x9b, 0x63, 0x49, 0x99, 0xbe, 0xba, 0x0b, + 0x7d, 0x57, 0x77, 0x9b, 0x38, 0xd1, 0xed, 0xfd, 0x20, 0x74, 0xe6, 0xa2, 0x6b, 0x96, 0xf4, 0x31, + 0x0f, 0x06, 0x41, 0xcf, 0x5e, 0x9a, 0x6f, 0x0e, 0xe7, 0x9d, 0xba, 0xe2, 0x85, 0x14, 0x48, 0x69, + 0xb4, 0x42, 0x18, 0x63, 0x0b, 0xce, 0x72, 0x72, 0x44, 0x38, 0xf1, 0x1d, 0x62, 0x3b, 0xd1, 0xcb, + 0x0a, 0xef, 0xc8, 0xad, 0x6a, 0xf1, 0xa2, 0x6b, 0x2e, 0x28, 0x09, 0x7d, 0x09, 0xc8, 0x9a, 0x49, + 0x22, 0x5b, 0x51, 0xe0, 0x09, 0x80, 0x8b, 0x69, 0x09, 0x69, 0x71, 0x4e, 0x7c, 0x19, 0x1b, 0x41, + 0xe0, 0x0d, 0xa5, 0x5b, 0xbc, 0x62, 0xdf, 0xf7, 0xf4, 0xab, 0x1d, 0x69, 0x57, 0x31, 0xb6, 0xb1, + 0x00, 0x27, 0x02, 0xc2, 0x29, 0x53, 0x57, 0x3c, 0x67, 0xe9, 0x11, 0x7a, 0x0c, 0x60, 0x29, 0x91, + 0xb6, 0xe9, 0x68, 0x13, 0x88, 0xdb, 0x53, 0xe8, 0x8e, 0x21, 0x74, 0x92, 0xd1, 0xeb, 0x10, 0xd9, + 0x03, 0x8f, 0xbe, 0x05, 0x70, 0x39, 0xd1, 0xf3, 0xa0, 0x25, 0x85, 0xc4, 0xbe, 0x4b, 0xfd, 0x7a, + 0x6c, 0x57, 0x67, 0x58, 0xbb, 0x76, 0xf4, 0x35, 0x99, 0x89, 0xcf, 0x28, 0x5a, 0x84, 0xae, 0x6b, + 0x20, 0xfa, 0x11, 0xc0, 0xf9, 0x44, 0xd8, 0x81, 0x87, 0x45, 0x63, 0xa7, 0x4d, 0x7c, 0x69, 0xec, + 0xc2, 0xb4, 0x3c, 0xdb, 0xda, 0xe2, 0xb0, 0x72, 0xe5, 0xaa, 0xcb, 0x69, 0xe7, 0xee, 0xcf, 0x40, + 0xd6, 0x6c, 0x12, 0xda, 0x8f, 0x22, 0xc6, 0x7b, 0x70, 0xf2, 0x88, 0x63, 0x27, 0xfc, 0xc2, 0xd1, + 0x55, 0xa8, 0x32, 0x5a, 0x09, 0xb0, 0x92, 0xf5, 0xe8, 0x27, 0x00, 0xf3, 0x03, 0xb4, 0x0a, 0xe3, + 0x31, 0x80, 0x0b, 0xa9, 0x16, 0x11, 0xce, 0xd8, 0x24, 0x9a, 0xd2, 0x6e, 0xde, 0xad, 0xfc, 0xc3, + 0x67, 0x57, 0x65, 0x00, 0x66, 0xf5, 0x0d, 0xed, 0xf3, 0xff, 0xfb, 0x77, 0xda, 0x8b, 0x8e, 0xac, + 0x7c, 0x7b, 0x80, 0x1e, 0x5d, 0x2a, 0xbe, 0x03, 0xf0, 0xc6, 0x2e, 0x21, 0x51, 0x03, 0xfb, 0x02, + 0xc0, 0x99, 0xb4, 0x72, 0x07, 0x8c, 0x79, 0xaf, 0x38, 0xe7, 0xfb, 0x9a, 0xbf, 0xd0, 0x5f, 0xf5, + 0xc3, 0xb5, 0x23, 0x1f, 0x77, 0xda, 0x82, 0x42, 0x35, 0xe8, 0xab, 0x2c, 0x2c, 0x5e, 0x6a, 0xb0, + 0x07, 0x01, 0xf1, 0x5d, 0x55, 0x45, 0xb1, 0x67, 0xe4, 0xe1, 0xb8, 0xa4, 0xd2, 0x23, 0xaa, 0x55, + 0x59, 0x6a, 0x60, 0x94, 0xe1, 0x4d, 0x97, 0x08, 0x87, 0xd3, 0x20, 0x3d, 0x4c, 0xab, 0x37, 0x14, + 0xb6, 0x51, 0x4e, 0x1c, 0x1a, 0x50, 0xe2, 0xcb, 0xa8, 0xde, 0x5f, 0xaf, 0x8d, 0x26, 0x18, 0x3d, + 0x6d, 0x3f, 0xf7, 0x1a, 0xda, 0xfe, 0xc6, 0xe4, 0x67, 0x4f, 0xcd, 0x4c, 0x74, 0x54, 0x7f, 0x02, + 0x58, 0x48, 0xbe, 0x11, 0x0f, 0x24, 0xe6, 0x92, 0xfa, 0xf5, 0x77, 0xfd, 0xa3, 0xa8, 0x50, 0x06, + 0x9c, 0xb4, 0x29, 0x0b, 0xbb, 0x4f, 0xef, 0x33, 0xe8, 0x29, 0x94, 0x7d, 0x09, 0xc8, 0x9a, 0x89, + 0x23, 0xfa, 0x11, 0x1c, 0xc2, 0x71, 0x21, 0xf1, 0x31, 0xd1, 0x2f, 0xe0, 0xed, 0x91, 0x9b, 0xe0, + 0xb4, 0x22, 0x8a, 0x40, 0x90, 0xa5, 0xc0, 0x8c, 0x1d, 0x38, 0xd1, 0x20, 0xb4, 0xde, 0x50, 0x5e, + 0xe7, 0xaa, 0xab, 0x7f, 0x74, 0xcd, 0x59, 0x87, 0x93, 0xb0, 0xc0, 0xfb, 0xb6, 0x9a, 0x4a, 0x45, + 0xf6, 0x4d, 0x20, 0x4b, 0x2f, 0xae, 0x9a, 0xcf, 0xcf, 0x4a, 0xe0, 0xc5, 0x59, 0x09, 0xfc, 0x7e, + 0x56, 0x02, 0x5f, 0x9f, 0x97, 0x32, 0x2f, 0xce, 0x4b, 0x99, 0x5f, 0xcf, 0x4b, 0x99, 0x8f, 0xc6, + 0x23, 0x09, 0xb5, 0x89, 0xe8, 0x3f, 0x8c, 0x7b, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x2c, 0xac, + 0x10, 0x4b, 0xdd, 0x0c, 0x00, 0x00, +} + +func (m *MsgSetWithdrawAddress) 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 *MsgSetWithdrawAddress) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetWithdrawAddress) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WithdrawAddress) > 0 { + i -= len(m.WithdrawAddress) + copy(dAtA[i:], m.WithdrawAddress) + i = encodeVarintTypes(dAtA, i, uint64(len(m.WithdrawAddress))) + 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 *MsgWithdrawDelegatorReward) 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 *MsgWithdrawDelegatorReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawDelegatorReward) 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 *MsgWithdrawValidatorCommission) 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 *MsgWithdrawValidatorCommission) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawValidatorCommission) 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgFundCommunityPool) 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 *MsgFundCommunityPool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgFundCommunityPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Depositor) > 0 { + i -= len(m.Depositor) + copy(dAtA[i:], m.Depositor) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Depositor))) + i-- + dAtA[i] = 0x12 + } + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[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 *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 m.WithdrawAddrEnabled { + i-- + if m.WithdrawAddrEnabled { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + { + size := m.BonusProposerReward.Size() + i -= size + if _, err := m.BonusProposerReward.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.BaseProposerReward.Size() + i -= size + if _, err := m.BaseProposerReward.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.CommunityTax.Size() + i -= size + if _, err := m.CommunityTax.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 *ValidatorHistoricalRewards) 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 *ValidatorHistoricalRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorHistoricalRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ReferenceCount != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ReferenceCount)) + i-- + dAtA[i] = 0x10 + } + if len(m.CumulativeRewardRatio) > 0 { + for iNdEx := len(m.CumulativeRewardRatio) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CumulativeRewardRatio[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 *ValidatorCurrentRewards) 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 *ValidatorCurrentRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorCurrentRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Period != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Period)) + i-- + dAtA[i] = 0x10 + } + if len(m.Rewards) > 0 { + for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Rewards[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 *ValidatorAccumulatedCommission) 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 *ValidatorAccumulatedCommission) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorAccumulatedCommission) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Commission) > 0 { + for iNdEx := len(m.Commission) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Commission[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 *ValidatorOutstandingRewards) 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 *ValidatorOutstandingRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorOutstandingRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Rewards) > 0 { + for iNdEx := len(m.Rewards) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Rewards[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 *ValidatorSlashEvent) 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 *ValidatorSlashEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorSlashEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Fraction.Size() + i -= size + if _, err := m.Fraction.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.ValidatorPeriod != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.ValidatorPeriod)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ValidatorSlashEvents) 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 *ValidatorSlashEvents) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ValidatorSlashEvents) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValidatorSlashEvents) > 0 { + for iNdEx := len(m.ValidatorSlashEvents) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ValidatorSlashEvents[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 *FeePool) 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 *FeePool) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FeePool) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.CommunityPool) > 0 { + for iNdEx := len(m.CommunityPool) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CommunityPool[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 *CommunityPoolSpendProposal) 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 *CommunityPoolSpendProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CommunityPoolSpendProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + for iNdEx := len(m.Amount) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Amount[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.Recipient) > 0 { + i -= len(m.Recipient) + copy(dAtA[i:], m.Recipient) + i = encodeVarintTypes(dAtA, i, uint64(len(m.Recipient))) + 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 *DelegatorStartingInfo) 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 *DelegatorStartingInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DelegatorStartingInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 + } + { + size := m.Stake.Size() + i -= size + if _, err := m.Stake.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTypes(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.PreviousPeriod != 0 { + i = encodeVarintTypes(dAtA, i, uint64(m.PreviousPeriod)) + i-- + dAtA[i] = 0x8 + } + 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 *MsgSetWithdrawAddress) 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.WithdrawAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgWithdrawDelegatorReward) 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 *MsgWithdrawValidatorCommission) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *MsgFundCommunityPool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + l = len(m.Depositor) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.CommunityTax.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.BaseProposerReward.Size() + n += 1 + l + sovTypes(uint64(l)) + l = m.BonusProposerReward.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.WithdrawAddrEnabled { + n += 2 + } + return n +} + +func (m *ValidatorHistoricalRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.CumulativeRewardRatio) > 0 { + for _, e := range m.CumulativeRewardRatio { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + if m.ReferenceCount != 0 { + n += 1 + sovTypes(uint64(m.ReferenceCount)) + } + return n +} + +func (m *ValidatorCurrentRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Rewards) > 0 { + for _, e := range m.Rewards { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + if m.Period != 0 { + n += 1 + sovTypes(uint64(m.Period)) + } + return n +} + +func (m *ValidatorAccumulatedCommission) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Commission) > 0 { + for _, e := range m.Commission { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *ValidatorOutstandingRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Rewards) > 0 { + for _, e := range m.Rewards { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *ValidatorSlashEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ValidatorPeriod != 0 { + n += 1 + sovTypes(uint64(m.ValidatorPeriod)) + } + l = m.Fraction.Size() + n += 1 + l + sovTypes(uint64(l)) + return n +} + +func (m *ValidatorSlashEvents) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.ValidatorSlashEvents) > 0 { + for _, e := range m.ValidatorSlashEvents { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *FeePool) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.CommunityPool) > 0 { + for _, e := range m.CommunityPool { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *CommunityPoolSpendProposal) 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)) + } + l = len(m.Recipient) + if l > 0 { + n += 1 + l + sovTypes(uint64(l)) + } + if len(m.Amount) > 0 { + for _, e := range m.Amount { + l = e.Size() + n += 1 + l + sovTypes(uint64(l)) + } + } + return n +} + +func (m *DelegatorStartingInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PreviousPeriod != 0 { + n += 1 + sovTypes(uint64(m.PreviousPeriod)) + } + l = m.Stake.Size() + n += 1 + l + sovTypes(uint64(l)) + if m.Height != 0 { + n += 1 + sovTypes(uint64(m.Height)) + } + 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 *MsgSetWithdrawAddress) 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: MsgSetWithdrawAddress: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetWithdrawAddress: 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 WithdrawAddress", 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.WithdrawAddress = append(m.WithdrawAddress[:0], dAtA[iNdEx:postIndex]...) + if m.WithdrawAddress == nil { + m.WithdrawAddress = []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 *MsgWithdrawDelegatorReward) 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: MsgWithdrawDelegatorReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawDelegatorReward: 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 *MsgWithdrawValidatorCommission) 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: MsgWithdrawValidatorCommission: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawValidatorCommission: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 *MsgFundCommunityPool) 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: MsgFundCommunityPool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgFundCommunityPool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Depositor", 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.Depositor = append(m.Depositor[:0], dAtA[iNdEx:postIndex]...) + if m.Depositor == nil { + m.Depositor = []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 *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 CommunityTax", 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.CommunityTax.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BaseProposerReward", 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.BaseProposerReward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BonusProposerReward", 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.BonusProposerReward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawAddrEnabled", 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.WithdrawAddrEnabled = bool(v != 0) + 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 *ValidatorHistoricalRewards) 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: ValidatorHistoricalRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorHistoricalRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CumulativeRewardRatio", 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.CumulativeRewardRatio = append(m.CumulativeRewardRatio, types.DecCoin{}) + if err := m.CumulativeRewardRatio[len(m.CumulativeRewardRatio)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReferenceCount", wireType) + } + m.ReferenceCount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReferenceCount |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *ValidatorCurrentRewards) 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: ValidatorCurrentRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorCurrentRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rewards", 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.Rewards = append(m.Rewards, types.DecCoin{}) + if err := m.Rewards[len(m.Rewards)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Period", wireType) + } + m.Period = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Period |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *ValidatorAccumulatedCommission) 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: ValidatorAccumulatedCommission: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorAccumulatedCommission: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 + } + m.Commission = append(m.Commission, types.DecCoin{}) + if err := m.Commission[len(m.Commission)-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 *ValidatorOutstandingRewards) 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: ValidatorOutstandingRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorOutstandingRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rewards", 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.Rewards = append(m.Rewards, types.DecCoin{}) + if err := m.Rewards[len(m.Rewards)-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 *ValidatorSlashEvent) 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: ValidatorSlashEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorSlashEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorPeriod", wireType) + } + m.ValidatorPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorPeriod |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Fraction", 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.Fraction.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 *ValidatorSlashEvents) 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: ValidatorSlashEvents: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ValidatorSlashEvents: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSlashEvents", 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.ValidatorSlashEvents = append(m.ValidatorSlashEvents, ValidatorSlashEvent{}) + if err := m.ValidatorSlashEvents[len(m.ValidatorSlashEvents)-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 *FeePool) 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: FeePool: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: FeePool: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommunityPool", 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.CommunityPool = append(m.CommunityPool, types.DecCoin{}) + if err := m.CommunityPool[len(m.CommunityPool)-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 *CommunityPoolSpendProposal) 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: CommunityPoolSpendProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CommunityPoolSpendProposal: 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 Recipient", 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.Recipient = append(m.Recipient[:0], dAtA[iNdEx:postIndex]...) + if m.Recipient == nil { + m.Recipient = []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 + } + m.Amount = append(m.Amount, types.Coin{}) + if err := m.Amount[len(m.Amount)-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 *DelegatorStartingInfo) 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: DelegatorStartingInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DelegatorStartingInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PreviousPeriod", wireType) + } + m.PreviousPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PreviousPeriod |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Stake", 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.Stake.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTypes + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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/distribution/types/types.proto b/x/distribution/types/types.proto new file mode 100644 index 000000000000..be398e09126a --- /dev/null +++ b/x/distribution/types/types.proto @@ -0,0 +1,182 @@ +syntax = "proto3"; +package cosmos_sdk.x.ditribution.v1; + +option go_package = "types"; + +import "third_party/proto/gogoproto/gogo.proto"; +import "types/types.proto"; + +// msg struct for changing the withdraw address for a delegator (or validator self-delegation) +message MsgSetWithdrawAddress { + bytes delegator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"delegator_address\"" + ]; + bytes withdraw_address = 2 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress", + (gogoproto.moretags) = "yaml:\"withdraw_address\"" + ]; +} + +// msg struct for delegation withdraw from a single validator +message MsgWithdrawDelegatorReward { + 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\"" + ]; +} + +// msg struct for validator withdraw +message MsgWithdrawValidatorCommission { + bytes validator_address = 1 [ + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress", + (gogoproto.moretags) = "yaml:\"validator_address\"" + ]; +} + +// MsgFundCommunityPool defines a Msg type that allows an account to directly +// fund the community pool. +message MsgFundCommunityPool { + repeated cosmos_sdk.v1.Coin amount = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + bytes depositor = 2 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; +} + +// Params defines the set of distribution parameters. +message Params { + option (gogoproto.goproto_stringer) = false; + string community_tax = 1 [ + (gogoproto.moretags) = "yaml:\"community_tax\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string base_proposer_reward = 2 [ + (gogoproto.moretags) = "yaml:\"base_proposer_reward\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string bonus_proposer_reward = 3 [ + (gogoproto.moretags) = "yaml:\"bonus_proposer_reward\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + bool withdraw_addr_enabled = 4 [(gogoproto.moretags) = "yaml:\"withdraw_addr_enabled\""]; +} + +// historical rewards for a validator +// height is implicit within the store key +// cumulative reward ratio is the sum from the zeroeth period +// until this period of rewards / tokens, per the spec +// The reference count indicates the number of objects +// which might need to reference this historical entry +// at any point. +// ReferenceCount = +// number of outstanding delegations which ended the associated period (and might need to read +// that record) +// + number of slashes which ended the associated period (and might need to read that record) +// + one per validator for the zeroeth period, set on initialization +message ValidatorHistoricalRewards { + repeated cosmos_sdk.v1.DecCoin cumulative_reward_ratio = 1 [ + (gogoproto.moretags) = "yaml:\"cumulative_reward_ratio\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; + uint32 reference_count = 2 [(gogoproto.moretags) = "yaml:\"reference_count\""]; +} + +// current rewards and current period for a validator +// kept as a running counter and incremented each block +// as long as the validator's tokens remain constant +message ValidatorCurrentRewards { + repeated cosmos_sdk.v1.DecCoin rewards = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; + uint64 period = 2; +} + +// accumulated commission for a validator +// kept as a running counter, can be withdrawn at any time +message ValidatorAccumulatedCommission { + repeated cosmos_sdk.v1.DecCoin commission = 1 [ + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; +} + +// outstanding (un-withdrawn) rewards for a validator +// inexpensive to track, allows simple sanity checks +message ValidatorOutstandingRewards { + repeated cosmos_sdk.v1.DecCoin rewards = 1 [ + (gogoproto.moretags) = "yaml:\"rewards\"", + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.nullable) = false + ]; +} + +// validator slash event +// height is implicit within the store key +// needed to calculate appropriate amounts of staking token +// for delegations which withdraw after a slash has occurred +message ValidatorSlashEvent { + uint64 validator_period = 1 [(gogoproto.moretags) = "yaml:\"validator_period\""]; + string fraction = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + +// ValidatorSlashEvents is a collection of ValidatorSlashEvent +message ValidatorSlashEvents { + option (gogoproto.goproto_stringer) = false; + repeated ValidatorSlashEvent validator_slash_events = 1 + [(gogoproto.moretags) = "yaml:\"validator_slash_events\"", (gogoproto.nullable) = false]; +} + +// global fee pool for distribution +message FeePool { + repeated cosmos_sdk.v1.DecCoin community_pool = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", + (gogoproto.moretags) = "yaml:\"community_pool\"" + ]; +} + +// CommunityPoolSpendProposal spends from the community pool +message CommunityPoolSpendProposal { + option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; + string title = 1; + string description = 2; + bytes recipient = 3 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"]; + repeated cosmos_sdk.v1.Coin amount = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// starting info for a delegator reward period +// tracks the previous validator period, the delegation's amount +// of staking token, and the creation height (to check later on +// if any slashes have occurred) +// NOTE that even though validators are slashed to whole staking tokens, the +// delegators within the validator may be left with less than a full token, +// thus sdk.Dec is used +message DelegatorStartingInfo { + uint64 previous_period = 1 [(gogoproto.moretags) = "yaml:\"previous_period\""]; + string stake = 2 [ + (gogoproto.moretags) = "yaml:\"stake\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + uint64 height = 3 [ + (gogoproto.moretags) = "yaml:\"creation_height\"", + (gogoproto.jsontag) = "creation_height" + ]; +} diff --git a/x/distribution/types/validator.go b/x/distribution/types/validator.go index 9ff1f4c9aa1f..aa64a3703068 100644 --- a/x/distribution/types/validator.go +++ b/x/distribution/types/validator.go @@ -7,38 +7,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// historical rewards for a validator -// height is implicit within the store key -// cumulative reward ratio is the sum from the zeroeth period -// until this period of rewards / tokens, per the spec -// The reference count indicates the number of objects -// which might need to reference this historical entry -// at any point. -// ReferenceCount = -// number of outstanding delegations which ended the associated period (and might need to read that record) -// + number of slashes which ended the associated period (and might need to read that record) -// + one per validator for the zeroeth period, set on initialization -type ValidatorHistoricalRewards struct { - CumulativeRewardRatio sdk.DecCoins `json:"cumulative_reward_ratio" yaml:"cumulative_reward_ratio"` - ReferenceCount uint16 `json:"reference_count" yaml:"reference_count"` -} - // create a new ValidatorHistoricalRewards -func NewValidatorHistoricalRewards(cumulativeRewardRatio sdk.DecCoins, referenceCount uint16) ValidatorHistoricalRewards { +func NewValidatorHistoricalRewards(cumulativeRewardRatio sdk.DecCoins, referenceCount uint32) ValidatorHistoricalRewards { return ValidatorHistoricalRewards{ CumulativeRewardRatio: cumulativeRewardRatio, ReferenceCount: referenceCount, } } -// current rewards and current period for a validator -// kept as a running counter and incremented each block -// as long as the validator's tokens remain constant -type ValidatorCurrentRewards struct { - Rewards sdk.DecCoins `json:"rewards" yaml:"rewards"` // current rewards - Period uint64 `json:"period" yaml:"period"` // current period -} - // create a new ValidatorCurrentRewards func NewValidatorCurrentRewards(rewards sdk.DecCoins, period uint64) ValidatorCurrentRewards { return ValidatorCurrentRewards{ @@ -47,24 +23,11 @@ func NewValidatorCurrentRewards(rewards sdk.DecCoins, period uint64) ValidatorCu } } -// accumulated commission for a validator -// kept as a running counter, can be withdrawn at any time -type ValidatorAccumulatedCommission = sdk.DecCoins - // return the initial accumulated commission (zero) func InitialValidatorAccumulatedCommission() ValidatorAccumulatedCommission { return ValidatorAccumulatedCommission{} } -// validator slash event -// height is implicit within the store key -// needed to calculate appropriate amounts of staking token -// for delegations which withdraw after a slash has occurred -type ValidatorSlashEvent struct { - ValidatorPeriod uint64 `json:"validator_period" yaml:"validator_period"` // period when the slash occurred - Fraction sdk.Dec `json:"fraction" yaml:"fraction"` // slash fraction -} - // create a new ValidatorSlashEvent func NewValidatorSlashEvent(validatorPeriod uint64, fraction sdk.Dec) ValidatorSlashEvent { return ValidatorSlashEvent{ @@ -73,17 +36,9 @@ func NewValidatorSlashEvent(validatorPeriod uint64, fraction sdk.Dec) ValidatorS } } -func (vs ValidatorSlashEvent) String() string { - return fmt.Sprintf(`Period: %d -Fraction: %s`, vs.ValidatorPeriod, vs.Fraction) -} - -// ValidatorSlashEvents is a collection of ValidatorSlashEvent -type ValidatorSlashEvents []ValidatorSlashEvent - func (vs ValidatorSlashEvents) String() string { out := "Validator Slash Events:\n" - for i, sl := range vs { + for i, sl := range vs.ValidatorSlashEvents { out += fmt.Sprintf(` Slash %d: Period: %d Fraction: %s @@ -91,7 +46,3 @@ func (vs ValidatorSlashEvents) String() string { } return strings.TrimSpace(out) } - -// outstanding (un-withdrawn) rewards for a validator -// inexpensive to track, allows simple sanity checks -type ValidatorOutstandingRewards = sdk.DecCoins