From 75c4d2d31300e5d4112bbf4b24d10369923cfd5f Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Sun, 14 Jul 2024 22:14:59 +0700 Subject: [PATCH 01/14] new module provider and send packet from consumer --- docs/proto/proto-docs.md | 203 +---- proto/osmosis/provider/v1beta1/genesis.proto | 18 + proto/osmosis/provider/v1beta1/params.proto | 22 + proto/osmosis/provider/v1beta1/query.proto | 30 + proto/osmosis/provider/v1beta1/tx.proto | 32 + proto/osmosis/types/v1beta1/wire.proto | 57 ++ x/meshsecurity/ibc_module.go | 172 ++++ x/meshsecurity/keeper/adapter_test.go | 12 +- x/meshsecurity/keeper/keeper.go | 53 +- x/meshsecurity/keeper/relay.go | 100 +++ x/meshsecurity/keeper/relay_test.go | 32 + x/meshsecurity/keeper/test_common.go | 11 +- x/meshsecurity/keeper/valset_updates.go | 46 +- x/meshsecurity/keeper/valset_updates_test.go | 53 +- x/meshsecurity/types/errors.go | 10 +- x/meshsecurity/types/expected_keepers.go | 30 + x/meshsecurity/types/genesis.pb.go | 25 +- x/meshsecurity/types/keys.go | 40 +- x/meshsecurity/types/meshsecurity.pb.go | 32 +- x/meshsecurity/types/params.go | 7 + x/meshsecurity/types/query.pb.go | 71 +- x/meshsecurity/types/query.pb.gw.go | 30 +- x/meshsecurity/types/relay.go | 43 + x/meshsecurity/types/scheduler.pb.go | 199 ++++- x/meshsecurity/types/tx.pb.go | 42 +- x/provider/client/cli/gov_tx.go | 144 ++++ x/provider/client/cli/query.go | 65 ++ x/provider/client/cli/tx.go | 27 + x/provider/ibc_module.go | 230 ++++++ x/provider/keeper/genesis.go | 18 + x/provider/keeper/keeper.go | 251 ++++++ x/provider/keeper/msg_server.go | 34 + x/provider/keeper/params.go | 30 + x/provider/keeper/querier.go | 28 + x/provider/keeper/relay.go | 60 ++ x/provider/module.go | 145 ++++ x/provider/types/codec.go | 32 + x/provider/types/errors.go | 13 + x/provider/types/events.go | 23 + x/provider/types/expected_keepers.go | 104 +++ x/provider/types/genesis.go | 18 + x/provider/types/genesis.pb.go | 344 ++++++++ x/provider/types/keys.go | 54 ++ x/provider/types/params.go | 20 + x/provider/types/params.pb.go | 361 ++++++++ x/provider/types/provider.go | 28 + x/provider/types/query.pb.go | 537 ++++++++++++ x/provider/types/query.pb.gw.go | 153 ++++ x/provider/types/tx.pb.go | 623 ++++++++++++++ x/types/codec.go | 11 + x/types/error.go | 13 + x/types/event.go | 12 + x/types/key.go | 8 + x/types/wire.go | 54 ++ x/types/wire.pb.go | 817 +++++++++++++++++++ x/types/wire_test.go | 27 + 56 files changed, 5228 insertions(+), 426 deletions(-) create mode 100644 proto/osmosis/provider/v1beta1/genesis.proto create mode 100644 proto/osmosis/provider/v1beta1/params.proto create mode 100644 proto/osmosis/provider/v1beta1/query.proto create mode 100644 proto/osmosis/provider/v1beta1/tx.proto create mode 100644 proto/osmosis/types/v1beta1/wire.proto create mode 100644 x/meshsecurity/ibc_module.go create mode 100644 x/meshsecurity/keeper/relay.go create mode 100644 x/meshsecurity/keeper/relay_test.go create mode 100644 x/meshsecurity/types/relay.go create mode 100644 x/provider/client/cli/gov_tx.go create mode 100644 x/provider/client/cli/query.go create mode 100644 x/provider/client/cli/tx.go create mode 100644 x/provider/ibc_module.go create mode 100644 x/provider/keeper/genesis.go create mode 100644 x/provider/keeper/keeper.go create mode 100644 x/provider/keeper/msg_server.go create mode 100644 x/provider/keeper/params.go create mode 100644 x/provider/keeper/querier.go create mode 100644 x/provider/keeper/relay.go create mode 100644 x/provider/module.go create mode 100644 x/provider/types/codec.go create mode 100644 x/provider/types/errors.go create mode 100644 x/provider/types/events.go create mode 100644 x/provider/types/expected_keepers.go create mode 100644 x/provider/types/genesis.go create mode 100644 x/provider/types/genesis.pb.go create mode 100644 x/provider/types/keys.go create mode 100644 x/provider/types/params.go create mode 100644 x/provider/types/params.pb.go create mode 100644 x/provider/types/provider.go create mode 100644 x/provider/types/query.pb.go create mode 100644 x/provider/types/query.pb.gw.go create mode 100644 x/provider/types/tx.pb.go create mode 100644 x/types/codec.go create mode 100644 x/types/error.go create mode 100644 x/types/event.go create mode 100644 x/types/key.go create mode 100644 x/types/wire.go create mode 100644 x/types/wire.pb.go create mode 100644 x/types/wire_test.go diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index b5fc4f31..78829d75 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,44 +4,36 @@ ## Table of Contents -- [osmosis/meshsecurity/v1beta1/meshsecurity.proto](#osmosis/meshsecurity/v1beta1/meshsecurity.proto) - - [Params](#osmosis.meshsecurity.v1beta1.Params) - - [VirtualStakingMaxCapInfo](#osmosis.meshsecurity.v1beta1.VirtualStakingMaxCapInfo) +- [osmosis/provider/v1beta1/params.proto](#osmosis/provider/v1beta1/params.proto) + - [Params](#osmosis.provider.v1beta1.Params) -- [osmosis/meshsecurity/v1beta1/genesis.proto](#osmosis/meshsecurity/v1beta1/genesis.proto) - - [GenesisState](#osmosis.meshsecurity.v1beta1.GenesisState) +- [osmosis/provider/v1beta1/genesis.proto](#osmosis/provider/v1beta1/genesis.proto) + - [GenesisState](#osmosis.provider.v1beta1.GenesisState) -- [osmosis/meshsecurity/v1beta1/query.proto](#osmosis/meshsecurity/v1beta1/query.proto) - - [QueryParamsRequest](#osmosis.meshsecurity.v1beta1.QueryParamsRequest) - - [QueryParamsResponse](#osmosis.meshsecurity.v1beta1.QueryParamsResponse) - - [QueryVirtualStakingMaxCapLimitRequest](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitRequest) - - [QueryVirtualStakingMaxCapLimitResponse](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitResponse) - - [QueryVirtualStakingMaxCapLimitsRequest](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitsRequest) - - [QueryVirtualStakingMaxCapLimitsResponse](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitsResponse) +- [osmosis/provider/v1beta1/query.proto](#osmosis/provider/v1beta1/query.proto) + - [QueryParamsRequest](#osmosis.provider.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#osmosis.provider.v1beta1.QueryParamsResponse) - - [Query](#osmosis.meshsecurity.v1beta1.Query) + - [Query](#osmosis.provider.v1beta1.Query) -- [osmosis/meshsecurity/v1beta1/scheduler.proto](#osmosis/meshsecurity/v1beta1/scheduler.proto) - - [ValidatorAddress](#osmosis.meshsecurity.v1beta1.ValidatorAddress) +- [osmosis/provider/v1beta1/tx.proto](#osmosis/provider/v1beta1/tx.proto) + - [MsgSetConsumerCommissionRate](#osmosis.provider.v1beta1.MsgSetConsumerCommissionRate) + - [MsgSetConsumerCommissionRateResponse](#osmosis.provider.v1beta1.MsgSetConsumerCommissionRateResponse) -- [osmosis/meshsecurity/v1beta1/tx.proto](#osmosis/meshsecurity/v1beta1/tx.proto) - - [MsgSetVirtualStakingMaxCap](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCap) - - [MsgSetVirtualStakingMaxCapResponse](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCapResponse) - - - [Msg](#osmosis.meshsecurity.v1beta1.Msg) + - [Msg](#osmosis.provider.v1beta1.Msg) - [Scalar Value Types](#scalar-value-types) - +

Top

-## osmosis/meshsecurity/v1beta1/meshsecurity.proto +## osmosis/provider/v1beta1/params.proto - + ### Params Params defines the parameters for the x/meshsecurity module. @@ -49,27 +41,8 @@ Params defines the parameters for the x/meshsecurity module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `total_contracts_max_cap` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | TotalContractsMaxCap is the maximum that the sum of all contract max caps must not exceed | -| `epoch_length` | [uint32](#uint32) | | Epoch length is the number of blocks that defines an epoch | -| `max_gas_end_blocker` | [uint32](#uint32) | | MaxGasEndBlocker defines the maximum gas that can be spent in a contract sudo callback | - - - - - - - - -### VirtualStakingMaxCapInfo -VirtualStakingMaxCapInfo stores info about -virtual staking max cap - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `contract` | [string](#string) | | Contract is the address of the contract | -| `delegated` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | Delegated is the total amount currently delegated | -| `cap` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | Cap is the current max cap limit | +| `infraction_time` | [uint64](#uint64) | | | +| `timeout_period` | [uint64](#uint64) | | TimeoutPeriod has the unit time.Millisecond | @@ -85,14 +58,14 @@ virtual staking max cap - +

Top

-## osmosis/meshsecurity/v1beta1/genesis.proto +## osmosis/provider/v1beta1/genesis.proto - + ### GenesisState GenesisState defines meshsecurity module's genesis state. @@ -100,7 +73,7 @@ GenesisState defines meshsecurity module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#osmosis.meshsecurity.v1beta1.Params) | | | +| `params` | [Params](#osmosis.provider.v1beta1.Params) | | | @@ -116,14 +89,14 @@ GenesisState defines meshsecurity module's genesis state. - +

Top

-## osmosis/meshsecurity/v1beta1/query.proto +## osmosis/provider/v1beta1/query.proto - + ### QueryParamsRequest QueryParamsRequest is the request type for the @@ -134,7 +107,7 @@ Query/Params RPC method - + ### QueryParamsResponse QueryParamsResponse is the response type for the @@ -143,67 +116,7 @@ Query/Params RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#osmosis.meshsecurity.v1beta1.Params) | | | - - - - - - - - -### QueryVirtualStakingMaxCapLimitRequest -QueryVirtualStakingMaxCapLimitRequest is the request type for the -Query/VirtualStakingMaxCapLimit RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | Address is the address of the contract to query | - - - - - - - - -### QueryVirtualStakingMaxCapLimitResponse -QueryVirtualStakingMaxCapLimitResponse is the response type for the -Query/VirtualStakingMaxCapLimit RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `delegated` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | -| `cap` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | - - - - - - - - -### QueryVirtualStakingMaxCapLimitsRequest -QueryVirtualStakingMaxCapLimitsRequest is the request type for the -Query/VirtualStakingMaxCapLimits RPC method - - - - - - - - -### QueryVirtualStakingMaxCapLimitsResponse -QueryVirtualStakingMaxCapLimitsResponse is the response type for the -Query/VirtualStakingMaxCapLimits RPC method - - -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `max_cap_infos` | [VirtualStakingMaxCapInfo](#osmosis.meshsecurity.v1beta1.VirtualStakingMaxCapInfo) | repeated | | +| `params` | [Params](#osmosis.provider.v1beta1.Params) | | | @@ -216,81 +129,47 @@ Query/VirtualStakingMaxCapLimits RPC method - + ### Query Query provides defines the gRPC querier service | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `VirtualStakingMaxCapLimit` | [QueryVirtualStakingMaxCapLimitRequest](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitRequest) | [QueryVirtualStakingMaxCapLimitResponse](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitResponse) | VirtualStakingMaxCapLimit gets max cap limit for the given contract | GET|/osmosis/meshsecurity/v1beta1/max_cap_limit/{address}| -| `VirtualStakingMaxCapLimits` | [QueryVirtualStakingMaxCapLimitsRequest](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitsRequest) | [QueryVirtualStakingMaxCapLimitsResponse](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitsResponse) | VirtualStakingMaxCapLimits gets max cap limits | GET|/osmosis/meshsecurity/v1beta1/max_cap_limits| -| `Params` | [QueryParamsRequest](#osmosis.meshsecurity.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#osmosis.meshsecurity.v1beta1.QueryParamsResponse) | Params queries the parameters of x/meshsecurity module. | GET|/osmosis/meshsecurity/v1beta1/params| +| `Params` | [QueryParamsRequest](#osmosis.provider.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#osmosis.provider.v1beta1.QueryParamsResponse) | Params queries the parameters of x/meshsecurity module. | GET|/osmosis/provider/v1beta1/params| - +

Top

-## osmosis/meshsecurity/v1beta1/scheduler.proto - - +## osmosis/provider/v1beta1/tx.proto - -### ValidatorAddress -ValidatorAddress payload data to be used with the scheduler + -| Field | Type | Label | Description | -| ----- | ---- | ----- | ----------- | -| `address` | [string](#string) | | Address is the ValAddress bech32 string | - +### MsgSetConsumerCommissionRate - - - - - - - - - - - - -

Top

- -## osmosis/meshsecurity/v1beta1/tx.proto - - - - - -### MsgSetVirtualStakingMaxCap -MsgSetVirtualStakingMaxCap creates or updates a maximum cap limit for virtual -staking coins to the given contract. - - | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `authority` | [string](#string) | | Authority is the address that controls the module (defaults to x/gov unless overwritten). | -| `contract` | [string](#string) | | Contract is the address of the smart contract that is given permission do virtual staking which includes minting and burning staking tokens. | -| `max_cap` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | MaxCap is the limit up this the virtual tokens can be minted. | +| `provider_addr` | [string](#string) | | | +| `chain_id` | [string](#string) | | | +| `rate` | [string](#string) | | | - + + +### MsgSetConsumerCommissionRateResponse -### MsgSetVirtualStakingMaxCapResponse -MsgSetVirtualStakingMaxCap returns result data. @@ -303,14 +182,14 @@ MsgSetVirtualStakingMaxCap returns result data. - + ### Msg -Msg defines the wasm Msg service. + | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `SetVirtualStakingMaxCap` | [MsgSetVirtualStakingMaxCap](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCap) | [MsgSetVirtualStakingMaxCapResponse](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCapResponse) | SetVirtualStakingMaxCap creates or updates a maximum cap limit for virtual staking coins | | +| `SetConsumerCommissionRate` | [MsgSetConsumerCommissionRate](#osmosis.provider.v1beta1.MsgSetConsumerCommissionRate) | [MsgSetConsumerCommissionRateResponse](#osmosis.provider.v1beta1.MsgSetConsumerCommissionRateResponse) | | | diff --git a/proto/osmosis/provider/v1beta1/genesis.proto b/proto/osmosis/provider/v1beta1/genesis.proto new file mode 100644 index 00000000..5829ce22 --- /dev/null +++ b/proto/osmosis/provider/v1beta1/genesis.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package osmosis.provider.v1beta1; + +import "osmosis/provider/v1beta1/params.proto"; +import "gogoproto/gogo.proto"; +import "amino/amino.proto"; + +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; +option (gogoproto.goproto_getters_all) = false; +option (gogoproto.equal_all) = false; + +// GenesisState defines meshsecurity module's genesis state. +message GenesisState { + option (gogoproto.equal) = true; + + Params params = 1 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; +} diff --git a/proto/osmosis/provider/v1beta1/params.proto b/proto/osmosis/provider/v1beta1/params.proto new file mode 100644 index 00000000..50ae2eb2 --- /dev/null +++ b/proto/osmosis/provider/v1beta1/params.proto @@ -0,0 +1,22 @@ +syntax = "proto3"; +package osmosis.provider.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; +import "amino/amino.proto"; + +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; +option (gogoproto.goproto_getters_all) = false; +option (gogoproto.equal_all) = false; + +// Params defines the parameters for the x/meshsecurity module. +message Params { + option (amino.name) = "provider/Params"; + option (gogoproto.equal) = true; + + uint64 infraction_time = 1; + + // TimeoutPeriod has the unit time.Millisecond + uint64 timeout_period = 2; +} + diff --git a/proto/osmosis/provider/v1beta1/query.proto b/proto/osmosis/provider/v1beta1/query.proto new file mode 100644 index 00000000..535d98a2 --- /dev/null +++ b/proto/osmosis/provider/v1beta1/query.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package osmosis.provider.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "osmosis/provider/v1beta1/params.proto"; +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "amino/amino.proto"; + +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; +option (gogoproto.goproto_getters_all) = false; +option (gogoproto.equal_all) = false; + +// Query provides defines the gRPC querier service +service Query { + // Params queries the parameters of x/meshsecurity module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/osmosis/provider/v1beta1/params"; + } +} +// QueryParamsRequest is the request type for the +// Query/Params RPC method +message QueryParamsRequest {} + +// QueryParamsResponse is the response type for the +// Query/Params RPC method +message QueryParamsResponse { + Params params = 1 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; +} diff --git a/proto/osmosis/provider/v1beta1/tx.proto b/proto/osmosis/provider/v1beta1/tx.proto new file mode 100644 index 00000000..77cb6f6c --- /dev/null +++ b/proto/osmosis/provider/v1beta1/tx.proto @@ -0,0 +1,32 @@ +syntax = "proto3"; +package osmosis.provider.v1beta1; + +import "cosmos_proto/cosmos.proto"; +import "cosmos/msg/v1/msg.proto"; +import "gogoproto/gogo.proto"; +import "amino/amino.proto"; + +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; +option (gogoproto.goproto_getters_all) = false; + +service Msg { + rpc SetConsumerCommissionRate(MsgSetConsumerCommissionRate) returns (MsgSetConsumerCommissionRateResponse); +} + +message MsgSetConsumerCommissionRate { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string provider_addr = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; + + string chain_id = 2; + + string rate = 3 [ + (cosmos_proto.scalar) = "cosmos.Dec", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + + +message MsgSetConsumerCommissionRateResponse {} diff --git a/proto/osmosis/types/v1beta1/wire.proto b/proto/osmosis/types/v1beta1/wire.proto new file mode 100644 index 00000000..5e5078f3 --- /dev/null +++ b/proto/osmosis/types/v1beta1/wire.proto @@ -0,0 +1,57 @@ +syntax = "proto3"; +package osmosis.types.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; +import "amino/amino.proto"; +import "cosmos/staking/v1beta1/staking.proto"; +import "tendermint/abci/types.proto"; + + +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/types"; +option (gogoproto.goproto_getters_all) = false; +option (gogoproto.equal_all) = false; + +// enum PipedValsetOperation +enum PipedValsetOperation { + UNSPECIFIED = 0; + VALIDATOR_BONDED = 1; + VALIDATOR_UNBONDED = 2; + VALIDATOR_JAILED = 3; + VALIDATOR_TOMBSTONED = 4; + VALIDATOR_UNJAILED = 5; + VALIDATOR_MODIFIED = 6; + VALIDATOR_SLASHED = 7; +} + +// SlashInfo defines info event from slashing +message SlashInfo { + int64 infraction_height = 2; + int64 power = 3; + string total_slash_amount = 4; + string slash_fraction = 5; + int64 time_infraction = 6; +} + +// ConsumerPacketData contains a consumer packet data and a type tag +message ConsumerPacketData { + PipedValsetOperation type = 1; + + oneof data { + SlashInfo slashPacketData = 2; + } +} + +// InfractionType indicates the infraction type a validator committed. +// Note ccv.InfractionType to maintain compatibility between ICS versions +// using different versions of the cosmos-sdk and ibc-go modules. +enum InfractionType { + option (gogoproto.goproto_enum_prefix) = false; + + // UNSPECIFIED defines an empty infraction type. + INFRACTION_TYPE_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "InfractionEmpty"]; + // DOUBLE_SIGN defines a validator that double-signs a block. + INFRACTION_TYPE_DOUBLE_SIGN = 1 [(gogoproto.enumvalue_customname) = "DoubleSign"]; + // DOWNTIME defines a validator that missed signing too many blocks. + INFRACTION_TYPE_DOWNTIME = 2 [(gogoproto.enumvalue_customname) = "Downtime"]; +} diff --git a/x/meshsecurity/ibc_module.go b/x/meshsecurity/ibc_module.go new file mode 100644 index 00000000..ddbffb48 --- /dev/null +++ b/x/meshsecurity/ibc_module.go @@ -0,0 +1,172 @@ +package meshsecurity + +import ( + // "fmt" + "strings" + // "strconv" + + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + // porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + // host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + // transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + + ctypes "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" + "github.com/osmosis-labs/mesh-security-sdk/x/types" +) + +// OnChanOpenInit implements the IBCModule interface +// this function is called by the relayer. +func (am AppModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) (string, error) { + if strings.TrimSpace(version) == "" { + version = types.Version + } + + return version, nil +} + +// OnChanOpenTry implements the IBCModule interface +func (am AppModule) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + counterpartyVersion string, +) (string, error) { + return "", errorsmod.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by consumer chain") +} + +// OnChanOpenAck implements the IBCModule interface +func (am AppModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + _ string, // Counter party channel ID is unused per spec + counterpartyMetadata string, +) error { + + return nil +} + +// OnChanOpenConfirm implements the IBCModule interface +func (am AppModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return errorsmod.Wrap(types.ErrInvalidChannelFlow, "channel handshake must be initiated by consumer chain") +} + +// OnChanCloseInit implements the IBCModule interface +func (am AppModule) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + // allow relayers to close duplicate OPEN channels, if the provider channel has already been established + // if providerChannel, ok := am.keeper.GetProviderChannel(ctx); ok && providerChannel != channelID { + // return nil + // } + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") +} + +// OnChanCloseConfirm implements the IBCModule interface +func (am AppModule) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnRecvPacket implements the IBCModule interface. A successful acknowledgement +// is returned if the packet data is successfully decoded and the receive application +// logic returns without error. +func (am AppModule) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + _ sdk.AccAddress, +) ibcexported.Acknowledgement { + ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) + // was successfully decoded + if ack.Success() { + //TODO: OnRecvPacket + } + + // NOTE: acknowledgement will be written synchronously during IBC handler execution. + return ack +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (am AppModule) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + _ sdk.AccAddress, +) error { + var ack channeltypes.Acknowledgement + if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal consumer packet acknowledgement: %v", err) + } + + if err := am.k.OnAcknowledgementPacket(ctx, packet, ack); err != nil { + return err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypePacket, + sdk.NewAttribute(sdk.AttributeKeyModule, ctypes.ModuleName), + sdk.NewAttribute(types.AttributeKeyAck, ack.String()), + ), + ) + switch resp := ack.Response.(type) { + case *channeltypes.Acknowledgement_Result: + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypePacket, + sdk.NewAttribute(types.AttributeKeyAckSuccess, string(resp.Result)), + ), + ) + case *channeltypes.Acknowledgement_Error: + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypePacket, + sdk.NewAttribute(types.AttributeKeyAckError, resp.Error), + ), + ) + } + return nil +} + +// OnTimeoutPacket implements the IBCModule interface +func (am AppModule) OnTimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + _ sdk.AccAddress, +) error { + return nil +} + +func UnmarshalConsumerPacket(packetData []byte) (any, error) { + // TODO: type packet from provider + return nil, nil +} diff --git a/x/meshsecurity/keeper/adapter_test.go b/x/meshsecurity/keeper/adapter_test.go index 02948394..72fe8e4f 100644 --- a/x/meshsecurity/keeper/adapter_test.go +++ b/x/meshsecurity/keeper/adapter_test.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/address" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" + cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" ) func TestCaptureTombstone(t *testing.T) { @@ -28,12 +28,12 @@ func TestCaptureTombstone(t *testing.T) { specs := map[string]struct { addr sdk.ConsAddress expPassed []sdk.ConsAddress - expStored []types.PipedValsetOperation + expStored []cptypes.PipedValsetOperation }{ "with existing validator": { addr: myConsAddress, expPassed: []sdk.ConsAddress{myConsAddress}, - expStored: []types.PipedValsetOperation{types.ValidatorTombstoned}, + expStored: []cptypes.PipedValsetOperation{cptypes.PipedValsetOperation_VALIDATOR_TOMBSTONED}, }, "unknown consensus address": { addr: otherConsAddress, @@ -76,19 +76,19 @@ func TestCaptureStakingEvents(t *testing.T) { specs := map[string]struct { consAddr sdk.ConsAddress op func(sdk.Context, sdk.ConsAddress) - expStored []types.PipedValsetOperation + expStored []cptypes.PipedValsetOperation expJailed bool }{ "jail": { consAddr: myConsAddress, op: decorator.Jail, - expStored: []types.PipedValsetOperation{types.ValidatorJailed}, + expStored: []cptypes.PipedValsetOperation{cptypes.PipedValsetOperation_VALIDATOR_JAILED}, expJailed: true, }, "unjail": { consAddr: myConsAddressJailed, op: decorator.Unjail, - expStored: []types.PipedValsetOperation{types.ValidatorUnjailed}, + expStored: []cptypes.PipedValsetOperation{cptypes.PipedValsetOperation_VALIDATOR_UNJAILED}, }, } for name, spec := range specs { diff --git a/x/meshsecurity/keeper/keeper.go b/x/meshsecurity/keeper/keeper.go index a9117790..2dc9dbec 100644 --- a/x/meshsecurity/keeper/keeper.go +++ b/x/meshsecurity/keeper/keeper.go @@ -8,6 +8,9 @@ import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -29,6 +32,9 @@ type Keeper struct { bank types.XBankKeeper Staking types.XStakingKeeper wasm types.WasmKeeper + + scopedKeeper types.ScopedKeeper + channelKeeper types.ChannelKeeper // the address capable of executing a MsgUpdateParams message. Typically, this // should be the x/gov module account. authority string @@ -42,10 +48,12 @@ func NewKeeper( bank types.SDKBankKeeper, staking types.SDKStakingKeeper, wasm types.WasmKeeper, + scopedKeeper types.ScopedKeeper, + channelKeeper types.ChannelKeeper, authority string, opts ...Option, ) *Keeper { - return NewKeeperX(cdc, storeKey, memoryStoreKey, NewBankKeeperAdapter(bank), NewStakingKeeperAdapter(staking, bank), wasm, authority, opts...) + return NewKeeperX(cdc, storeKey, memoryStoreKey, NewBankKeeperAdapter(bank), NewStakingKeeperAdapter(staking, bank), wasm, scopedKeeper, channelKeeper, authority, opts...) } // NewKeeperX constructor with extended Osmosis SDK keepers @@ -56,17 +64,21 @@ func NewKeeperX( bank types.XBankKeeper, staking types.XStakingKeeper, wasm types.WasmKeeper, + scopedKeeper types.ScopedKeeper, + channelKeeper types.ChannelKeeper, authority string, opts ...Option, ) *Keeper { k := &Keeper{ - storeKey: storeKey, - memKey: memoryStoreKey, - cdc: cdc, - bank: bank, - Staking: staking, - wasm: wasm, - authority: authority, + storeKey: storeKey, + memKey: memoryStoreKey, + cdc: cdc, + bank: bank, + Staking: staking, + wasm: wasm, + scopedKeeper: scopedKeeper, + channelKeeper: channelKeeper, + authority: authority, } for _, o := range opts { o.apply(k) @@ -185,3 +197,28 @@ func (k Keeper) IterateMaxCapLimit(ctx sdk.Context, cb func(sdk.AccAddress, math func ModuleLogger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +// GetProviderChannel gets the channelID for the channel to the provider. +func (k Keeper) GetProviderChannel(ctx sdk.Context) (string, bool) { + store := ctx.KVStore(k.storeKey) + channelIdBytes := store.Get(types.ProviderChannelKey()) + if len(channelIdBytes) == 0 { + return "", false + } + return string(channelIdBytes), true +} + +// SetProviderChannel sets the channelID for the channel to the provider. +func (k Keeper) SetProviderChannel(ctx sdk.Context, channelID string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.ProviderChannelKey(), []byte(channelID)) +} + +func (k Keeper) ChanCloseInit(ctx sdk.Context, portID, channelID string) error { + capName := host.ChannelCapabilityPath(portID, channelID) + chanCap, ok := k.scopedKeeper.GetCapability(ctx, capName) + if !ok { + return errorsmod.Wrapf(channeltypes.ErrChannelCapabilityNotFound, "could not retrieve channel capability at: %s", capName) + } + return k.channelKeeper.ChanCloseInit(ctx, portID, channelID, chanCap) +} diff --git a/x/meshsecurity/keeper/relay.go b/x/meshsecurity/keeper/relay.go new file mode 100644 index 00000000..48e8e73d --- /dev/null +++ b/x/meshsecurity/keeper/relay.go @@ -0,0 +1,100 @@ +package keeper + +import ( + errorsmod "cosmossdk.io/errors" + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + + ctypes "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" + "github.com/osmosis-labs/mesh-security-sdk/x/types" +) + +func (k Keeper) SendPackets(ctx sdk.Context) { + channelID, ok := k.GetProviderChannel(ctx) + if !ok { + return + } + + // pending := k.GetAllPendingPacketsWithIdx(ctx) + ConsumerPackets := []types.ConsumerPacketData{} + k.iteratePipedValsetOperations(ctx, func(valAddress sdk.ValAddress, op types.PipedValsetOperation, slashInfo *types.SlashInfo) bool { + newPacket := types.ConsumerPacketData{ + Type: op, + Data: &types.ConsumerPacketData_SlashPacketData{ + SlashPacketData: slashInfo, + }, + } + ConsumerPackets = append(ConsumerPackets, newPacket) + + return false + }) + + for _, s := range ConsumerPackets { + // Send packet over IBC + err := ctypes.SendIBCPacket( + ctx, + k.scopedKeeper, + k.channelKeeper, + channelID, // source channel id + ctypes.ConsumerPortID, // source port id + s.GetBytes(), + k.GetParams(ctx).GetTimeoutPeriod(), + ) + if err != nil { + if clienttypes.ErrClientNotActive.Is(err) { + ModuleLogger(ctx).Info("IBC client is expired, cannot send IBC packet; leaving packet data stored:") + break + } + ModuleLogger(ctx).Error("cannot send IBC packet; leaving packet data stored:", "err", err.Error()) + break + } + } +} + +func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, ack channeltypes.Acknowledgement) error { + if res := ack.GetResult(); res != nil { + if len(res) != 1 { + return fmt.Errorf("acknowledgement result length must be 1, got %d", len(res)) + } + + consumerPacket, err := types.UnmarshalConsumerPacketData(packet.GetData()) + if err != nil { + return err + } + if consumerPacket.Type != types.PipedValsetOperation_VALIDATOR_SLASHED { + return nil + } + k.ClearPipedValsetOperations(ctx) + } + + if err := ack.GetError(); err != "" { + // Reasons for ErrorAcknowledgment + // - packet data could not be successfully decoded + // - invalid Slash packet + // None of these should ever happen. + ModuleLogger(ctx).Error( + "recv ErrorAcknowledgement", + "channel", packet.SourceChannel, + "error", err, + ) + // Initiate ChanCloseInit using packet source (non-counterparty) port and channel + err := k.ChanCloseInit(ctx, packet.SourcePort, packet.SourceChannel) + if err != nil { + return fmt.Errorf("ChanCloseInit(%s) failed: %s", packet.SourceChannel, err.Error()) + } + // check if there is an established CCV channel to provider + channelID, found := k.GetProviderChannel(ctx) + if !found { + return errorsmod.Wrapf(ctypes.ErrNoProposerChannelId, "recv ErrorAcknowledgement on non-established channel %s", packet.SourceChannel) + } + if channelID != packet.SourceChannel { + // Close the established CCV channel as well + return k.ChanCloseInit(ctx, types.ConsumerPortID, channelID) + } + } + return nil +} diff --git a/x/meshsecurity/keeper/relay_test.go b/x/meshsecurity/keeper/relay_test.go new file mode 100644 index 00000000..56522c38 --- /dev/null +++ b/x/meshsecurity/keeper/relay_test.go @@ -0,0 +1,32 @@ +package keeper + +import ( + "testing" + + "cosmossdk.io/math" + "github.com/cometbft/cometbft/libs/rand" + sdk "github.com/cosmos/cosmos-sdk/types" + + // "github.com/stretchr/testify/require" + + // "github.com/cosmos/cosmos-sdk/types/address" + + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" +) + +func TestDDD(t *testing.T) { + ctx, keepers := CreateDefaultTestInput(t) + k := keepers.MeshKeeper + myValidatorAddr := sdk.ValAddress(rand.Bytes(20)) + // myOtherValAddr = sdk.ValAddress(rand.Bytes(address.Len)) + // myVStakingContractAddr = sdk.AccAddress(rand.Bytes(address.Len)) + // myOtherVStakingContractAddr = sdk.AccAddress(rand.Bytes(address.Len)) + + k.SetProviderChannel(ctx, "consumerCCVChannelID") + k.SetParams(ctx, types.DefaultParams(sdk.DefaultBondDenom)) + + k.ScheduleSlashed(ctx, myValidatorAddr, 46, 56, math.NewInt(66), math.LegacyMustNewDecFromStr("0.1")) + k.ScheduleSlashed(ctx, myValidatorAddr, 45, 55, math.NewInt(66), math.LegacyMustNewDecFromStr("0.1")) + + k.SendPackets(ctx) +} diff --git a/x/meshsecurity/keeper/test_common.go b/x/meshsecurity/keeper/test_common.go index 6a97ac67..98fe202c 100644 --- a/x/meshsecurity/keeper/test_common.go +++ b/x/meshsecurity/keeper/test_common.go @@ -60,6 +60,7 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" + cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" ) type encodingConfig struct { @@ -276,6 +277,8 @@ func CreateDefaultTestInput(t testing.TB, opts ...Option) (sdk.Context, TestKeep bankKeeper, stakingKeeper, wasmKeeper, + scopedWasmKeeper, + ibcKeeper.ChannelKeeper, authority, opts..., ) @@ -296,12 +299,12 @@ func CreateDefaultTestInput(t testing.TB, opts ...Option) (sdk.Context, TestKeep } // FetchAllStoredOperations load all ops from temp db -func FetchAllStoredOperations(t *testing.T, ctx sdk.Context, msKeeper *Keeper) map[string][]types.PipedValsetOperation { - index := make(map[string][]types.PipedValsetOperation, 1) - err := msKeeper.iteratePipedValsetOperations(ctx, func(valAddr sdk.ValAddress, op types.PipedValsetOperation, slashInfo *types.SlashInfo) bool { +func FetchAllStoredOperations(t *testing.T, ctx sdk.Context, msKeeper *Keeper) map[string][]cptypes.PipedValsetOperation { + index := make(map[string][]cptypes.PipedValsetOperation, 1) + err := msKeeper.iteratePipedValsetOperations(ctx, func(valAddr sdk.ValAddress, op cptypes.PipedValsetOperation, slashInfo *cptypes.SlashInfo) bool { ops, ok := index[valAddr.String()] if !ok { - ops = []types.PipedValsetOperation{} + ops = []cptypes.PipedValsetOperation{} } index[valAddr.String()] = append(ops, op) return false diff --git a/x/meshsecurity/keeper/valset_updates.go b/x/meshsecurity/keeper/valset_updates.go index 50101d1a..3e5ebdc1 100644 --- a/x/meshsecurity/keeper/valset_updates.go +++ b/x/meshsecurity/keeper/valset_updates.go @@ -8,6 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/contract" "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" @@ -16,48 +18,48 @@ import ( // ScheduleBonded store a validator update to bonded status for the valset update report func (k Keeper) ScheduleBonded(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, types.ValidatorBonded, addr, nil) + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_BONDED, addr, nil) } // ScheduleUnbonded store a validator update to unbonded status for the valset update report func (k Keeper) ScheduleUnbonded(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, types.ValidatorUnbonded, addr, nil) + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_UNBONDED, addr, nil) } // ScheduleSlashed store a validator slash event / data for the valset update report func (k Keeper) ScheduleSlashed(ctx sdk.Context, addr sdk.ValAddress, power int64, height int64, totalSlashAmount math.Int, slashRatio sdk.Dec) error { - var slashInfo = &types.SlashInfo{ + var slashInfo = &cptypes.SlashInfo{ Power: power, InfractionHeight: height, TotalSlashAmount: totalSlashAmount.String(), SlashFraction: slashRatio.String(), } - return k.sendAsync(ctx, types.ValidatorSlashed, addr, slashInfo) + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_SLASHED, addr, slashInfo) } // ScheduleJailed store a validator update to jailed status for the valset update report func (k Keeper) ScheduleJailed(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, types.ValidatorJailed, addr, nil) + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_JAILED, addr, nil) } // ScheduleTombstoned store a validator update to tombstoned status for the valset update report func (k Keeper) ScheduleTombstoned(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, types.ValidatorTombstoned, addr, nil) + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_TOMBSTONED, addr, nil) } // ScheduleUnjailed store a validator update to unjailed status for the valset update report func (k Keeper) ScheduleUnjailed(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, types.ValidatorUnjailed, addr, nil) + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_UNJAILED, addr, nil) } // ScheduleModified store a validator metadata update for the valset update report func (k Keeper) ScheduleModified(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, types.ValidatorModified, addr, nil) + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, addr, nil) } // instead of sync calls to the contracts for the different kind of valset changes in a block, we store them in the mem db // and async send to all registered contracts in the end blocker -func (k Keeper) sendAsync(ctx sdk.Context, op types.PipedValsetOperation, valAddr sdk.ValAddress, slashInfo *types.SlashInfo) error { +func (k Keeper) sendAsync(ctx sdk.Context, op cptypes.PipedValsetOperation, valAddr sdk.ValAddress, slashInfo *cptypes.SlashInfo) error { ModuleLogger(ctx).Debug("storing for async update", "operation", int(op), "val", valAddr.String()) ctx.KVStore(k.memKey).Set(types.BuildPipedValsetOpKey(op, valAddr, slashInfo), []byte{}) // and schedule an update callback for all registered contracts @@ -112,21 +114,21 @@ func (k Keeper) ValsetUpdateReport(ctx sdk.Context) (contract.ValsetUpdate, erro Tombstoned: make([]contract.ValidatorAddr, 0), Slashed: make([]contract.ValidatorSlash, 0), } - err := k.iteratePipedValsetOperations(ctx, func(valAddr sdk.ValAddress, op types.PipedValsetOperation, slashInfo *types.SlashInfo) bool { + err := k.iteratePipedValsetOperations(ctx, func(valAddr sdk.ValAddress, op cptypes.PipedValsetOperation, slashInfo *cptypes.SlashInfo) bool { switch op { - case types.ValidatorBonded: + case cptypes.PipedValsetOperation_VALIDATOR_BONDED: return appendValidator(&r.Additions, valAddr) - case types.ValidatorUnbonded: + case cptypes.PipedValsetOperation_VALIDATOR_UNBONDED: r.Removals = append(r.Removals, valAddr.String()) - case types.ValidatorJailed: + case cptypes.PipedValsetOperation_VALIDATOR_JAILED: r.Jailed = append(r.Jailed, valAddr.String()) - case types.ValidatorTombstoned: + case cptypes.PipedValsetOperation_VALIDATOR_TOMBSTONED: r.Tombstoned = append(r.Tombstoned, valAddr.String()) - case types.ValidatorUnjailed: + case cptypes.PipedValsetOperation_VALIDATOR_UNJAILED: r.Unjailed = append(r.Unjailed, valAddr.String()) - case types.ValidatorModified: + case cptypes.PipedValsetOperation_VALIDATOR_MODIFIED: return appendValidator(&r.Updated, valAddr) - case types.ValidatorSlashed: + case cptypes.PipedValsetOperation_VALIDATOR_SLASHED: // TODO: Add / send the infraction time return slashValidator(&r.Slashed, valAddr, slashInfo.Power, slashInfo.InfractionHeight, 0, slashInfo.TotalSlashAmount, slashInfo.SlashFraction) @@ -157,27 +159,27 @@ func (k Keeper) ClearPipedValsetOperations(ctx sdk.Context) { } // iterate through all stored valset updates. Due to the storage key, there are no contract duplicates within an operation type. -func (k Keeper) iteratePipedValsetOperations(ctx sdk.Context, cb func(valAddress sdk.ValAddress, op types.PipedValsetOperation, slashInfo *types.SlashInfo) bool) error { +func (k Keeper) iteratePipedValsetOperations(ctx sdk.Context, cb func(valAddress sdk.ValAddress, op cptypes.PipedValsetOperation, slashInfo *cptypes.SlashInfo) bool) error { pStore := prefix.NewStore(ctx.KVStore(k.memKey), types.PipedValsetPrefix) iter := pStore.Iterator(nil, nil) for ; iter.Valid(); iter.Next() { key := iter.Key() addrLen := key[0] addr, op := key[1:addrLen+1], key[addrLen+1] - var slashInfo *types.SlashInfo = nil - if types.PipedValsetOperation(op) == types.ValidatorSlashed { + var slashInfo *cptypes.SlashInfo = nil + if cptypes.PipedValsetOperation(op) == cptypes.PipedValsetOperation_VALIDATOR_SLASHED { if len(key) <= 1+int(addrLen)+1+8+8+1 { return types.ErrInvalid.Wrapf("invalid slash key length %d", len(key)) } totalSlashAmountLen := key[addrLen+2+8+8] - slashInfo = &types.SlashInfo{ + slashInfo = &cptypes.SlashInfo{ Power: int64(sdk.BigEndianToUint64(key[addrLen+2 : addrLen+2+8])), InfractionHeight: int64(sdk.BigEndianToUint64(key[addrLen+2+8 : addrLen+2+8+8])), TotalSlashAmount: string(key[addrLen+2+8+8+1 : addrLen+2+8+8+1+totalSlashAmountLen]), SlashFraction: string(key[addrLen+2+8+8+1+totalSlashAmountLen:]), } } - if cb(addr, types.PipedValsetOperation(op), slashInfo) { + if cb(addr, cptypes.PipedValsetOperation(op), slashInfo) { break } } diff --git a/x/meshsecurity/keeper/valset_updates_test.go b/x/meshsecurity/keeper/valset_updates_test.go index 5d794593..03a75a0d 100644 --- a/x/meshsecurity/keeper/valset_updates_test.go +++ b/x/meshsecurity/keeper/valset_updates_test.go @@ -17,6 +17,7 @@ import ( "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/contract" "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" + cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" ) func TestSendAsync(t *testing.T) { @@ -30,36 +31,36 @@ func TestSendAsync(t *testing.T) { ) specs := map[string]struct { setup func(t *testing.T, ctx sdk.Context) - assert func(t *testing.T, ctx sdk.Context, ops map[string][]types.PipedValsetOperation) + assert func(t *testing.T, ctx sdk.Context, ops map[string][]cptypes.PipedValsetOperation) }{ "no duplicates": { setup: func(t *testing.T, ctx sdk.Context) { - require.NoError(t, k.sendAsync(ctx, types.ValidatorModified, myValAddr, nil)) + require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, myValAddr, nil)) }, - assert: func(t *testing.T, ctx sdk.Context, ops map[string][]types.PipedValsetOperation) { + assert: func(t *testing.T, ctx sdk.Context, ops map[string][]cptypes.PipedValsetOperation) { assert.Len(t, ops, 1) - exp := []types.PipedValsetOperation{types.ValidatorModified} + exp := []cptypes.PipedValsetOperation{cptypes.PipedValsetOperation_VALIDATOR_MODIFIED} assert.Equal(t, exp, ops[myValAddr.String()]) }, }, "separated by validator": { setup: func(t *testing.T, ctx sdk.Context) { - require.NoError(t, k.sendAsync(ctx, types.ValidatorModified, myOtherValAddr, nil)) + require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, myOtherValAddr, nil)) }, - assert: func(t *testing.T, ctx sdk.Context, ops map[string][]types.PipedValsetOperation) { + assert: func(t *testing.T, ctx sdk.Context, ops map[string][]cptypes.PipedValsetOperation) { assert.Len(t, ops, 2) - exp := []types.PipedValsetOperation{types.ValidatorModified} + exp := []cptypes.PipedValsetOperation{cptypes.PipedValsetOperation_VALIDATOR_MODIFIED} assert.Equal(t, exp, ops[myValAddr.String()]) assert.Equal(t, exp, ops[myOtherValAddr.String()]) }, }, "separated by type": { setup: func(t *testing.T, ctx sdk.Context) { - require.NoError(t, k.sendAsync(ctx, types.ValidatorBonded, myValAddr, nil)) + require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_BONDED, myValAddr, nil)) }, - assert: func(t *testing.T, ctx sdk.Context, ops map[string][]types.PipedValsetOperation) { + assert: func(t *testing.T, ctx sdk.Context, ops map[string][]cptypes.PipedValsetOperation) { assert.Len(t, ops, 1) - exp := []types.PipedValsetOperation{types.ValidatorBonded, types.ValidatorModified} + exp := []cptypes.PipedValsetOperation{cptypes.PipedValsetOperation_VALIDATOR_BONDED, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED} assert.Equal(t, exp, ops[myValAddr.String()]) }, }, @@ -70,7 +71,7 @@ func TestSendAsync(t *testing.T) { err = k.SetMaxCapLimit(ctx, myOtherVStakingContractAddr, sdk.NewCoin("stake", sdkmath.NewInt(100_000_000))) require.NoError(t, err) }, - assert: func(t *testing.T, ctx sdk.Context, ops map[string][]types.PipedValsetOperation) { + assert: func(t *testing.T, ctx sdk.Context, ops map[string][]cptypes.PipedValsetOperation) { isScheduled := k.HasScheduledTask(ctx, types.SchedulerTaskValsetUpdate, myVStakingContractAddr, false) assert.True(t, isScheduled) isScheduled = k.HasScheduledTask(ctx, types.SchedulerTaskValsetUpdate, myOtherVStakingContractAddr, false) @@ -82,7 +83,7 @@ func TestSendAsync(t *testing.T) { err := k.SetMaxCapLimit(ctx, myVStakingContractAddr, sdk.NewCoin("stake", sdkmath.NewInt(100_000_000))) require.NoError(t, err) }, - assert: func(t *testing.T, ctx sdk.Context, ops map[string][]types.PipedValsetOperation) { + assert: func(t *testing.T, ctx sdk.Context, ops map[string][]cptypes.PipedValsetOperation) { isScheduled := k.HasScheduledTask(ctx, types.SchedulerTaskValsetUpdate, myVStakingContractAddr, false) assert.True(t, isScheduled) isScheduled = k.HasScheduledTask(ctx, types.SchedulerTaskValsetUpdate, myOtherVStakingContractAddr, false) @@ -95,7 +96,7 @@ func TestSendAsync(t *testing.T) { ctx, _ := pCtx.CacheContext() spec.setup(t, ctx) // when - gotErr := k.sendAsync(ctx, types.ValidatorModified, myValAddr, nil) + gotErr := k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, myValAddr, nil) // then require.NoError(t, gotErr) allStoredOps := FetchAllStoredOperations(t, ctx, k) @@ -123,19 +124,19 @@ func TestBuildValsetUpdateReport(t *testing.T) { } type tuple struct { - op types.PipedValsetOperation + op cptypes.PipedValsetOperation valAddr sdk.ValAddress } allOps := []tuple{ - {op: types.ValidatorJailed, valAddr: val1}, - {op: types.ValidatorUnjailed, valAddr: val2}, - {op: types.ValidatorModified, valAddr: val2}, - {op: types.ValidatorUnbonded, valAddr: val3}, - {op: types.ValidatorJailed, valAddr: val3}, - {op: types.ValidatorTombstoned, valAddr: val3}, - {op: types.ValidatorModified, valAddr: val3}, - {op: types.ValidatorBonded, valAddr: val4}, - {op: types.ValidatorModified, valAddr: val4}, + {op: cptypes.PipedValsetOperation_VALIDATOR_JAILED, valAddr: val1}, + {op: cptypes.PipedValsetOperation_VALIDATOR_UNJAILED, valAddr: val2}, + {op: cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, valAddr: val2}, + {op: cptypes.PipedValsetOperation_VALIDATOR_UNBONDED, valAddr: val3}, + {op: cptypes.PipedValsetOperation_VALIDATOR_JAILED, valAddr: val3}, + {op: cptypes.PipedValsetOperation_VALIDATOR_TOMBSTONED, valAddr: val3}, + {op: cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, valAddr: val3}, + {op: cptypes.PipedValsetOperation_VALIDATOR_BONDED, valAddr: val4}, + {op: cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, valAddr: val4}, } stdrand.Shuffle(len(allOps), func(i, j int) { allOps[i], allOps[j] = allOps[j], allOps[i] @@ -197,7 +198,7 @@ func TestValsetUpdateReportErrors(t *testing.T) { }{ "unknown val address": { setup: func(t *testing.T, ctx sdk.Context) { - require.NoError(t, k.sendAsync(ctx, types.ValidatorBonded, nonValAddr, nil)) + require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_BONDED, nonValAddr, nil)) }, expErr: types.ErrUnknown, }, @@ -223,9 +224,9 @@ func TestValsetUpdateReportErrors(t *testing.T) { func TestClearPipedValsetOperations(t *testing.T) { ctx, keepers := CreateDefaultTestInput(t) k := keepers.MeshKeeper - err := k.sendAsync(ctx, types.ValidatorModified, rand.Bytes(address.Len), nil) + err := k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, rand.Bytes(address.Len), nil) require.NoError(t, err) - err = k.sendAsync(ctx, types.ValidatorUnjailed, rand.Bytes(address.Len), nil) + err = k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_UNJAILED, rand.Bytes(address.Len), nil) require.NoError(t, err) // when k.ClearPipedValsetOperations(ctx) diff --git a/x/meshsecurity/types/errors.go b/x/meshsecurity/types/errors.go index da76a5a1..661c6e76 100644 --- a/x/meshsecurity/types/errors.go +++ b/x/meshsecurity/types/errors.go @@ -5,8 +5,10 @@ import ( ) var ( - ErrInvalid = errorsmod.Register(ModuleName, 1, "invalid") - ErrMaxCapExceeded = errorsmod.Register(ModuleName, 2, "max cap exceeded") - ErrUnsupported = errorsmod.Register(ModuleName, 3, "unsupported") - ErrUnknown = errorsmod.Register(ModuleName, 4, "unknown") + ErrInvalid = errorsmod.Register(ModuleName, 1, "invalid") + ErrMaxCapExceeded = errorsmod.Register(ModuleName, 2, "max cap exceeded") + ErrUnsupported = errorsmod.Register(ModuleName, 3, "unsupported") + ErrUnknown = errorsmod.Register(ModuleName, 4, "unknown") + ErrNoProposerChannelId = errorsmod.Register(ModuleName, 5, "no established meshsecurity channel") + ErrConsumerRewardDenomAlreadyRegistered = errorsmod.Register(ModuleName, 6, "consumer reward denom already registered") ) diff --git a/x/meshsecurity/types/expected_keepers.go b/x/meshsecurity/types/expected_keepers.go index 57d52a51..7be9a6e3 100644 --- a/x/meshsecurity/types/expected_keepers.go +++ b/x/meshsecurity/types/expected_keepers.go @@ -8,6 +8,12 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" ) type SDKBankKeeper interface { @@ -62,3 +68,27 @@ type WasmKeeper interface { Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) bool } + +// ChannelKeeper defines the expected IBC channel keeper +type ChannelKeeper interface { + GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) + GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) + SendPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + sourcePort string, + sourceChannel string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + data []byte, + ) (sequence uint64, err error) + WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error + ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error + GetChannelConnection(ctx sdk.Context, portID, channelID string) (string, ibcexported.ConnectionI, error) +} + +type ScopedKeeper interface { + GetCapability(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool) + AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool + ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error +} diff --git a/x/meshsecurity/types/genesis.pb.go b/x/meshsecurity/types/genesis.pb.go index 5575e806..f0eb82ba 100644 --- a/x/meshsecurity/types/genesis.pb.go +++ b/x/meshsecurity/types/genesis.pb.go @@ -5,21 +5,18 @@ package types import ( fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var ( - _ = proto.Marshal - _ = fmt.Errorf - _ = math.Inf -) +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. @@ -38,11 +35,9 @@ func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { return fileDescriptor_e38a457d5139d73a, []int{0} } - func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_GenesisState.Marshal(b, m, deterministic) @@ -55,15 +50,12 @@ func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } - func (m *GenesisState) XXX_Merge(src proto.Message) { xxx_messageInfo_GenesisState.Merge(m, src) } - func (m *GenesisState) XXX_Size() int { return m.Size() } - func (m *GenesisState) XXX_DiscardUnknown() { xxx_messageInfo_GenesisState.DiscardUnknown(m) } @@ -122,7 +114,6 @@ func (this *GenesisState) Equal(that interface{}) bool { } return true } - func (m *GenesisState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -167,7 +158,6 @@ func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } - func (m *GenesisState) Size() (n int) { if m == nil { return 0 @@ -182,11 +172,9 @@ func (m *GenesisState) Size() (n int) { func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } - func sozGenesis(x uint64) (n int) { return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } - func (m *GenesisState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -270,7 +258,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } - func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/meshsecurity/types/keys.go b/x/meshsecurity/types/keys.go index fa21f06c..1a95d227 100644 --- a/x/meshsecurity/types/keys.go +++ b/x/meshsecurity/types/keys.go @@ -4,12 +4,16 @@ import ( "encoding/binary" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" + "github.com/osmosis-labs/mesh-security-sdk/x/types" ) const ( // ModuleName defines the module name. ModuleName = "meshsecurity" + // ConsumerPortID is the default port id the consumer module binds to + ConsumerPortID = "consumer" + // StoreKey defines the primary module store key. StoreKey = ModuleName @@ -30,29 +34,10 @@ var ( TotalDelegatedAmountKeyPrefix = []byte{0x3} SchedulerKeyPrefix = []byte{0x4} - PipedValsetPrefix = []byte{0x5} -) - -type PipedValsetOperation byte - -const ( - ValsetOperationUndefined PipedValsetOperation = iota - ValidatorBonded - ValidatorUnbonded - ValidatorJailed - ValidatorTombstoned - ValidatorUnjailed - ValidatorModified - ValidatorSlashed + PipedValsetPrefix = []byte{0x5} + ProviderChannelByteKey = []byte{0x6} ) -type SlashInfo struct { - InfractionHeight int64 - Power int64 - TotalSlashAmount string - SlashFraction string -} - // BuildMaxCapLimitKey build max cap limit store key func BuildMaxCapLimitKey(contractAddr sdk.AccAddress) []byte { return append(MaxCapLimitKeyPrefix, contractAddr.Bytes()...) @@ -90,13 +75,13 @@ func BuildSchedulerContractKey(tp SchedulerTaskType, blockHeight uint64, contrac } // BuildPipedValsetOpKey build store key for the temporary valset operation store -func BuildPipedValsetOpKey(op PipedValsetOperation, val sdk.ValAddress, slashInfo *SlashInfo) []byte { - if op == ValsetOperationUndefined { +func BuildPipedValsetOpKey(op types.PipedValsetOperation, val sdk.ValAddress, slashInfo *types.SlashInfo) []byte { + if op == types.PipedValsetOperation_UNSPECIFIED { panic("empty operation") } pn, an := len(PipedValsetPrefix), len(val) sn := 0 - if op == ValidatorSlashed { + if op == types.PipedValsetOperation_VALIDATOR_SLASHED { if slashInfo == nil { panic("slash info is nil") } @@ -106,7 +91,7 @@ func BuildPipedValsetOpKey(op PipedValsetOperation, val sdk.ValAddress, slashInf copy(r, PipedValsetPrefix) copy(r[pn:], address.MustLengthPrefix(val)) r[pn+an+1] = byte(op) - if op == ValidatorSlashed { + if op == types.PipedValsetOperation_VALIDATOR_SLASHED { b := make([]byte, 8) binary.BigEndian.PutUint64(b, uint64(slashInfo.InfractionHeight)) copy(r[pn+an+1+1:], b) @@ -119,3 +104,8 @@ func BuildPipedValsetOpKey(op PipedValsetOperation, val sdk.ValAddress, slashInf } return r } + +// ProviderChannelKey returns the key for storing channelID of the provider chain +func ProviderChannelKey() []byte { + return ProviderChannelByteKey +} diff --git a/x/meshsecurity/types/meshsecurity.pb.go b/x/meshsecurity/types/meshsecurity.pb.go index 91e1950b..6abc9723 100644 --- a/x/meshsecurity/types/meshsecurity.pb.go +++ b/x/meshsecurity/types/meshsecurity.pb.go @@ -5,22 +5,19 @@ package types import ( fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var ( - _ = proto.Marshal - _ = fmt.Errorf - _ = math.Inf -) +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. @@ -45,11 +42,9 @@ func (*VirtualStakingMaxCapInfo) ProtoMessage() {} func (*VirtualStakingMaxCapInfo) Descriptor() ([]byte, []int) { return fileDescriptor_53771980e3e4256c, []int{0} } - func (m *VirtualStakingMaxCapInfo) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *VirtualStakingMaxCapInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_VirtualStakingMaxCapInfo.Marshal(b, m, deterministic) @@ -62,15 +57,12 @@ func (m *VirtualStakingMaxCapInfo) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } - func (m *VirtualStakingMaxCapInfo) XXX_Merge(src proto.Message) { xxx_messageInfo_VirtualStakingMaxCapInfo.Merge(m, src) } - func (m *VirtualStakingMaxCapInfo) XXX_Size() int { return m.Size() } - func (m *VirtualStakingMaxCapInfo) XXX_DiscardUnknown() { xxx_messageInfo_VirtualStakingMaxCapInfo.DiscardUnknown(m) } @@ -95,11 +87,9 @@ func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { return fileDescriptor_53771980e3e4256c, []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) @@ -112,15 +102,12 @@ func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { 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) } @@ -196,7 +183,6 @@ func (this *VirtualStakingMaxCapInfo) Equal(that interface{}) bool { } return true } - func (this *Params) Equal(that interface{}) bool { if that == nil { return this == nil @@ -227,7 +213,6 @@ func (this *Params) Equal(that interface{}) bool { } return true } - func (m *VirtualStakingMaxCapInfo) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -332,7 +317,6 @@ func encodeVarintMeshsecurity(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } - func (m *VirtualStakingMaxCapInfo) Size() (n int) { if m == nil { return 0 @@ -370,11 +354,9 @@ func (m *Params) Size() (n int) { func sovMeshsecurity(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } - func sozMeshsecurity(x uint64) (n int) { return sovMeshsecurity(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } - func (m *VirtualStakingMaxCapInfo) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -523,7 +505,6 @@ func (m *VirtualStakingMaxCapInfo) Unmarshal(dAtA []byte) error { } return nil } - func (m *Params) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -645,7 +626,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } - func skipMeshsecurity(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/meshsecurity/types/params.go b/x/meshsecurity/types/params.go index 25c3a1a4..7835e6fb 100644 --- a/x/meshsecurity/types/params.go +++ b/x/meshsecurity/types/params.go @@ -3,6 +3,7 @@ package types import ( errorsmod "cosmossdk.io/errors" "cosmossdk.io/math" + "time" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -29,3 +30,9 @@ func (p Params) ValidateBasic() error { } return nil } + +// GetCCVTimeoutPeriod returns the timeout period for sent ccv related ibc packets +func (p Params) GetTimeoutPeriod() time.Duration { + // TODO: add TimeoutPeriod for params + return time.Duration(5) * time.Microsecond +} diff --git a/x/meshsecurity/types/query.pb.go b/x/meshsecurity/types/query.pb.go index c3287ff4..18bc2e46 100644 --- a/x/meshsecurity/types/query.pb.go +++ b/x/meshsecurity/types/query.pb.go @@ -6,10 +6,6 @@ package types import ( context "context" fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" @@ -19,14 +15,15 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var ( - _ = proto.Marshal - _ = fmt.Errorf - _ = math.Inf -) +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. @@ -47,11 +44,9 @@ func (*QueryVirtualStakingMaxCapLimitRequest) ProtoMessage() {} func (*QueryVirtualStakingMaxCapLimitRequest) Descriptor() ([]byte, []int) { return fileDescriptor_50c89ba006eed4fb, []int{0} } - func (m *QueryVirtualStakingMaxCapLimitRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *QueryVirtualStakingMaxCapLimitRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryVirtualStakingMaxCapLimitRequest.Marshal(b, m, deterministic) @@ -64,15 +59,12 @@ func (m *QueryVirtualStakingMaxCapLimitRequest) XXX_Marshal(b []byte, determinis return b[:n], nil } } - func (m *QueryVirtualStakingMaxCapLimitRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryVirtualStakingMaxCapLimitRequest.Merge(m, src) } - func (m *QueryVirtualStakingMaxCapLimitRequest) XXX_Size() int { return m.Size() } - func (m *QueryVirtualStakingMaxCapLimitRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryVirtualStakingMaxCapLimitRequest.DiscardUnknown(m) } @@ -94,11 +86,9 @@ func (*QueryVirtualStakingMaxCapLimitResponse) ProtoMessage() {} func (*QueryVirtualStakingMaxCapLimitResponse) Descriptor() ([]byte, []int) { return fileDescriptor_50c89ba006eed4fb, []int{1} } - func (m *QueryVirtualStakingMaxCapLimitResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *QueryVirtualStakingMaxCapLimitResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryVirtualStakingMaxCapLimitResponse.Marshal(b, m, deterministic) @@ -111,15 +101,12 @@ func (m *QueryVirtualStakingMaxCapLimitResponse) XXX_Marshal(b []byte, determini return b[:n], nil } } - func (m *QueryVirtualStakingMaxCapLimitResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryVirtualStakingMaxCapLimitResponse.Merge(m, src) } - func (m *QueryVirtualStakingMaxCapLimitResponse) XXX_Size() int { return m.Size() } - func (m *QueryVirtualStakingMaxCapLimitResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryVirtualStakingMaxCapLimitResponse.DiscardUnknown(m) } @@ -128,7 +115,8 @@ var xxx_messageInfo_QueryVirtualStakingMaxCapLimitResponse proto.InternalMessage // QueryVirtualStakingMaxCapLimitsRequest is the request type for the // Query/VirtualStakingMaxCapLimits RPC method -type QueryVirtualStakingMaxCapLimitsRequest struct{} +type QueryVirtualStakingMaxCapLimitsRequest struct { +} func (m *QueryVirtualStakingMaxCapLimitsRequest) Reset() { *m = QueryVirtualStakingMaxCapLimitsRequest{} @@ -138,11 +126,9 @@ func (*QueryVirtualStakingMaxCapLimitsRequest) ProtoMessage() {} func (*QueryVirtualStakingMaxCapLimitsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_50c89ba006eed4fb, []int{2} } - func (m *QueryVirtualStakingMaxCapLimitsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *QueryVirtualStakingMaxCapLimitsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryVirtualStakingMaxCapLimitsRequest.Marshal(b, m, deterministic) @@ -155,15 +141,12 @@ func (m *QueryVirtualStakingMaxCapLimitsRequest) XXX_Marshal(b []byte, determini return b[:n], nil } } - func (m *QueryVirtualStakingMaxCapLimitsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryVirtualStakingMaxCapLimitsRequest.Merge(m, src) } - func (m *QueryVirtualStakingMaxCapLimitsRequest) XXX_Size() int { return m.Size() } - func (m *QueryVirtualStakingMaxCapLimitsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryVirtualStakingMaxCapLimitsRequest.DiscardUnknown(m) } @@ -184,11 +167,9 @@ func (*QueryVirtualStakingMaxCapLimitsResponse) ProtoMessage() {} func (*QueryVirtualStakingMaxCapLimitsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_50c89ba006eed4fb, []int{3} } - func (m *QueryVirtualStakingMaxCapLimitsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *QueryVirtualStakingMaxCapLimitsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryVirtualStakingMaxCapLimitsResponse.Marshal(b, m, deterministic) @@ -201,15 +182,12 @@ func (m *QueryVirtualStakingMaxCapLimitsResponse) XXX_Marshal(b []byte, determin return b[:n], nil } } - func (m *QueryVirtualStakingMaxCapLimitsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryVirtualStakingMaxCapLimitsResponse.Merge(m, src) } - func (m *QueryVirtualStakingMaxCapLimitsResponse) XXX_Size() int { return m.Size() } - func (m *QueryVirtualStakingMaxCapLimitsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryVirtualStakingMaxCapLimitsResponse.DiscardUnknown(m) } @@ -218,7 +196,8 @@ var xxx_messageInfo_QueryVirtualStakingMaxCapLimitsResponse proto.InternalMessag // QueryParamsRequest is the request type for the // Query/Params RPC method -type QueryParamsRequest struct{} +type QueryParamsRequest struct { +} func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } @@ -226,11 +205,9 @@ func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_50c89ba006eed4fb, []int{4} } - func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) @@ -243,15 +220,12 @@ func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } - func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsRequest.Merge(m, src) } - func (m *QueryParamsRequest) XXX_Size() int { return m.Size() } - func (m *QueryParamsRequest) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) } @@ -270,11 +244,9 @@ func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_50c89ba006eed4fb, []int{5} } - func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) @@ -287,15 +259,12 @@ func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } - func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_QueryParamsResponse.Merge(m, src) } - func (m *QueryParamsResponse) XXX_Size() int { return m.Size() } - func (m *QueryParamsResponse) XXX_DiscardUnknown() { xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) } @@ -384,10 +353,8 @@ func (this *QueryVirtualStakingMaxCapLimitResponse) Equal(that interface{}) bool } // Reference imports to suppress errors if they are not otherwise used. -var ( - _ context.Context - _ grpc.ClientConn -) +var _ context.Context +var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -451,16 +418,15 @@ type QueryServer interface { } // UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct{} +type UnimplementedQueryServer struct { +} func (*UnimplementedQueryServer) VirtualStakingMaxCapLimit(ctx context.Context, req *QueryVirtualStakingMaxCapLimitRequest) (*QueryVirtualStakingMaxCapLimitResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method VirtualStakingMaxCapLimit not implemented") } - func (*UnimplementedQueryServer) VirtualStakingMaxCapLimits(ctx context.Context, req *QueryVirtualStakingMaxCapLimitsRequest) (*QueryVirtualStakingMaxCapLimitsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method VirtualStakingMaxCapLimits not implemented") } - func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } @@ -744,7 +710,6 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } - func (m *QueryVirtualStakingMaxCapLimitRequest) Size() (n int) { if m == nil { return 0 @@ -818,11 +783,9 @@ func (m *QueryParamsResponse) Size() (n int) { func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } - func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } - func (m *QueryVirtualStakingMaxCapLimitRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -905,7 +868,6 @@ func (m *QueryVirtualStakingMaxCapLimitRequest) Unmarshal(dAtA []byte) error { } return nil } - func (m *QueryVirtualStakingMaxCapLimitResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1022,7 +984,6 @@ func (m *QueryVirtualStakingMaxCapLimitResponse) Unmarshal(dAtA []byte) error { } return nil } - func (m *QueryVirtualStakingMaxCapLimitsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1073,7 +1034,6 @@ func (m *QueryVirtualStakingMaxCapLimitsRequest) Unmarshal(dAtA []byte) error { } return nil } - func (m *QueryVirtualStakingMaxCapLimitsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1158,7 +1118,6 @@ func (m *QueryVirtualStakingMaxCapLimitsResponse) Unmarshal(dAtA []byte) error { } return nil } - func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1209,7 +1168,6 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } - func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -1293,7 +1251,6 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } - func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/meshsecurity/types/query.pb.gw.go b/x/meshsecurity/types/query.pb.gw.go index 7922edbd..b00a85c2 100644 --- a/x/meshsecurity/types/query.pb.gw.go +++ b/x/meshsecurity/types/query.pb.gw.go @@ -25,15 +25,13 @@ import ( ) // Suppress "imported and not used" errors -var ( - _ codes.Code - _ io.Reader - _ status.Status - _ = runtime.String - _ = utilities.NewDoubleArray - _ = descriptor.ForMessage - _ = metadata.Join -) +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_VirtualStakingMaxCapLimit_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryVirtualStakingMaxCapLimitRequest @@ -59,6 +57,7 @@ func request_Query_VirtualStakingMaxCapLimit_0(ctx context.Context, marshaler ru msg, err := client.VirtualStakingMaxCapLimit(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err + } func local_request_Query_VirtualStakingMaxCapLimit_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -85,6 +84,7 @@ func local_request_Query_VirtualStakingMaxCapLimit_0(ctx context.Context, marsha msg, err := server.VirtualStakingMaxCapLimit(ctx, &protoReq) return msg, metadata, err + } func request_Query_VirtualStakingMaxCapLimits_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -93,6 +93,7 @@ func request_Query_VirtualStakingMaxCapLimits_0(ctx context.Context, marshaler r msg, err := client.VirtualStakingMaxCapLimits(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err + } func local_request_Query_VirtualStakingMaxCapLimits_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -101,6 +102,7 @@ func local_request_Query_VirtualStakingMaxCapLimits_0(ctx context.Context, marsh msg, err := server.VirtualStakingMaxCapLimits(ctx, &protoReq) return msg, metadata, err + } func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -109,6 +111,7 @@ func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, cl msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err + } func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { @@ -117,6 +120,7 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal msg, err := server.Params(ctx, &protoReq) return msg, metadata, err + } // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". @@ -124,6 +128,7 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + mux.Handle("GET", pattern_Query_VirtualStakingMaxCapLimit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -144,6 +149,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_VirtualStakingMaxCapLimit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) mux.Handle("GET", pattern_Query_VirtualStakingMaxCapLimits_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -166,6 +172,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_VirtualStakingMaxCapLimits_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -188,6 +195,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) return nil @@ -230,6 +238,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + mux.Handle("GET", pattern_Query_VirtualStakingMaxCapLimit_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -247,6 +256,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_VirtualStakingMaxCapLimit_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) mux.Handle("GET", pattern_Query_VirtualStakingMaxCapLimits_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -266,6 +276,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_VirtualStakingMaxCapLimits_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { @@ -285,6 +296,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) return nil diff --git a/x/meshsecurity/types/relay.go b/x/meshsecurity/types/relay.go new file mode 100644 index 00000000..2428f646 --- /dev/null +++ b/x/meshsecurity/types/relay.go @@ -0,0 +1,43 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/gogoproto/gogoproto" + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + host "github.com/cosmos/ibc-go/v7/modules/core/24-host" +) + +// SendIBCPacket sends an IBC packet with packetData +// over the source channelID and portID +func SendIBCPacket( + ctx sdk.Context, + scopedKeeper ScopedKeeper, + channelKeeper ChannelKeeper, + sourceChannelID string, + sourcePortID string, + packetData []byte, + timeoutPeriod time.Duration, +) error { + _, ok := channelKeeper.GetChannel(ctx, sourcePortID, sourceChannelID) + if !ok { + return errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "channel not found for channel ID: %s", sourceChannelID) + } + channelCap, ok := scopedKeeper.GetCapability(ctx, host.ChannelCapabilityPath(sourcePortID, sourceChannelID)) + if !ok { + return errorsmod.Wrap(channeltypes.ErrChannelCapabilityNotFound, "module does not own channel capability") + } + + _, err := channelKeeper.SendPacket(ctx, + channelCap, + sourcePortID, + sourceChannelID, + clienttypes.Height{}, // timeout height disabled + uint64(ctx.BlockTime().Add(timeoutPeriod).UnixNano()), // timeout timestamp + packetData, + ) + return err +} diff --git a/x/meshsecurity/types/scheduler.pb.go b/x/meshsecurity/types/scheduler.pb.go index 83d6f939..df8bee24 100644 --- a/x/meshsecurity/types/scheduler.pb.go +++ b/x/meshsecurity/types/scheduler.pb.go @@ -5,21 +5,18 @@ package types import ( fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var ( - _ = proto.Marshal - _ = fmt.Errorf - _ = math.Inf -) +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. @@ -27,6 +24,43 @@ var ( // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type ScheduledWork struct { + Repeat bool `protobuf:"varint,1,opt,name=repeat,proto3" json:"repeat,omitempty"` +} + +func (m *ScheduledWork) Reset() { *m = ScheduledWork{} } +func (m *ScheduledWork) String() string { return proto.CompactTextString(m) } +func (*ScheduledWork) ProtoMessage() {} +func (*ScheduledWork) Descriptor() ([]byte, []int) { + return fileDescriptor_de3814df630b6218, []int{0} +} +func (m *ScheduledWork) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ScheduledWork) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ScheduledWork.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 *ScheduledWork) XXX_Merge(src proto.Message) { + xxx_messageInfo_ScheduledWork.Merge(m, src) +} +func (m *ScheduledWork) XXX_Size() int { + return m.Size() +} +func (m *ScheduledWork) XXX_DiscardUnknown() { + xxx_messageInfo_ScheduledWork.DiscardUnknown(m) +} + +var xxx_messageInfo_ScheduledWork proto.InternalMessageInfo + // ValidatorAddress payload data to be used with the scheduler type ValidatorAddress struct { // Address is the ValAddress bech32 string @@ -37,13 +71,11 @@ func (m *ValidatorAddress) Reset() { *m = ValidatorAddress{} } func (m *ValidatorAddress) String() string { return proto.CompactTextString(m) } func (*ValidatorAddress) ProtoMessage() {} func (*ValidatorAddress) Descriptor() ([]byte, []int) { - return fileDescriptor_de3814df630b6218, []int{0} + return fileDescriptor_de3814df630b6218, []int{1} } - func (m *ValidatorAddress) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *ValidatorAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_ValidatorAddress.Marshal(b, m, deterministic) @@ -56,15 +88,12 @@ func (m *ValidatorAddress) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } - func (m *ValidatorAddress) XXX_Merge(src proto.Message) { xxx_messageInfo_ValidatorAddress.Merge(m, src) } - func (m *ValidatorAddress) XXX_Size() int { return m.Size() } - func (m *ValidatorAddress) XXX_DiscardUnknown() { xxx_messageInfo_ValidatorAddress.DiscardUnknown(m) } @@ -72,6 +101,7 @@ func (m *ValidatorAddress) XXX_DiscardUnknown() { var xxx_messageInfo_ValidatorAddress proto.InternalMessageInfo func init() { + proto.RegisterType((*ScheduledWork)(nil), "osmosis.meshsecurity.v1beta1.ScheduledWork") proto.RegisterType((*ValidatorAddress)(nil), "osmosis.meshsecurity.v1beta1.ValidatorAddress") } @@ -80,22 +110,57 @@ func init() { } var fileDescriptor_de3814df630b6218 = []byte{ - // 236 bytes of a gzipped FileDescriptorProto + // 264 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0xc9, 0x2f, 0xce, 0xcd, 0x2f, 0xce, 0x2c, 0xd6, 0xcf, 0x4d, 0x2d, 0xce, 0x28, 0x4e, 0x4d, 0x2e, 0x2d, 0xca, 0x2c, 0xa9, 0xd4, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x4e, 0xce, 0x48, 0x4d, 0x29, 0xcd, 0x49, 0x2d, 0xd2, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x81, 0xaa, 0xd6, 0x43, 0x56, 0xad, 0x07, 0x55, 0x2d, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xa8, 0x0f, 0x62, 0x41, 0xf4, 0x48, - 0x49, 0x26, 0x83, 0x35, 0xc5, 0x43, 0x24, 0x20, 0x1c, 0x88, 0x94, 0x92, 0x1b, 0x97, 0x40, 0x58, - 0x62, 0x4e, 0x66, 0x4a, 0x62, 0x49, 0x7e, 0x91, 0x63, 0x4a, 0x4a, 0x51, 0x6a, 0x71, 0xb1, 0x90, - 0x11, 0x17, 0x7b, 0x22, 0x84, 0x29, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xe9, 0x24, 0x71, 0x69, 0x8b, - 0xae, 0x08, 0x54, 0x1b, 0x54, 0x51, 0x70, 0x49, 0x51, 0x66, 0x5e, 0x7a, 0x10, 0x4c, 0xa1, 0x53, - 0xc2, 0x89, 0x87, 0x72, 0x0c, 0x2b, 0x1e, 0xc9, 0x31, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, - 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, - 0xb1, 0x1c, 0x43, 0x94, 0x5d, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, - 0xd4, 0x0f, 0xba, 0x39, 0x89, 0x49, 0x10, 0x6f, 0xeb, 0xc2, 0x7c, 0xa2, 0x5b, 0x9c, 0x92, 0xad, - 0x5f, 0x81, 0x1a, 0x14, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x07, 0x1b, 0x03, 0x02, - 0x00, 0x00, 0xff, 0xff, 0xb5, 0xc5, 0xe7, 0x2e, 0x2f, 0x01, 0x00, 0x00, + 0x49, 0x26, 0x83, 0x35, 0xc5, 0x43, 0x24, 0x20, 0x1c, 0x88, 0x94, 0x92, 0x3a, 0x17, 0x6f, 0x30, + 0xd4, 0x86, 0x94, 0xf0, 0xfc, 0xa2, 0x6c, 0x21, 0x31, 0x2e, 0xb6, 0xa2, 0xd4, 0x82, 0xd4, 0xc4, + 0x12, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x8e, 0x20, 0x28, 0x4f, 0xc9, 0x8d, 0x4b, 0x20, 0x2c, 0x31, + 0x27, 0x33, 0x25, 0xb1, 0x24, 0xbf, 0xc8, 0x31, 0x25, 0xa5, 0x28, 0xb5, 0xb8, 0x58, 0xc8, 0x88, + 0x8b, 0x3d, 0x11, 0xc2, 0x04, 0x2b, 0xe6, 0x74, 0x92, 0xb8, 0xb4, 0x45, 0x57, 0x04, 0x6a, 0x3e, + 0x54, 0x51, 0x70, 0x49, 0x51, 0x66, 0x5e, 0x7a, 0x10, 0x4c, 0xa1, 0x53, 0xc2, 0x89, 0x87, 0x72, + 0x0c, 0x2b, 0x1e, 0xc9, 0x31, 0x9c, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, + 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, + 0x5d, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xd4, 0xb3, 0xba, 0x39, + 0x89, 0x49, 0x90, 0xf0, 0xd1, 0x85, 0x79, 0x59, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0x35, 0xcc, + 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x3e, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, + 0xf5, 0x6f, 0x77, 0x0e, 0x58, 0x01, 0x00, 0x00, +} + +func (m *ScheduledWork) 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 *ScheduledWork) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ScheduledWork) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Repeat { + i-- + if m.Repeat { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil } func (m *ValidatorAddress) Marshal() (dAtA []byte, err error) { @@ -139,6 +204,17 @@ func encodeVarintScheduler(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *ScheduledWork) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Repeat { + n += 2 + } + return n +} func (m *ValidatorAddress) Size() (n int) { if m == nil { @@ -156,11 +232,79 @@ func (m *ValidatorAddress) Size() (n int) { func sovScheduler(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } - func sozScheduler(x uint64) (n int) { return sovScheduler(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *ScheduledWork) 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 ErrIntOverflowScheduler + } + 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: ScheduledWork: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ScheduledWork: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Repeat", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowScheduler + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Repeat = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipScheduler(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthScheduler + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ValidatorAddress) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -243,7 +387,6 @@ func (m *ValidatorAddress) Unmarshal(dAtA []byte) error { } return nil } - func skipScheduler(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/meshsecurity/types/tx.pb.go b/x/meshsecurity/types/tx.pb.go index 7147eeff..1372d1b9 100644 --- a/x/meshsecurity/types/tx.pb.go +++ b/x/meshsecurity/types/tx.pb.go @@ -6,10 +6,6 @@ package types import ( context "context" fmt "fmt" - io "io" - math "math" - math_bits "math/bits" - types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" @@ -19,14 +15,15 @@ import ( grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. -var ( - _ = proto.Marshal - _ = fmt.Errorf - _ = math.Inf -) +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. @@ -53,11 +50,9 @@ func (*MsgSetVirtualStakingMaxCap) ProtoMessage() {} func (*MsgSetVirtualStakingMaxCap) Descriptor() ([]byte, []int) { return fileDescriptor_ca993316ec9770c4, []int{0} } - func (m *MsgSetVirtualStakingMaxCap) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *MsgSetVirtualStakingMaxCap) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgSetVirtualStakingMaxCap.Marshal(b, m, deterministic) @@ -70,15 +65,12 @@ func (m *MsgSetVirtualStakingMaxCap) XXX_Marshal(b []byte, deterministic bool) ( return b[:n], nil } } - func (m *MsgSetVirtualStakingMaxCap) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgSetVirtualStakingMaxCap.Merge(m, src) } - func (m *MsgSetVirtualStakingMaxCap) XXX_Size() int { return m.Size() } - func (m *MsgSetVirtualStakingMaxCap) XXX_DiscardUnknown() { xxx_messageInfo_MsgSetVirtualStakingMaxCap.DiscardUnknown(m) } @@ -86,7 +78,8 @@ func (m *MsgSetVirtualStakingMaxCap) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetVirtualStakingMaxCap proto.InternalMessageInfo // MsgSetVirtualStakingMaxCap returns result data. -type MsgSetVirtualStakingMaxCapResponse struct{} +type MsgSetVirtualStakingMaxCapResponse struct { +} func (m *MsgSetVirtualStakingMaxCapResponse) Reset() { *m = MsgSetVirtualStakingMaxCapResponse{} } func (m *MsgSetVirtualStakingMaxCapResponse) String() string { return proto.CompactTextString(m) } @@ -94,11 +87,9 @@ func (*MsgSetVirtualStakingMaxCapResponse) ProtoMessage() {} func (*MsgSetVirtualStakingMaxCapResponse) Descriptor() ([]byte, []int) { return fileDescriptor_ca993316ec9770c4, []int{1} } - func (m *MsgSetVirtualStakingMaxCapResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } - func (m *MsgSetVirtualStakingMaxCapResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { return xxx_messageInfo_MsgSetVirtualStakingMaxCapResponse.Marshal(b, m, deterministic) @@ -111,15 +102,12 @@ func (m *MsgSetVirtualStakingMaxCapResponse) XXX_Marshal(b []byte, deterministic return b[:n], nil } } - func (m *MsgSetVirtualStakingMaxCapResponse) XXX_Merge(src proto.Message) { xxx_messageInfo_MsgSetVirtualStakingMaxCapResponse.Merge(m, src) } - func (m *MsgSetVirtualStakingMaxCapResponse) XXX_Size() int { return m.Size() } - func (m *MsgSetVirtualStakingMaxCapResponse) XXX_DiscardUnknown() { xxx_messageInfo_MsgSetVirtualStakingMaxCapResponse.DiscardUnknown(m) } @@ -164,10 +152,8 @@ var fileDescriptor_ca993316ec9770c4 = []byte{ } // Reference imports to suppress errors if they are not otherwise used. -var ( - _ context.Context - _ grpc.ClientConn -) +var _ context.Context +var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. @@ -207,7 +193,8 @@ type MsgServer interface { } // UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct{} +type UnimplementedMsgServer struct { +} func (*UnimplementedMsgServer) SetVirtualStakingMaxCap(ctx context.Context, req *MsgSetVirtualStakingMaxCap) (*MsgSetVirtualStakingMaxCapResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetVirtualStakingMaxCap not implemented") @@ -329,7 +316,6 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } - func (m *MsgSetVirtualStakingMaxCap) Size() (n int) { if m == nil { return 0 @@ -361,11 +347,9 @@ func (m *MsgSetVirtualStakingMaxCapResponse) Size() (n int) { func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } - func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } - func (m *MsgSetVirtualStakingMaxCap) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -513,7 +497,6 @@ func (m *MsgSetVirtualStakingMaxCap) Unmarshal(dAtA []byte) error { } return nil } - func (m *MsgSetVirtualStakingMaxCapResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -564,7 +547,6 @@ func (m *MsgSetVirtualStakingMaxCapResponse) Unmarshal(dAtA []byte) error { } return nil } - func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/provider/client/cli/gov_tx.go b/x/provider/client/cli/gov_tx.go new file mode 100644 index 00000000..22186946 --- /dev/null +++ b/x/provider/client/cli/gov_tx.go @@ -0,0 +1,144 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/pkg/errors" + "github.com/spf13/cobra" + + errorsmod "cosmossdk.io/errors" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + "github.com/cosmos/cosmos-sdk/version" + "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" +) + +// DefaultGovAuthority is set to the gov module address. +// Extension point for chains to overwrite the default +var DefaultGovAuthority = sdk.AccAddress(address.Module("gov")) + +func SubmitProposalCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "submit-proposal", + Short: "Submit a mesh security proposal.", + SilenceUsage: true, + } + cmd.AddCommand( + ProposalSetVirtualStakingMaxCapCmd(), + ) + return cmd +} + +func ProposalSetVirtualStakingMaxCapCmd() *cobra.Command { + bech32Prefix := sdk.GetConfig().GetBech32AccountAddrPrefix() + cmd := &cobra.Command{ + Use: "set-virtual-staking-max-cap [contract_addr_bech32] [max_cap] --title [text] --summary [text] --authority [address]", + Short: "Submit a set virtual staking max cap proposal", + Args: cobra.ExactArgs(2), + Long: strings.TrimSpace( + fmt.Sprintf(`Submit a proposal to set virtual staking maximum cap limit to the given contract. + +Example: +$ %s tx meshsecurity submit-proposal set-virtual-staking-max-cap %s1l94ptufswr6v7qntax4m7nvn3jgf6k4gn2rknq 100stake --title "a title" --summary "a summary" --authority %s +`, version.AppName, bech32Prefix, DefaultGovAuthority.String())), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, proposalTitle, summary, metadata, deposit, err := getProposalInfo(cmd) + if err != nil { + return err + } + authority, err := cmd.Flags().GetString(flagAuthority) + if err != nil { + return fmt.Errorf("authority: %s", err) + } + + if len(authority) == 0 { + return errors.New("authority address is required") + } + + src, err := parseSetVirtualStakingMaxCapArgs(args, authority) + if err != nil { + return err + } + + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), metadata, proposalTitle, summary) + if err != nil { + return err + } + if err = proposalMsg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg) + }, + SilenceUsage: true, + } + + // proposal flags + addCommonProposalFlags(cmd) + return cmd +} + +func parseSetVirtualStakingMaxCapArgs(args []string, authority string) (types.MsgSetVirtualStakingMaxCap, error) { + maxCap, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return types.MsgSetVirtualStakingMaxCap{}, errorsmod.Wrap(err, "max cap") + } + + msg := types.MsgSetVirtualStakingMaxCap{ + Authority: authority, + Contract: args[0], + MaxCap: maxCap, + } + return msg, nil +} + +func addCommonProposalFlags(cmd *cobra.Command) { + flags.AddTxFlagsToCmd(cmd) + cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") + cmd.Flags().String(cli.FlagSummary, "", "Summary of proposal") + cmd.Flags().String(cli.FlagMetadata, "", "Metadata of proposal") + cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") + cmd.Flags().String(flagAuthority, DefaultGovAuthority.String(), "The address of the governance account. Default is the sdk gov module account") +} + +func getProposalInfo(cmd *cobra.Command) (client.Context, string, string, string, sdk.Coins, error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return client.Context{}, "", "", "", nil, err + } + + proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle) + if err != nil { + return clientCtx, proposalTitle, "", "", nil, err + } + + summary, err := cmd.Flags().GetString(cli.FlagSummary) + if err != nil { + return client.Context{}, proposalTitle, summary, "", nil, err + } + + metadata, err := cmd.Flags().GetString(cli.FlagMetadata) + if err != nil { + return client.Context{}, proposalTitle, summary, metadata, nil, err + } + + depositArg, err := cmd.Flags().GetString(cli.FlagDeposit) + if err != nil { + return client.Context{}, proposalTitle, summary, metadata, nil, err + } + + deposit, err := sdk.ParseCoinsNormalized(depositArg) + if err != nil { + return client.Context{}, proposalTitle, summary, metadata, deposit, err + } + + return clientCtx, proposalTitle, summary, metadata, deposit, nil +} diff --git a/x/provider/client/cli/query.go b/x/provider/client/cli/query.go new file mode 100644 index 00000000..285789a8 --- /dev/null +++ b/x/provider/client/cli/query.go @@ -0,0 +1,65 @@ +package cli + +import ( + "fmt" + "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/version" + + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" +) + +func GetQueryCmd() *cobra.Command { + queryCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Querying commands for the mesh security module", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + SilenceUsage: true, + } + queryCmd.AddCommand( + GetCmdQueryParams(), + ) + return queryCmd +} + +// GetCmdQueryParams implements the params query command. +func GetCmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Args: cobra.NoArgs, + Short: "Query the current mesh-security parameters information", + Long: strings.TrimSpace( + fmt.Sprintf(`Query values set as mesh-security parameters. + +Example: +$ %s query meshsecurity params +`, + version.AppName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.Params(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(&res.Params) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/provider/client/cli/tx.go b/x/provider/client/cli/tx.go new file mode 100644 index 00000000..17525d88 --- /dev/null +++ b/x/provider/client/cli/tx.go @@ -0,0 +1,27 @@ +package cli + +import ( + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" +) + +const flagAuthority = "authority" + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Mesh security transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + SilenceUsage: true, + } + txCmd.AddCommand( + SubmitProposalCmd(), + ) + return txCmd +} diff --git a/x/provider/ibc_module.go b/x/provider/ibc_module.go new file mode 100644 index 00000000..5831716a --- /dev/null +++ b/x/provider/ibc_module.go @@ -0,0 +1,230 @@ +package provider + +import ( + "fmt" + // "strconv" + + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + // transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + + "github.com/osmosis-labs/mesh-security-sdk/x/provider/keeper" + types "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" +) + +// OnChanOpenInit implements the IBCModule interface +func (am AppModule) OnChanOpenInit( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID string, + channelID string, + channelCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + version string, +) (string, error) { + return version, errorsmod.Wrap(cptypes.ErrInvalidChannelFlow, "channel handshake must be initiated by consumer chain") +} + +// OnChanOpenTry implements the IBCModule interface + +func (am AppModule) OnChanOpenTry( + ctx sdk.Context, + order channeltypes.Order, + connectionHops []string, + portID, + channelID string, + chanCap *capabilitytypes.Capability, + counterparty channeltypes.Counterparty, + counterpartyVersion string, +) (metadata string, err error) { + if counterparty.PortId != cptypes.ConsumerPortID { + return "", errorsmod.Wrapf(porttypes.ErrInvalidPort, + "invalid counterparty port: %s, expected %s", counterparty.PortId, cptypes.ConsumerPortID) + } + + // ensure the counter party version matches the expected version + if counterpartyVersion != cptypes.Version { + return "", errorsmod.Wrapf( + cptypes.ErrInvalidVersion, "invalid counterparty version: got: %s, expected %s", + counterpartyVersion, cptypes.Version) + } + + // Claim channel capability + if err := am.k.ClaimCapability( + ctx, chanCap, host.ChannelCapabilityPath(portID, channelID), + ); err != nil { + return "", err + } + + if err := am.k.VerifyConsumerChain( + ctx, channelID, connectionHops, + ); err != nil { + return "", err + } + // TODO: ConsumerRewards + return "", nil +} + +// OnChanOpenAck implements the IBCModule interface +func (am AppModule) OnChanOpenAck( + ctx sdk.Context, + portID, + channelID string, + _ string, // Counter party channel ID is unused per spec + counterpartyMetadata string, +) error { + return errorsmod.Wrap(cptypes.ErrInvalidChannelFlow, "channel handshake must be initiated by consumer chain") +} + +// OnChanOpenConfirm implements the IBCModule interface +func (am AppModule) OnChanOpenConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + err := am.k.SetConsumerChain(ctx, channelID) + if err != nil { + return err + } + return nil +} + +// OnChanCloseInit implements the IBCModule interface +func (am AppModule) OnChanCloseInit( + ctx sdk.Context, + portID, + channelID string, +) error { + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "user cannot close channel") +} + +// OnChanCloseConfirm implements the IBCModule interface +func (am AppModule) OnChanCloseConfirm( + ctx sdk.Context, + portID, + channelID string, +) error { + return nil +} + +// OnRecvPacket implements the IBCModule interface. A successful acknowledgement +// is returned if the packet data is successfully decoded and the receive application +// logic returns without error. +func (am AppModule) OnRecvPacket( + ctx sdk.Context, + packet channeltypes.Packet, + _ sdk.AccAddress, +) ibcexported.Acknowledgement { + logger := keeper.ModuleLogger(ctx) + ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) + + var ackErr error + _, err := UnmarshalConsumerPacket(packet) + if err != nil { + ackErr = errorsmod.Wrapf(sdkerrors.ErrInvalidType, "cannot unmarshal ConsumerPacket data") + logger.Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence)) + ack = channeltypes.NewErrorAcknowledgement(ackErr) + } + + eventAttributes := []sdk.Attribute{ + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + } + + // only attempt the application logic if the packet data + // was successfully decoded + if ack.Success() { + } + + eventAttributes = append(eventAttributes, sdk.NewAttribute(cptypes.AttributeKeyAckSuccess, fmt.Sprintf("%t", ack.Success()))) + if ackErr != nil { + eventAttributes = append(eventAttributes, sdk.NewAttribute(cptypes.AttributeKeyAckError, ackErr.Error())) + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + cptypes.EventTypePacket, + eventAttributes..., + ), + ) + + // NOTE: acknowledgement will be written synchronously during IBC handler execution. + return ack +} + +// OnAcknowledgementPacket implements the IBCModule interface +func (am AppModule) OnAcknowledgementPacket( + ctx sdk.Context, + packet channeltypes.Packet, + acknowledgement []byte, + _ sdk.AccAddress, +) error { + var ack channeltypes.Acknowledgement + if err := types.ModuleCdc.UnmarshalJSON(acknowledgement, &ack); err != nil { + return errorsmod.Wrapf(sdkerrors.ErrUnknownRequest, "cannot unmarshal provider packet acknowledgement: %v", err) + } + + if err := am.k.OnAcknowledgementPacket(ctx, packet, ack); err != nil { + return err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + cptypes.EventTypePacket, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(cptypes.AttributeKeyAck, ack.String()), + ), + ) + + switch resp := ack.Response.(type) { + case *channeltypes.Acknowledgement_Result: + ctx.EventManager().EmitEvent( + sdk.NewEvent( + cptypes.EventTypePacket, + sdk.NewAttribute(cptypes.AttributeKeyAckSuccess, string(resp.Result)), + ), + ) + case *channeltypes.Acknowledgement_Error: + ctx.EventManager().EmitEvent( + sdk.NewEvent( + cptypes.EventTypePacket, + sdk.NewAttribute(cptypes.AttributeKeyAckError, resp.Error), + ), + ) + } + + return nil +} + +// OnTimeoutPacket implements the IBCModule interface +func (am AppModule) OnTimeoutPacket( + ctx sdk.Context, + packet channeltypes.Packet, + _ sdk.AccAddress, +) error { + if err := am.k.OnTimeoutPacket(ctx, packet); err != nil { + return err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + cptypes.EventTypeTimeout, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + ), + ) + + return nil +} + +func UnmarshalConsumerPacket(packet channeltypes.Packet) (consumerPacket cptypes.ConsumerPacketData, err error) { + return cptypes.UnmarshalConsumerPacketData(packet.GetData()) +} diff --git a/x/provider/keeper/genesis.go b/x/provider/keeper/genesis.go new file mode 100644 index 00000000..d7e1391c --- /dev/null +++ b/x/provider/keeper/genesis.go @@ -0,0 +1,18 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" +) + +func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { + if err := k.SetParams(ctx, data.Params); err != nil { + panic(err) + } +} + +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + params := k.GetParams(ctx) + return types.NewGenesisState(params) +} diff --git a/x/provider/keeper/keeper.go b/x/provider/keeper/keeper.go new file mode 100644 index 00000000..5d10068f --- /dev/null +++ b/x/provider/keeper/keeper.go @@ -0,0 +1,251 @@ +package keeper + +import ( + "encoding/binary" + "fmt" + + "github.com/cometbft/cometbft/libs/log" + + errorsmod "cosmossdk.io/errors" + // "cosmossdk.io/math" + + "github.com/cosmos/cosmos-sdk/codec" + // "github.com/cosmos/cosmos-sdk/store/prefix" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + // sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + // host "github.com/cosmos/ibc-go/v7/modules/core/24-host" + ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + + ctypes "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" + "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" +) + +// Option is an extension point to instantiate keeper with non default values +type Option interface { + apply(*Keeper) +} + +type Keeper struct { + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + cdc codec.Codec + bank types.BankKeeper + Staking types.StakingKeeper + wasm types.WasmKeeper + + scopedKeeper types.ScopedKeeper + channelKeeper types.ChannelKeeper + connectionKeeper types.ConnectionKeeper + clientKeeper types.ClientKeeper + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string +} + +// NewKeeper constructor with vanilla sdk keepers +func NewKeeper( + cdc codec.Codec, + storeKey storetypes.StoreKey, + memoryStoreKey storetypes.StoreKey, + bank types.BankKeeper, + staking types.StakingKeeper, + wasm types.WasmKeeper, + scopedKeeper types.ScopedKeeper, + channelKeeper types.ChannelKeeper, + authority string, + opts ...Option, +) *Keeper { + k := &Keeper{ + storeKey: storeKey, + memKey: memoryStoreKey, + cdc: cdc, + bank: bank, + Staking: staking, + wasm: wasm, + scopedKeeper: scopedKeeper, + channelKeeper: channelKeeper, + authority: authority, + } + for _, o := range opts { + o.apply(k) + } + + return k +} + +// ModuleLogger returns logger with module attribute +func ModuleLogger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +// SetConsumerChain is called by OnChanOpenConfirm. +func (k Keeper) SetConsumerChain(ctx sdk.Context, channelID string) error { + channel, ok := k.channelKeeper.GetChannel(ctx, cptypes.ProviderPortID, channelID) + if !ok { + return errorsmod.Wrapf(channeltypes.ErrChannelNotFound, "channel not found for channel ID: %s", channelID) + } + if len(channel.ConnectionHops) != 1 { + return errorsmod.Wrap(channeltypes.ErrTooManyConnectionHops, "must have direct connection to consumer chain") + } + connectionID := channel.ConnectionHops[0] + clientID, tmClient, err := k.getUnderlyingClient(ctx, connectionID) + if err != nil { + return err + } + // Verify that there isn't already a CCV channel for the consumer chain + chainID := tmClient.ChainId + if prevChannelID, ok := k.GetChainToChannel(ctx, chainID); ok { + return errorsmod.Wrapf(cptypes.ErrDuplicateChannel, "CCV channel with ID: %s already created for consumer chain %s", prevChannelID, chainID) + } + + // the CCV channel is established: + // - set channel mappings + k.SetChainToChannel(ctx, chainID, channelID) + k.SetChannelToChain(ctx, channelID, chainID) + // - set current block height for the consumer chain initialization + k.SetInitChainHeight(ctx, chainID, uint64(ctx.BlockHeight())) + // - remove init timeout timestamp + k.DeleteInitTimeoutTimestamp(ctx, chainID) + + // emit event on successful addition + ctx.EventManager().EmitEvent( + sdk.NewEvent( + cptypes.EventTypeChannelEstablished, + sdk.NewAttribute(sdk.AttributeKeyModule, ctypes.ModuleName), + sdk.NewAttribute(cptypes.AttributeChainID, chainID), + sdk.NewAttribute(conntypes.AttributeKeyClientID, clientID), + sdk.NewAttribute(channeltypes.AttributeKeyChannelID, channelID), + sdk.NewAttribute(conntypes.AttributeKeyConnectionID, connectionID), + ), + ) + return nil +} + +// Retrieves the underlying client state corresponding to a connection ID. +func (k Keeper) getUnderlyingClient(ctx sdk.Context, connectionID string) ( + clientID string, tmClient *ibctmtypes.ClientState, err error, +) { + conn, ok := k.connectionKeeper.GetConnection(ctx, connectionID) + if !ok { + return "", nil, errorsmod.Wrapf(conntypes.ErrConnectionNotFound, + "connection not found for connection ID: %s", connectionID) + } + clientID = conn.ClientId + clientState, ok := k.clientKeeper.GetClientState(ctx, clientID) + if !ok { + return "", nil, errorsmod.Wrapf(clienttypes.ErrClientNotFound, + "client not found for client ID: %s", conn.ClientId) + } + tmClient, ok = clientState.(*ibctmtypes.ClientState) + if !ok { + return "", nil, errorsmod.Wrapf(clienttypes.ErrInvalidClientType, + "invalid client type. expected %s, got %s", ibchost.Tendermint, clientState.ClientType()) + } + return clientID, tmClient, nil +} + +func (k Keeper) GetChainToChannel(ctx sdk.Context, chainID string) (string, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ChainToChannelKey(chainID)) + if bz == nil { + return "", false + } + return string(bz), true +} + +func (k Keeper) SetChainToChannel(ctx sdk.Context, chainID, channelID string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.ChainToChannelKey(chainID), []byte(channelID)) +} + +func (k Keeper) SetChannelToChain(ctx sdk.Context, channelID, chainID string) { + store := ctx.KVStore(k.storeKey) + store.Set(types.ChannelToChainKey(channelID), []byte(chainID)) +} + +func (k Keeper) SetInitChainHeight(ctx sdk.Context, chainID string, height uint64) { + store := ctx.KVStore(k.storeKey) + heightBytes := make([]byte, 8) + binary.BigEndian.PutUint64(heightBytes, height) + + store.Set(types.InitChainHeightKey(chainID), heightBytes) +} + +func (k Keeper) DeleteInitTimeoutTimestamp(ctx sdk.Context, chainID string) { + store := ctx.KVStore(k.storeKey) + store.Delete(types.InitTimeoutTimestampKey(chainID)) +} + +func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error { + return k.scopedKeeper.ClaimCapability(ctx, cap, name) +} + +func (k Keeper) VerifyConsumerChain(ctx sdk.Context, channelID string, connectionHops []string) error { + if len(connectionHops) != 1 { + return errorsmod.Wrap(channeltypes.ErrTooManyConnectionHops, "must have direct connection to provider chain") + } + connectionID := connectionHops[0] + clientID, tmClient, err := k.getUnderlyingClient(ctx, connectionID) + if err != nil { + return err + } + ccvClientId, found := k.GetConsumerClientId(ctx, tmClient.ChainId) + if !found { + return errorsmod.Wrapf(cptypes.ErrClientNotFound, "cannot find client for consumer chain %s", tmClient.ChainId) + } + if ccvClientId != clientID { + return errorsmod.Wrapf(types.ErrInvalidConsumerClient, "CCV channel must be built on top of CCV client. expected %s, got %s", ccvClientId, clientID) + } + + // Verify that there isn't already a CCV channel for the consumer chain + if prevChannel, ok := k.GetChainToChannel(ctx, tmClient.ChainId); ok { + return errorsmod.Wrapf(cptypes.ErrDuplicateChannel, "CCV channel with ID: %s already created for consumer chain %s", prevChannel, tmClient.ChainId) + } + return nil +} + +func (k Keeper) GetConsumerClientId(ctx sdk.Context, chainID string) (string, bool) { + store := ctx.KVStore(k.storeKey) + clientIdBytes := store.Get(types.ChainToClientKey(chainID)) + if clientIdBytes == nil { + return "", false + } + return string(clientIdBytes), true +} + +func (k Keeper) GetChannelToChain(ctx sdk.Context, channelID string) (string, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.ChannelToChainKey(channelID)) + if bz == nil { + return "", false + } + return string(bz), true +} + +func (k Keeper) SetConsumerCommissionRate( + ctx sdk.Context, + chainID string, + providerAddr types.ProviderConsAddress, + commissionRate sdk.Dec, +) error { + store := ctx.KVStore(k.storeKey) + bz, err := commissionRate.Marshal() + if err != nil { + err = fmt.Errorf("consumer commission rate marshalling failed: %s", err) + ModuleLogger(ctx).Error(err.Error()) + return err + } + + store.Set(types.ConsumerCommissionRateKey(chainID, providerAddr), bz) + return nil +} diff --git a/x/provider/keeper/msg_server.go b/x/provider/keeper/msg_server.go new file mode 100644 index 00000000..42afe6ec --- /dev/null +++ b/x/provider/keeper/msg_server.go @@ -0,0 +1,34 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" +) + +type msgServer struct { + *Keeper +} + +func NewMsgServer(keeper *Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.MsgSetConsumerCommissionRate) (*types.MsgSetConsumerCommissionRateResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + // TODO: Handle set comissionRate + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.EventTypeSetConsumerCommissionRate, + sdk.NewAttribute(types.AttributeConsumerChainID, msg.ChainId), + sdk.NewAttribute(types.AttributeProviderValidatorAddress, msg.ProviderAddr), + sdk.NewAttribute(types.AttributeConsumerCommissionRate, msg.Rate.String()), + ), + }) + + return &types.MsgSetConsumerCommissionRateResponse{}, nil +} diff --git a/x/provider/keeper/params.go b/x/provider/keeper/params.go new file mode 100644 index 00000000..c4949cb9 --- /dev/null +++ b/x/provider/keeper/params.go @@ -0,0 +1,30 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" +) + +// SetParams sets the module's parameters. +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) error { + store := ctx.KVStore(k.storeKey) + bz, err := k.cdc.Marshal(¶ms) + if err != nil { + return err + } + store.Set(types.ParamsKey, bz) + + return nil +} + +// GetParams gets the module's parameters. +func (k Keeper) GetParams(clientCtx sdk.Context) (params types.Params) { + store := clientCtx.KVStore(k.storeKey) + bz := store.Get(types.ParamsKey) + if bz == nil { + return params + } + + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} diff --git a/x/provider/keeper/querier.go b/x/provider/keeper/querier.go new file mode 100644 index 00000000..0120562d --- /dev/null +++ b/x/provider/keeper/querier.go @@ -0,0 +1,28 @@ +package keeper + +import ( + "context" + + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" +) + +var _ types.QueryServer = &querier{} + +type querier struct { + cdc codec.Codec + k *Keeper +} + +// NewQuerier constructor +func NewQuerier(cdc codec.Codec, k *Keeper) *querier { + return &querier{cdc: cdc, k: k} +} + +// Params implements the gRPC service handler for querying the mesh-security parameters. +func (q querier) Params(ctx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + params := q.k.GetParams(sdk.UnwrapSDKContext(ctx)) + return &types.QueryParamsResponse{Params: params}, nil +} diff --git a/x/provider/keeper/relay.go b/x/provider/keeper/relay.go new file mode 100644 index 00000000..f6732a37 --- /dev/null +++ b/x/provider/keeper/relay.go @@ -0,0 +1,60 @@ +package keeper + +import ( + "fmt" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" +) + +func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet) error { + chainID, found := k.GetChannelToChain(ctx, packet.SourceChannel) + if !found { + ModuleLogger(ctx).Error("packet timeout, unknown channel:", "channelID", packet.SourceChannel) + // abort transaction + return errorsmod.Wrap( + channeltypes.ErrInvalidChannelState, + packet.SourceChannel, + ) + } + ModuleLogger(ctx).Info("packet timeout, removing the consumer:", "chainID", chainID) + // stop consumer chain and release unbondings + return k.StopConsumerChain(ctx, chainID, false) +} + +func (k Keeper) StopConsumerChain(ctx sdk.Context, chainID string, closeChan bool) (err error) { + // check that a client for chainID exists + if _, found := k.GetConsumerClientId(ctx, chainID); !found { + return errorsmod.Wrap(types.ErrConsumerChainNotFound, + fmt.Sprintf("cannot stop non-existent consumer chain: %s", chainID)) + } + + // TODO: Stop consumerchain + + ModuleLogger(ctx).Info("consumer chain removed from provider", "chainID", chainID) + + return nil +} + +// OnAcknowledgementPacket handles acknowledgments for sent VSC packets +func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, ack channeltypes.Acknowledgement) error { + if err := ack.GetError(); err != "" { + // The VSC packet data could not be successfully decoded. + // This should never happen. + ModuleLogger(ctx).Error( + "recv ErrorAcknowledgement", + "channelID", packet.SourceChannel, + "error", err, + ) + if chainID, ok := k.GetChannelToChain(ctx, packet.SourceChannel); ok { + // stop consumer chain and release unbonding + return k.StopConsumerChain(ctx, chainID, false) + } + return errorsmod.Wrapf(types.ErrUnknownConsumerChannelId, "recv ErrorAcknowledgement on unknown channel %s", packet.SourceChannel) + } + return nil +} diff --git a/x/provider/module.go b/x/provider/module.go new file mode 100644 index 00000000..6cb101f3 --- /dev/null +++ b/x/provider/module.go @@ -0,0 +1,145 @@ +package provider + +import ( + "context" + "encoding/json" + "fmt" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" + + "github.com/osmosis-labs/mesh-security-sdk/x/provider/client/cli" + "github.com/osmosis-labs/mesh-security-sdk/x/provider/keeper" + "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" +) + +var ( + _ porttypes.IBCModule = AppModule{} +) + +// ConsensusVersion defines the module's consensus version. +const ConsensusVersion = 1 + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// AppModuleBasic defines the basic application module used by the mesh-security module. +type AppModuleBasic struct{} + +func (b AppModuleBasic) RegisterLegacyAminoCodec(amino *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(amino) +} + +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, serveMux *runtime.ServeMux) { + err := types.RegisterQueryHandlerClient(context.Background(), serveMux, types.NewQueryClient(clientCtx)) + if err != nil { + panic(err) + } +} + +// Name returns the provider module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// DefaultGenesis returns default genesis state as raw bytes for the mesh-security +// module. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState(sdk.DefaultBondDenom)) +} + +// ValidateGenesis performs genesis state validation for the mesh-security module. +func (b AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var data types.GenesisState + if err := cdc.UnmarshalJSON(bz, &data); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return types.ValidateGenesis(&data) +} + +// GetTxCmd returns the root tx command for the mesh-security module. +func (b AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns no root query command for the mesh-security module. +func (b AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd() +} + +// RegisterInterfaces implements InterfaceModule +func (b AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +// AppModule implements an application module interface +type AppModule struct { + AppModuleBasic + cdc codec.Codec + k *keeper.Keeper +} + +// NewAppModuleX extended constructor +func NewAppModule(cdc codec.Codec, k *keeper.Keeper) *AppModule { + return &AppModule{cdc: cdc, k: k} +} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// Name returns the module's name. +func (AppModule) Name() string { return types.ModuleName } + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServer(am.k)) + types.RegisterQueryServer(cfg.QueryServer(), keeper.NewQuerier(am.cdc, am.k)) +} + +// RegisterInvariants registers the module's invariants. +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { +} + +// InitGenesis performs genesis initialization for the mesh-security module. It returns +// no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) []abci.ValidatorUpdate { + var data types.GenesisState + cdc.MustUnmarshalJSON(bz, &data) + am.k.InitGenesis(ctx, data) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the exported genesis state as raw bytes for the mesh-security +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(am.k.ExportGenesis(ctx)) +} + +// QuerierRoute returns the bank module's querier route name. +func (AppModule) QuerierRoute() string { + return types.RouterKey +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { + return ConsensusVersion +} + +// BeginBlock executed before every block +func (am AppModule) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) { +} + +// EndBlock executed after every block. It returns no validator updates. +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return nil +} diff --git a/x/provider/types/codec.go b/x/provider/types/codec.go new file mode 100644 index 00000000..b24cdf84 --- /dev/null +++ b/x/provider/types/codec.go @@ -0,0 +1,32 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + // "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterLegacyAminoCodec register types with legacy amino +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + +} + +// RegisterInterfaces register types with interface registry +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations( + (*sdk.Msg)(nil), + ) +} + +var ( + amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + sdk.RegisterLegacyAminoCodec(amino) +} diff --git a/x/provider/types/errors.go b/x/provider/types/errors.go new file mode 100644 index 00000000..2f243544 --- /dev/null +++ b/x/provider/types/errors.go @@ -0,0 +1,13 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" +) + +var ( + ErrInvalid = errorsmod.Register(ModuleName, 1, "invalid") + ErrInvalidConsumerClient = errorsmod.Register(ModuleName, 16, "ccv channel is not built on correct client") + ErrConsumerChainNotFound = errorsmod.Register(ModuleName, 18, "consumer chain not found") + ErrUnknownConsumerChannelId = errorsmod.Register(ModuleName, 4, "no consumer chain with this channel id") + ErrUnknownConsumerChainId = errorsmod.Register(ModuleName, 3, "no consumer chain with this chain id") +) diff --git a/x/provider/types/events.go b/x/provider/types/events.go new file mode 100644 index 00000000..8701821c --- /dev/null +++ b/x/provider/types/events.go @@ -0,0 +1,23 @@ +package types + +// Provider events +const ( + EventTypeConsumerClientCreated = "consumer_client_created" + EventTypeAssignConsumerKey = "assign_consumer_key" + EventTypeAddConsumerRewardDenom = "add_consumer_reward_denom" + EventTypeRemoveConsumerRewardDenom = "remove_consumer_reward_denom" + EventTypeExecuteConsumerChainSlash = "execute_consumer_chain_slash" + EventTypeSetConsumerCommissionRate = "set_consumer_commission_rate" + EventTypeOptIn = "opt_in" + EventTypeOptOut = "opt_out" + AttributeInfractionHeight = "infraction_height" + AttributeInitialHeight = "initial_height" + AttributeInitializationTimeout = "initialization_timeout" + AttributeTrustingPeriod = "trusting_period" + AttributeUnbondingPeriod = "unbonding_period" + AttributeProviderValidatorAddress = "provider_validator_address" + AttributeConsumerConsensusPubKey = "consumer_consensus_pub_key" + AttributeConsumerRewardDenom = "consumer_reward_denom" + AttributeConsumerCommissionRate = "consumer_commission_rate" + AttributeConsumerChainID = "consumer_chain_id" +) diff --git a/x/provider/types/expected_keepers.go b/x/provider/types/expected_keepers.go new file mode 100644 index 00000000..805f119c --- /dev/null +++ b/x/provider/types/expected_keepers.go @@ -0,0 +1,104 @@ +package types + +import ( + "time" + + "cosmossdk.io/math" + + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + + // transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" + + clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" +) + +type BankKeeper interface { + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error + BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + UndelegateCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error +} + +// SDKStakingKeeper expected staking keeper. +type StakingKeeper interface { + BondDenom(ctx sdk.Context) string + GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) + GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) + ValidateUnbondAmount(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt math.Int) (shares sdk.Dec, err error) + Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt math.Int, tokenSrc stakingtypes.BondStatus, validator stakingtypes.Validator, subtractAccount bool) (newShares sdk.Dec, err error) + GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) + UnbondingTime(ctx sdk.Context) time.Duration + GetParams(ctx sdk.Context) stakingtypes.Params + Unbond(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, shares sdk.Dec) (amount math.Int, err error) + IterateBondedValidatorsByPower(ctx sdk.Context, fn func(int64, stakingtypes.ValidatorI) bool) + TotalBondedTokens(ctx sdk.Context) math.Int + IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(int64, stakingtypes.DelegationI) bool) + GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (stakingtypes.Validator, bool) + MinCommissionRate(ctx sdk.Context) math.LegacyDec +} + +// CommunityPoolKeeper expected distribution keeper. +type CommunityPoolKeeper interface { + WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (sdk.Coins, error) +} + +// AccountKeeper interface contains functions for getting accounts and the module address +type AccountKeeper interface { + GetModuleAddress(name string) sdk.AccAddress + GetModuleAccount(ctx sdk.Context, name string) authtypes.ModuleAccountI +} + +// WasmKeeper abstract wasm keeper +type WasmKeeper interface { + Sudo(ctx sdk.Context, contractAddress sdk.AccAddress, msg []byte) ([]byte, error) + HasContractInfo(ctx sdk.Context, contractAddress sdk.AccAddress) bool +} + +// ChannelKeeper defines the expected IBC channel keeper +type ChannelKeeper interface { + GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) + GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) + SendPacket( + ctx sdk.Context, + chanCap *capabilitytypes.Capability, + sourcePort string, + sourceChannel string, + timeoutHeight clienttypes.Height, + timeoutTimestamp uint64, + data []byte, + ) (sequence uint64, err error) + WriteAcknowledgement(ctx sdk.Context, chanCap *capabilitytypes.Capability, packet ibcexported.PacketI, acknowledgement ibcexported.Acknowledgement) error + ChanCloseInit(ctx sdk.Context, portID, channelID string, chanCap *capabilitytypes.Capability) error + GetChannelConnection(ctx sdk.Context, portID, channelID string) (string, ibcexported.ConnectionI, error) +} + +type ScopedKeeper interface { + GetCapability(ctx sdk.Context, name string) (*capabilitytypes.Capability, bool) + AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool + ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error +} + +// ConnectionKeeper defines the expected IBC connection keeper +type ConnectionKeeper interface { + GetConnection(ctx sdk.Context, connectionID string) (conntypes.ConnectionEnd, bool) +} + +// ClientKeeper defines the expected IBC client keeper +type ClientKeeper interface { + CreateClient(ctx sdk.Context, clientState ibcexported.ClientState, consensusState ibcexported.ConsensusState) (string, error) + GetClientState(ctx sdk.Context, clientID string) (ibcexported.ClientState, bool) + GetLatestClientConsensusState(ctx sdk.Context, clientID string) (ibcexported.ConsensusState, bool) + GetSelfConsensusState(ctx sdk.Context, height ibcexported.Height) (ibcexported.ConsensusState, error) + ClientStore(ctx sdk.Context, clientID string) sdk.KVStore + SetClientState(ctx sdk.Context, clientID string, clientState ibcexported.ClientState) + GetClientConsensusState(ctx sdk.Context, clientID string, height ibcexported.Height) (ibcexported.ConsensusState, bool) +} diff --git a/x/provider/types/genesis.go b/x/provider/types/genesis.go new file mode 100644 index 00000000..d8a4275d --- /dev/null +++ b/x/provider/types/genesis.go @@ -0,0 +1,18 @@ +package types + +// NewGenesisState constructor +func NewGenesisState(params Params) *GenesisState { + return &GenesisState{ + Params: params, + } +} + +// DefaultGenesisState default genesis state +func DefaultGenesisState(denom string) *GenesisState { + return NewGenesisState(DefaultParams(denom)) +} + +// ValidateGenesis does basic validation on genesis state +func ValidateGenesis(gs *GenesisState) error { + return gs.Params.ValidateBasic() +} diff --git a/x/provider/types/genesis.pb.go b/x/provider/types/genesis.pb.go new file mode 100644 index 00000000..2af86f2b --- /dev/null +++ b/x/provider/types/genesis.pb.go @@ -0,0 +1,344 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/provider/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// GenesisState defines meshsecurity module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_1f21be234bee84ef, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func init() { + proto.RegisterType((*GenesisState)(nil), "osmosis.provider.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("osmosis/provider/v1beta1/genesis.proto", fileDescriptor_1f21be234bee84ef) +} + +var fileDescriptor_1f21be234bee84ef = []byte{ + // 252 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcb, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xcb, 0x4c, 0x49, 0x2d, 0xd2, 0x2f, 0x33, 0x4c, + 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, + 0x2f, 0xc9, 0x17, 0x92, 0x80, 0xaa, 0xd3, 0x83, 0xa9, 0xd3, 0x83, 0xaa, 0x93, 0x52, 0xc5, 0x69, + 0x42, 0x41, 0x62, 0x51, 0x62, 0x2e, 0xd4, 0x00, 0x29, 0x91, 0xf4, 0xfc, 0xf4, 0x7c, 0x30, 0x53, + 0x1f, 0xc4, 0x82, 0x8a, 0x0a, 0x26, 0xe6, 0x66, 0xe6, 0xe5, 0xeb, 0x83, 0x49, 0x88, 0x90, 0x52, + 0x24, 0x17, 0x8f, 0x3b, 0xc4, 0xea, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x67, 0x2e, 0x36, 0x88, + 0x41, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0x0a, 0x7a, 0xb8, 0x9c, 0xa2, 0x17, 0x00, 0x56, + 0xe7, 0xc4, 0x79, 0xe2, 0x9e, 0x3c, 0xc3, 0x8a, 0xe7, 0x1b, 0xb4, 0x18, 0x83, 0xa0, 0x5a, 0xad, + 0x58, 0x5e, 0x2c, 0x90, 0x67, 0x74, 0x8a, 0x39, 0xf1, 0x50, 0x8e, 0x61, 0xc5, 0x23, 0x39, 0x86, + 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, + 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xb2, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, + 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x5a, 0xa3, 0x9b, 0x93, 0x98, 0x54, 0xac, 0x9f, 0x9b, + 0x5a, 0x9c, 0xa1, 0x5b, 0x9c, 0x9a, 0x5c, 0x5a, 0x94, 0x59, 0x52, 0xa9, 0x5b, 0x9c, 0x92, 0xad, + 0x5f, 0x81, 0xf0, 0x70, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0xfd, 0xc6, 0x80, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x8f, 0x28, 0x1e, 0x44, 0x53, 0x01, 0x00, 0x00, +} + +func (this *GenesisState) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*GenesisState) + if !ok { + that2, ok := that.(GenesisState) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if !this.Params.Equal(&that1.Params) { + return false + } + return true +} +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", 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 := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + 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 skipGenesis(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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrIntOverflowGenesis + } + 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, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/provider/types/keys.go b/x/provider/types/keys.go new file mode 100644 index 00000000..416c2830 --- /dev/null +++ b/x/provider/types/keys.go @@ -0,0 +1,54 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + ModuleName = "meshsecurity" + RouterKey = ModuleName +) + +var ( + ChainToChannelBytePrefix = []byte{0x1} + ChannelToChainBytePrefix = []byte{0x2} + InitChainHeightBytePrefix = []byte{0x3} + InitTimeoutTimestampBytePrefix = []byte{0x4} + ChainToClientBytePrefix = []byte{0x5} + ConsumerCommissionRatePrefix = []byte{0x6} + ParamsKey = []byte{0x7} +) + +func ChainToChannelKey(chainID string) []byte { + return append(ChainToChannelBytePrefix, []byte(chainID)...) +} + +func ChannelToChainKey(channelID string) []byte { + return append(ChannelToChainBytePrefix, []byte(channelID)...) +} + +func InitChainHeightKey(chainID string) []byte { + return append(InitChainHeightBytePrefix, []byte(chainID)...) +} + +func InitTimeoutTimestampKey(chainID string) []byte { + return append(InitTimeoutTimestampBytePrefix, []byte(chainID)...) +} + +func ChainToClientKey(chainID string) []byte { + return append(ChainToClientBytePrefix, []byte(chainID)...) +} + +func ConsumerCommissionRateKey(chainID string, providerAddr ProviderConsAddress) []byte { + return append(append(ConsumerCommissionRatePrefix, []byte(chainID)...), providerAddr.Address...) +} + +type ProviderConsAddress struct { + Address sdk.ConsAddress +} + +func NewProviderConsAddress(addr sdk.ConsAddress) ProviderConsAddress { + return ProviderConsAddress{ + Address: addr, + } +} diff --git a/x/provider/types/params.go b/x/provider/types/params.go new file mode 100644 index 00000000..68de7172 --- /dev/null +++ b/x/provider/types/params.go @@ -0,0 +1,20 @@ +package types + +// DefaultParams returns default mesh-security parameters +func DefaultParams(denom string) Params { + return Params{ // todo: revisit and set proper defaults + InfractionTime: 0, + TimeoutPeriod: 60, + } +} + +// ValidateBasic performs basic validation on mesh-security parameters. +func (p Params) ValidateBasic() error { + if p.InfractionTime <= 0 { + return ErrInvalid.Wrap("empty epoch length") + } + if p.TimeoutPeriod <= 0 { + return ErrInvalid.Wrap("empty max gas end-blocker setting") + } + return nil +} diff --git a/x/provider/types/params.pb.go b/x/provider/types/params.pb.go new file mode 100644 index 00000000..0b8e9350 --- /dev/null +++ b/x/provider/types/params.pb.go @@ -0,0 +1,361 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/provider/v1beta1/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// Params defines the parameters for the x/meshsecurity module. +type Params struct { + InfractionTime uint64 `protobuf:"varint,1,opt,name=infraction_time,json=infractionTime,proto3" json:"infraction_time,omitempty"` + // TimeoutPeriod has the unit time.Millisecond + TimeoutPeriod uint64 `protobuf:"varint,2,opt,name=timeout_period,json=timeoutPeriod,proto3" json:"timeout_period,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_8d8ea49c9593b4cd, []int{0} +} +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 init() { + proto.RegisterType((*Params)(nil), "osmosis.provider.v1beta1.Params") +} + +func init() { + proto.RegisterFile("osmosis/provider/v1beta1/params.proto", fileDescriptor_8d8ea49c9593b4cd) +} + +var fileDescriptor_8d8ea49c9593b4cd = []byte{ + // 283 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x90, 0xc1, 0x4a, 0xc3, 0x40, + 0x10, 0x86, 0xb3, 0x22, 0x3d, 0x04, 0x6c, 0x31, 0x78, 0x08, 0x3d, 0xac, 0x22, 0x14, 0x45, 0x48, + 0x96, 0xe2, 0xad, 0x47, 0x9f, 0xa0, 0x88, 0x27, 0x11, 0xca, 0x26, 0x59, 0xd3, 0x41, 0x37, 0x13, + 0x76, 0x36, 0xc5, 0xbe, 0x82, 0x27, 0x1f, 0xc1, 0xa3, 0x47, 0x1f, 0xa3, 0xc7, 0x1e, 0x3d, 0x6a, + 0x72, 0xd0, 0xc7, 0x90, 0x6e, 0xd2, 0xf6, 0x32, 0x0c, 0xdf, 0x7c, 0xc3, 0x30, 0xbf, 0x3f, 0x42, + 0xd2, 0x48, 0x40, 0xa2, 0x34, 0xb8, 0x80, 0x4c, 0x19, 0xb1, 0x18, 0x27, 0xca, 0xca, 0xb1, 0x28, + 0xa5, 0x91, 0x9a, 0xe2, 0xd2, 0xa0, 0xc5, 0x20, 0xec, 0xb4, 0x78, 0xab, 0xc5, 0x9d, 0x36, 0xe4, + 0xa9, 0x1b, 0x89, 0x44, 0x92, 0xda, 0xed, 0xa6, 0x08, 0x45, 0xbb, 0x39, 0x3c, 0xc9, 0x31, 0x47, + 0xd7, 0x8a, 0x4d, 0xd7, 0xd1, 0x63, 0xa9, 0xa1, 0x40, 0xe1, 0x6a, 0x8b, 0xce, 0x8d, 0xdf, 0x9b, + 0xba, 0x93, 0xc1, 0x85, 0x3f, 0x80, 0xe2, 0xd1, 0xc8, 0xd4, 0x02, 0x16, 0x33, 0x0b, 0x5a, 0x85, + 0xec, 0x8c, 0x5d, 0x1e, 0xde, 0xf6, 0xf7, 0xf8, 0x0e, 0xb4, 0x0a, 0x46, 0x7e, 0x7f, 0x33, 0xc5, + 0xca, 0xce, 0x4a, 0x65, 0x00, 0xb3, 0xf0, 0xc0, 0x79, 0x47, 0x1d, 0x9d, 0x3a, 0x38, 0x09, 0xff, + 0xde, 0x4f, 0xd9, 0xeb, 0xef, 0xe7, 0xd5, 0x60, 0xf7, 0x64, 0x7b, 0xe9, 0xe6, 0x61, 0xf5, 0xc3, + 0xbd, 0x8f, 0x9a, 0x7b, 0xab, 0x9a, 0xb3, 0x75, 0xcd, 0xd9, 0x77, 0xcd, 0xd9, 0x5b, 0xc3, 0xbd, + 0x75, 0xc3, 0xbd, 0xaf, 0x86, 0x7b, 0xf7, 0x93, 0x1c, 0xec, 0xbc, 0x4a, 0xe2, 0x14, 0xb5, 0xe8, + 0x32, 0x88, 0x9e, 0x65, 0x42, 0x42, 0x2b, 0x9a, 0x47, 0xa4, 0xd2, 0xca, 0x80, 0x5d, 0x46, 0x94, + 0x3d, 0x89, 0x97, 0x7d, 0x86, 0x76, 0x59, 0x2a, 0x4a, 0x7a, 0xee, 0xb1, 0xeb, 0xff, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x1f, 0x21, 0xa6, 0x5e, 0x64, 0x01, 0x00, 0x00, +} + +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.InfractionTime != that1.InfractionTime { + return false + } + if this.TimeoutPeriod != that1.TimeoutPeriod { + return false + } + return true +} +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.TimeoutPeriod != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.TimeoutPeriod)) + i-- + dAtA[i] = 0x10 + } + if m.InfractionTime != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.InfractionTime)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.InfractionTime != 0 { + n += 1 + sovParams(uint64(m.InfractionTime)) + } + if m.TimeoutPeriod != 0 { + n += 1 + sovParams(uint64(m.TimeoutPeriod)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +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 ErrIntOverflowParams + } + 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 != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field InfractionTime", wireType) + } + m.InfractionTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.InfractionTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutPeriod", wireType) + } + m.TimeoutPeriod = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeoutPeriod |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrIntOverflowParams + } + 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, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/provider/types/provider.go b/x/provider/types/provider.go new file mode 100644 index 00000000..dbe6bc1f --- /dev/null +++ b/x/provider/types/provider.go @@ -0,0 +1,28 @@ +package types + +import ( + crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" +) + +type ValidatorConsumerPubKey struct { + ChainId string + ProviderAddr []byte + ConsumerKey *crypto.PublicKey +} + +type ValidatorByConsumerAddr struct { + ChainId string + ConsumerAddr []byte + ProviderAddr []byte +} + +type ConsumerAddrsToPrune struct { + ChainId string + VscId uint64 + ConsumerAddrs *AddressList +} + +// AddressList contains a list of consensus addresses +type AddressList struct { + Addresses [][]byte +} diff --git a/x/provider/types/query.pb.go b/x/provider/types/query.pb.go new file mode 100644 index 00000000..86b77476 --- /dev/null +++ b/x/provider/types/query.pb.go @@ -0,0 +1,537 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/provider/v1beta1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +// QueryParamsRequest is the request type for the +// Query/Params RPC method +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_dc940424cad20223, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is the response type for the +// Query/Params RPC method +type QueryParamsResponse struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_dc940424cad20223, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "osmosis.provider.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "osmosis.provider.v1beta1.QueryParamsResponse") +} + +func init() { + proto.RegisterFile("osmosis/provider/v1beta1/query.proto", fileDescriptor_dc940424cad20223) +} + +var fileDescriptor_dc940424cad20223 = []byte{ + // 338 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0x41, 0x4a, 0xc3, 0x40, + 0x14, 0x86, 0x33, 0x82, 0x05, 0xe3, 0xca, 0xd8, 0x45, 0x29, 0x32, 0x96, 0xa0, 0x50, 0xc4, 0x64, + 0x68, 0xdd, 0xb9, 0xac, 0x17, 0xd0, 0x2e, 0x8b, 0x9b, 0x49, 0x3a, 0xa4, 0x83, 0x4d, 0x5e, 0x9a, + 0x37, 0x29, 0x76, 0xeb, 0x05, 0x14, 0x5c, 0x79, 0x83, 0x2e, 0x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d, 0xfb, 0x27, 0x6d, 0x6a, 0xbb, 0xcd, 0x9b, 0xa7, 0xf7, 0xfb, 0x0d, 0xd7, 0x69, 0xb0, + 0x3f, 0x56, 0xdb, 0xb9, 0x9c, 0xbd, 0x51, 0x6b, 0x5a, 0x50, 0x6b, 0x56, 0x50, 0x32, 0x2f, 0x28, + 0x79, 0x2d, 0x28, 0xb9, 0x5b, 0x50, 0x6b, 0xbe, 0xa0, 0xd6, 0xf3, 0x82, 0x5a, 0xbd, 0xd3, 0x48, + 0xaa, 0x41, 0x1e, 0xf8, 0x21, 0xc4, 0xab, 0x34, 0x6f, 0xc8, 0x03, 0x64, 0xb1, 0xc0, 0x81, 0x87, + 0x22, 0xcc, 0x33, 0xa9, 0x26, 0x1e, 0xf6, 0xaf, 0xd8, 0xf5, 0xf7, 0x33, 0x6a, 0x92, 0x0a, 0x0c, + 0x2a, 0x7a, 0xe5, 0x27, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x80, 0xc3, 0xc6, 0x42, 0x02, + 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Params queries the parameters of x/meshsecurity module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/osmosis.provider.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Params queries the parameters of x/meshsecurity module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.provider.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.provider.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/provider/v1beta1/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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 ErrIntOverflowQuery + } + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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 ErrIntOverflowQuery + } + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrIntOverflowQuery + } + 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, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/provider/types/query.pb.gw.go b/x/provider/types/query.pb.gw.go new file mode 100644 index 00000000..e745219f --- /dev/null +++ b/x/provider/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: osmosis/provider/v1beta1/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "provider", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/provider/types/tx.pb.go b/x/provider/types/tx.pb.go new file mode 100644 index 00000000..75ccff9e --- /dev/null +++ b/x/provider/types/tx.pb.go @@ -0,0 +1,623 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/provider/v1beta1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + 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 + +type MsgSetConsumerCommissionRate struct { + ProviderAddr string `protobuf:"bytes,1,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Rate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=rate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"rate"` +} + +func (m *MsgSetConsumerCommissionRate) Reset() { *m = MsgSetConsumerCommissionRate{} } +func (m *MsgSetConsumerCommissionRate) String() string { return proto.CompactTextString(m) } +func (*MsgSetConsumerCommissionRate) ProtoMessage() {} +func (*MsgSetConsumerCommissionRate) Descriptor() ([]byte, []int) { + return fileDescriptor_600cc2e6a7e19cb9, []int{0} +} +func (m *MsgSetConsumerCommissionRate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetConsumerCommissionRate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetConsumerCommissionRate.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 *MsgSetConsumerCommissionRate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetConsumerCommissionRate.Merge(m, src) +} +func (m *MsgSetConsumerCommissionRate) XXX_Size() int { + return m.Size() +} +func (m *MsgSetConsumerCommissionRate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetConsumerCommissionRate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetConsumerCommissionRate proto.InternalMessageInfo + +type MsgSetConsumerCommissionRateResponse struct { +} + +func (m *MsgSetConsumerCommissionRateResponse) Reset() { *m = MsgSetConsumerCommissionRateResponse{} } +func (m *MsgSetConsumerCommissionRateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetConsumerCommissionRateResponse) ProtoMessage() {} +func (*MsgSetConsumerCommissionRateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_600cc2e6a7e19cb9, []int{1} +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetConsumerCommissionRateResponse.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 *MsgSetConsumerCommissionRateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetConsumerCommissionRateResponse.Merge(m, src) +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetConsumerCommissionRateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetConsumerCommissionRateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetConsumerCommissionRateResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgSetConsumerCommissionRate)(nil), "osmosis.provider.v1beta1.MsgSetConsumerCommissionRate") + proto.RegisterType((*MsgSetConsumerCommissionRateResponse)(nil), "osmosis.provider.v1beta1.MsgSetConsumerCommissionRateResponse") +} + +func init() { proto.RegisterFile("osmosis/provider/v1beta1/tx.proto", fileDescriptor_600cc2e6a7e19cb9) } + +var fileDescriptor_600cc2e6a7e19cb9 = []byte{ + // 404 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcc, 0x2f, 0xce, 0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0x0a, 0x44, 0x92, 0x03, 0x87, + 0x60, 0x12, 0x1b, 0x38, 0xde, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x67, 0x1e, 0x99, + 0x93, 0x02, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// MsgClient is the client API for Msg service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type MsgClient interface { + SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) { + out := new(MsgSetConsumerCommissionRateResponse) + err := c.cc.Invoke(ctx, "/osmosis.provider.v1beta1.Msg/SetConsumerCommissionRate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + SetConsumerCommissionRate(context.Context, *MsgSetConsumerCommissionRate) (*MsgSetConsumerCommissionRateResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) SetConsumerCommissionRate(ctx context.Context, req *MsgSetConsumerCommissionRate) (*MsgSetConsumerCommissionRateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetConsumerCommissionRate not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_SetConsumerCommissionRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetConsumerCommissionRate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetConsumerCommissionRate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.provider.v1beta1.Msg/SetConsumerCommissionRate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetConsumerCommissionRate(ctx, req.(*MsgSetConsumerCommissionRate)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.provider.v1beta1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SetConsumerCommissionRate", + Handler: _Msg_SetConsumerCommissionRate_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/provider/v1beta1/tx.proto", +} + +func (m *MsgSetConsumerCommissionRate) 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 *MsgSetConsumerCommissionRate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetConsumerCommissionRate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.Rate.Size() + i -= size + if _, err := m.Rate.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x12 + } + if len(m.ProviderAddr) > 0 { + i -= len(m.ProviderAddr) + copy(dAtA[i:], m.ProviderAddr) + i = encodeVarintTx(dAtA, i, uint64(len(m.ProviderAddr))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetConsumerCommissionRateResponse) 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 *MsgSetConsumerCommissionRateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetConsumerCommissionRateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSetConsumerCommissionRate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ProviderAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Rate.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSetConsumerCommissionRateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgSetConsumerCommissionRate) 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 ErrIntOverflowTx + } + 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: MsgSetConsumerCommissionRate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetConsumerCommissionRate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ProviderAddr", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ProviderAddr = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Rate", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Rate.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetConsumerCommissionRateResponse) 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 ErrIntOverflowTx + } + 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: MsgSetConsumerCommissionRateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetConsumerCommissionRateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/types/codec.go b/x/types/codec.go new file mode 100644 index 00000000..324b3ec0 --- /dev/null +++ b/x/types/codec.go @@ -0,0 +1,11 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" +) + +var ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + +func init() { +} diff --git a/x/types/error.go b/x/types/error.go new file mode 100644 index 00000000..7662bbf0 --- /dev/null +++ b/x/types/error.go @@ -0,0 +1,13 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" +) + +// meshsecurity sentinel errors +var ( + ErrInvalidVersion = errorsmod.Register(ModuleName, 2, "invalid meshsecurity version") + ErrInvalidChannelFlow = errorsmod.Register(ModuleName, 3, "invalid message sent to channel end") + ErrDuplicateChannel = errorsmod.Register(ModuleName, 5, "meshsecurity channel already exists") + ErrClientNotFound = errorsmod.Register(ModuleName, 10, "client not found") +) diff --git a/x/types/event.go b/x/types/event.go new file mode 100644 index 00000000..014831e1 --- /dev/null +++ b/x/types/event.go @@ -0,0 +1,12 @@ +package types + +const ( + EventTypeTimeout = "timeout" + EventTypePacket = "mesh_packet" + EventTypeChannelEstablished = "channel_established" + + AttributeKeyAckSuccess = "success" + AttributeKeyAck = "acknowledgement" + AttributeKeyAckError = "error" + AttributeChainID = "chain_id" +) diff --git a/x/types/key.go b/x/types/key.go new file mode 100644 index 00000000..91643215 --- /dev/null +++ b/x/types/key.go @@ -0,0 +1,8 @@ +package types + +const ( + ModuleName = "MeshSecurity" + ProviderPortID = "provider" + ConsumerPortID = "consumer" + Version = "1" +) diff --git a/x/types/wire.go b/x/types/wire.go new file mode 100644 index 00000000..cee764a8 --- /dev/null +++ b/x/types/wire.go @@ -0,0 +1,54 @@ +package types + +import ( + "encoding/binary" +) + +func (c ConsumerPacketData) GetBytes() []byte { + var bytes []byte + bytes = append(bytes, Int32ToBytes(int32(c.Type))...) + if c.Type != PipedValsetOperation_VALIDATOR_SLASHED { + bytes = append(bytes, ModuleCdc.MustMarshalJSON(&c)...) + return bytes + } + + packetSlashInfo := c.GetSlashPacketData() + bytes = append(bytes, ModuleCdc.MustMarshalJSON(packetSlashInfo)...) + return bytes +} + +func UnmarshalConsumerPacketData(data []byte) (ConsumerPacketData, error) { + cp := PipedValsetOperation(BigEndianToInt32(data[:4])) + if cp != PipedValsetOperation_VALIDATOR_SLASHED { + var c ConsumerPacketData + ModuleCdc.UnmarshalJSON(data[4:], &c) + return c, nil + } + + var slash SlashInfo + err := ModuleCdc.UnmarshalJSON(data[4:], &slash) + if err != nil { + return ConsumerPacketData{}, err + } + + return ConsumerPacketData{ + Type: cp, + Data: &ConsumerPacketData_SlashPacketData{ + SlashPacketData: &slash, + }, + }, nil + +} + +func BigEndianToInt32(bz []byte) int32 { + if len(bz) == 0 { + return 0 + } + return int32(binary.BigEndian.Uint32(bz)) +} + +func Int32ToBytes(i int32) []byte { + data := make([]byte, 4) + binary.BigEndian.PutUint32(data, uint32(i)) + return data +} diff --git a/x/types/wire.pb.go b/x/types/wire.pb.go new file mode 100644 index 00000000..f73234cb --- /dev/null +++ b/x/types/wire.pb.go @@ -0,0 +1,817 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/types/v1beta1/wire.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cometbft/cometbft/abci/types" + _ "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/cosmos-sdk/x/staking/types" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// enum PipedValsetOperation +type PipedValsetOperation int32 + +const ( + PipedValsetOperation_UNSPECIFIED PipedValsetOperation = 0 + PipedValsetOperation_VALIDATOR_BONDED PipedValsetOperation = 1 + PipedValsetOperation_VALIDATOR_UNBONDED PipedValsetOperation = 2 + PipedValsetOperation_VALIDATOR_JAILED PipedValsetOperation = 3 + PipedValsetOperation_VALIDATOR_TOMBSTONED PipedValsetOperation = 4 + PipedValsetOperation_VALIDATOR_UNJAILED PipedValsetOperation = 5 + PipedValsetOperation_VALIDATOR_MODIFIED PipedValsetOperation = 6 + PipedValsetOperation_VALIDATOR_SLASHED PipedValsetOperation = 7 +) + +var PipedValsetOperation_name = map[int32]string{ + 0: "UNSPECIFIED", + 1: "VALIDATOR_BONDED", + 2: "VALIDATOR_UNBONDED", + 3: "VALIDATOR_JAILED", + 4: "VALIDATOR_TOMBSTONED", + 5: "VALIDATOR_UNJAILED", + 6: "VALIDATOR_MODIFIED", + 7: "VALIDATOR_SLASHED", +} + +var PipedValsetOperation_value = map[string]int32{ + "UNSPECIFIED": 0, + "VALIDATOR_BONDED": 1, + "VALIDATOR_UNBONDED": 2, + "VALIDATOR_JAILED": 3, + "VALIDATOR_TOMBSTONED": 4, + "VALIDATOR_UNJAILED": 5, + "VALIDATOR_MODIFIED": 6, + "VALIDATOR_SLASHED": 7, +} + +func (x PipedValsetOperation) String() string { + return proto.EnumName(PipedValsetOperation_name, int32(x)) +} + +func (PipedValsetOperation) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c573c9158aa3b788, []int{0} +} + +// InfractionType indicates the infraction type a validator committed. +// Note ccv.InfractionType to maintain compatibility between ICS versions +// using different versions of the cosmos-sdk and ibc-go modules. +type InfractionType int32 + +const ( + // UNSPECIFIED defines an empty infraction type. + InfractionEmpty InfractionType = 0 + // DOUBLE_SIGN defines a validator that double-signs a block. + DoubleSign InfractionType = 1 + // DOWNTIME defines a validator that missed signing too many blocks. + Downtime InfractionType = 2 +) + +var InfractionType_name = map[int32]string{ + 0: "INFRACTION_TYPE_UNSPECIFIED", + 1: "INFRACTION_TYPE_DOUBLE_SIGN", + 2: "INFRACTION_TYPE_DOWNTIME", +} + +var InfractionType_value = map[string]int32{ + "INFRACTION_TYPE_UNSPECIFIED": 0, + "INFRACTION_TYPE_DOUBLE_SIGN": 1, + "INFRACTION_TYPE_DOWNTIME": 2, +} + +func (x InfractionType) String() string { + return proto.EnumName(InfractionType_name, int32(x)) +} + +func (InfractionType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_c573c9158aa3b788, []int{1} +} + +// SlashInfo defines info event from slashing +type SlashInfo struct { + InfractionHeight int64 `protobuf:"varint,2,opt,name=infraction_height,json=infractionHeight,proto3" json:"infraction_height,omitempty"` + Power int64 `protobuf:"varint,3,opt,name=power,proto3" json:"power,omitempty"` + TotalSlashAmount string `protobuf:"bytes,4,opt,name=total_slash_amount,json=totalSlashAmount,proto3" json:"total_slash_amount,omitempty"` + SlashFraction string `protobuf:"bytes,5,opt,name=slash_fraction,json=slashFraction,proto3" json:"slash_fraction,omitempty"` + TimeInfraction int64 `protobuf:"varint,6,opt,name=time_infraction,json=timeInfraction,proto3" json:"time_infraction,omitempty"` +} + +func (m *SlashInfo) Reset() { *m = SlashInfo{} } +func (m *SlashInfo) String() string { return proto.CompactTextString(m) } +func (*SlashInfo) ProtoMessage() {} +func (*SlashInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_c573c9158aa3b788, []int{0} +} +func (m *SlashInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SlashInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SlashInfo.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 *SlashInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_SlashInfo.Merge(m, src) +} +func (m *SlashInfo) XXX_Size() int { + return m.Size() +} +func (m *SlashInfo) XXX_DiscardUnknown() { + xxx_messageInfo_SlashInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_SlashInfo proto.InternalMessageInfo + +// ConsumerPacketData contains a consumer packet data and a type tag +type ConsumerPacketData struct { + Type PipedValsetOperation `protobuf:"varint,1,opt,name=type,proto3,enum=osmosis.types.v1beta1.PipedValsetOperation" json:"type,omitempty"` + // Types that are valid to be assigned to Data: + // *ConsumerPacketData_SlashPacketData + Data isConsumerPacketData_Data `protobuf_oneof:"data"` +} + +func (m *ConsumerPacketData) Reset() { *m = ConsumerPacketData{} } +func (m *ConsumerPacketData) String() string { return proto.CompactTextString(m) } +func (*ConsumerPacketData) ProtoMessage() {} +func (*ConsumerPacketData) Descriptor() ([]byte, []int) { + return fileDescriptor_c573c9158aa3b788, []int{1} +} +func (m *ConsumerPacketData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ConsumerPacketData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ConsumerPacketData.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 *ConsumerPacketData) XXX_Merge(src proto.Message) { + xxx_messageInfo_ConsumerPacketData.Merge(m, src) +} +func (m *ConsumerPacketData) XXX_Size() int { + return m.Size() +} +func (m *ConsumerPacketData) XXX_DiscardUnknown() { + xxx_messageInfo_ConsumerPacketData.DiscardUnknown(m) +} + +var xxx_messageInfo_ConsumerPacketData proto.InternalMessageInfo + +type isConsumerPacketData_Data interface { + isConsumerPacketData_Data() + MarshalTo([]byte) (int, error) + Size() int +} + +type ConsumerPacketData_SlashPacketData struct { + SlashPacketData *SlashInfo `protobuf:"bytes,2,opt,name=slashPacketData,proto3,oneof" json:"slashPacketData,omitempty"` +} + +func (*ConsumerPacketData_SlashPacketData) isConsumerPacketData_Data() {} + +func (m *ConsumerPacketData) GetData() isConsumerPacketData_Data { + if m != nil { + return m.Data + } + return nil +} + +func (m *ConsumerPacketData) GetSlashPacketData() *SlashInfo { + if x, ok := m.GetData().(*ConsumerPacketData_SlashPacketData); ok { + return x.SlashPacketData + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ConsumerPacketData) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*ConsumerPacketData_SlashPacketData)(nil), + } +} + +func init() { + proto.RegisterEnum("osmosis.types.v1beta1.PipedValsetOperation", PipedValsetOperation_name, PipedValsetOperation_value) + proto.RegisterEnum("osmosis.types.v1beta1.InfractionType", InfractionType_name, InfractionType_value) + proto.RegisterType((*SlashInfo)(nil), "osmosis.types.v1beta1.SlashInfo") + proto.RegisterType((*ConsumerPacketData)(nil), "osmosis.types.v1beta1.ConsumerPacketData") +} + +func init() { proto.RegisterFile("osmosis/types/v1beta1/wire.proto", fileDescriptor_c573c9158aa3b788) } + +var fileDescriptor_c573c9158aa3b788 = []byte{ + // 643 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x4f, 0x4f, 0xdb, 0x3c, + 0x1c, 0xc7, 0x13, 0x28, 0x7d, 0x1e, 0xcc, 0xf3, 0xb4, 0xc1, 0x2b, 0x53, 0x54, 0xa4, 0x28, 0x42, + 0x9b, 0x86, 0x60, 0x34, 0x82, 0xed, 0x3e, 0xb5, 0x24, 0x8c, 0x4c, 0x25, 0xa9, 0x9a, 0xc2, 0xb4, + 0x5d, 0x22, 0x27, 0x35, 0xad, 0x45, 0x13, 0x57, 0xb1, 0x3b, 0xc6, 0x3b, 0x98, 0x38, 0xed, 0x0d, + 0x70, 0xda, 0x65, 0xd3, 0xde, 0x08, 0x07, 0x0e, 0x1c, 0x77, 0xdc, 0xca, 0x1b, 0x99, 0xe2, 0x64, + 0x8d, 0xf8, 0xb3, 0x4b, 0x64, 0x7f, 0xfc, 0xfd, 0x7e, 0xfd, 0xb3, 0x7f, 0x31, 0xd0, 0x29, 0x8b, + 0x28, 0x23, 0xcc, 0xe0, 0x67, 0x63, 0xcc, 0x8c, 0x0f, 0xdb, 0x01, 0xe6, 0x68, 0xdb, 0x38, 0x25, + 0x09, 0x6e, 0x8c, 0x13, 0xca, 0x29, 0x5c, 0xc9, 0x15, 0x0d, 0xa1, 0x68, 0xe4, 0x8a, 0xba, 0x16, + 0x0a, 0x6e, 0x04, 0x88, 0xe1, 0x99, 0x2d, 0xa4, 0x24, 0xce, 0x6c, 0xf5, 0xda, 0x80, 0x0e, 0xa8, + 0x18, 0x1a, 0xe9, 0x28, 0xa7, 0xcb, 0x28, 0x22, 0x31, 0x35, 0xc4, 0x37, 0x47, 0x4f, 0xf2, 0x20, + 0xc6, 0xd1, 0x09, 0x89, 0x07, 0xb3, 0xac, 0x7c, 0x9e, 0xab, 0x56, 0x39, 0x8e, 0xfb, 0x38, 0x89, + 0x48, 0xcc, 0x0d, 0x14, 0x84, 0x24, 0xab, 0x37, 0x5b, 0x5c, 0xbb, 0x92, 0xc1, 0xa2, 0x37, 0x42, + 0x6c, 0x68, 0xc7, 0xc7, 0x14, 0x6e, 0x82, 0x65, 0x12, 0x1f, 0x27, 0x28, 0xe4, 0x84, 0xc6, 0xfe, + 0x10, 0x93, 0xc1, 0x90, 0xab, 0x73, 0xba, 0xbc, 0x3e, 0xdf, 0x55, 0x8a, 0x85, 0x7d, 0xc1, 0x61, + 0x0d, 0x2c, 0x8c, 0xe9, 0x29, 0x4e, 0xd4, 0x79, 0x21, 0xc8, 0x26, 0xf0, 0x39, 0x80, 0x9c, 0x72, + 0x34, 0xf2, 0x59, 0x9a, 0xea, 0xa3, 0x88, 0x4e, 0x62, 0xae, 0x96, 0x74, 0x79, 0x7d, 0xb1, 0xab, + 0x88, 0x15, 0xb1, 0x5d, 0x53, 0x70, 0xf8, 0x14, 0x54, 0x32, 0xdd, 0x9f, 0x6c, 0x75, 0x41, 0x28, + 0xff, 0x17, 0x74, 0x2f, 0x87, 0xf0, 0x19, 0xa8, 0x72, 0x12, 0x61, 0xbf, 0xa8, 0x41, 0x2d, 0x8b, + 0x4d, 0x2b, 0x29, 0xb6, 0x67, 0x74, 0xed, 0xbb, 0x0c, 0xe0, 0x2e, 0x8d, 0xd9, 0x24, 0xc2, 0x49, + 0x07, 0x85, 0x27, 0x98, 0x9b, 0x88, 0x23, 0xf8, 0x0a, 0x94, 0xd2, 0x43, 0xab, 0xb2, 0x2e, 0xaf, + 0x57, 0x76,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 0x45, 0x63, 0x7e, 0x06, 0x8d, 0xfb, 0x2e, 0xd3, 0x3d, 0x6c, 0xb5, 0x2d, + 0xdf, 0xb3, 0x5f, 0x3b, 0x8a, 0x5c, 0xaf, 0x9c, 0x5f, 0xe8, 0xc0, 0xa4, 0x93, 0x60, 0x84, 0x3d, + 0x32, 0x88, 0xe1, 0x06, 0x50, 0xef, 0x1b, 0xde, 0x3a, 0x3d, 0xfb, 0xc0, 0x52, 0xe6, 0xea, 0xff, + 0x9d, 0x5f, 0xe8, 0xff, 0x9a, 0xf4, 0x34, 0x4e, 0x7f, 0x96, 0x7a, 0xe9, 0xd3, 0x17, 0x4d, 0x6a, + 0x79, 0x97, 0xbf, 0x34, 0xe9, 0xeb, 0x54, 0x93, 0x2e, 0xa7, 0x9a, 0x7c, 0x3d, 0xd5, 0xe4, 0x9f, + 0x53, 0x4d, 0xfe, 0x7c, 0xa3, 0x49, 0xd7, 0x37, 0x9a, 0xf4, 0xe3, 0x46, 0x93, 0xde, 0x6f, 0x0f, + 0x08, 0x1f, 0x4e, 0x82, 0x46, 0x48, 0x23, 0x23, 0xef, 0xf1, 0xd6, 0x08, 0x05, 0xcc, 0x88, 0x30, + 0x1b, 0x6e, 0x31, 0x1c, 0x4e, 0x12, 0xc2, 0xcf, 0xb6, 0x58, 0xff, 0xc4, 0xf8, 0x98, 0x3d, 0xa9, + 0xa0, 0x2c, 0xde, 0xd4, 0x8b, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x29, 0x61, 0x91, 0x2d, 0x1a, + 0x04, 0x00, 0x00, +} + +func (m *SlashInfo) 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 *SlashInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SlashInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.TimeInfraction != 0 { + i = encodeVarintWire(dAtA, i, uint64(m.TimeInfraction)) + i-- + dAtA[i] = 0x30 + } + if len(m.SlashFraction) > 0 { + i -= len(m.SlashFraction) + copy(dAtA[i:], m.SlashFraction) + i = encodeVarintWire(dAtA, i, uint64(len(m.SlashFraction))) + i-- + dAtA[i] = 0x2a + } + if len(m.TotalSlashAmount) > 0 { + i -= len(m.TotalSlashAmount) + copy(dAtA[i:], m.TotalSlashAmount) + i = encodeVarintWire(dAtA, i, uint64(len(m.TotalSlashAmount))) + i-- + dAtA[i] = 0x22 + } + if m.Power != 0 { + i = encodeVarintWire(dAtA, i, uint64(m.Power)) + i-- + dAtA[i] = 0x18 + } + if m.InfractionHeight != 0 { + i = encodeVarintWire(dAtA, i, uint64(m.InfractionHeight)) + i-- + dAtA[i] = 0x10 + } + return len(dAtA) - i, nil +} + +func (m *ConsumerPacketData) 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 *ConsumerPacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsumerPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Data != nil { + { + size := m.Data.Size() + i -= size + if _, err := m.Data.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + if m.Type != 0 { + i = encodeVarintWire(dAtA, i, uint64(m.Type)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ConsumerPacketData_SlashPacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsumerPacketData_SlashPacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.SlashPacketData != nil { + { + size, err := m.SlashPacketData.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWire(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func encodeVarintWire(dAtA []byte, offset int, v uint64) int { + offset -= sovWire(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *SlashInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.InfractionHeight != 0 { + n += 1 + sovWire(uint64(m.InfractionHeight)) + } + if m.Power != 0 { + n += 1 + sovWire(uint64(m.Power)) + } + l = len(m.TotalSlashAmount) + if l > 0 { + n += 1 + l + sovWire(uint64(l)) + } + l = len(m.SlashFraction) + if l > 0 { + n += 1 + l + sovWire(uint64(l)) + } + if m.TimeInfraction != 0 { + n += 1 + sovWire(uint64(m.TimeInfraction)) + } + return n +} + +func (m *ConsumerPacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Type != 0 { + n += 1 + sovWire(uint64(m.Type)) + } + if m.Data != nil { + n += m.Data.Size() + } + return n +} + +func (m *ConsumerPacketData_SlashPacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SlashPacketData != nil { + l = m.SlashPacketData.Size() + n += 1 + l + sovWire(uint64(l)) + } + return n +} + +func sovWire(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozWire(x uint64) (n int) { + return sovWire(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *SlashInfo) 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 ErrIntOverflowWire + } + 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: SlashInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SlashInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field InfractionHeight", wireType) + } + m.InfractionHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.InfractionHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 ErrIntOverflowWire + } + 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 TotalSlashAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + 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 ErrInvalidLengthWire + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWire + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TotalSlashAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashFraction", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + 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 ErrInvalidLengthWire + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWire + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SlashFraction = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TimeInfraction", wireType) + } + m.TimeInfraction = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TimeInfraction |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipWire(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWire + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ConsumerPacketData) 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 ErrIntOverflowWire + } + 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: ConsumerPacketData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ConsumerPacketData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) + } + m.Type = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Type |= PipedValsetOperation(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SlashPacketData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWire + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWire + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &SlashInfo{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Data = &ConsumerPacketData_SlashPacketData{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWire(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWire + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipWire(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, ErrIntOverflowWire + } + 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, ErrIntOverflowWire + } + 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, ErrIntOverflowWire + } + 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, ErrInvalidLengthWire + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupWire + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthWire + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthWire = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowWire = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupWire = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/types/wire_test.go b/x/types/wire_test.go new file mode 100644 index 00000000..901c516f --- /dev/null +++ b/x/types/wire_test.go @@ -0,0 +1,27 @@ +package types + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestGetBytesAndX(t *testing.T) { + c1 := ConsumerPacketData{ + Type: PipedValsetOperation_VALIDATOR_SLASHED, + Data: &ConsumerPacketData_SlashPacketData{ + SlashPacketData: &SlashInfo{ + InfractionHeight: 1, + Power: 2, + TotalSlashAmount: "3", + SlashFraction: "0.1", + TimeInfraction: 1000, + }, + }, + } + + data := c1.GetBytes() + c2, err := UnmarshalConsumerPacketData(data) + require.NoError(t, err) + require.Equal(t, c1, c2) +} From 759240d30150ee8dd8e8109b4d340c50fbacc796 Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Tue, 16 Jul 2024 20:47:48 +0700 Subject: [PATCH 02/14] Updates: Add delegate and vault... --- docs/proto/proto-docs.md | 216 ++++- .../meshsecurity/v1beta1/meshsecurity.proto | 2 + proto/osmosis/provider/v1beta1/delegate.proto | 45 + proto/osmosis/provider/v1beta1/params.proto | 6 +- proto/osmosis/provider/v1beta1/tx.proto | 31 +- proto/osmosis/types/v1beta1/wire.proto | 8 + x/meshsecurity/ibc_module.go | 5 - x/meshsecurity/keeper/adapter.go | 36 - x/meshsecurity/keeper/adapter_test.go | 1 - x/meshsecurity/keeper/relay.go | 11 +- x/meshsecurity/keeper/relay_test.go | 32 - x/meshsecurity/keeper/slash.go | 26 + x/meshsecurity/keeper/staking_hooks.go | 5 + x/meshsecurity/keeper/test_common.go | 28 +- x/meshsecurity/keeper/valset_updates.go | 146 ++- x/meshsecurity/keeper/valset_updates_test.go | 135 ++- x/meshsecurity/types/expected_keepers.go | 1 + x/meshsecurity/types/keys.go | 38 +- x/meshsecurity/types/meshsecurity.pb.go | 87 +- x/meshsecurity/types/params.go | 1 + x/provider/contract/in_message.go | 22 + x/provider/ibc_module.go | 67 +- x/provider/keeper/delegate.go | 63 ++ x/provider/keeper/keeper.go | 96 +- x/provider/keeper/keeper_test.go | 56 ++ x/provider/keeper/msg_server.go | 63 ++ x/provider/keeper/relay.go | 161 ++++ x/provider/keeper/relay_test.go | 1 + x/provider/keeper/test_common.go | 316 ++++++ x/provider/keeper/wasm.go | 28 + x/provider/types/delegate.go | 34 + x/provider/types/delegate.pb.go | 833 ++++++++++++++++ x/provider/types/events.go | 3 + x/provider/types/expected_keepers.go | 3 + x/provider/types/keys.go | 22 +- x/provider/types/params.go | 19 +- x/provider/types/params.pb.go | 93 +- x/provider/types/tx.pb.go | 907 +++++++++++++++++- x/types/error.go | 1 + x/types/wire.go | 90 +- x/types/wire.pb.go | 424 +++++++- x/types/wire_test.go | 22 +- 42 files changed, 3775 insertions(+), 409 deletions(-) create mode 100644 proto/osmosis/provider/v1beta1/delegate.proto delete mode 100644 x/meshsecurity/keeper/relay_test.go create mode 100644 x/meshsecurity/keeper/slash.go create mode 100644 x/provider/contract/in_message.go create mode 100644 x/provider/keeper/delegate.go create mode 100644 x/provider/keeper/keeper_test.go create mode 100644 x/provider/keeper/relay_test.go create mode 100644 x/provider/keeper/test_common.go create mode 100644 x/provider/keeper/wasm.go create mode 100644 x/provider/types/delegate.go create mode 100644 x/provider/types/delegate.pb.go diff --git a/docs/proto/proto-docs.md b/docs/proto/proto-docs.md index 78829d75..e35f550b 100644 --- a/docs/proto/proto-docs.md +++ b/docs/proto/proto-docs.md @@ -4,36 +4,45 @@ ## Table of Contents -- [osmosis/provider/v1beta1/params.proto](#osmosis/provider/v1beta1/params.proto) - - [Params](#osmosis.provider.v1beta1.Params) +- [osmosis/meshsecurity/v1beta1/meshsecurity.proto](#osmosis/meshsecurity/v1beta1/meshsecurity.proto) + - [Params](#osmosis.meshsecurity.v1beta1.Params) + - [VirtualStakingMaxCapInfo](#osmosis.meshsecurity.v1beta1.VirtualStakingMaxCapInfo) -- [osmosis/provider/v1beta1/genesis.proto](#osmosis/provider/v1beta1/genesis.proto) - - [GenesisState](#osmosis.provider.v1beta1.GenesisState) +- [osmosis/meshsecurity/v1beta1/genesis.proto](#osmosis/meshsecurity/v1beta1/genesis.proto) + - [GenesisState](#osmosis.meshsecurity.v1beta1.GenesisState) -- [osmosis/provider/v1beta1/query.proto](#osmosis/provider/v1beta1/query.proto) - - [QueryParamsRequest](#osmosis.provider.v1beta1.QueryParamsRequest) - - [QueryParamsResponse](#osmosis.provider.v1beta1.QueryParamsResponse) +- [osmosis/meshsecurity/v1beta1/query.proto](#osmosis/meshsecurity/v1beta1/query.proto) + - [QueryParamsRequest](#osmosis.meshsecurity.v1beta1.QueryParamsRequest) + - [QueryParamsResponse](#osmosis.meshsecurity.v1beta1.QueryParamsResponse) + - [QueryVirtualStakingMaxCapLimitRequest](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitRequest) + - [QueryVirtualStakingMaxCapLimitResponse](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitResponse) + - [QueryVirtualStakingMaxCapLimitsRequest](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitsRequest) + - [QueryVirtualStakingMaxCapLimitsResponse](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitsResponse) - - [Query](#osmosis.provider.v1beta1.Query) + - [Query](#osmosis.meshsecurity.v1beta1.Query) -- [osmosis/provider/v1beta1/tx.proto](#osmosis/provider/v1beta1/tx.proto) - - [MsgSetConsumerCommissionRate](#osmosis.provider.v1beta1.MsgSetConsumerCommissionRate) - - [MsgSetConsumerCommissionRateResponse](#osmosis.provider.v1beta1.MsgSetConsumerCommissionRateResponse) +- [osmosis/meshsecurity/v1beta1/scheduler.proto](#osmosis/meshsecurity/v1beta1/scheduler.proto) + - [ScheduledWork](#osmosis.meshsecurity.v1beta1.ScheduledWork) + - [ValidatorAddress](#osmosis.meshsecurity.v1beta1.ValidatorAddress) - - [Msg](#osmosis.provider.v1beta1.Msg) +- [osmosis/meshsecurity/v1beta1/tx.proto](#osmosis/meshsecurity/v1beta1/tx.proto) + - [MsgSetVirtualStakingMaxCap](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCap) + - [MsgSetVirtualStakingMaxCapResponse](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCapResponse) + + - [Msg](#osmosis.meshsecurity.v1beta1.Msg) - [Scalar Value Types](#scalar-value-types) - +

Top

-## osmosis/provider/v1beta1/params.proto +## osmosis/meshsecurity/v1beta1/meshsecurity.proto - + ### Params Params defines the parameters for the x/meshsecurity module. @@ -41,8 +50,28 @@ Params defines the parameters for the x/meshsecurity module. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | +| `total_contracts_max_cap` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | TotalContractsMaxCap is the maximum that the sum of all contract max caps must not exceed | +| `epoch_length` | [uint32](#uint32) | | Epoch length is the number of blocks that defines an epoch | +| `max_gas_end_blocker` | [uint32](#uint32) | | MaxGasEndBlocker defines the maximum gas that can be spent in a contract sudo callback | | `infraction_time` | [uint64](#uint64) | | | -| `timeout_period` | [uint64](#uint64) | | TimeoutPeriod has the unit time.Millisecond | + + + + + + + + +### VirtualStakingMaxCapInfo +VirtualStakingMaxCapInfo stores info about +virtual staking max cap + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `contract` | [string](#string) | | Contract is the address of the contract | +| `delegated` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | Delegated is the total amount currently delegated | +| `cap` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | Cap is the current max cap limit | @@ -58,14 +87,14 @@ Params defines the parameters for the x/meshsecurity module. - +

Top

-## osmosis/provider/v1beta1/genesis.proto +## osmosis/meshsecurity/v1beta1/genesis.proto - + ### GenesisState GenesisState defines meshsecurity module's genesis state. @@ -73,7 +102,7 @@ GenesisState defines meshsecurity module's genesis state. | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#osmosis.provider.v1beta1.Params) | | | +| `params` | [Params](#osmosis.meshsecurity.v1beta1.Params) | | | @@ -89,14 +118,14 @@ GenesisState defines meshsecurity module's genesis state. - +

Top

-## osmosis/provider/v1beta1/query.proto +## osmosis/meshsecurity/v1beta1/query.proto - + ### QueryParamsRequest QueryParamsRequest is the request type for the @@ -107,7 +136,7 @@ Query/Params RPC method - + ### QueryParamsResponse QueryParamsResponse is the response type for the @@ -116,7 +145,67 @@ Query/Params RPC method | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `params` | [Params](#osmosis.provider.v1beta1.Params) | | | +| `params` | [Params](#osmosis.meshsecurity.v1beta1.Params) | | | + + + + + + + + +### QueryVirtualStakingMaxCapLimitRequest +QueryVirtualStakingMaxCapLimitRequest is the request type for the +Query/VirtualStakingMaxCapLimit RPC method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | Address is the address of the contract to query | + + + + + + + + +### QueryVirtualStakingMaxCapLimitResponse +QueryVirtualStakingMaxCapLimitResponse is the response type for the +Query/VirtualStakingMaxCapLimit RPC method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `delegated` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | +| `cap` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | | + + + + + + + + +### QueryVirtualStakingMaxCapLimitsRequest +QueryVirtualStakingMaxCapLimitsRequest is the request type for the +Query/VirtualStakingMaxCapLimits RPC method + + + + + + + + +### QueryVirtualStakingMaxCapLimitsResponse +QueryVirtualStakingMaxCapLimitsResponse is the response type for the +Query/VirtualStakingMaxCapLimits RPC method + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `max_cap_infos` | [VirtualStakingMaxCapInfo](#osmosis.meshsecurity.v1beta1.VirtualStakingMaxCapInfo) | repeated | | @@ -129,47 +218,52 @@ Query/Params RPC method - + ### Query Query provides defines the gRPC querier service | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `Params` | [QueryParamsRequest](#osmosis.provider.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#osmosis.provider.v1beta1.QueryParamsResponse) | Params queries the parameters of x/meshsecurity module. | GET|/osmosis/provider/v1beta1/params| +| `VirtualStakingMaxCapLimit` | [QueryVirtualStakingMaxCapLimitRequest](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitRequest) | [QueryVirtualStakingMaxCapLimitResponse](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitResponse) | VirtualStakingMaxCapLimit gets max cap limit for the given contract | GET|/osmosis/meshsecurity/v1beta1/max_cap_limit/{address}| +| `VirtualStakingMaxCapLimits` | [QueryVirtualStakingMaxCapLimitsRequest](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitsRequest) | [QueryVirtualStakingMaxCapLimitsResponse](#osmosis.meshsecurity.v1beta1.QueryVirtualStakingMaxCapLimitsResponse) | VirtualStakingMaxCapLimits gets max cap limits | GET|/osmosis/meshsecurity/v1beta1/max_cap_limits| +| `Params` | [QueryParamsRequest](#osmosis.meshsecurity.v1beta1.QueryParamsRequest) | [QueryParamsResponse](#osmosis.meshsecurity.v1beta1.QueryParamsResponse) | Params queries the parameters of x/meshsecurity module. | GET|/osmosis/meshsecurity/v1beta1/params| - +

Top

-## osmosis/provider/v1beta1/tx.proto +## osmosis/meshsecurity/v1beta1/scheduler.proto - + -### MsgSetConsumerCommissionRate +### ScheduledWork | Field | Type | Label | Description | | ----- | ---- | ----- | ----------- | -| `provider_addr` | [string](#string) | | | -| `chain_id` | [string](#string) | | | -| `rate` | [string](#string) | | | +| `repeat` | [bool](#bool) | | | + + - +### ValidatorAddress +ValidatorAddress payload data to be used with the scheduler -### MsgSetConsumerCommissionRateResponse +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `address` | [string](#string) | | Address is the ValAddress bech32 string | @@ -181,15 +275,59 @@ Query provides defines the gRPC querier service + + + + + +

Top

+ +## osmosis/meshsecurity/v1beta1/tx.proto + + + + + +### MsgSetVirtualStakingMaxCap +MsgSetVirtualStakingMaxCap creates or updates a maximum cap limit for virtual +staking coins to the given contract. + + +| Field | Type | Label | Description | +| ----- | ---- | ----- | ----------- | +| `authority` | [string](#string) | | Authority is the address that controls the module (defaults to x/gov unless overwritten). | +| `contract` | [string](#string) | | Contract is the address of the smart contract that is given permission do virtual staking which includes minting and burning staking tokens. | +| `max_cap` | [cosmos.base.v1beta1.Coin](#cosmos.base.v1beta1.Coin) | | MaxCap is the limit up this the virtual tokens can be minted. | + + + + + + + + +### MsgSetVirtualStakingMaxCapResponse +MsgSetVirtualStakingMaxCap returns result data. - -### Msg + + + + + + + + + + +### Msg +Msg defines the wasm Msg service. + | Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint | | ----------- | ------------ | ------------- | ------------| ------- | -------- | -| `SetConsumerCommissionRate` | [MsgSetConsumerCommissionRate](#osmosis.provider.v1beta1.MsgSetConsumerCommissionRate) | [MsgSetConsumerCommissionRateResponse](#osmosis.provider.v1beta1.MsgSetConsumerCommissionRateResponse) | | | +| `SetVirtualStakingMaxCap` | [MsgSetVirtualStakingMaxCap](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCap) | [MsgSetVirtualStakingMaxCapResponse](#osmosis.meshsecurity.v1beta1.MsgSetVirtualStakingMaxCapResponse) | SetVirtualStakingMaxCap creates or updates a maximum cap limit for virtual staking coins | | diff --git a/proto/osmosis/meshsecurity/v1beta1/meshsecurity.proto b/proto/osmosis/meshsecurity/v1beta1/meshsecurity.proto index 02cfc51e..b2fab291 100644 --- a/proto/osmosis/meshsecurity/v1beta1/meshsecurity.proto +++ b/proto/osmosis/meshsecurity/v1beta1/meshsecurity.proto @@ -36,4 +36,6 @@ message Params { // MaxGasEndBlocker defines the maximum gas that can be spent in a contract // sudo callback uint32 max_gas_end_blocker = 3; + + uint64 infraction_time = 4; } \ No newline at end of file diff --git a/proto/osmosis/provider/v1beta1/delegate.proto b/proto/osmosis/provider/v1beta1/delegate.proto new file mode 100644 index 00000000..4611fe99 --- /dev/null +++ b/proto/osmosis/provider/v1beta1/delegate.proto @@ -0,0 +1,45 @@ +syntax = "proto3"; +package osmosis.provider.v1beta1; + +import "cosmos/base/v1beta1/coin.proto"; +import "gogoproto/gogo.proto"; +import "amino/amino.proto"; + +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; +option (gogoproto.goproto_getters_all) = false; +option (gogoproto.equal_all) = false; + +// Params defines the parameters for the x/meshsecurity module. +message Depositors { + string address = 1; + repeated cosmos.base.v1beta1.Coin tokens = 2 [ + (gogoproto.nullable) = false, + (amino.dont_omitempty) = true, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; +} + +// vault-staker +message Intermediary { + string consumer_validator = 1; + string chain_id = 2; + string contract_address = 3; + bool jailed = 4; + bool tombstoned = 5; + BondStatus status = 6; + cosmos.base.v1beta1.Coin token = 7; +} + +// BondStatus is the status of a validator. +enum BondStatus { + option (gogoproto.goproto_enum_prefix) = false; + + // UNSPECIFIED defines an invalid validator status. + BOND_STATUS_UNSPECIFIED = 0 [(gogoproto.enumvalue_customname) = "Unspecified"]; + // UNBONDED defines a validator that is not bonded. + BOND_STATUS_UNBONDED = 1 [(gogoproto.enumvalue_customname) = "Unbonded"]; + // UNBONDING defines a validator that is unbonding. + BOND_STATUS_UNBONDING = 2 [(gogoproto.enumvalue_customname) = "Unbonding"]; + // BONDED defines a validator that is bonded. + BOND_STATUS_BONDED = 3 [(gogoproto.enumvalue_customname) = "Bonded"]; + } \ No newline at end of file diff --git a/proto/osmosis/provider/v1beta1/params.proto b/proto/osmosis/provider/v1beta1/params.proto index 50ae2eb2..9f76fd35 100644 --- a/proto/osmosis/provider/v1beta1/params.proto +++ b/proto/osmosis/provider/v1beta1/params.proto @@ -14,9 +14,9 @@ message Params { option (amino.name) = "provider/Params"; option (gogoproto.equal) = true; - uint64 infraction_time = 1; - // TimeoutPeriod has the unit time.Millisecond - uint64 timeout_period = 2; + uint64 timeout_period = 1; + + string vault_contract_address = 2; } diff --git a/proto/osmosis/provider/v1beta1/tx.proto b/proto/osmosis/provider/v1beta1/tx.proto index 77cb6f6c..ca725e0c 100644 --- a/proto/osmosis/provider/v1beta1/tx.proto +++ b/proto/osmosis/provider/v1beta1/tx.proto @@ -5,12 +5,41 @@ import "cosmos_proto/cosmos.proto"; import "cosmos/msg/v1/msg.proto"; import "gogoproto/gogo.proto"; import "amino/amino.proto"; +import "cosmos/base/v1beta1/coin.proto"; option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; option (gogoproto.goproto_getters_all) = false; service Msg { - rpc SetConsumerCommissionRate(MsgSetConsumerCommissionRate) returns (MsgSetConsumerCommissionRateResponse); + rpc Delegate(MsgDelegate) returns (MsgDelegateResponse); + + rpc Undelegate(MsgUndelegate) returns (MsgUndelegateResponse); + + + + rpc SetConsumerCommissionRate(MsgSetConsumerCommissionRate) returns (MsgSetConsumerCommissionRateResponse); +} +message MsgDelegate { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} +message MsgDelegateResponse {} + +message MsgUndelegate { + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +// MsgUndelegateResponse defines the Msg/Undelegate response type. +message MsgUndelegateResponse { } message MsgSetConsumerCommissionRate { diff --git a/proto/osmosis/types/v1beta1/wire.proto b/proto/osmosis/types/v1beta1/wire.proto index 5e5078f3..66adb1af 100644 --- a/proto/osmosis/types/v1beta1/wire.proto +++ b/proto/osmosis/types/v1beta1/wire.proto @@ -26,6 +26,7 @@ enum PipedValsetOperation { // SlashInfo defines info event from slashing message SlashInfo { + string validator = 1; int64 infraction_height = 2; int64 power = 3; string total_slash_amount = 4; @@ -33,12 +34,19 @@ message SlashInfo { int64 time_infraction = 6; } +// InfoSchedule +message ScheduleInfo { + string validator = 1; + string actor = 2; +} + // ConsumerPacketData contains a consumer packet data and a type tag message ConsumerPacketData { PipedValsetOperation type = 1; oneof data { SlashInfo slashPacketData = 2; + ScheduleInfo schedulePacketData = 3; } } diff --git a/x/meshsecurity/ibc_module.go b/x/meshsecurity/ibc_module.go index ddbffb48..79d069b6 100644 --- a/x/meshsecurity/ibc_module.go +++ b/x/meshsecurity/ibc_module.go @@ -165,8 +165,3 @@ func (am AppModule) OnTimeoutPacket( ) error { return nil } - -func UnmarshalConsumerPacket(packetData []byte) (any, error) { - // TODO: type packet from provider - return nil, nil -} diff --git a/x/meshsecurity/keeper/adapter.go b/x/meshsecurity/keeper/adapter.go index c7914979..1d2a9e0b 100644 --- a/x/meshsecurity/keeper/adapter.go +++ b/x/meshsecurity/keeper/adapter.go @@ -113,42 +113,6 @@ func NewStakingDecorator(stakingKeeper slashingtypes.StakingKeeper, k *Keeper) * return &StakingDecorator{StakingKeeper: stakingKeeper, k: k} } -// Slash captures the slash event and calls the decorated staking keeper slash method -func (s StakingDecorator) Slash(ctx sdk.Context, consAddr sdk.ConsAddress, power int64, height int64, slashRatio sdk.Dec) math.Int { - val := s.StakingKeeper.ValidatorByConsAddr(ctx, consAddr) - totalSlashAmount := s.StakingKeeper.Slash(ctx, consAddr, power, height, slashRatio) - if val == nil { - ModuleLogger(ctx). - Error("can not propagate slash: validator not found", "validator", consAddr.String()) - } else if err := s.k.ScheduleSlashed(ctx, val.GetOperator(), power, height, totalSlashAmount, slashRatio); err != nil { - ModuleLogger(ctx). - Error("can not propagate slash: schedule event", - "cause", err, - "validator", consAddr.String()) - } - return totalSlashAmount -} - -// SlashWithInfractionReason implementation doesn't require the infraction (types.Infraction) to work but is required by Interchain Security. -func (s StakingDecorator) SlashWithInfractionReason(ctx sdk.Context, consAddr sdk.ConsAddress, infractionHeight int64, power int64, slashFactor sdk.Dec, _ stakingtypes.Infraction) math.Int { - return s.Slash(ctx, consAddr, infractionHeight, power, slashFactor) -} - -// Jail captures the jail event and calls the decorated staking keeper jail method -func (s StakingDecorator) Jail(ctx sdk.Context, consAddr sdk.ConsAddress) { - val := s.StakingKeeper.ValidatorByConsAddr(ctx, consAddr) - if val == nil { - ModuleLogger(ctx). - Error("can not propagate jail: validator not found", "validator", consAddr.String()) - } else if err := s.k.ScheduleJailed(ctx, val.GetOperator()); err != nil { - ModuleLogger(ctx). - Error("can not propagate jail: schedule event", - "cause", err, - "validator", consAddr.String()) - } - s.StakingKeeper.Jail(ctx, consAddr) -} - // Unjail captures the unjail event and calls the decorated staking keeper unjail method func (s StakingDecorator) Unjail(ctx sdk.Context, consAddr sdk.ConsAddress) { val := s.StakingKeeper.ValidatorByConsAddr(ctx, consAddr) diff --git a/x/meshsecurity/keeper/adapter_test.go b/x/meshsecurity/keeper/adapter_test.go index 72fe8e4f..e8e692ee 100644 --- a/x/meshsecurity/keeper/adapter_test.go +++ b/x/meshsecurity/keeper/adapter_test.go @@ -10,7 +10,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" - cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" ) diff --git a/x/meshsecurity/keeper/relay.go b/x/meshsecurity/keeper/relay.go index 48e8e73d..bae5d50b 100644 --- a/x/meshsecurity/keeper/relay.go +++ b/x/meshsecurity/keeper/relay.go @@ -21,15 +21,8 @@ func (k Keeper) SendPackets(ctx sdk.Context) { // pending := k.GetAllPendingPacketsWithIdx(ctx) ConsumerPackets := []types.ConsumerPacketData{} - k.iteratePipedValsetOperations(ctx, func(valAddress sdk.ValAddress, op types.PipedValsetOperation, slashInfo *types.SlashInfo) bool { - newPacket := types.ConsumerPacketData{ - Type: op, - Data: &types.ConsumerPacketData_SlashPacketData{ - SlashPacketData: slashInfo, - }, - } - ConsumerPackets = append(ConsumerPackets, newPacket) - + k.iteratePipedValsetOperations(ctx, func(packet *types.ConsumerPacketData) bool { + ConsumerPackets = append(ConsumerPackets, *packet) return false }) diff --git a/x/meshsecurity/keeper/relay_test.go b/x/meshsecurity/keeper/relay_test.go deleted file mode 100644 index 56522c38..00000000 --- a/x/meshsecurity/keeper/relay_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package keeper - -import ( - "testing" - - "cosmossdk.io/math" - "github.com/cometbft/cometbft/libs/rand" - sdk "github.com/cosmos/cosmos-sdk/types" - - // "github.com/stretchr/testify/require" - - // "github.com/cosmos/cosmos-sdk/types/address" - - "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" -) - -func TestDDD(t *testing.T) { - ctx, keepers := CreateDefaultTestInput(t) - k := keepers.MeshKeeper - myValidatorAddr := sdk.ValAddress(rand.Bytes(20)) - // myOtherValAddr = sdk.ValAddress(rand.Bytes(address.Len)) - // myVStakingContractAddr = sdk.AccAddress(rand.Bytes(address.Len)) - // myOtherVStakingContractAddr = sdk.AccAddress(rand.Bytes(address.Len)) - - k.SetProviderChannel(ctx, "consumerCCVChannelID") - k.SetParams(ctx, types.DefaultParams(sdk.DefaultBondDenom)) - - k.ScheduleSlashed(ctx, myValidatorAddr, 46, 56, math.NewInt(66), math.LegacyMustNewDecFromStr("0.1")) - k.ScheduleSlashed(ctx, myValidatorAddr, 45, 55, math.NewInt(66), math.LegacyMustNewDecFromStr("0.1")) - - k.SendPackets(ctx) -} diff --git a/x/meshsecurity/keeper/slash.go b/x/meshsecurity/keeper/slash.go new file mode 100644 index 00000000..99111a17 --- /dev/null +++ b/x/meshsecurity/keeper/slash.go @@ -0,0 +1,26 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) HandleBeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, slashRatio sdk.Dec) error { + if valAddr == nil { + ModuleLogger(ctx). + Error("can not propagate slash: validator not found", "validator", valAddr.String()) + } + if err := k.ScheduleSlashed(ctx, valAddr, slashRatio); err != nil { + ModuleLogger(ctx). + Error("can not propagate slash: schedule event", + "cause", err, + "validator", valAddr.String()) + } + if err := k.ScheduleJailed(ctx, valAddr); err != nil { + ModuleLogger(ctx). + Error("can not propagate jail: schedule event", + "cause", err, + "validator", valAddr.String()) + } + + return nil +} diff --git a/x/meshsecurity/keeper/staking_hooks.go b/x/meshsecurity/keeper/staking_hooks.go index c9b0df9b..12ac4255 100644 --- a/x/meshsecurity/keeper/staking_hooks.go +++ b/x/meshsecurity/keeper/staking_hooks.go @@ -29,6 +29,11 @@ func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, _ sdk.ConsAddress, } func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec) error { + if fraction.IsZero() { + return nil + } + h.k.HandleBeforeValidatorSlashed(ctx, valAddr, fraction) + return nil } diff --git a/x/meshsecurity/keeper/test_common.go b/x/meshsecurity/keeper/test_common.go index 98fe202c..26279706 100644 --- a/x/meshsecurity/keeper/test_common.go +++ b/x/meshsecurity/keeper/test_common.go @@ -301,26 +301,28 @@ func CreateDefaultTestInput(t testing.TB, opts ...Option) (sdk.Context, TestKeep // FetchAllStoredOperations load all ops from temp db func FetchAllStoredOperations(t *testing.T, ctx sdk.Context, msKeeper *Keeper) map[string][]cptypes.PipedValsetOperation { index := make(map[string][]cptypes.PipedValsetOperation, 1) - err := msKeeper.iteratePipedValsetOperations(ctx, func(valAddr sdk.ValAddress, op cptypes.PipedValsetOperation, slashInfo *cptypes.SlashInfo) bool { - ops, ok := index[valAddr.String()] - if !ok { - ops = []cptypes.PipedValsetOperation{} + err := msKeeper.iteratePipedValsetOperations(ctx, func(packet *cptypes.ConsumerPacketData) bool { + if packet.Type != cptypes.PipedValsetOperation_VALIDATOR_SLASHED { + data := packet.GetSchedulePacketData() + ops, ok := index[data.Validator] + if !ok { + ops = []cptypes.PipedValsetOperation{} + } + index[data.Validator] = append(ops, packet.Type) + } else { + data := packet.GetSlashPacketData() + ops, ok := index[data.Validator] + if !ok { + ops = []cptypes.PipedValsetOperation{} + } + index[data.Validator] = append(ops, packet.Type) } - index[valAddr.String()] = append(ops, op) return false }) require.NoError(t, err) return index } -// for test code only -func must[t any](s t, err error) t { - if err != nil { - panic(err) - } - return s -} - // MinValidatorFixture creates minimal sdk validator object func MinValidatorFixture(t *testing.T) stakingtypes.Validator { t.Helper() diff --git a/x/meshsecurity/keeper/valset_updates.go b/x/meshsecurity/keeper/valset_updates.go index 3e5ebdc1..f0ecd0ee 100644 --- a/x/meshsecurity/keeper/valset_updates.go +++ b/x/meshsecurity/keeper/valset_updates.go @@ -12,56 +12,120 @@ import ( "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/contract" "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" - - outmessage "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/contract" ) // ScheduleBonded store a validator update to bonded status for the valset update report func (k Keeper) ScheduleBonded(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_BONDED, addr, nil) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_BONDED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: addr.String(), + }, + }, + } + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_BONDED, addr, packet) } // ScheduleUnbonded store a validator update to unbonded status for the valset update report func (k Keeper) ScheduleUnbonded(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_UNBONDED, addr, nil) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_UNBONDED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: addr.String(), + }, + }, + } + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_UNBONDED, addr, packet) } // ScheduleSlashed store a validator slash event / data for the valset update report -func (k Keeper) ScheduleSlashed(ctx sdk.Context, addr sdk.ValAddress, power int64, height int64, totalSlashAmount math.Int, slashRatio sdk.Dec) error { +func (k Keeper) ScheduleSlashed(ctx sdk.Context, valAddr sdk.ValAddress, slashRatio sdk.Dec) error { + power := k.Staking.GetLastValidatorPower(ctx, valAddr) + infractionHeight := ctx.BlockHeight() - sdk.ValidatorUpdateDelay - 1 + validator, _ := k.Staking.GetValidator(ctx, valAddr) + totalSlashAmount := sdk.NewDecFromInt(validator.Tokens).MulTruncate(slashRatio).RoundInt() + // TODO: timeInfraction + var slashInfo = &cptypes.SlashInfo{ + Validator: validator.OperatorAddress, Power: power, - InfractionHeight: height, + InfractionHeight: infractionHeight, TotalSlashAmount: totalSlashAmount.String(), SlashFraction: slashRatio.String(), + // TODO: timeInfraction + TimeInfraction: 0, + } + + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_SLASHED, + Data: &cptypes.ConsumerPacketData_SlashPacketData{ + SlashPacketData: slashInfo, + }, } - return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_SLASHED, addr, slashInfo) + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_SLASHED, valAddr, packet) } // ScheduleJailed store a validator update to jailed status for the valset update report func (k Keeper) ScheduleJailed(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_JAILED, addr, nil) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_JAILED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: addr.String(), + }, + }, + } + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_JAILED, addr, packet) } // ScheduleTombstoned store a validator update to tombstoned status for the valset update report func (k Keeper) ScheduleTombstoned(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_TOMBSTONED, addr, nil) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_TOMBSTONED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: addr.String(), + }, + }, + } + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_TOMBSTONED, addr, packet) } // ScheduleUnjailed store a validator update to unjailed status for the valset update report func (k Keeper) ScheduleUnjailed(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_UNJAILED, addr, nil) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_UNJAILED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: addr.String(), + }, + }, + } + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_UNJAILED, addr, packet) } // ScheduleModified store a validator metadata update for the valset update report func (k Keeper) ScheduleModified(ctx sdk.Context, addr sdk.ValAddress) error { - return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, addr, nil) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: addr.String(), + }, + }, + } + return k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, addr, packet) } // instead of sync calls to the contracts for the different kind of valset changes in a block, we store them in the mem db // and async send to all registered contracts in the end blocker -func (k Keeper) sendAsync(ctx sdk.Context, op cptypes.PipedValsetOperation, valAddr sdk.ValAddress, slashInfo *cptypes.SlashInfo) error { +func (k Keeper) sendAsync(ctx sdk.Context, op cptypes.PipedValsetOperation, valAddr sdk.ValAddress, packet cptypes.ConsumerPacketData) error { + // if op ModuleLogger(ctx).Debug("storing for async update", "operation", int(op), "val", valAddr.String()) - ctx.KVStore(k.memKey).Set(types.BuildPipedValsetOpKey(op, valAddr, slashInfo), []byte{}) + value := packet.GetBytes() + ctx.KVStore(k.memKey).Set(types.BuildPipedValsetOpKey(op, valAddr), value) // and schedule an update callback for all registered contracts var innerErr error k.IterateMaxCapLimit(ctx, func(contractAddr sdk.AccAddress, m math.Int) bool { @@ -90,9 +154,9 @@ func (k Keeper) ValsetUpdateReport(ctx sdk.Context) (contract.ValsetUpdate, erro *set = append(*set, ConvertSdkValidatorToWasm(val)) return false } - slashValidator := func(set *[]outmessage.ValidatorSlash, valAddr sdk.ValAddress, power int64, infractionHeight int64, + slashValidator := func(set *[]contract.ValidatorSlash, valAddr sdk.ValAddress, power int64, infractionHeight int64, infractionTime int64, slashAmount string, slashRatio string) bool { - valSlash := outmessage.ValidatorSlash{ + valSlash := contract.ValidatorSlash{ ValidatorAddr: valAddr.String(), Power: power, InfractionHeight: infractionHeight, @@ -114,26 +178,32 @@ func (k Keeper) ValsetUpdateReport(ctx sdk.Context) (contract.ValsetUpdate, erro Tombstoned: make([]contract.ValidatorAddr, 0), Slashed: make([]contract.ValidatorSlash, 0), } - err := k.iteratePipedValsetOperations(ctx, func(valAddr sdk.ValAddress, op cptypes.PipedValsetOperation, slashInfo *cptypes.SlashInfo) bool { - switch op { + err := k.iteratePipedValsetOperations(ctx, func(packet *cptypes.ConsumerPacketData) bool { + switch packet.Type { case cptypes.PipedValsetOperation_VALIDATOR_BONDED: - return appendValidator(&r.Additions, valAddr) + data := packet.GetSchedulePacketData() + return appendValidator(&r.Additions, sdk.ValAddress(data.Validator)) case cptypes.PipedValsetOperation_VALIDATOR_UNBONDED: - r.Removals = append(r.Removals, valAddr.String()) + data := packet.GetSchedulePacketData() + r.Removals = append(r.Removals, data.Validator) case cptypes.PipedValsetOperation_VALIDATOR_JAILED: - r.Jailed = append(r.Jailed, valAddr.String()) + data := packet.GetSchedulePacketData() + r.Jailed = append(r.Jailed, data.Validator) case cptypes.PipedValsetOperation_VALIDATOR_TOMBSTONED: - r.Tombstoned = append(r.Tombstoned, valAddr.String()) + data := packet.GetSchedulePacketData() + r.Tombstoned = append(r.Tombstoned, data.Validator) case cptypes.PipedValsetOperation_VALIDATOR_UNJAILED: - r.Unjailed = append(r.Unjailed, valAddr.String()) + data := packet.GetSchedulePacketData() + r.Unjailed = append(r.Unjailed, data.Validator) case cptypes.PipedValsetOperation_VALIDATOR_MODIFIED: - return appendValidator(&r.Updated, valAddr) + data := packet.GetSchedulePacketData() + return appendValidator(&r.Updated, sdk.ValAddress(data.Validator)) case cptypes.PipedValsetOperation_VALIDATOR_SLASHED: - // TODO: Add / send the infraction time - return slashValidator(&r.Slashed, valAddr, slashInfo.Power, slashInfo.InfractionHeight, 0, - slashInfo.TotalSlashAmount, slashInfo.SlashFraction) + data := packet.GetSlashPacketData() + return slashValidator(&r.Slashed, sdk.ValAddress(data.Validator), data.Power, data.InfractionHeight, data.TimeInfraction, + data.TotalSlashAmount, data.SlashFraction) default: - innerErr = types.ErrInvalid.Wrapf("undefined operation type %X", op) + innerErr = types.ErrInvalid.Wrapf("undefined operation type %X", packet.Type) return true } return false @@ -159,27 +229,15 @@ func (k Keeper) ClearPipedValsetOperations(ctx sdk.Context) { } // iterate through all stored valset updates. Due to the storage key, there are no contract duplicates within an operation type. -func (k Keeper) iteratePipedValsetOperations(ctx sdk.Context, cb func(valAddress sdk.ValAddress, op cptypes.PipedValsetOperation, slashInfo *cptypes.SlashInfo) bool) error { +func (k Keeper) iteratePipedValsetOperations(ctx sdk.Context, cb func(packet *cptypes.ConsumerPacketData) bool) error { pStore := prefix.NewStore(ctx.KVStore(k.memKey), types.PipedValsetPrefix) iter := pStore.Iterator(nil, nil) for ; iter.Valid(); iter.Next() { - key := iter.Key() - addrLen := key[0] - addr, op := key[1:addrLen+1], key[addrLen+1] - var slashInfo *cptypes.SlashInfo = nil - if cptypes.PipedValsetOperation(op) == cptypes.PipedValsetOperation_VALIDATOR_SLASHED { - if len(key) <= 1+int(addrLen)+1+8+8+1 { - return types.ErrInvalid.Wrapf("invalid slash key length %d", len(key)) - } - totalSlashAmountLen := key[addrLen+2+8+8] - slashInfo = &cptypes.SlashInfo{ - Power: int64(sdk.BigEndianToUint64(key[addrLen+2 : addrLen+2+8])), - InfractionHeight: int64(sdk.BigEndianToUint64(key[addrLen+2+8 : addrLen+2+8+8])), - TotalSlashAmount: string(key[addrLen+2+8+8+1 : addrLen+2+8+8+1+totalSlashAmountLen]), - SlashFraction: string(key[addrLen+2+8+8+1+totalSlashAmountLen:]), - } + consumerPacket, err := cptypes.UnmarshalConsumerPacketData(iter.Value()) + if err != nil { + panic(err) } - if cb(addr, cptypes.PipedValsetOperation(op), slashInfo) { + if cb(&consumerPacket) { break } } diff --git a/x/meshsecurity/keeper/valset_updates_test.go b/x/meshsecurity/keeper/valset_updates_test.go index 03a75a0d..8198bb0a 100644 --- a/x/meshsecurity/keeper/valset_updates_test.go +++ b/x/meshsecurity/keeper/valset_updates_test.go @@ -4,6 +4,7 @@ import ( "bytes" stdrand "math/rand" "testing" + "time" "github.com/cometbft/cometbft/libs/rand" "github.com/stretchr/testify/assert" @@ -13,6 +14,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/contract" @@ -35,7 +37,15 @@ func TestSendAsync(t *testing.T) { }{ "no duplicates": { setup: func(t *testing.T, ctx sdk.Context) { - require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, myValAddr, nil)) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: myValAddr.String(), + }, + }, + } + require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, myValAddr, packet)) }, assert: func(t *testing.T, ctx sdk.Context, ops map[string][]cptypes.PipedValsetOperation) { assert.Len(t, ops, 1) @@ -45,7 +55,15 @@ func TestSendAsync(t *testing.T) { }, "separated by validator": { setup: func(t *testing.T, ctx sdk.Context) { - require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, myOtherValAddr, nil)) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: myOtherValAddr.String(), + }, + }, + } + require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, myOtherValAddr, packet)) }, assert: func(t *testing.T, ctx sdk.Context, ops map[string][]cptypes.PipedValsetOperation) { assert.Len(t, ops, 2) @@ -56,7 +74,15 @@ func TestSendAsync(t *testing.T) { }, "separated by type": { setup: func(t *testing.T, ctx sdk.Context) { - require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_BONDED, myValAddr, nil)) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_BONDED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: myValAddr.String(), + }, + }, + } + require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_BONDED, myValAddr, packet)) }, assert: func(t *testing.T, ctx sdk.Context, ops map[string][]cptypes.PipedValsetOperation) { assert.Len(t, ops, 1) @@ -96,7 +122,15 @@ func TestSendAsync(t *testing.T) { ctx, _ := pCtx.CacheContext() spec.setup(t, ctx) // when - gotErr := k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, myValAddr, nil) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: myValAddr.String(), + }, + }, + } + gotErr := k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, myValAddr, packet) // then require.NoError(t, gotErr) allStoredOps := FetchAllStoredOperations(t, ctx, k) @@ -143,7 +177,15 @@ func TestBuildValsetUpdateReport(t *testing.T) { }) for _, v := range allOps { - require.NoError(t, k.sendAsync(ctx, v.op, v.valAddr, nil)) + packet := cptypes.ConsumerPacketData{ + Type: v.op, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: v.valAddr.String(), + }, + }, + } + require.NoError(t, k.sendAsync(ctx, v.op, v.valAddr, packet)) } // when got, err := k.ValsetUpdateReport(ctx) @@ -198,13 +240,29 @@ func TestValsetUpdateReportErrors(t *testing.T) { }{ "unknown val address": { setup: func(t *testing.T, ctx sdk.Context) { - require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_BONDED, nonValAddr, nil)) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_BONDED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: nonValAddr.String(), + }, + }, + } + require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_BONDED, nonValAddr, packet)) }, expErr: types.ErrUnknown, }, "unsupported val operation": { setup: func(t *testing.T, ctx sdk.Context) { - require.NoError(t, k.sendAsync(ctx, 0xff, nonValAddr, nil)) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_BONDED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: nonValAddr.String(), + }, + }, + } + require.NoError(t, k.sendAsync(ctx, 0xff, nonValAddr, packet)) }, expErr: types.ErrInvalid, }, @@ -224,12 +282,71 @@ func TestValsetUpdateReportErrors(t *testing.T) { func TestClearPipedValsetOperations(t *testing.T) { ctx, keepers := CreateDefaultTestInput(t) k := keepers.MeshKeeper - err := k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, rand.Bytes(address.Len), nil) + val := rand.Bytes(address.Len) + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: string(val), + }, + }, + } + err := k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, val, packet) require.NoError(t, err) - err = k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_UNJAILED, rand.Bytes(address.Len), nil) + + packet = cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_UNJAILED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: string(val), + }, + }, + } + err = k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_UNJAILED, val, packet) require.NoError(t, err) // when k.ClearPipedValsetOperations(ctx) // then assert.Empty(t, FetchAllStoredOperations(t, ctx, k)) } + +func TestSetAndGetScheduleSlashed(t *testing.T) { + ctx, keepers := CreateDefaultTestInput(t) + k := keepers.MeshKeeper + + valAdrees := sdk.ValAddress(rand.Bytes(address.Len)) + slashInfo := &cptypes.SlashInfo{ + Validator: valAdrees.String(), + Power: 12, + InfractionHeight: 123, + TotalSlashAmount: sdk.NewInt(1000).String(), + SlashFraction: sdk.NewDec(1).String(), + TimeInfraction: time.Now().Unix(), + } + + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_SLASHED, + Data: &cptypes.ConsumerPacketData_SlashPacketData{ + SlashPacketData: slashInfo, + }, + } + // set + err := k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_SLASHED, valAdrees, packet) + require.NoError(t, err) + // get + var getSlash cptypes.SlashInfo + err = k.iteratePipedValsetOperations(ctx, func(packet *cptypes.ConsumerPacketData) bool { + if packet.Type == cptypes.PipedValsetOperation_VALIDATOR_SLASHED { + getSlash = *packet.GetSlashPacketData() + return true + } + return false + }) + require.NoError(t, err) + // check + require.Equal(t, slashInfo.TimeInfraction, getSlash.TimeInfraction) + require.Equal(t, slashInfo.Power, getSlash.Power) + require.Equal(t, slashInfo.InfractionHeight, getSlash.InfractionHeight) + require.Equal(t, slashInfo.TotalSlashAmount, getSlash.TotalSlashAmount) + require.Equal(t, valAdrees.String(), getSlash.Validator) +} diff --git a/x/meshsecurity/types/expected_keepers.go b/x/meshsecurity/types/expected_keepers.go index 7be9a6e3..021d8318 100644 --- a/x/meshsecurity/types/expected_keepers.go +++ b/x/meshsecurity/types/expected_keepers.go @@ -45,6 +45,7 @@ type SDKStakingKeeper interface { TotalBondedTokens(ctx sdk.Context) math.Int IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(int64, stakingtypes.DelegationI) bool) GetValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) (stakingtypes.Validator, bool) + GetLastValidatorPower(ctx sdk.Context, operator sdk.ValAddress) int64 } type XStakingKeeper interface { diff --git a/x/meshsecurity/types/keys.go b/x/meshsecurity/types/keys.go index 1a95d227..6fe5996d 100644 --- a/x/meshsecurity/types/keys.go +++ b/x/meshsecurity/types/keys.go @@ -1,15 +1,14 @@ package types import ( - "encoding/binary" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" - "github.com/osmosis-labs/mesh-security-sdk/x/types" + + cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" ) const ( // ModuleName defines the module name. - ModuleName = "meshsecurity" + ModuleName = "meshsecurityconsummer" // ConsumerPortID is the default port id the consumer module binds to ConsumerPortID = "consumer" @@ -75,34 +74,13 @@ func BuildSchedulerContractKey(tp SchedulerTaskType, blockHeight uint64, contrac } // BuildPipedValsetOpKey build store key for the temporary valset operation store -func BuildPipedValsetOpKey(op types.PipedValsetOperation, val sdk.ValAddress, slashInfo *types.SlashInfo) []byte { - if op == types.PipedValsetOperation_UNSPECIFIED { +func BuildPipedValsetOpKey(op cptypes.PipedValsetOperation, val sdk.ValAddress) []byte { + if op == cptypes.PipedValsetOperation_UNSPECIFIED { panic("empty operation") } - pn, an := len(PipedValsetPrefix), len(val) - sn := 0 - if op == types.PipedValsetOperation_VALIDATOR_SLASHED { - if slashInfo == nil { - panic("slash info is nil") - } - sn = 8 + 8 + 1 + len(slashInfo.TotalSlashAmount) + len(slashInfo.SlashFraction) // 8 for height, 8 for power, +1 for total amount length - } - r := make([]byte, pn+an+sn+1+1) // +1 for address prefix, +1 for op - copy(r, PipedValsetPrefix) - copy(r[pn:], address.MustLengthPrefix(val)) - r[pn+an+1] = byte(op) - if op == types.PipedValsetOperation_VALIDATOR_SLASHED { - b := make([]byte, 8) - binary.BigEndian.PutUint64(b, uint64(slashInfo.InfractionHeight)) - copy(r[pn+an+1+1:], b) - binary.BigEndian.PutUint64(b, uint64(slashInfo.Power)) - copy(r[pn+an+1+1+8:], b) - tn := len(slashInfo.TotalSlashAmount) - r[pn+an+1+1+8+8] = byte(tn) - copy(r[pn+an+1+1+8+8+1:], slashInfo.TotalSlashAmount) - copy(r[pn+an+1+1+8+8+1+tn:], slashInfo.SlashFraction) - } - return r + k := append(append(PipedValsetPrefix, byte(op)), val...) + // return + return k } // ProviderChannelKey returns the key for storing channelID of the provider chain diff --git a/x/meshsecurity/types/meshsecurity.pb.go b/x/meshsecurity/types/meshsecurity.pb.go index 6abc9723..ae9df2e6 100644 --- a/x/meshsecurity/types/meshsecurity.pb.go +++ b/x/meshsecurity/types/meshsecurity.pb.go @@ -79,6 +79,7 @@ type Params struct { // MaxGasEndBlocker defines the maximum gas that can be spent in a contract // sudo callback MaxGasEndBlocker uint32 `protobuf:"varint,3,opt,name=max_gas_end_blocker,json=maxGasEndBlocker,proto3" json:"max_gas_end_blocker,omitempty"` + InfractionTime uint64 `protobuf:"varint,4,opt,name=infraction_time,json=infractionTime,proto3" json:"infraction_time,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -124,33 +125,35 @@ func init() { } var fileDescriptor_53771980e3e4256c = []byte{ - // 416 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0xce, 0xb8, 0xcb, 0xe2, 0xce, 0xba, 0xa0, 0xd9, 0x05, 0x63, 0x59, 0x66, 0xd7, 0x9e, 0x8a, - 0x90, 0x84, 0xea, 0xad, 0xa0, 0x87, 0x16, 0x11, 0x41, 0x41, 0x22, 0xf4, 0xe0, 0x25, 0xbe, 0x4c, - 0xc6, 0x64, 0x68, 0x32, 0x13, 0x32, 0x53, 0x49, 0xff, 0x82, 0x27, 0x7f, 0x82, 0x47, 0x4f, 0xe2, - 0xcf, 0xe8, 0xb1, 0x47, 0x4f, 0xa2, 0xe9, 0x41, 0x7f, 0x86, 0x64, 0xd2, 0x54, 0x72, 0xeb, 0x65, - 0x78, 0xf3, 0xbd, 0xf9, 0xbe, 0xf9, 0x3e, 0xde, 0xc3, 0xbe, 0x54, 0xb9, 0x54, 0x5c, 0xf9, 0x39, - 0x53, 0xa9, 0x62, 0x74, 0x59, 0x72, 0xbd, 0xf2, 0x3f, 0x8e, 0x23, 0xa6, 0x61, 0xdc, 0x03, 0xbd, - 0xa2, 0x94, 0x5a, 0xda, 0x57, 0x3b, 0x82, 0xd7, 0xeb, 0xed, 0x08, 0x03, 0x42, 0x4d, 0xdb, 0x8f, - 0x40, 0xb1, 0xbd, 0x0a, 0x95, 0x5c, 0xb4, 0xec, 0xc1, 0x65, 0x22, 0x13, 0x69, 0x4a, 0xbf, 0xa9, - 0x76, 0xe8, 0x3d, 0xc8, 0xb9, 0x90, 0xbe, 0x39, 0x5b, 0x68, 0xf8, 0x0d, 0x61, 0x67, 0xce, 0x4b, - 0xbd, 0x84, 0xec, 0xad, 0x86, 0x05, 0x17, 0xc9, 0x6b, 0xa8, 0x66, 0x50, 0xbc, 0x14, 0x1f, 0xa4, - 0x3d, 0xc0, 0xb7, 0xa9, 0x14, 0xba, 0x04, 0xaa, 0x1d, 0x74, 0x83, 0x46, 0xa7, 0xc1, 0xfe, 0x6e, - 0x3f, 0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 0xf3, 0x6e, 0x91, 0xdc, 0x0c, 0xa2, 0x76, 0x9b, - 0xdc, 0x4e, 0xcf, 0x55, 0xf1, 0xc2, 0xaf, 0xfa, 0x1b, 0xa6, 0x57, 0x05, 0x53, 0xd1, 0x89, 0x19, - 0xf6, 0x93, 0x7f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x98, 0xcb, 0x62, 0xae, 0x86, 0x02, 0x00, 0x00, + // 444 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x3f, 0x6f, 0xd3, 0x40, + 0x1c, 0xf5, 0xd1, 0xa8, 0xa2, 0x57, 0xca, 0x9f, 0x6b, 0x25, 0x4c, 0x54, 0x5d, 0x43, 0x17, 0x22, + 0xa4, 0xd8, 0x0a, 0x6c, 0x95, 0x60, 0x48, 0x84, 0x10, 0x12, 0x48, 0xc8, 0xa0, 0x0e, 0x2c, 0xe6, + 0xe7, 0xf3, 0xd5, 0x39, 0xc5, 0x77, 0x67, 0xf9, 0x2e, 0x28, 0xfd, 0x0a, 0x4c, 0x7c, 0x04, 0x46, + 0x26, 0xc4, 0xc7, 0xc8, 0xd8, 0x91, 0x09, 0x41, 0x32, 0xc0, 0x57, 0x60, 0xab, 0x7c, 0x8e, 0x5b, + 0x79, 0xcb, 0x62, 0xfd, 0xfc, 0x7e, 0xf7, 0xde, 0xef, 0x3d, 0xe9, 0xe1, 0x50, 0x1b, 0xa9, 0x8d, + 0x30, 0xa1, 0xe4, 0x66, 0x62, 0x38, 0x9b, 0x95, 0xc2, 0x9e, 0x87, 0x9f, 0x86, 0x09, 0xb7, 0x30, + 0x6c, 0x81, 0x41, 0x51, 0x6a, 0xab, 0xc9, 0xe1, 0x9a, 0x10, 0xb4, 0x76, 0x6b, 0x42, 0x97, 0x32, + 0xb7, 0x0e, 0x13, 0x30, 0xfc, 0x4a, 0x85, 0x69, 0xa1, 0x6a, 0x76, 0x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30, 0x7f, 0x09, 0xe6, 0x85, 0x4a, 0x47, 0x35, 0x4e, 0x1e, 0xe1, 0x3b, 0x42, 0x9d, 0x55, + 0x37, 0x84, 0x56, 0xb1, 0x15, 0x92, 0xfb, 0x9d, 0x1e, 0xea, 0x77, 0xa2, 0xdb, 0xd7, 0xf0, 0x7b, + 0x21, 0xf9, 0xc9, 0x61, 0x95, 0xf1, 0xf3, 0xdf, 0x1f, 0x8f, 0xf7, 0x5b, 0x3d, 0xa9, 0x03, 0x8f, + 0x3e, 0x2e, 0xfe, 0x50, 0xef, 0xdb, 0x92, 0x7a, 0x8b, 0x25, 0x45, 0x17, 0x4b, 0x8a, 0x7e, 0x2f, + 0x29, 0xfa, 0xb2, 0xa2, 0xde, 0xc5, 0x8a, 0x7a, 0x3f, 0x57, 0xd4, 0xfb, 0xf0, 0x3c, 0x13, 0x76, + 0x32, 0x4b, 0x02, 0xa6, 0x65, 0xd3, 0xb8, 0x41, 0x0e, 0x49, 0x5d, 0xbb, 0x41, 0xa3, 0x37, 0x30, + 0xe9, 0x34, 0x9c, 0xb7, 0xab, 0x68, 0xcf, 0x0b, 0x6e, 0x92, 0x6d, 0xd7, 0x8a, 0xa7, 0x97, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x95, 0xad, 0x29, 0xf1, 0xaf, 0x02, 0x00, 0x00, } func (this *VirtualStakingMaxCapInfo) Equal(that interface{}) bool { @@ -211,6 +214,9 @@ func (this *Params) Equal(that interface{}) bool { if this.MaxGasEndBlocker != that1.MaxGasEndBlocker { return false } + if this.InfractionTime != that1.InfractionTime { + return false + } return true } func (m *VirtualStakingMaxCapInfo) Marshal() (dAtA []byte, err error) { @@ -283,6 +289,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.InfractionTime != 0 { + i = encodeVarintMeshsecurity(dAtA, i, uint64(m.InfractionTime)) + i-- + dAtA[i] = 0x20 + } if m.MaxGasEndBlocker != 0 { i = encodeVarintMeshsecurity(dAtA, i, uint64(m.MaxGasEndBlocker)) i-- @@ -348,6 +359,9 @@ func (m *Params) Size() (n int) { if m.MaxGasEndBlocker != 0 { n += 1 + sovMeshsecurity(uint64(m.MaxGasEndBlocker)) } + if m.InfractionTime != 0 { + n += 1 + sovMeshsecurity(uint64(m.InfractionTime)) + } return n } @@ -605,6 +619,25 @@ func (m *Params) Unmarshal(dAtA []byte) error { break } } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field InfractionTime", wireType) + } + m.InfractionTime = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowMeshsecurity + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.InfractionTime |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipMeshsecurity(dAtA[iNdEx:]) diff --git a/x/meshsecurity/types/params.go b/x/meshsecurity/types/params.go index 7835e6fb..022d834a 100644 --- a/x/meshsecurity/types/params.go +++ b/x/meshsecurity/types/params.go @@ -14,6 +14,7 @@ func DefaultParams(denom string) Params { TotalContractsMaxCap: sdk.NewCoin(denom, math.NewInt(10_000_000_000)), EpochLength: 1_000, MaxGasEndBlocker: 500_000, + InfractionTime: 0, } } diff --git a/x/provider/contract/in_message.go b/x/provider/contract/in_message.go new file mode 100644 index 00000000..ee5e99ec --- /dev/null +++ b/x/provider/contract/in_message.go @@ -0,0 +1,22 @@ +package contract + +import wasmvmtypes "github.com/CosmWasm/wasmvm/types" + +type ( + SudoMsg struct { + VaultSudoMsg *StakeMsg `json:"vault,omitempty"` + } + + StakeMsg struct { + StakeRemote `json:"stake_remote"` + StakeLocal `json:"stake_local"` + } + + StakeRemote struct { + Contract string `json:"contract"` + Amount wasmvmtypes.Coin `json:"amount"` + } + StakeLocal struct { + Amount wasmvmtypes.Coin `json:"amount"` + } +) diff --git a/x/provider/ibc_module.go b/x/provider/ibc_module.go index 5831716a..c67dffe8 100644 --- a/x/provider/ibc_module.go +++ b/x/provider/ibc_module.go @@ -14,6 +14,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + // transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" "github.com/osmosis-labs/mesh-security-sdk/x/provider/keeper" @@ -129,7 +130,7 @@ func (am AppModule) OnRecvPacket( ack := channeltypes.NewResultAcknowledgement([]byte{byte(1)}) var ackErr error - _, err := UnmarshalConsumerPacket(packet) + consumerPacket, err := UnmarshalConsumerPacket(packet) if err != nil { ackErr = errorsmod.Wrapf(sdkerrors.ErrInvalidType, "cannot unmarshal ConsumerPacket data") logger.Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence)) @@ -140,9 +141,69 @@ func (am AppModule) OnRecvPacket( sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), } - // only attempt the application logic if the packet data - // was successfully decoded if ack.Success() { + var err error + + switch consumerPacket.Type { + case cptypes.PipedValsetOperation_VALIDATOR_BONDED: + var ackResult cptypes.PacketAckResult + data := consumerPacket.GetSchedulePacketData() + ackResult, err = am.k.OnRecvBondedPacket(ctx, packet, data) + if err == nil { + ack = channeltypes.NewResultAcknowledgement(ackResult) + } + + case cptypes.PipedValsetOperation_VALIDATOR_UNBONDED: + var ackResult cptypes.PacketAckResult + data := consumerPacket.GetSchedulePacketData() + ackResult, err = am.k.OnRecvUnbondedPacket(ctx, packet, data) + if err == nil { + ack = channeltypes.NewResultAcknowledgement(ackResult) + } + case cptypes.PipedValsetOperation_VALIDATOR_JAILED: + var ackResult cptypes.PacketAckResult + data := consumerPacket.GetSchedulePacketData() + ackResult, err = am.k.OnRecvJailedPacket(ctx, packet, data) + if err == nil { + ack = channeltypes.NewResultAcknowledgement(ackResult) + } + case cptypes.PipedValsetOperation_VALIDATOR_TOMBSTONED: + var ackResult cptypes.PacketAckResult + data := consumerPacket.GetSchedulePacketData() + ackResult, err = am.k.OnRecvTombstonedPacket(ctx, packet, data) + if err == nil { + ack = channeltypes.NewResultAcknowledgement(ackResult) + } + case cptypes.PipedValsetOperation_VALIDATOR_UNJAILED: + var ackResult cptypes.PacketAckResult + data := consumerPacket.GetSchedulePacketData() + ackResult, err = am.k.OnRecvUnjailedPacket(ctx, packet, data) + if err == nil { + ack = channeltypes.NewResultAcknowledgement(ackResult) + } + case cptypes.PipedValsetOperation_VALIDATOR_MODIFIED: + var ackResult cptypes.PacketAckResult + data := consumerPacket.GetSchedulePacketData() + ackResult, err = am.k.OnRecvModifiedPacket(ctx, packet, data) + if err == nil { + ack = channeltypes.NewResultAcknowledgement(ackResult) + } + case cptypes.PipedValsetOperation_VALIDATOR_SLASHED: + var ackResult cptypes.PacketAckResult + data := consumerPacket.GetSlashPacketData() + ackResult, err = am.k.OnRecvSlashPacket(ctx, packet, *data) + if err == nil { + ack = channeltypes.NewResultAcknowledgement(ackResult) + } + default: + err = fmt.Errorf("invalid consumer packet type: %q", consumerPacket.Type) + } + + if err != nil { + ack = channeltypes.NewErrorAcknowledgement(err) + ackErr = err + logger.Error(fmt.Sprintf("%s sequence %d", ackErr.Error(), packet.Sequence)) + } } eventAttributes = append(eventAttributes, sdk.NewAttribute(cptypes.AttributeKeyAckSuccess, fmt.Sprintf("%t", ack.Success()))) diff --git a/x/provider/keeper/delegate.go b/x/provider/keeper/delegate.go new file mode 100644 index 00000000..d9b81e2b --- /dev/null +++ b/x/provider/keeper/delegate.go @@ -0,0 +1,63 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + // stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + "github.com/osmosis-labs/mesh-security-sdk/x/provider/contract" + "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" +) + +func (k Keeper) LocalStake(ctx sdk.Context, token sdk.Coin, valAddr string) error { + amount := wasmkeeper.ConvertSdkCoinToWasmCoin(token) + providerStakeMsg := contract.StakeMsg{ + StakeLocal: contract.StakeLocal{ + Amount: amount, + }, + } + + err := k.SendVaultStake(ctx, providerStakeMsg) + if err != nil { + return err + } + + contractAddr := k.GetContractWithNativeDenom(ctx, token.Denom) + inter, found := k.GetIntermediary(ctx, token.Denom) + if !found { + inter = types.NewIntermediary(valAddr, ctx.ChainID(), contractAddr.String(), false, false, types.Bonded, &token) + } else { + newAmout := inter.Token.Add(token) + inter.Token = &newAmout + } + k.SetIntermediary(ctx, inter) + return nil +} + +func (k Keeper) RemoteStake(ctx sdk.Context, denomDelegate string, token sdk.Coin) error { + contractAddr := k.GetContractWithNativeDenom(ctx, denomDelegate) + + amount := wasmkeeper.ConvertSdkCoinToWasmCoin(token) + + providerStakeMsg := contract.StakeMsg{ + StakeRemote: contract.StakeRemote{ + Amount: amount, + Contract: contractAddr.String(), + }, + } + err := k.SendVaultStake(ctx, providerStakeMsg) + if err != nil { + return err + } + + // TODO: validator addresss on consumer chain + inter, found := k.GetIntermediary(ctx, token.Denom) + if !found { + inter = types.NewIntermediary("", ctx.ChainID(), contractAddr.String(), false, false, types.Bonded, &token) + } else { + newAmout := inter.Token.Add(token) + inter.Token = &newAmout + } + k.SetIntermediary(ctx, inter) + return nil +} diff --git a/x/provider/keeper/keeper.go b/x/provider/keeper/keeper.go index 5d10068f..e83a86b7 100644 --- a/x/provider/keeper/keeper.go +++ b/x/provider/keeper/keeper.go @@ -7,21 +7,17 @@ import ( "github.com/cometbft/cometbft/libs/log" errorsmod "cosmossdk.io/errors" - // "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/store/prefix" "github.com/cosmos/cosmos-sdk/codec" - // "github.com/cosmos/cosmos-sdk/store/prefix" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - // sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - clienttypes "github.com/cosmos/ibc-go/v7/modules/core/02-client/types" conntypes "github.com/cosmos/ibc-go/v7/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" - // host "github.com/cosmos/ibc-go/v7/modules/core/24-host" ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" @@ -181,6 +177,16 @@ func (k Keeper) SetInitChainHeight(ctx sdk.Context, chainID string, height uint6 store.Set(types.InitChainHeightKey(chainID), heightBytes) } +func (k Keeper) GetInitChainHeight(ctx sdk.Context, chainID string) (uint64, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.InitChainHeightKey(chainID)) + if bz == nil { + return 0, false + } + + return binary.BigEndian.Uint64(bz), true +} + func (k Keeper) DeleteInitTimeoutTimestamp(ctx sdk.Context, chainID string) { store := ctx.KVStore(k.storeKey) store.Delete(types.InitTimeoutTimestampKey(chainID)) @@ -249,3 +255,83 @@ func (k Keeper) SetConsumerCommissionRate( store.Set(types.ConsumerCommissionRateKey(chainID, providerAddr), bz) return nil } + +func (k Keeper) SetDepositors(ctx sdk.Context, del types.Depositors) error { + store := ctx.KVStore(k.storeKey) + bz, err := types.ModuleCdc.Marshal(&del) + if err != nil { + err = fmt.Errorf("external staker marshalling failed: %s", err) + ModuleLogger(ctx).Error(err.Error()) + return err + } + store.Set(types.DepositorsKey(del.Address), bz) + + return nil +} + +func (k Keeper) GetDepositors(ctx sdk.Context, del string) (types.Depositors, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.DepositorsKey(del)) + if bz == nil { + return types.Depositors{}, false + } + var r types.Depositors + if err := r.Unmarshal(bz); err != nil { + panic(err) + } + return r, true +} + +func (k Keeper) iterateDepositors(ctx sdk.Context, cb func(depositors types.Depositors) bool) error { + pStore := prefix.NewStore(ctx.KVStore(k.memKey), types.DepositorsKeyPrefix) + iter := pStore.Iterator(nil, nil) + for ; iter.Valid(); iter.Next() { + var r types.Depositors + if err := r.Unmarshal(iter.Value()); err != nil { + panic(err) + } + if cb(r) { + break + } + } + return iter.Close() +} + +func (k Keeper) SetIntermediary(ctx sdk.Context, inter types.Intermediary) error { + store := ctx.KVStore(k.storeKey) + bz, err := types.ModuleCdc.Marshal(&inter) + if err != nil { + err = fmt.Errorf("external staker marshalling failed: %s", err) + ModuleLogger(ctx).Error(err.Error()) + return err + } + store.Set(types.IntermediaryKey(inter.Token.Denom), bz) + + return nil +} + +func (k Keeper) GetIntermediary(ctx sdk.Context, denom string) (types.Intermediary, bool) { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.IntermediaryKey(denom)) + if bz == nil { + return types.Intermediary{}, false + } + var r types.Intermediary + if err := r.Unmarshal(bz); err != nil { + panic(err) + } + return r, true +} + +func (k Keeper) GetContractWithNativeDenom(ctx sdk.Context, denom string) sdk.AccAddress { + var contractAddr sdk.AccAddress + + store := ctx.KVStore(k.storeKey) + contractAddr = store.Get(types.ContractWithNativeDenomKey(denom)) + return contractAddr +} + +func (k Keeper) SetContractWithNativeDenom(ctx sdk.Context, denom string, contractAddr sdk.AccAddress) { + store := ctx.KVStore(k.storeKey) + store.Set(types.ContractWithNativeDenomKey(denom), contractAddr) +} diff --git a/x/provider/keeper/keeper_test.go b/x/provider/keeper/keeper_test.go new file mode 100644 index 00000000..0a4b9493 --- /dev/null +++ b/x/provider/keeper/keeper_test.go @@ -0,0 +1,56 @@ +package keeper + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/stretchr/testify/require" +) + +func TestStoreDelegator(t *testing.T) { + pCtx, keepers := CreateDefaultTestInput(t) + k := keepers.MeshKeeperProvider + + d1 := types.Depositors{ + Address: "delegate", + Tokens: sdk.NewCoins([]sdk.Coin{sdk.NewCoin("osmo", sdk.NewInt(123))}...), + } + err := k.SetDepositors(pCtx, d1) + require.NoError(t, err) + + d2, f := k.GetDepositors(pCtx, d1.Address) + require.True(t, f) + require.Equal(t, d1, d2) + + d2.Tokens = d2.Tokens.Add(sdk.NewCoin("juno", sdk.NewInt(10000))) + d2.Tokens = d2.Tokens.Add(sdk.NewCoin("juno", sdk.NewInt(10000))) + err = k.SetDepositors(pCtx, d2) + require.NoError(t, err) + + d3, f := k.GetDepositors(pCtx, d1.Address) + require.True(t, f) + require.Equal(t, sdk.NewInt(20000), d3.Tokens.AmountOf("juno")) +} + +func TestStoreIntermediary(t *testing.T) { + pCtx, keepers := CreateDefaultTestInput(t) + k := keepers.MeshKeeperProvider + + coin := sdk.NewCoin("osmo", sdk.NewInt(123)) + e1 := types.Intermediary{ + ConsumerValidator: "validator", + ChainId: "osmo-1", + ContractAddress: "address", + Jailed: false, + Tombstoned: false, + Status: types.Bonded, + Token: &coin, + } + err := k.SetIntermediary(pCtx, e1) + require.NoError(t, err) + + e2, f := k.GetIntermediary(pCtx, e1.Token.Denom) + require.True(t, f) + require.Equal(t, e1, e2) +} diff --git a/x/provider/keeper/msg_server.go b/x/provider/keeper/msg_server.go index 42afe6ec..41e5c125 100644 --- a/x/provider/keeper/msg_server.go +++ b/x/provider/keeper/msg_server.go @@ -2,6 +2,7 @@ package keeper import ( "context" + "fmt" sdk "github.com/cosmos/cosmos-sdk/types" @@ -32,3 +33,65 @@ func (k msgServer) SetConsumerCommissionRate(goCtx context.Context, msg *types.M return &types.MsgSetConsumerCommissionRateResponse{}, nil } + +func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*types.MsgDelegateResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + err := msg.Amount.Validate() + if err != nil { + return nil, fmt.Errorf("failed to delegate; Validate fail") + } + denomDelegate := msg.Amount.Denom + + vaultAdress := sdk.AccAddress(k.Keeper.GetParams(ctx).GetVaultContractAddress()) + delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return nil, err + } + + balance := k.bank.GetBalance(ctx, delegatorAddress, denomDelegate) + + if balance.IsLT(msg.Amount) { + return nil, fmt.Errorf("failed to delegate; %s is smaller than %s", balance, msg.Amount) + } + + if err := k.bank.SendCoins(ctx, delegatorAddress, vaultAdress, sdk.NewCoins([]sdk.Coin{msg.Amount}...)); err != nil { + return nil, err + } + + bondDenom := k.Staking.BondDenom(ctx) + if denomDelegate == bondDenom { + // local stake + err = k.Keeper.LocalStake(ctx, msg.Amount, msg.ValidatorAddress) + if err != nil { + // if fail refunds + k.bank.SendCoins(ctx, vaultAdress, delegatorAddress, sdk.NewCoins([]sdk.Coin{msg.Amount}...)) + return nil, err + } + } else { + // remote stake + err := k.Keeper.RemoteStake(ctx, denomDelegate, msg.Amount) + if err != nil { + // if fail refunds + k.bank.SendCoins(ctx, vaultAdress, delegatorAddress, sdk.NewCoins([]sdk.Coin{msg.Amount}...)) + return nil, err + } + } + + depositors, found := k.Keeper.GetDepositors(ctx, msg.DelegatorAddress) + if !found { + depositors = types.NewDepositors(msg.DelegatorAddress, []sdk.Coin{msg.Amount}) + } else { + depositors.Tokens = depositors.Tokens.Add(msg.Amount) + } + err = k.Keeper.SetDepositors(ctx, depositors) + if err != nil { + return nil, err + } + + return &types.MsgDelegateResponse{}, nil +} + +func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) (*types.MsgUndelegateResponse, error) { + return &types.MsgUndelegateResponse{}, nil +} diff --git a/x/provider/keeper/relay.go b/x/provider/keeper/relay.go index f6732a37..e1f4f654 100644 --- a/x/provider/keeper/relay.go +++ b/x/provider/keeper/relay.go @@ -2,6 +2,8 @@ package keeper import ( "fmt" + "strconv" + channeltypes "github.com/cosmos/ibc-go/v7/modules/core/04-channel/types" errorsmod "cosmossdk.io/errors" @@ -9,6 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" ) func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet) error { @@ -58,3 +61,161 @@ func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Pac } return nil } + +func (k Keeper) OnRecvSlashPacket( + ctx sdk.Context, + packet channeltypes.Packet, + data cptypes.SlashInfo, +) (cptypes.PacketAckResult, error) { + chainID, found := k.GetChannelToChain(ctx, packet.DestinationChannel) + if !found { + ModuleLogger(ctx).Error("SlashPacket received on unknown channel", + "channelID", packet.DestinationChannel, + ) + panic(fmt.Errorf("SlashPacket received on unknown channel %s", packet.DestinationChannel)) + } + // validate packet data upon receiving + if err := data.Validate(); err != nil { + return nil, errorsmod.Wrapf(err, "error validating SlashPacket data") + } + + if err := k.ValidateSlashPacket(ctx, chainID); err != nil { + ModuleLogger(ctx).Error("invalid slash packet", + "error", err.Error(), + "chainID", chainID, + ) + return nil, err + } + + k.HandleSlashPacket(ctx, chainID, data) + + ModuleLogger(ctx).Info("slash packet received and handled", + "chainID", chainID, + "consumer val addr", data.Validator, + ) + return cptypes.SlashPacketHandledResult, nil +} + +func (k Keeper) OnRecvBondedPacket( + ctx sdk.Context, + packet channeltypes.Packet, + data *cptypes.ScheduleInfo, +) (cptypes.PacketAckResult, error) { + + return cptypes.SlashPacketHandledResult, nil +} + +func (k Keeper) OnRecvUnbondedPacket( + ctx sdk.Context, + packet channeltypes.Packet, + data *cptypes.ScheduleInfo, +) (cptypes.PacketAckResult, error) { + + return cptypes.SlashPacketHandledResult, nil +} + +func (k Keeper) OnRecvJailedPacket( + ctx sdk.Context, + packet channeltypes.Packet, + data *cptypes.ScheduleInfo, +) (cptypes.PacketAckResult, error) { + + return cptypes.SlashPacketHandledResult, nil +} + +func (k Keeper) OnRecvTombstonedPacket( + ctx sdk.Context, + packet channeltypes.Packet, + data *cptypes.ScheduleInfo, +) (cptypes.PacketAckResult, error) { + + return cptypes.SlashPacketHandledResult, nil +} +func (k Keeper) OnRecvUnjailedPacket( + ctx sdk.Context, + packet channeltypes.Packet, + data *cptypes.ScheduleInfo, +) (cptypes.PacketAckResult, error) { + + return cptypes.SlashPacketHandledResult, nil +} +func (k Keeper) OnRecvModifiedPacket( + ctx sdk.Context, + packet channeltypes.Packet, + data *cptypes.ScheduleInfo, +) (cptypes.PacketAckResult, error) { + + return cptypes.SlashPacketHandledResult, nil +} + +func (k Keeper) HandleSlashPacket(ctx sdk.Context, chainID string, data cptypes.SlashInfo) { + totalSlashAmount, err := sdk.ParseCoinNormalized(data.TotalSlashAmount) + if err != nil { + ModuleLogger(ctx).Error("Handle slash packet fail: ParseCoinsNormalized fail") + return + } + denom := totalSlashAmount.Denom + intermediary, found := k.GetIntermediary(ctx, denom) + if !found { + ModuleLogger(ctx).Error("External Staker not found for validor", + data.Validator, + ) + panic(fmt.Errorf("external Staker not found for validor %s", data.Validator)) + } + + if intermediary.IsUnboned() { + ModuleLogger(ctx).Error("validator is unbonded") + return + } + + if intermediary.IsTombstoned() { + ModuleLogger(ctx).Info( + "slash packet dropped because validator is already tombstoned", + ) + return + } + if intermediary.IsJailed() { + ModuleLogger(ctx).Info("validator jailed") + return + } + + intermediary.Jailed = true + slashRatio := sdk.MustNewDecFromStr(data.SlashFraction) + amountSlash := slashRatio.MulInt(intermediary.Token.Amount).TruncateInt() + newAmount := sdk.NewCoin(denom, amountSlash) + intermediary.Token = &newAmount + k.SetIntermediary(ctx, intermediary) + + k.iterateDepositors(ctx, func(depositors types.Depositors) bool { + amout := depositors.Tokens.AmountOf(denom) + if amout.GT(sdk.ZeroInt()) { + amountSlash = slashRatio.MulInt(amout).TruncateInt() + tokenSlash := sdk.NewCoin(denom, amountSlash) + newTokens := depositors.Tokens.Sub(tokenSlash) + depositors.Tokens = newTokens + + k.SetDepositors(ctx, depositors) + } + return false + }) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeExecuteConsumerChainSlash, + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), + sdk.NewAttribute(types.AttributeInfractionHeight, strconv.FormatInt(data.InfractionHeight, 10)), + sdk.NewAttribute(types.AttributeConsumerValidator, data.Validator), + ), + ) +} + +func (k Keeper) ValidateSlashPacket(ctx sdk.Context, chainID string, +) error { + _, found := k.GetInitChainHeight(ctx, chainID) + // return error if we cannot find infraction height matching the validator update id + if !found { + return fmt.Errorf("cannot find infraction height matching "+ + "for chain %s", chainID) + } + + return nil +} diff --git a/x/provider/keeper/relay_test.go b/x/provider/keeper/relay_test.go new file mode 100644 index 00000000..b55569d4 --- /dev/null +++ b/x/provider/keeper/relay_test.go @@ -0,0 +1 @@ +package keeper diff --git a/x/provider/keeper/test_common.go b/x/provider/keeper/test_common.go new file mode 100644 index 00000000..b7728332 --- /dev/null +++ b/x/provider/keeper/test_common.go @@ -0,0 +1,316 @@ +package keeper + +import ( + "testing" + "time" + + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + "github.com/CosmWasm/wasmd/x/wasm/keeper/wasmtesting" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + dbm "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + "github.com/cometbft/cometbft/libs/rand" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + ibctransfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" + ibcexported "github.com/cosmos/ibc-go/v7/modules/core/exported" + ibckeeper "github.com/cosmos/ibc-go/v7/modules/core/keeper" + "github.com/stretchr/testify/require" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + codec2 "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/std" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + "github.com/cosmos/cosmos-sdk/testutil/mock" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/address" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/cosmos/cosmos-sdk/x/auth" + authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" + "github.com/cosmos/cosmos-sdk/x/auth/tx" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" + "github.com/cosmos/cosmos-sdk/x/bank" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" + capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" + distributionkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper" + distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types" + evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + "github.com/cosmos/cosmos-sdk/x/feegrant" + "github.com/cosmos/cosmos-sdk/x/gov" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/cosmos/cosmos-sdk/x/mint" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + paramsclient "github.com/cosmos/cosmos-sdk/x/params/client" + paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper" + slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" + "github.com/cosmos/cosmos-sdk/x/staking" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client" + upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" + upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + + "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" +) + +type encodingConfig struct { + InterfaceRegistry codectypes.InterfaceRegistry + Marshaler codec.Codec + TxConfig client.TxConfig + Amino *codec.LegacyAmino +} + +var moduleBasics = module.NewBasicManager( + auth.AppModuleBasic{}, + bank.AppModuleBasic{}, + staking.AppModuleBasic{}, + mint.AppModuleBasic{}, + gov.NewAppModuleBasic([]govclient.ProposalHandler{ + paramsclient.ProposalHandler, + upgradeclient.LegacyProposalHandler, + upgradeclient.LegacyCancelProposalHandler, + }), +) + +func makeEncodingConfig(_ testing.TB) encodingConfig { + amino := codec.NewLegacyAmino() + interfaceRegistry := codectypes.NewInterfaceRegistry() + marshaler := codec.NewProtoCodec(interfaceRegistry) + std.RegisterInterfaces(interfaceRegistry) + std.RegisterLegacyAminoCodec(amino) + + moduleBasics.RegisterLegacyAminoCodec(amino) + moduleBasics.RegisterInterfaces(interfaceRegistry) + // add mesh-security types + types.RegisterInterfaces(interfaceRegistry) + types.RegisterLegacyAminoCodec(amino) + + return encodingConfig{ + InterfaceRegistry: interfaceRegistry, + Marshaler: marshaler, + TxConfig: tx.NewTxConfig(marshaler, tx.DefaultSignModes), + Amino: amino, + } +} + +type TestKeepers struct { + StakingKeeper *stakingkeeper.Keeper + SlashingKeeper slashingkeeper.Keeper + BankKeeper bankkeeper.Keeper + StoreKey *storetypes.KVStoreKey + EncodingConfig encodingConfig + MeshKeeperProvider *Keeper + AccountKeeper authkeeper.AccountKeeper + WasmKeeper *wasmkeeper.Keeper + Faucet *wasmkeeper.TestFaucet +} + +func CreateDefaultTestInput(t testing.TB, opts ...Option) (sdk.Context, TestKeepers) { + db := dbm.NewMemDB() + ms := store.NewCommitMultiStore(db) + keys := sdk.NewKVStoreKeys( + authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey, + minttypes.StoreKey, distributiontypes.StoreKey, slashingtypes.StoreKey, + govtypes.StoreKey, paramstypes.StoreKey, ibcexported.StoreKey, upgradetypes.StoreKey, + evidencetypes.StoreKey, ibctransfertypes.StoreKey, + capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, + wasmtypes.StoreKey, types.StoreKey, + ) + for _, v := range keys { + ms.MountStoreWithDB(v, storetypes.StoreTypeIAVL, db) + } + memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey, types.MemStoreKey) + for _, v := range memKeys { + ms.MountStoreWithDB(v, storetypes.StoreTypeMemory, db) + } + tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) + for _, v := range tkeys { + ms.MountStoreWithDB(v, storetypes.StoreTypeTransient, db) + } + require.NoError(t, ms.LoadLatestVersion()) + + encConfig := makeEncodingConfig(t) + appCodec := encConfig.Marshaler + + maccPerms := map[string][]string{ // module account permissions + authtypes.FeeCollectorName: nil, + distributiontypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter}, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + types.ModuleName: {authtypes.Minter, authtypes.Burner}, + } + authority := authtypes.NewModuleAddress(govtypes.ModuleName).String() + accountKeeper := authkeeper.NewAccountKeeper( + appCodec, + keys[authtypes.StoreKey], // target store + authtypes.ProtoBaseAccount, // prototype + maccPerms, + sdk.Bech32MainPrefix, + authority, + ) + blockedAddrs := make(map[string]bool) + for acc := range maccPerms { + blockedAddrs[authtypes.NewModuleAddress(acc).String()] = true + } + ctx := sdk.NewContext(ms, tmproto.Header{ + Height: 1234567, + Time: time.Date(2020, time.April, 22, 12, 0, 0, 0, time.UTC), + }, false, log.NewNopLogger()) + + bankKeeper := bankkeeper.NewBaseKeeper( + appCodec, + keys[banktypes.StoreKey], + accountKeeper, + blockedAddrs, + authority, + ) + require.NoError(t, bankKeeper.SetParams(ctx, banktypes.DefaultParams())) + + stakingKeeper := stakingkeeper.NewKeeper( + appCodec, + keys[stakingtypes.StoreKey], + accountKeeper, + bankKeeper, + authority, + ) + require.NoError(t, stakingKeeper.SetParams(ctx, stakingtypes.DefaultParams())) + + slashingKeeper := slashingkeeper.NewKeeper( + appCodec, + encConfig.Amino, + keys[slashingtypes.StoreKey], + stakingKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + require.NoError(t, slashingKeeper.SetParams(ctx, slashingtypes.DefaultParams())) + + distKeeper := distributionkeeper.NewKeeper( + appCodec, + keys[distributiontypes.StoreKey], + accountKeeper, + bankKeeper, + stakingKeeper, + authtypes.FeeCollectorName, + authtypes.NewModuleAddress(distributiontypes.ModuleName).String(), + ) + require.NoError(t, distKeeper.SetParams(ctx, distributiontypes.DefaultParams())) + + querier := baseapp.NewGRPCQueryRouter() + querier.SetInterfaceRegistry(encConfig.InterfaceRegistry) + msgRouter := baseapp.NewMsgServiceRouter() + msgRouter.SetInterfaceRegistry(encConfig.InterfaceRegistry) + + capabilityKeeper := capabilitykeeper.NewKeeper( + appCodec, + keys[capabilitytypes.StoreKey], + memKeys[capabilitytypes.MemStoreKey], + ) + scopedIBCKeeper := capabilityKeeper.ScopeToModule(ibcexported.ModuleName) + scopedWasmKeeper := capabilityKeeper.ScopeToModule(types.ModuleName) + + paramsKeeper := paramskeeper.NewKeeper( + appCodec, + encConfig.Amino, + keys[paramstypes.StoreKey], + tkeys[paramstypes.TStoreKey], + ) + + upgradeKeeper := upgradekeeper.NewKeeper( + map[int64]bool{}, + keys[upgradetypes.StoreKey], + appCodec, + t.TempDir(), + nil, + authtypes.NewModuleAddress(upgradetypes.ModuleName).String(), + ) + + ibcKeeper := ibckeeper.NewKeeper( + appCodec, + keys[ibcexported.StoreKey], + paramsKeeper.Subspace(ibcexported.ModuleName), + stakingKeeper, + upgradeKeeper, + scopedIBCKeeper, + ) + + cfg := sdk.GetConfig() + cfg.SetAddressVerifier(wasmtypes.VerifyAddressLen()) + + wasmKeeper := wasmkeeper.NewKeeper( + appCodec, + keys[wasmtypes.StoreKey], + accountKeeper, + bankKeeper, + stakingKeeper, + distributionkeeper.NewQuerier(distKeeper), + ibcKeeper.ChannelKeeper, // ICS4Wrapper + ibcKeeper.ChannelKeeper, + &ibcKeeper.PortKeeper, + scopedWasmKeeper, + wasmtesting.MockIBCTransferKeeper{}, + msgRouter, + querier, + t.TempDir(), + wasmtypes.DefaultWasmConfig(), + "iterator,staking,stargate,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_3,virtual_staking", + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + require.NoError(t, wasmKeeper.SetParams(ctx, wasmtypes.DefaultParams())) + + meshKeeperProvider := NewKeeper( + appCodec, + keys[types.StoreKey], + memKeys[types.MemStoreKey], + bankKeeper, + stakingKeeper, + wasmKeeper, + scopedWasmKeeper, + ibcKeeper.ChannelKeeper, + authority, + opts..., + ) + require.NoError(t, meshKeeperProvider.SetParams(ctx, types.DefaultParams(sdk.DefaultBondDenom))) + + faucet := wasmkeeper.NewTestFaucet(t, ctx, bankKeeper, minttypes.ModuleName, sdk.NewInt64Coin(sdk.DefaultBondDenom, 1_000_000_000_000)) + return ctx, TestKeepers{ + AccountKeeper: accountKeeper, + StakingKeeper: stakingKeeper, + SlashingKeeper: slashingKeeper, + BankKeeper: bankKeeper, + StoreKey: keys[types.StoreKey], + EncodingConfig: encConfig, + MeshKeeperProvider: meshKeeperProvider, + WasmKeeper: &wasmKeeper, + Faucet: faucet, + } +} + +// MinValidatorFixture creates minimal sdk validator object +func MinValidatorFixture(t *testing.T) stakingtypes.Validator { + t.Helper() + privVal := mock.NewPV() + pubKey, err := privVal.GetPubKey() + require.NoError(t, err) + + pk, err := codec2.FromTmPubKeyInterface(pubKey) + require.NoError(t, err) + pkAny, err := codectypes.NewAnyWithValue(pk) + require.NoError(t, err) + + return stakingtypes.Validator{ + ConsensusPubkey: pkAny, + OperatorAddress: sdk.ValAddress(rand.Bytes(address.Len)).String(), + } +} diff --git a/x/provider/keeper/wasm.go b/x/provider/keeper/wasm.go new file mode 100644 index 00000000..e91b681e --- /dev/null +++ b/x/provider/keeper/wasm.go @@ -0,0 +1,28 @@ +package keeper + +import ( + "encoding/json" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/mesh-security-sdk/x/provider/contract" +) + +func (k Keeper) SendVaultStake(ctx sdk.Context, v contract.StakeMsg) error { + msg := contract.SudoMsg{ + VaultSudoMsg: &v, + } + + return k.doSudoCall(ctx, k.GetParams(ctx).GetVaultContractAddress(), msg) +} + +func (k Keeper) doSudoCall(ctx sdk.Context, contractAddr sdk.AccAddress, msg contract.SudoMsg) error { + bz, err := json.Marshal(msg) + if err != nil { + return errorsmod.Wrap(err, "marshal sudo msg") + } + _, err = k.wasm.Sudo(ctx, contractAddr, bz) + return err +} diff --git a/x/provider/types/delegate.go b/x/provider/types/delegate.go new file mode 100644 index 00000000..8689242a --- /dev/null +++ b/x/provider/types/delegate.go @@ -0,0 +1,34 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +func (e Intermediary) IsTombstoned() bool { + return e.Tombstoned +} + +func (e Intermediary) IsUnboned() bool { + return e.Status == Unbonded +} + +func (e Intermediary) IsJailed() bool { + return e.Jailed +} + +func NewIntermediary(consumerValidator, chainID, contractAddress string, jailed, tombstoned bool, status BondStatus, token *sdk.Coin) Intermediary { + return Intermediary{ + ConsumerValidator: consumerValidator, + ContractAddress: contractAddress, + ChainId: chainID, + Jailed: jailed, + Tombstoned: tombstoned, + Status: status, + Token: token, + } +} + +func NewDepositors(address string, tokens sdk.Coins) Depositors { + return Depositors{ + Address: address, + Tokens: tokens, + } +} diff --git a/x/provider/types/delegate.pb.go b/x/provider/types/delegate.pb.go new file mode 100644 index 00000000..0161d884 --- /dev/null +++ b/x/provider/types/delegate.pb.go @@ -0,0 +1,833 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/provider/v1beta1/delegate.proto + +package types + +import ( + fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 + +// BondStatus is the status of a validator. +type BondStatus int32 + +const ( + // UNSPECIFIED defines an invalid validator status. + Unspecified BondStatus = 0 + // UNBONDED defines a validator that is not bonded. + Unbonded BondStatus = 1 + // UNBONDING defines a validator that is unbonding. + Unbonding BondStatus = 2 + // BONDED defines a validator that is bonded. + Bonded BondStatus = 3 +) + +var BondStatus_name = map[int32]string{ + 0: "BOND_STATUS_UNSPECIFIED", + 1: "BOND_STATUS_UNBONDED", + 2: "BOND_STATUS_UNBONDING", + 3: "BOND_STATUS_BONDED", +} + +var BondStatus_value = map[string]int32{ + "BOND_STATUS_UNSPECIFIED": 0, + "BOND_STATUS_UNBONDED": 1, + "BOND_STATUS_UNBONDING": 2, + "BOND_STATUS_BONDED": 3, +} + +func (x BondStatus) String() string { + return proto.EnumName(BondStatus_name, int32(x)) +} + +func (BondStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_cd75e4a5b29b30f7, []int{0} +} + +// Params defines the parameters for the x/meshsecurity module. +type Depositors struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Tokens github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=tokens,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tokens"` +} + +func (m *Depositors) Reset() { *m = Depositors{} } +func (m *Depositors) String() string { return proto.CompactTextString(m) } +func (*Depositors) ProtoMessage() {} +func (*Depositors) Descriptor() ([]byte, []int) { + return fileDescriptor_cd75e4a5b29b30f7, []int{0} +} +func (m *Depositors) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Depositors) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Depositors.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 *Depositors) XXX_Merge(src proto.Message) { + xxx_messageInfo_Depositors.Merge(m, src) +} +func (m *Depositors) XXX_Size() int { + return m.Size() +} +func (m *Depositors) XXX_DiscardUnknown() { + xxx_messageInfo_Depositors.DiscardUnknown(m) +} + +var xxx_messageInfo_Depositors proto.InternalMessageInfo + +// vault-staker +type Intermediary struct { + ConsumerValidator string `protobuf:"bytes,1,opt,name=consumer_validator,json=consumerValidator,proto3" json:"consumer_validator,omitempty"` + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + ContractAddress string `protobuf:"bytes,3,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` + Jailed bool `protobuf:"varint,4,opt,name=jailed,proto3" json:"jailed,omitempty"` + Tombstoned bool `protobuf:"varint,5,opt,name=tombstoned,proto3" json:"tombstoned,omitempty"` + Status BondStatus `protobuf:"varint,6,opt,name=status,proto3,enum=osmosis.provider.v1beta1.BondStatus" json:"status,omitempty"` + Token *types.Coin `protobuf:"bytes,7,opt,name=token,proto3" json:"token,omitempty"` +} + +func (m *Intermediary) Reset() { *m = Intermediary{} } +func (m *Intermediary) String() string { return proto.CompactTextString(m) } +func (*Intermediary) ProtoMessage() {} +func (*Intermediary) Descriptor() ([]byte, []int) { + return fileDescriptor_cd75e4a5b29b30f7, []int{1} +} +func (m *Intermediary) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Intermediary) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Intermediary.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 *Intermediary) XXX_Merge(src proto.Message) { + xxx_messageInfo_Intermediary.Merge(m, src) +} +func (m *Intermediary) XXX_Size() int { + return m.Size() +} +func (m *Intermediary) XXX_DiscardUnknown() { + xxx_messageInfo_Intermediary.DiscardUnknown(m) +} + +var xxx_messageInfo_Intermediary proto.InternalMessageInfo + +func init() { + proto.RegisterEnum("osmosis.provider.v1beta1.BondStatus", BondStatus_name, BondStatus_value) + proto.RegisterType((*Depositors)(nil), "osmosis.provider.v1beta1.Depositors") + proto.RegisterType((*Intermediary)(nil), "osmosis.provider.v1beta1.Intermediary") +} + +func init() { + proto.RegisterFile("osmosis/provider/v1beta1/delegate.proto", fileDescriptor_cd75e4a5b29b30f7) +} + +var fileDescriptor_cd75e4a5b29b30f7 = []byte{ + // 574 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xc7, 0xbd, 0x69, 0xeb, 0xb6, 0xdb, 0x42, 0xd3, 0x55, 0x01, 0xd7, 0x07, 0xd7, 0xaa, 0x10, + 0x98, 0x8a, 0xd8, 0x6a, 0x11, 0x17, 0xc4, 0xa5, 0x69, 0x0a, 0xca, 0xa5, 0xa0, 0xa4, 0xe1, 0x80, + 0x90, 0xa2, 0xb5, 0x77, 0x49, 0x96, 0xc6, 0xbb, 0x91, 0x77, 0x13, 0x91, 0x37, 0x40, 0x39, 0xf5, + 0x05, 0x72, 0xe2, 0x52, 0xf5, 0xc4, 0x89, 0x67, 0xc8, 0xb1, 0x47, 0x4e, 0x7c, 0x24, 0x07, 0x5e, + 0x03, 0x65, 0x6d, 0xd3, 0x20, 0x04, 0x17, 0x7b, 0x3e, 0x7e, 0x33, 0xfa, 0xcf, 0x78, 0x0c, 0xef, + 0x0b, 0x19, 0x0b, 0xc9, 0x64, 0xd0, 0x4d, 0x44, 0x9f, 0x11, 0x9a, 0x04, 0xfd, 0xfd, 0x90, 0x2a, + 0xbc, 0x1f, 0x10, 0xda, 0xa1, 0x2d, 0xac, 0xa8, 0xdf, 0x4d, 0x84, 0x12, 0xc8, 0xca, 0x40, 0x3f, + 0x07, 0xfd, 0x0c, 0xb4, 0x9d, 0x48, 0xa7, 0x82, 0x10, 0x4b, 0xfa, 0xbb, 0x3a, 0x12, 0x8c, 0xa7, + 0x95, 0xf6, 0x56, 0x4b, 0xb4, 0x84, 0x36, 0x83, 0x99, 0x95, 0x45, 0x37, 0x71, 0xcc, 0xb8, 0x08, + 0xf4, 0x33, 0x0d, 0xed, 0x9e, 0x03, 0x08, 0x2b, 0xb4, 0x2b, 0x24, 0x53, 0x22, 0x91, 0xc8, 0x82, + 0xcb, 0x98, 0x90, 0x84, 0x4a, 0x69, 0x01, 0x17, 0x78, 0xab, 0xb5, 0xdc, 0x45, 0x6d, 0x68, 0x2a, + 0x71, 0x46, 0xb9, 0xb4, 0x0a, 0xee, 0x82, 0xb7, 0x76, 0xb0, 0xed, 0xa7, 0x12, 0xfc, 0x99, 0x84, + 0x5c, 0x97, 0x7f, 0x24, 0x18, 0x2f, 0x3f, 0x1e, 0x7f, 0xdd, 0x31, 0x2e, 0xbf, 0xed, 0x78, 0x2d, + 0xa6, 0xda, 0xbd, 0xd0, 0x8f, 0x44, 0x1c, 0x64, 0x7a, 0xd3, 0x57, 0x49, 0x92, 0xb3, 0x40, 0x0d, + 0xba, 0x54, 0xea, 0x02, 0x79, 0xf1, 0xf3, 0xd3, 0x1e, 0xa8, 0x65, 0xfd, 0x77, 0x2f, 0x0b, 0x70, + 0xbd, 0xca, 0x15, 0x4d, 0x62, 0x4a, 0x18, 0x4e, 0x06, 0xa8, 0x04, 0x51, 0x24, 0xb8, 0xec, 0xc5, + 0x34, 0x69, 0xf6, 0x71, 0x87, 0x11, 0xac, 0x44, 0x92, 0xe9, 0xd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, + 0x93, 0xe7, 0xc5, 0x82, 0x7d, 0x63, 0x38, 0x72, 0x57, 0x53, 0x90, 0xf1, 0x16, 0xda, 0x85, 0x68, + 0x9e, 0xcc, 0xfa, 0x2d, 0xd8, 0x70, 0x38, 0x72, 0xcd, 0xb2, 0xee, 0x66, 0x2f, 0x7e, 0xf8, 0xe8, + 0x18, 0xe5, 0x37, 0xe3, 0x1f, 0x8e, 0x71, 0x31, 0x71, 0x8c, 0xf1, 0xc4, 0x01, 0x57, 0x13, 0x07, + 0x7c, 0x9f, 0x38, 0xe0, 0x7c, 0xea, 0x18, 0x57, 0x53, 0xc7, 0xf8, 0x32, 0x75, 0x8c, 0xd7, 0x4f, + 0xe6, 0xce, 0x27, 0xdb, 0x61, 0xa9, 0x83, 0x43, 0x19, 0xc4, 0x54, 0xb6, 0x4b, 0x92, 0x46, 0xbd, + 0x84, 0xa9, 0x81, 0xbe, 0xa5, 0xf7, 0xd7, 0xbf, 0x92, 0x3e, 0xab, 0xd0, 0xd4, 0xd7, 0xfd, 0xe8, + 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x83, 0xdd, 0x14, 0x3d, 0x6b, 0x03, 0x00, 0x00, +} + +func (m *Depositors) 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 *Depositors) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Depositors) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Tokens) > 0 { + for iNdEx := len(m.Tokens) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Tokens[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDelegate(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintDelegate(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Intermediary) 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 *Intermediary) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Intermediary) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Token != nil { + { + size, err := m.Token.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintDelegate(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + if m.Status != 0 { + i = encodeVarintDelegate(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x30 + } + if m.Tombstoned { + i-- + if m.Tombstoned { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x28 + } + if m.Jailed { + i-- + if m.Jailed { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if len(m.ContractAddress) > 0 { + i -= len(m.ContractAddress) + copy(dAtA[i:], m.ContractAddress) + i = encodeVarintDelegate(dAtA, i, uint64(len(m.ContractAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.ChainId) > 0 { + i -= len(m.ChainId) + copy(dAtA[i:], m.ChainId) + i = encodeVarintDelegate(dAtA, i, uint64(len(m.ChainId))) + i-- + dAtA[i] = 0x12 + } + if len(m.ConsumerValidator) > 0 { + i -= len(m.ConsumerValidator) + copy(dAtA[i:], m.ConsumerValidator) + i = encodeVarintDelegate(dAtA, i, uint64(len(m.ConsumerValidator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintDelegate(dAtA []byte, offset int, v uint64) int { + offset -= sovDelegate(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Depositors) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovDelegate(uint64(l)) + } + if len(m.Tokens) > 0 { + for _, e := range m.Tokens { + l = e.Size() + n += 1 + l + sovDelegate(uint64(l)) + } + } + return n +} + +func (m *Intermediary) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ConsumerValidator) + if l > 0 { + n += 1 + l + sovDelegate(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovDelegate(uint64(l)) + } + l = len(m.ContractAddress) + if l > 0 { + n += 1 + l + sovDelegate(uint64(l)) + } + if m.Jailed { + n += 2 + } + if m.Tombstoned { + n += 2 + } + if m.Status != 0 { + n += 1 + sovDelegate(uint64(m.Status)) + } + if m.Token != nil { + l = m.Token.Size() + n += 1 + l + sovDelegate(uint64(l)) + } + return n +} + +func sovDelegate(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozDelegate(x uint64) (n int) { + return sovDelegate(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Depositors) 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 ErrIntOverflowDelegate + } + 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: Depositors: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Depositors: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDelegate + } + 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 ErrInvalidLengthDelegate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDelegate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tokens", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDelegate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDelegate + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDelegate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Tokens = append(m.Tokens, types.Coin{}) + if err := m.Tokens[len(m.Tokens)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDelegate(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDelegate + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Intermediary) 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 ErrIntOverflowDelegate + } + 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: Intermediary: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Intermediary: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ConsumerValidator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDelegate + } + 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 ErrInvalidLengthDelegate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDelegate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ConsumerValidator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDelegate + } + 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 ErrInvalidLengthDelegate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDelegate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ContractAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDelegate + } + 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 ErrInvalidLengthDelegate + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthDelegate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Jailed", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDelegate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Jailed = bool(v != 0) + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Tombstoned", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDelegate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Tombstoned = bool(v != 0) + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDelegate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= BondStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowDelegate + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthDelegate + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthDelegate + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Token == nil { + m.Token = &types.Coin{} + } + if err := m.Token.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipDelegate(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthDelegate + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipDelegate(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, ErrIntOverflowDelegate + } + 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, ErrIntOverflowDelegate + } + 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, ErrIntOverflowDelegate + } + 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, ErrInvalidLengthDelegate + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupDelegate + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthDelegate + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthDelegate = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowDelegate = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupDelegate = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/provider/types/events.go b/x/provider/types/events.go index 8701821c..6024d0d6 100644 --- a/x/provider/types/events.go +++ b/x/provider/types/events.go @@ -2,6 +2,7 @@ package types // Provider events const ( + EventTypeDelegate = "delegate" EventTypeConsumerClientCreated = "consumer_client_created" EventTypeAssignConsumerKey = "assign_consumer_key" EventTypeAddConsumerRewardDenom = "add_consumer_reward_denom" @@ -20,4 +21,6 @@ const ( AttributeConsumerRewardDenom = "consumer_reward_denom" AttributeConsumerCommissionRate = "consumer_commission_rate" AttributeConsumerChainID = "consumer_chain_id" + AttributeConsumerValidator = "consumer_validator" + AttributeKeyNewShares = "new_shares" ) diff --git a/x/provider/types/expected_keepers.go b/x/provider/types/expected_keepers.go index 805f119c..6c849257 100644 --- a/x/provider/types/expected_keepers.go +++ b/x/provider/types/expected_keepers.go @@ -21,11 +21,14 @@ import ( type BankKeeper interface { GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error UndelegateCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + DelegateCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error } // SDKStakingKeeper expected staking keeper. diff --git a/x/provider/types/keys.go b/x/provider/types/keys.go index 416c2830..44733548 100644 --- a/x/provider/types/keys.go +++ b/x/provider/types/keys.go @@ -5,18 +5,23 @@ import ( ) const ( - ModuleName = "meshsecurity" - RouterKey = ModuleName + ModuleName = "meshsecurityprovider" + RouterKey = ModuleName + StoreKey = ModuleName + MemStoreKey = "memory:meshsecurityprovider" ) var ( - ChainToChannelBytePrefix = []byte{0x1} + ChainToChannelBytePrefix = []byte{0x10} ChannelToChainBytePrefix = []byte{0x2} InitChainHeightBytePrefix = []byte{0x3} InitTimeoutTimestampBytePrefix = []byte{0x4} ChainToClientBytePrefix = []byte{0x5} ConsumerCommissionRatePrefix = []byte{0x6} ParamsKey = []byte{0x7} + DepositorsKeyPrefix = []byte{0x8} + ContractWithNativeDenomPrefix = []byte{0x9} + IntermediaryKeyPrefix = []byte{0x11} ) func ChainToChannelKey(chainID string) []byte { @@ -43,6 +48,17 @@ func ConsumerCommissionRateKey(chainID string, providerAddr ProviderConsAddress) return append(append(ConsumerCommissionRatePrefix, []byte(chainID)...), providerAddr.Address...) } +func DepositorsKey(del string) []byte { + return append(DepositorsKeyPrefix, []byte(del)...) +} + +func ContractWithNativeDenomKey(denom string) []byte { + return append(ContractWithNativeDenomPrefix, []byte(denom)...) +} +func IntermediaryKey(denom string) []byte { + return append(IntermediaryKeyPrefix, []byte(denom)...) +} + type ProviderConsAddress struct { Address sdk.ConsAddress } diff --git a/x/provider/types/params.go b/x/provider/types/params.go index 68de7172..050f8982 100644 --- a/x/provider/types/params.go +++ b/x/provider/types/params.go @@ -1,20 +1,29 @@ package types +import sdk "github.com/cosmos/cosmos-sdk/types" + // DefaultParams returns default mesh-security parameters func DefaultParams(denom string) Params { return Params{ // todo: revisit and set proper defaults - InfractionTime: 0, - TimeoutPeriod: 60, + TimeoutPeriod: 60, } } // ValidateBasic performs basic validation on mesh-security parameters. func (p Params) ValidateBasic() error { - if p.InfractionTime <= 0 { - return ErrInvalid.Wrap("empty epoch length") - } if p.TimeoutPeriod <= 0 { return ErrInvalid.Wrap("empty max gas end-blocker setting") } + if p.VaultContractAddress == "" { + return ErrInvalid.Wrap("vault contract address cannot be empty") + } return nil } + +func (p Params) GetVaultContractAddress() sdk.AccAddress { + vaultContractAddress, err := sdk.AccAddressFromBech32(p.VaultContractAddress) + if err != nil { + panic("params error: VaultContractAddress") + } + return vaultContractAddress +} diff --git a/x/provider/types/params.pb.go b/x/provider/types/params.pb.go index 0b8e9350..cd898db6 100644 --- a/x/provider/types/params.pb.go +++ b/x/provider/types/params.pb.go @@ -27,9 +27,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params defines the parameters for the x/meshsecurity module. type Params struct { - InfractionTime uint64 `protobuf:"varint,1,opt,name=infraction_time,json=infractionTime,proto3" json:"infraction_time,omitempty"` // TimeoutPeriod has the unit time.Millisecond - TimeoutPeriod uint64 `protobuf:"varint,2,opt,name=timeout_period,json=timeoutPeriod,proto3" json:"timeout_period,omitempty"` + TimeoutPeriod uint64 `protobuf:"varint,1,opt,name=timeout_period,json=timeoutPeriod,proto3" json:"timeout_period,omitempty"` + VaultContractAddress string `protobuf:"bytes,2,opt,name=vault_contract_address,json=vaultContractAddress,proto3" json:"vault_contract_address,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -74,25 +74,26 @@ func init() { } var fileDescriptor_8d8ea49c9593b4cd = []byte{ - // 283 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x90, 0xc1, 0x4a, 0xc3, 0x40, - 0x10, 0x86, 0xb3, 0x22, 0x3d, 0x04, 0x6c, 0x31, 0x78, 0x08, 0x3d, 0xac, 0x22, 0x14, 0x45, 0x48, - 0x96, 0xe2, 0xad, 0x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0xd9, 0x77, 0xcd, 0xd9, 0x5b, 0xc3, 0xbd, - 0x75, 0xc3, 0xbd, 0xaf, 0x86, 0x7b, 0xf7, 0x93, 0x1c, 0xec, 0xbc, 0x4a, 0xe2, 0x14, 0xb5, 0xe8, - 0x32, 0x88, 0x9e, 0x65, 0x42, 0x42, 0x2b, 0x9a, 0x47, 0xa4, 0xd2, 0xca, 0x80, 0x5d, 0x46, 0x94, - 0x3d, 0x89, 0x97, 0x7d, 0x86, 0x76, 0x59, 0x2a, 0x4a, 0x7a, 0xee, 0xb1, 0xeb, 0xff, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x1f, 0x21, 0xa6, 0x5e, 0x64, 0x01, 0x00, 0x00, + // 296 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x90, 0xb1, 0x4a, 0x33, 0x41, + 0x10, 0xc7, 0x6f, 0x3f, 0x3e, 0x02, 0x1e, 0xa8, 0x18, 0x82, 0x1c, 0x29, 0xd6, 0x20, 0x04, 0x82, + 0x90, 0x5b, 0x82, 0x56, 0xe9, 0xd4, 0x17, 0x08, 0x29, 0x45, 0x08, 0x7b, 0x7b, 0xcb, 0x65, 0x31, + 0x7b, 0x73, 0xec, 0xec, 0x1d, 0xa6, 0xb2, 0xb7, 0xf2, 0x11, 0x2c, 0x2d, 0x7d, 0x8c, 0x94, 0x29, + 0x2d, 0xf5, 0xae, 0xd0, 0xc7, 0x10, 0xf7, 0xd6, 0xd8, 0x0c, 0xc3, 0xef, 0xf7, 0x1f, 0x86, 0x99, + 0x70, 0x08, 0xa8, 0x01, 0x15, 0xb2, 0xc2, 0x40, 0xa5, 0x52, 0x69, 0x58, 0x35, 0x49, 0xa4, 0xe5, + 0x13, 0x56, 0x70, 0xc3, 0x35, 0xc6, 0x85, 0x01, 0x0b, 0xdd, 0xc8, 0xc7, 0xe2, 0xdf, 0x58, 0xec, + 0x63, 0x7d, 0x2a, 0x9c, 0x62, 0x09, 0x47, 0xb9, 0x9b, 0x15, 0xa0, 0xf2, 0x76, 0xb2, 0xdf, 0xcb, + 0x20, 0x03, 0xd7, 0xb2, 0x9f, 0xce, 0xd3, 0x23, 0xae, 0x55, 0x0e, 0xcc, 0xd5, 0x16, 0x9d, 0x3e, + 0x84, 0x9d, 0x99, 0x5b, 0xd9, 0x1d, 0x86, 0x07, 0x56, 0x69, 0x09, 0xa5, 0x5d, 0x14, 0xd2, 0x28, + 0x48, 0x23, 0x32, 0x20, 0xa3, 0xff, 0xf3, 0x7d, 0x4f, 0x67, 0x0e, 0x76, 0x2f, 0xc2, 0xe3, 0x8a, + 0x97, 0x2b, 0xbb, 0x10, 0x90, 0x5b, 0xc3, 0x85, 0x5d, 0xf0, 0x34, 0x35, 0x12, 0x31, 0xfa, 0x37, + 0x20, 0xa3, 0xbd, 0x79, 0xcf, 0xd9, 0x6b, 0x2f, 0x2f, 0x5b, 0x37, 0x8d, 0xbe, 0x9e, 0x4f, 0xc8, + 0xe3, 0xe7, 0xeb, 0xd9, 0xe1, 0xee, 0xe2, 0x76, 0xed, 0xd5, 0xed, 0xe6, 0x83, 0x06, 0x2f, 0x35, + 0x0d, 0x36, 0x35, 0x25, 0xdb, 0x9a, 0x92, 0xf7, 0x9a, 0x92, 0xa7, 0x86, 0x06, 0xdb, 0x86, 0x06, + 0x6f, 0x0d, 0x0d, 0x6e, 0xa6, 0x99, 0xb2, 0xcb, 0x32, 0x89, 0x05, 0x68, 0xe6, 0x1f, 0x32, 0x5e, + 0xf1, 0x04, 0x99, 0x96, 0xb8, 0x1c, 0xa3, 0x14, 0xa5, 0x51, 0x76, 0x3d, 0xc6, 0xf4, 0x8e, 0xdd, + 0xff, 0x3d, 0xd4, 0xae, 0x0b, 0x89, 0x49, 0xc7, 0x5d, 0x79, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, + 0x36, 0xe2, 0x98, 0xcf, 0x71, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -114,10 +115,10 @@ func (this *Params) Equal(that interface{}) bool { } else if this == nil { return false } - if this.InfractionTime != that1.InfractionTime { + if this.TimeoutPeriod != that1.TimeoutPeriod { return false } - if this.TimeoutPeriod != that1.TimeoutPeriod { + if this.VaultContractAddress != that1.VaultContractAddress { return false } return true @@ -142,13 +143,15 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.TimeoutPeriod != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.TimeoutPeriod)) + if len(m.VaultContractAddress) > 0 { + i -= len(m.VaultContractAddress) + copy(dAtA[i:], m.VaultContractAddress) + i = encodeVarintParams(dAtA, i, uint64(len(m.VaultContractAddress))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } - if m.InfractionTime != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.InfractionTime)) + if m.TimeoutPeriod != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.TimeoutPeriod)) i-- dAtA[i] = 0x8 } @@ -172,12 +175,13 @@ func (m *Params) Size() (n int) { } var l int _ = l - if m.InfractionTime != 0 { - n += 1 + sovParams(uint64(m.InfractionTime)) - } if m.TimeoutPeriod != 0 { n += 1 + sovParams(uint64(m.TimeoutPeriod)) } + l = len(m.VaultContractAddress) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } return n } @@ -218,9 +222,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field InfractionTime", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TimeoutPeriod", wireType) } - m.InfractionTime = 0 + m.TimeoutPeriod = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -230,16 +234,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.InfractionTime |= uint64(b&0x7F) << shift + m.TimeoutPeriod |= uint64(b&0x7F) << shift if b < 0x80 { break } } case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TimeoutPeriod", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VaultContractAddress", wireType) } - m.TimeoutPeriod = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowParams @@ -249,11 +253,24 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.TimeoutPeriod |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VaultContractAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/provider/types/tx.pb.go b/x/provider/types/tx.pb.go index 75ccff9e..933d37ae 100644 --- a/x/provider/types/tx.pb.go +++ b/x/provider/types/tx.pb.go @@ -8,6 +8,7 @@ import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/msgservice" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" @@ -32,6 +33,157 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgDelegate struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` +} + +func (m *MsgDelegate) Reset() { *m = MsgDelegate{} } +func (m *MsgDelegate) String() string { return proto.CompactTextString(m) } +func (*MsgDelegate) ProtoMessage() {} +func (*MsgDelegate) Descriptor() ([]byte, []int) { + return fileDescriptor_600cc2e6a7e19cb9, []int{0} +} +func (m *MsgDelegate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDelegate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDelegate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgDelegate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDelegate.Merge(m, src) +} +func (m *MsgDelegate) XXX_Size() int { + return m.Size() +} +func (m *MsgDelegate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDelegate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDelegate proto.InternalMessageInfo + +type MsgDelegateResponse struct { +} + +func (m *MsgDelegateResponse) Reset() { *m = MsgDelegateResponse{} } +func (m *MsgDelegateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDelegateResponse) ProtoMessage() {} +func (*MsgDelegateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_600cc2e6a7e19cb9, []int{1} +} +func (m *MsgDelegateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDelegateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDelegateResponse.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 *MsgDelegateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDelegateResponse.Merge(m, src) +} +func (m *MsgDelegateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDelegateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDelegateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDelegateResponse proto.InternalMessageInfo + +type MsgUndelegate struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` +} + +func (m *MsgUndelegate) Reset() { *m = MsgUndelegate{} } +func (m *MsgUndelegate) String() string { return proto.CompactTextString(m) } +func (*MsgUndelegate) ProtoMessage() {} +func (*MsgUndelegate) Descriptor() ([]byte, []int) { + return fileDescriptor_600cc2e6a7e19cb9, []int{2} +} +func (m *MsgUndelegate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUndelegate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUndelegate.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgUndelegate) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUndelegate.Merge(m, src) +} +func (m *MsgUndelegate) XXX_Size() int { + return m.Size() +} +func (m *MsgUndelegate) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUndelegate.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUndelegate proto.InternalMessageInfo + +// MsgUndelegateResponse defines the Msg/Undelegate response type. +type MsgUndelegateResponse struct { +} + +func (m *MsgUndelegateResponse) Reset() { *m = MsgUndelegateResponse{} } +func (m *MsgUndelegateResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUndelegateResponse) ProtoMessage() {} +func (*MsgUndelegateResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_600cc2e6a7e19cb9, []int{3} +} +func (m *MsgUndelegateResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUndelegateResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUndelegateResponse.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 *MsgUndelegateResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUndelegateResponse.Merge(m, src) +} +func (m *MsgUndelegateResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUndelegateResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUndelegateResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUndelegateResponse proto.InternalMessageInfo + type MsgSetConsumerCommissionRate struct { ProviderAddr string `protobuf:"bytes,1,opt,name=provider_addr,json=providerAddr,proto3" json:"provider_addr,omitempty" yaml:"address"` ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` @@ -42,7 +194,7 @@ func (m *MsgSetConsumerCommissionRate) Reset() { *m = MsgSetConsumerComm func (m *MsgSetConsumerCommissionRate) String() string { return proto.CompactTextString(m) } func (*MsgSetConsumerCommissionRate) ProtoMessage() {} func (*MsgSetConsumerCommissionRate) Descriptor() ([]byte, []int) { - return fileDescriptor_600cc2e6a7e19cb9, []int{0} + return fileDescriptor_600cc2e6a7e19cb9, []int{4} } func (m *MsgSetConsumerCommissionRate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -78,7 +230,7 @@ func (m *MsgSetConsumerCommissionRateResponse) Reset() { *m = MsgSetCons func (m *MsgSetConsumerCommissionRateResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetConsumerCommissionRateResponse) ProtoMessage() {} func (*MsgSetConsumerCommissionRateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_600cc2e6a7e19cb9, []int{1} + return fileDescriptor_600cc2e6a7e19cb9, []int{5} } func (m *MsgSetConsumerCommissionRateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -108,6 +260,10 @@ func (m *MsgSetConsumerCommissionRateResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetConsumerCommissionRateResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgDelegate)(nil), "osmosis.provider.v1beta1.MsgDelegate") + proto.RegisterType((*MsgDelegateResponse)(nil), "osmosis.provider.v1beta1.MsgDelegateResponse") + proto.RegisterType((*MsgUndelegate)(nil), "osmosis.provider.v1beta1.MsgUndelegate") + proto.RegisterType((*MsgUndelegateResponse)(nil), "osmosis.provider.v1beta1.MsgUndelegateResponse") proto.RegisterType((*MsgSetConsumerCommissionRate)(nil), "osmosis.provider.v1beta1.MsgSetConsumerCommissionRate") proto.RegisterType((*MsgSetConsumerCommissionRateResponse)(nil), "osmosis.provider.v1beta1.MsgSetConsumerCommissionRateResponse") } @@ -115,33 +271,44 @@ func init() { func init() { proto.RegisterFile("osmosis/provider/v1beta1/tx.proto", fileDescriptor_600cc2e6a7e19cb9) } var fileDescriptor_600cc2e6a7e19cb9 = []byte{ - // 404 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcc, 0x2f, 0xce, 0xcd, - 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xcb, 0x4c, 0x49, 0x2d, 0xd2, 0x2f, 0x33, 0x4c, - 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x92, 0x80, - 0x2a, 0xd1, 0x83, 0x29, 0xd1, 0x83, 0x2a, 0x91, 0x92, 0x4c, 0x06, 0x4b, 0xc5, 0x83, 0xd5, 0xe9, - 0x43, 0x38, 0x10, 0x4d, 0x52, 0xe2, 0x10, 0x9e, 0x7e, 0x6e, 0x71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x82, 0x4b, 0x6a, 0x72, 0x10, 0xd8, 0x24, 0x2b, 0x8e, 0x8e, 0x05, 0xf2, 0x0c, 0x2f, 0x16, - 0xc8, 0x33, 0x28, 0xa9, 0x71, 0xa9, 0xe0, 0xf3, 0x4f, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, - 0xaa, 0xd1, 0x6c, 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0xc9, 0x8c, 0x5c, 0x92, 0xb8, 0x7d, - 0x6f, 0xa6, 0x87, 0x2b, 0x5a, 0xf4, 0xf0, 0xd9, 0x22, 0x65, 0x47, 0x9e, 0x3e, 0x98, 0xeb, 0x9c, - 0x22, 0x4e, 0x3c, 0x94, 0x63, 0x38, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, - 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, - 0x2b, 0xa4, 0x90, 0x82, 0xda, 0xa3, 0x9b, 0x93, 0x98, 0x54, 0xac, 0x9f, 0x9b, 0x5a, 0x9c, 0xa1, - 0x5b, 0x9c, 0x9a, 0x5c, 0x5a, 0x94, 0x59, 0x52, 0x09, 0x0e, 0xb6, 0x0a, 0x44, 0x92, 0x03, 0x87, - 0x60, 0x12, 0x1b, 0x38, 0xde, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0xaf, 0x67, 0x1e, 0x99, - 0x93, 0x02, 0x00, 0x00, + // 579 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x54, 0x41, 0x6b, 0x13, 0x41, + 0x14, 0xde, 0x69, 0xa5, 0x26, 0x53, 0x2b, 0x76, 0x6d, 0x69, 0x12, 0x64, 0x53, 0x83, 0xd6, 0x22, + 0xec, 0x2e,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+ 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -156,6 +323,8 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { + Delegate(ctx context.Context, in *MsgDelegate, opts ...grpc.CallOption) (*MsgDelegateResponse, error) + Undelegate(ctx context.Context, in *MsgUndelegate, opts ...grpc.CallOption) (*MsgUndelegateResponse, error) SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) } @@ -167,6 +336,24 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) Delegate(ctx context.Context, in *MsgDelegate, opts ...grpc.CallOption) (*MsgDelegateResponse, error) { + out := new(MsgDelegateResponse) + err := c.cc.Invoke(ctx, "/osmosis.provider.v1beta1.Msg/Delegate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) Undelegate(ctx context.Context, in *MsgUndelegate, opts ...grpc.CallOption) (*MsgUndelegateResponse, error) { + out := new(MsgUndelegateResponse) + err := c.cc.Invoke(ctx, "/osmosis.provider.v1beta1.Msg/Undelegate", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) { out := new(MsgSetConsumerCommissionRateResponse) err := c.cc.Invoke(ctx, "/osmosis.provider.v1beta1.Msg/SetConsumerCommissionRate", in, out, opts...) @@ -178,6 +365,8 @@ func (c *msgClient) SetConsumerCommissionRate(ctx context.Context, in *MsgSetCon // MsgServer is the server API for Msg service. type MsgServer interface { + Delegate(context.Context, *MsgDelegate) (*MsgDelegateResponse, error) + Undelegate(context.Context, *MsgUndelegate) (*MsgUndelegateResponse, error) SetConsumerCommissionRate(context.Context, *MsgSetConsumerCommissionRate) (*MsgSetConsumerCommissionRateResponse, error) } @@ -185,6 +374,12 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) Delegate(ctx context.Context, req *MsgDelegate) (*MsgDelegateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Delegate not implemented") +} +func (*UnimplementedMsgServer) Undelegate(ctx context.Context, req *MsgUndelegate) (*MsgUndelegateResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Undelegate not implemented") +} func (*UnimplementedMsgServer) SetConsumerCommissionRate(ctx context.Context, req *MsgSetConsumerCommissionRate) (*MsgSetConsumerCommissionRateResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetConsumerCommissionRate not implemented") } @@ -193,6 +388,42 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_Delegate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDelegate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Delegate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.provider.v1beta1.Msg/Delegate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Delegate(ctx, req.(*MsgDelegate)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_Undelegate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUndelegate) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).Undelegate(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.provider.v1beta1.Msg/Undelegate", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).Undelegate(ctx, req.(*MsgUndelegate)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_SetConsumerCommissionRate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgSetConsumerCommissionRate) if err := dec(in); err != nil { @@ -215,6 +446,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "osmosis.provider.v1beta1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "Delegate", + Handler: _Msg_Delegate_Handler, + }, + { + MethodName: "Undelegate", + Handler: _Msg_Undelegate_Handler, + }, { MethodName: "SetConsumerCommissionRate", Handler: _Msg_SetConsumerCommissionRate_Handler, @@ -224,6 +463,146 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "osmosis/provider/v1beta1/tx.proto", } +func (m *MsgDelegate) 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 *MsgDelegate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDelegateResponse) 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 *MsgDelegateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDelegateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUndelegate) 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 *MsgUndelegate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUndelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintTx(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUndelegateResponse) 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 *MsgUndelegateResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUndelegateResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgSetConsumerCommissionRate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -305,26 +684,26 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgSetConsumerCommissionRate) Size() (n int) { +func (m *MsgDelegate) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.ProviderAddr) + l = len(m.DelegatorAddress) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.ChainId) + l = len(m.ValidatorAddress) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = m.Rate.Size() + l = m.Amount.Size() n += 1 + l + sovTx(uint64(l)) return n } -func (m *MsgSetConsumerCommissionRateResponse) Size() (n int) { +func (m *MsgDelegateResponse) Size() (n int) { if m == nil { return 0 } @@ -333,11 +712,461 @@ func (m *MsgSetConsumerCommissionRateResponse) Size() (n int) { return n } -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func (m *MsgUndelegate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUndelegateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSetConsumerCommissionRate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ProviderAddr) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.ChainId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Rate.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgSetConsumerCommissionRateResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgDelegate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgDelegate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDelegate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDelegateResponse) 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 ErrIntOverflowTx + } + 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: MsgDelegateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDelegateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUndelegate) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUndelegate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUndelegate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUndelegateResponse) 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 ErrIntOverflowTx + } + 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: MsgUndelegateResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUndelegateResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } func (m *MsgSetConsumerCommissionRate) Unmarshal(dAtA []byte) error { l := len(dAtA) diff --git a/x/types/error.go b/x/types/error.go index 7662bbf0..788482ba 100644 --- a/x/types/error.go +++ b/x/types/error.go @@ -10,4 +10,5 @@ var ( ErrInvalidChannelFlow = errorsmod.Register(ModuleName, 3, "invalid message sent to channel end") ErrDuplicateChannel = errorsmod.Register(ModuleName, 5, "meshsecurity channel already exists") ErrClientNotFound = errorsmod.Register(ModuleName, 10, "client not found") + ErrInvalidPacketData = errorsmod.Register(ModuleName, 1, "invalid CCV packet data") ) diff --git a/x/types/wire.go b/x/types/wire.go index cee764a8..c9f8e2a8 100644 --- a/x/types/wire.go +++ b/x/types/wire.go @@ -1,6 +1,7 @@ package types import ( + errorsmod "cosmossdk.io/errors" "encoding/binary" ) @@ -8,36 +9,42 @@ func (c ConsumerPacketData) GetBytes() []byte { var bytes []byte bytes = append(bytes, Int32ToBytes(int32(c.Type))...) if c.Type != PipedValsetOperation_VALIDATOR_SLASHED { - bytes = append(bytes, ModuleCdc.MustMarshalJSON(&c)...) - return bytes + packetScheduleInfo := c.GetSchedulePacketData() + bytes = append(bytes, ModuleCdc.MustMarshalJSON(packetScheduleInfo)...) + } else { + packetSlashInfo := c.GetSlashPacketData() + bytes = append(bytes, ModuleCdc.MustMarshalJSON(packetSlashInfo)...) } - - packetSlashInfo := c.GetSlashPacketData() - bytes = append(bytes, ModuleCdc.MustMarshalJSON(packetSlashInfo)...) return bytes } func UnmarshalConsumerPacketData(data []byte) (ConsumerPacketData, error) { cp := PipedValsetOperation(BigEndianToInt32(data[:4])) if cp != PipedValsetOperation_VALIDATOR_SLASHED { - var c ConsumerPacketData - ModuleCdc.UnmarshalJSON(data[4:], &c) - return c, nil - } - - var slash SlashInfo - err := ModuleCdc.UnmarshalJSON(data[4:], &slash) - if err != nil { - return ConsumerPacketData{}, err + var s ScheduleInfo + err := ModuleCdc.UnmarshalJSON(data[4:], &s) + if err != nil { + return ConsumerPacketData{}, err + } + return ConsumerPacketData{ + Type: cp, + Data: &ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &s, + }, + }, nil + } else { + var slash SlashInfo + err := ModuleCdc.UnmarshalJSON(data[4:], &slash) + if err != nil { + return ConsumerPacketData{}, err + } + return ConsumerPacketData{ + Type: cp, + Data: &ConsumerPacketData_SlashPacketData{ + SlashPacketData: &slash, + }, + }, nil } - - return ConsumerPacketData{ - Type: cp, - Data: &ConsumerPacketData_SlashPacketData{ - SlashPacketData: &slash, - }, - }, nil - } func BigEndianToInt32(bz []byte) int32 { @@ -52,3 +59,42 @@ func Int32ToBytes(i int32) []byte { binary.BigEndian.PutUint32(data, uint32(i)) return data } + +type PacketAckResult []byte + +var ( + // Slash packet handled result ack, sent by a throttling provider to indicate that a slash packet was handled. + SlashPacketHandledResult = PacketAckResult([]byte{byte(1)}) + // Slash packet bounced result ack, sent by a throttling provider to indicate that a slash packet was NOT handled + // and should eventually be retried. + SlashPacketBouncedResult = PacketAckResult([]byte{byte(2)}) +) + +func NewConsumerPacketData(cpdType PipedValsetOperation, data isConsumerPacketData_Data) ConsumerPacketData { + return ConsumerPacketData{ + Type: cpdType, + Data: data, + } +} + +func (s SlashInfo) Validate() error { + if s.Validator == "" { + return errorsmod.Wrap(ErrInvalidPacketData, "invalid validator") + } + if s.Power == 0 { + return errorsmod.Wrap(ErrInvalidPacketData, "validator power cannot be zero") + } + if s.InfractionHeight <= 0 { + return errorsmod.Wrap(ErrInvalidPacketData, "Infraction Height cannot be zero") + } + if s.SlashFraction == "0" { + return errorsmod.Wrap(ErrInvalidPacketData, "Slash Fraction cannot be zero") + } + if s.TotalSlashAmount == "0" { + return errorsmod.Wrap(ErrInvalidPacketData, "Total Slash Amount cannot be zero") + } + if s.TimeInfraction < 0 { + return errorsmod.Wrap(ErrInvalidPacketData, "TimeInfraction cannot be negative") + } + return nil +} diff --git a/x/types/wire.pb.go b/x/types/wire.pb.go index f73234cb..9dcd5977 100644 --- a/x/types/wire.pb.go +++ b/x/types/wire.pb.go @@ -107,6 +107,7 @@ func (InfractionType) EnumDescriptor() ([]byte, []int) { // SlashInfo defines info event from slashing type SlashInfo struct { + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` InfractionHeight int64 `protobuf:"varint,2,opt,name=infraction_height,json=infractionHeight,proto3" json:"infraction_height,omitempty"` Power int64 `protobuf:"varint,3,opt,name=power,proto3" json:"power,omitempty"` TotalSlashAmount string `protobuf:"bytes,4,opt,name=total_slash_amount,json=totalSlashAmount,proto3" json:"total_slash_amount,omitempty"` @@ -147,11 +148,51 @@ func (m *SlashInfo) XXX_DiscardUnknown() { var xxx_messageInfo_SlashInfo proto.InternalMessageInfo +// InfoSchedule +type ScheduleInfo struct { + Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` + Actor string `protobuf:"bytes,2,opt,name=actor,proto3" json:"actor,omitempty"` +} + +func (m *ScheduleInfo) Reset() { *m = ScheduleInfo{} } +func (m *ScheduleInfo) String() string { return proto.CompactTextString(m) } +func (*ScheduleInfo) ProtoMessage() {} +func (*ScheduleInfo) Descriptor() ([]byte, []int) { + return fileDescriptor_c573c9158aa3b788, []int{1} +} +func (m *ScheduleInfo) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ScheduleInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ScheduleInfo.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 *ScheduleInfo) XXX_Merge(src proto.Message) { + xxx_messageInfo_ScheduleInfo.Merge(m, src) +} +func (m *ScheduleInfo) XXX_Size() int { + return m.Size() +} +func (m *ScheduleInfo) XXX_DiscardUnknown() { + xxx_messageInfo_ScheduleInfo.DiscardUnknown(m) +} + +var xxx_messageInfo_ScheduleInfo proto.InternalMessageInfo + // ConsumerPacketData contains a consumer packet data and a type tag type ConsumerPacketData struct { Type PipedValsetOperation `protobuf:"varint,1,opt,name=type,proto3,enum=osmosis.types.v1beta1.PipedValsetOperation" json:"type,omitempty"` // Types that are valid to be assigned to Data: // *ConsumerPacketData_SlashPacketData + // *ConsumerPacketData_SchedulePacketData Data isConsumerPacketData_Data `protobuf_oneof:"data"` } @@ -159,7 +200,7 @@ func (m *ConsumerPacketData) Reset() { *m = ConsumerPacketData{} } func (m *ConsumerPacketData) String() string { return proto.CompactTextString(m) } func (*ConsumerPacketData) ProtoMessage() {} func (*ConsumerPacketData) Descriptor() ([]byte, []int) { - return fileDescriptor_c573c9158aa3b788, []int{1} + return fileDescriptor_c573c9158aa3b788, []int{2} } func (m *ConsumerPacketData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -197,8 +238,12 @@ type isConsumerPacketData_Data interface { type ConsumerPacketData_SlashPacketData struct { SlashPacketData *SlashInfo `protobuf:"bytes,2,opt,name=slashPacketData,proto3,oneof" json:"slashPacketData,omitempty"` } +type ConsumerPacketData_SchedulePacketData struct { + SchedulePacketData *ScheduleInfo `protobuf:"bytes,3,opt,name=schedulePacketData,proto3,oneof" json:"schedulePacketData,omitempty"` +} -func (*ConsumerPacketData_SlashPacketData) isConsumerPacketData_Data() {} +func (*ConsumerPacketData_SlashPacketData) isConsumerPacketData_Data() {} +func (*ConsumerPacketData_SchedulePacketData) isConsumerPacketData_Data() {} func (m *ConsumerPacketData) GetData() isConsumerPacketData_Data { if m != nil { @@ -214,10 +259,18 @@ func (m *ConsumerPacketData) GetSlashPacketData() *SlashInfo { return nil } +func (m *ConsumerPacketData) GetSchedulePacketData() *ScheduleInfo { + if x, ok := m.GetData().(*ConsumerPacketData_SchedulePacketData); ok { + return x.SchedulePacketData + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*ConsumerPacketData) XXX_OneofWrappers() []interface{} { return []interface{}{ (*ConsumerPacketData_SlashPacketData)(nil), + (*ConsumerPacketData_SchedulePacketData)(nil), } } @@ -225,54 +278,58 @@ func init() { proto.RegisterEnum("osmosis.types.v1beta1.PipedValsetOperation", PipedValsetOperation_name, PipedValsetOperation_value) proto.RegisterEnum("osmosis.types.v1beta1.InfractionType", InfractionType_name, InfractionType_value) proto.RegisterType((*SlashInfo)(nil), "osmosis.types.v1beta1.SlashInfo") + proto.RegisterType((*ScheduleInfo)(nil), "osmosis.types.v1beta1.ScheduleInfo") proto.RegisterType((*ConsumerPacketData)(nil), "osmosis.types.v1beta1.ConsumerPacketData") } func init() { proto.RegisterFile("osmosis/types/v1beta1/wire.proto", fileDescriptor_c573c9158aa3b788) } var fileDescriptor_c573c9158aa3b788 = []byte{ - // 643 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x93, 0x4f, 0x4f, 0xdb, 0x3c, - 0x1c, 0xc7, 0x13, 0x28, 0x7d, 0x1e, 0xcc, 0xf3, 0xb4, 0xc1, 0x2b, 0x53, 0x54, 0xa4, 0x28, 0x42, - 0x9b, 0x86, 0x60, 0x34, 0x82, 0xed, 0x3e, 0xb5, 0x24, 0x8c, 0x4c, 0x25, 0xa9, 0x9a, 0xc2, 0xb4, - 0x5d, 0x22, 0x27, 0x35, 0xad, 0x45, 0x13, 0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23, 0xef, 0xf1, 0xd6, 0x08, 0x05, 0xcc, 0x88, 0x30, - 0x1b, 0x6e, 0x31, 0x1c, 0x4e, 0x12, 0xc2, 0xcf, 0xb6, 0x58, 0xff, 0xc4, 0xf8, 0x98, 0x3d, 0xa9, - 0xa0, 0x2c, 0xde, 0xd4, 0x8b, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x29, 0x61, 0x91, 0x2d, 0x1a, - 0x04, 0x00, 0x00, + // 704 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4f, 0x4f, 0xdb, 0x48, + 0x18, 0xc6, 0xed, 0xfc, 0xdb, 0x65, 0x60, 0x13, 0x33, 0x1b, 0x56, 0x56, 0x58, 0x59, 0x11, 0xbb, + 0x55, 0x11, 0x94, 0x58, 0xd0, 0xde, 0xab, 0x04, 0x9b, 0xc6, 0x55, 0xb0, 0xa3, 0x38, 0xa1, 0x6a, + 0x2f, 0xd6, 0xc4, 0x19, 0x92, 0x11, 0xb1, 0x27, 0xb2, 0x27, 0x50, 0xae, 0x3d, 0x55, 0x9c, 0xfa, + 0x05, 0x38, 0xf5, 0xd2, 0x7e, 0x13, 0x0e, 0x3d, 0x70, 0xec, 0xb1, 0x0d, 0xb7, 0x7e, 0x8a, 0xca, + 0x63, 0x37, 0xe6, 0xaf, 0xd4, 0x8b, 0xe5, 0xf9, 0xbd, 0xcf, 0xf3, 0xcc, 0xfb, 0x7a, 0xac, 0x01, + 0x55, 0x1a, 0x7a, 0x34, 0x24, 0xa1, 0xca, 0x4e, 0x27, 0x38, 0x54, 0x8f, 0xb7, 0xfb, 0x98, 0xa1, + 0x6d, 0xf5, 0x84, 0x04, 0xb8, 0x36, 0x09, 0x28, 0xa3, 0x70, 0x25, 0x51, 0xd4, 0xb8, 0xa2, 0x96, + 0x28, 0x2a, 0x8a, 0xcb, 0xb9, 0xda, 0x47, 0x21, 0x9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xbf, 0xc0, 0x2f, + 0x83, 0xa7, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xbd, 0xe2, 0x97, 0xbe, 0xd3, 0x04, 0x00, 0x00, } func (m *SlashInfo) Marshal() (dAtA []byte, err error) { @@ -324,6 +381,50 @@ func (m *SlashInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintWire(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ScheduleInfo) 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 *ScheduleInfo) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ScheduleInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Actor) > 0 { + i -= len(m.Actor) + copy(dAtA[i:], m.Actor) + i = encodeVarintWire(dAtA, i, uint64(len(m.Actor))) + i-- + dAtA[i] = 0x12 + } + if len(m.Validator) > 0 { + i -= len(m.Validator) + copy(dAtA[i:], m.Validator) + i = encodeVarintWire(dAtA, i, uint64(len(m.Validator))) + i-- + dAtA[i] = 0xa + } return len(dAtA) - i, nil } @@ -385,6 +486,27 @@ func (m *ConsumerPacketData_SlashPacketData) MarshalToSizedBuffer(dAtA []byte) ( } return len(dAtA) - i, nil } +func (m *ConsumerPacketData_SchedulePacketData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ConsumerPacketData_SchedulePacketData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.SchedulePacketData != nil { + { + size, err := m.SchedulePacketData.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintWire(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} func encodeVarintWire(dAtA []byte, offset int, v uint64) int { offset -= sovWire(v) base := offset @@ -402,6 +524,10 @@ func (m *SlashInfo) Size() (n int) { } var l int _ = l + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovWire(uint64(l)) + } if m.InfractionHeight != 0 { n += 1 + sovWire(uint64(m.InfractionHeight)) } @@ -422,6 +548,23 @@ func (m *SlashInfo) Size() (n int) { return n } +func (m *ScheduleInfo) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Validator) + if l > 0 { + n += 1 + l + sovWire(uint64(l)) + } + l = len(m.Actor) + if l > 0 { + n += 1 + l + sovWire(uint64(l)) + } + return n +} + func (m *ConsumerPacketData) Size() (n int) { if m == nil { return 0 @@ -449,6 +592,18 @@ func (m *ConsumerPacketData_SlashPacketData) Size() (n int) { } return n } +func (m *ConsumerPacketData_SchedulePacketData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SchedulePacketData != nil { + l = m.SchedulePacketData.Size() + n += 1 + l + sovWire(uint64(l)) + } + return n +} func sovWire(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 @@ -485,6 +640,38 @@ func (m *SlashInfo) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: SlashInfo: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + 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 ErrInvalidLengthWire + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWire + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 2: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field InfractionHeight", wireType) @@ -627,6 +814,120 @@ func (m *SlashInfo) Unmarshal(dAtA []byte) error { } return nil } +func (m *ScheduleInfo) 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 ErrIntOverflowWire + } + 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: ScheduleInfo: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ScheduleInfo: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Validator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + 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 ErrInvalidLengthWire + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWire + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Validator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Actor", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + 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 ErrInvalidLengthWire + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWire + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Actor = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipWire(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthWire + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -710,6 +1011,41 @@ func (m *ConsumerPacketData) Unmarshal(dAtA []byte) error { } m.Data = &ConsumerPacketData_SlashPacketData{v} iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SchedulePacketData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthWire + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthWire + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ScheduleInfo{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Data = &ConsumerPacketData_SchedulePacketData{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipWire(dAtA[iNdEx:]) diff --git a/x/types/wire_test.go b/x/types/wire_test.go index 901c516f..16d02a17 100644 --- a/x/types/wire_test.go +++ b/x/types/wire_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestGetBytesAndX(t *testing.T) { +func TestGetBytesAndGetData(t *testing.T) { c1 := ConsumerPacketData{ Type: PipedValsetOperation_VALIDATOR_SLASHED, Data: &ConsumerPacketData_SlashPacketData{ @@ -24,4 +24,24 @@ func TestGetBytesAndX(t *testing.T) { c2, err := UnmarshalConsumerPacketData(data) require.NoError(t, err) require.Equal(t, c1, c2) + + require.Equal(t, int64(1), c2.GetSlashPacketData().InfractionHeight) + require.Equal(t, int64(2), c2.GetSlashPacketData().Power) + require.Equal(t, "3", c2.GetSlashPacketData().TotalSlashAmount) + require.Equal(t, "0.1", c2.GetSlashPacketData().SlashFraction) + require.Equal(t, int64(1000), c2.GetSlashPacketData().TimeInfraction) + + s1 := ConsumerPacketData{ + Type: PipedValsetOperation_VALIDATOR_TOMBSTONED, + Data: &ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &ScheduleInfo{ + Validator: "val", + Actor: "contract", + }, + }, + } + data = s1.GetBytes() + s2, err := UnmarshalConsumerPacketData(data) + require.NoError(t, err) + require.Equal(t, s1, s2) } From a2879149bdd380f0f2c615250820781707452143 Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Wed, 17 Jul 2024 10:24:46 +0700 Subject: [PATCH 03/14] minor --- x/provider/types/provider.go | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 x/provider/types/provider.go diff --git a/x/provider/types/provider.go b/x/provider/types/provider.go deleted file mode 100644 index dbe6bc1f..00000000 --- a/x/provider/types/provider.go +++ /dev/null @@ -1,28 +0,0 @@ -package types - -import ( - crypto "github.com/cometbft/cometbft/proto/tendermint/crypto" -) - -type ValidatorConsumerPubKey struct { - ChainId string - ProviderAddr []byte - ConsumerKey *crypto.PublicKey -} - -type ValidatorByConsumerAddr struct { - ChainId string - ConsumerAddr []byte - ProviderAddr []byte -} - -type ConsumerAddrsToPrune struct { - ChainId string - VscId uint64 - ConsumerAddrs *AddressList -} - -// AddressList contains a list of consensus addresses -type AddressList struct { - Addresses [][]byte -} From 00bdf4dce7667daf33ded12e0d7b0ab35f1c5d9a Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Wed, 17 Jul 2024 14:47:27 +0700 Subject: [PATCH 04/14] updates --- demo/app/app.go | 69 +++++++++++++------------ x/meshsecurity/keeper/valset_updates.go | 21 ++++++-- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/demo/app/app.go b/demo/app/app.go index 05fcb885..424a82ff 100644 --- a/demo/app/app.go +++ b/demo/app/app.go @@ -359,6 +359,8 @@ func NewMeshApp( scopedICAControllerKeeper := app.CapabilityKeeper.ScopeToModule(icacontrollertypes.SubModuleName) scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) scopedWasmKeeper := app.CapabilityKeeper.ScopeToModule(wasmtypes.ModuleName) + scopedMeshKeeper := app.CapabilityKeeper.ScopeToModule(meshsectypes.ModuleName) + app.CapabilityKeeper.Seal() // add keepers @@ -404,28 +406,6 @@ func NewMeshApp( authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) - // setup mesh-security keeper with vanilla Cosmos-SDK - // see also NewKeeperX constructor for integration with Osmosis SDK fork - // should be initialized before wasm keeper for custom query/msg handlers - app.MeshSecKeeper = meshseckeeper.NewKeeper( - app.appCodec, - keys[meshsectypes.StoreKey], - memKeys[meshsectypes.MemStoreKey], - app.BankKeeper, - app.StakingKeeper, - &app.WasmKeeper, // ensure this is a pointer as we instantiate the keeper a bit later - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - - app.SlashingKeeper = slashingkeeper.NewKeeper( - appCodec, - legacyAmino, - keys[slashingtypes.StoreKey], - // decorate the sdk keeper to capture all jail/ unjail events for MS - meshseckeeper.NewStakingDecorator(app.StakingKeeper, app.MeshSecKeeper), - authtypes.NewModuleAddress(govtypes.ModuleName).String(), - ) - invCheckPeriod := cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)) app.CrisisKeeper = crisiskeeper.NewKeeper( appCodec, @@ -438,17 +418,6 @@ func NewMeshApp( app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) - // register the staking hooks - // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks - app.StakingKeeper.SetHooks( - stakingtypes.NewMultiStakingHooks( - app.DistrKeeper.Hooks(), - app.SlashingKeeper.Hooks(), - // register hook to capture valset updates - app.MeshSecKeeper.Hooks(), - ), - ) - app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper) groupConfig := group.DefaultConfig() @@ -483,6 +452,40 @@ func NewMeshApp( scopedIBCKeeper, ) + // setup mesh-security keeper with vanilla Cosmos-SDK + // see also NewKeeperX constructor for integration with Osmosis SDK fork + // should be initialized before wasm keeper for custom query/msg handlers + app.MeshSecKeeper = meshseckeeper.NewKeeper( + app.appCodec, + keys[meshsectypes.StoreKey], + memKeys[meshsectypes.MemStoreKey], + app.BankKeeper, + app.StakingKeeper, + &app.WasmKeeper, // ensure this is a pointer as we instantiate the keeper a bit later + scopedMeshKeeper, + app.IBCKeeper.ChannelKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + app.SlashingKeeper = slashingkeeper.NewKeeper( + appCodec, + legacyAmino, + keys[slashingtypes.StoreKey], + // decorate the sdk keeper to capture all jail/ unjail events for MS + meshseckeeper.NewStakingDecorator(app.StakingKeeper, app.MeshSecKeeper), + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + + // register the staking hooks + // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks + app.StakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks( + app.DistrKeeper.Hooks(), + app.SlashingKeeper.Hooks(), + // register hook to capture valset updates + app.MeshSecKeeper.Hooks(), + ), + ) // Register the proposal types // Deprecated: Avoid adding new handlers, instead use the new proposal flow // by granting the governance module the right to execute the message. diff --git a/x/meshsecurity/keeper/valset_updates.go b/x/meshsecurity/keeper/valset_updates.go index f0ecd0ee..a1955e5c 100644 --- a/x/meshsecurity/keeper/valset_updates.go +++ b/x/meshsecurity/keeper/valset_updates.go @@ -182,7 +182,12 @@ func (k Keeper) ValsetUpdateReport(ctx sdk.Context) (contract.ValsetUpdate, erro switch packet.Type { case cptypes.PipedValsetOperation_VALIDATOR_BONDED: data := packet.GetSchedulePacketData() - return appendValidator(&r.Additions, sdk.ValAddress(data.Validator)) + valAddr, err := sdk.ValAddressFromBech32(data.Validator) + if err != nil { + innerErr = types.ErrInvalid.Wrapf("validator does not exist %X", packet.Type) + return true + } + return appendValidator(&r.Additions, valAddr) case cptypes.PipedValsetOperation_VALIDATOR_UNBONDED: data := packet.GetSchedulePacketData() r.Removals = append(r.Removals, data.Validator) @@ -197,10 +202,20 @@ func (k Keeper) ValsetUpdateReport(ctx sdk.Context) (contract.ValsetUpdate, erro r.Unjailed = append(r.Unjailed, data.Validator) case cptypes.PipedValsetOperation_VALIDATOR_MODIFIED: data := packet.GetSchedulePacketData() - return appendValidator(&r.Updated, sdk.ValAddress(data.Validator)) + valAddr, err := sdk.ValAddressFromBech32(data.Validator) + if err != nil { + innerErr = types.ErrInvalid.Wrapf("validator does not exist %X", packet.Type) + return true + } + return appendValidator(&r.Updated, valAddr) case cptypes.PipedValsetOperation_VALIDATOR_SLASHED: data := packet.GetSlashPacketData() - return slashValidator(&r.Slashed, sdk.ValAddress(data.Validator), data.Power, data.InfractionHeight, data.TimeInfraction, + valAddr, err := sdk.ValAddressFromBech32(data.Validator) + if err != nil { + innerErr = types.ErrInvalid.Wrapf("validator does not exist %X", packet.Type) + return true + } + return slashValidator(&r.Slashed, valAddr, data.Power, data.InfractionHeight, data.TimeInfraction, data.TotalSlashAmount, data.SlashFraction) default: innerErr = types.ErrInvalid.Wrapf("undefined operation type %X", packet.Type) From cd5c518a6b07d608f9a659504c5a82ea90c8f09e Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Wed, 17 Jul 2024 16:58:33 +0700 Subject: [PATCH 05/14] updates e2e test --- tests/e2e/valset_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/e2e/valset_test.go b/tests/e2e/valset_test.go index 9d5201d3..303197bc 100644 --- a/tests/e2e/valset_test.go +++ b/tests/e2e/valset_test.go @@ -174,7 +174,9 @@ func jailValidator(t *testing.T, consAddr sdk.ConsAddress, coordinator *wasmibct ctx = chain.GetContext() signInfo.MissedBlocksCounter = app.SlashingKeeper.MinSignedPerWindow(ctx) app.SlashingKeeper.SetValidatorSigningInfo(ctx, consAddr, signInfo) - power := app.StakingKeeper.GetLastValidatorPower(ctx, sdk.ValAddress(consAddr)) + + v, _ := app.StakingKeeper.GetValidatorByConsAddr(ctx, consAddr) + power := app.StakingKeeper.GetLastValidatorPower(ctx, v.GetOperator()) app.SlashingKeeper.HandleValidatorSignature(ctx, cryptotypes.Address(consAddr), power, false) // when updates trigger chain.NextBlock() From d2ab52fb6e92cb4d613c4235474511867637cd95 Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Thu, 18 Jul 2024 14:37:08 +0700 Subject: [PATCH 06/14] fix test --- x/meshsecurity/keeper/adapter_test.go | 28 ++++++++++++++++---- x/meshsecurity/keeper/handler_plugin_test.go | 4 +-- x/meshsecurity/keeper/test_common.go | 6 +++++ x/meshsecurity/keeper/valset_updates.go | 6 ++--- x/meshsecurity/keeper/valset_updates_test.go | 27 ++++++++++++++++--- 5 files changed, 57 insertions(+), 14 deletions(-) diff --git a/x/meshsecurity/keeper/adapter_test.go b/x/meshsecurity/keeper/adapter_test.go index e8e692ee..7b0168c6 100644 --- a/x/meshsecurity/keeper/adapter_test.go +++ b/x/meshsecurity/keeper/adapter_test.go @@ -10,6 +10,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/address" evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" + minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" + "github.com/cosmos/cosmos-sdk/x/staking/types" cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" ) @@ -57,10 +59,18 @@ func TestCaptureTombstone(t *testing.T) { func TestCaptureStakingEvents(t *testing.T) { pCtx, keepers := CreateDefaultTestInput(t) + denom := keepers.StakingKeeper.BondDenom(pCtx) + coin := sdk.NewCoin(denom, sdk.NewIntFromUint64(1000000)) val := MinValidatorFixture(t) + val.Status = types.Bonded + val.Tokens = sdk.NewIntFromUint64(1000000) myConsAddress, err := val.GetConsAddr() require.NoError(t, err) + acc := sdk.AccAddress(rand.Bytes(32)) + keepers.BankKeeper.MintCoins(pCtx, minttypes.ModuleName, sdk.NewCoins([]sdk.Coin{coin}...)) + keepers.BankKeeper.SendCoinsFromModuleToAccount(pCtx, minttypes.ModuleName, acc, sdk.NewCoins([]sdk.Coin{coin}...)) + keepers.BankKeeper.DelegateCoinsFromAccountToModule(pCtx, acc, types.BondedPoolName, sdk.NewCoins([]sdk.Coin{coin}...)) keepers.StakingKeeper.SetValidatorByConsAddr(pCtx, val) keepers.StakingKeeper.SetValidator(pCtx, val) @@ -78,10 +88,17 @@ func TestCaptureStakingEvents(t *testing.T) { expStored []cptypes.PipedValsetOperation expJailed bool }{ - "jail": { - consAddr: myConsAddress, - op: decorator.Jail, - expStored: []cptypes.PipedValsetOperation{cptypes.PipedValsetOperation_VALIDATOR_JAILED}, + "slash and jail": { + consAddr: myConsAddress, + op: func(ctx sdk.Context, ca sdk.ConsAddress) { + decorator.Slash(ctx, ca, ctx.BlockHeight(), 1, sdk.MustNewDecFromStr("0.1")) + decorator.Jail(ctx, ca) + }, + expStored: []cptypes.PipedValsetOperation{ + cptypes.PipedValsetOperation_VALIDATOR_JAILED, + cptypes.PipedValsetOperation_VALIDATOR_MODIFIED, + cptypes.PipedValsetOperation_VALIDATOR_SLASHED, + }, expJailed: true, }, "unjail": { @@ -98,7 +115,8 @@ func TestCaptureStakingEvents(t *testing.T) { spec.op(ctx, spec.consAddr) // then - loadedVal := keepers.StakingKeeper.ValidatorByConsAddr(ctx, spec.consAddr) + loadedVal, found := keepers.StakingKeeper.GetValidatorByConsAddr(ctx, spec.consAddr) + assert.True(t, found) assert.Equal(t, spec.expJailed, loadedVal.IsJailed()) // and stored for async propagation allStoredOps := FetchAllStoredOperations(t, ctx, keepers.MeshKeeper) diff --git a/x/meshsecurity/keeper/handler_plugin_test.go b/x/meshsecurity/keeper/handler_plugin_test.go index 95bd947e..de002a0a 100644 --- a/x/meshsecurity/keeper/handler_plugin_test.go +++ b/x/meshsecurity/keeper/handler_plugin_test.go @@ -52,7 +52,7 @@ func TestCustomMeshSecDispatchMsg(t *testing.T) { return &msKeeperMock{DelegateFn: fn}, asserts }, expEvents: []sdk.Event{sdk.NewEvent("instant_delegate", - sdk.NewAttribute("module", "meshsecurity"), + sdk.NewAttribute("module", types.ModuleName), sdk.NewAttribute("validator", myValidatorAddr.String()), sdk.NewAttribute("amount", myAmount.String()), sdk.NewAttribute("delegator", myContractAddr.String()), @@ -77,7 +77,7 @@ func TestCustomMeshSecDispatchMsg(t *testing.T) { return &msKeeperMock{UndelegateFn: fn}, asserts }, expEvents: []sdk.Event{sdk.NewEvent("instant_unbond", - sdk.NewAttribute("module", "meshsecurity"), + sdk.NewAttribute("module", types.ModuleName), sdk.NewAttribute("validator", myValidatorAddr.String()), sdk.NewAttribute("amount", myAmount.String()), sdk.NewAttribute("sender", myContractAddr.String()), diff --git a/x/meshsecurity/keeper/test_common.go b/x/meshsecurity/keeper/test_common.go index 26279706..0b1964de 100644 --- a/x/meshsecurity/keeper/test_common.go +++ b/x/meshsecurity/keeper/test_common.go @@ -284,6 +284,12 @@ func CreateDefaultTestInput(t testing.TB, opts ...Option) (sdk.Context, TestKeep ) require.NoError(t, msKeeper.SetParams(ctx, types.DefaultParams(sdk.DefaultBondDenom))) + stakingKeeper.SetHooks( + stakingtypes.NewMultiStakingHooks( + slashingKeeper.Hooks(), + msKeeper.Hooks(), + ), + ) faucet := wasmkeeper.NewTestFaucet(t, ctx, bankKeeper, minttypes.ModuleName, sdk.NewInt64Coin(sdk.DefaultBondDenom, 1_000_000_000_000)) return ctx, TestKeepers{ AccountKeeper: accountKeeper, diff --git a/x/meshsecurity/keeper/valset_updates.go b/x/meshsecurity/keeper/valset_updates.go index a1955e5c..5260fcab 100644 --- a/x/meshsecurity/keeper/valset_updates.go +++ b/x/meshsecurity/keeper/valset_updates.go @@ -184,7 +184,7 @@ func (k Keeper) ValsetUpdateReport(ctx sdk.Context) (contract.ValsetUpdate, erro data := packet.GetSchedulePacketData() valAddr, err := sdk.ValAddressFromBech32(data.Validator) if err != nil { - innerErr = types.ErrInvalid.Wrapf("validator does not exist %X", packet.Type) + innerErr = types.ErrUnknown.Wrapf("validator does not exist %v", err) return true } return appendValidator(&r.Additions, valAddr) @@ -204,7 +204,7 @@ func (k Keeper) ValsetUpdateReport(ctx sdk.Context) (contract.ValsetUpdate, erro data := packet.GetSchedulePacketData() valAddr, err := sdk.ValAddressFromBech32(data.Validator) if err != nil { - innerErr = types.ErrInvalid.Wrapf("validator does not exist %X", packet.Type) + innerErr = types.ErrUnknown.Wrapf("validator does not exist %v", err) return true } return appendValidator(&r.Updated, valAddr) @@ -212,7 +212,7 @@ func (k Keeper) ValsetUpdateReport(ctx sdk.Context) (contract.ValsetUpdate, erro data := packet.GetSlashPacketData() valAddr, err := sdk.ValAddressFromBech32(data.Validator) if err != nil { - innerErr = types.ErrInvalid.Wrapf("validator does not exist %X", packet.Type) + innerErr = types.ErrUnknown.Wrapf("validator does not exist %v", err) return true } return slashValidator(&r.Slashed, valAddr, data.Power, data.InfractionHeight, data.TimeInfraction, diff --git a/x/meshsecurity/keeper/valset_updates_test.go b/x/meshsecurity/keeper/valset_updates_test.go index 8198bb0a..74646a86 100644 --- a/x/meshsecurity/keeper/valset_updates_test.go +++ b/x/meshsecurity/keeper/valset_updates_test.go @@ -230,7 +230,8 @@ func TestBuildValsetUpdateReport(t *testing.T) { } func TestValsetUpdateReportErrors(t *testing.T) { - nonValAddr := sdk.ValAddress(bytes.Repeat([]byte{1}, address.Len)) + nonVal := MinValidatorFixture(t) + nonValAddr := nonVal.GetOperator() pCtx, keepers := CreateDefaultTestInput(t) k := keepers.MeshKeeper @@ -255,7 +256,7 @@ func TestValsetUpdateReportErrors(t *testing.T) { "unsupported val operation": { setup: func(t *testing.T, ctx sdk.Context) { packet := cptypes.ConsumerPacketData{ - Type: cptypes.PipedValsetOperation_VALIDATOR_BONDED, + Type: 0xff, Data: &cptypes.ConsumerPacketData_SchedulePacketData{ SchedulePacketData: &cptypes.ScheduleInfo{ Validator: nonValAddr.String(), @@ -266,6 +267,21 @@ func TestValsetUpdateReportErrors(t *testing.T) { }, expErr: types.ErrInvalid, }, + "success": { + setup: func(t *testing.T, ctx sdk.Context) { + packet := cptypes.ConsumerPacketData{ + Type: cptypes.PipedValsetOperation_VALIDATOR_BONDED, + Data: &cptypes.ConsumerPacketData_SchedulePacketData{ + SchedulePacketData: &cptypes.ScheduleInfo{ + Validator: nonValAddr.String(), + }, + }, + } + keepers.StakingKeeper.SetValidator(pCtx, nonVal) + require.NoError(t, k.sendAsync(ctx, cptypes.PipedValsetOperation_VALIDATOR_BONDED, nonValAddr, packet)) + }, + expErr: nil, + }, } for name, spec := range specs { t.Run(name, func(t *testing.T) { @@ -273,8 +289,11 @@ func TestValsetUpdateReportErrors(t *testing.T) { spec.setup(t, ctx) // when _, gotErr := k.ValsetUpdateReport(ctx) - require.Error(t, gotErr) - assert.ErrorIs(t, spec.expErr, gotErr) + if spec.expErr != nil { + assert.ErrorIs(t, spec.expErr, gotErr) + } else { + assert.NoError(t, gotErr) + } }) } } From 47ed2f1dd05b1320144a9ff87227b657a1817aff Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Thu, 18 Jul 2024 15:04:32 +0700 Subject: [PATCH 07/14] minor keys --- x/meshsecurity/keeper/relay.go | 4 ++-- x/meshsecurity/types/keys.go | 7 ++----- x/provider/types/keys.go | 12 ++++++++---- x/types/key.go | 13 +++++++++---- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/x/meshsecurity/keeper/relay.go b/x/meshsecurity/keeper/relay.go index bae5d50b..5f5ead24 100644 --- a/x/meshsecurity/keeper/relay.go +++ b/x/meshsecurity/keeper/relay.go @@ -32,8 +32,8 @@ func (k Keeper) SendPackets(ctx sdk.Context) { ctx, k.scopedKeeper, k.channelKeeper, - channelID, // source channel id - ctypes.ConsumerPortID, // source port id + channelID, // source channel id + types.ConsumerPortID, // source port id s.GetBytes(), k.GetParams(ctx).GetTimeoutPeriod(), ) diff --git a/x/meshsecurity/types/keys.go b/x/meshsecurity/types/keys.go index 6fe5996d..2e1eb428 100644 --- a/x/meshsecurity/types/keys.go +++ b/x/meshsecurity/types/keys.go @@ -8,16 +8,13 @@ import ( const ( // ModuleName defines the module name. - ModuleName = "meshsecurityconsummer" - - // ConsumerPortID is the default port id the consumer module binds to - ConsumerPortID = "consumer" + ModuleName = "meshsecurity-consummer" // StoreKey defines the primary module store key. StoreKey = ModuleName // MemStoreKey defines the in-memory store key - MemStoreKey = "memory:meshsecurity" + MemStoreKey = "memory:meshsecurity-consummer" // RouterKey is the message route RouterKey = ModuleName diff --git a/x/provider/types/keys.go b/x/provider/types/keys.go index 44733548..d42c6286 100644 --- a/x/provider/types/keys.go +++ b/x/provider/types/keys.go @@ -5,10 +5,14 @@ import ( ) const ( - ModuleName = "meshsecurityprovider" - RouterKey = ModuleName - StoreKey = ModuleName - MemStoreKey = "memory:meshsecurityprovider" + // ModuleName defines the module name. + ModuleName = "meshsecurity-provider" + // RouterKey is the message route + RouterKey = ModuleName + // StoreKey defines the primary module store key. + StoreKey = ModuleName + // MemStoreKey defines the in-memory store key + MemStoreKey = "memory:meshsecurity-provider" ) var ( diff --git a/x/types/key.go b/x/types/key.go index 91643215..72316279 100644 --- a/x/types/key.go +++ b/x/types/key.go @@ -1,8 +1,13 @@ package types const ( - ModuleName = "MeshSecurity" - ProviderPortID = "provider" - ConsumerPortID = "consumer" - Version = "1" + ModuleName = "MeshSecurity" + + // ProviderPortID is the default port id the provider module binds to + ProviderPortID = "ms-provider" + + // ConsumerPortID is the default port id the consumer module binds to + ConsumerPortID = "ms-consumer" + + Version = "1" ) From 5e98d86be55607087efff62a5b7cada34664bd5f Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Thu, 18 Jul 2024 16:49:18 +0700 Subject: [PATCH 08/14] RegisterInterfaces for provider --- x/provider/types/codec.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x/provider/types/codec.go b/x/provider/types/codec.go index b24cdf84..518047b4 100644 --- a/x/provider/types/codec.go +++ b/x/provider/types/codec.go @@ -10,13 +10,18 @@ import ( // RegisterLegacyAminoCodec register types with legacy amino func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - + cdc.RegisterConcrete(&MsgDelegate{}, "provider/MsgDelegate", nil) + cdc.RegisterConcrete(&MsgUndelegate{}, "provider/MsgUndelegate", nil) + cdc.RegisterConcrete(&MsgSetConsumerCommissionRate{}, "provider/MsgSetConsumerCommissionRate", nil) } // RegisterInterfaces register types with interface registry func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), + &MsgDelegate{}, + &MsgUndelegate{}, + &MsgSetConsumerCommissionRate{}, ) } From 41381d55db28289fe607fb0af07af240871a188b Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Thu, 18 Jul 2024 17:39:10 +0700 Subject: [PATCH 09/14] updates --- x/provider/types/codec.go | 9 +++- x/provider/types/tx.go | 96 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 x/provider/types/tx.go diff --git a/x/provider/types/codec.go b/x/provider/types/codec.go index 518047b4..66763b8f 100644 --- a/x/provider/types/codec.go +++ b/x/provider/types/codec.go @@ -5,7 +5,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" - // "github.com/cosmos/cosmos-sdk/types/msgservice" + "github.com/cosmos/cosmos-sdk/types/msgservice" ) // RegisterLegacyAminoCodec register types with legacy amino @@ -20,9 +20,16 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), &MsgDelegate{}, + ) + registry.RegisterImplementations( + (*sdk.Msg)(nil), &MsgUndelegate{}, + ) + registry.RegisterImplementations( + (*sdk.Msg)(nil), &MsgSetConsumerCommissionRate{}, ) + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } var ( diff --git a/x/provider/types/tx.go b/x/provider/types/tx.go new file mode 100644 index 00000000..f2692c79 --- /dev/null +++ b/x/provider/types/tx.go @@ -0,0 +1,96 @@ +package types + +import ( + "strings" + + errorsmod "cosmossdk.io/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// GetSignBytes implements the LegacyMsg interface. +func (msg MsgDelegate) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners returns the expected signers for MsgSoftwareUpgrade. +func (msg MsgDelegate) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.DelegatorAddress) + return []sdk.AccAddress{addr} +} + +// ValidateBasic validate basic constraints +func (msg MsgDelegate) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.DelegatorAddress); err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address: %s", err) + } + if _, err := sdk.ValAddressFromBech32(msg.ValidatorAddress); err != nil { + return errorsmod.Wrap(err, "contract") + } + if err := msg.Amount.Validate(); err != nil { + return errorsmod.Wrap(err, "max cap") + } + return nil +} + +// GetSignBytes implements the LegacyMsg interface. +func (msg MsgUndelegate) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners returns the expected signers for MsgSoftwareUpgrade. +func (msg MsgUndelegate) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(msg.DelegatorAddress) + return []sdk.AccAddress{addr} +} + +// ValidateBasic validate basic constraints +func (msg MsgUndelegate) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(msg.DelegatorAddress); err != nil { + return sdkerrors.ErrInvalidAddress.Wrapf("invalid authority address: %s", err) + } + if _, err := sdk.ValAddressFromBech32(msg.ValidatorAddress); err != nil { + return errorsmod.Wrap(err, "contract") + } + if err := msg.Amount.Validate(); err != nil { + return errorsmod.Wrap(err, "max cap") + } + return nil +} + +// GetSignBytes implements the LegacyMsg interface. +func (msg MsgSetConsumerCommissionRate) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +// GetSigners returns the expected signers for MsgSoftwareUpgrade. +func (msg MsgSetConsumerCommissionRate) GetSigners() []sdk.AccAddress { + valAddr, err := sdk.ValAddressFromBech32(msg.ProviderAddr) + if err != nil { + // same behavior as in cosmos-sdk + panic(err) + } + return []sdk.AccAddress{valAddr.Bytes()} +} + +// ValidateBasic validate basic constraints +func (msg MsgSetConsumerCommissionRate) ValidateBasic() error { + if strings.TrimSpace(msg.ChainId) == "" { + panic("chainId cannot be blank") + } + + if 128 < len(msg.ChainId) { + panic("chainId cannot exceed 128 length") + } + _, err := sdk.ValAddressFromBech32(msg.ProviderAddr) + if err != nil { + panic(err) + } + + if msg.Rate.IsNegative() || msg.Rate.GT(sdk.OneDec()) { + panic("consumer commission rate should be in the range [0, 1]") + } + + return nil +} From c684f636113e8e10bd64a88859f8f6d8a5c54df7 Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Fri, 19 Jul 2024 14:06:56 +0700 Subject: [PATCH 10/14] rename povider to meshsecurityprovider --- .../v1beta1/delegate.proto | 4 +- .../v1beta1/genesis.proto | 6 +- .../v1beta1/params.proto | 6 +- .../v1beta1/query.proto | 8 +- .../v1beta1/tx.proto | 4 +- .../client/cli/query.go | 6 +- x/meshsecurityprovider/client/cli/tx.go | 75 +++++++++ .../contract/in_message.go | 0 .../ibc_module.go | 4 +- .../keeper/delegate.go | 4 +- .../keeper/genesis.go | 2 +- .../keeper/keeper.go | 5 +- .../keeper/keeper_test.go | 2 +- .../keeper/msg_server.go | 2 +- .../keeper/params.go | 2 +- .../keeper/querier.go | 2 +- .../keeper/relay.go | 2 +- .../keeper/relay_test.go | 0 .../keeper/test_common.go | 2 +- .../keeper/wasm.go | 2 +- .../module.go | 6 +- .../types/codec.go | 0 .../types/delegate.go | 0 .../types/delegate.pb.go | 0 .../types/errors.go | 0 .../types/events.go | 0 .../types/expected_keepers.go | 0 .../types/genesis.go | 0 .../types/genesis.pb.go | 0 .../types/keys.go | 0 .../types/params.go | 0 .../types/params.pb.go | 0 .../types/query.pb.go | 0 .../types/query.pb.gw.go | 0 .../types/tx.go | 9 ++ .../types/tx.pb.go | 0 x/provider/client/cli/gov_tx.go | 144 ------------------ x/provider/client/cli/tx.go | 27 ---- 38 files changed, 118 insertions(+), 206 deletions(-) rename proto/osmosis/{provider => meshsecurityprovider}/v1beta1/delegate.proto (95%) rename proto/osmosis/{provider => meshsecurityprovider}/v1beta1/genesis.proto (76%) rename proto/osmosis/{provider => meshsecurityprovider}/v1beta1/params.proto (79%) rename proto/osmosis/{provider => meshsecurityprovider}/v1beta1/query.proto (78%) rename proto/osmosis/{provider => meshsecurityprovider}/v1beta1/tx.proto (96%) rename x/{provider => meshsecurityprovider}/client/cli/query.go (90%) create mode 100644 x/meshsecurityprovider/client/cli/tx.go rename x/{provider => meshsecurityprovider}/contract/in_message.go (100%) rename x/{provider => meshsecurityprovider}/ibc_module.go (98%) rename x/{provider => meshsecurityprovider}/keeper/delegate.go (91%) rename x/{provider => meshsecurityprovider}/keeper/genesis.go (82%) rename x/{provider => meshsecurityprovider}/keeper/keeper.go (98%) rename x/{provider => meshsecurityprovider}/keeper/keeper_test.go (95%) rename x/{provider => meshsecurityprovider}/keeper/msg_server.go (97%) rename x/{provider => meshsecurityprovider}/keeper/params.go (89%) rename x/{provider => meshsecurityprovider}/keeper/querier.go (89%) rename x/{provider => meshsecurityprovider}/keeper/relay.go (98%) rename x/{provider => meshsecurityprovider}/keeper/relay_test.go (100%) rename x/{provider => meshsecurityprovider}/keeper/test_common.go (99%) rename x/{provider => meshsecurityprovider}/keeper/wasm.go (88%) rename x/{provider => meshsecurityprovider}/module.go (95%) rename x/{provider => meshsecurityprovider}/types/codec.go (100%) rename x/{provider => meshsecurityprovider}/types/delegate.go (100%) rename x/{provider => meshsecurityprovider}/types/delegate.pb.go (100%) rename x/{provider => meshsecurityprovider}/types/errors.go (100%) rename x/{provider => meshsecurityprovider}/types/events.go (100%) rename x/{provider => meshsecurityprovider}/types/expected_keepers.go (100%) rename x/{provider => meshsecurityprovider}/types/genesis.go (100%) rename x/{provider => meshsecurityprovider}/types/genesis.pb.go (100%) rename x/{provider => meshsecurityprovider}/types/keys.go (100%) rename x/{provider => meshsecurityprovider}/types/params.go (100%) rename x/{provider => meshsecurityprovider}/types/params.pb.go (100%) rename x/{provider => meshsecurityprovider}/types/query.pb.go (100%) rename x/{provider => meshsecurityprovider}/types/query.pb.gw.go (100%) rename x/{provider => meshsecurityprovider}/types/tx.go (88%) rename x/{provider => meshsecurityprovider}/types/tx.pb.go (100%) delete mode 100644 x/provider/client/cli/gov_tx.go delete mode 100644 x/provider/client/cli/tx.go diff --git a/proto/osmosis/provider/v1beta1/delegate.proto b/proto/osmosis/meshsecurityprovider/v1beta1/delegate.proto similarity index 95% rename from proto/osmosis/provider/v1beta1/delegate.proto rename to proto/osmosis/meshsecurityprovider/v1beta1/delegate.proto index 4611fe99..78f36146 100644 --- a/proto/osmosis/provider/v1beta1/delegate.proto +++ b/proto/osmosis/meshsecurityprovider/v1beta1/delegate.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package osmosis.provider.v1beta1; +package osmosis.meshsecurityprovider.v1beta1; import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "amino/amino.proto"; -option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types"; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = false; diff --git a/proto/osmosis/provider/v1beta1/genesis.proto b/proto/osmosis/meshsecurityprovider/v1beta1/genesis.proto similarity index 76% rename from proto/osmosis/provider/v1beta1/genesis.proto rename to proto/osmosis/meshsecurityprovider/v1beta1/genesis.proto index 5829ce22..aff7fb21 100644 --- a/proto/osmosis/provider/v1beta1/genesis.proto +++ b/proto/osmosis/meshsecurityprovider/v1beta1/genesis.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package osmosis.provider.v1beta1; +package osmosis.meshsecurityprovider.v1beta1; -import "osmosis/provider/v1beta1/params.proto"; +import "osmosis/meshsecurityprovider/v1beta1/params.proto"; import "gogoproto/gogo.proto"; import "amino/amino.proto"; -option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types"; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = false; diff --git a/proto/osmosis/provider/v1beta1/params.proto b/proto/osmosis/meshsecurityprovider/v1beta1/params.proto similarity index 79% rename from proto/osmosis/provider/v1beta1/params.proto rename to proto/osmosis/meshsecurityprovider/v1beta1/params.proto index 9f76fd35..646d23cd 100644 --- a/proto/osmosis/provider/v1beta1/params.proto +++ b/proto/osmosis/meshsecurityprovider/v1beta1/params.proto @@ -1,17 +1,17 @@ syntax = "proto3"; -package osmosis.provider.v1beta1; +package osmosis.meshsecurityprovider.v1beta1; import "cosmos/base/v1beta1/coin.proto"; import "gogoproto/gogo.proto"; import "amino/amino.proto"; -option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types"; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = false; // Params defines the parameters for the x/meshsecurity module. message Params { - option (amino.name) = "provider/Params"; + option (amino.name) = "meshsecurityprovider/Params"; option (gogoproto.equal) = true; // TimeoutPeriod has the unit time.Millisecond diff --git a/proto/osmosis/provider/v1beta1/query.proto b/proto/osmosis/meshsecurityprovider/v1beta1/query.proto similarity index 78% rename from proto/osmosis/provider/v1beta1/query.proto rename to proto/osmosis/meshsecurityprovider/v1beta1/query.proto index 535d98a2..3b58da35 100644 --- a/proto/osmosis/provider/v1beta1/query.proto +++ b/proto/osmosis/meshsecurityprovider/v1beta1/query.proto @@ -1,13 +1,13 @@ syntax = "proto3"; -package osmosis.provider.v1beta1; +package osmosis.meshsecurityprovider.v1beta1; import "cosmos/base/v1beta1/coin.proto"; -import "osmosis/provider/v1beta1/params.proto"; +import "osmosis/meshsecurityprovider/v1beta1/params.proto"; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "amino/amino.proto"; -option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types"; option (gogoproto.goproto_getters_all) = false; option (gogoproto.equal_all) = false; @@ -15,7 +15,7 @@ option (gogoproto.equal_all) = false; service Query { // Params queries the parameters of x/meshsecurity module. rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/osmosis/provider/v1beta1/params"; + option (google.api.http).get = "/osmosis/meshsecurityprovider/v1beta1/params"; } } // QueryParamsRequest is the request type for the diff --git a/proto/osmosis/provider/v1beta1/tx.proto b/proto/osmosis/meshsecurityprovider/v1beta1/tx.proto similarity index 96% rename from proto/osmosis/provider/v1beta1/tx.proto rename to proto/osmosis/meshsecurityprovider/v1beta1/tx.proto index ca725e0c..a2d1265b 100644 --- a/proto/osmosis/provider/v1beta1/tx.proto +++ b/proto/osmosis/meshsecurityprovider/v1beta1/tx.proto @@ -1,5 +1,5 @@ syntax = "proto3"; -package osmosis.provider.v1beta1; +package osmosis.meshsecurityprovider.v1beta1; import "cosmos_proto/cosmos.proto"; import "cosmos/msg/v1/msg.proto"; @@ -7,7 +7,7 @@ import "gogoproto/gogo.proto"; import "amino/amino.proto"; import "cosmos/base/v1beta1/coin.proto"; -option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/provider/types"; +option go_package = "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types"; option (gogoproto.goproto_getters_all) = false; service Msg { diff --git a/x/provider/client/cli/query.go b/x/meshsecurityprovider/client/cli/query.go similarity index 90% rename from x/provider/client/cli/query.go rename to x/meshsecurityprovider/client/cli/query.go index 285789a8..68beafc2 100644 --- a/x/provider/client/cli/query.go +++ b/x/meshsecurityprovider/client/cli/query.go @@ -10,13 +10,13 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/version" - "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" ) func GetQueryCmd() *cobra.Command { queryCmd := &cobra.Command{ Use: types.ModuleName, - Short: "Querying commands for the mesh security module", + Short: "Querying commands for the mesh security provider module", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, @@ -38,7 +38,7 @@ func GetCmdQueryParams() *cobra.Command { fmt.Sprintf(`Query values set as mesh-security parameters. Example: -$ %s query meshsecurity params +$ %s query meshsecurity-provider params `, version.AppName, ), diff --git a/x/meshsecurityprovider/client/cli/tx.go b/x/meshsecurityprovider/client/cli/tx.go new file mode 100644 index 00000000..2b3a4443 --- /dev/null +++ b/x/meshsecurityprovider/client/cli/tx.go @@ -0,0 +1,75 @@ +package cli + +import ( + "fmt" + "github.com/spf13/cobra" + "strings" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" + + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" +) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Mesh security transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + SilenceUsage: true, + } + + txCmd.AddCommand(NewSetConsumerCommissionRateCmd()) + return txCmd +} + +func NewSetConsumerCommissionRateCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-consumer-commission-rate [consumer-chain-id] [commission-rate]", + Short: "set a per-consumer chain commission", + Long: strings.TrimSpace( + fmt.Sprintf(`Note that the "commission-rate" argument is a fraction and should be in the range [0,1]. + Example: + %s set-consumer-commission-rate consumer-1 0.5 --from node0 --home ../node0`, + version.AppName), + ), + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + txf, err := tx.NewFactoryCLI(clientCtx, cmd.Flags()) + if err != nil { + return err + } + txf = txf.WithTxConfig(clientCtx.TxConfig).WithAccountRetriever(clientCtx.AccountRetriever) + + providerValAddr := clientCtx.GetFromAddress() + + commission, err := sdk.NewDecFromStr(args[1]) + if err != nil { + return err + } + msg := types.NewMsgSetConsumerCommissionRate(args[0], commission, sdk.ValAddress(providerValAddr)) + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxWithFactory(clientCtx, txf, msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + _ = cmd.MarkFlagRequired(flags.FlagFrom) + + return cmd +} diff --git a/x/provider/contract/in_message.go b/x/meshsecurityprovider/contract/in_message.go similarity index 100% rename from x/provider/contract/in_message.go rename to x/meshsecurityprovider/contract/in_message.go diff --git a/x/provider/ibc_module.go b/x/meshsecurityprovider/ibc_module.go similarity index 98% rename from x/provider/ibc_module.go rename to x/meshsecurityprovider/ibc_module.go index c67dffe8..8cb7a883 100644 --- a/x/provider/ibc_module.go +++ b/x/meshsecurityprovider/ibc_module.go @@ -17,8 +17,8 @@ import ( // transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/keeper" - types "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/keeper" + types "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" ) diff --git a/x/provider/keeper/delegate.go b/x/meshsecurityprovider/keeper/delegate.go similarity index 91% rename from x/provider/keeper/delegate.go rename to x/meshsecurityprovider/keeper/delegate.go index d9b81e2b..768c60a5 100644 --- a/x/provider/keeper/delegate.go +++ b/x/meshsecurityprovider/keeper/delegate.go @@ -5,8 +5,8 @@ import ( // stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/contract" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/contract" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" ) func (k Keeper) LocalStake(ctx sdk.Context, token sdk.Coin, valAddr string) error { diff --git a/x/provider/keeper/genesis.go b/x/meshsecurityprovider/keeper/genesis.go similarity index 82% rename from x/provider/keeper/genesis.go rename to x/meshsecurityprovider/keeper/genesis.go index d7e1391c..795a6daa 100644 --- a/x/provider/keeper/genesis.go +++ b/x/meshsecurityprovider/keeper/genesis.go @@ -3,7 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" ) func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { diff --git a/x/provider/keeper/keeper.go b/x/meshsecurityprovider/keeper/keeper.go similarity index 98% rename from x/provider/keeper/keeper.go rename to x/meshsecurityprovider/keeper/keeper.go index e83a86b7..de4536a0 100644 --- a/x/provider/keeper/keeper.go +++ b/x/meshsecurityprovider/keeper/keeper.go @@ -21,8 +21,7 @@ import ( ibchost "github.com/cosmos/ibc-go/v7/modules/core/exported" ibctmtypes "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" - ctypes "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" ) @@ -117,7 +116,7 @@ func (k Keeper) SetConsumerChain(ctx sdk.Context, channelID string) error { ctx.EventManager().EmitEvent( sdk.NewEvent( cptypes.EventTypeChannelEstablished, - sdk.NewAttribute(sdk.AttributeKeyModule, ctypes.ModuleName), + sdk.NewAttribute(sdk.AttributeKeyModule, types.ModuleName), sdk.NewAttribute(cptypes.AttributeChainID, chainID), sdk.NewAttribute(conntypes.AttributeKeyClientID, clientID), sdk.NewAttribute(channeltypes.AttributeKeyChannelID, channelID), diff --git a/x/provider/keeper/keeper_test.go b/x/meshsecurityprovider/keeper/keeper_test.go similarity index 95% rename from x/provider/keeper/keeper_test.go rename to x/meshsecurityprovider/keeper/keeper_test.go index 0a4b9493..2817ada8 100644 --- a/x/provider/keeper/keeper_test.go +++ b/x/meshsecurityprovider/keeper/keeper_test.go @@ -4,7 +4,7 @@ import ( "testing" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" "github.com/stretchr/testify/require" ) diff --git a/x/provider/keeper/msg_server.go b/x/meshsecurityprovider/keeper/msg_server.go similarity index 97% rename from x/provider/keeper/msg_server.go rename to x/meshsecurityprovider/keeper/msg_server.go index 41e5c125..8c213d45 100644 --- a/x/provider/keeper/msg_server.go +++ b/x/meshsecurityprovider/keeper/msg_server.go @@ -6,7 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" ) type msgServer struct { diff --git a/x/provider/keeper/params.go b/x/meshsecurityprovider/keeper/params.go similarity index 89% rename from x/provider/keeper/params.go rename to x/meshsecurityprovider/keeper/params.go index c4949cb9..bccc5161 100644 --- a/x/provider/keeper/params.go +++ b/x/meshsecurityprovider/keeper/params.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" ) // SetParams sets the module's parameters. diff --git a/x/provider/keeper/querier.go b/x/meshsecurityprovider/keeper/querier.go similarity index 89% rename from x/provider/keeper/querier.go rename to x/meshsecurityprovider/keeper/querier.go index 0120562d..0bab8edf 100644 --- a/x/provider/keeper/querier.go +++ b/x/meshsecurityprovider/keeper/querier.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" ) var _ types.QueryServer = &querier{} diff --git a/x/provider/keeper/relay.go b/x/meshsecurityprovider/keeper/relay.go similarity index 98% rename from x/provider/keeper/relay.go rename to x/meshsecurityprovider/keeper/relay.go index e1f4f654..ccd9d4a2 100644 --- a/x/provider/keeper/relay.go +++ b/x/meshsecurityprovider/keeper/relay.go @@ -10,7 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" cptypes "github.com/osmosis-labs/mesh-security-sdk/x/types" ) diff --git a/x/provider/keeper/relay_test.go b/x/meshsecurityprovider/keeper/relay_test.go similarity index 100% rename from x/provider/keeper/relay_test.go rename to x/meshsecurityprovider/keeper/relay_test.go diff --git a/x/provider/keeper/test_common.go b/x/meshsecurityprovider/keeper/test_common.go similarity index 99% rename from x/provider/keeper/test_common.go rename to x/meshsecurityprovider/keeper/test_common.go index b7728332..184322f3 100644 --- a/x/provider/keeper/test_common.go +++ b/x/meshsecurityprovider/keeper/test_common.go @@ -59,7 +59,7 @@ import ( upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" ) type encodingConfig struct { diff --git a/x/provider/keeper/wasm.go b/x/meshsecurityprovider/keeper/wasm.go similarity index 88% rename from x/provider/keeper/wasm.go rename to x/meshsecurityprovider/keeper/wasm.go index e91b681e..e56945ff 100644 --- a/x/provider/keeper/wasm.go +++ b/x/meshsecurityprovider/keeper/wasm.go @@ -7,7 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/contract" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/contract" ) func (k Keeper) SendVaultStake(ctx sdk.Context, v contract.StakeMsg) error { diff --git a/x/provider/module.go b/x/meshsecurityprovider/module.go similarity index 95% rename from x/provider/module.go rename to x/meshsecurityprovider/module.go index 6cb101f3..79062e05 100644 --- a/x/provider/module.go +++ b/x/meshsecurityprovider/module.go @@ -16,9 +16,9 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" porttypes "github.com/cosmos/ibc-go/v7/modules/core/05-port/types" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/client/cli" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/keeper" - "github.com/osmosis-labs/mesh-security-sdk/x/provider/types" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/client/cli" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/keeper" + "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" ) var ( diff --git a/x/provider/types/codec.go b/x/meshsecurityprovider/types/codec.go similarity index 100% rename from x/provider/types/codec.go rename to x/meshsecurityprovider/types/codec.go diff --git a/x/provider/types/delegate.go b/x/meshsecurityprovider/types/delegate.go similarity index 100% rename from x/provider/types/delegate.go rename to x/meshsecurityprovider/types/delegate.go diff --git a/x/provider/types/delegate.pb.go b/x/meshsecurityprovider/types/delegate.pb.go similarity index 100% rename from x/provider/types/delegate.pb.go rename to x/meshsecurityprovider/types/delegate.pb.go diff --git a/x/provider/types/errors.go b/x/meshsecurityprovider/types/errors.go similarity index 100% rename from x/provider/types/errors.go rename to x/meshsecurityprovider/types/errors.go diff --git a/x/provider/types/events.go b/x/meshsecurityprovider/types/events.go similarity index 100% rename from x/provider/types/events.go rename to x/meshsecurityprovider/types/events.go diff --git a/x/provider/types/expected_keepers.go b/x/meshsecurityprovider/types/expected_keepers.go similarity index 100% rename from x/provider/types/expected_keepers.go rename to x/meshsecurityprovider/types/expected_keepers.go diff --git a/x/provider/types/genesis.go b/x/meshsecurityprovider/types/genesis.go similarity index 100% rename from x/provider/types/genesis.go rename to x/meshsecurityprovider/types/genesis.go diff --git a/x/provider/types/genesis.pb.go b/x/meshsecurityprovider/types/genesis.pb.go similarity index 100% rename from x/provider/types/genesis.pb.go rename to x/meshsecurityprovider/types/genesis.pb.go diff --git a/x/provider/types/keys.go b/x/meshsecurityprovider/types/keys.go similarity index 100% rename from x/provider/types/keys.go rename to x/meshsecurityprovider/types/keys.go diff --git a/x/provider/types/params.go b/x/meshsecurityprovider/types/params.go similarity index 100% rename from x/provider/types/params.go rename to x/meshsecurityprovider/types/params.go diff --git a/x/provider/types/params.pb.go b/x/meshsecurityprovider/types/params.pb.go similarity index 100% rename from x/provider/types/params.pb.go rename to x/meshsecurityprovider/types/params.pb.go diff --git a/x/provider/types/query.pb.go b/x/meshsecurityprovider/types/query.pb.go similarity index 100% rename from x/provider/types/query.pb.go rename to x/meshsecurityprovider/types/query.pb.go diff --git a/x/provider/types/query.pb.gw.go b/x/meshsecurityprovider/types/query.pb.gw.go similarity index 100% rename from x/provider/types/query.pb.gw.go rename to x/meshsecurityprovider/types/query.pb.gw.go diff --git a/x/provider/types/tx.go b/x/meshsecurityprovider/types/tx.go similarity index 88% rename from x/provider/types/tx.go rename to x/meshsecurityprovider/types/tx.go index f2692c79..871f996a 100644 --- a/x/provider/types/tx.go +++ b/x/meshsecurityprovider/types/tx.go @@ -59,6 +59,15 @@ func (msg MsgUndelegate) ValidateBasic() error { return nil } +// NewMsgSetConsumerCommissionRate creates a new MsgSetConsumerCommissionRate msg instance. +func NewMsgSetConsumerCommissionRate(chainID string, commission sdk.Dec, providerValidatorAddress sdk.ValAddress) *MsgSetConsumerCommissionRate { + return &MsgSetConsumerCommissionRate{ + ChainId: chainID, + Rate: commission, + ProviderAddr: providerValidatorAddress.String(), + } +} + // GetSignBytes implements the LegacyMsg interface. func (msg MsgSetConsumerCommissionRate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) diff --git a/x/provider/types/tx.pb.go b/x/meshsecurityprovider/types/tx.pb.go similarity index 100% rename from x/provider/types/tx.pb.go rename to x/meshsecurityprovider/types/tx.pb.go diff --git a/x/provider/client/cli/gov_tx.go b/x/provider/client/cli/gov_tx.go deleted file mode 100644 index 22186946..00000000 --- a/x/provider/client/cli/gov_tx.go +++ /dev/null @@ -1,144 +0,0 @@ -package cli - -import ( - "fmt" - "strings" - - "github.com/pkg/errors" - "github.com/spf13/cobra" - - errorsmod "cosmossdk.io/errors" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" - "github.com/cosmos/cosmos-sdk/version" - "github.com/cosmos/cosmos-sdk/x/gov/client/cli" - v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" - - "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" -) - -// DefaultGovAuthority is set to the gov module address. -// Extension point for chains to overwrite the default -var DefaultGovAuthority = sdk.AccAddress(address.Module("gov")) - -func SubmitProposalCmd() *cobra.Command { - cmd := &cobra.Command{ - Use: "submit-proposal", - Short: "Submit a mesh security proposal.", - SilenceUsage: true, - } - cmd.AddCommand( - ProposalSetVirtualStakingMaxCapCmd(), - ) - return cmd -} - -func ProposalSetVirtualStakingMaxCapCmd() *cobra.Command { - bech32Prefix := sdk.GetConfig().GetBech32AccountAddrPrefix() - cmd := &cobra.Command{ - Use: "set-virtual-staking-max-cap [contract_addr_bech32] [max_cap] --title [text] --summary [text] --authority [address]", - Short: "Submit a set virtual staking max cap proposal", - Args: cobra.ExactArgs(2), - Long: strings.TrimSpace( - fmt.Sprintf(`Submit a proposal to set virtual staking maximum cap limit to the given contract. - -Example: -$ %s tx meshsecurity submit-proposal set-virtual-staking-max-cap %s1l94ptufswr6v7qntax4m7nvn3jgf6k4gn2rknq 100stake --title "a title" --summary "a summary" --authority %s -`, version.AppName, bech32Prefix, DefaultGovAuthority.String())), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, metadata, deposit, err := getProposalInfo(cmd) - if err != nil { - return err - } - authority, err := cmd.Flags().GetString(flagAuthority) - if err != nil { - return fmt.Errorf("authority: %s", err) - } - - if len(authority) == 0 { - return errors.New("authority address is required") - } - - src, err := parseSetVirtualStakingMaxCapArgs(args, authority) - if err != nil { - return err - } - - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), metadata, proposalTitle, summary) - if err != nil { - return err - } - if err = proposalMsg.ValidateBasic(); err != nil { - return err - } - - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposalMsg) - }, - SilenceUsage: true, - } - - // proposal flags - addCommonProposalFlags(cmd) - return cmd -} - -func parseSetVirtualStakingMaxCapArgs(args []string, authority string) (types.MsgSetVirtualStakingMaxCap, error) { - maxCap, err := sdk.ParseCoinNormalized(args[1]) - if err != nil { - return types.MsgSetVirtualStakingMaxCap{}, errorsmod.Wrap(err, "max cap") - } - - msg := types.MsgSetVirtualStakingMaxCap{ - Authority: authority, - Contract: args[0], - MaxCap: maxCap, - } - return msg, nil -} - -func addCommonProposalFlags(cmd *cobra.Command) { - flags.AddTxFlagsToCmd(cmd) - cmd.Flags().String(cli.FlagTitle, "", "Title of proposal") - cmd.Flags().String(cli.FlagSummary, "", "Summary of proposal") - cmd.Flags().String(cli.FlagMetadata, "", "Metadata of proposal") - cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") - cmd.Flags().String(flagAuthority, DefaultGovAuthority.String(), "The address of the governance account. Default is the sdk gov module account") -} - -func getProposalInfo(cmd *cobra.Command) (client.Context, string, string, string, sdk.Coins, error) { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return client.Context{}, "", "", "", nil, err - } - - proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle) - if err != nil { - return clientCtx, proposalTitle, "", "", nil, err - } - - summary, err := cmd.Flags().GetString(cli.FlagSummary) - if err != nil { - return client.Context{}, proposalTitle, summary, "", nil, err - } - - metadata, err := cmd.Flags().GetString(cli.FlagMetadata) - if err != nil { - return client.Context{}, proposalTitle, summary, metadata, nil, err - } - - depositArg, err := cmd.Flags().GetString(cli.FlagDeposit) - if err != nil { - return client.Context{}, proposalTitle, summary, metadata, nil, err - } - - deposit, err := sdk.ParseCoinsNormalized(depositArg) - if err != nil { - return client.Context{}, proposalTitle, summary, metadata, deposit, err - } - - return clientCtx, proposalTitle, summary, metadata, deposit, nil -} diff --git a/x/provider/client/cli/tx.go b/x/provider/client/cli/tx.go deleted file mode 100644 index 17525d88..00000000 --- a/x/provider/client/cli/tx.go +++ /dev/null @@ -1,27 +0,0 @@ -package cli - -import ( - "github.com/spf13/cobra" - - "github.com/cosmos/cosmos-sdk/client" - - "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurity/types" -) - -const flagAuthority = "authority" - -// GetTxCmd returns the transaction commands for this module -func GetTxCmd() *cobra.Command { - txCmd := &cobra.Command{ - Use: types.ModuleName, - Short: "Mesh security transaction subcommands", - DisableFlagParsing: true, - SuggestionsMinimumDistance: 2, - RunE: client.ValidateCmd, - SilenceUsage: true, - } - txCmd.AddCommand( - SubmitProposalCmd(), - ) - return txCmd -} From 0370f42cc36813797e6b535a339feb15efb3da87 Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Mon, 22 Jul 2024 10:39:36 +0700 Subject: [PATCH 11/14] rename --- x/meshsecurity/keeper/relay.go | 2 +- x/meshsecurity/keeper/valset_updates.go | 2 +- x/types/wire.go | 2 +- x/types/wire_test.go | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/x/meshsecurity/keeper/relay.go b/x/meshsecurity/keeper/relay.go index 5f5ead24..366c8d75 100644 --- a/x/meshsecurity/keeper/relay.go +++ b/x/meshsecurity/keeper/relay.go @@ -34,7 +34,7 @@ func (k Keeper) SendPackets(ctx sdk.Context) { k.channelKeeper, channelID, // source channel id types.ConsumerPortID, // source port id - s.GetBytes(), + s.MarshalConsumerPacketData(), k.GetParams(ctx).GetTimeoutPeriod(), ) if err != nil { diff --git a/x/meshsecurity/keeper/valset_updates.go b/x/meshsecurity/keeper/valset_updates.go index 5260fcab..3c8eb79a 100644 --- a/x/meshsecurity/keeper/valset_updates.go +++ b/x/meshsecurity/keeper/valset_updates.go @@ -124,7 +124,7 @@ func (k Keeper) ScheduleModified(ctx sdk.Context, addr sdk.ValAddress) error { func (k Keeper) sendAsync(ctx sdk.Context, op cptypes.PipedValsetOperation, valAddr sdk.ValAddress, packet cptypes.ConsumerPacketData) error { // if op ModuleLogger(ctx).Debug("storing for async update", "operation", int(op), "val", valAddr.String()) - value := packet.GetBytes() + value := packet.MarshalConsumerPacketData() ctx.KVStore(k.memKey).Set(types.BuildPipedValsetOpKey(op, valAddr), value) // and schedule an update callback for all registered contracts var innerErr error diff --git a/x/types/wire.go b/x/types/wire.go index c9f8e2a8..6da90e76 100644 --- a/x/types/wire.go +++ b/x/types/wire.go @@ -5,7 +5,7 @@ import ( "encoding/binary" ) -func (c ConsumerPacketData) GetBytes() []byte { +func (c ConsumerPacketData) MarshalConsumerPacketData() []byte { var bytes []byte bytes = append(bytes, Int32ToBytes(int32(c.Type))...) if c.Type != PipedValsetOperation_VALIDATOR_SLASHED { diff --git a/x/types/wire_test.go b/x/types/wire_test.go index 16d02a17..6473e42f 100644 --- a/x/types/wire_test.go +++ b/x/types/wire_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestGetBytesAndGetData(t *testing.T) { +func TestGetBytesAndUnmarshalConsumerPacketData(t *testing.T) { c1 := ConsumerPacketData{ Type: PipedValsetOperation_VALIDATOR_SLASHED, Data: &ConsumerPacketData_SlashPacketData{ @@ -20,7 +20,7 @@ func TestGetBytesAndGetData(t *testing.T) { }, } - data := c1.GetBytes() + data := c1.MarshalConsumerPacketData() c2, err := UnmarshalConsumerPacketData(data) require.NoError(t, err) require.Equal(t, c1, c2) @@ -40,7 +40,7 @@ func TestGetBytesAndGetData(t *testing.T) { }, }, } - data = s1.GetBytes() + data = s1.MarshalConsumerPacketData() s2, err := UnmarshalConsumerPacketData(data) require.NoError(t, err) require.Equal(t, s1, s2) From 50ba5e342041a4d457e8ebb8bfb1045eed26a81d Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Mon, 22 Jul 2024 10:47:47 +0700 Subject: [PATCH 12/14] minor --- x/meshsecurityprovider/ibc_module.go | 2 +- x/meshsecurityprovider/keeper/keeper_test.go | 7 ++++--- x/meshsecurityprovider/module.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/x/meshsecurityprovider/ibc_module.go b/x/meshsecurityprovider/ibc_module.go index 8cb7a883..ae7a90e4 100644 --- a/x/meshsecurityprovider/ibc_module.go +++ b/x/meshsecurityprovider/ibc_module.go @@ -1,4 +1,4 @@ -package provider +package meshsecurityprovider import ( "fmt" diff --git a/x/meshsecurityprovider/keeper/keeper_test.go b/x/meshsecurityprovider/keeper/keeper_test.go index 2817ada8..1ff7f433 100644 --- a/x/meshsecurityprovider/keeper/keeper_test.go +++ b/x/meshsecurityprovider/keeper/keeper_test.go @@ -3,6 +3,7 @@ package keeper import ( "testing" + "github.com/cometbft/cometbft/libs/rand" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" "github.com/stretchr/testify/require" @@ -13,7 +14,7 @@ func TestStoreDelegator(t *testing.T) { k := keepers.MeshKeeperProvider d1 := types.Depositors{ - Address: "delegate", + Address: sdk.AccAddress(rand.Bytes(32)).String(), Tokens: sdk.NewCoins([]sdk.Coin{sdk.NewCoin("osmo", sdk.NewInt(123))}...), } err := k.SetDepositors(pCtx, d1) @@ -39,9 +40,9 @@ func TestStoreIntermediary(t *testing.T) { coin := sdk.NewCoin("osmo", sdk.NewInt(123)) e1 := types.Intermediary{ - ConsumerValidator: "validator", + ConsumerValidator: sdk.ValAddress(rand.Bytes(32)).String(), ChainId: "osmo-1", - ContractAddress: "address", + ContractAddress: sdk.AccAddress(rand.Bytes(32)).String(), Jailed: false, Tombstoned: false, Status: types.Bonded, diff --git a/x/meshsecurityprovider/module.go b/x/meshsecurityprovider/module.go index 79062e05..aefb7763 100644 --- a/x/meshsecurityprovider/module.go +++ b/x/meshsecurityprovider/module.go @@ -1,4 +1,4 @@ -package provider +package meshsecurityprovider import ( "context" From 09db0b63a9c7f5f70e9a1e9a9c9c2daba438d6a9 Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Mon, 22 Jul 2024 15:53:18 +0700 Subject: [PATCH 13/14] updates --- proto/osmosis/types/v1beta1/wire.proto | 1 + x/meshsecurity/keeper/valset_updates.go | 6 + x/meshsecurityprovider/keeper/relay.go | 80 ++++++++++++ x/meshsecurityprovider/types/delegate.pb.go | 95 +++++++------- x/meshsecurityprovider/types/genesis.pb.go | 44 +++---- x/meshsecurityprovider/types/params.pb.go | 50 ++++---- x/meshsecurityprovider/types/query.pb.go | 72 +++++------ x/meshsecurityprovider/types/query.pb.gw.go | 4 +- x/meshsecurityprovider/types/tx.pb.go | 130 +++++++++---------- x/types/wire.pb.go | 135 +++++++++++++------- 10 files changed, 376 insertions(+), 241 deletions(-) diff --git a/proto/osmosis/types/v1beta1/wire.proto b/proto/osmosis/types/v1beta1/wire.proto index 66adb1af..cb1e5187 100644 --- a/proto/osmosis/types/v1beta1/wire.proto +++ b/proto/osmosis/types/v1beta1/wire.proto @@ -38,6 +38,7 @@ message SlashInfo { message ScheduleInfo { string validator = 1; string actor = 2; + string denom = 3; } // ConsumerPacketData contains a consumer packet data and a type tag diff --git a/x/meshsecurity/keeper/valset_updates.go b/x/meshsecurity/keeper/valset_updates.go index 3c8eb79a..0e19b096 100644 --- a/x/meshsecurity/keeper/valset_updates.go +++ b/x/meshsecurity/keeper/valset_updates.go @@ -21,6 +21,7 @@ func (k Keeper) ScheduleBonded(ctx sdk.Context, addr sdk.ValAddress) error { Data: &cptypes.ConsumerPacketData_SchedulePacketData{ SchedulePacketData: &cptypes.ScheduleInfo{ Validator: addr.String(), + Denom: k.Staking.BondDenom(ctx), }, }, } @@ -34,6 +35,7 @@ func (k Keeper) ScheduleUnbonded(ctx sdk.Context, addr sdk.ValAddress) error { Data: &cptypes.ConsumerPacketData_SchedulePacketData{ SchedulePacketData: &cptypes.ScheduleInfo{ Validator: addr.String(), + Denom: k.Staking.BondDenom(ctx), }, }, } @@ -74,6 +76,7 @@ func (k Keeper) ScheduleJailed(ctx sdk.Context, addr sdk.ValAddress) error { Data: &cptypes.ConsumerPacketData_SchedulePacketData{ SchedulePacketData: &cptypes.ScheduleInfo{ Validator: addr.String(), + Denom: k.Staking.BondDenom(ctx), }, }, } @@ -87,6 +90,7 @@ func (k Keeper) ScheduleTombstoned(ctx sdk.Context, addr sdk.ValAddress) error { Data: &cptypes.ConsumerPacketData_SchedulePacketData{ SchedulePacketData: &cptypes.ScheduleInfo{ Validator: addr.String(), + Denom: k.Staking.BondDenom(ctx), }, }, } @@ -100,6 +104,7 @@ func (k Keeper) ScheduleUnjailed(ctx sdk.Context, addr sdk.ValAddress) error { Data: &cptypes.ConsumerPacketData_SchedulePacketData{ SchedulePacketData: &cptypes.ScheduleInfo{ Validator: addr.String(), + Denom: k.Staking.BondDenom(ctx), }, }, } @@ -113,6 +118,7 @@ func (k Keeper) ScheduleModified(ctx sdk.Context, addr sdk.ValAddress) error { Data: &cptypes.ConsumerPacketData_SchedulePacketData{ SchedulePacketData: &cptypes.ScheduleInfo{ Validator: addr.String(), + Denom: k.Staking.BondDenom(ctx), }, }, } diff --git a/x/meshsecurityprovider/keeper/relay.go b/x/meshsecurityprovider/keeper/relay.go index ccd9d4a2..cfc04359 100644 --- a/x/meshsecurityprovider/keeper/relay.go +++ b/x/meshsecurityprovider/keeper/relay.go @@ -101,7 +101,18 @@ func (k Keeper) OnRecvBondedPacket( packet channeltypes.Packet, data *cptypes.ScheduleInfo, ) (cptypes.PacketAckResult, error) { + intermediary, found := k.GetIntermediary(ctx, data.Denom) + if !found { + ModuleLogger(ctx).Error("External Staker not found for validor", + data.Validator, + ) + panic(fmt.Errorf("external Staker not found for validor %s", data.Validator)) + } + if intermediary.Status != types.Bonded { + intermediary.Status = types.Bonded + } + k.SetIntermediary(ctx, intermediary) return cptypes.SlashPacketHandledResult, nil } @@ -110,7 +121,18 @@ func (k Keeper) OnRecvUnbondedPacket( packet channeltypes.Packet, data *cptypes.ScheduleInfo, ) (cptypes.PacketAckResult, error) { + intermediary, found := k.GetIntermediary(ctx, data.Denom) + if !found { + ModuleLogger(ctx).Error("External Staker not found for validor", + data.Validator, + ) + panic(fmt.Errorf("external Staker not found for validor %s", data.Validator)) + } + if intermediary.Status != types.Unbonded { + intermediary.Status = types.Unbonded + } + k.SetIntermediary(ctx, intermediary) return cptypes.SlashPacketHandledResult, nil } @@ -119,6 +141,31 @@ func (k Keeper) OnRecvJailedPacket( packet channeltypes.Packet, data *cptypes.ScheduleInfo, ) (cptypes.PacketAckResult, error) { + intermediary, found := k.GetIntermediary(ctx, data.Denom) + if !found { + ModuleLogger(ctx).Error("External Staker not found for validor", + data.Validator, + ) + panic(fmt.Errorf("external Staker not found for validor %s", data.Validator)) + } + + if intermediary.IsUnboned() { + ModuleLogger(ctx).Error("validator %s is unbonded", data.Validator) + return cptypes.SlashPacketHandledResult, nil + } + + if intermediary.IsTombstoned() { + ModuleLogger(ctx).Info( + "slash packet dropped because validator %s is already tombstoned", data.Validator, + ) + return cptypes.SlashPacketHandledResult, nil + } + if intermediary.IsJailed() { + ModuleLogger(ctx).Info("validator %s jailed", data.Validator) + return cptypes.SlashPacketHandledResult, nil + } + intermediary.Jailed = true + k.SetIntermediary(ctx, intermediary) return cptypes.SlashPacketHandledResult, nil } @@ -128,6 +175,20 @@ func (k Keeper) OnRecvTombstonedPacket( packet channeltypes.Packet, data *cptypes.ScheduleInfo, ) (cptypes.PacketAckResult, error) { + intermediary, found := k.GetIntermediary(ctx, data.Denom) + if !found { + ModuleLogger(ctx).Error("External Staker not found for validor", + data.Validator, + ) + panic(fmt.Errorf("external Staker not found for validor %s", data.Validator)) + } + + if intermediary.IsUnboned() { + ModuleLogger(ctx).Error("validator %s is unbonded", data.Validator) + return cptypes.SlashPacketHandledResult, nil + } + intermediary.Tombstoned = true + k.SetIntermediary(ctx, intermediary) return cptypes.SlashPacketHandledResult, nil } @@ -136,6 +197,25 @@ func (k Keeper) OnRecvUnjailedPacket( packet channeltypes.Packet, data *cptypes.ScheduleInfo, ) (cptypes.PacketAckResult, error) { + intermediary, found := k.GetIntermediary(ctx, data.Denom) + if !found { + ModuleLogger(ctx).Error("External Staker not found for validor", + data.Validator, + ) + panic(fmt.Errorf("external Staker not found for validor %s", data.Validator)) + } + + if intermediary.IsUnboned() { + ModuleLogger(ctx).Error("validator %s is unbonded", data.Validator) + return cptypes.SlashPacketHandledResult, nil + } + if !intermediary.Jailed { + ModuleLogger(ctx).Error("validator %s is not jailed", data.Validator) + return cptypes.SlashPacketHandledResult, nil + } + + intermediary.Jailed = false + k.SetIntermediary(ctx, intermediary) return cptypes.SlashPacketHandledResult, nil } diff --git a/x/meshsecurityprovider/types/delegate.pb.go b/x/meshsecurityprovider/types/delegate.pb.go index 0161d884..53d1af93 100644 --- a/x/meshsecurityprovider/types/delegate.pb.go +++ b/x/meshsecurityprovider/types/delegate.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/provider/v1beta1/delegate.proto +// source: osmosis/meshsecurityprovider/v1beta1/delegate.proto package types @@ -59,7 +59,7 @@ func (x BondStatus) String() string { } func (BondStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_cd75e4a5b29b30f7, []int{0} + return fileDescriptor_ff7e9b6105b0114c, []int{0} } // Params defines the parameters for the x/meshsecurity module. @@ -72,7 +72,7 @@ func (m *Depositors) Reset() { *m = Depositors{} } func (m *Depositors) String() string { return proto.CompactTextString(m) } func (*Depositors) ProtoMessage() {} func (*Depositors) Descriptor() ([]byte, []int) { - return fileDescriptor_cd75e4a5b29b30f7, []int{0} + return fileDescriptor_ff7e9b6105b0114c, []int{0} } func (m *Depositors) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -108,7 +108,7 @@ type Intermediary struct { ContractAddress string `protobuf:"bytes,3,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty"` Jailed bool `protobuf:"varint,4,opt,name=jailed,proto3" json:"jailed,omitempty"` Tombstoned bool `protobuf:"varint,5,opt,name=tombstoned,proto3" json:"tombstoned,omitempty"` - Status BondStatus `protobuf:"varint,6,opt,name=status,proto3,enum=osmosis.provider.v1beta1.BondStatus" json:"status,omitempty"` + Status BondStatus `protobuf:"varint,6,opt,name=status,proto3,enum=osmosis.meshsecurityprovider.v1beta1.BondStatus" json:"status,omitempty"` Token *types.Coin `protobuf:"bytes,7,opt,name=token,proto3" json:"token,omitempty"` } @@ -116,7 +116,7 @@ func (m *Intermediary) Reset() { *m = Intermediary{} } func (m *Intermediary) String() string { return proto.CompactTextString(m) } func (*Intermediary) ProtoMessage() {} func (*Intermediary) Descriptor() ([]byte, []int) { - return fileDescriptor_cd75e4a5b29b30f7, []int{1} + return fileDescriptor_ff7e9b6105b0114c, []int{1} } func (m *Intermediary) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -146,53 +146,54 @@ func (m *Intermediary) XXX_DiscardUnknown() { var xxx_messageInfo_Intermediary proto.InternalMessageInfo func init() { - proto.RegisterEnum("osmosis.provider.v1beta1.BondStatus", BondStatus_name, BondStatus_value) - proto.RegisterType((*Depositors)(nil), "osmosis.provider.v1beta1.Depositors") - proto.RegisterType((*Intermediary)(nil), "osmosis.provider.v1beta1.Intermediary") + proto.RegisterEnum("osmosis.meshsecurityprovider.v1beta1.BondStatus", BondStatus_name, BondStatus_value) + proto.RegisterType((*Depositors)(nil), "osmosis.meshsecurityprovider.v1beta1.Depositors") + proto.RegisterType((*Intermediary)(nil), "osmosis.meshsecurityprovider.v1beta1.Intermediary") } func init() { - proto.RegisterFile("osmosis/provider/v1beta1/delegate.proto", fileDescriptor_cd75e4a5b29b30f7) + proto.RegisterFile("osmosis/meshsecurityprovider/v1beta1/delegate.proto", fileDescriptor_ff7e9b6105b0114c) } -var fileDescriptor_cd75e4a5b29b30f7 = []byte{ - // 574 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0xc7, 0xbd, 0x69, 0xeb, 0xb6, 0xdb, 0x42, 0xd3, 0x55, 0x01, 0xd7, 0x07, 0xd7, 0xaa, 0x10, - 0x98, 0x8a, 0xd8, 0x6a, 0x11, 0x17, 0xc4, 0xa5, 0x69, 0x0a, 0xca, 0xa5, 0xa0, 0xa4, 0xe1, 0x80, - 0x90, 0xa2, 0xb5, 0x77, 0x49, 0x96, 0xc6, 0xbb, 0x91, 0x77, 0x13, 0x91, 0x37, 0x40, 0x39, 0xf5, - 0x05, 0x72, 0xe2, 0x52, 0xf5, 0xc4, 0x89, 0x67, 0xc8, 0xb1, 0x47, 0x4e, 0x7c, 0x24, 0x07, 0x5e, - 0x03, 0x65, 0x6d, 0xd3, 0x20, 0x04, 0x17, 0x7b, 0x3e, 0x7e, 0x33, 0xfa, 0xcf, 0x78, 0x0c, 0xef, - 0x0b, 0x19, 0x0b, 0xc9, 0x64, 0xd0, 0x4d, 0x44, 0x9f, 0x11, 0x9a, 0x04, 0xfd, 0xfd, 0x90, 0x2a, - 0xbc, 0x1f, 0x10, 0xda, 0xa1, 0x2d, 0xac, 0xa8, 0xdf, 0x4d, 0x84, 0x12, 0xc8, 0xca, 0x40, 0x3f, - 0x07, 0xfd, 0x0c, 0xb4, 0x9d, 0x48, 0xa7, 0x82, 0x10, 0x4b, 0xfa, 0xbb, 0x3a, 0x12, 0x8c, 0xa7, - 0x95, 0xf6, 0x56, 0x4b, 0xb4, 0x84, 0x36, 0x83, 0x99, 0x95, 0x45, 0x37, 0x71, 0xcc, 0xb8, 0x08, - 0xf4, 0x33, 0x0d, 0xed, 0x9e, 0x03, 0x08, 0x2b, 0xb4, 0x2b, 0x24, 0x53, 0x22, 0x91, 0xc8, 0x82, - 0xcb, 0x98, 0x90, 0x84, 0x4a, 0x69, 0x01, 0x17, 0x78, 0xab, 0xb5, 0xdc, 0x45, 0x6d, 0x68, 0x2a, - 0x71, 0x46, 0xb9, 0xb4, 0x0a, 0xee, 0x82, 0xb7, 0x76, 0xb0, 0xed, 0xa7, 0x12, 0xfc, 0x99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x00, 0x00, +var fileDescriptor_ff7e9b6105b0114c = []byte{ + // 579 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0xf5, 0xa4, 0xad, 0xdb, 0x4e, 0xfb, 0x7d, 0x4d, 0x47, 0x05, 0x5c, 0x2f, 0x5c, 0xab, 0x42, + 0xc8, 0x54, 0xc4, 0xa6, 0xad, 0x78, 0x80, 0xa6, 0x69, 0x21, 0x9b, 0x82, 0x92, 0x86, 0x05, 0x9b, + 0x68, 0xec, 0x19, 0x92, 0xa1, 0xf1, 0x4c, 0xe4, 0x99, 0x44, 0xe4, 0x0d, 0x50, 0x56, 0x7d, 0x81, + 0xac, 0xd8, 0x54, 0xac, 0x58, 0xf5, 0x19, 0xb2, 0xec, 0x92, 0x15, 0x3f, 0xc9, 0x82, 0xd7, 0x40, + 0x19, 0xdb, 0x10, 0x44, 0x85, 0xd8, 0xd8, 0x73, 0xef, 0x3d, 0xe7, 0xe8, 0xdc, 0x3b, 0x77, 0xe0, + 0xa1, 0x90, 0xb1, 0x90, 0x4c, 0x06, 0x31, 0x95, 0x6d, 0x49, 0xa3, 0x5e, 0xc2, 0xd4, 0xa0, 0x9b, + 0x88, 0x3e, 0x23, 0x34, 0x09, 0xfa, 0xfb, 0x21, 0x55, 0x78, 0x3f, 0x20, 0xb4, 0x43, 0x5b, 0x58, + 0x51, 0xbf, 0x9b, 0x08, 0x25, 0xd0, 0xfd, 0x8c, 0xe4, 0xdf, 0x46, 0xf2, 0x33, 0x92, 0xed, 0x44, + 0x1a, 0x16, 0x84, 0x58, 0xd2, 0x9f, 0x4a, 0x91, 0x60, 0x3c, 0x55, 0xb1, 0xb7, 0x5a, 0xa2, 0x25, + 0xf4, 0x31, 0x98, 0x9d, 0xb2, 0xec, 0x26, 0x8e, 0x19, 0x17, 0x81, 0xfe, 0xa6, 0xa9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xe3, 0xd5, 0xe9, 0xdc, 0x2a, 0x65, 0xf3, 0x2c, + 0x75, 0x70, 0x98, 0x3e, 0xad, 0x52, 0x3e, 0x55, 0xbd, 0x57, 0x6f, 0x6f, 0x7f, 0x6e, 0x7a, 0xdd, + 0x42, 0x53, 0x6f, 0xfd, 0xe1, 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x27, 0x08, 0xab, 0x24, 0x9b, + 0x03, 0x00, 0x00, } func (m *Depositors) Marshal() (dAtA []byte, err error) { diff --git a/x/meshsecurityprovider/types/genesis.pb.go b/x/meshsecurityprovider/types/genesis.pb.go index 2af86f2b..6e72cf54 100644 --- a/x/meshsecurityprovider/types/genesis.pb.go +++ b/x/meshsecurityprovider/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/provider/v1beta1/genesis.proto +// source: osmosis/meshsecurityprovider/v1beta1/genesis.proto package types @@ -33,7 +33,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_1f21be234bee84ef, []int{0} + return fileDescriptor_555788d51f2b67d4, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -63,31 +63,31 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo func init() { - proto.RegisterType((*GenesisState)(nil), "osmosis.provider.v1beta1.GenesisState") + proto.RegisterType((*GenesisState)(nil), "osmosis.meshsecurityprovider.v1beta1.GenesisState") } func init() { - proto.RegisterFile("osmosis/provider/v1beta1/genesis.proto", fileDescriptor_1f21be234bee84ef) + proto.RegisterFile("osmosis/meshsecurityprovider/v1beta1/genesis.proto", fileDescriptor_555788d51f2b67d4) } -var fileDescriptor_1f21be234bee84ef = []byte{ - // 252 bytes of a gzipped FileDescriptorProto -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0x96, 0x63, 0x88, 0xb2, 0x4a, 0xcf, 0x2c, 0xc9, 0x28, - 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x87, 0x5a, 0xa3, 0x9b, 0x93, 0x98, 0x54, 0xac, 0x9f, 0x9b, - 0x5a, 0x9c, 0xa1, 0x5b, 0x9c, 0x9a, 0x5c, 0x5a, 0x94, 0x59, 0x52, 0xa9, 0x5b, 0x9c, 0x92, 0xad, - 0x5f, 0x81, 0xf0, 0x70, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0xfd, 0xc6, 0x80, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x8f, 0x28, 0x1e, 0x44, 0x53, 0x01, 0x00, 0x00, +var fileDescriptor_555788d51f2b67d4 = []byte{ + // 255 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0xca, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0xcf, 0x4d, 0x2d, 0xce, 0x28, 0x4e, 0x4d, 0x2e, 0x2d, 0xca, 0x2c, 0xa9, + 0x2c, 0x28, 0xca, 0x2f, 0xcb, 0x4c, 0x49, 0x2d, 0xd2, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, + 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, + 0x81, 0xea, 0xd1, 0xc3, 0xa6, 0x47, 0x0f, 0xaa, 0x47, 0xca, 0x90, 0x28, 0x93, 0x0b, 0x12, 0x8b, + 0x12, 0x73, 0xa1, 0x06, 0x4b, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0x99, 0xfa, 0x20, 0x16, 0x54, + 0x54, 0x30, 0x31, 0x37, 0x33, 0x2f, 0x5f, 0x1f, 0x4c, 0x42, 0x84, 0x94, 0x52, 0xb9, 0x78, 0xdc, + 0x21, 0x4e, 0x0a, 0x2e, 0x49, 0x2c, 0x49, 0x15, 0xf2, 0xe7, 0x62, 0x83, 0x18, 0x24, 0xc1, 0xa8, + 0xc0, 0xa8, 0xc1, 0x6d, 0xa4, 0xa3, 0x47, 0x8c, 0x13, 0xf5, 0x02, 0xc0, 0x7a, 0x9c, 0x38, 0x4f, + 0xdc, 0x93, 0x67, 0x58, 0xf1, 0x7c, 0x83, 0x16, 0x63, 0x10, 0xd4, 0x18, 0x2b, 0x96, 0x17, 0x0b, + 0xe4, 0x19, 0x9d, 0x32, 0x4e, 0x3c, 0x94, 0x63, 0x58, 0xf1, 0x48, 0x8e, 0xe1, 0xc4, 0x23, 0x39, + 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, + 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0xdc, 0xd2, 0x33, 0x4b, 0x32, 0x4a, 0x93, 0xf4, 0x92, + 0xf3, 0x73, 0xf5, 0xa1, 0x56, 0xea, 0xe6, 0x24, 0x26, 0x41, 0x3c, 0xad, 0x0b, 0xb3, 0x58, 0xb7, + 0x38, 0x25, 0x5b, 0xbf, 0x02, 0x7b, 0x40, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0xfd, + 0x65, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xa4, 0xc2, 0x57, 0x54, 0x8f, 0x01, 0x00, 0x00, } func (this *GenesisState) Equal(that interface{}) bool { diff --git a/x/meshsecurityprovider/types/params.pb.go b/x/meshsecurityprovider/types/params.pb.go index cd898db6..7e361c73 100644 --- a/x/meshsecurityprovider/types/params.pb.go +++ b/x/meshsecurityprovider/types/params.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/provider/v1beta1/params.proto +// source: osmosis/meshsecurityprovider/v1beta1/params.proto package types @@ -36,7 +36,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_8d8ea49c9593b4cd, []int{0} + return fileDescriptor_6d51515613408cf3, []int{0} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -66,34 +66,34 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo func init() { - proto.RegisterType((*Params)(nil), "osmosis.provider.v1beta1.Params") + proto.RegisterType((*Params)(nil), "osmosis.meshsecurityprovider.v1beta1.Params") } func init() { - proto.RegisterFile("osmosis/provider/v1beta1/params.proto", fileDescriptor_8d8ea49c9593b4cd) + proto.RegisterFile("osmosis/meshsecurityprovider/v1beta1/params.proto", fileDescriptor_6d51515613408cf3) } -var fileDescriptor_8d8ea49c9593b4cd = []byte{ - // 296 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x90, 0xb1, 0x4a, 0x33, 0x41, - 0x10, 0xc7, 0x6f, 0x3f, 0x3e, 0x02, 0x1e, 0xa8, 0x18, 0x82, 0x1c, 0x29, 0xd6, 0x20, 0x04, 0x82, - 0x90, 0x5b, 0x82, 0x56, 0xe9, 0xd4, 0x17, 0x08, 0x29, 0x45, 0x08, 0x7b, 0x7b, 0xcb, 0x65, 0x31, - 0x7b, 0x73, 0xec, 0xec, 0x1d, 0xa6, 0xb2, 0xb7, 0xf2, 0x11, 0x2c, 0x2d, 0x7d, 0x8c, 0x94, 0x29, - 0x2d, 0xf5, 0xae, 0xd0, 0xc7, 0x10, 0xf7, 0xd6, 0xd8, 0x0c, 0xc3, 0xef, 0xf7, 0x1f, 0x86, 0x99, - 0x70, 0x08, 0xa8, 0x01, 0x15, 0xb2, 0xc2, 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, 0x8e, 0xdd, - 0xff, 0x3d, 0xd4, 0xae, 0x0b, 0x89, 0x49, 0xc7, 0x5d, 0x79, 0xfe, 0x1d, 0x00, 0x00, 0xff, 0xff, - 0x36, 0xe2, 0x98, 0xcf, 0x71, 0x01, 0x00, 0x00, +var fileDescriptor_6d51515613408cf3 = []byte{ + // 302 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x90, 0x31, 0x4b, 0xfc, 0x30, + 0x18, 0xc6, 0x9b, 0x3f, 0x7f, 0x0e, 0x2c, 0x28, 0x78, 0x1c, 0x72, 0x9c, 0x10, 0x0f, 0x39, 0xe1, + 0x10, 0xda, 0x50, 0x74, 0x72, 0x53, 0xc1, 0xf9, 0xb8, 0xd1, 0xa5, 0xa4, 0x69, 0x68, 0x83, 0x97, + 0xbe, 0x25, 0x49, 0x8b, 0xf7, 0x15, 0x74, 0xf1, 0x23, 0x38, 0x3a, 0xfa, 0x31, 0x6e, 0xbc, 0xd1, + 0x51, 0xdb, 0x41, 0x3f, 0x86, 0x98, 0x46, 0xa7, 0x2e, 0xe1, 0xe5, 0x79, 0xf2, 0x3c, 0xc9, 0xfb, + 0xf3, 0x23, 0xd0, 0x12, 0xb4, 0xd0, 0x44, 0x72, 0x9d, 0x6b, 0xce, 0x2a, 0x25, 0xcc, 0xba, 0x54, + 0x50, 0x8b, 0x94, 0x2b, 0x52, 0x47, 0x09, 0x37, 0x34, 0x22, 0x25, 0x55, 0x54, 0xea, 0xb0, 0x54, + 0x60, 0x60, 0x38, 0x73, 0x91, 0xb0, 0x2f, 0x12, 0xba, 0xc8, 0x04, 0x33, 0x7b, 0x8d, 0x24, 0x54, + 0xf3, 0xbf, 0x1e, 0x06, 0xa2, 0xe8, 0x5a, 0x26, 0xa3, 0x0c, 0x32, 0xb0, 0x23, 0xf9, 0x99, 0x9c, + 0xba, 0x4f, 0xa5, 0x28, 0x80, 0xd8, 0xb3, 0x93, 0x8e, 0x1f, 0x91, 0x3f, 0x58, 0xd8, 0xf7, 0x87, + 0x27, 0xfe, 0x9e, 0x11, 0x92, 0x43, 0x65, 0xe2, 0x92, 0x2b, 0x01, 0xe9, 0x18, 0x4d, 0xd1, 0xfc, + 0xff, 0x72, 0xd7, 0xa9, 0x0b, 0x2b, 0x0e, 0xcf, 0xfd, 0x83, 0x9a, 0x56, 0x2b, 0x13, 0x33, 0x28, + 0x8c, 0xa2, 0xcc, 0xc4, 0x34, 0x4d, 0x15, 0xd7, 0x7a, 0xfc, 0x6f, 0x8a, 0xe6, 0x3b, 0xcb, 0x91, + 0x75, 0xaf, 0x9d, 0x79, 0xd9, 0x79, 0x17, 0xb3, 0xaf, 0xe7, 0x23, 0xf4, 0xf0, 0xf9, 0x7a, 0x7a, + 0xd8, 0x8b, 0xa2, 0xfb, 0xc2, 0x55, 0xbe, 0xf9, 0xc0, 0xde, 0x4b, 0x83, 0xbd, 0x4d, 0x83, 0xd1, + 0xb6, 0xc1, 0xe8, 0xbd, 0xc1, 0xe8, 0xa9, 0xc5, 0xde, 0xb6, 0xc5, 0xde, 0x5b, 0x8b, 0xbd, 0xdb, + 0x9b, 0x4c, 0x98, 0xbc, 0x4a, 0x42, 0x06, 0x92, 0x38, 0x52, 0xc1, 0x8a, 0x26, 0x1d, 0xe1, 0xe0, + 0xb7, 0x37, 0xd0, 0xe9, 0x1d, 0xb9, 0xef, 0xa7, 0x6e, 0xd6, 0x25, 0xd7, 0xc9, 0xc0, 0xae, 0x7f, + 0xf6, 0x1d, 0x00, 0x00, 0xff, 0xff, 0x34, 0x89, 0x55, 0x25, 0xa2, 0x01, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { diff --git a/x/meshsecurityprovider/types/query.pb.go b/x/meshsecurityprovider/types/query.pb.go index 86b77476..fe6f9118 100644 --- a/x/meshsecurityprovider/types/query.pb.go +++ b/x/meshsecurityprovider/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/provider/v1beta1/query.proto +// source: osmosis/meshsecurityprovider/v1beta1/query.proto package types @@ -40,7 +40,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_dc940424cad20223, []int{0} + return fileDescriptor_9fa24ab7f9d99b32, []int{0} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -79,7 +79,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_dc940424cad20223, []int{1} + return fileDescriptor_9fa24ab7f9d99b32, []int{1} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -109,38 +109,38 @@ func (m *QueryParamsResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*QueryParamsRequest)(nil), "osmosis.provider.v1beta1.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "osmosis.provider.v1beta1.QueryParamsResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "osmosis.meshsecurityprovider.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "osmosis.meshsecurityprovider.v1beta1.QueryParamsResponse") } func init() { - proto.RegisterFile("osmosis/provider/v1beta1/query.proto", fileDescriptor_dc940424cad20223) -} - -var fileDescriptor_dc940424cad20223 = []byte{ - // 338 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x90, 0x41, 0x4a, 0xc3, 0x40, - 0x14, 0x86, 0x33, 0x82, 0x05, 0xe3, 0xca, 0xd8, 0x45, 0x29, 0x32, 0x96, 0xa0, 0x50, 0xc4, 0x64, - 0x68, 0xdd, 0xb9, 0xac, 0x17, 0xd0, 0x2e, 0x8b, 0x9b, 0x49, 0x3a, 0xa4, 0x83, 0x4d, 0x5e, 0x9a, - 0x37, 0x29, 0x76, 0xeb, 0x05, 0x14, 0x5c, 0x79, 0x83, 0x2e, 0x3d, 0x46, 0x97, 0x05, 0x37, 0xae, - 0x44, 0x53, 0xc1, 0x6b, 0x48, 0x67, 0x52, 0x45, 0xa4, 0xe8, 0x66, 0x78, 0xfc, 0xf3, 0xfd, 0xff, - 0xfc, 0xf3, 0xec, 0x03, 0xc0, 0x18, 0x50, 0x22, 0x4b, 0x33, 0x18, 0xcb, 0xbe, 0xc8, 0xd8, 0xb8, - 0x15, 0x08, 0xc5, 0x5b, 0x6c, 0x94, 0x8b, 0x6c, 0xe2, 0xa7, 0x19, 0x28, 0x70, 0x6a, 0x25, 0xe5, - 0xaf, 0x28, 0xbf, 0xa4, 0xea, 0x34, 0xd4, 0x57, 0x2c, 0xe0, 0x28, 0xbe, 0xac, 0x21, 0xc8, 0xc4, - 0x38, 0xeb, 0x87, 0x6b, 0xf3, 0x53, 0x9e, 0xf1, 0x18, 0x4b, 0xac, 0x1a, 0x41, 0x04, 0x7a, 0x64, - 0xcb, 0xa9, 0x54, 0xf7, 0x22, 0x80, 0x68, 0x28, 0x18, 0x4f, 0x25, 0xe3, 0x49, 0x02, 0x8a, 0x2b, - 0x09, 0xc9, 0xca, 0xb3, 0xc3, 0x63, 0x99, 0x00, 0xd3, 0xa7, 0x91, 0xdc, 0xaa, 0xed, 0x5c, 0x2c, - 0x6b, 0x9f, 0xeb, 0xec, 0xae, 0x18, 0xe5, 0x02, 0x95, 0xdb, 0xb3, 0x77, 0x7f, 0xa8, 0x98, 0x42, - 0x82, 0xc2, 0x39, 0xb3, 0x2b, 0xa6, 0x43, 0x8d, 0x34, 0x48, 0x73, 0xbb, 0xdd, 0xf0, 0xd7, 0xfd, - 0xd2, 0x37, 0xce, 0xce, 0xd6, 0xec, 0x65, 0xdf, 0x9a, 0x7e, 0x3c, 0x1e, 0x91, 0x6e, 0x69, 0x6d, - 0x3f, 0x10, 0x7b, 0x53, 0x87, 0x3b, 0xb7, 0xc4, 0xae, 0x18, 0xce, 0x39, 0x5e, 0x9f, 0xf4, 0xbb, - 0x5e, 0xdd, 0xfb, 0x27, 0x6d, 0x6a, 0xbb, 0xcd, 0x9b, 0xa7, 0xf7, 0xfb, 0x0d, 0xd7, 0x69, 0xb0, - 0x3f, 0x56, 0xdb, 0xb9, 0x9c, 0xbd, 0x51, 0x6b, 0x5a, 0x50, 0x6b, 0x56, 0x50, 0x32, 0x2f, 0x28, - 0x79, 0x2d, 0x28, 0xb9, 0x5b, 0x50, 0x6b, 0xbe, 0xa0, 0xd6, 0xf3, 0x82, 0x5a, 0xbd, 0xd3, 0x48, - 0xaa, 0x41, 0x1e, 0xf8, 0x21, 0xc4, 0xab, 0x34, 0x6f, 0xc8, 0x03, 0x64, 0xb1, 0xc0, 0x81, 0x87, - 0x22, 0xcc, 0x33, 0xa9, 0x26, 0x1e, 0xf6, 0xaf, 0xd8, 0xf5, 0xf7, 0x33, 0x6a, 0x92, 0x0a, 0x0c, - 0x2a, 0x7a, 0xe5, 0x27, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x80, 0xc3, 0xc6, 0x42, 0x02, - 0x00, 0x00, + proto.RegisterFile("osmosis/meshsecurityprovider/v1beta1/query.proto", fileDescriptor_9fa24ab7f9d99b32) +} + +var fileDescriptor_9fa24ab7f9d99b32 = []byte{ + // 344 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xb1, 0x4a, 0x33, 0x41, + 0x10, 0xc7, 0x6f, 0x3f, 0xf8, 0x02, 0x9e, 0x95, 0x67, 0x0a, 0x09, 0xb2, 0x4a, 0xb0, 0x10, 0x49, + 0x76, 0x4d, 0xb4, 0xd0, 0x36, 0x85, 0xad, 0x9a, 0xd2, 0x6e, 0xef, 0xb2, 0x5e, 0x16, 0x73, 0x37, + 0x97, 0x9b, 0xbd, 0x60, 0x5a, 0x9f, 0x40, 0xf0, 0x25, 0x52, 0x0a, 0xd6, 0xf6, 0x29, 0x03, 0x36, + 0x56, 0xa2, 0x17, 0xc1, 0xd7, 0x90, 0xec, 0x5e, 0x04, 0x31, 0x45, 0xb4, 0x59, 0x96, 0x61, 0x7e, + 0xbf, 0x99, 0x3f, 0xe3, 0xee, 0x03, 0x46, 0x80, 0x0a, 0x79, 0x24, 0xb1, 0x8b, 0x32, 0xc8, 0x52, + 0xa5, 0x87, 0x49, 0x0a, 0x03, 0xd5, 0x91, 0x29, 0x1f, 0x34, 0x7c, 0xa9, 0x45, 0x83, 0xf7, 0x33, + 0x99, 0x0e, 0x59, 0x92, 0x82, 0x06, 0x6f, 0xa7, 0x20, 0xd8, 0x22, 0x82, 0x15, 0x44, 0x85, 0x06, + 0xa6, 0x8d, 0xfb, 0x02, 0xe5, 0x97, 0x26, 0x00, 0x15, 0x5b, 0x4b, 0xa5, 0xb1, 0xd4, 0xdc, 0x44, + 0xa4, 0x22, 0xc2, 0x02, 0x29, 0x87, 0x10, 0x82, 0xf9, 0xf2, 0xd9, 0xaf, 0xa8, 0x6e, 0x86, 0x00, + 0x61, 0x4f, 0x72, 0x91, 0x28, 0x2e, 0xe2, 0x18, 0xb4, 0xd0, 0x0a, 0xe2, 0x39, 0xb3, 0x26, 0x22, + 0x15, 0x03, 0x37, 0xaf, 0x2d, 0x55, 0xcb, 0xae, 0x77, 0x3e, 0x8b, 0x73, 0x66, 0xdc, 0x6d, 0xd9, + 0xcf, 0x24, 0xea, 0xea, 0xa5, 0xbb, 0xfe, 0xad, 0x8a, 0x09, 0xc4, 0x28, 0xbd, 0x53, 0xb7, 0x64, + 0x77, 0xd8, 0x20, 0xdb, 0x64, 0x77, 0xb5, 0x59, 0x63, 0xcb, 0xa4, 0x67, 0xd6, 0xd2, 0x5a, 0x19, + 0xbf, 0x6c, 0x39, 0xa3, 0x8f, 0xfb, 0x3d, 0xd2, 0x2e, 0x34, 0xcd, 0x47, 0xe2, 0xfe, 0x37, 0x83, + 0xbc, 0x07, 0xe2, 0x96, 0x6c, 0x9f, 0x77, 0xb4, 0x9c, 0xf5, 0xe7, 0xda, 0x95, 0xe3, 0x3f, 0x90, + 0x36, 0x5a, 0xf5, 0xf0, 0xe6, 0xe9, 0xfd, 0xee, 0x1f, 0xf3, 0x6a, 0xfc, 0x17, 0xa7, 0x68, 0x75, + 0xc7, 0x6f, 0xd4, 0x19, 0xe5, 0xd4, 0x19, 0xe7, 0x94, 0x4c, 0x72, 0x4a, 0x5e, 0x73, 0x4a, 0x6e, + 0xa7, 0xd4, 0x99, 0x4c, 0xa9, 0xf3, 0x3c, 0xa5, 0xce, 0xc5, 0x49, 0xa8, 0x74, 0x37, 0xf3, 0x59, + 0x00, 0xd1, 0xdc, 0x5c, 0xef, 0x09, 0xdf, 0xea, 0xeb, 0x73, 0x7f, 0x1d, 0x3b, 0x57, 0xfc, 0x7a, + 0xf1, 0x48, 0x3d, 0x4c, 0x24, 0xfa, 0x25, 0x73, 0xae, 0x83, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x4d, 0xfa, 0xb2, 0xe9, 0xa2, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -169,7 +169,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/osmosis.provider.v1beta1.Query/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/osmosis.meshsecurityprovider.v1beta1.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -204,7 +204,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/osmosis.provider.v1beta1.Query/Params", + FullMethod: "/osmosis.meshsecurityprovider.v1beta1.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) @@ -213,7 +213,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "osmosis.provider.v1beta1.Query", + ServiceName: "osmosis.meshsecurityprovider.v1beta1.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -222,7 +222,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "osmosis/provider/v1beta1/query.proto", + Metadata: "osmosis/meshsecurityprovider/v1beta1/query.proto", } func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/meshsecurityprovider/types/query.pb.gw.go b/x/meshsecurityprovider/types/query.pb.gw.go index e745219f..9ae45777 100644 --- a/x/meshsecurityprovider/types/query.pb.gw.go +++ b/x/meshsecurityprovider/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: osmosis/provider/v1beta1/query.proto +// source: osmosis/meshsecurityprovider/v1beta1/query.proto /* Package types is a reverse proxy. @@ -145,7 +145,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "provider", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "meshsecurityprovider", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/x/meshsecurityprovider/types/tx.pb.go b/x/meshsecurityprovider/types/tx.pb.go index 933d37ae..568d5f68 100644 --- a/x/meshsecurityprovider/types/tx.pb.go +++ b/x/meshsecurityprovider/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/provider/v1beta1/tx.proto +// source: osmosis/meshsecurityprovider/v1beta1/tx.proto package types @@ -43,7 +43,7 @@ func (m *MsgDelegate) Reset() { *m = MsgDelegate{} } func (m *MsgDelegate) String() string { return proto.CompactTextString(m) } func (*MsgDelegate) ProtoMessage() {} func (*MsgDelegate) Descriptor() ([]byte, []int) { - return fileDescriptor_600cc2e6a7e19cb9, []int{0} + return fileDescriptor_05534c9e44219747, []int{0} } func (m *MsgDelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -79,7 +79,7 @@ func (m *MsgDelegateResponse) Reset() { *m = MsgDelegateResponse{} } func (m *MsgDelegateResponse) String() string { return proto.CompactTextString(m) } func (*MsgDelegateResponse) ProtoMessage() {} func (*MsgDelegateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_600cc2e6a7e19cb9, []int{1} + return fileDescriptor_05534c9e44219747, []int{1} } func (m *MsgDelegateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -118,7 +118,7 @@ func (m *MsgUndelegate) Reset() { *m = MsgUndelegate{} } func (m *MsgUndelegate) String() string { return proto.CompactTextString(m) } func (*MsgUndelegate) ProtoMessage() {} func (*MsgUndelegate) Descriptor() ([]byte, []int) { - return fileDescriptor_600cc2e6a7e19cb9, []int{2} + return fileDescriptor_05534c9e44219747, []int{2} } func (m *MsgUndelegate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -155,7 +155,7 @@ func (m *MsgUndelegateResponse) Reset() { *m = MsgUndelegateResponse{} } func (m *MsgUndelegateResponse) String() string { return proto.CompactTextString(m) } func (*MsgUndelegateResponse) ProtoMessage() {} func (*MsgUndelegateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_600cc2e6a7e19cb9, []int{3} + return fileDescriptor_05534c9e44219747, []int{3} } func (m *MsgUndelegateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -194,7 +194,7 @@ func (m *MsgSetConsumerCommissionRate) Reset() { *m = MsgSetConsumerComm func (m *MsgSetConsumerCommissionRate) String() string { return proto.CompactTextString(m) } func (*MsgSetConsumerCommissionRate) ProtoMessage() {} func (*MsgSetConsumerCommissionRate) Descriptor() ([]byte, []int) { - return fileDescriptor_600cc2e6a7e19cb9, []int{4} + return fileDescriptor_05534c9e44219747, []int{4} } func (m *MsgSetConsumerCommissionRate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -230,7 +230,7 @@ func (m *MsgSetConsumerCommissionRateResponse) Reset() { *m = MsgSetCons func (m *MsgSetConsumerCommissionRateResponse) String() string { return proto.CompactTextString(m) } func (*MsgSetConsumerCommissionRateResponse) ProtoMessage() {} func (*MsgSetConsumerCommissionRateResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_600cc2e6a7e19cb9, []int{5} + return fileDescriptor_05534c9e44219747, []int{5} } func (m *MsgSetConsumerCommissionRateResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -260,55 +260,57 @@ func (m *MsgSetConsumerCommissionRateResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetConsumerCommissionRateResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgDelegate)(nil), "osmosis.provider.v1beta1.MsgDelegate") - proto.RegisterType((*MsgDelegateResponse)(nil), "osmosis.provider.v1beta1.MsgDelegateResponse") - proto.RegisterType((*MsgUndelegate)(nil), "osmosis.provider.v1beta1.MsgUndelegate") - proto.RegisterType((*MsgUndelegateResponse)(nil), "osmosis.provider.v1beta1.MsgUndelegateResponse") - proto.RegisterType((*MsgSetConsumerCommissionRate)(nil), "osmosis.provider.v1beta1.MsgSetConsumerCommissionRate") - proto.RegisterType((*MsgSetConsumerCommissionRateResponse)(nil), "osmosis.provider.v1beta1.MsgSetConsumerCommissionRateResponse") -} - -func init() { proto.RegisterFile("osmosis/provider/v1beta1/tx.proto", fileDescriptor_600cc2e6a7e19cb9) } - -var fileDescriptor_600cc2e6a7e19cb9 = []byte{ - // 579 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x54, 0x41, 0x6b, 0x13, 0x41, - 0x14, 0xde, 0x69, 0xa5, 0x26, 0x53, 0x2b, 0x76, 0x6d, 0x69, 0x12, 0x64, 0x53, 0x83, 0xd6, 0x22, - 0xec, 0x2e, 0xa9, 0xa0, 0x10, 0x8a, 0x60, 0x12, 0x0f, 0x1e, 0x02, 0xb2, 0x45, 0x10, 0x2f, 0x71, - 0xb2, 0x3b, 0x6e, 0x06, 0xb3, 0x3b, 0x61, 0xdf, 0x24, 0x34, 0xff, 0xc0, 0xa3, 0xe0, 0x1f, 0xe8, - 0xd1, 0xa3, 0x87, 0xfe, 0x88, 0x9c, 0xa4, 0xf4, 0x24, 0x1e, 0x82, 0x26, 0x14, 0x3d, 0xfb, 0x0b, - 0x64, 0x77, 0x67, 0xb7, 0xdb, 0x43, 0x62, 0xf1, 0xd8, 0xcb, 0xee, 0xcc, 0xbc, 0xef, 0xfb, 0xe6, - 0x7d, 0x6f, 0xde, 0x0c, 0xbe, 0xcb, 0xc1, 0xe3, 0xc0, 0xc0, 0xec, 0x07, 0x7c, 0xc8, 0x1c, 0x1a, - 0x98, 0xc3, 0x6a, 0x87, 0x0a, 0x52, 0x35, 0xc5, 0xa1, 0xd1, 0x0f, 0xb8, 0xe0, 0x6a, 0x41, 0x42, - 0x8c, 0x04, 0x62, 0x48, 0x48, 0xa9, 0x68, 0x47, 0xa1, 0x76, 0x84, 0x33, 0xe3, 0x49, 0x4c, 0x2a, - 0x6d, 0xc5, 0x33, 0xd3, 0x03, 0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 0xa6, 0x8c, - 0xa7, 0x1a, 0x3a, 0x99, 0x6a, 0xe8, 0xc7, 0x54, 0x43, 0x1f, 0x67, 0x9a, 0x72, 0x32, 0xd3, 0x94, - 0x6f, 0x33, 0x4d, 0x79, 0x53, 0xcb, 0x9c, 0xb9, 0xdc, 0x47, 0xef, 0x91, 0x0e, 0x98, 0x1e, 0x85, - 0xae, 0x0e, 0xd4, 0x1e, 0x04, 0x4c, 0x8c, 0xa2, 0x06, 0x38, 0x3c, 0x7f, 0x5a, 0xa3, 0x5e, 0xe8, - 0xac, 0x44, 0xef, 0xd7, 0xa3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x35, 0x16, 0x0e, 0x7a, 0x7b, - 0x05, 0x00, 0x00, + proto.RegisterType((*MsgDelegate)(nil), "osmosis.meshsecurityprovider.v1beta1.MsgDelegate") + proto.RegisterType((*MsgDelegateResponse)(nil), "osmosis.meshsecurityprovider.v1beta1.MsgDelegateResponse") + proto.RegisterType((*MsgUndelegate)(nil), "osmosis.meshsecurityprovider.v1beta1.MsgUndelegate") + proto.RegisterType((*MsgUndelegateResponse)(nil), "osmosis.meshsecurityprovider.v1beta1.MsgUndelegateResponse") + proto.RegisterType((*MsgSetConsumerCommissionRate)(nil), "osmosis.meshsecurityprovider.v1beta1.MsgSetConsumerCommissionRate") + proto.RegisterType((*MsgSetConsumerCommissionRateResponse)(nil), "osmosis.meshsecurityprovider.v1beta1.MsgSetConsumerCommissionRateResponse") +} + +func init() { + proto.RegisterFile("osmosis/meshsecurityprovider/v1beta1/tx.proto", fileDescriptor_05534c9e44219747) +} + +var fileDescriptor_05534c9e44219747 = []byte{ + // 583 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x54, 0xcf, 0x6b, 0x13, 0x41, + 0x14, 0xde, 0x31, 0x52, 0x93, 0xa9, 0x15, 0xbb, 0xb6, 0x34, 0x09, 0xb2, 0x29, 0xa1, 0x94, 0x22, + 0xec, 0x2e, 0x69, 0x0f, 0x62, 0xed, 0xc5, 0x24, 0x0a, 0x0a, 0x01, 0xd9, 0xe2, 0xc5, 0x4b, 0x98, + 0xec, 0x0e, 0x9b, 0xc1, 0xec, 0x4e, 0xd8, 0x37, 0x09, 0xc9, 0xc5, 0xb3, 0x47, 0xff, 0x84, 0x1e, + 0x05, 0x11, 0x3c, 0xf4, 0x8f, 0xc8, 0x49, 0x4a, 0x4f, 0xe2, 0x21, 0x68, 0x82, 0xe8, 0xd9, 0xbf, + 0x40, 0x76, 0x77, 0x76, 0xdd, 0x42, 0xab, 0x51, 0x6f, 0xbd, 0xec, 0xfc, 0x7a, 0xdf, 0x37, 0xef, + 0x7b, 0xfb, 0xcd, 0xc3, 0x3a, 0x07, 0x8f, 0x03, 0x03, 0xd3, 0xa3, 0xd0, 0x05, 0x6a, 0x0f, 0x02, + 0x26, 0xc6, 0xfd, 0x80, 0x0f, 0x99, 0x43, 0x03, 0x73, 0x58, 0xeb, 0x50, 0x41, 0x6a, 0xa6, 0x18, + 0x19, 0xfd, 0x80, 0x0b, 0xae, 0x6e, 0xc9, 0x70, 0xe3, 0xbc, 0x70, 0x43, 0x86, 0x97, 0x4b, 0x76, + 0x14, 0xd6, 0x8e, 0x30, 0x66, 0xbc, 0x88, 0x09, 0xca, 0x1b, 0xf1, 0xca, 0xf4, 0xc0, 0x35, 0x87, + 0xb5, 0x70, 0x90, 0x07, 0x6b, 0x2e, 0x77, 0x79, 0x0c, 0x08, 0x67, 0x72, 0x77, 0x95, 0x78, 0xcc, + 0xe7, 0x66, 0xf4, 0x95, 0x5b, 0x9a, 0x64, 0xe8, 0x10, 0xa0, 0x69, 0x82, 0x36, 0x67, 0x7e, 0x7c, + 0x5e, 0x9d, 0x23, 0xbc, 0xdc, 0x02, 0xb7, 0x49, 0x7b, 0xd4, 0x25, 0x82, 0xaa, 0x0f, 0xf1, 0xaa, + 0x13, 0xcf, 0x79, 0xd0,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xff, 0x5e, + 0xda, 0xf3, 0xe6, 0xe7, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -338,7 +340,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) Delegate(ctx context.Context, in *MsgDelegate, opts ...grpc.CallOption) (*MsgDelegateResponse, error) { out := new(MsgDelegateResponse) - err := c.cc.Invoke(ctx, "/osmosis.provider.v1beta1.Msg/Delegate", in, out, opts...) + err := c.cc.Invoke(ctx, "/osmosis.meshsecurityprovider.v1beta1.Msg/Delegate", in, out, opts...) if err != nil { return nil, err } @@ -347,7 +349,7 @@ func (c *msgClient) Delegate(ctx context.Context, in *MsgDelegate, opts ...grpc. func (c *msgClient) Undelegate(ctx context.Context, in *MsgUndelegate, opts ...grpc.CallOption) (*MsgUndelegateResponse, error) { out := new(MsgUndelegateResponse) - err := c.cc.Invoke(ctx, "/osmosis.provider.v1beta1.Msg/Undelegate", in, out, opts...) + err := c.cc.Invoke(ctx, "/osmosis.meshsecurityprovider.v1beta1.Msg/Undelegate", in, out, opts...) if err != nil { return nil, err } @@ -356,7 +358,7 @@ func (c *msgClient) Undelegate(ctx context.Context, in *MsgUndelegate, opts ...g func (c *msgClient) SetConsumerCommissionRate(ctx context.Context, in *MsgSetConsumerCommissionRate, opts ...grpc.CallOption) (*MsgSetConsumerCommissionRateResponse, error) { out := new(MsgSetConsumerCommissionRateResponse) - err := c.cc.Invoke(ctx, "/osmosis.provider.v1beta1.Msg/SetConsumerCommissionRate", in, out, opts...) + err := c.cc.Invoke(ctx, "/osmosis.meshsecurityprovider.v1beta1.Msg/SetConsumerCommissionRate", in, out, opts...) if err != nil { return nil, err } @@ -398,7 +400,7 @@ func _Msg_Delegate_Handler(srv interface{}, ctx context.Context, dec func(interf } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/osmosis.provider.v1beta1.Msg/Delegate", + FullMethod: "/osmosis.meshsecurityprovider.v1beta1.Msg/Delegate", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).Delegate(ctx, req.(*MsgDelegate)) @@ -416,7 +418,7 @@ func _Msg_Undelegate_Handler(srv interface{}, ctx context.Context, dec func(inte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/osmosis.provider.v1beta1.Msg/Undelegate", + FullMethod: "/osmosis.meshsecurityprovider.v1beta1.Msg/Undelegate", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).Undelegate(ctx, req.(*MsgUndelegate)) @@ -434,7 +436,7 @@ func _Msg_SetConsumerCommissionRate_Handler(srv interface{}, ctx context.Context } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/osmosis.provider.v1beta1.Msg/SetConsumerCommissionRate", + FullMethod: "/osmosis.meshsecurityprovider.v1beta1.Msg/SetConsumerCommissionRate", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).SetConsumerCommissionRate(ctx, req.(*MsgSetConsumerCommissionRate)) @@ -443,7 +445,7 @@ func _Msg_SetConsumerCommissionRate_Handler(srv interface{}, ctx context.Context } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "osmosis.provider.v1beta1.Msg", + ServiceName: "osmosis.meshsecurityprovider.v1beta1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -460,7 +462,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "osmosis/provider/v1beta1/tx.proto", + Metadata: "osmosis/meshsecurityprovider/v1beta1/tx.proto", } func (m *MsgDelegate) Marshal() (dAtA []byte, err error) { diff --git a/x/types/wire.pb.go b/x/types/wire.pb.go index 9dcd5977..9d6ee623 100644 --- a/x/types/wire.pb.go +++ b/x/types/wire.pb.go @@ -152,6 +152,7 @@ var xxx_messageInfo_SlashInfo proto.InternalMessageInfo type ScheduleInfo struct { Validator string `protobuf:"bytes,1,opt,name=validator,proto3" json:"validator,omitempty"` Actor string `protobuf:"bytes,2,opt,name=actor,proto3" json:"actor,omitempty"` + Denom string `protobuf:"bytes,3,opt,name=denom,proto3" json:"denom,omitempty"` } func (m *ScheduleInfo) Reset() { *m = ScheduleInfo{} } @@ -285,51 +286,52 @@ func init() { func init() { proto.RegisterFile("osmosis/types/v1beta1/wire.proto", fileDescriptor_c573c9158aa3b788) } var fileDescriptor_c573c9158aa3b788 = []byte{ - // 704 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4f, 0x4f, 0xdb, 0x48, - 0x18, 0xc6, 0xed, 0xfc, 0xdb, 0x65, 0x60, 0x13, 0x33, 0x1b, 0x56, 0x56, 0x58, 0x59, 0x11, 0xbb, - 0x55, 0x11, 0x94, 0x58, 0xd0, 0xde, 0xab, 0x04, 0x9b, 0xc6, 0x55, 0xb0, 0xa3, 0x38, 0xa1, 0x6a, - 0x2f, 0xd6, 0xc4, 0x19, 0x92, 0x11, 0xb1, 0x27, 0xb2, 0x27, 0x50, 0xae, 0x3d, 0x55, 0x9c, 0xfa, - 0x05, 0x38, 0xf5, 0xd2, 0x7e, 0x13, 0x0e, 0x3d, 0x70, 0xec, 0xb1, 0x0d, 0xb7, 0x7e, 0x8a, 0xca, - 0x63, 0x37, 0xe6, 0xaf, 0xd4, 0x8b, 0xe5, 0xf9, 0xbd, 0xcf, 0xf3, 0xcc, 0xfb, 0x7a, 0xac, 0x01, - 0x55, 0x1a, 0x7a, 0x34, 0x24, 0xa1, 0xca, 0x4e, 0x27, 0x38, 0x54, 0x8f, 0xb7, 0xfb, 0x98, 0xa1, - 0x6d, 0xf5, 0x84, 0x04, 0xb8, 0x36, 0x09, 0x28, 0xa3, 0x70, 0x25, 0x51, 0xd4, 0xb8, 0xa2, 0x96, - 0x28, 0x2a, 0x8a, 0xcb, 0xb9, 0xda, 0x47, 0x21, 0x9e, 0xdb, 0x5c, 0x4a, 0xfc, 0xd8, 0x56, 0x29, - 0x0f, 0xe9, 0x90, 0xf2, 0x57, 0x35, 0x7a, 0x4b, 0xe8, 0x32, 0xf2, 0x88, 0x4f, 0x55, 0xfe, 0x4c, - 0xd0, 0xff, 0x49, 0x50, 0xc8, 0xd0, 0x11, 0xf1, 0x87, 0xf3, 0xac, 0x64, 0x9d, 0xa8, 0x56, 0x19, - 0xf6, 0x07, 0x38, 0xf0, 0x88, 0xcf, 0x54, 0xd4, 0x77, 0x49, 0xdc, 0x6f, 0x5c, 0x5c, 0xfb, 0x21, - 0x82, 0x05, 0x7b, 0x8c, 0xc2, 0x91, 0xe1, 0x1f, 0x52, 0xf8, 0x2f, 0x58, 0x38, 0x46, 0x63, 0x32, - 0x40, 0x8c, 0x06, 0xb2, 0x58, 0x15, 0xd7, 0x17, 0x3a, 0x29, 0x80, 0x9b, 0x60, 0x99, 0xf8, 0x87, - 0x01, 0x72, 0x19, 0xa1, 0xbe, 0x33, 0xc2, 0x64, 0x38, 0x62, 0x72, 0xa6, 0x2a, 0xae, 0x67, 0x3b, - 0x52, 0x5a, 0x68, 0x72, 0x0e, 0xcb, 0x20, 0x3f, 0xa1, 0x27, 0x38, 0x90, 0xb3, 0x5c, 0x10, 0x2f, - 0xe0, 0x13, 0x00, 0x19, 0x65, 0x68, 0xec, 0x84, 0xd1, 0x9e, 0x0e, 0xf2, 0xe8, 0xd4, 0x67, 0x72, - 0x8e, 0xef, 0x24, 0xf1, 0x0a, 0x6f, 0xa6, 0xce, 0x39, 0x7c, 0x04, 0x8a, 0xb1, 0xee, 0x57, 0xb6, - 0x9c, 0xe7, 0xca, 0xbf, 0x38, 0xdd, 0x4b, 0x20, 0x7c, 0x0c, 0x4a, 0x8c, 0x78, 0xd8, 0x49, 0x7b, - 0x90, 0x0b, 0x7c, 0xd3, 0x62, 0x84, 0x8d, 0x39, 0x5d, 0x6b, 0x80, 0x25, 0xdb, 0x1d, 0xe1, 0xc1, - 0x74, 0x8c, 0x7f, 0x63, 0xdc, 0x32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f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xbd, 0xe2, 0x97, 0xbe, 0xd3, 0x04, 0x00, 0x00, + // 716 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4d, 0x4f, 0xe3, 0x46, + 0x18, 0xc7, 0xed, 0xbc, 0xb5, 0x19, 0x68, 0x62, 0xa6, 0xa1, 0xb2, 0x42, 0x65, 0x45, 0xb4, 0x55, + 0x11, 0x94, 0x58, 0xd0, 0xde, 0xab, 0x04, 0x9b, 0xc6, 0x55, 0xb0, 0x23, 0x3b, 0xa1, 0x2f, 0x17, + 0x6b, 0xe2, 0x0c, 0xc9, 0x88, 0xd8, 0x13, 0xd9, 0x13, 0x28, 0xd7, 0x9e, 0x56, 0x9c, 0xf6, 0x0b, + 0x70, 0xda, 0xcb, 0xee, 0x37, 0xe1, 0xb0, 0x07, 0x8e, 0x7b, 0xdc, 0x0d, 0xb7, 0xfd, 0x14, 0x2b, + 0x8f, 0xbd, 0x31, 0xaf, 0xd2, 0x5e, 0x2c, 0xcf, 0xef, 0xf9, 0xff, 0xff, 0xf3, 0x3c, 0x9e, 0x91, + 0x41, 0x83, 0x46, 0x3e, 0x8d, 0x48, 0xa4, 0xb2, 0x8b, 0x19, 0x8e, 0xd4, 0xb3, 0xbd, 0x21, 0x66, + 0x68, 0x4f, 0x3d, 0x27, 0x21, 0x6e, 0xce, 0x42, 0xca, 0x28, 0x5c, 0x4f, 0x15, 0x4d, 0xae, 0x68, + 0xa6, 0x8a, 0xba, 0xe2, 0x71, 0xae, 0x0e, 0x51, 0x84, 0x97, 0x36, 0x8f, 0x92, 0x20, 0xb1, 0xd5, + 0x6b, 0x63, 0x3a, 0xa6, 0xfc, 0x55, 0x8d, 0xdf, 0x52, 0xba, 0x86, 0x7c, 0x12, 0x50, 0x95, 0x3f, + 0x53, 0xf4, 0x63, 0x1a, 0x14, 0x31, 0x74,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x00, } func (m *SlashInfo) Marshal() (dAtA []byte, err error) { @@ -411,6 +413,13 @@ func (m *ScheduleInfo) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintWire(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x1a + } if len(m.Actor) > 0 { i -= len(m.Actor) copy(dAtA[i:], m.Actor) @@ -562,6 +571,10 @@ func (m *ScheduleInfo) Size() (n int) { if l > 0 { n += 1 + l + sovWire(uint64(l)) } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovWire(uint64(l)) + } return n } @@ -907,6 +920,38 @@ func (m *ScheduleInfo) Unmarshal(dAtA []byte) error { } m.Actor = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowWire + } + 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 ErrInvalidLengthWire + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthWire + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipWire(dAtA[iNdEx:]) From fd3ca3f3a21416b3bfb0686d4c36965b62afd60b Mon Sep 17 00:00:00 2001 From: Likes To Eat Fish Date: Wed, 24 Jul 2024 11:33:50 +0700 Subject: [PATCH 14/14] updates --- x/meshsecurityprovider/client/cli/tx.go | 87 +++++++++++++++++++ x/meshsecurityprovider/contract/in_message.go | 17 ++++ x/meshsecurityprovider/keeper/delegate.go | 29 +++++++ x/meshsecurityprovider/keeper/msg_server.go | 38 ++++++++ x/meshsecurityprovider/keeper/wasm.go | 16 ++++ x/meshsecurityprovider/types/params.go | 3 +- x/meshsecurityprovider/types/tx.go | 16 ++++ 7 files changed, 205 insertions(+), 1 deletion(-) diff --git a/x/meshsecurityprovider/client/cli/tx.go b/x/meshsecurityprovider/client/cli/tx.go index 2b3a4443..d5077f3b 100644 --- a/x/meshsecurityprovider/client/cli/tx.go +++ b/x/meshsecurityprovider/client/cli/tx.go @@ -73,3 +73,90 @@ func NewSetConsumerCommissionRateCmd() *cobra.Command { return cmd } + +// NewDelegateCmd returns a CLI command handler for creating a MsgDelegate transaction. +func NewDelegateCmd() *cobra.Command { + bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() + + cmd := &cobra.Command{ + Use: "delegate [validator-addr] [amount]", + Args: cobra.ExactArgs(2), + Short: "Delegate liquid tokens to a validator", + Long: strings.TrimSpace( + fmt.Sprintf(`Delegate an amount of liquid coins to a validator from your wallet. + +Example: +$ %s tx staking delegate %s1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm 1000stake --from mykey +`, + version.AppName, bech32PrefixValAddr, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + amount, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return err + } + + delAddr := clientCtx.GetFromAddress() + valAddr, err := sdk.ValAddressFromBech32(args[0]) + if err != nil { + return err + } + + msg := types.NewMsgDelegate(delAddr, valAddr, amount) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func NewUnbondCmd() *cobra.Command { + bech32PrefixValAddr := sdk.GetConfig().GetBech32ValidatorAddrPrefix() + + cmd := &cobra.Command{ + Use: "unbond [validator-addr] [amount]", + Short: "Unbond shares from a validator", + Args: cobra.ExactArgs(2), + Long: strings.TrimSpace( + fmt.Sprintf(`Unbond an amount of bonded shares from a validator. + +Example: +$ %s tx staking unbond %s1gghjut3ccd8ay0zduzj64hwre2fxs9ldmqhffj 100stake --from mykey +`, + version.AppName, bech32PrefixValAddr, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + delAddr := clientCtx.GetFromAddress() + valAddr, err := sdk.ValAddressFromBech32(args[0]) + if err != nil { + return err + } + + amount, err := sdk.ParseCoinNormalized(args[1]) + if err != nil { + return err + } + + msg := types.NewMsgUndelegate(delAddr, valAddr, amount) + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/meshsecurityprovider/contract/in_message.go b/x/meshsecurityprovider/contract/in_message.go index ee5e99ec..f0ff1e43 100644 --- a/x/meshsecurityprovider/contract/in_message.go +++ b/x/meshsecurityprovider/contract/in_message.go @@ -20,3 +20,20 @@ type ( Amount wasmvmtypes.Coin `json:"amount"` } ) + +type ( + CustomMsg struct { + VaultCustomMsg *VaultCustomMsg `json:"vault,omitempty"` + } + VaultCustomMsg struct { + Bond *BondMsg `json:"bond,omitempty"` + Unbond *UnbondMsg `json:"unbond,omitempty"` + } + BondMsg struct { + Amount wasmvmtypes.Coin `json:"amount"` + Validator string `json:"validator"` + } + UnbondMsg struct { + Amount wasmvmtypes.Coin `json:"amount"` + } +) diff --git a/x/meshsecurityprovider/keeper/delegate.go b/x/meshsecurityprovider/keeper/delegate.go index 768c60a5..a44a034c 100644 --- a/x/meshsecurityprovider/keeper/delegate.go +++ b/x/meshsecurityprovider/keeper/delegate.go @@ -1,6 +1,8 @@ package keeper import ( + "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" // stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -61,3 +63,30 @@ func (k Keeper) RemoteStake(ctx sdk.Context, denomDelegate string, token sdk.Coi k.SetIntermediary(ctx, inter) return nil } + +func (k Keeper) Undelegate(ctx sdk.Context, msg types.MsgUndelegate) error { + amount := wasmkeeper.ConvertSdkCoinToWasmCoin(msg.Amount) + unbondMsg := contract.VaultCustomMsg{ + Unbond: &contract.UnbondMsg{ + Amount: amount, + }, + } + err := k.SendCustomUnbond(ctx, unbondMsg) + if err != nil { + return err + } + + inter, found := k.GetIntermediary(ctx, msg.Amount.Denom) + if !found { + return fmt.Errorf("can not found Intermediary by denom %s", msg.Amount.Denom) + } + if inter.Token.IsLT(msg.Amount) { + return fmt.Errorf("failed to undelegate; total inter token %s is smaller than %s", inter.Token, msg.Amount) + } + + newAmount := inter.Token.Sub(msg.Amount) + inter.Token = &newAmount + + k.SetIntermediary(ctx, inter) + return nil +} diff --git a/x/meshsecurityprovider/keeper/msg_server.go b/x/meshsecurityprovider/keeper/msg_server.go index 8c213d45..197ede8c 100644 --- a/x/meshsecurityprovider/keeper/msg_server.go +++ b/x/meshsecurityprovider/keeper/msg_server.go @@ -93,5 +93,43 @@ func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*typ } func (k msgServer) Undelegate(goCtx context.Context, msg *types.MsgUndelegate) (*types.MsgUndelegateResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + err := msg.Amount.Validate() + if err != nil { + return nil, fmt.Errorf("failed to undelegate; Validate fail") + } + denomUndelegate := msg.Amount.Denom + + vaultAdress := sdk.AccAddress(k.Keeper.GetParams(ctx).GetVaultContractAddress()) + delegatorAddress, err := sdk.AccAddressFromBech32(msg.DelegatorAddress) + if err != nil { + return nil, err + } + + depositors, found := k.GetDepositors(ctx, msg.DelegatorAddress) + if !found { + return nil, fmt.Errorf("failed to undelegate; not found Depositors") + } + + found, totalDelegate := depositors.Tokens.Find(denomUndelegate) + if !found { + return nil, fmt.Errorf("failed to undelegate; not found token %s in Depositors", denomUndelegate) + } + + if totalDelegate.IsLT(msg.Amount) { + return nil, fmt.Errorf("failed to delegate; %s is smaller than %s", totalDelegate, msg.Amount) + } + + // call back contract and consumerchain + err = k.Keeper.Undelegate(ctx, *msg) + if err != nil { + return nil, err + } + + if err := k.bank.SendCoins(ctx, vaultAdress, delegatorAddress, sdk.NewCoins([]sdk.Coin{msg.Amount}...)); err != nil { + return nil, err + } + return &types.MsgUndelegateResponse{}, nil } diff --git a/x/meshsecurityprovider/keeper/wasm.go b/x/meshsecurityprovider/keeper/wasm.go index e56945ff..5fa3a394 100644 --- a/x/meshsecurityprovider/keeper/wasm.go +++ b/x/meshsecurityprovider/keeper/wasm.go @@ -26,3 +26,19 @@ func (k Keeper) doSudoCall(ctx sdk.Context, contractAddr sdk.AccAddress, msg con _, err = k.wasm.Sudo(ctx, contractAddr, bz) return err } + +func (k Keeper) SendCustomUnbond(ctx sdk.Context, v contract.VaultCustomMsg) error { + msg := contract.CustomMsg{ + VaultCustomMsg: &v, + } + return k.doExcCall(ctx, k.GetParams(ctx).GetVaultContractAddress(), msg) +} + +func (k Keeper) doExcCall(ctx sdk.Context, contractAddr sdk.AccAddress, msg contract.CustomMsg) error { + bz, err := json.Marshal(msg) + if err != nil { + return errorsmod.Wrap(err, "marshal sudo msg") + } + _, err = k.wasm.Sudo(ctx, contractAddr, bz) + return err +} diff --git a/x/meshsecurityprovider/types/params.go b/x/meshsecurityprovider/types/params.go index 050f8982..0e844c3e 100644 --- a/x/meshsecurityprovider/types/params.go +++ b/x/meshsecurityprovider/types/params.go @@ -5,7 +5,8 @@ import sdk "github.com/cosmos/cosmos-sdk/types" // DefaultParams returns default mesh-security parameters func DefaultParams(denom string) Params { return Params{ // todo: revisit and set proper defaults - TimeoutPeriod: 60, + TimeoutPeriod: 60, + VaultContractAddress: "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr", } } diff --git a/x/meshsecurityprovider/types/tx.go b/x/meshsecurityprovider/types/tx.go index 871f996a..cb15b5f9 100644 --- a/x/meshsecurityprovider/types/tx.go +++ b/x/meshsecurityprovider/types/tx.go @@ -9,6 +9,14 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +func NewMsgDelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) *MsgDelegate { + return &MsgDelegate{ + DelegatorAddress: delAddr.String(), + ValidatorAddress: valAddr.String(), + Amount: amount, + } +} + // GetSignBytes implements the LegacyMsg interface. func (msg MsgDelegate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) @@ -34,6 +42,14 @@ func (msg MsgDelegate) ValidateBasic() error { return nil } +func NewMsgUndelegate(delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount sdk.Coin) *MsgUndelegate { + return &MsgUndelegate{ + DelegatorAddress: delAddr.String(), + ValidatorAddress: valAddr.String(), + Amount: amount, + } +} + // GetSignBytes implements the LegacyMsg interface. func (msg MsgUndelegate) GetSignBytes() []byte { return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))