Merge PR #5634: Protobuf - Migrate x/evidence
This commit is contained in:
parent
e3dc0fd4a6
commit
f7486b9395
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -115,6 +115,17 @@ serialization instead of Amino.
|
|||
requiring a concrete codec to know how to serialize `SupplyI` types.
|
||||
* The `SupplyI` interface has been modified to no longer return `SupplyI` on methods. Instead the
|
||||
concrete type's receiver should modify the type.
|
||||
* (x/mint) [\#5634](https://github.com/cosmos/cosmos-sdk/pull/5634) Migrate the `x/mint` module to use Protocol Buffers for state
|
||||
serialization instead of Amino.
|
||||
* The `internal` sub-package has been removed in order to expose the types proto file.
|
||||
* (x/evidence) [\#5634](https://github.com/cosmos/cosmos-sdk/pull/5634) Migrate the `x/evidence` module to use Protocol Buffers for state
|
||||
serialization instead of Amino.
|
||||
* The `internal` sub-package has been removed in order to expose the types proto file.
|
||||
* The module now accepts a `Codec` interface which extends the `codec.Marshaler` interface by
|
||||
requiring a concrete codec to know how to serialize `Evidence` types.
|
||||
* The `MsgSubmitEvidence` message has been removed in favor of `MsgSubmitEvidenceBase`. The application-level
|
||||
codec must now define the concrete `MsgSubmitEvidence` type which must implement the module's `MsgSubmitEvidence`
|
||||
interface.
|
||||
|
||||
### Improvements
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
## Changelog
|
||||
|
||||
- 2020 Feb 15: Initial Draft
|
||||
- 2020 Feb 24: Updates to handle messages with interface fields
|
||||
|
||||
## Status
|
||||
|
||||
|
@ -143,19 +144,6 @@ message Account {
|
|||
```go
|
||||
// app/codec/codec.go
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||
// ...
|
||||
)
|
||||
|
||||
var (
|
||||
_ auth.Codec = (*Codec)(nil)
|
||||
// ...
|
||||
)
|
||||
|
||||
type Codec struct {
|
||||
codec.Marshaler
|
||||
|
||||
|
@ -192,10 +180,91 @@ about all the required types. Note, the use of `interface_type` allows us to avo
|
|||
amount of code boilerplate when implementing the `Codec`.
|
||||
|
||||
A similar concept is to be applied for messages that contain interfaces fields. The module will
|
||||
define a "base" concrete message type (e.g. `MsgSubmitProposalBase`) that the application-level codec
|
||||
will extend via `oneof` (e.g. `MsgSubmitProposal`) that fulfills the required interface
|
||||
(e.g. `MsgSubmitProposalI`). Note, however, the module's message handler must now switch on the
|
||||
interface rather than the concrete type for this particular message.
|
||||
define a "base" concrete message type that the application-level codec will extend via `oneof` that
|
||||
fulfills the required message interface.
|
||||
|
||||
Example:
|
||||
|
||||
The `MsgSubmitEvidence` defined by the `x/evidence` module contains a field `Evidence` which is an
|
||||
interface.
|
||||
|
||||
```go
|
||||
type MsgSubmitEvidence struct {
|
||||
Evidence exported.Evidence
|
||||
Submitter sdk.AccAddress
|
||||
}
|
||||
```
|
||||
|
||||
Instead, we will implement a "base" message type and an interface which the concrete message type
|
||||
must implement.
|
||||
|
||||
```protobuf
|
||||
// x/evidence/types/types.proto
|
||||
|
||||
message MsgSubmitEvidenceBase {
|
||||
bytes submitter = 1
|
||||
[
|
||||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
```go
|
||||
// x/evidence/exported/evidence.go
|
||||
|
||||
type MsgSubmitEvidence interface {
|
||||
sdk.Msg
|
||||
|
||||
GetEvidence() Evidence
|
||||
GetSubmitter() sdk.AccAddress
|
||||
}
|
||||
```
|
||||
|
||||
Notice the `MsgSubmitEvidence` interface extends `sdk.Msg` and allows for the `Evidence` interface
|
||||
to be retrieved from the concrete message type.
|
||||
|
||||
Now, the application-level codec will define the concrete `MsgSubmitEvidence` type and will have it
|
||||
fulfill the `MsgSubmitEvidence` interface defined by `x/evidence`.
|
||||
|
||||
```protobuf
|
||||
// app/codec/codec.proto
|
||||
|
||||
message Evidence {
|
||||
option (gogoproto.equal) = true;
|
||||
option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/x/evidence/exported.Evidence";
|
||||
|
||||
oneof sum {
|
||||
cosmos_sdk.x.evidence.v1.Equivocation equivocation = 1;
|
||||
}
|
||||
}
|
||||
|
||||
message MsgSubmitEvidence {
|
||||
option (gogoproto.equal) = true;
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
Evidence evidence = 1;
|
||||
cosmos_sdk.x.evidence.v1.MsgSubmitEvidenceBase base = 2
|
||||
[
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.embed) = true
|
||||
];
|
||||
}
|
||||
```
|
||||
|
||||
```go
|
||||
// app/codec/msgs.go
|
||||
|
||||
func (msg MsgSubmitEvidence) GetEvidence() eviexported.Evidence {
|
||||
return msg.Evidence.GetEvidence()
|
||||
}
|
||||
|
||||
func (msg MsgSubmitEvidence) GetSubmitter() sdk.AccAddress {
|
||||
return msg.Submitter
|
||||
}
|
||||
```
|
||||
|
||||
Note, however, the module's message handler must now handle the interface `MsgSubmitEvidence` in
|
||||
addition to any concrete types.
|
||||
|
||||
### Why Wasn't X Chosen Instead
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ func NewSimApp(
|
|||
appCodec, keys[staking.StoreKey], app.BankKeeper, app.SupplyKeeper, app.subspaces[staking.ModuleName],
|
||||
)
|
||||
app.MintKeeper = mint.NewKeeper(
|
||||
app.cdc, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper,
|
||||
appCodec, keys[mint.StoreKey], app.subspaces[mint.ModuleName], &stakingKeeper,
|
||||
app.SupplyKeeper, auth.FeeCollectorName,
|
||||
)
|
||||
app.DistrKeeper = distr.NewKeeper(
|
||||
|
@ -193,7 +193,7 @@ func NewSimApp(
|
|||
|
||||
// create evidence keeper with router
|
||||
evidenceKeeper := evidence.NewKeeper(
|
||||
app.cdc, keys[evidence.StoreKey], app.subspaces[evidence.ModuleName], &app.StakingKeeper, app.SlashingKeeper,
|
||||
appCodec, keys[evidence.StoreKey], app.subspaces[evidence.ModuleName], &app.StakingKeeper, app.SlashingKeeper,
|
||||
)
|
||||
evidenceRouter := evidence.NewRouter()
|
||||
// TODO: Register evidence routes.
|
||||
|
|
|
@ -7,13 +7,16 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply/exported"
|
||||
supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported"
|
||||
)
|
||||
|
||||
var (
|
||||
_ auth.Codec = (*Codec)(nil)
|
||||
_ supply.Codec = (*Codec)(nil)
|
||||
_ auth.Codec = (*Codec)(nil)
|
||||
_ supply.Codec = (*Codec)(nil)
|
||||
_ evidence.Codec = (*Codec)(nil)
|
||||
)
|
||||
|
||||
// Codec defines the application-level codec. This codec contains all the
|
||||
|
@ -72,7 +75,7 @@ func (c *Codec) UnmarshalAccountJSON(bz []byte) (authexported.Account, error) {
|
|||
// MarshalSupply marshals a SupplyI interface. If the given type implements
|
||||
// the Marshaler interface, it is treated as a Proto-defined message and
|
||||
// serialized that way. Otherwise, it falls back on the internal Amino codec.
|
||||
func (c *Codec) MarshalSupply(supplyI exported.SupplyI) ([]byte, error) {
|
||||
func (c *Codec) MarshalSupply(supplyI supplyexported.SupplyI) ([]byte, error) {
|
||||
supply := &Supply{}
|
||||
if err := supply.SetSupplyI(supplyI); err != nil {
|
||||
return nil, err
|
||||
|
@ -83,7 +86,7 @@ func (c *Codec) MarshalSupply(supplyI exported.SupplyI) ([]byte, error) {
|
|||
|
||||
// UnmarshalSupply returns a SupplyI interface from raw encoded account bytes
|
||||
// of a Proto-based SupplyI type. An error is returned upon decoding failure.
|
||||
func (c *Codec) UnmarshalSupply(bz []byte) (exported.SupplyI, error) {
|
||||
func (c *Codec) UnmarshalSupply(bz []byte) (supplyexported.SupplyI, error) {
|
||||
supply := &Supply{}
|
||||
if err := c.Marshaler.UnmarshalBinaryLengthPrefixed(bz, supply); err != nil {
|
||||
return nil, err
|
||||
|
@ -94,12 +97,12 @@ func (c *Codec) UnmarshalSupply(bz []byte) (exported.SupplyI, error) {
|
|||
|
||||
// MarshalSupplyJSON JSON encodes a supply object implementing the SupplyI
|
||||
// interface.
|
||||
func (c *Codec) MarshalSupplyJSON(supply exported.SupplyI) ([]byte, error) {
|
||||
func (c *Codec) MarshalSupplyJSON(supply supplyexported.SupplyI) ([]byte, error) {
|
||||
return c.Marshaler.MarshalJSON(supply)
|
||||
}
|
||||
|
||||
// UnmarshalSupplyJSON returns a SupplyI from JSON encoded bytes.
|
||||
func (c *Codec) UnmarshalSupplyJSON(bz []byte) (exported.SupplyI, error) {
|
||||
func (c *Codec) UnmarshalSupplyJSON(bz []byte) (supplyexported.SupplyI, error) {
|
||||
supply := &Supply{}
|
||||
if err := c.Marshaler.UnmarshalJSON(bz, supply); err != nil {
|
||||
return nil, err
|
||||
|
@ -108,9 +111,47 @@ func (c *Codec) UnmarshalSupplyJSON(bz []byte) (exported.SupplyI, error) {
|
|||
return supply.GetSupplyI(), nil
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MarshalEvidence marshals an Evidence interface. If the given type implements
|
||||
// the Marshaler interface, it is treated as a Proto-defined message and
|
||||
// serialized that way. Otherwise, it falls back on the internal Amino codec.
|
||||
func (c *Codec) MarshalEvidence(evidenceI eviexported.Evidence) ([]byte, error) {
|
||||
evidence := &Evidence{}
|
||||
if err := evidence.SetEvidence(evidenceI); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// MakeCodec creates and returns a reference to an Amino codec that has all the
|
||||
return c.Marshaler.MarshalBinaryLengthPrefixed(evidence)
|
||||
}
|
||||
|
||||
// UnmarshalEvidence returns an Evidence interface from raw encoded evidence
|
||||
// bytes of a Proto-based Evidence type. An error is returned upon decoding
|
||||
// failure.
|
||||
func (c *Codec) UnmarshalEvidence(bz []byte) (eviexported.Evidence, error) {
|
||||
evidence := &Evidence{}
|
||||
if err := c.Marshaler.UnmarshalBinaryLengthPrefixed(bz, evidence); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return evidence.GetEvidence(), nil
|
||||
}
|
||||
|
||||
// MarshalEvidenceJSON JSON encodes an evidence object implementing the Evidence
|
||||
// interface.
|
||||
func (c *Codec) MarshalEvidenceJSON(evidence eviexported.Evidence) ([]byte, error) {
|
||||
return c.Marshaler.MarshalJSON(evidence)
|
||||
}
|
||||
|
||||
// UnmarshalEvidenceJSON returns an Evidence from JSON encoded bytes
|
||||
func (c *Codec) UnmarshalEvidenceJSON(bz []byte) (eviexported.Evidence, error) {
|
||||
evidence := &Evidence{}
|
||||
if err := c.Marshaler.UnmarshalJSON(bz, evidence); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return evidence.GetEvidence(), nil
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// necessary types and interfaces registered. This codec is provided to all the
|
||||
// modules the application depends on.
|
||||
//
|
||||
|
|
|
@ -8,8 +8,11 @@ import (
|
|||
github_com_cosmos_cosmos_sdk_x_auth_exported "github.com/cosmos/cosmos-sdk/x/auth/exported"
|
||||
types "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
types1 "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
||||
github_com_cosmos_cosmos_sdk_x_evidence_exported "github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
types3 "github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
github_com_cosmos_cosmos_sdk_x_supply_exported "github.com/cosmos/cosmos-sdk/x/supply/exported"
|
||||
types2 "github.com/cosmos/cosmos-sdk/x/supply/types"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "github.com/regen-network/cosmos-proto"
|
||||
io "io"
|
||||
|
@ -157,7 +160,7 @@ func (*Account) XXX_OneofWrappers() []interface{} {
|
|||
|
||||
// Supply defines the application-level Supply type.
|
||||
type Supply struct {
|
||||
// sum defines a list of all acceptable concrete Supply implementations.
|
||||
// sum defines a set of all acceptable concrete Supply implementations.
|
||||
//
|
||||
// Types that are valid to be assigned to Sum:
|
||||
// *Supply_Supply
|
||||
|
@ -199,6 +202,7 @@ var xxx_messageInfo_Supply proto.InternalMessageInfo
|
|||
|
||||
type isSupply_Sum interface {
|
||||
isSupply_Sum()
|
||||
Equal(interface{}) bool
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
@ -230,45 +234,309 @@ func (*Supply) XXX_OneofWrappers() []interface{} {
|
|||
}
|
||||
}
|
||||
|
||||
// Evidence defines the application-level allowed Evidence to be submitted via a
|
||||
// MsgSubmitEvidence message.
|
||||
type Evidence struct {
|
||||
// sum defines a set of all acceptable concrete Evidence implementations.
|
||||
//
|
||||
// Types that are valid to be assigned to Sum:
|
||||
// *Evidence_Equivocation
|
||||
Sum isEvidence_Sum `protobuf_oneof:"sum"`
|
||||
}
|
||||
|
||||
func (m *Evidence) Reset() { *m = Evidence{} }
|
||||
func (m *Evidence) String() string { return proto.CompactTextString(m) }
|
||||
func (*Evidence) ProtoMessage() {}
|
||||
func (*Evidence) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_3c6d4085e4065f5a, []int{2}
|
||||
}
|
||||
func (m *Evidence) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Evidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Evidence.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 *Evidence) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Evidence.Merge(m, src)
|
||||
}
|
||||
func (m *Evidence) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Evidence) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Evidence.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Evidence proto.InternalMessageInfo
|
||||
|
||||
type isEvidence_Sum interface {
|
||||
isEvidence_Sum()
|
||||
Equal(interface{}) bool
|
||||
MarshalTo([]byte) (int, error)
|
||||
Size() int
|
||||
}
|
||||
|
||||
type Evidence_Equivocation struct {
|
||||
Equivocation *types3.Equivocation `protobuf:"bytes,1,opt,name=equivocation,proto3,oneof" json:"equivocation,omitempty"`
|
||||
}
|
||||
|
||||
func (*Evidence_Equivocation) isEvidence_Sum() {}
|
||||
|
||||
func (m *Evidence) GetSum() isEvidence_Sum {
|
||||
if m != nil {
|
||||
return m.Sum
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Evidence) GetEquivocation() *types3.Equivocation {
|
||||
if x, ok := m.GetSum().(*Evidence_Equivocation); ok {
|
||||
return x.Equivocation
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// XXX_OneofWrappers is for the internal use of the proto package.
|
||||
func (*Evidence) XXX_OneofWrappers() []interface{} {
|
||||
return []interface{}{
|
||||
(*Evidence_Equivocation)(nil),
|
||||
}
|
||||
}
|
||||
|
||||
// MsgSubmitEvidence defines the application-level message type for handling
|
||||
// evidence submission.
|
||||
type MsgSubmitEvidence struct {
|
||||
Evidence *Evidence `protobuf:"bytes,1,opt,name=evidence,proto3" json:"evidence,omitempty"`
|
||||
types3.MsgSubmitEvidenceBase `protobuf:"bytes,2,opt,name=base,proto3,embedded=base" json:"base"`
|
||||
}
|
||||
|
||||
func (m *MsgSubmitEvidence) Reset() { *m = MsgSubmitEvidence{} }
|
||||
func (m *MsgSubmitEvidence) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgSubmitEvidence) ProtoMessage() {}
|
||||
func (*MsgSubmitEvidence) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_3c6d4085e4065f5a, []int{3}
|
||||
}
|
||||
func (m *MsgSubmitEvidence) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgSubmitEvidence) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgSubmitEvidence.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 *MsgSubmitEvidence) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgSubmitEvidence.Merge(m, src)
|
||||
}
|
||||
func (m *MsgSubmitEvidence) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgSubmitEvidence) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgSubmitEvidence.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgSubmitEvidence proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Account)(nil), "cosmos_sdk.simapp.codec.v1.Account")
|
||||
proto.RegisterType((*Supply)(nil), "cosmos_sdk.simapp.codec.v1.Supply")
|
||||
proto.RegisterType((*Evidence)(nil), "cosmos_sdk.simapp.codec.v1.Evidence")
|
||||
proto.RegisterType((*MsgSubmitEvidence)(nil), "cosmos_sdk.simapp.codec.v1.MsgSubmitEvidence")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("simapp/codec/codec.proto", fileDescriptor_3c6d4085e4065f5a) }
|
||||
|
||||
var fileDescriptor_3c6d4085e4065f5a = []byte{
|
||||
// 444 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x93, 0x4f, 0x8b, 0xd3, 0x40,
|
||||
0x18, 0xc6, 0x13, 0x77, 0xb7, 0xc2, 0xac, 0x7a, 0x08, 0xa8, 0x21, 0x87, 0xb0, 0x2e, 0x08, 0xfe,
|
||||
0xa1, 0x13, 0xd6, 0xf5, 0xef, 0x7a, 0xb2, 0x15, 0xa9, 0x07, 0x45, 0x2a, 0x78, 0xf0, 0x12, 0x92,
|
||||
0x99, 0xa1, 0x0d, 0x6d, 0x32, 0x43, 0x66, 0x26, 0x24, 0x5f, 0xc0, 0xb3, 0x1f, 0xa6, 0x47, 0x3f,
|
||||
0x80, 0xf4, 0xd4, 0xa3, 0x47, 0x69, 0xbf, 0x88, 0x74, 0x66, 0x6c, 0x22, 0x49, 0xeb, 0x25, 0xf0,
|
||||
0xce, 0xf3, 0xbc, 0xcf, 0xef, 0x0d, 0xf3, 0x0e, 0x70, 0x79, 0x92, 0x46, 0x8c, 0x05, 0x88, 0x62,
|
||||
0x82, 0xf4, 0x17, 0xb2, 0x9c, 0x0a, 0xea, 0x78, 0x88, 0xf2, 0x94, 0xf2, 0x90, 0xe3, 0x19, 0xd4,
|
||||
0x26, 0xa8, 0xe5, 0xe2, 0xc2, 0x7b, 0x2c, 0xa6, 0x49, 0x8e, 0x43, 0x16, 0xe5, 0xa2, 0x0a, 0x94,
|
||||
0x3d, 0xd0, 0xee, 0x7e, 0xb3, 0xd0, 0x41, 0x9e, 0x5b, 0x06, 0x91, 0x14, 0xd3, 0x40, 0x54, 0x8c,
|
||||
0x70, 0xfd, 0x35, 0xca, 0x99, 0x51, 0x0a, 0xc2, 0x45, 0x92, 0x4d, 0x3a, 0x1c, 0x5e, 0x19, 0x70,
|
||||
0xc9, 0xd8, 0xbc, 0x6a, 0x6b, 0xe7, 0x3f, 0x8e, 0xc1, 0xf5, 0x37, 0x08, 0x51, 0x99, 0x09, 0xe7,
|
||||
0x1d, 0xb8, 0x11, 0x47, 0x9c, 0x84, 0x91, 0xae, 0x5d, 0xfb, 0xcc, 0x7e, 0x70, 0xfa, 0xe4, 0x1e,
|
||||
0x6c, 0xfc, 0x43, 0x09, 0xb7, 0x2c, 0x58, 0x5c, 0xc0, 0x41, 0xc4, 0x89, 0x69, 0x1c, 0x59, 0xe3,
|
||||
0xd3, 0xb8, 0x2e, 0x9d, 0x02, 0x78, 0x88, 0x66, 0x22, 0xc9, 0x24, 0x95, 0x3c, 0x34, 0x73, 0xed,
|
||||
0x52, 0xaf, 0xa9, 0xd4, 0xe7, 0x5d, 0xa9, 0xda, 0xb9, 0x4d, 0x1f, 0xee, 0xfa, 0xbf, 0xe8, 0xc3,
|
||||
0x1a, 0xe5, 0xa2, 0x3d, 0x9a, 0x93, 0x82, 0xbb, 0x98, 0xcc, 0xa3, 0x8a, 0xe0, 0x16, 0xf4, 0x48,
|
||||
0x41, 0x2f, 0x0f, 0x43, 0xdf, 0xea, 0xe6, 0x16, 0xf1, 0x36, 0xee, 0x12, 0x1c, 0x06, 0x5c, 0x46,
|
||||
0xf2, 0x84, 0xe2, 0x04, 0xb5, 0x78, 0xc7, 0x8a, 0xf7, 0xf4, 0x30, 0xef, 0x93, 0xe9, 0x6e, 0x01,
|
||||
0xef, 0xb0, 0x4e, 0xc5, 0xf9, 0x08, 0x6e, 0xa5, 0x14, 0xcb, 0x79, 0x7d, 0x45, 0x27, 0x8a, 0x73,
|
||||
0xff, 0x5f, 0x8e, 0xbe, 0xec, 0x2d, 0xe1, 0x83, 0x72, 0xd7, 0xc1, 0x37, 0xd3, 0xe6, 0xc1, 0xd5,
|
||||
0xab, 0xe5, 0xa2, 0xff, 0xec, 0xd1, 0x24, 0x11, 0x53, 0x19, 0x43, 0x44, 0x53, 0xb3, 0x72, 0x7f,
|
||||
0xd7, 0x90, 0xe3, 0x59, 0x60, 0x96, 0x8b, 0x94, 0x8c, 0xe6, 0x82, 0x60, 0x68, 0x5a, 0x07, 0x27,
|
||||
0xe0, 0x88, 0xcb, 0xf4, 0xfc, 0x9b, 0x0d, 0x7a, 0x9f, 0x15, 0xce, 0x79, 0x09, 0x7a, 0x1a, 0x6c,
|
||||
0xf6, 0xc6, 0xdf, 0x37, 0x94, 0xf6, 0x8f, 0xac, 0xb1, 0xf1, 0x5f, 0xbd, 0x5e, 0x2e, 0xfa, 0x2f,
|
||||
0xfe, 0x37, 0x86, 0xd9, 0xe0, 0xdd, 0x20, 0x3a, 0xe5, 0xbd, 0x19, 0x64, 0x30, 0xfc, 0xb9, 0xf6,
|
||||
0xed, 0xd5, 0xda, 0xb7, 0x7f, 0xaf, 0x7d, 0xfb, 0xfb, 0xc6, 0xb7, 0x56, 0x1b, 0xdf, 0xfa, 0xb5,
|
||||
0xf1, 0xad, 0xaf, 0x0f, 0x0f, 0x06, 0x37, 0x5f, 0x6e, 0xdc, 0x53, 0x6f, 0xe2, 0xf2, 0x4f, 0x00,
|
||||
0x00, 0x00, 0xff, 0xff, 0xdc, 0xbb, 0x4f, 0xcf, 0xd0, 0x03, 0x00, 0x00,
|
||||
// 593 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x54, 0x4d, 0x6f, 0xd3, 0x3e,
|
||||
0x18, 0x4f, 0xfe, 0xeb, 0xfa, 0xaf, 0xbc, 0x81, 0x44, 0x24, 0xa0, 0xaa, 0x50, 0x3a, 0x26, 0x98,
|
||||
0x78, 0x51, 0x13, 0x8d, 0xf1, 0xb6, 0x5e, 0x60, 0x1d, 0x43, 0x45, 0xa2, 0x08, 0x75, 0x12, 0x07,
|
||||
0x2e, 0x55, 0x6a, 0x5b, 0xad, 0xb5, 0x26, 0x36, 0xb5, 0x1d, 0xb5, 0xdf, 0x00, 0x71, 0xe2, 0x23,
|
||||
0x4c, 0x7c, 0x00, 0x4e, 0x3b, 0xf2, 0x01, 0xa6, 0x9d, 0x7a, 0xe4, 0x34, 0xa1, 0xf6, 0xc2, 0xc7,
|
||||
0x40, 0x89, 0x9d, 0xb4, 0x55, 0xda, 0xee, 0x12, 0xd5, 0x7e, 0x7e, 0x6f, 0x76, 0x9f, 0xc7, 0xa0,
|
||||
0xc8, 0x89, 0xef, 0x31, 0xe6, 0x42, 0x8a, 0x30, 0x54, 0x5f, 0x87, 0xf5, 0xa9, 0xa0, 0x56, 0x09,
|
||||
0x52, 0xee, 0x53, 0xde, 0xe2, 0xe8, 0xc4, 0x51, 0x20, 0x47, 0x95, 0xc3, 0xdd, 0xd2, 0x63, 0xd1,
|
||||
0x25, 0x7d, 0xd4, 0x62, 0x5e, 0x5f, 0x0c, 0xdd, 0x18, 0xee, 0x2a, 0x74, 0x65, 0x76, 0xa1, 0x84,
|
||||
0x4a, 0x3b, 0x59, 0x70, 0x87, 0x76, 0xe8, 0xf4, 0x97, 0xc6, 0x15, 0x07, 0xae, 0x27, 0x45, 0xd7,
|
||||
0x15, 0x43, 0x86, 0xb9, 0xfa, 0xea, 0xca, 0x96, 0xae, 0x84, 0x98, 0x0b, 0x12, 0x74, 0x16, 0x20,
|
||||
0x4a, 0x03, 0x97, 0x4b, 0xc6, 0x7a, 0xc3, 0x05, 0xb5, 0x3b, 0x03, 0x17, 0x87, 0x04, 0xe1, 0x00,
|
||||
0xe2, 0x6c, 0x75, 0xfb, 0x57, 0x0e, 0xfc, 0x7f, 0x00, 0x21, 0x95, 0x81, 0xb0, 0xde, 0x82, 0xcd,
|
||||
0xb6, 0xc7, 0x71, 0xcb, 0x53, 0xeb, 0xa2, 0xb9, 0x65, 0x3e, 0xd8, 0x78, 0x72, 0xd7, 0x99, 0xb9,
|
||||
0x89, 0x81, 0x13, 0x25, 0x71, 0xc2, 0x5d, 0xa7, 0xe6, 0x71, 0xac, 0x89, 0x75, 0xa3, 0xb9, 0xd1,
|
||||
0x9e, 0x2e, 0xad, 0x10, 0x94, 0x20, 0x0d, 0x04, 0x09, 0x24, 0x95, 0xbc, 0xa5, 0x53, 0xa7, 0xaa,
|
||||
0xff, 0xc5, 0xaa, 0xcf, 0x17, 0xa9, 0x2a, 0x64, 0xa4, 0x7e, 0x98, 0xf2, 0x3f, 0xa9, 0xcd, 0xa9,
|
||||
0x55, 0x11, 0x2e, 0xa9, 0x59, 0x3e, 0xb8, 0x8d, 0x70, 0xcf, 0x1b, 0x62, 0x94, 0x31, 0x5d, 0x8b,
|
||||
0x4d, 0xf7, 0x56, 0x9b, 0xbe, 0x51, 0xe4, 0x8c, 0xe3, 0x4d, 0xb4, 0xa8, 0x60, 0x31, 0x50, 0x64,
|
||||
0xb8, 0x4f, 0x28, 0x22, 0x30, 0xe3, 0x97, 0x8b, 0xfd, 0x9e, 0xae, 0xf6, 0xfb, 0xa8, 0xd9, 0x19,
|
||||
0xc3, 0x5b, 0x6c, 0x61, 0xc5, 0xfa, 0x00, 0xae, 0xfb, 0x14, 0xc9, 0xde, 0xf4, 0x2f, 0x5a, 0x8f,
|
||||
0x7d, 0xee, 0xcf, 0xfb, 0xa8, 0x56, 0x88, 0x1c, 0x1a, 0x31, 0x7a, 0x2a, 0x7c, 0xcd, 0x9f, 0xdd,
|
||||
0xa8, 0xee, 0x5f, 0x9c, 0x55, 0x9e, 0x3d, 0xea, 0x10, 0xd1, 0x95, 0x6d, 0x07, 0x52, 0x5f, 0x37,
|
||||
0x6e, 0xd2, 0xcc, 0x1c, 0x9d, 0xb8, 0xba, 0xf5, 0xf0, 0x80, 0xd1, 0xbe, 0xc0, 0xc8, 0xd1, 0xd4,
|
||||
0xda, 0x3a, 0x58, 0xe3, 0xd2, 0xdf, 0xfe, 0x66, 0x82, 0xfc, 0x71, 0x6c, 0x67, 0xbd, 0x04, 0x79,
|
||||
0x65, 0xac, 0xfb, 0xc6, 0x5e, 0x16, 0x4a, 0xe1, 0xeb, 0x46, 0x53, 0xe3, 0xab, 0xaf, 0xfe, 0x9e,
|
||||
0x96, 0xcd, 0x8b, 0xb3, 0xca, 0x8b, 0xab, 0xa2, 0xe8, 0x1e, 0x4f, 0xc3, 0x28, 0xa5, 0x77, 0x49,
|
||||
0x98, 0x1f, 0x26, 0x28, 0x1c, 0xe9, 0x56, 0xb7, 0xde, 0x83, 0x4d, 0xfc, 0x45, 0x92, 0x90, 0x42,
|
||||
0x4f, 0x10, 0x1a, 0xe8, 0x50, 0x3b, 0xf3, 0xa1, 0x92, 0xc1, 0x88, 0x62, 0x1d, 0xcd, 0xa0, 0xeb,
|
||||
0x46, 0x73, 0x8e, 0x5d, 0x3d, 0xd0, 0x11, 0xf7, 0xaf, 0x48, 0x98, 0x4e, 0x5a, 0x9a, 0x31, 0x09,
|
||||
0x94, 0x84, 0xfc, 0x69, 0x82, 0x1b, 0x0d, 0xde, 0x39, 0x96, 0x6d, 0x9f, 0x88, 0x34, 0xed, 0x6b,
|
||||
0x50, 0x48, 0xa8, 0x3a, 0xe9, 0x3d, 0x67, 0xf9, 0x03, 0x94, 0x8a, 0x36, 0x53, 0x96, 0xd5, 0x00,
|
||||
0xb9, 0x68, 0x06, 0xf5, 0x78, 0xb9, 0xcb, 0xcf, 0x99, 0x31, 0x8f, 0x26, 0xb9, 0x56, 0x38, 0xbf,
|
||||
0x2c, 0x1b, 0xa3, 0xcb, 0xb2, 0xd9, 0x8c, 0x65, 0xaa, 0x85, 0xaf, 0xa7, 0x65, 0x23, 0x3a, 0x74,
|
||||
0xed, 0xf0, 0x7c, 0x6c, 0x9b, 0xa3, 0xb1, 0x6d, 0xfe, 0x19, 0xdb, 0xe6, 0xf7, 0x89, 0x6d, 0x8c,
|
||||
0x26, 0xb6, 0xf1, 0x7b, 0x62, 0x1b, 0x9f, 0x1f, 0xae, 0xbc, 0x8c, 0xd9, 0x97, 0xb5, 0x9d, 0x8f,
|
||||
0x5f, 0x9b, 0xbd, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x57, 0xb9, 0x47, 0x37, 0x70, 0x05, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
func (this *Supply) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*Supply)
|
||||
if !ok {
|
||||
that2, ok := that.(Supply)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if that1.Sum == nil {
|
||||
if this.Sum != nil {
|
||||
return false
|
||||
}
|
||||
} else if this.Sum == nil {
|
||||
return false
|
||||
} else if !this.Sum.Equal(that1.Sum) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *Supply_Supply) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*Supply_Supply)
|
||||
if !ok {
|
||||
that2, ok := that.(Supply_Supply)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if !this.Supply.Equal(that1.Supply) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *Evidence) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*Evidence)
|
||||
if !ok {
|
||||
that2, ok := that.(Evidence)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if that1.Sum == nil {
|
||||
if this.Sum != nil {
|
||||
return false
|
||||
}
|
||||
} else if this.Sum == nil {
|
||||
return false
|
||||
} else if !this.Sum.Equal(that1.Sum) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *Evidence_Equivocation) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*Evidence_Equivocation)
|
||||
if !ok {
|
||||
that2, ok := that.(Evidence_Equivocation)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if !this.Equivocation.Equal(that1.Equivocation) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *MsgSubmitEvidence) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*MsgSubmitEvidence)
|
||||
if !ok {
|
||||
that2, ok := that.(MsgSubmitEvidence)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if !this.Evidence.Equal(that1.Evidence) {
|
||||
return false
|
||||
}
|
||||
if !this.MsgSubmitEvidenceBase.Equal(&that1.MsgSubmitEvidenceBase) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *Account) GetAccount() github_com_cosmos_cosmos_sdk_x_auth_exported.Account {
|
||||
if x := this.GetBaseAccount(); x != nil {
|
||||
return x
|
||||
|
@ -333,6 +601,29 @@ func (this *Supply) SetSupplyI(value github_com_cosmos_cosmos_sdk_x_supply_expor
|
|||
return fmt.Errorf("can't encode value of type %T as message Supply", value)
|
||||
}
|
||||
|
||||
func (this *Evidence) GetEvidence() github_com_cosmos_cosmos_sdk_x_evidence_exported.Evidence {
|
||||
if x := this.GetEquivocation(); x != nil {
|
||||
return x
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (this *Evidence) SetEvidence(value github_com_cosmos_cosmos_sdk_x_evidence_exported.Evidence) error {
|
||||
if value == nil {
|
||||
this.Sum = nil
|
||||
return nil
|
||||
}
|
||||
switch vt := value.(type) {
|
||||
case *types3.Equivocation:
|
||||
this.Sum = &Evidence_Equivocation{vt}
|
||||
return nil
|
||||
case types3.Equivocation:
|
||||
this.Sum = &Evidence_Equivocation{&vt}
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("can't encode value of type %T as message Evidence", value)
|
||||
}
|
||||
|
||||
func (m *Account) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
|
@ -523,6 +814,104 @@ func (m *Supply_Supply) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
func (m *Evidence) 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 *Evidence) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Evidence) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.Sum != nil {
|
||||
{
|
||||
size := m.Sum.Size()
|
||||
i -= size
|
||||
if _, err := m.Sum.MarshalTo(dAtA[i:]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Evidence_Equivocation) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Evidence_Equivocation) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
if m.Equivocation != nil {
|
||||
{
|
||||
size, err := m.Equivocation.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintCodec(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
func (m *MsgSubmitEvidence) 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 *MsgSubmitEvidence) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgSubmitEvidence) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
{
|
||||
size, err := m.MsgSubmitEvidenceBase.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintCodec(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
if m.Evidence != nil {
|
||||
{
|
||||
size, err := m.Evidence.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintCodec(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintCodec(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovCodec(v)
|
||||
base := offset
|
||||
|
@ -630,6 +1019,44 @@ func (m *Supply_Supply) Size() (n int) {
|
|||
}
|
||||
return n
|
||||
}
|
||||
func (m *Evidence) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Sum != nil {
|
||||
n += m.Sum.Size()
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Evidence_Equivocation) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Equivocation != nil {
|
||||
l = m.Equivocation.Size()
|
||||
n += 1 + l + sovCodec(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
func (m *MsgSubmitEvidence) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Evidence != nil {
|
||||
l = m.Evidence.Size()
|
||||
n += 1 + l + sovCodec(uint64(l))
|
||||
}
|
||||
l = m.MsgSubmitEvidenceBase.Size()
|
||||
n += 1 + l + sovCodec(uint64(l))
|
||||
return n
|
||||
}
|
||||
|
||||
func sovCodec(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
|
@ -953,6 +1380,216 @@ func (m *Supply) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Evidence) 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 ErrIntOverflowCodec
|
||||
}
|
||||
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: Evidence: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Evidence: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Equivocation", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowCodec
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthCodec
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthCodec
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
v := &types3.Equivocation{}
|
||||
if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Sum = &Evidence_Equivocation{v}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipCodec(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthCodec
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthCodec
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MsgSubmitEvidence) 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 ErrIntOverflowCodec
|
||||
}
|
||||
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: MsgSubmitEvidence: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgSubmitEvidence: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Evidence", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowCodec
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthCodec
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthCodec
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Evidence == nil {
|
||||
m.Evidence = &Evidence{}
|
||||
}
|
||||
if err := m.Evidence.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field MsgSubmitEvidenceBase", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowCodec
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthCodec
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthCodec
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := m.MsgSubmitEvidenceBase.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipCodec(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthCodec
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthCodec
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipCodec(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
|
|
@ -2,9 +2,11 @@ syntax = "proto3";
|
|||
package cosmos_sdk.simapp.codec.v1;
|
||||
|
||||
import "third_party/proto/cosmos-proto/cosmos.proto";
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "x/auth/types/types.proto";
|
||||
import "x/auth/vesting/types/types.proto";
|
||||
import "x/supply/types/types.proto";
|
||||
import "x/evidence/types/types.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/simapp/codec";
|
||||
|
||||
|
@ -24,10 +26,33 @@ message Account {
|
|||
|
||||
// Supply defines the application-level Supply type.
|
||||
message Supply {
|
||||
option (gogoproto.equal) = true;
|
||||
option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/supply/exported.SupplyI";
|
||||
|
||||
// sum defines a list of all acceptable concrete Supply implementations.
|
||||
// sum defines a set of all acceptable concrete Supply implementations.
|
||||
oneof sum {
|
||||
cosmos_sdk.x.supply.v1.Supply supply = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Evidence defines the application-level allowed Evidence to be submitted via a
|
||||
// MsgSubmitEvidence message.
|
||||
message Evidence {
|
||||
option (gogoproto.equal) = true;
|
||||
option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/x/evidence/exported.Evidence";
|
||||
|
||||
// sum defines a set of all acceptable concrete Evidence implementations.
|
||||
oneof sum {
|
||||
cosmos_sdk.x.evidence.v1.Equivocation equivocation = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// MsgSubmitEvidence defines the application-level message type for handling
|
||||
// evidence submission.
|
||||
message MsgSubmitEvidence {
|
||||
option (gogoproto.equal) = true;
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
Evidence evidence = 1;
|
||||
cosmos_sdk.x.evidence.v1.MsgSubmitEvidenceBase base = 2 [(gogoproto.nullable) = false, (gogoproto.embed) = true];
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package codec
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
)
|
||||
|
||||
var _ eviexported.MsgSubmitEvidence = MsgSubmitEvidence{}
|
||||
|
||||
// NewMsgSubmitEvidence returns a new MsgSubmitEvidence.
|
||||
func NewMsgSubmitEvidence(evidenceI eviexported.Evidence, s sdk.AccAddress) MsgSubmitEvidence {
|
||||
e := &Evidence{}
|
||||
e.SetEvidence(evidenceI)
|
||||
|
||||
return MsgSubmitEvidence{Evidence: e, MsgSubmitEvidenceBase: evidence.NewMsgSubmitEvidenceBase(s)}
|
||||
}
|
||||
|
||||
// ValidateBasic performs basic (non-state-dependant) validation on a
|
||||
// MsgSubmitEvidence.
|
||||
func (msg MsgSubmitEvidence) ValidateBasic() error {
|
||||
if err := msg.MsgSubmitEvidenceBase.ValidateBasic(); err != nil {
|
||||
return nil
|
||||
}
|
||||
if msg.Evidence == nil {
|
||||
return sdkerrors.Wrap(evidence.ErrInvalidEvidence, "missing evidence")
|
||||
}
|
||||
if err := msg.Evidence.GetEvidence().ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// nolint
|
||||
func (msg MsgSubmitEvidence) GetEvidence() eviexported.Evidence { return msg.Evidence.GetEvidence() }
|
||||
func (msg MsgSubmitEvidence) GetSubmitter() sdk.AccAddress { return msg.Submitter }
|
|
@ -13,8 +13,8 @@ message BaseAccount {
|
|||
option (gogoproto.goproto_getters) = false;
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
|
||||
bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
bytes pub_key = 2 [(gogoproto.moretags) = "yaml:\"public_key\""];
|
||||
bytes address = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
bytes pub_key = 2 [(gogoproto.moretags) = "yaml:\"public_key\""];
|
||||
uint64 account_number = 3 [(gogoproto.moretags) = "yaml:\"account_number\""];
|
||||
uint64 sequence = 4;
|
||||
}
|
||||
|
@ -25,10 +25,8 @@ message BaseAccount {
|
|||
message StdFee {
|
||||
option (gogoproto.equal) = true;
|
||||
|
||||
repeated cosmos_sdk.v1.Coin amount = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
|
||||
];
|
||||
repeated cosmos_sdk.v1.Coin amount = 1
|
||||
[(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"];
|
||||
uint64 gas = 2;
|
||||
}
|
||||
|
||||
|
@ -40,12 +38,8 @@ message Params {
|
|||
uint64 max_memo_characters = 1 [(gogoproto.moretags) = "yaml:\"max_memo_characters\""];
|
||||
uint64 tx_sig_limit = 2 [(gogoproto.moretags) = "yaml:\"tx_sig_limit\""];
|
||||
uint64 tx_size_cost_per_byte = 3 [(gogoproto.moretags) = "yaml:\"tx_size_cost_per_byte\""];
|
||||
uint64 sig_verify_cost_ed25519 = 4 [
|
||||
(gogoproto.customname) = "SigVerifyCostED25519",
|
||||
(gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""
|
||||
];
|
||||
uint64 sig_verify_cost_secp256k1 = 5 [
|
||||
(gogoproto.customname) = "SigVerifyCostSecp256k1",
|
||||
(gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""
|
||||
];
|
||||
uint64 sig_verify_cost_ed25519 = 4
|
||||
[(gogoproto.customname) = "SigVerifyCostED25519", (gogoproto.moretags) = "yaml:\"sig_verify_cost_ed25519\""];
|
||||
uint64 sig_verify_cost_secp256k1 = 5
|
||||
[(gogoproto.customname) = "SigVerifyCostSecp256k1", (gogoproto.moretags) = "yaml:\"sig_verify_cost_secp256k1\""];
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package evidence
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
// nolint
|
||||
|
@ -27,12 +27,11 @@ var (
|
|||
NewKeeper = keeper.NewKeeper
|
||||
NewQuerier = keeper.NewQuerier
|
||||
|
||||
NewMsgSubmitEvidence = types.NewMsgSubmitEvidence
|
||||
NewMsgSubmitEvidenceBase = types.NewMsgSubmitEvidenceBase
|
||||
NewRouter = types.NewRouter
|
||||
NewQueryEvidenceParams = types.NewQueryEvidenceParams
|
||||
NewQueryAllEvidenceParams = types.NewQueryAllEvidenceParams
|
||||
RegisterCodec = types.RegisterCodec
|
||||
RegisterEvidenceTypeCodec = types.RegisterEvidenceTypeCodec
|
||||
ModuleCdc = types.ModuleCdc
|
||||
NewGenesisState = types.NewGenesisState
|
||||
DefaultGenesisState = types.DefaultGenesisState
|
||||
|
@ -40,14 +39,19 @@ var (
|
|||
KeyMaxEvidenceAge = types.KeyMaxEvidenceAge
|
||||
DoubleSignJailEndTime = types.DoubleSignJailEndTime
|
||||
ParamKeyTable = types.ParamKeyTable
|
||||
ErrNoEvidenceHandlerExists = types.ErrNoEvidenceHandlerExists
|
||||
ErrInvalidEvidence = types.ErrInvalidEvidence
|
||||
ErrNoEvidenceExists = types.ErrNoEvidenceExists
|
||||
ErrEvidenceExists = types.ErrEvidenceExists
|
||||
)
|
||||
|
||||
type (
|
||||
Keeper = keeper.Keeper
|
||||
|
||||
GenesisState = types.GenesisState
|
||||
MsgSubmitEvidence = types.MsgSubmitEvidence
|
||||
Handler = types.Handler
|
||||
Router = types.Router
|
||||
Equivocation = types.Equivocation
|
||||
GenesisState = types.GenesisState
|
||||
MsgSubmitEvidenceBase = types.MsgSubmitEvidenceBase
|
||||
Handler = types.Handler
|
||||
Router = types.Router
|
||||
Equivocation = types.Equivocation
|
||||
Codec = types.Codec
|
||||
)
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
// GetQueryCmd returns the CLI command with all evidence module query commands
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
|
|
@ -27,3 +27,13 @@ type Evidence interface {
|
|||
// The total validator set power at time of infraction
|
||||
GetTotalPower() int64
|
||||
}
|
||||
|
||||
// MsgSubmitEvidence defines the specific interface a concrete message must
|
||||
// implement in order to process submitted evidence. The concrete MsgSubmitEvidence
|
||||
// must be defined at the application-level.
|
||||
type MsgSubmitEvidence interface {
|
||||
sdk.Msg
|
||||
|
||||
GetEvidence() Evidence
|
||||
GetSubmitter() sdk.AccAddress
|
||||
}
|
||||
|
|
|
@ -3,16 +3,16 @@ package evidence_test
|
|||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
"github.com/tendermint/tendermint/types/time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
type GenesisTestSuite struct {
|
||||
|
@ -26,20 +26,8 @@ func (suite *GenesisTestSuite) SetupTest() {
|
|||
checkTx := false
|
||||
app := simapp.Setup(checkTx)
|
||||
|
||||
// get the app's codec and register custom testing types
|
||||
cdc := app.Codec()
|
||||
cdc.RegisterConcrete(types.TestEquivocationEvidence{}, "test/TestEquivocationEvidence", nil)
|
||||
|
||||
// recreate keeper in order to use custom testing types
|
||||
evidenceKeeper := evidence.NewKeeper(
|
||||
cdc, app.GetKey(evidence.StoreKey), app.GetSubspace(evidence.ModuleName), app.StakingKeeper, app.SlashingKeeper,
|
||||
)
|
||||
router := evidence.NewRouter()
|
||||
router = router.AddRoute(types.TestEvidenceRouteEquivocation, types.TestEquivocationHandler(*evidenceKeeper))
|
||||
evidenceKeeper.SetRouter(router)
|
||||
|
||||
suite.ctx = app.BaseApp.NewContext(checkTx, abci.Header{Height: 1})
|
||||
suite.keeper = *evidenceKeeper
|
||||
suite.keeper = app.EvidenceKeeper
|
||||
}
|
||||
|
||||
func (suite *GenesisTestSuite) TestInitGenesis_Valid() {
|
||||
|
@ -47,21 +35,11 @@ func (suite *GenesisTestSuite) TestInitGenesis_Valid() {
|
|||
|
||||
testEvidence := make([]exported.Evidence, 100)
|
||||
for i := 0; i < 100; i++ {
|
||||
sv := types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: int64(i),
|
||||
Round: 0,
|
||||
}
|
||||
sig, err := pk.Sign(sv.SignBytes("test-chain"))
|
||||
suite.NoError(err)
|
||||
sv.Signature = sig
|
||||
|
||||
testEvidence[i] = types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: sv,
|
||||
testEvidence[i] = types.Equivocation{
|
||||
Height: int64(i + 1),
|
||||
Power: 100,
|
||||
Time: time.Now().UTC(),
|
||||
ConsensusAddress: pk.PubKey().Address().Bytes(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,21 +58,10 @@ func (suite *GenesisTestSuite) TestInitGenesis_Invalid() {
|
|||
|
||||
testEvidence := make([]exported.Evidence, 100)
|
||||
for i := 0; i < 100; i++ {
|
||||
sv := types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: int64(i),
|
||||
Round: 0,
|
||||
}
|
||||
sig, err := pk.Sign(sv.SignBytes("test-chain"))
|
||||
suite.NoError(err)
|
||||
sv.Signature = sig
|
||||
|
||||
testEvidence[i] = types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: types.TestVote{Height: 10, Round: 1},
|
||||
testEvidence[i] = types.Equivocation{
|
||||
Power: 100,
|
||||
Time: time.Now().UTC(),
|
||||
ConsensusAddress: pk.PubKey().Address().Bytes(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package evidence
|
|||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
)
|
||||
|
||||
func NewHandler(k Keeper) sdk.Handler {
|
||||
|
@ -10,17 +11,23 @@ func NewHandler(k Keeper) sdk.Handler {
|
|||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
||||
|
||||
switch msg := msg.(type) {
|
||||
case MsgSubmitEvidence:
|
||||
return handleMsgSubmitEvidence(ctx, k, msg)
|
||||
case MsgSubmitEvidenceBase:
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "%T must be extended to support evidence", msg)
|
||||
|
||||
default:
|
||||
msgSubEv, ok := msg.(exported.MsgSubmitEvidence)
|
||||
if ok {
|
||||
return handleMsgSubmitEvidence(ctx, k, msgSubEv)
|
||||
}
|
||||
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", ModuleName, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handleMsgSubmitEvidence(ctx sdk.Context, k Keeper, msg MsgSubmitEvidence) (*sdk.Result, error) {
|
||||
if err := k.SubmitEvidence(ctx, msg.Evidence); err != nil {
|
||||
func handleMsgSubmitEvidence(ctx sdk.Context, k Keeper, msg exported.MsgSubmitEvidence) (*sdk.Result, error) {
|
||||
evidence := msg.GetEvidence()
|
||||
if err := k.SubmitEvidence(ctx, evidence); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -28,12 +35,12 @@ func handleMsgSubmitEvidence(ctx sdk.Context, k Keeper, msg MsgSubmitEvidence) (
|
|||
sdk.NewEvent(
|
||||
sdk.EventTypeMessage,
|
||||
sdk.NewAttribute(sdk.AttributeKeyModule, AttributeValueCategory),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.Submitter.String()),
|
||||
sdk.NewAttribute(sdk.AttributeKeySender, msg.GetSubmitter().String()),
|
||||
),
|
||||
)
|
||||
|
||||
return &sdk.Result{
|
||||
Data: msg.Evidence.Hash(),
|
||||
Data: evidence.Hash(),
|
||||
Events: ctx.EventManager().Events(),
|
||||
}, nil
|
||||
}
|
||||
|
|
|
@ -1,102 +1,118 @@
|
|||
package evidence_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
type HandlerTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
ctx sdk.Context
|
||||
handler sdk.Handler
|
||||
keeper evidence.Keeper
|
||||
app *simapp.SimApp
|
||||
}
|
||||
|
||||
func testEquivocationHandler(k interface{}) types.Handler {
|
||||
return func(ctx sdk.Context, e exported.Evidence) error {
|
||||
if err := e.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ee, ok := e.(*types.Equivocation)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected evidence type: %T", e)
|
||||
}
|
||||
if ee.Height%2 == 0 {
|
||||
return fmt.Errorf("unexpected even evidence height: %d", ee.Height)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *HandlerTestSuite) SetupTest() {
|
||||
checkTx := false
|
||||
app := simapp.Setup(checkTx)
|
||||
|
||||
// get the app's codec and register custom testing types
|
||||
cdc := app.Codec()
|
||||
cdc.RegisterConcrete(types.TestEquivocationEvidence{}, "test/TestEquivocationEvidence", nil)
|
||||
|
||||
// recreate keeper in order to use custom testing types
|
||||
evidenceKeeper := evidence.NewKeeper(
|
||||
cdc, app.GetKey(evidence.StoreKey), app.GetSubspace(evidence.ModuleName), app.StakingKeeper, app.SlashingKeeper,
|
||||
simappcodec.NewAppCodec(app.Codec()), app.GetKey(evidence.StoreKey),
|
||||
app.GetSubspace(evidence.ModuleName), app.StakingKeeper, app.SlashingKeeper,
|
||||
)
|
||||
router := evidence.NewRouter()
|
||||
router = router.AddRoute(types.TestEvidenceRouteEquivocation, types.TestEquivocationHandler(*evidenceKeeper))
|
||||
router = router.AddRoute(types.RouteEquivocation, testEquivocationHandler(*evidenceKeeper))
|
||||
evidenceKeeper.SetRouter(router)
|
||||
|
||||
suite.ctx = app.BaseApp.NewContext(checkTx, abci.Header{Height: 1})
|
||||
app.EvidenceKeeper = *evidenceKeeper
|
||||
|
||||
suite.handler = evidence.NewHandler(*evidenceKeeper)
|
||||
suite.keeper = *evidenceKeeper
|
||||
suite.app = app
|
||||
}
|
||||
|
||||
func (suite *HandlerTestSuite) TestMsgSubmitEvidence_Valid() {
|
||||
func (suite *HandlerTestSuite) TestMsgSubmitEvidence() {
|
||||
pk := ed25519.GenPrivKey()
|
||||
sv := types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: 11,
|
||||
Round: 0,
|
||||
}
|
||||
|
||||
sig, err := pk.Sign(sv.SignBytes(suite.ctx.ChainID()))
|
||||
suite.NoError(err)
|
||||
sv.Signature = sig
|
||||
|
||||
s := sdk.AccAddress("test")
|
||||
e := types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: sv,
|
||||
|
||||
testCases := []struct {
|
||||
msg sdk.Msg
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
simappcodec.NewMsgSubmitEvidence(
|
||||
&types.Equivocation{
|
||||
Height: 11,
|
||||
Time: time.Now().UTC(),
|
||||
Power: 100,
|
||||
ConsensusAddress: pk.PubKey().Address().Bytes(),
|
||||
},
|
||||
s,
|
||||
),
|
||||
false,
|
||||
},
|
||||
{
|
||||
simappcodec.NewMsgSubmitEvidence(
|
||||
&types.Equivocation{
|
||||
Height: 10,
|
||||
Time: time.Now().UTC(),
|
||||
Power: 100,
|
||||
ConsensusAddress: pk.PubKey().Address().Bytes(),
|
||||
},
|
||||
s,
|
||||
),
|
||||
true,
|
||||
},
|
||||
{
|
||||
types.NewMsgSubmitEvidenceBase(s),
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
msg := evidence.NewMsgSubmitEvidence(e, s)
|
||||
res, err := suite.handler(ctx, msg)
|
||||
suite.NoError(err)
|
||||
suite.NotNil(res)
|
||||
suite.Equal(e.Hash().Bytes(), res.Data)
|
||||
}
|
||||
for i, tc := range testCases {
|
||||
ctx := suite.app.BaseApp.NewContext(false, abci.Header{Height: suite.app.LastBlockHeight() + 1})
|
||||
|
||||
func (suite *HandlerTestSuite) TestMsgSubmitEvidence_Invalid() {
|
||||
pk := ed25519.GenPrivKey()
|
||||
sv := types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: 11,
|
||||
Round: 0,
|
||||
res, err := suite.handler(ctx, tc.msg)
|
||||
if tc.expectErr {
|
||||
suite.Require().Error(err, "expected error; tc #%d", i)
|
||||
} else {
|
||||
suite.Require().NoError(err, "unexpected error; tc #%d", i)
|
||||
suite.Require().NotNil(res, "expected non-nil result; tc #%d", i)
|
||||
|
||||
msg := tc.msg.(simappcodec.MsgSubmitEvidence)
|
||||
suite.Require().Equal(msg.GetEvidence().Hash().Bytes(), res.Data, "invalid hash; tc #%d", i)
|
||||
}
|
||||
}
|
||||
|
||||
sig, err := pk.Sign(sv.SignBytes(suite.ctx.ChainID()))
|
||||
suite.NoError(err)
|
||||
sv.Signature = sig
|
||||
|
||||
s := sdk.AccAddress("test")
|
||||
e := types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: types.TestVote{Height: 10, Round: 1},
|
||||
}
|
||||
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
msg := evidence.NewMsgSubmitEvidence(e, s)
|
||||
res, err := suite.handler(ctx, msg)
|
||||
suite.Error(err)
|
||||
suite.Nil(res)
|
||||
}
|
||||
|
||||
func TestHandlerTestSuite(t *testing.T) {
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
)
|
||||
|
||||
func (suite *KeeperTestSuite) TestParams() {
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
suite.Equal(types.DefaultParams(), suite.keeper.GetParams(ctx))
|
||||
suite.Equal(types.DefaultMaxEvidenceAge, suite.keeper.MaxEvidenceAge(ctx))
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
)
|
||||
|
||||
// ModuleCdc defines the evidence module's codec. The codec is not sealed as to
|
||||
// allow other modules to register their concrete Evidence types.
|
||||
var ModuleCdc = codec.New()
|
||||
|
||||
// RegisterCodec registers all the necessary types and interfaces for the
|
||||
// evidence module.
|
||||
func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterInterface((*exported.Evidence)(nil), nil)
|
||||
cdc.RegisterConcrete(MsgSubmitEvidence{}, "cosmos-sdk/MsgSubmitEvidence", nil)
|
||||
cdc.RegisterConcrete(Equivocation{}, "cosmos-sdk/Equivocation", nil)
|
||||
}
|
||||
|
||||
// RegisterEvidenceTypeCodec registers an external concrete Evidence type defined
|
||||
// in another module for the internal ModuleCdc. This allows the MsgSubmitEvidence
|
||||
// to be correctly Amino encoded and decoded.
|
||||
func RegisterEvidenceTypeCodec(o interface{}, name string) {
|
||||
ModuleCdc.RegisterConcrete(o, name, nil)
|
||||
}
|
||||
|
||||
func init() {
|
||||
RegisterCodec(ModuleCdc)
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
tmbytes "github.com/tendermint/tendermint/libs/bytes"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
)
|
||||
|
||||
var _ exported.Evidence = (*testEvidence)(nil)
|
||||
|
||||
type testEvidence struct{}
|
||||
|
||||
func (te testEvidence) Route() string { return "" }
|
||||
func (te testEvidence) Type() string { return "" }
|
||||
func (te testEvidence) String() string { return "" }
|
||||
func (te testEvidence) ValidateBasic() error { return nil }
|
||||
func (te testEvidence) GetConsensusAddress() sdk.ConsAddress { return nil }
|
||||
func (te testEvidence) Hash() tmbytes.HexBytes { return nil }
|
||||
func (te testEvidence) GetHeight() int64 { return 0 }
|
||||
func (te testEvidence) GetValidatorPower() int64 { return 0 }
|
||||
func (te testEvidence) GetTotalPower() int64 { return 0 }
|
||||
|
||||
func TestCodec(t *testing.T) {
|
||||
cdc := codec.New()
|
||||
types.RegisterCodec(cdc)
|
||||
types.RegisterEvidenceTypeCodec(testEvidence{}, "cosmos-sdk/testEvidence")
|
||||
|
||||
var e exported.Evidence = testEvidence{}
|
||||
bz, err := cdc.MarshalBinaryBare(e)
|
||||
require.NoError(t, err)
|
||||
|
||||
var te testEvidence
|
||||
require.NoError(t, cdc.UnmarshalBinaryBare(bz, &te))
|
||||
|
||||
require.Panics(t, func() { types.RegisterEvidenceTypeCodec(testEvidence{}, "cosmos-sdk/testEvidence") })
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
)
|
||||
|
||||
// Message types for the evidence module
|
||||
const (
|
||||
TypeMsgSubmitEvidence = "submit_evidence"
|
||||
)
|
||||
|
||||
var (
|
||||
_ sdk.Msg = MsgSubmitEvidence{}
|
||||
)
|
||||
|
||||
// MsgSubmitEvidence defines an sdk.Msg type that supports submitting arbitrary
|
||||
// Evidence.
|
||||
type MsgSubmitEvidence struct {
|
||||
Evidence exported.Evidence `json:"evidence" yaml:"evidence"`
|
||||
Submitter sdk.AccAddress `json:"submitter" yaml:"submitter"`
|
||||
}
|
||||
|
||||
func NewMsgSubmitEvidence(e exported.Evidence, s sdk.AccAddress) MsgSubmitEvidence {
|
||||
return MsgSubmitEvidence{Evidence: e, Submitter: s}
|
||||
}
|
||||
|
||||
// Route returns the MsgSubmitEvidence's route.
|
||||
func (m MsgSubmitEvidence) Route() string { return RouterKey }
|
||||
|
||||
// Type returns the MsgSubmitEvidence's type.
|
||||
func (m MsgSubmitEvidence) Type() string { return TypeMsgSubmitEvidence }
|
||||
|
||||
// ValidateBasic performs basic (non-state-dependant) validation on a MsgSubmitEvidence.
|
||||
func (m MsgSubmitEvidence) ValidateBasic() error {
|
||||
if m.Evidence == nil {
|
||||
return sdkerrors.Wrap(ErrInvalidEvidence, "missing evidence")
|
||||
}
|
||||
if err := m.Evidence.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
if m.Submitter.Empty() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, m.Submitter.String())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes returns the raw bytes a signer is expected to sign when submitting
|
||||
// a MsgSubmitEvidence message.
|
||||
func (m MsgSubmitEvidence) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m))
|
||||
}
|
||||
|
||||
// GetSigners returns the single expected signer for a MsgSubmitEvidence.
|
||||
func (m MsgSubmitEvidence) GetSigners() []sdk.AccAddress {
|
||||
return []sdk.AccAddress{m.Submitter}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
)
|
||||
|
||||
func TestMsgSubmitEvidence(t *testing.T) {
|
||||
pk := ed25519.GenPrivKey()
|
||||
sv := types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: 11,
|
||||
Round: 0,
|
||||
}
|
||||
sig, err := pk.Sign(sv.SignBytes("test-chain"))
|
||||
require.NoError(t, err)
|
||||
sv.Signature = sig
|
||||
|
||||
submitter := sdk.AccAddress("test")
|
||||
testCases := []struct {
|
||||
evidence exported.Evidence
|
||||
submitter sdk.AccAddress
|
||||
expectErr bool
|
||||
}{
|
||||
{nil, submitter, true},
|
||||
{
|
||||
types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: sv,
|
||||
},
|
||||
submitter,
|
||||
false,
|
||||
},
|
||||
{
|
||||
types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: types.TestVote{Height: 10, Round: 1},
|
||||
},
|
||||
submitter,
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
msg := types.NewMsgSubmitEvidence(tc.evidence, tc.submitter)
|
||||
require.Equal(t, msg.Route(), types.RouterKey, "unexpected result for tc #%d", i)
|
||||
require.Equal(t, msg.Type(), types.TypeMsgSubmitEvidence, "unexpected result for tc #%d", i)
|
||||
require.Equal(t, tc.expectErr, msg.ValidateBasic() != nil, "unexpected result for tc #%d", i)
|
||||
|
||||
if !tc.expectErr {
|
||||
require.Equal(t, msg.GetSigners(), []sdk.AccAddress{tc.submitter}, "unexpected result for tc #%d", i)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
/*
|
||||
Common testing types and utility functions and methods to be used in unit and
|
||||
integration testing of the evidence module.
|
||||
*/
|
||||
// DONTCOVER
|
||||
package types
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
tmbytes "github.com/tendermint/tendermint/libs/bytes"
|
||||
)
|
||||
|
||||
var (
|
||||
_ exported.Evidence = (*TestEquivocationEvidence)(nil)
|
||||
|
||||
TestingCdc = codec.New()
|
||||
)
|
||||
|
||||
const (
|
||||
TestEvidenceRouteEquivocation = "TestEquivocationEvidence"
|
||||
TestEvidenceTypeEquivocation = "equivocation"
|
||||
)
|
||||
|
||||
type (
|
||||
TestVote struct {
|
||||
Height int64
|
||||
Round int64
|
||||
Timestamp time.Time
|
||||
ValidatorAddress tmbytes.HexBytes
|
||||
Signature []byte
|
||||
}
|
||||
|
||||
TestCanonicalVote struct {
|
||||
Height int64
|
||||
Round int64
|
||||
Timestamp time.Time
|
||||
ChainID string
|
||||
}
|
||||
|
||||
TestEquivocationEvidence struct {
|
||||
Power int64
|
||||
TotalPower int64
|
||||
PubKey crypto.PubKey
|
||||
VoteA TestVote
|
||||
VoteB TestVote
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterCodec(TestingCdc)
|
||||
codec.RegisterCrypto(TestingCdc)
|
||||
TestingCdc.RegisterConcrete(TestEquivocationEvidence{}, "test/TestEquivocationEvidence", nil)
|
||||
}
|
||||
|
||||
func (e TestEquivocationEvidence) Route() string { return TestEvidenceRouteEquivocation }
|
||||
func (e TestEquivocationEvidence) Type() string { return TestEvidenceTypeEquivocation }
|
||||
func (e TestEquivocationEvidence) GetHeight() int64 { return e.VoteA.Height }
|
||||
func (e TestEquivocationEvidence) GetValidatorPower() int64 { return e.Power }
|
||||
func (e TestEquivocationEvidence) GetTotalPower() int64 { return e.TotalPower }
|
||||
|
||||
func (e TestEquivocationEvidence) String() string {
|
||||
bz, _ := yaml.Marshal(e)
|
||||
return string(bz)
|
||||
}
|
||||
|
||||
func (e TestEquivocationEvidence) GetConsensusAddress() sdk.ConsAddress {
|
||||
return sdk.ConsAddress(e.PubKey.Address())
|
||||
}
|
||||
|
||||
func (e TestEquivocationEvidence) ValidateBasic() error {
|
||||
if e.VoteA.Height != e.VoteB.Height ||
|
||||
e.VoteA.Round != e.VoteB.Round {
|
||||
return fmt.Errorf("H/R/S does not match (got %v and %v)", e.VoteA, e.VoteB)
|
||||
}
|
||||
|
||||
if !bytes.Equal(e.VoteA.ValidatorAddress, e.VoteB.ValidatorAddress) {
|
||||
return fmt.Errorf(
|
||||
"validator addresses do not match (got %X and %X)",
|
||||
e.VoteA.ValidatorAddress,
|
||||
e.VoteB.ValidatorAddress,
|
||||
)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e TestEquivocationEvidence) Hash() tmbytes.HexBytes {
|
||||
return tmhash.Sum(TestingCdc.MustMarshalBinaryBare(e))
|
||||
}
|
||||
|
||||
func (v TestVote) SignBytes(chainID string) []byte {
|
||||
scv := TestCanonicalVote{
|
||||
Height: v.Height,
|
||||
Round: v.Round,
|
||||
Timestamp: v.Timestamp,
|
||||
ChainID: chainID,
|
||||
}
|
||||
bz, _ := TestingCdc.MarshalBinaryLengthPrefixed(scv)
|
||||
return bz
|
||||
}
|
||||
|
||||
func TestEquivocationHandler(k interface{}) Handler {
|
||||
return func(ctx sdk.Context, e exported.Evidence) error {
|
||||
if err := e.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ee, ok := e.(TestEquivocationEvidence)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected evidence type: %T", e)
|
||||
}
|
||||
if !ee.PubKey.VerifyBytes(ee.VoteA.SignBytes(ctx.ChainID()), ee.VoteA.Signature) {
|
||||
return errors.New("failed to verify vote A signature")
|
||||
}
|
||||
if !ee.PubKey.VerifyBytes(ee.VoteB.SignBytes(ctx.ChainID()), ee.VoteB.Signature) {
|
||||
return errors.New("failed to verify vote B signature")
|
||||
}
|
||||
|
||||
// TODO: Slashing!
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
// HandleDoubleSign implements an equivocation evidence handler. Assuming the
|
|
@ -4,7 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto"
|
||||
|
@ -51,7 +51,7 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign() {
|
|||
Power: power,
|
||||
ConsensusAddress: sdk.ConsAddress(val.Address()),
|
||||
}
|
||||
suite.keeper.HandleDoubleSign(ctx, evidence)
|
||||
suite.app.EvidenceKeeper.HandleDoubleSign(ctx, evidence)
|
||||
|
||||
// should be jailed and tombstoned
|
||||
suite.True(suite.app.StakingKeeper.Validator(ctx, operatorAddr).IsJailed())
|
||||
|
@ -62,7 +62,7 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign() {
|
|||
suite.True(newTokens.LT(oldTokens))
|
||||
|
||||
// submit duplicate evidence
|
||||
suite.keeper.HandleDoubleSign(ctx, evidence)
|
||||
suite.app.EvidenceKeeper.HandleDoubleSign(ctx, evidence)
|
||||
|
||||
// tokens should be the same (capped slash)
|
||||
suite.True(suite.app.StakingKeeper.Validator(ctx, operatorAddr).GetTokens().Equal(newTokens))
|
||||
|
@ -113,7 +113,7 @@ func (suite *KeeperTestSuite) TestHandleDoubleSign_TooOld() {
|
|||
ConsensusAddress: sdk.ConsAddress(val.Address()),
|
||||
}
|
||||
ctx = ctx.WithBlockTime(ctx.BlockTime().Add(suite.app.EvidenceKeeper.MaxEvidenceAge(ctx) + 1))
|
||||
suite.keeper.HandleDoubleSign(ctx, evidence)
|
||||
suite.app.EvidenceKeeper.HandleDoubleSign(ctx, evidence)
|
||||
|
||||
suite.False(suite.app.StakingKeeper.Validator(ctx, operatorAddr).IsJailed())
|
||||
suite.False(suite.app.SlashingKeeper.IsTombstoned(ctx, sdk.ConsAddress(val.Address())))
|
|
@ -6,12 +6,11 @@ import (
|
|||
tmbytes "github.com/tendermint/tendermint/libs/bytes"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
|
@ -19,7 +18,7 @@ import (
|
|||
// managing persistence, state transitions and query handling for the evidence
|
||||
// module.
|
||||
type Keeper struct {
|
||||
cdc *codec.Codec
|
||||
cdc types.Codec
|
||||
storeKey sdk.StoreKey
|
||||
paramSpace paramtypes.Subspace
|
||||
router types.Router
|
||||
|
@ -28,7 +27,7 @@ type Keeper struct {
|
|||
}
|
||||
|
||||
func NewKeeper(
|
||||
cdc *codec.Codec, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace,
|
||||
cdc types.Codec, storeKey sdk.StoreKey, paramSpace paramtypes.Subspace,
|
||||
stakingKeeper types.StakingKeeper, slashingKeeper types.SlashingKeeper,
|
||||
) *Keeper {
|
||||
|
||||
|
@ -110,13 +109,12 @@ func (k Keeper) SubmitEvidence(ctx sdk.Context, evidence exported.Evidence) erro
|
|||
// SetEvidence sets Evidence by hash in the module's KVStore.
|
||||
func (k Keeper) SetEvidence(ctx sdk.Context, evidence exported.Evidence) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixEvidence)
|
||||
bz := k.cdc.MustMarshalBinaryLengthPrefixed(evidence)
|
||||
store.Set(evidence.Hash(), bz)
|
||||
store.Set(evidence.Hash(), k.MustMarshalEvidence(evidence))
|
||||
}
|
||||
|
||||
// GetEvidence retrieves Evidence by hash if it exists. If no Evidence exists for
|
||||
// the given hash, (nil, false) is returned.
|
||||
func (k Keeper) GetEvidence(ctx sdk.Context, hash tmbytes.HexBytes) (evidence exported.Evidence, found bool) {
|
||||
func (k Keeper) GetEvidence(ctx sdk.Context, hash tmbytes.HexBytes) (exported.Evidence, bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixEvidence)
|
||||
|
||||
bz := store.Get(hash)
|
||||
|
@ -124,8 +122,7 @@ func (k Keeper) GetEvidence(ctx sdk.Context, hash tmbytes.HexBytes) (evidence ex
|
|||
return nil, false
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(bz, &evidence)
|
||||
return evidence, true
|
||||
return k.MustUnmarshalEvidence(bz), true
|
||||
}
|
||||
|
||||
// IterateEvidence provides an interator over all stored Evidence objects. For
|
||||
|
@ -137,8 +134,7 @@ func (k Keeper) IterateEvidence(ctx sdk.Context, cb func(exported.Evidence) bool
|
|||
|
||||
defer iterator.Close()
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var evidence exported.Evidence
|
||||
k.cdc.MustUnmarshalBinaryLengthPrefixed(iterator.Value(), &evidence)
|
||||
evidence := k.MustUnmarshalEvidence(iterator.Value())
|
||||
|
||||
if cb(evidence) {
|
||||
break
|
||||
|
@ -152,5 +148,28 @@ func (k Keeper) GetAllEvidence(ctx sdk.Context) (evidence []exported.Evidence) {
|
|||
evidence = append(evidence, e)
|
||||
return false
|
||||
})
|
||||
|
||||
return evidence
|
||||
}
|
||||
|
||||
// MustUnmarshalEvidence attempts to decode and return an Evidence object from
|
||||
// raw encoded bytes. It panics on error.
|
||||
func (k Keeper) MustUnmarshalEvidence(bz []byte) exported.Evidence {
|
||||
evidence, err := k.cdc.UnmarshalEvidence(bz)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to decode evidence: %w", err))
|
||||
}
|
||||
|
||||
return evidence
|
||||
}
|
||||
|
||||
// MustMarshalEvidence attempts to encode an Evidence object and returns the
|
||||
// raw encoded bytes. It panics on error.
|
||||
func (k Keeper) MustMarshalEvidence(evidence exported.Evidence) []byte {
|
||||
bz, err := k.cdc.MarshalEvidence(evidence)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("failed to encode evidence: %w", err))
|
||||
}
|
||||
|
||||
return bz
|
||||
}
|
|
@ -2,15 +2,18 @@ package keeper_test
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/supply"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
@ -48,12 +51,29 @@ func newPubKey(pk string) (res crypto.PubKey) {
|
|||
return pubkey
|
||||
}
|
||||
|
||||
func testEquivocationHandler(k interface{}) types.Handler {
|
||||
return func(ctx sdk.Context, e exported.Evidence) error {
|
||||
if err := e.ValidateBasic(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ee, ok := e.(types.Equivocation)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected evidence type: %T", e)
|
||||
}
|
||||
if ee.Height%2 == 0 {
|
||||
return fmt.Errorf("unexpected even evidence height: %d", ee.Height)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
type KeeperTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
ctx sdk.Context
|
||||
querier sdk.Querier
|
||||
keeper keeper.Keeper
|
||||
app *simapp.SimApp
|
||||
}
|
||||
|
||||
|
@ -61,21 +81,19 @@ func (suite *KeeperTestSuite) SetupTest() {
|
|||
checkTx := false
|
||||
app := simapp.Setup(checkTx)
|
||||
|
||||
// get the app's codec and register custom testing types
|
||||
cdc := app.Codec()
|
||||
cdc.RegisterConcrete(types.TestEquivocationEvidence{}, "test/TestEquivocationEvidence", nil)
|
||||
|
||||
// recreate keeper in order to use custom testing types
|
||||
evidenceKeeper := evidence.NewKeeper(
|
||||
cdc, app.GetKey(evidence.StoreKey), app.GetSubspace(evidence.ModuleName), app.StakingKeeper, app.SlashingKeeper,
|
||||
simappcodec.NewAppCodec(app.Codec()), app.GetKey(evidence.StoreKey),
|
||||
app.GetSubspace(evidence.ModuleName), app.StakingKeeper, app.SlashingKeeper,
|
||||
)
|
||||
router := evidence.NewRouter()
|
||||
router = router.AddRoute(types.TestEvidenceRouteEquivocation, types.TestEquivocationHandler(*evidenceKeeper))
|
||||
router = router.AddRoute(types.RouteEquivocation, testEquivocationHandler(*evidenceKeeper))
|
||||
evidenceKeeper.SetRouter(router)
|
||||
|
||||
app.EvidenceKeeper = *evidenceKeeper
|
||||
|
||||
suite.ctx = app.BaseApp.NewContext(checkTx, abci.Header{Height: 1})
|
||||
suite.querier = keeper.NewQuerier(*evidenceKeeper)
|
||||
suite.keeper = *evidenceKeeper
|
||||
suite.app = app
|
||||
|
||||
for i, addr := range valAddresses {
|
||||
|
@ -89,25 +107,15 @@ func (suite *KeeperTestSuite) populateEvidence(ctx sdk.Context, numEvidence int)
|
|||
|
||||
for i := 0; i < numEvidence; i++ {
|
||||
pk := ed25519.GenPrivKey()
|
||||
sv := types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: int64(i),
|
||||
Round: 0,
|
||||
|
||||
evidence[i] = types.Equivocation{
|
||||
Height: 11,
|
||||
Power: 100,
|
||||
Time: time.Now().UTC(),
|
||||
ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()),
|
||||
}
|
||||
|
||||
sig, err := pk.Sign(sv.SignBytes(ctx.ChainID()))
|
||||
suite.NoError(err)
|
||||
sv.Signature = sig
|
||||
|
||||
evidence[i] = types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: sv,
|
||||
}
|
||||
|
||||
suite.Nil(suite.keeper.SubmitEvidence(ctx, evidence[i]))
|
||||
suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, evidence[i]))
|
||||
}
|
||||
|
||||
return evidence
|
||||
|
@ -128,82 +136,53 @@ func (suite *KeeperTestSuite) populateValidators(ctx sdk.Context) {
|
|||
func (suite *KeeperTestSuite) TestSubmitValidEvidence() {
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
pk := ed25519.GenPrivKey()
|
||||
sv := types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: 11,
|
||||
Round: 0,
|
||||
|
||||
e := types.Equivocation{
|
||||
Height: 1,
|
||||
Power: 100,
|
||||
Time: time.Now().UTC(),
|
||||
ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()),
|
||||
}
|
||||
|
||||
sig, err := pk.Sign(sv.SignBytes(ctx.ChainID()))
|
||||
suite.NoError(err)
|
||||
sv.Signature = sig
|
||||
suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e))
|
||||
|
||||
e := types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: sv,
|
||||
}
|
||||
|
||||
suite.Nil(suite.keeper.SubmitEvidence(ctx, e))
|
||||
|
||||
res, ok := suite.keeper.GetEvidence(ctx, e.Hash())
|
||||
res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash())
|
||||
suite.True(ok)
|
||||
suite.Equal(e, res)
|
||||
suite.Equal(&e, res)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestSubmitValidEvidence_Duplicate() {
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
pk := ed25519.GenPrivKey()
|
||||
sv := types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: 11,
|
||||
Round: 0,
|
||||
|
||||
e := types.Equivocation{
|
||||
Height: 1,
|
||||
Power: 100,
|
||||
Time: time.Now().UTC(),
|
||||
ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()),
|
||||
}
|
||||
|
||||
sig, err := pk.Sign(sv.SignBytes(ctx.ChainID()))
|
||||
suite.NoError(err)
|
||||
sv.Signature = sig
|
||||
suite.Nil(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e))
|
||||
suite.Error(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e))
|
||||
|
||||
e := types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: sv,
|
||||
}
|
||||
|
||||
suite.Nil(suite.keeper.SubmitEvidence(ctx, e))
|
||||
suite.Error(suite.keeper.SubmitEvidence(ctx, e))
|
||||
|
||||
res, ok := suite.keeper.GetEvidence(ctx, e.Hash())
|
||||
res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash())
|
||||
suite.True(ok)
|
||||
suite.Equal(e, res)
|
||||
suite.Equal(&e, res)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestSubmitInvalidEvidence() {
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
pk := ed25519.GenPrivKey()
|
||||
e := types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: 10,
|
||||
Round: 0,
|
||||
},
|
||||
VoteB: types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: 11,
|
||||
Round: 0,
|
||||
},
|
||||
e := types.Equivocation{
|
||||
Height: 0,
|
||||
Power: 100,
|
||||
Time: time.Now().UTC(),
|
||||
ConsensusAddress: sdk.ConsAddress(pk.PubKey().Address().Bytes()),
|
||||
}
|
||||
|
||||
suite.Error(suite.keeper.SubmitEvidence(ctx, e))
|
||||
suite.Error(suite.app.EvidenceKeeper.SubmitEvidence(ctx, e))
|
||||
|
||||
res, ok := suite.keeper.GetEvidence(ctx, e.Hash())
|
||||
res, ok := suite.app.EvidenceKeeper.GetEvidence(ctx, e.Hash())
|
||||
suite.False(ok)
|
||||
suite.Nil(res)
|
||||
}
|
||||
|
@ -213,16 +192,16 @@ func (suite *KeeperTestSuite) TestIterateEvidence() {
|
|||
numEvidence := 100
|
||||
suite.populateEvidence(ctx, numEvidence)
|
||||
|
||||
evidence := suite.keeper.GetAllEvidence(ctx)
|
||||
evidence := suite.app.EvidenceKeeper.GetAllEvidence(ctx)
|
||||
suite.Len(evidence, numEvidence)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGetEvidenceHandler() {
|
||||
handler, err := suite.keeper.GetEvidenceHandler(types.TestEquivocationEvidence{}.Route())
|
||||
handler, err := suite.app.EvidenceKeeper.GetEvidenceHandler(types.Equivocation{}.Route())
|
||||
suite.NoError(err)
|
||||
suite.NotNil(handler)
|
||||
|
||||
handler, err = suite.keeper.GetEvidenceHandler("invalidHandler")
|
||||
handler, err = suite.app.EvidenceKeeper.GetEvidenceHandler("invalidHandler")
|
||||
suite.Error(err)
|
||||
suite.Nil(handler)
|
||||
}
|
|
@ -4,7 +4,7 @@ import (
|
|||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
// MaxEvidenceAge returns the maximum age for submitted evidence.
|
|
@ -0,0 +1,11 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
func (suite *KeeperTestSuite) TestParams() {
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
suite.Equal(types.DefaultParams(), suite.app.EvidenceKeeper.GetParams(ctx))
|
||||
suite.Equal(types.DefaultMaxEvidenceAge, suite.app.EvidenceKeeper.MaxEvidenceAge(ctx))
|
||||
}
|
|
@ -8,7 +8,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
)
|
|
@ -3,8 +3,9 @@ package keeper_test
|
|||
import (
|
||||
"strings"
|
||||
|
||||
simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
)
|
||||
|
@ -16,11 +17,12 @@ const (
|
|||
func (suite *KeeperTestSuite) TestQueryEvidence_Existing() {
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
numEvidence := 100
|
||||
cdc := simappcodec.NewAppCodec(suite.app.Codec())
|
||||
|
||||
evidence := suite.populateEvidence(ctx, numEvidence)
|
||||
query := abci.RequestQuery{
|
||||
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryEvidence}, "/"),
|
||||
Data: types.TestingCdc.MustMarshalJSON(types.NewQueryEvidenceParams(evidence[0].Hash().String())),
|
||||
Data: cdc.MustMarshalJSON(types.NewQueryEvidenceParams(evidence[0].Hash().String())),
|
||||
}
|
||||
|
||||
bz, err := suite.querier(ctx, []string{types.QueryEvidence}, query)
|
||||
|
@ -28,18 +30,19 @@ func (suite *KeeperTestSuite) TestQueryEvidence_Existing() {
|
|||
suite.NotNil(bz)
|
||||
|
||||
var e exported.Evidence
|
||||
suite.Nil(types.TestingCdc.UnmarshalJSON(bz, &e))
|
||||
suite.Nil(cdc.UnmarshalJSON(bz, &e))
|
||||
suite.Equal(evidence[0], e)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryEvidence_NonExisting() {
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
cdc := simappcodec.NewAppCodec(suite.app.Codec())
|
||||
numEvidence := 100
|
||||
|
||||
suite.populateEvidence(ctx, numEvidence)
|
||||
query := abci.RequestQuery{
|
||||
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryEvidence}, "/"),
|
||||
Data: types.TestingCdc.MustMarshalJSON(types.NewQueryEvidenceParams("0000000000000000000000000000000000000000000000000000000000000000")),
|
||||
Data: cdc.MustMarshalJSON(types.NewQueryEvidenceParams("0000000000000000000000000000000000000000000000000000000000000000")),
|
||||
}
|
||||
|
||||
bz, err := suite.querier(ctx, []string{types.QueryEvidence}, query)
|
||||
|
@ -49,12 +52,13 @@ func (suite *KeeperTestSuite) TestQueryEvidence_NonExisting() {
|
|||
|
||||
func (suite *KeeperTestSuite) TestQueryAllEvidence() {
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
cdc := simappcodec.NewAppCodec(suite.app.Codec())
|
||||
numEvidence := 100
|
||||
|
||||
suite.populateEvidence(ctx, numEvidence)
|
||||
query := abci.RequestQuery{
|
||||
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryAllEvidence}, "/"),
|
||||
Data: types.TestingCdc.MustMarshalJSON(types.NewQueryAllEvidenceParams(1, numEvidence)),
|
||||
Data: cdc.MustMarshalJSON(types.NewQueryAllEvidenceParams(1, numEvidence)),
|
||||
}
|
||||
|
||||
bz, err := suite.querier(ctx, []string{types.QueryAllEvidence}, query)
|
||||
|
@ -62,18 +66,19 @@ func (suite *KeeperTestSuite) TestQueryAllEvidence() {
|
|||
suite.NotNil(bz)
|
||||
|
||||
var e []exported.Evidence
|
||||
suite.Nil(types.TestingCdc.UnmarshalJSON(bz, &e))
|
||||
suite.Nil(cdc.UnmarshalJSON(bz, &e))
|
||||
suite.Len(e, numEvidence)
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryAllEvidence_InvalidPagination() {
|
||||
ctx := suite.ctx.WithIsCheckTx(false)
|
||||
cdc := simappcodec.NewAppCodec(suite.app.Codec())
|
||||
numEvidence := 100
|
||||
|
||||
suite.populateEvidence(ctx, numEvidence)
|
||||
query := abci.RequestQuery{
|
||||
Path: strings.Join([]string{custom, types.QuerierRoute, types.QueryAllEvidence}, "/"),
|
||||
Data: types.TestingCdc.MustMarshalJSON(types.NewQueryAllEvidenceParams(0, numEvidence)),
|
||||
Data: cdc.MustMarshalJSON(types.NewQueryAllEvidenceParams(0, numEvidence)),
|
||||
}
|
||||
|
||||
bz, err := suite.querier(ctx, []string{types.QueryAllEvidence}, query)
|
||||
|
@ -81,7 +86,7 @@ func (suite *KeeperTestSuite) TestQueryAllEvidence_InvalidPagination() {
|
|||
suite.NotNil(bz)
|
||||
|
||||
var e []exported.Evidence
|
||||
suite.Nil(types.TestingCdc.UnmarshalJSON(bz, &e))
|
||||
suite.Nil(cdc.UnmarshalJSON(bz, &e))
|
||||
suite.Len(e, 0)
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
)
|
||||
|
||||
// EvidenceCodec defines the interface required to serialize evidence
|
||||
type Codec interface {
|
||||
codec.Marshaler
|
||||
|
||||
MarshalEvidence(exported.Evidence) ([]byte, error)
|
||||
UnmarshalEvidence([]byte) (exported.Evidence, error)
|
||||
MarshalEvidenceJSON(exported.Evidence) ([]byte, error)
|
||||
UnmarshalEvidenceJSON([]byte) (exported.Evidence, error)
|
||||
}
|
||||
|
||||
// RegisterCodec registers all the necessary types and interfaces for the
|
||||
// evidence module.
|
||||
func RegisterCodec(cdc *codec.Codec) {
|
||||
cdc.RegisterInterface((*exported.Evidence)(nil), nil)
|
||||
cdc.RegisterConcrete(MsgSubmitEvidenceBase{}, "cosmos-sdk/MsgSubmitEvidenceBase", nil)
|
||||
cdc.RegisterConcrete(Equivocation{}, "cosmos-sdk/Equivocation", nil)
|
||||
}
|
||||
|
||||
var (
|
||||
amino = codec.New()
|
||||
|
||||
// ModuleCdc references the global x/evidence module codec. Note, the codec should
|
||||
// ONLY be used in certain instances of tests and for JSON encoding as Amino is
|
||||
// still used for that purpose.
|
||||
//
|
||||
// The actual codec used for serialization should be provided to x/evidence and
|
||||
// defined at the application level.
|
||||
ModuleCdc = codec.NewHybridCodec(amino)
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterCodec(amino)
|
||||
codec.RegisterCrypto(amino)
|
||||
amino.Seal()
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
func TestCodec(t *testing.T) {
|
||||
app := simapp.Setup(false)
|
||||
appCodec := simappcodec.NewAppCodec(app.Codec())
|
||||
pk := ed25519.GenPrivKey()
|
||||
|
||||
var e exported.Evidence = &types.Equivocation{
|
||||
Height: 10,
|
||||
Time: time.Now().UTC(),
|
||||
Power: 100000,
|
||||
ConsensusAddress: pk.PubKey().Address().Bytes(),
|
||||
}
|
||||
bz, err := appCodec.MarshalEvidence(e)
|
||||
require.NoError(t, err)
|
||||
|
||||
other, err := appCodec.UnmarshalEvidence(bz)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, e, other)
|
||||
}
|
|
@ -21,15 +21,6 @@ const (
|
|||
|
||||
var _ exported.Evidence = (*Equivocation)(nil)
|
||||
|
||||
// Equivocation implements the Evidence interface and defines evidence of double
|
||||
// signing misbehavior.
|
||||
type Equivocation struct {
|
||||
Height int64 `json:"height" yaml:"height"`
|
||||
Time time.Time `json:"time" yaml:"time"`
|
||||
Power int64 `json:"power" yaml:"power"`
|
||||
ConsensusAddress sdk.ConsAddress `json:"consensus_address" yaml:"consensus_address"`
|
||||
}
|
||||
|
||||
// Route returns the Evidence Handler route for an Equivocation type.
|
||||
func (e Equivocation) Route() string { return RouteEquivocation }
|
||||
|
||||
|
@ -43,7 +34,7 @@ func (e Equivocation) String() string {
|
|||
|
||||
// Hash returns the hash of an Equivocation object.
|
||||
func (e Equivocation) Hash() tmbytes.HexBytes {
|
||||
return tmhash.Sum(ModuleCdc.MustMarshalBinaryBare(e))
|
||||
return tmhash.Sum(ModuleCdc.MustMarshalBinaryBare(&e))
|
||||
}
|
||||
|
||||
// ValidateBasic performs basic stateless validation checks on an Equivocation object.
|
|
@ -7,7 +7,7 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
func TestEquivocation_Valid(t *testing.T) {
|
||||
|
@ -26,7 +26,7 @@ func TestEquivocation_Valid(t *testing.T) {
|
|||
require.Equal(t, e.GetHeight(), e.Height)
|
||||
require.Equal(t, e.Type(), types.TypeEquivocation)
|
||||
require.Equal(t, e.Route(), types.RouteEquivocation)
|
||||
require.Equal(t, e.Hash().String(), "808DA679674C9C0599965D02EBC5D4DCFD5E700D03035BBCD2DECCBBF44386F7")
|
||||
require.Equal(t, e.Hash().String(), "16337536D55FB6DB93360AED8FDB9B615BFACAF0440C28C46B89F167D042154A")
|
||||
require.Equal(t, e.String(), "height: 100\ntime: 2006-01-02T15:04:05Z\npower: 1000000\nconsensus_address: cosmosvalcons1vehk7pqt5u4\n")
|
||||
require.NoError(t, e.ValidateBasic())
|
||||
}
|
|
@ -2,12 +2,13 @@ package types_test
|
|||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
func TestDefaultGenesisState(t *testing.T) {
|
||||
|
@ -21,21 +22,11 @@ func TestGenesisStateValidate_Valid(t *testing.T) {
|
|||
|
||||
evidence := make([]exported.Evidence, 100)
|
||||
for i := 0; i < 100; i++ {
|
||||
sv := types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
Height: int64(i),
|
||||
Round: 0,
|
||||
}
|
||||
sig, err := pk.Sign(sv.SignBytes("test-chain"))
|
||||
require.NoError(t, err)
|
||||
sv.Signature = sig
|
||||
|
||||
evidence[i] = types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: sv,
|
||||
evidence[i] = types.Equivocation{
|
||||
Height: int64(i) + 1,
|
||||
Power: 100,
|
||||
Time: time.Now().UTC(),
|
||||
ConsensusAddress: pk.PubKey().Address().Bytes(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,21 +39,11 @@ func TestGenesisStateValidate_Invalid(t *testing.T) {
|
|||
|
||||
evidence := make([]exported.Evidence, 100)
|
||||
for i := 0; i < 100; i++ {
|
||||
sv := types.TestVote{
|
||||
ValidatorAddress: pk.PubKey().Address(),
|
||||
evidence[i] = types.Equivocation{
|
||||
Height: int64(i),
|
||||
Round: 0,
|
||||
}
|
||||
sig, err := pk.Sign(sv.SignBytes("test-chain"))
|
||||
require.NoError(t, err)
|
||||
sv.Signature = sig
|
||||
|
||||
evidence[i] = types.TestEquivocationEvidence{
|
||||
Power: 100,
|
||||
TotalPower: 100000,
|
||||
PubKey: pk.PubKey(),
|
||||
VoteA: sv,
|
||||
VoteB: types.TestVote{Height: 10, Round: 1},
|
||||
Power: 100,
|
||||
Time: time.Now().UTC(),
|
||||
ConsensusAddress: pk.PubKey().Address().Bytes(),
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
// Message types for the evidence module
|
||||
const (
|
||||
TypeMsgSubmitEvidence = "submit_evidence"
|
||||
)
|
||||
|
||||
var (
|
||||
_ sdk.Msg = MsgSubmitEvidenceBase{}
|
||||
)
|
||||
|
||||
// NewMsgSubmitEvidenceBase returns a new MsgSubmitEvidenceBase with a signer/submitter.
|
||||
// Note, the MsgSubmitEvidenceBase is not to be used as an actual message, but
|
||||
// rather to be extended with Evidence.
|
||||
func NewMsgSubmitEvidenceBase(s sdk.AccAddress) MsgSubmitEvidenceBase {
|
||||
return MsgSubmitEvidenceBase{Submitter: s}
|
||||
}
|
||||
|
||||
// Route returns the MsgSubmitEvidenceBase's route.
|
||||
func (m MsgSubmitEvidenceBase) Route() string { return RouterKey }
|
||||
|
||||
// Type returns the MsgSubmitEvidenceBase's type.
|
||||
func (m MsgSubmitEvidenceBase) Type() string { return TypeMsgSubmitEvidence }
|
||||
|
||||
// ValidateBasic performs basic (non-state-dependant) validation on a MsgSubmitEvidenceBase.
|
||||
func (m MsgSubmitEvidenceBase) ValidateBasic() error {
|
||||
if m.Submitter.Empty() {
|
||||
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, m.Submitter.String())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetSignBytes returns the raw bytes a signer is expected to sign when submitting
|
||||
// a MsgSubmitEvidenceBase message.
|
||||
func (m MsgSubmitEvidenceBase) GetSignBytes() []byte {
|
||||
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(m))
|
||||
}
|
||||
|
||||
// GetSigners returns the single expected signer for a MsgSubmitEvidenceBase.
|
||||
func (m MsgSubmitEvidenceBase) GetSigners() []sdk.AccAddress {
|
||||
return []sdk.AccAddress{m.Submitter}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package types_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
simappcodec "github.com/cosmos/cosmos-sdk/simapp/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
)
|
||||
|
||||
func TestMsgSubmitEvidence(t *testing.T) {
|
||||
pk := ed25519.GenPrivKey()
|
||||
submitter := sdk.AccAddress("test")
|
||||
|
||||
testCases := []struct {
|
||||
msg sdk.Msg
|
||||
submitter sdk.AccAddress
|
||||
expectErr bool
|
||||
}{
|
||||
{
|
||||
types.NewMsgSubmitEvidenceBase(submitter),
|
||||
submitter,
|
||||
false,
|
||||
},
|
||||
{
|
||||
simappcodec.NewMsgSubmitEvidence(&types.Equivocation{
|
||||
Height: 0,
|
||||
Power: 100,
|
||||
Time: time.Now().UTC(),
|
||||
ConsensusAddress: pk.PubKey().Address().Bytes(),
|
||||
}, submitter),
|
||||
submitter,
|
||||
true,
|
||||
},
|
||||
{
|
||||
simappcodec.NewMsgSubmitEvidence(&types.Equivocation{
|
||||
Height: 10,
|
||||
Power: 100,
|
||||
Time: time.Now().UTC(),
|
||||
ConsensusAddress: pk.PubKey().Address().Bytes(),
|
||||
}, submitter),
|
||||
submitter,
|
||||
false,
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
require.Equal(t, tc.msg.Route(), types.RouterKey, "unexpected result for tc #%d", i)
|
||||
require.Equal(t, tc.msg.Type(), types.TypeMsgSubmitEvidence, "unexpected result for tc #%d", i)
|
||||
require.Equal(t, tc.expectErr, tc.msg.ValidateBasic() != nil, "unexpected result for tc #%d", i)
|
||||
|
||||
if !tc.expectErr {
|
||||
require.Equal(t, tc.msg.GetSigners(), []sdk.AccAddress{tc.submitter}, "unexpected result for tc #%d", i)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,11 +26,6 @@ var (
|
|||
DoubleSignJailEndTime = time.Unix(253402300799, 0)
|
||||
)
|
||||
|
||||
// Params defines the total set of parameters for the evidence module
|
||||
type Params struct {
|
||||
MaxEvidenceAge time.Duration `json:"max_evidence_age" yaml:"max_evidence_age"`
|
||||
}
|
||||
|
||||
// ParamKeyTable returns the parameter key table.
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence/types"
|
||||
)
|
||||
|
||||
func testHandler(sdk.Context, exported.Evidence) error { return nil }
|
|
@ -0,0 +1,876 @@
|
|||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: x/evidence/types/types.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
bytes "bytes"
|
||||
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"
|
||||
github_com_gogo_protobuf_types "github.com/gogo/protobuf/types"
|
||||
_ "github.com/golang/protobuf/ptypes/duration"
|
||||
_ "github.com/golang/protobuf/ptypes/timestamp"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
time "time"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
var _ = time.Kitchen
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
// MsgSubmitEvidenceBase defines an sdk.Msg type that supports submitting arbitrary
|
||||
// Evidence.
|
||||
//
|
||||
// Note, this message type provides the basis for which a true MsgSubmitEvidence
|
||||
// can be constructed. Since the evidence submitted in the message can be arbitrary,
|
||||
// assuming it fulfills the Evidence interface, it must be defined at the
|
||||
// application-level and extend MsgSubmitEvidenceBase.
|
||||
type MsgSubmitEvidenceBase struct {
|
||||
Submitter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,1,opt,name=submitter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"submitter,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MsgSubmitEvidenceBase) Reset() { *m = MsgSubmitEvidenceBase{} }
|
||||
func (m *MsgSubmitEvidenceBase) String() string { return proto.CompactTextString(m) }
|
||||
func (*MsgSubmitEvidenceBase) ProtoMessage() {}
|
||||
func (*MsgSubmitEvidenceBase) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_72113e6a7b2536ae, []int{0}
|
||||
}
|
||||
func (m *MsgSubmitEvidenceBase) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MsgSubmitEvidenceBase) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MsgSubmitEvidenceBase.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 *MsgSubmitEvidenceBase) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MsgSubmitEvidenceBase.Merge(m, src)
|
||||
}
|
||||
func (m *MsgSubmitEvidenceBase) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MsgSubmitEvidenceBase) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MsgSubmitEvidenceBase.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MsgSubmitEvidenceBase proto.InternalMessageInfo
|
||||
|
||||
func (m *MsgSubmitEvidenceBase) GetSubmitter() github_com_cosmos_cosmos_sdk_types.AccAddress {
|
||||
if m != nil {
|
||||
return m.Submitter
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Equivocation implements the Evidence interface and defines evidence of double
|
||||
// signing misbehavior.
|
||||
type Equivocation struct {
|
||||
Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"`
|
||||
Time time.Time `protobuf:"bytes,2,opt,name=time,proto3,stdtime" json:"time"`
|
||||
Power int64 `protobuf:"varint,3,opt,name=power,proto3" json:"power,omitempty"`
|
||||
ConsensusAddress github_com_cosmos_cosmos_sdk_types.ConsAddress `protobuf:"bytes,4,opt,name=consensus_address,json=consensusAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ConsAddress" json:"consensus_address,omitempty" yaml:"consensus_address"`
|
||||
}
|
||||
|
||||
func (m *Equivocation) Reset() { *m = Equivocation{} }
|
||||
func (*Equivocation) ProtoMessage() {}
|
||||
func (*Equivocation) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_72113e6a7b2536ae, []int{1}
|
||||
}
|
||||
func (m *Equivocation) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Equivocation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Equivocation.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 *Equivocation) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Equivocation.Merge(m, src)
|
||||
}
|
||||
func (m *Equivocation) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Equivocation) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Equivocation.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Equivocation proto.InternalMessageInfo
|
||||
|
||||
// Params defines the total set of parameters for the evidence module
|
||||
type Params struct {
|
||||
MaxEvidenceAge time.Duration `protobuf:"bytes,1,opt,name=max_evidence_age,json=maxEvidenceAge,proto3,stdduration" json:"max_evidence_age" yaml:"max_evidence_age"`
|
||||
}
|
||||
|
||||
func (m *Params) Reset() { *m = Params{} }
|
||||
func (*Params) ProtoMessage() {}
|
||||
func (*Params) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_72113e6a7b2536ae, []int{2}
|
||||
}
|
||||
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) GetMaxEvidenceAge() time.Duration {
|
||||
if m != nil {
|
||||
return m.MaxEvidenceAge
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*MsgSubmitEvidenceBase)(nil), "cosmos_sdk.x.evidence.v1.MsgSubmitEvidenceBase")
|
||||
proto.RegisterType((*Equivocation)(nil), "cosmos_sdk.x.evidence.v1.Equivocation")
|
||||
proto.RegisterType((*Params)(nil), "cosmos_sdk.x.evidence.v1.Params")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("x/evidence/types/types.proto", fileDescriptor_72113e6a7b2536ae) }
|
||||
|
||||
var fileDescriptor_72113e6a7b2536ae = []byte{
|
||||
// 455 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x3d, 0x6f, 0xd4, 0x30,
|
||||
0x1c, 0xc6, 0x63, 0x7a, 0x9c, 0x8a, 0x5b, 0xa1, 0x12, 0xf1, 0x12, 0x4e, 0x28, 0xae, 0x82, 0x84,
|
||||
0xba, 0xd4, 0x51, 0xcb, 0x82, 0x6e, 0xbb, 0x40, 0x27, 0xc4, 0x8b, 0x0e, 0x26, 0x96, 0xc8, 0x97,
|
||||
0x18, 0x27, 0x6a, 0x1d, 0x07, 0xdb, 0x39, 0x72, 0xe2, 0x0b, 0x30, 0x76, 0xec, 0xd8, 0x91, 0x8f,
|
||||
0xd2, 0xb1, 0x23, 0x53, 0x40, 0x77, 0xdf, 0xa0, 0x63, 0x25, 0x24, 0x74, 0x76, 0x42, 0xa5, 0xab,
|
||||
0x84, 0xba, 0x24, 0xb1, 0xf3, 0xe4, 0xc9, 0xf3, 0xfb, 0x3f, 0x86, 0x4f, 0xea, 0x90, 0x4e, 0xf3,
|
||||
0x94, 0x16, 0x09, 0x0d, 0xf5, 0xac, 0xa4, 0xca, 0x5e, 0x71, 0x29, 0x85, 0x16, 0xae, 0x97, 0x08,
|
||||
0xc5, 0x85, 0x8a, 0x55, 0x7a, 0x88, 0x6b, 0xdc, 0x09, 0xf1, 0x74, 0x6f, 0xf0, 0x4c, 0x67, 0xb9,
|
||||
0x4c, 0xe3, 0x92, 0x48, 0x3d, 0x0b, 0x8d, 0x38, 0x64, 0x82, 0x89, 0xab, 0x27, 0xeb, 0x30, 0x40,
|
||||
0x4c, 0x08, 0x76, 0x44, 0xad, 0x64, 0x52, 0x7d, 0x0e, 0x75, 0xce, 0xa9, 0xd2, 0x84, 0x97, 0xad,
|
||||
0xc0, 0x5f, 0x15, 0xa4, 0x95, 0x24, 0x3a, 0x17, 0x85, 0x7d, 0x1f, 0x64, 0xf0, 0xc1, 0x1b, 0xc5,
|
||||
0x3e, 0x54, 0x13, 0x9e, 0xeb, 0x83, 0x36, 0x40, 0x44, 0x14, 0x75, 0xdf, 0xc1, 0x3b, 0xca, 0xec,
|
||||
0x6a, 0x2a, 0x3d, 0xb0, 0x0d, 0x76, 0x36, 0xa3, 0xbd, 0xcb, 0x06, 0xed, 0xb2, 0x5c, 0x67, 0xd5,
|
||||
0x04, 0x27, 0x82, 0x87, 0x36, 0x7d, 0x7b, 0xdb, 0x55, 0xe9, 0x61, 0x0b, 0x37, 0x4a, 0x92, 0x51,
|
||||
0x9a, 0x4a, 0xaa, 0xd4, 0xf8, 0xca, 0x23, 0xf8, 0x03, 0xe0, 0xe6, 0xc1, 0x97, 0x2a, 0x9f, 0x8a,
|
||||
0xc4, 0x04, 0x70, 0x1f, 0xc2, 0x7e, 0x46, 0x73, 0x96, 0x69, 0x63, 0xbf, 0x36, 0x6e, 0x57, 0xee,
|
||||
0x0b, 0xd8, 0x5b, 0x52, 0x78, 0xb7, 0xb6, 0xc1, 0xce, 0xc6, 0xfe, 0x00, 0x5b, 0x02, 0xdc, 0x11,
|
||||
0xe0, 0x8f, 0x1d, 0x62, 0xb4, 0x7e, 0xd6, 0x20, 0xe7, 0xf8, 0x17, 0x02, 0x63, 0xf3, 0x85, 0x7b,
|
||||
0x1f, 0xde, 0x2e, 0xc5, 0x57, 0x2a, 0xbd, 0x35, 0x63, 0x68, 0x17, 0xee, 0x37, 0x78, 0x2f, 0x11,
|
||||
0x85, 0xa2, 0x85, 0xaa, 0x54, 0x4c, 0x6c, 0x30, 0xaf, 0x67, 0x88, 0xde, 0x5e, 0x34, 0xc8, 0x9b,
|
||||
0x11, 0x7e, 0x34, 0x0c, 0xae, 0x49, 0x82, 0xcb, 0x06, 0xe1, 0x1b, 0xd0, 0xbe, 0x14, 0x85, 0xea,
|
||||
0x70, 0xb7, 0xfe, 0xb9, 0xb4, 0x3b, 0xc3, 0xf5, 0xef, 0xa7, 0xc8, 0x39, 0x39, 0x45, 0x4e, 0x50,
|
||||
0xc3, 0xfe, 0x7b, 0x22, 0x09, 0x57, 0x6e, 0x06, 0xb7, 0x38, 0xa9, 0xe3, 0xae, 0xef, 0x98, 0x30,
|
||||
0x6a, 0x46, 0xb0, 0xb1, 0xff, 0xf8, 0x1a, 0xec, 0xab, 0xb6, 0xae, 0xe8, 0xe9, 0x92, 0xf5, 0xa2,
|
||||
0x41, 0x8f, 0x6c, 0xdc, 0x55, 0x83, 0xe0, 0x64, 0x39, 0x86, 0xbb, 0x9c, 0xd4, 0x5d, 0x8b, 0x23,
|
||||
0x46, 0x87, 0xbd, 0xe5, 0x9f, 0xa3, 0xd7, 0x3f, 0xe6, 0x3e, 0x38, 0x9b, 0xfb, 0xe0, 0x7c, 0xee,
|
||||
0x83, 0xdf, 0x73, 0x1f, 0x1c, 0x2f, 0x7c, 0xe7, 0x7c, 0xe1, 0x3b, 0x3f, 0x17, 0xbe, 0xf3, 0xe9,
|
||||
0xff, 0x8d, 0xae, 0x9e, 0xdf, 0x49, 0xdf, 0x44, 0x7b, 0xfe, 0x37, 0x00, 0x00, 0xff, 0xff, 0x35,
|
||||
0xfb, 0xe6, 0x44, 0xda, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (this *MsgSubmitEvidenceBase) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*MsgSubmitEvidenceBase)
|
||||
if !ok {
|
||||
that2, ok := that.(MsgSubmitEvidenceBase)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(this.Submitter, that1.Submitter) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *Equivocation) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*Equivocation)
|
||||
if !ok {
|
||||
that2, ok := that.(Equivocation)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if this.Height != that1.Height {
|
||||
return false
|
||||
}
|
||||
if !this.Time.Equal(that1.Time) {
|
||||
return false
|
||||
}
|
||||
if this.Power != that1.Power {
|
||||
return false
|
||||
}
|
||||
if !bytes.Equal(this.ConsensusAddress, that1.ConsensusAddress) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (this *Params) Equal(that interface{}) bool {
|
||||
if that == nil {
|
||||
return this == nil
|
||||
}
|
||||
|
||||
that1, ok := that.(*Params)
|
||||
if !ok {
|
||||
that2, ok := that.(Params)
|
||||
if ok {
|
||||
that1 = &that2
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if that1 == nil {
|
||||
return this == nil
|
||||
} else if this == nil {
|
||||
return false
|
||||
}
|
||||
if this.MaxEvidenceAge != that1.MaxEvidenceAge {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (m *MsgSubmitEvidenceBase) 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 *MsgSubmitEvidenceBase) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MsgSubmitEvidenceBase) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Submitter) > 0 {
|
||||
i -= len(m.Submitter)
|
||||
copy(dAtA[i:], m.Submitter)
|
||||
i = encodeVarintTypes(dAtA, i, uint64(len(m.Submitter)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Equivocation) 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 *Equivocation) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Equivocation) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.ConsensusAddress) > 0 {
|
||||
i -= len(m.ConsensusAddress)
|
||||
copy(dAtA[i:], m.ConsensusAddress)
|
||||
i = encodeVarintTypes(dAtA, i, uint64(len(m.ConsensusAddress)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if m.Power != 0 {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(m.Power))
|
||||
i--
|
||||
dAtA[i] = 0x18
|
||||
}
|
||||
n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.Time, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.Time):])
|
||||
if err1 != nil {
|
||||
return 0, err1
|
||||
}
|
||||
i -= n1
|
||||
i = encodeVarintTypes(dAtA, i, uint64(n1))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
if m.Height != 0 {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(m.Height))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
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
|
||||
n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MaxEvidenceAge, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxEvidenceAge):])
|
||||
if err2 != nil {
|
||||
return 0, err2
|
||||
}
|
||||
i -= n2
|
||||
i = encodeVarintTypes(dAtA, i, uint64(n2))
|
||||
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 *MsgSubmitEvidenceBase) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Submitter)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Equivocation) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Height != 0 {
|
||||
n += 1 + sovTypes(uint64(m.Height))
|
||||
}
|
||||
l = github_com_gogo_protobuf_types.SizeOfStdTime(m.Time)
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
if m.Power != 0 {
|
||||
n += 1 + sovTypes(uint64(m.Power))
|
||||
}
|
||||
l = len(m.ConsensusAddress)
|
||||
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 = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MaxEvidenceAge)
|
||||
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 *MsgSubmitEvidenceBase) 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: MsgSubmitEvidenceBase: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MsgSubmitEvidenceBase: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Submitter", 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.Submitter = append(m.Submitter[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Submitter == nil {
|
||||
m.Submitter = []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 *Equivocation) 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: Equivocation: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Equivocation: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
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 |= int64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.Time, dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Power", wireType)
|
||||
}
|
||||
m.Power = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Power |= int64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ConsensusAddress", 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.ConsensusAddress = append(m.ConsensusAddress[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.ConsensusAddress == nil {
|
||||
m.ConsensusAddress = []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 MaxEvidenceAge", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MaxEvidenceAge, 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 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")
|
||||
)
|
|
@ -0,0 +1,46 @@
|
|||
syntax = "proto3";
|
||||
package cosmos_sdk.x.evidence.v1;
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/evidence/types";
|
||||
option (gogoproto.equal_all) = true;
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
// MsgSubmitEvidenceBase defines an sdk.Msg type that supports submitting arbitrary
|
||||
// Evidence.
|
||||
//
|
||||
// Note, this message type provides the basis for which a true MsgSubmitEvidence
|
||||
// can be constructed. Since the evidence submitted in the message can be arbitrary,
|
||||
// assuming it fulfills the Evidence interface, it must be defined at the
|
||||
// application-level and extend MsgSubmitEvidenceBase.
|
||||
message MsgSubmitEvidenceBase {
|
||||
bytes submitter = 1 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
}
|
||||
|
||||
// Equivocation implements the Evidence interface and defines evidence of double
|
||||
// signing misbehavior.
|
||||
message Equivocation {
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
int64 height = 1;
|
||||
google.protobuf.Timestamp time = 2 [(gogoproto.nullable) = false, (gogoproto.stdtime) = true];
|
||||
int64 power = 3;
|
||||
bytes consensus_address = 4 [
|
||||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ConsAddress",
|
||||
(gogoproto.moretags) = "yaml:\"consensus_address\""
|
||||
];
|
||||
}
|
||||
|
||||
// Params defines the total set of parameters for the evidence module
|
||||
message Params {
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
|
||||
google.protobuf.Duration max_evidence_age = 1 [
|
||||
(gogoproto.nullable) = false,
|
||||
(gogoproto.stdduration) = true,
|
||||
(gogoproto.moretags) = "yaml:\"max_evidence_age\""
|
||||
];
|
||||
}
|
|
@ -2,7 +2,7 @@ package mint
|
|||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
// BeginBlocker mints new tokens for the previous block.
|
||||
|
|
|
@ -3,8 +3,8 @@ package mint
|
|||
// nolint
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
// GetQueryCmd returns the cli query commands for the minting module.
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
func registerQueryRoutes(cliCtx context.CLIContext, r *mux.Router) {
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
// generic sealed codec to be used throughout this module
|
||||
var ModuleCdc *codec.Codec
|
||||
|
||||
func init() {
|
||||
ModuleCdc = codec.New()
|
||||
codec.RegisterCrypto(ModuleCdc)
|
||||
ModuleCdc.Seal()
|
||||
}
|
|
@ -5,7 +5,7 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/simapp"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
// returns context and an app with updated mint keeper
|
|
@ -7,13 +7,13 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
||||
// Keeper of the mint store
|
||||
type Keeper struct {
|
||||
cdc *codec.Codec
|
||||
cdc codec.Marshaler
|
||||
storeKey sdk.StoreKey
|
||||
paramSpace paramtypes.Subspace
|
||||
sk types.StakingKeeper
|
||||
|
@ -23,7 +23,7 @@ type Keeper struct {
|
|||
|
||||
// NewKeeper creates a new mint Keeper instance
|
||||
func NewKeeper(
|
||||
cdc *codec.Codec, key sdk.StoreKey, paramSpace paramtypes.Subspace,
|
||||
cdc codec.Marshaler, key sdk.StoreKey, paramSpace paramtypes.Subspace,
|
||||
sk types.StakingKeeper, supplyKeeper types.SupplyKeeper, feeCollectorName string,
|
||||
) Keeper {
|
||||
|
||||
|
@ -64,7 +64,7 @@ func (k Keeper) GetMinter(ctx sdk.Context) (minter types.Minter) {
|
|||
// set the minter
|
||||
func (k Keeper) SetMinter(ctx sdk.Context, minter types.Minter) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
b := k.cdc.MustMarshalBinaryLengthPrefixed(minter)
|
||||
b := k.cdc.MustMarshalBinaryLengthPrefixed(&minter)
|
||||
store.Set(types.MinterKey, b)
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
// NewQuerier returns a minting Querier handler.
|
|
@ -6,8 +6,8 @@ import (
|
|||
"github.com/stretchr/testify/require"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
keep "github.com/cosmos/cosmos-sdk/x/mint/internal/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
keep "github.com/cosmos/cosmos-sdk/x/mint/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
)
|
|
@ -7,7 +7,7 @@ import (
|
|||
tmkv "github.com/tendermint/tendermint/libs/kv"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
// DecodeStore unmarshals the KVPair's Value to the corresponding mint type
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
func makeTestCodec() (cdc *codec.Codec) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
)
|
||||
|
||||
// Simulation parameter constants
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/internal/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
)
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
)
|
||||
|
||||
var (
|
||||
amino = codec.New()
|
||||
|
||||
// ModuleCdc references the global x/mint module codec. Note, the codec
|
||||
// should ONLY be used in certain instances of tests and for JSON encoding as
|
||||
// Amino is still used for that purpose.
|
||||
//
|
||||
// The actual codec used for serialization should be provided to x/mint and
|
||||
// defined at the application level.
|
||||
ModuleCdc = codec.NewHybridCodec(amino)
|
||||
)
|
||||
|
||||
func init() {
|
||||
codec.RegisterCrypto(amino)
|
||||
amino.Seal()
|
||||
}
|
|
@ -6,12 +6,6 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
// Minter represents the minting state.
|
||||
type Minter struct {
|
||||
Inflation sdk.Dec `json:"inflation" yaml:"inflation"` // current annual inflation rate
|
||||
AnnualProvisions sdk.Dec `json:"annual_provisions" yaml:"annual_provisions"` // current annual expected provisions
|
||||
}
|
||||
|
||||
// NewMinter returns a new Minter object with the given inflation and annual
|
||||
// provisions values.
|
||||
func NewMinter(inflation, annualProvisions sdk.Dec) Minter {
|
|
@ -5,6 +5,8 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
)
|
||||
|
@ -19,16 +21,6 @@ var (
|
|||
KeyBlocksPerYear = []byte("BlocksPerYear")
|
||||
)
|
||||
|
||||
// mint parameters
|
||||
type Params struct {
|
||||
MintDenom string `json:"mint_denom" yaml:"mint_denom"` // type of coin to mint
|
||||
InflationRateChange sdk.Dec `json:"inflation_rate_change" yaml:"inflation_rate_change"` // maximum annual change in inflation rate
|
||||
InflationMax sdk.Dec `json:"inflation_max" yaml:"inflation_max"` // maximum inflation rate
|
||||
InflationMin sdk.Dec `json:"inflation_min" yaml:"inflation_min"` // minimum inflation rate
|
||||
GoalBonded sdk.Dec `json:"goal_bonded" yaml:"goal_bonded"` // goal of percent bonded atoms
|
||||
BlocksPerYear uint64 `json:"blocks_per_year" yaml:"blocks_per_year"` // expected blocks per year
|
||||
}
|
||||
|
||||
// ParamTable for minting module.
|
||||
func ParamKeyTable() paramtypes.KeyTable {
|
||||
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
|
||||
|
@ -91,18 +83,10 @@ func (p Params) Validate() error {
|
|||
|
||||
}
|
||||
|
||||
// String implements the Stringer interface.
|
||||
func (p Params) String() string {
|
||||
return fmt.Sprintf(`Minting Params:
|
||||
Mint Denom: %s
|
||||
Inflation Rate Change: %s
|
||||
Inflation Max: %s
|
||||
Inflation Min: %s
|
||||
Goal Bonded: %s
|
||||
Blocks Per Year: %d
|
||||
`,
|
||||
p.MintDenom, p.InflationRateChange, p.InflationMax,
|
||||
p.InflationMin, p.GoalBonded, p.BlocksPerYear,
|
||||
)
|
||||
out, _ := yaml.Marshal(p)
|
||||
return string(out)
|
||||
}
|
||||
|
||||
// Implements params.ParamSet
|
|
@ -0,0 +1,785 @@
|
|||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: x/mint/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
|
||||
|
||||
// Minter represents the minting state.
|
||||
type Minter struct {
|
||||
// current annual inflation rate
|
||||
Inflation github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=inflation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation"`
|
||||
// current annual expected provisions
|
||||
AnnualProvisions github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=annual_provisions,json=annualProvisions,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"annual_provisions" yaml:"annual_provisions"`
|
||||
}
|
||||
|
||||
func (m *Minter) Reset() { *m = Minter{} }
|
||||
func (m *Minter) String() string { return proto.CompactTextString(m) }
|
||||
func (*Minter) ProtoMessage() {}
|
||||
func (*Minter) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_fcb8be2eaea25b48, []int{0}
|
||||
}
|
||||
func (m *Minter) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Minter) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Minter.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 *Minter) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Minter.Merge(m, src)
|
||||
}
|
||||
func (m *Minter) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Minter) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Minter.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Minter proto.InternalMessageInfo
|
||||
|
||||
// mint parameters
|
||||
type Params struct {
|
||||
// type of coin to mint
|
||||
MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"`
|
||||
// maximum annual change in inflation rate
|
||||
InflationRateChange github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=inflation_rate_change,json=inflationRateChange,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation_rate_change" yaml:"inflation_rate_change"`
|
||||
// maximum inflation rate
|
||||
InflationMax github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=inflation_max,json=inflationMax,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation_max" yaml:"inflation_max"`
|
||||
// minimum inflation rate
|
||||
InflationMin github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=inflation_min,json=inflationMin,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"inflation_min" yaml:"inflation_min"`
|
||||
// goal of percent bonded atoms
|
||||
GoalBonded github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=goal_bonded,json=goalBonded,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"goal_bonded" yaml:"goal_bonded"`
|
||||
// expected blocks per year
|
||||
BlocksPerYear uint64 `protobuf:"varint,6,opt,name=blocks_per_year,json=blocksPerYear,proto3" json:"blocks_per_year,omitempty" yaml:"blocks_per_year"`
|
||||
}
|
||||
|
||||
func (m *Params) Reset() { *m = Params{} }
|
||||
func (*Params) ProtoMessage() {}
|
||||
func (*Params) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_fcb8be2eaea25b48, []int{1}
|
||||
}
|
||||
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) GetMintDenom() string {
|
||||
if m != nil {
|
||||
return m.MintDenom
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *Params) GetBlocksPerYear() uint64 {
|
||||
if m != nil {
|
||||
return m.BlocksPerYear
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Minter)(nil), "cosmos_sdk.x.mint.v1.Minter")
|
||||
proto.RegisterType((*Params)(nil), "cosmos_sdk.x.mint.v1.Params")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("x/mint/types/types.proto", fileDescriptor_fcb8be2eaea25b48) }
|
||||
|
||||
var fileDescriptor_fcb8be2eaea25b48 = []byte{
|
||||
// 439 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0xb1, 0x6e, 0xd3, 0x40,
|
||||
0x1c, 0xc6, 0x6d, 0x48, 0x23, 0xe5, 0xa0, 0x02, 0x8e, 0x82, 0xac, 0x0a, 0xec, 0xca, 0x43, 0xd5,
|
||||
0x05, 0x5b, 0x88, 0xad, 0xa3, 0x89, 0x18, 0x10, 0x45, 0x91, 0x37, 0x58, 0x4e, 0xff, 0xd8, 0x87,
|
||||
0x73, 0x8a, 0xef, 0xce, 0xba, 0xbb, 0x16, 0x67, 0xe5, 0x09, 0x18, 0x19, 0x79, 0x0b, 0x5e, 0xa1,
|
||||
0x1b, 0x1d, 0x11, 0x43, 0x84, 0x92, 0x37, 0xe8, 0x13, 0x20, 0xdf, 0x45, 0x09, 0x04, 0x96, 0x48,
|
||||
0x5d, 0x6c, 0xff, 0x3f, 0x7d, 0xff, 0xef, 0xf7, 0xf9, 0xa4, 0x43, 0x41, 0x9b, 0x72, 0x26, 0x4c,
|
||||
0x6a, 0x66, 0x0d, 0xd5, 0xee, 0x99, 0x34, 0x4a, 0x1a, 0x89, 0x0f, 0x0a, 0xa9, 0xb9, 0xd4, 0x44,
|
||||
0x97, 0xd3, 0xa4, 0x4d, 0x3a, 0x53, 0x72, 0xf1, 0xfc, 0xf0, 0xd8, 0x4c, 0x98, 0x2a, 0x49, 0x03,
|
||||
0xca, 0xcc, 0x52, 0x6b, 0x4c, 0x2b, 0x59, 0xc9, 0xcd, 0x97, 0xdb, 0x8e, 0xbf, 0xfb, 0xa8, 0x7f,
|
||||
0xc6, 0x84, 0xa1, 0x0a, 0xbf, 0x41, 0x03, 0x26, 0x3e, 0xd4, 0x60, 0x98, 0x14, 0x81, 0x7f, 0xe4,
|
||||
0x9f, 0x0c, 0xb2, 0xe4, 0x72, 0x1e, 0x79, 0x3f, 0xe7, 0xd1, 0x71, 0xc5, 0xcc, 0xe4, 0x7c, 0x9c,
|
||||
0x14, 0x92, 0xa7, 0x0e, 0xb7, 0x7a, 0x3d, 0xd3, 0xe5, 0x74, 0xd5, 0x66, 0x48, 0x8b, 0x7c, 0x13,
|
||||
0x80, 0x3f, 0xa2, 0x07, 0x20, 0xc4, 0x39, 0xd4, 0xa4, 0x51, 0xf2, 0x82, 0x69, 0x26, 0x85, 0x0e,
|
||||
0x6e, 0xd9, 0xd4, 0xd7, 0xbb, 0xa5, 0x5e, 0xcf, 0xa3, 0x60, 0x06, 0xbc, 0x3e, 0x8d, 0xff, 0x09,
|
||||
0x8c, 0xf3, 0xfb, 0x4e, 0x1b, 0x6d, 0xa4, 0x6f, 0x3d, 0xd4, 0x1f, 0x81, 0x02, 0xae, 0xf1, 0x53,
|
||||
0x84, 0xba, 0xf3, 0x20, 0x25, 0x15, 0x92, 0xbb, 0x5f, 0xca, 0x07, 0x9d, 0x32, 0xec, 0x04, 0xfc,
|
||||
0xc9, 0x47, 0x8f, 0xd6, 0x85, 0x89, 0x02, 0x43, 0x49, 0x31, 0x01, 0x51, 0xd1, 0x55, 0xcf, 0xb7,
|
||||
0x3b, 0xf7, 0x7c, 0xe2, 0x7a, 0xfe, 0x37, 0x34, 0xce, 0x1f, 0xae, 0xf5, 0x1c, 0x0c, 0x7d, 0x69,
|
||||
0x55, 0x3c, 0x45, 0xfb, 0x1b, 0x3b, 0x87, 0x36, 0xb8, 0x6d, 0xd9, 0xaf, 0x76, 0x66, 0x1f, 0x6c,
|
||||
0xb3, 0x39, 0xb4, 0x71, 0x7e, 0x77, 0x3d, 0x9f, 0x41, 0xbb, 0x05, 0x63, 0x22, 0xe8, 0xdd, 0x18,
|
||||
0x8c, 0x89, 0xbf, 0x60, 0x4c, 0x60, 0x8a, 0xee, 0x54, 0x12, 0x6a, 0x32, 0x96, 0xa2, 0xa4, 0x65,
|
||||
0xb0, 0x67, 0x51, 0xc3, 0x9d, 0x51, 0xd8, 0xa1, 0xfe, 0x88, 0x8a, 0x73, 0xd4, 0x4d, 0x99, 0x1d,
|
||||
0x70, 0x86, 0xee, 0x8d, 0x6b, 0x59, 0x4c, 0x35, 0x69, 0xa8, 0x22, 0x33, 0x0a, 0x2a, 0xe8, 0x1f,
|
||||
0xf9, 0x27, 0xbd, 0xec, 0xf0, 0x7a, 0x1e, 0x3d, 0x76, 0xcb, 0x5b, 0x86, 0x38, 0xdf, 0x77, 0xca,
|
||||
0x88, 0xaa, 0x77, 0x14, 0xd4, 0x69, 0xef, 0xcb, 0xd7, 0xc8, 0xcb, 0xa2, 0xcb, 0x45, 0xe8, 0x5f,
|
||||
0x2d, 0x42, 0xff, 0xd7, 0x22, 0xf4, 0x3f, 0x2f, 0x43, 0xef, 0x6a, 0x19, 0x7a, 0x3f, 0x96, 0xa1,
|
||||
0xf7, 0x7e, 0xcf, 0x16, 0x1a, 0xf7, 0xed, 0x9d, 0x79, 0xf1, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x9e,
|
||||
0xe3, 0xbd, 0x88, 0x8d, 0x03, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Minter) 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 *Minter) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Minter) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
{
|
||||
size := m.AnnualProvisions.Size()
|
||||
i -= size
|
||||
if _, err := m.AnnualProvisions.MarshalTo(dAtA[i:]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i = encodeVarintTypes(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
{
|
||||
size := m.Inflation.Size()
|
||||
i -= size
|
||||
if _, err := m.Inflation.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 *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.BlocksPerYear != 0 {
|
||||
i = encodeVarintTypes(dAtA, i, uint64(m.BlocksPerYear))
|
||||
i--
|
||||
dAtA[i] = 0x30
|
||||
}
|
||||
{
|
||||
size := m.GoalBonded.Size()
|
||||
i -= size
|
||||
if _, err := m.GoalBonded.MarshalTo(dAtA[i:]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i = encodeVarintTypes(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
{
|
||||
size := m.InflationMin.Size()
|
||||
i -= size
|
||||
if _, err := m.InflationMin.MarshalTo(dAtA[i:]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i = encodeVarintTypes(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
{
|
||||
size := m.InflationMax.Size()
|
||||
i -= size
|
||||
if _, err := m.InflationMax.MarshalTo(dAtA[i:]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i = encodeVarintTypes(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
{
|
||||
size := m.InflationRateChange.Size()
|
||||
i -= size
|
||||
if _, err := m.InflationRateChange.MarshalTo(dAtA[i:]); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i = encodeVarintTypes(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
if len(m.MintDenom) > 0 {
|
||||
i -= len(m.MintDenom)
|
||||
copy(dAtA[i:], m.MintDenom)
|
||||
i = encodeVarintTypes(dAtA, i, uint64(len(m.MintDenom)))
|
||||
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 *Minter) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = m.Inflation.Size()
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
l = m.AnnualProvisions.Size()
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Params) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.MintDenom)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
}
|
||||
l = m.InflationRateChange.Size()
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
l = m.InflationMax.Size()
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
l = m.InflationMin.Size()
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
l = m.GoalBonded.Size()
|
||||
n += 1 + l + sovTypes(uint64(l))
|
||||
if m.BlocksPerYear != 0 {
|
||||
n += 1 + sovTypes(uint64(m.BlocksPerYear))
|
||||
}
|
||||
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 *Minter) 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: Minter: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Minter: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Inflation", 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.Inflation.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field AnnualProvisions", 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.AnnualProvisions.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipTypes(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthTypes
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Params) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Params: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field MintDenom", 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.MintDenom = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field InflationRateChange", 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.InflationRateChange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field InflationMax", 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.InflationMax.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field InflationMin", 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.InflationMin.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field GoalBonded", 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.GoalBonded.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 6:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerYear", wireType)
|
||||
}
|
||||
m.BlocksPerYear = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowTypes
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.BlocksPerYear |= 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")
|
||||
)
|
|
@ -0,0 +1,53 @@
|
|||
syntax = "proto3";
|
||||
package cosmos_sdk.x.mint.v1;
|
||||
|
||||
option go_package = "types";
|
||||
|
||||
import "third_party/proto/gogoproto/gogo.proto";
|
||||
|
||||
// Minter represents the minting state.
|
||||
message Minter {
|
||||
// current annual inflation rate
|
||||
string inflation = 1
|
||||
[(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false];
|
||||
// current annual expected provisions
|
||||
string annual_provisions = 2 [
|
||||
(gogoproto.moretags) = "yaml:\"annual_provisions\"",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
}
|
||||
|
||||
// mint parameters
|
||||
message Params {
|
||||
option (gogoproto.goproto_stringer) = false;
|
||||
|
||||
// type of coin to mint
|
||||
string mint_denom = 1;
|
||||
// maximum annual change in inflation rate
|
||||
string inflation_rate_change = 2 [
|
||||
(gogoproto.moretags) = "yaml:\"inflation_rate_change\"",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// maximum inflation rate
|
||||
string inflation_max = 3 [
|
||||
(gogoproto.moretags) = "yaml:\"inflation_max\"",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// minimum inflation rate
|
||||
string inflation_min = 4 [
|
||||
(gogoproto.moretags) = "yaml:\"inflation_min\"",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// goal of percent bonded atoms
|
||||
string goal_bonded = 5 [
|
||||
(gogoproto.moretags) = "yaml:\"goal_bonded\"",
|
||||
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
|
||||
(gogoproto.nullable) = false
|
||||
];
|
||||
// expected blocks per year
|
||||
uint64 blocks_per_year = 6 [(gogoproto.moretags) = "yaml:\"blocks_per_year\""];
|
||||
}
|
Loading…
Reference in New Issue