diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 96253e7c..488206e9 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -20,6 +20,7 @@ - [PoEContractType](#confio.poe.v1beta1.PoEContractType) - [confio/poe/v1beta1/genesis.proto](#confio/poe/v1beta1/genesis.proto) + - [EngagementContractConfig](#confio.poe.v1beta1.EngagementContractConfig) - [GenesisState](#confio.poe.v1beta1.GenesisState) - [PoEContract](#confio.poe.v1beta1.PoEContract) - [StakeContractConfig](#confio.poe.v1beta1.StakeContractConfig) @@ -230,6 +231,21 @@ PoEContractType type of PoE contract + + +### EngagementContractConfig +EngagementContractConfig initial setup config + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `halflife` | [google.protobuf.Duration](#google.protobuf.Duration) | | | + + + + + + ### GenesisState @@ -246,6 +262,7 @@ GenesisState - initial state of module | `engagement` | [TG4Member](#confio.poe.v1beta1.TG4Member) | repeated | Engagement weighted members of the engagement group. Validators should be in here. | | `stake_contract_config` | [StakeContractConfig](#confio.poe.v1beta1.StakeContractConfig) | | | | `valset_contract_config` | [ValsetContractConfig](#confio.poe.v1beta1.ValsetContractConfig) | | | +| `engagment_contract_config` | [EngagementContractConfig](#confio.poe.v1beta1.EngagementContractConfig) | | | | `bond_denom` | [string](#string) | | BondDenom defines the bondable coin denomination. | @@ -318,6 +335,8 @@ ValsetContractConfig initial setup config | `epoch_reward` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | | `scaling` | [uint32](#uint32) | | | | `fee_percentage` | [string](#string) | | | +| `ValidatorsRewardRatio` | [uint32](#uint32) | | ValidatorsRewardRatio in percentage | +| `AutoUnjail` | [bool](#bool) | | AutoUnjail if set to true, we will auto-unjail any validator after their jailtime is over. | diff --git a/proto/confio/poe/v1beta1/genesis.proto b/proto/confio/poe/v1beta1/genesis.proto index e26c4194..5a2d9cbd 100644 --- a/proto/confio/poe/v1beta1/genesis.proto +++ b/proto/confio/poe/v1beta1/genesis.proto @@ -49,8 +49,10 @@ message GenesisState { ValsetContractConfig valset_contract_config = 8 [ (gogoproto.jsontag) = "valset_contract_config,omitempty" ]; + EngagementContractConfig engagment_contract_config = 9 + [ (gogoproto.jsontag) = "engagment_contract_config,omitempty" ]; // BondDenom defines the bondable coin denomination. - string bond_denom = 9 [ (gogoproto.moretags) = "yaml:\"bond_denom\"" ]; + string bond_denom = 10 [ (gogoproto.moretags) = "yaml:\"bond_denom\"" ]; } // StakeContractConfig initial setup config @@ -75,6 +77,17 @@ message ValsetContractConfig { (gogoproto.nullable) = false, (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec" ]; + // ValidatorsRewardRatio in percentage + uint32 ValidatorsRewardRatio = 7; + // AutoUnjail if set to true, we will auto-unjail any validator after their + // jailtime is over. + bool AutoUnjail = 8; +} + +// EngagementContractConfig initial setup config +message EngagementContractConfig { + google.protobuf.Duration halflife = 1 + [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; } // PoEContract address and type information diff --git a/x/poe/bootstrap.go b/x/poe/bootstrap.go index 2e3f307d..c0f0e6f9 100644 --- a/x/poe/bootstrap.go +++ b/x/poe/bootstrap.go @@ -45,11 +45,11 @@ type poeKeeper interface { // // * [tg4-group](https://github.com/confio/tgrade-contracts/tree/main/contracts/tg4-group) - engagement group with weighted // members -//* [tg4-stake](https://github.com/confio/tgrade-contracts/tree/main/contracts/tg4-stake) - validator group weighted by +// * [tg4-stake](https://github.com/confio/tgrade-contracts/tree/main/contracts/tg4-stake) - validator group weighted by // staked amount -//* [valset](https://github.com/confio/tgrade-contracts/tree/main/contracts/tgrade-valset) - privileged contract to map a +// * [valset](https://github.com/confio/tgrade-contracts/tree/main/contracts/tgrade-valset) - privileged contract to map a // trusted cw4 contract to the Tendermint validator set running the chain -//* [mixer](https://github.com/confio/tgrade-contracts/tree/main/contracts/tg4-mixer) - calculates the combined value of +// * [mixer](https://github.com/confio/tgrade-contracts/tree/main/contracts/tg4-mixer) - calculates the combined value of // stake and engagement points. Source for the valset contract. func bootstrapPoEContracts(ctx sdk.Context, k wasmtypes.ContractOpsKeeper, tk twasmKeeper, poeKeeper poeKeeper, gs types.GenesisState) error { tg4EngagementInitMsg := contract.TG4EngagementInitMsg{ @@ -57,9 +57,7 @@ func bootstrapPoEContracts(ctx sdk.Context, k wasmtypes.ContractOpsKeeper, tk tw Members: make([]contract.TG4Member, len(gs.Engagement)), Preauths: 1, Token: gs.BondDenom, - // TODO: allow us to configure halflife in Genesis - // now hardcoded as 180 days = 180 * 86400s - Halflife: 15552000, + Halflife: uint64(gs.EngagmentContractConfig.Halflife.Seconds()), } for i, v := range gs.Engagement { tg4EngagementInitMsg.Members[i] = contract.TG4Member{ @@ -174,17 +172,16 @@ func newValsetInitMsg( engagementID uint64, ) contract.ValsetInitMsg { return contract.ValsetInitMsg{ - Membership: mixerContractAddr.String(), - MinWeight: gs.ValsetContractConfig.MinWeight, - MaxValidators: gs.ValsetContractConfig.MaxValidators, - EpochLength: uint64(gs.ValsetContractConfig.EpochLength.Seconds()), - EpochReward: gs.ValsetContractConfig.EpochReward, - InitialKeys: []contract.Validator{}, - Scaling: gs.ValsetContractConfig.Scaling, - FeePercentage: contract.DecimalFromPercentage(gs.ValsetContractConfig.FeePercentage), - // TODO: set AutoJail from genesis - // TODO: set ValidatorsRewardRatio from genesis (hardcode to 50% here) - ValidatorsRewardRatio: contract.DecimalFromPercentage(sdk.NewDec(50)), + Membership: mixerContractAddr.String(), + MinWeight: gs.ValsetContractConfig.MinWeight, + MaxValidators: gs.ValsetContractConfig.MaxValidators, + EpochLength: uint64(gs.ValsetContractConfig.EpochLength.Seconds()), + EpochReward: gs.ValsetContractConfig.EpochReward, + InitialKeys: []contract.Validator{}, + Scaling: gs.ValsetContractConfig.Scaling, + FeePercentage: contract.DecimalFromPercentage(gs.ValsetContractConfig.FeePercentage), + AutoUnjail: gs.ValsetContractConfig.AutoUnjail, + ValidatorsRewardRatio: contract.DecimalFromPercentage(sdk.NewDec(int64(gs.ValsetContractConfig.ValidatorsRewardRatio))), DistributionContract: engagementAddr.String(), RewardsCodeId: engagementID, } diff --git a/x/poe/types/genesis.go b/x/poe/types/genesis.go index 6bb4deca..a4bcab2d 100644 --- a/x/poe/types/genesis.go +++ b/x/poe/types/genesis.go @@ -25,12 +25,17 @@ func DefaultGenesisState() GenesisState { PreAuths: 1, }, ValsetContractConfig: &ValsetContractConfig{ - MinWeight: 1, - MaxValidators: 100, - EpochLength: 60 * time.Second, - EpochReward: sdk.NewCoin(DefaultBondDenom, sdk.NewInt(100_000)), - Scaling: 1, - FeePercentage: sdk.NewDec(50), + MinWeight: 1, + MaxValidators: 100, + EpochLength: 60 * time.Second, + EpochReward: sdk.NewCoin(DefaultBondDenom, sdk.NewInt(100_000)), + Scaling: 1, + FeePercentage: sdk.NewDec(50), + AutoUnjail: false, + ValidatorsRewardRatio: 50, + }, + EngagmentContractConfig: &EngagementContractConfig{ + Halflife: 180 * 24 * time.Hour, }, SystemAdminAddress: sdk.AccAddress(rand.Bytes(sdk.AddrLen)).String(), Params: DefaultParams(), @@ -38,9 +43,6 @@ func DefaultGenesisState() GenesisState { } func ValidateGenesis(g GenesisState, txJSONDecoder sdk.TxDecoder) error { - if err := sdk.ValidateDenom(g.BondDenom); err != nil { - return sdkerrors.Wrap(err, "bond denom") - } if g.SeedContracts { if len(g.Contracts) != 0 { return sdkerrors.Wrap(wasmtypes.ErrInvalidGenesis, "seed enabled but PoE contracts addresses provided") @@ -48,6 +50,16 @@ func ValidateGenesis(g GenesisState, txJSONDecoder sdk.TxDecoder) error { if len(g.Engagement) == 0 { return sdkerrors.Wrap(wasmtypes.ErrInvalidGenesis, "empty engagement group") } + if g.EngagmentContractConfig == nil { + return sdkerrors.Wrap(wasmtypes.ErrInvalidGenesis, "empty engagement contract config") + } + if err := g.EngagmentContractConfig.ValidateBasic(); err != nil { + return sdkerrors.Wrap(err, "engagement contract config") + } + if err := sdk.ValidateDenom(g.BondDenom); err != nil { + return sdkerrors.Wrap(err, "bond denom") + } + if g.ValsetContractConfig == nil { return sdkerrors.Wrap(wasmtypes.ErrInvalidGenesis, "empty valset contract config") } @@ -128,6 +140,14 @@ func ValidateGenesis(g GenesisState, txJSONDecoder sdk.TxDecoder) error { return nil } +// ValidateBasic ensure basic constraints +func (c *EngagementContractConfig) ValidateBasic() error { + if c.Halflife.Truncate(time.Second) != c.Halflife { + return sdkerrors.Wrap(ErrInvalid, "halflife must not contain anything less than seconds") + } + return nil +} + // ValidateBasic ensure basic constraints func (c ValsetContractConfig) ValidateBasic() error { if c.MaxValidators == 0 { @@ -139,6 +159,9 @@ func (c ValsetContractConfig) ValidateBasic() error { if c.Scaling == 0 { return sdkerrors.Wrap(ErrEmpty, "scaling") } + if c.ValidatorsRewardRatio > 100 { + return sdkerrors.Wrap(ErrInvalid, "validator reward ratio must not be greater 100") + } minFeePercentage := sdk.NewDecFromIntWithPrec(sdk.OneInt(), 16) if c.FeePercentage.LT(minFeePercentage) { diff --git a/x/poe/types/genesis.pb.go b/x/poe/types/genesis.pb.go index 15154681..a9debf0f 100644 --- a/x/poe/types/genesis.pb.go +++ b/x/poe/types/genesis.pb.go @@ -49,11 +49,12 @@ type GenesisState struct { Contracts []PoEContract `protobuf:"bytes,5,rep,name=contracts,proto3" json:"contracts,omitempty"` // Engagement weighted members of the engagement group. Validators should be // in here. - Engagement []TG4Member `protobuf:"bytes,6,rep,name=engagement,proto3" json:"engagement,omitempty"` - StakeContractConfig *StakeContractConfig `protobuf:"bytes,7,opt,name=stake_contract_config,json=stakeContractConfig,proto3" json:"stake_contract_config,omitempty"` - ValsetContractConfig *ValsetContractConfig `protobuf:"bytes,8,opt,name=valset_contract_config,json=valsetContractConfig,proto3" json:"valset_contract_config,omitempty"` + Engagement []TG4Member `protobuf:"bytes,6,rep,name=engagement,proto3" json:"engagement,omitempty"` + StakeContractConfig *StakeContractConfig `protobuf:"bytes,7,opt,name=stake_contract_config,json=stakeContractConfig,proto3" json:"stake_contract_config,omitempty"` + ValsetContractConfig *ValsetContractConfig `protobuf:"bytes,8,opt,name=valset_contract_config,json=valsetContractConfig,proto3" json:"valset_contract_config,omitempty"` + EngagmentContractConfig *EngagementContractConfig `protobuf:"bytes,9,opt,name=engagement_contract_config,json=engagmentContractConfig,proto3" json:"engagement_contract_config,omitempty"` // BondDenom defines the bondable coin denomination. - BondDenom string `protobuf:"bytes,9,opt,name=bond_denom,json=bondDenom,proto3" json:"bond_denom,omitempty" yaml:"bond_denom"` + BondDenom string `protobuf:"bytes,10,opt,name=bond_denom,json=bondDenom,proto3" json:"bond_denom,omitempty" yaml:"bond_denom"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -145,6 +146,13 @@ func (m *GenesisState) GetValsetContractConfig() *ValsetContractConfig { return nil } +func (m *GenesisState) GetEngagmentContractConfig() *EngagementContractConfig { + if m != nil { + return m.EngagmentContractConfig + } + return nil +} + func (m *GenesisState) GetBondDenom() string { if m != nil { return m.BondDenom @@ -237,6 +245,11 @@ type ValsetContractConfig struct { EpochReward types.Coin `protobuf:"bytes,4,opt,name=epoch_reward,json=epochReward,proto3" json:"epoch_reward"` Scaling uint32 `protobuf:"varint,5,opt,name=scaling,proto3" json:"scaling,omitempty"` FeePercentage github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=fee_percentage,json=feePercentage,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fee_percentage"` + // ValidatorsRewardRatio in percentage + ValidatorsRewardRatio uint32 `protobuf:"varint,7,opt,name=ValidatorsRewardRatio,proto3" json:"ValidatorsRewardRatio,omitempty"` + // AutoUnjail if set to true, we will auto-unjail any validator after their + // jailtime is over. + AutoUnjail bool `protobuf:"varint,8,opt,name=AutoUnjail,proto3" json:"AutoUnjail,omitempty"` } func (m *ValsetContractConfig) Reset() { *m = ValsetContractConfig{} } @@ -307,6 +320,65 @@ func (m *ValsetContractConfig) GetScaling() uint32 { return 0 } +func (m *ValsetContractConfig) GetValidatorsRewardRatio() uint32 { + if m != nil { + return m.ValidatorsRewardRatio + } + return 0 +} + +func (m *ValsetContractConfig) GetAutoUnjail() bool { + if m != nil { + return m.AutoUnjail + } + return false +} + +// EngagementContractConfig initial setup config +type EngagementContractConfig struct { + Halflife time.Duration `protobuf:"bytes,1,opt,name=halflife,proto3,stdduration" json:"halflife"` +} + +func (m *EngagementContractConfig) Reset() { *m = EngagementContractConfig{} } +func (m *EngagementContractConfig) String() string { return proto.CompactTextString(m) } +func (*EngagementContractConfig) ProtoMessage() {} +func (*EngagementContractConfig) Descriptor() ([]byte, []int) { + return fileDescriptor_a165193bab811d9d, []int{3} +} +func (m *EngagementContractConfig) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *EngagementContractConfig) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_EngagementContractConfig.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 *EngagementContractConfig) XXX_Merge(src proto.Message) { + xxx_messageInfo_EngagementContractConfig.Merge(m, src) +} +func (m *EngagementContractConfig) XXX_Size() int { + return m.Size() +} +func (m *EngagementContractConfig) XXX_DiscardUnknown() { + xxx_messageInfo_EngagementContractConfig.DiscardUnknown(m) +} + +var xxx_messageInfo_EngagementContractConfig proto.InternalMessageInfo + +func (m *EngagementContractConfig) GetHalflife() time.Duration { + if m != nil { + return m.Halflife + } + return 0 +} + // PoEContract address and type information type PoEContract struct { // ContractType type. @@ -319,7 +391,7 @@ func (m *PoEContract) Reset() { *m = PoEContract{} } func (m *PoEContract) String() string { return proto.CompactTextString(m) } func (*PoEContract) ProtoMessage() {} func (*PoEContract) Descriptor() ([]byte, []int) { - return fileDescriptor_a165193bab811d9d, []int{3} + return fileDescriptor_a165193bab811d9d, []int{4} } func (m *PoEContract) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -373,7 +445,7 @@ func (m *TG4Member) Reset() { *m = TG4Member{} } func (m *TG4Member) String() string { return proto.CompactTextString(m) } func (*TG4Member) ProtoMessage() {} func (*TG4Member) Descriptor() ([]byte, []int) { - return fileDescriptor_a165193bab811d9d, []int{4} + return fileDescriptor_a165193bab811d9d, []int{5} } func (m *TG4Member) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -420,6 +492,7 @@ func init() { proto.RegisterType((*GenesisState)(nil), "confio.poe.v1beta1.GenesisState") proto.RegisterType((*StakeContractConfig)(nil), "confio.poe.v1beta1.StakeContractConfig") proto.RegisterType((*ValsetContractConfig)(nil), "confio.poe.v1beta1.ValsetContractConfig") + proto.RegisterType((*EngagementContractConfig)(nil), "confio.poe.v1beta1.EngagementContractConfig") proto.RegisterType((*PoEContract)(nil), "confio.poe.v1beta1.PoEContract") proto.RegisterType((*TG4Member)(nil), "confio.poe.v1beta1.TG4Member") } @@ -427,67 +500,72 @@ func init() { func init() { proto.RegisterFile("confio/poe/v1beta1/genesis.proto", fileDescriptor_a165193bab811d9d) } var fileDescriptor_a165193bab811d9d = []byte{ - // 945 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xc1, 0x73, 0xdb, 0xc4, - 0x17, 0x8e, 0x92, 0xd4, 0xb1, 0x37, 0x71, 0xfa, 0xeb, 0xc6, 0xed, 0xa8, 0x69, 0x6b, 0x79, 0xdc, - 0xf6, 0x87, 0x87, 0x01, 0x89, 0x86, 0xcc, 0xc0, 0x70, 0x60, 0x26, 0x4a, 0xa0, 0x1c, 0x5a, 0x26, - 0xa3, 0x84, 0x32, 0x53, 0x0e, 0x9a, 0xb5, 0xf4, 0x22, 0x2f, 0xb1, 0x76, 0x85, 0x76, 0xed, 0xd8, - 0x37, 0x0e, 0xfc, 0x01, 0x1c, 0xf9, 0x93, 0x7a, 0xec, 0x11, 0x38, 0x08, 0x26, 0xb9, 0x79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0xcb, 0x89, 0x30, 0xd7, 0x3a, 0x6b, 0xbd, 0x2d, 0xf7, 0xa3, 0x59, - 0x66, 0xd5, 0x22, 0x60, 0x72, 0x22, 0xde, 0x64, 0x56, 0x73, 0x4a, 0xe2, 0xe1, 0x27, 0xdd, 0xdc, - 0xee, 0xfe, 0x99, 0x59, 0x26, 0xb0, 0x80, 0x87, 0x94, 0x45, 0xce, 0xb7, 0x82, 0x33, 0xdb, 0x23, - 0x17, 0xcf, 0x41, 0x08, 0x12, 0x81, 0xa7, 0x40, 0xa7, 0x13, 0x81, 0x3f, 0x40, 0x2d, 0x31, 0x15, - 0x12, 0x62, 0x9f, 0x84, 0x31, 0x65, 0x3e, 0x09, 0xc3, 0x14, 0x84, 0x30, 0xd7, 0x3b, 0x46, 0xaf, - 0xe1, 0xe1, 0xdc, 0x77, 0xa0, 0x5c, 0x07, 0xb9, 0x07, 0xbf, 0x44, 0x8d, 0x45, 0x96, 0x37, 0x3a, - 0x6b, 0xbd, 0xcd, 0x3d, 0xab, 0xb2, 0x4e, 0xfe, 0xd9, 0x3c, 0x71, 0xf7, 0x9e, 0x2a, 0x76, 0x96, - 0x59, 0x3b, 0x25, 0xf2, 0x3d, 0x1e, 0x53, 0x09, 0x71, 0x22, 0xa7, 0xde, 0x82, 0x0e, 0x7f, 0x83, - 0x10, 0xb0, 0x88, 0x44, 0x10, 0x03, 0x93, 0x66, 0x4d, 0x93, 0x3f, 0xa8, 0x22, 0x3f, 0x7d, 0xba, - 0xff, 0x1c, 0xe2, 0x3e, 0xa4, 0xee, 0xfd, 0x82, 0xba, 0xb5, 0x00, 0x2e, 0x71, 0x2f, 0xd1, 0xe1, - 0xef, 0x0d, 0x74, 0x5b, 0x48, 0x72, 0x0e, 0x65, 0x97, 0x7d, 0xcd, 0x1c, 0x99, 0x1b, 0xfa, 0xb4, - 0xde, 0xa9, 0xda, 0xe8, 0x44, 0x01, 0xe6, 0x75, 0x1c, 0xea, 0x70, 0xf7, 0xe1, 0x2c,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, 0xa4, 0x31, 0x95, 0x7a, 0xb6, 0x9b, 0x5e, 0x4b, 0x7b, 0x0f, 0x4a, 0xe7, 0x33, - 0xe5, 0xc3, 0xf7, 0x50, 0x23, 0x49, 0x41, 0x61, 0x06, 0x6a, 0xba, 0x55, 0x60, 0x3d, 0x49, 0xe1, - 0x40, 0xd9, 0xdd, 0x5f, 0x56, 0x51, 0xab, 0xea, 0x30, 0xf0, 0x03, 0x84, 0x54, 0x0b, 0x8a, 0x02, - 0xf3, 0x26, 0x34, 0x62, 0xca, 0x8a, 0xd2, 0x1e, 0xa3, 0xed, 0x98, 0x4c, 0xfc, 0x31, 0x19, 0xd2, - 0x90, 0x48, 0x9e, 0xe6, 0xb7, 0xbb, 0xe9, 0x35, 0x63, 0x32, 0x79, 0x51, 0x2e, 0xe2, 0xcf, 0xd1, - 0x16, 0x24, 0x3c, 0x18, 0xf8, 0x43, 0x60, 0x91, 0x1c, 0xfc, 0x97, 0xea, 0x37, 0x35, 0xf0, 0x99, - 0xc6, 0x61, 0x77, 0xce, 0x93, 0xc2, 0x05, 0x49, 0x43, 0x5d, 0xaf, 0xe2, 0xc9, 0xc5, 0xd2, 0x56, - 0x62, 0x59, 0xce, 0xd6, 0x21, 0xa7, 0xac, 0xd0, 0xa2, 0x9c, 0xc3, 0xd3, 0x18, 0x6c, 0xa2, 0x0d, - 0x11, 0x90, 0x21, 0x65, 0x51, 0xd1, 0x85, 0xb9, 0x89, 0xbf, 0x42, 0xdb, 0x67, 0x00, 0xea, 0x84, - 0x02, 0x60, 0x92, 0x44, 0x60, 0xd6, 0xf4, 0x00, 0xd9, 0x8a, 0xe4, 0xd7, 0xcc, 0xfa, 0x7f, 0x44, - 0xe5, 0x60, 0xd4, 0xb7, 0x03, 0x1e, 0x3b, 0x85, 0x3c, 0xe7, 0xaf, 0xf7, 0x45, 0x78, 0xee, 0xc8, - 0x69, 0x02, 0xc2, 0x3e, 0x82, 0xc0, 0x6b, 0x9e, 0x01, 0x1c, 0x97, 0x24, 0xdd, 0xef, 0xd0, 0xe6, - 0x92, 0x62, 0xe0, 0x2f, 0x50, 0xb3, 0x9c, 0x6a, 0x85, 0xd1, 0x4d, 0xdd, 0xde, 0x7b, 0xf8, 0x2f, - 0x4a, 0x73, 0x3a, 0x4d, 0xc0, 0xdb, 0x0a, 0x96, 0x2c, 0x55, 0xc9, 0x5c, 0xd4, 0x56, 0xb5, 0xa8, - 0xcd, 0xcd, 0xee, 0x09, 0x6a, 0x94, 0x3a, 0x82, 0xbb, 0x8b, 0x30, 0x43, 0xd7, 0x53, 0x9f, 0x65, - 0xd6, 0xba, 0x92, 0xcd, 0x12, 0x80, 0xbb, 0xa8, 0xb6, 0x3c, 0xc3, 0x2e, 0x52, 0xea, 0x9b, 0xaf, - 0x78, 0xc5, 0xdb, 0xfd, 0xf4, 0xd5, 0x65, 0xdb, 0x78, 0x7d, 0xd9, 0x36, 0x7e, 0xbf, 0x6c, 0x1b, - 0x3f, 0x5e, 0xb5, 0x57, 0x5e, 0x5f, 0xb5, 0x57, 0x7e, 0xbe, 0x6a, 0xaf, 0xbc, 0x7c, 0xf4, 0x8f, - 0xc6, 0xe8, 0xff, 0x8e, 0x8c, 0x52, 0x12, 0x82, 0x33, 0xd1, 0x3f, 0x20, 0xdd, 0x9a, 0x7e, 0x4d, - 0x1f, 0xf3, 0x87, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xab, 0xec, 0x0d, 0xa6, 0x27, 0x07, 0x00, - 0x00, + // 1038 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x41, 0x73, 0xdb, 0x44, + 0x14, 0x8e, 0x9a, 0xe0, 0xd8, 0x9b, 0x38, 0xa5, 0x5b, 0xb7, 0xa8, 0x69, 0x6b, 0x79, 0x9c, 0x96, + 0x7a, 0x98, 0x22, 0xd1, 0x90, 0x19, 0x18, 0x0e, 0x30, 0x51, 0x52, 0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, + 0x86, 0x42, 0x55, 0xdb, 0x92, 0x73, 0x39, 0x37, 0xec, 0x41, 0xfa, 0x9d, 0xda, 0xc6, 0xdf, 0xa2, + 0xf7, 0x47, 0x54, 0x92, 0x84, 0x34, 0x90, 0xee, 0x21, 0xf3, 0xf5, 0x45, 0x95, 0x9e, 0x1b, 0x66, + 0xde, 0x1c, 0xcc, 0x69, 0x73, 0x30, 0x77, 0x8b, 0xe6, 0x60, 0xd7, 0xe5, 0x8b, 0xfc, 0xf9, 0x77, + 0x43, 0x73, 0x2e, 0x97, 0xe0, 0x3d, 0x85, 0xc5, 0x5b, 0xe8, 0xba, 0x17, 0x91, 0x30, 0x76, 0xc9, + 0x48, 0xb0, 0x14, 0xc4, 0x28, 0xa5, 0x6e, 0x14, 0xc6, 0xa1, 0x50, 0xf5, 0xd6, 0x74, 0x5a, 0xca, + 0xba, 0x5d, 0x1a, 0x1f, 0x4b, 0x1b, 0xbe, 0x89, 0x1a, 0x49, 0x0a, 0x12, 0x33, 0x94, 0x15, 0x27, + 0x1d, 0xeb, 0x49, 0x0a, 0xdb, 0x72, 0xdd, 0xfd, 0x65, 0x11, 0xb5, 0xaa, 0x1e, 0x08, 0xbe, 0x8d, + 0x90, 0x4c, 0x41, 0x11, 0x60, 0x9e, 0x84, 0x46, 0x1c, 0xd2, 0x22, 0xb4, 0xbb, 0x68, 0x2d, 0x26, + 0x63, 0xf7, 0x88, 0x44, 0xa1, 0x4f, 0x04, 0x4b, 0xf3, 0x8e, 0xd3, 0x74, 0x9a, 0x31, 0x19, 0x3f, + 0x2b, 0x37, 0xf1, 0xd7, 0x68, 0x15, 0x12, 0xe6, 0x0d, 0xdd, 0x08, 0x68, 0x20, 0x86, 0xff, 0x27, + 0xfa, 0x15, 0x05, 0x7c, 0xac, 0x70, 0xd8, 0x9e, 0xf2, 0xa4, 0x70, 0x4c, 0x52, 0x5f, 0xc5, 0x2b, + 0x79, 0xf2, 0x06, 0x6e, 0xca, 0x06, 0x5e, 0xbe,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x8c, 0x25, 0x39, + 0x7d, 0x4a, 0x00, 0xee, 0xa2, 0xda, 0x7c, 0xd9, 0xd9, 0x48, 0x0e, 0xb1, 0x7c, 0xc7, 0x29, 0xfe, + 0xed, 0x2f, 0x5f, 0x9f, 0xb6, 0xb5, 0x37, 0xa7, 0x6d, 0xed, 0x8f, 0xd3, 0xb6, 0xf6, 0xe3, 0x59, + 0x7b, 0xe1, 0xcd, 0x59, 0x7b, 0xe1, 0xd7, 0xb3, 0xf6, 0xc2, 0xf3, 0x3b, 0xff, 0xb8, 0x4b, 0x35, + 0xbe, 0x45, 0x90, 0x12, 0x1f, 0xac, 0xb1, 0x9a, 0xe3, 0xea, 0x36, 0xfb, 0x35, 0x95, 0xae, 0x4f, + 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x7e, 0xd8, 0x99, 0x6e, 0x08, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -515,6 +593,18 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.BondDenom) i = encodeVarintGenesis(dAtA, i, uint64(len(m.BondDenom))) i-- + dAtA[i] = 0x52 + } + if m.EngagmentContractConfig != nil { + { + size, err := m.EngagmentContractConfig.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- dAtA[i] = 0x4a } if m.ValsetContractConfig != nil { @@ -638,12 +728,12 @@ func (m *StakeContractConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - n4, err4 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) - if err4 != nil { - return 0, err4 + n5, err5 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.UnbondingPeriod, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.UnbondingPeriod):]) + if err5 != nil { + return 0, err5 } - i -= n4 - i = encodeVarintGenesis(dAtA, i, uint64(n4)) + i -= n5 + i = encodeVarintGenesis(dAtA, i, uint64(n5)) i-- dAtA[i] = 0x1a if m.TokensPerWeight != 0 { @@ -679,6 +769,21 @@ func (m *ValsetContractConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.AutoUnjail { + i-- + if m.AutoUnjail { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } + if m.ValidatorsRewardRatio != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.ValidatorsRewardRatio)) + i-- + dAtA[i] = 0x38 + } { size := m.FeePercentage.Size() i -= size @@ -704,12 +809,12 @@ func (m *ValsetContractConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x22 - n6, err6 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.EpochLength, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.EpochLength):]) - if err6 != nil { - return 0, err6 + n7, err7 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.EpochLength, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.EpochLength):]) + if err7 != nil { + return 0, err7 } - i -= n6 - i = encodeVarintGenesis(dAtA, i, uint64(n6)) + i -= n7 + i = encodeVarintGenesis(dAtA, i, uint64(n7)) i-- dAtA[i] = 0x1a if m.MaxValidators != 0 { @@ -725,6 +830,37 @@ func (m *ValsetContractConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *EngagementContractConfig) 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 *EngagementContractConfig) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *EngagementContractConfig) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n8, err8 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Halflife, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Halflife):]) + if err8 != nil { + return 0, err8 + } + i -= n8 + i = encodeVarintGenesis(dAtA, i, uint64(n8)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *PoEContract) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -847,6 +983,10 @@ func (m *GenesisState) Size() (n int) { l = m.ValsetContractConfig.Size() n += 1 + l + sovGenesis(uint64(l)) } + if m.EngagmentContractConfig != nil { + l = m.EngagmentContractConfig.Size() + n += 1 + l + sovGenesis(uint64(l)) + } l = len(m.BondDenom) if l > 0 { n += 1 + l + sovGenesis(uint64(l)) @@ -898,6 +1038,23 @@ func (m *ValsetContractConfig) Size() (n int) { } l = m.FeePercentage.Size() n += 1 + l + sovGenesis(uint64(l)) + if m.ValidatorsRewardRatio != 0 { + n += 1 + sovGenesis(uint64(m.ValidatorsRewardRatio)) + } + if m.AutoUnjail { + n += 2 + } + return n +} + +func (m *EngagementContractConfig) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Halflife) + n += 1 + l + sovGenesis(uint64(l)) return n } @@ -1226,6 +1383,42 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EngagmentContractConfig", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.EngagmentContractConfig == nil { + m.EngagmentContractConfig = &EngagementContractConfig{} + } + if err := m.EngagmentContractConfig.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BondDenom", wireType) } @@ -1623,6 +1816,128 @@ func (m *ValsetContractConfig) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorsRewardRatio", wireType) + } + m.ValidatorsRewardRatio = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ValidatorsRewardRatio |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AutoUnjail", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.AutoUnjail = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *EngagementContractConfig) 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 ErrIntOverflowGenesis + } + 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: EngagementContractConfig: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: EngagementContractConfig: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Halflife", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.Halflife, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/poe/types/genesis_test.go b/x/poe/types/genesis_test.go index 3d37abe2..9dabf24b 100644 --- a/x/poe/types/genesis_test.go +++ b/x/poe/types/genesis_test.go @@ -104,6 +104,12 @@ func TestValidateGenesis(t *testing.T) { }), expErr: true, }, + "invalid engagement contract config": { + source: GenesisStateFixture(func(m *GenesisState) { + m.EngagmentContractConfig.Halflife = time.Nanosecond + }), + expErr: true, + }, "invalid valset contract config": { source: GenesisStateFixture(func(m *GenesisState) { m.ValsetContractConfig.MaxValidators = 0 @@ -129,6 +135,38 @@ func TestValidateGenesis(t *testing.T) { } } +func TestValidateEngagementContractConfig(t *testing.T) { + specs := map[string]struct { + src *EngagementContractConfig + expErr bool + }{ + "default": { + src: DefaultGenesisState().EngagmentContractConfig, + }, + "halflife empty": { + src: GenesisStateFixture(func(m *GenesisState) { + m.EngagmentContractConfig.Halflife = 0 + }).EngagmentContractConfig, + }, + "halflife contains elements < second": { + src: GenesisStateFixture(func(m *GenesisState) { + m.EngagmentContractConfig.Halflife = time.Minute + time.Millisecond + }).EngagmentContractConfig, + expErr: true, + }, + } + for name, spec := range specs { + t.Run(name, func(t *testing.T) { + gotErr := spec.src.ValidateBasic() + if spec.expErr { + require.Error(t, gotErr) + return + } + require.NoError(t, gotErr) + }) + } +} + func TestValidateValsetContractConfig(t *testing.T) { specs := map[string]struct { src ValsetContractConfig @@ -176,6 +214,28 @@ func TestValidateValsetContractConfig(t *testing.T) { ).ValsetContractConfig, expErr: true, }, + "rewards ratio zero": { + src: *GenesisStateFixture( + func(m *GenesisState) { + m.ValsetContractConfig.ValidatorsRewardRatio = 0 + }, + ).ValsetContractConfig, + }, + "rewards ratio 100": { + src: *GenesisStateFixture( + func(m *GenesisState) { + m.ValsetContractConfig.ValidatorsRewardRatio = 100 + }, + ).ValsetContractConfig, + }, + "rewards ratio > 100": { + src: *GenesisStateFixture( + func(m *GenesisState) { + m.ValsetContractConfig.ValidatorsRewardRatio = 101 + }, + ).ValsetContractConfig, + expErr: true, + }, } for name, spec := range specs { t.Run(name, func(t *testing.T) { @@ -238,5 +298,4 @@ func TestValidateStakeContractConfig(t *testing.T) { require.NoError(t, gotErr) }) } - }