Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update poktroll proto files #22

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions proto/poktroll/application/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,42 @@ option (gogoproto.stable_marshaler_all) = true;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

import "poktroll/application/types.proto";

// EventRedelegation is an event emitted whenever an application changes its
// delegatee gateways on chain. This is in response to both a DelegateToGateway
// and UndelegateFromGateway message.
message EventRedelegation {
string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application.
string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application has changed their delegation of.
}

// EventTransferBegin is emitted whenever an application begins a transfer. It
// includes the source application state immediately after the transfer began.
message EventTransferBegin {
string source_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string destination_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
poktroll.application.Application source_application = 3;
}

// EventTransferEnd is emitted whenever an application transfer is completed. It
// includes the destination application state at the time the transfer completed.
// Either EventTransferEnd or EventTransferError will be emitted corresponding to
// any given EventTransferBegin event.
message EventTransferEnd {
string source_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string destination_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
poktroll.application.Application destination_application = 3;
}

// EventTransferError is emitted whenever an application transfer fails. It
// includes the source application state at the time the transfer failed and
// the error message.
// Either EventTransferEnd or EventTransferError will be emitted corresponding to
// any given EventTransferBegin event.
message EventTransferError {
string source_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string destination_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
poktroll.application.Application source_application = 3;
string error = 4;
}
44 changes: 30 additions & 14 deletions proto/poktroll/application/tx.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
syntax = "proto3";

package poktroll.application;

option go_package = "github.com/pokt-network/poktroll/x/application/types";
Expand All @@ -9,27 +10,27 @@ import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "gogoproto/gogo.proto";

import "poktroll/application/types.proto";
import "poktroll/application/params.proto";
import "poktroll/shared/service.proto";


// Msg defines the Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;

// UpdateParams defines a (governance) operation for updating the module
// parameters. The authority defaults to the x/gov module account.
rpc UpdateParams (MsgUpdateParams ) returns (MsgUpdateParamsResponse );
rpc StakeApplication (MsgStakeApplication ) returns (MsgStakeApplicationResponse );
rpc UnstakeApplication (MsgUnstakeApplication ) returns (MsgUnstakeApplicationResponse );
rpc DelegateToGateway (MsgDelegateToGateway ) returns (MsgDelegateToGatewayResponse );
rpc UndelegateFromGateway (MsgUndelegateFromGateway) returns (MsgUndelegateFromGatewayResponse);
rpc UpdateParams (MsgUpdateParams) returns (MsgUpdateParamsResponse);
rpc StakeApplication (MsgStakeApplication) returns (MsgStakeApplicationResponse);
rpc UnstakeApplication (MsgUnstakeApplication) returns (MsgUnstakeApplicationResponse);
rpc DelegateToGateway (MsgDelegateToGateway) returns (MsgDelegateToGatewayResponse);
rpc UndelegateFromGateway (MsgUndelegateFromGateway) returns (MsgUndelegateFromGatewayResponse);
rpc TransferApplication (MsgTransferApplication) returns (MsgTransferApplicationResponse);
}
// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "poktroll/x/application/MsgUpdateParams";
option (amino.name) = "poktroll/x/application/MsgUpdateParams";

// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Expand All @@ -49,13 +50,17 @@ message MsgUpdateParamsResponse {}

message MsgStakeApplication {
option (cosmos.msg.v1.signer) = "address";

string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application.
cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the application has staked. Must be ≥ to the current amount that the application has staked (if any)
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application.
cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the application has staked. Must be ≥ to the current amount that the application has staked (if any)
repeated poktroll.shared.ApplicationServiceConfig services = 3; // The list of services this application is staked to request service for
// TODO_POST_MAINNET_CONSIDERATION: Consdier allowing appplications to delegate
// to gateways at time of staking for a better developer experience.
// repeated string gateway_addresss
}

message MsgStakeApplicationResponse {}
message MsgStakeApplicationResponse {
poktroll.application.Application application = 1;
}

