-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: restaking module keeper and msg server (#31)
## Description This PR implements the write operations of the `x/restaking` module. In particular, it contains the `Keeper` and `MsgServer` methods to execute the various restaking-related messages. All queries and read operations are not present inside this PR, neither are the module registration inside the `App`, nor clients implementations. All of this will be implemented with other PRs in the future. This guarantees that the files changed here are less and easier to review. <!-- Add a description of the changes that this PR introduces and the files that are the most critical to review. --> --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [x] targeted the correct branch (see [PR Targeting](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#pr-targeting)) - [x] provided a link to the relevant issue or specification - [x] followed the guidelines for [building modules](https://docs.cosmos.network/v0.44/building-modules/intro.html) - [x] included the necessary unit and integration [tests](https://github.com/desmos-labs/desmos/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [x] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [x] reviewed "Files changed" and left comments if necessary - [x] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable)
- Loading branch information
Showing
52 changed files
with
9,414 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
syntax = "proto3"; | ||
package milkyway.restaking.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "milkyway/restaking/v1/models.proto"; | ||
import "milkyway/restaking/v1/params.proto"; | ||
|
||
option go_package = "github.com/milkyway-labs/milkyway/x/restaking/types"; | ||
|
||
// GenesisState defines the restaking module's genesis state. | ||
message GenesisState { | ||
// Params defines the parameters of the module. | ||
Params params = 1 [ (gogoproto.nullable) = false ]; | ||
|
||
// PoolDelegations represents the delegations to pools. | ||
repeated PoolDelegation pools_delegations = 2 | ||
[ (gogoproto.nullable) = false ]; | ||
|
||
// ServiceDelegations represents the delegations to services. | ||
repeated ServiceDelegation services_delegations = 3 | ||
[ (gogoproto.nullable) = false ]; | ||
|
||
// OperatorDelegations represents the delegations to operators. | ||
repeated OperatorDelegation operators_delegations = 4 | ||
[ (gogoproto.nullable) = false ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
syntax = "proto3"; | ||
package milkyway.restaking.v1; | ||
|
||
import "amino/amino.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "cosmos/bank/v1beta1/bank.proto"; | ||
import "cosmos/msg/v1/msg.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "milkyway/restaking/v1/params.proto"; | ||
|
||
option go_package = "github.com/milkyway-labs/milkyway/x/restaking/types"; | ||
|
||
// Msg defines the restaking module's gRPC message service. | ||
service Msg { | ||
option (cosmos.msg.v1.service) = true; | ||
|
||
// DelegatePool defines the operation that allows users to delegate any amount | ||
// of an asset to a pool that can then be used to provide services with | ||
// cryptoeconomic security. | ||
rpc DelegatePool(MsgDelegatePool) returns (MsgDelegatePoolResponse); | ||
|
||
// DelegateOperator defines the operation that allows users to delegate their | ||
// assets to a specific operator. | ||
rpc DelegateOperator(MsgDelegateOperator) | ||
returns (MsgDelegateOperatorResponse); | ||
|
||
// DelegateService defines the operation that allows users to delegate their | ||
// assets to a specific service. | ||
rpc DelegateService(MsgDelegateService) returns (MsgDelegateServiceResponse); | ||
|
||
// UpdateParams defines a (governance) operation for updating the module | ||
// parameters. | ||
// The authority defaults to the x/gov module account. | ||
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse); | ||
} | ||
|
||
// MsgDelegatePool defines the message structure for the DelegatePool gRPC | ||
// service method. It allows a user to put their assets into a restaking pool | ||
// that will later be used to provide cryptoeconomic security to services that | ||
// choose it. | ||
message MsgDelegatePool { | ||
option (cosmos.msg.v1.signer) = "delegator"; | ||
option (amino.name) = "milkyway/MsgJoinRestakingPool"; | ||
|
||
// Delegator is the address of the user joining the pool | ||
string delegator = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
|
||
// Amount is the amount of coins to be staked | ||
cosmos.base.v1beta1.Coin amount = 2 | ||
[ (gogoproto.customname) = "Amount", (gogoproto.nullable) = false ]; | ||
} | ||
|
||
// MsgDelegatePoolResponse defines the return value of MsgDelegatePool. | ||
message MsgDelegatePoolResponse {} | ||
|
||
// MsgDelegateOperator defines the message structure for the OperatorRestake | ||
// gRPC service method. It allows a user to delegate their assets to an | ||
// operator. | ||
message MsgDelegateOperator { | ||
option (cosmos.msg.v1.signer) = "delegator"; | ||
option (amino.name) = "milkyway/MsgDelegateOperator"; | ||
|
||
// Delegator is the address of the user delegating to the operator | ||
string delegator = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
|
||
// OperatorID is the ID of the operator to delegate to | ||
uint32 operator_id = 2 [ (gogoproto.customname) = "OperatorID" ]; | ||
|
||
// Amount is the amount of coins to be delegated | ||
repeated cosmos.base.v1beta1.Coin amount = 3 [ | ||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", | ||
(gogoproto.customname) = "Amount", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
// MsgDelegateOperatorResponse is the return value of MsgDelegateOperator. | ||
message MsgDelegateOperatorResponse {} | ||
|
||
// MsgDelegateService defines the message structure for the ServiceRestake gRPC | ||
// service method. It allows a user to delegate their assets to a service. | ||
message MsgDelegateService { | ||
option (cosmos.msg.v1.signer) = "delegator"; | ||
option (amino.name) = "milkyway/MsgDelegateService"; | ||
|
||
// Delegator is the address of the user delegating to the service | ||
string delegator = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
|
||
// ServiceID is the ID of the service to delegate to | ||
uint32 service_id = 2 [ (gogoproto.customname) = "ServiceID" ]; | ||
|
||
// Amount is the amount of coins to be delegated | ||
repeated cosmos.base.v1beta1.Coin amount = 3 [ | ||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", | ||
(gogoproto.customname) = "Amount", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
// MsgDelegateServiceResponse is the return value of MsgDelegateService. | ||
message MsgDelegateServiceResponse {} | ||
|
||
// MsgDeactivateService defines the message structure for the UpdateParams gRPC | ||
// service method. It allows the authority to update the module parameters. | ||
message MsgUpdateParams { | ||
option (cosmos.msg.v1.signer) = "authority"; | ||
option (amino.name) = "milkyway/x/restaking/MsgUpdateParams"; | ||
|
||
// Authority is the address that controls the module (defaults to x/gov unless | ||
// overwritten). | ||
string authority = 1 [ | ||
(gogoproto.moretags) = "yaml:\"authority\"", | ||
(cosmos_proto.scalar) = "cosmos.AddressString" | ||
]; | ||
|
||
// Params define the parameters to update. | ||
// | ||
// NOTE: All parameters must be supplied. | ||
Params params = 2 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
// MsgDeactivateServiceResponse is the return value of MsgUpdateParams. | ||
message MsgUpdateParamsResponse {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
syntax = "proto3"; | ||
package milkyway.restaking.v1; | ||
|
||
import "amino/amino.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
|
||
option go_package = "github.com/milkyway-labs/milkyway/x/restaking/types"; | ||
|
||
// PoolDelegation represents the bond with tokens held by an account with a | ||
// given pool. It is owned by one delegator, and is associated with a pool. | ||
message PoolDelegation { | ||
option (gogoproto.equal) = false; | ||
option (gogoproto.goproto_getters) = false; | ||
|
||
// UserAddress is the encoded address of the user. | ||
string user_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
|
||
// PoolID is the id of the pool. | ||
uint32 pool_id = 2 [ (gogoproto.customname) = "PoolID" ]; | ||
|
||
// Shares define the delegation shares received. | ||
string shares = 3 [ | ||
(cosmos_proto.scalar) = "cosmos.Dec", | ||
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
// OperatorDelegation represents the bond with tokens held by an account with a | ||
// given operator. It is owned by one delegator, and is associated with a | ||
// operator. | ||
message OperatorDelegation { | ||
option (gogoproto.equal) = false; | ||
option (gogoproto.goproto_getters) = false; | ||
|
||
// UserAddress is the encoded address of the user. | ||
string user_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
|
||
// OperatorID is the id of the operator. | ||
uint32 operator_id = 2 [ (gogoproto.customname) = "OperatorID" ]; | ||
|
||
// Shares define the delegation shares received. | ||
repeated cosmos.base.v1beta1.DecCoin shares = 3 [ | ||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", | ||
(gogoproto.nullable) = false | ||
]; | ||
} | ||
|
||
// ServiceDelegation represents the bond with tokens held by an account with a | ||
// given service. It is owned by one delegator, and is associated with a | ||
// service. | ||
message ServiceDelegation { | ||
option (gogoproto.equal) = false; | ||
option (gogoproto.goproto_getters) = false; | ||
|
||
// UserAddress is the encoded address of the user. | ||
string user_address = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; | ||
|
||
// ServiceID is the id of the service. | ||
uint32 service_id = 2 [ (gogoproto.customname) = "ServiceID" ]; | ||
|
||
// Shares define the delegation shares received. | ||
repeated cosmos.base.v1beta1.DecCoin shares = 3 [ | ||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins", | ||
(gogoproto.nullable) = false | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
package milkyway.restaking.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
|
||
option go_package = "github.com/milkyway-labs/milkyway/x/restaking/types"; | ||
|
||
// Params defines the parameters for the module. | ||
message Params { | ||
|
||
// UnbondingTime represents the time that will take for assets to be unbonded | ||
// after the user initiates an unbonding request. This will be applied to all | ||
// types of restaking: pool, operator and service restaking. | ||
int64 unbonding_time = 1 [ (gogoproto.stdduration) = true ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.