message MsgUnstakeApplication {
option (cosmos.msg.v1.signer) = "address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries
Expand All @@ -68,10 +73,11 @@ message MsgDelegateToGateway {
option (cosmos.msg.v1.signer) = "app_address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries
string app_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application.
string gateway_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application wants to delegate to.

}

message MsgDelegateToGatewayResponse {}
message MsgDelegateToGatewayResponse {
poktroll.application.Application application = 1;
}

message MsgUndelegateFromGateway {
option (cosmos.msg.v1.signer) = "app_address"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries
Expand All @@ -81,3 +87,13 @@ message MsgUndelegateFromGateway {

message MsgUndelegateFromGatewayResponse {}

message MsgTransferApplication {
option (cosmos.msg.v1.signer) = "source_address";
string source_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
string destination_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}

message MsgTransferApplicationResponse {
poktroll.application.Application application = 1;
}

8 changes: 8 additions & 0 deletions proto/poktroll/application/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@ message Application {
// The end height of the session at which an application initiated its unstaking process.
// If the application did not unstake, this value will be 0.
uint64 unstake_session_end_height = 6;
PendingApplicationTransfer pending_transfer = 7;
}

// UndelegatingGatewayList is used as the Value of `pending_undelegations`.
// It is required to store a repeated list of strings as a map value.
message UndelegatingGatewayList {
repeated string gateway_addresses = 2 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.nullable) = false];
}

// PendingTransfer is used to store the details of a pending transfer.
// It is only intended to be used inside of an Application object.
message PendingApplicationTransfer {
string destination_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
uint64 session_end_height = 2;
}
4 changes: 4 additions & 0 deletions proto/poktroll/gateway/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ option go_package = "github.com/pokt-network/poktroll/x/gateway/types";
option (gogoproto.stable_marshaler_all) = true;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";

// Params defines the parameters for the module.
message Params {
option (amino.name) = "poktroll/x/gateway/Params";
option (gogoproto.equal) = true;

// min_stake is the minimum amount of uPOKT that a gateway must stake.
cosmos.base.v1beta1.Coin min_stake = 1 [(gogoproto.jsontag) = "min_stake"];
}
33 changes: 27 additions & 6 deletions proto/poktroll/gateway/tx.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
syntax = "proto3";

package poktroll.gateway;

option go_package = "github.com/pokt-network/poktroll/x/gateway/types";
Expand All @@ -9,8 +10,8 @@ import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

import "poktroll/gateway/params.proto";
import "poktroll/gateway/types.proto";

// Msg defines the Msg service.
service Msg {
Expand All @@ -21,11 +22,12 @@ service Msg {
rpc UpdateParams (MsgUpdateParams ) returns (MsgUpdateParamsResponse );
rpc StakeGateway (MsgStakeGateway ) returns (MsgStakeGatewayResponse );
rpc UnstakeGateway (MsgUnstakeGateway) returns (MsgUnstakeGatewayResponse);
rpc UpdateParam (MsgUpdateParam ) returns (MsgUpdateParamResponse );
}
// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "poktroll/x/gateway/MsgUpdateParams";
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "poktroll/x/gateway/MsgUpdateParams";

// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
Expand All @@ -45,11 +47,13 @@ message MsgUpdateParamsResponse {}

message MsgStakeGateway {
option (cosmos.msg.v1.signer) = "address"; // see: https://docs.cosmos.network/main/build/building-modules/protobuf-annotations#signer
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway
cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the gateway is staking. Must be ≥ to the current amount that the gateway has staked (if any)
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway
cosmos.base.v1beta1.Coin stake = 2; // The total amount of uPOKT the gateway is staking. Must be ≥ to the current amount that the gateway has staked (if any)
}

message MsgStakeGatewayResponse {}
message MsgStakeGatewayResponse {
poktroll.gateway.Gateway gateway = 1;
}

message MsgUnstakeGateway {
option (cosmos.msg.v1.signer) = "address";
Expand All @@ -58,3 +62,20 @@ message MsgUnstakeGateway {

message MsgUnstakeGatewayResponse {}

// MsgUpdateParam is the Msg/UpdateParam request type to update a single param.
message MsgUpdateParam {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

string name = 2;
oneof as_type {
cosmos.base.v1beta1.Coin as_coin = 3 [(gogoproto.jsontag) = "as_coin"];
}
}

message MsgUpdateParamResponse {
Params params = 1;
}

12 changes: 10 additions & 2 deletions proto/poktroll/proof/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,22 @@ message Params {
// is equal to or above the threshold. This is in contrast to the this requirement
// being determined probabilistically via ProofRequestProbability.
//
// TODO_MAINNET: Consider renaming this to `proof_requirement_threshold_compute_units`.
uint64 proof_requirement_threshold = 3 [(gogoproto.jsontag) = "proof_requirement_threshold"];
// TODO_MAINNET: Consider renaming this to `proof_requirement_threshold_upokt`.
cosmos.base.v1beta1.Coin proof_requirement_threshold = 3 [(gogoproto.jsontag) = "proof_requirement_threshold"];

// proof_missing_penalty is the number of tokens (uPOKT) which should be slashed from a supplier
// when a proof is required (either via proof_requirement_threshold or proof_missing_penalty)
// but is not provided.
// TODO_MAINNET: Consider renaming this to `proof_missing_penalty_upokt`.
cosmos.base.v1beta1.Coin proof_missing_penalty = 4 [(gogoproto.jsontag) = "proof_missing_penalty"];

// proof_submission_fee is the number of tokens (uPOKT) which should be paid by
// the supplier operator when submitting a proof.
// This is needed to account for the cost of storing proofs on-chain and prevent
// spamming (i.e. sybil bloat attacks) the network with non-required proofs.
// TODO_MAINNET: Consider renaming this to `proof_submission_fee_upokt`.
cosmos.base.v1beta1.Coin proof_submission_fee = 5 [(gogoproto.jsontag) = "proof_submission_fee"];

// IMPORTANT: Make sure to update all related files if you're modifying or adding a new parameter.
// Try the following grep to find all related places: `grep -r compute_units_to_tokens_multiplier`
// TODO_IMPROVE: Look into an opportunity to use an enum to avoid using strings throughout the codebase.
Expand Down
2 changes: 1 addition & 1 deletion proto/poktroll/proof/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ message MsgSubmitProof {
string supplier_operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
poktroll.session.SessionHeader session_header = 2;

// serialized version of *smt.SparseMerkleClosestProof
// serialized version of *smt.SparseCompactMerkleClosestProof
bytes proof = 3;
}

Expand Down
2 changes: 1 addition & 1 deletion proto/poktroll/proof/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ message Proof {
string supplier_operator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// The session header of the session that this claim is for.
poktroll.session.SessionHeader session_header = 2;
// The serialized SMST proof from the `#ClosestProof()` method.
// The serialized SMST compacted proof from the `#ClosestProof()` method.
bytes closest_merkle_proof = 3;
}

Expand Down
3 changes: 2 additions & 1 deletion proto/poktroll/service/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ option (gogoproto.stable_marshaler_all) = true;

import "amino/amino.proto";
import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";


// Params defines the parameters for the module.
Expand All @@ -16,5 +17,5 @@ message Params {
// The amount of uPOKT required to add a new service.
// This will be deducted from the signer's account balance,
// and transferred to the pocket network foundation.
uint64 add_service_fee = 1 [(gogoproto.jsontag) = "add_service_fee", (gogoproto.moretags) = "yaml:\"add_service_fee\""];
cosmos.base.v1beta1.Coin add_service_fee = 1 [(gogoproto.jsontag) = "add_service_fee", (gogoproto.moretags) = "yaml:\"add_service_fee\""];
}
23 changes: 23 additions & 0 deletions proto/poktroll/service/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ option go_package = "github.com/pokt-network/poktroll/x/service/types";
option (gogoproto.stable_marshaler_all) = true;

import "amino/amino.proto";
import "cosmos/base/v1beta1/coin.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";
Expand All @@ -20,6 +21,7 @@ service Msg {
// UpdateParams defines a (governance) operation for updating the module
// parameters. The authority defaults to the x/gov module account.
rpc UpdateParams (MsgUpdateParams) returns (MsgUpdateParamsResponse);
rpc UpdateParam (MsgUpdateParam ) returns (MsgUpdateParamResponse );
rpc AddService (MsgAddService ) returns (MsgAddServiceResponse );
}
// MsgUpdateParams is the Msg/UpdateParams request type.
Expand All @@ -40,6 +42,27 @@ message MsgUpdateParams {
// MsgUpdateParams message.
message MsgUpdateParamsResponse {}

// MsgUpdateParam is the Msg/UpdateParam request type to update a single param.
message MsgUpdateParam {
option (cosmos.msg.v1.signer) = "authority";

// authority is the address that controls the module (defaults to x/gov unless overwritten).
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];

// The (name, as_type) tuple must match the corresponding name and type as
// specified in the `Params` message in `proof/params.proto.`
string name = 2;
oneof as_type {
cosmos.base.v1beta1.Coin as_coin = 9 [(gogoproto.jsontag) = "as_coin"];
}
}

// MsgUpdateParamResponse defines the response structure for executing a
// MsgUpdateParam message after a single param update.
message MsgUpdateParamResponse {
Params params = 1;
}

// MsgAddService defines a message for adding a new message to the network.
// Services can be added by any actor in the network making them truly
// permissionless.
Expand Down
2 changes: 1 addition & 1 deletion proto/poktroll/session/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ message QueryParamsResponse {

message QueryGetSessionRequest {
string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application.
poktroll.shared.Service service = 2; // The service to query the session for
string service_id = 2; // The service ID to query the session for
int64 block_height = 3; // The block height to query the session for
}

Expand Down
2 changes: 1 addition & 1 deletion proto/poktroll/session/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "gogoproto/gogo.proto";
// It is the minimal amount of data required to hydrate & retrieve all data relevant to the session.
message SessionHeader {
string application_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the application.
poktroll.shared.Service service = 2; // The service this session is for
string service_id = 2; // The service id this session is for
// NOTE: session_id can be derived from the above values using on-chain but is included in the header for convenience
string session_id = 3; // A unique pseudoranom ID for this session
int64 session_start_block_height = 4; // The height at which this session started
Expand Down
3 changes: 3 additions & 0 deletions proto/poktroll/shared/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,7 @@ message Params {
// On-chain business logic requires, and ensures, that the corresponding block count of the
// application unbonding period will exceed the end of its corresponding proof window close height.
uint64 application_unbonding_period_sessions = 8 [(gogoproto.jsontag) = "application_unbonding_period_sessions"];
// The amount of upokt that a compute unit should translate to when settling a session.
// DEV_NOTE: This used to be under x/tokenomics but has been moved here to avoid cyclic dependencies.
uint64 compute_units_to_tokens_multiplier = 9 [(gogoproto.jsontag) = "compute_units_to_tokens_multiplier", (gogoproto.moretags) = "yaml:\"compute_units_to_tokens_multiplier\""];
}
8 changes: 3 additions & 5 deletions proto/poktroll/shared/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ message Service {
// For example, what if we want to request a session for a certain service but with some additional configs that identify it?
string id = 1; // Unique identifier for the service

// TODO_MAINNET: Remove this.
// TODO_BETA: Either remove this or rename it to alias.
string name = 2; // (Optional) Semantic human readable name for the service

// The cost of a single relay for this service in terms of compute units.
Expand All @@ -32,8 +32,7 @@ message Service {

// ApplicationServiceConfig holds the service configuration the application stakes for
message ApplicationServiceConfig {
// TODO_MAINNET: Avoid embedding the full Service because we just need the ID.
Service service = 1; // The Service for which the application is configured
string service_id = 1; // The Service ID for which the application is configured

// TODO_MAINNET: There is an opportunity for applications to advertise the max
// they're willing to pay for a certain configuration/price, but this is outside of scope.
Expand All @@ -42,8 +41,7 @@ message ApplicationServiceConfig {

// SupplierServiceConfig holds the service configuration the supplier stakes for
message SupplierServiceConfig {
// TODO_MAINNET: Avoid embedding the full Service because we just need the ID.
Service service = 1; // The Service for which the supplier is configured
string service_id = 1; // The Service ID for which the supplier is configured
repeated SupplierEndpoint endpoints = 2; // List of endpoints for the service
repeated ServiceRevenueShare rev_share = 3; // List of revenue share configurations for the service
// TODO_MAINNET: There is an opportunity for supplier to advertise the min
Expand Down
Loading