Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
67 changes: 64 additions & 3 deletions proto/poktroll/application/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,31 @@ option (gogoproto.stable_marshaler_all) = true;

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

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

enum ApplicationUnbondingReason {
ELECTIVE = 0;
BELOW_MIN_STAKE = 1;
}

// EventApplicationStaked is emitted when an application is staked or up-staked.
message EventApplicationStaked {
poktroll.application.Application application = 1 [(gogoproto.jsontag) = "application"];
// The end height of the session in which the application was staked.
int64 session_end_height = 2 [(gogoproto.jsontag) = "session_end_height"];
}

// 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.
// The application which was redelegated.
poktroll.application.Application application = 1 [(gogoproto.jsontag) = "application"];
// The end height of the session in which the redelegation was committed.
int64 session_end_height = 2 [(gogoproto.jsontag) = "session_end_height"];
}

// EventTransferBegin is emitted whenever an application begins a transfer. It
Expand All @@ -23,6 +39,10 @@ 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;
// The end height of the session in which the transfer began.
int64 session_end_height = 4 [(gogoproto.jsontag) = "session_end_height"];
// The height at which the transfer will complete.
int64 transfer_end_height = 5 [(gogoproto.jsontag) = "transfer_end_height"];
}

// EventTransferEnd is emitted whenever an application transfer is completed. It
Expand All @@ -33,6 +53,10 @@ 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;
// The end height of the session in which the transfer ended.
int64 session_end_height = 4 [(gogoproto.jsontag) = "session_end_height"];
// The height at which the transfer completed.
int64 transfer_end_height = 5 [(gogoproto.jsontag) = "transfer_end_height"];
}

// EventTransferError is emitted whenever an application transfer fails. It
Expand All @@ -44,5 +68,42 @@ 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;
// The end height of the session in which the transfer failed.
int64 session_end_height = 4 [(gogoproto.jsontag) = "session_end_height"];
string error = 5;
}

// EventApplicationUnbondingBegin is emitted when an application begins unbonding.
// This can be triggered by the commitment of an unstake message or by the applicaiton's
// stake dropping below the minimum. This event signals that an application has begun
// unbonding. The unbonding period is determined by the shared param,
// application_unbonding_period_sessions.
message EventApplicationUnbondingBegin {
poktroll.application.Application application = 1 [(gogoproto.jsontag) = "application"];
ApplicationUnbondingReason reason = 2 [(gogoproto.jsontag) = "reason"];
// The end height of the session in which the unbonding began.
int64 session_end_height = 3 [(gogoproto.jsontag) = "session_end_height"];
// The height at which application unbonding will end.
int64 unbonding_end_height = 4 [(gogoproto.jsontag) = "unbonding_height"];
}

// EventApplicationUnbondingEnd is emitted when an application has completed
// unbonding. The unbonding period is determined by the shared param,
// application_unbonding_period_sessions.
message EventApplicationUnbondingEnd {
poktroll.application.Application application = 1 [(gogoproto.jsontag) = "application"];
ApplicationUnbondingReason reason = 2 [(gogoproto.jsontag) = "reason"];
// The end height of the session in which the unbonding ended.
int64 session_end_height = 3 [(gogoproto.jsontag) = "session_end_height"];
// The height at which application unbonding ended.
int64 unbonding_end_height = 4 [(gogoproto.jsontag) = "unbonding_height"];
}

// EventApplicationUnbondingCanceled is emitted when an application which was unbonding
// successfully (re-)stakes before the unbonding period has elapsed. An EventApplicationStaked
// event will also be emitted immediately after this event.
message EventApplicationUnbondingCanceled {
poktroll.application.Application application = 1 [(gogoproto.jsontag) = "application"];
// The end height of the session in which the unbonding was canceled.
int64 session_end_height = 2 [(gogoproto.jsontag) = "session_end_height"];
}
4 changes: 2 additions & 2 deletions proto/poktroll/application/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ message MsgUpdateParam {

string name = 2;
oneof asType {
int64 as_int64 = 3;
cosmos.base.v1beta1.Coin as_coin = 4;
uint64 as_uint64 = 3 [(gogoproto.jsontag) = "as_uint64"];
cosmos.base.v1beta1.Coin as_coin = 4 [(gogoproto.jsontag) = "as_coin"];
};
}

Expand Down
17 changes: 15 additions & 2 deletions proto/poktroll/gateway/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ option (gogoproto.stable_marshaler_all) = true;
import "cosmos_proto/cosmos.proto";
import "gogoproto/gogo.proto";

// GatewayStaked defines the event emitted when a gateway has been unstaked.
import "poktroll/gateway/types.proto";

// GatewayStaked is emitted when a gateway is staked or up-staked.
message EventGatewayStaked {
// The gateway that has been staked.
Gateway gateway = 1 [(gogoproto.jsontag) = "gateway"];
// The end height of the session in which gateway was staked.
int64 session_end_height = 2 [(gogoproto.jsontag) = "session_end_height"];
}

// GatewayUnstaked defines the event emitted when a gateway has been unstaked.
message EventGatewayUnstaked {
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the gateway the application has changed their delegation of.
// The gateway that has been unstaked.
Gateway gateway = 1 [(gogoproto.jsontag) = "gateway"];
// The end height of the session in which gateway was unstaked.
int64 session_end_height = 2 [(gogoproto.jsontag) = "session_end_height"];
}
8 changes: 4 additions & 4 deletions proto/poktroll/proof/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ message EventClaimCreated {
uint64 num_relays = 2 [(gogoproto.jsontag) = "num_relays"];
uint64 num_claimed_compute_units = 4 [(gogoproto.jsontag) = "num_claimed_compute_units"];
uint64 num_estimated_compute_units = 5 [(gogoproto.jsontag) = "num_estimated_compute_units"];
cosmos.base.v1beta1.Coin claimed_amount_upokt = 6 [(gogoproto.jsontag) = "claimed_amount_upokt"];
cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
}

// TODO_TEST: Add coverage for claim updates.
Expand All @@ -22,7 +22,7 @@ message EventClaimUpdated {
uint64 num_relays = 2 [(gogoproto.jsontag) = "num_relays"];
uint64 num_claimed_compute_units = 4 [(gogoproto.jsontag) = "num_claimed_compute_units"];
uint64 num_estimated_compute_units = 5 [(gogoproto.jsontag) = "num_estimated_compute_units"];
cosmos.base.v1beta1.Coin claimed_amount_upokt = 6 [(gogoproto.jsontag) = "claimed_amount_upokt"];
cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
}

message EventProofSubmitted {
Expand All @@ -31,7 +31,7 @@ message EventProofSubmitted {
uint64 num_relays = 3 [(gogoproto.jsontag) = "num_relays"];
uint64 num_claimed_compute_units = 4 [(gogoproto.jsontag) = "num_claimed_compute_units"];
uint64 num_estimated_compute_units = 5 [(gogoproto.jsontag) = "num_estimated_compute_units"];
cosmos.base.v1beta1.Coin claimed_amount_upokt = 6 [(gogoproto.jsontag) = "claimed_amount_upokt"];
cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
}

// TODO_TEST: Add coverage for proof updates.
Expand All @@ -41,5 +41,5 @@ message EventProofUpdated {
uint64 num_relays = 3 [(gogoproto.jsontag) = "num_relays"];
uint64 num_claimed_compute_units = 4 [(gogoproto.jsontag) = "num_claimed_compute_units"];
uint64 num_estimated_compute_units = 5 [(gogoproto.jsontag) = "num_estimated_compute_units"];
cosmos.base.v1beta1.Coin claimed_amount_upokt = 6 [(gogoproto.jsontag) = "claimed_amount_upokt"];
cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
}
2 changes: 0 additions & 2 deletions proto/poktroll/proof/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ message MsgUpdateParam {
// specified in the `Params`` message in `proof/params.proto.`
string name = 2;
oneof as_type {
string as_string = 3 [(gogoproto.jsontag) = "as_string"];
int64 as_int64 = 6 [(gogoproto.jsontag) = "as_int64"];
bytes as_bytes = 7 [(gogoproto.jsontag) = "as_bytes"];
float as_float = 8 [(gogoproto.jsontag) = "as_float"];
cosmos.base.v1beta1.Coin as_coin = 9 [(gogoproto.jsontag) = "as_coin"];
Expand Down
1 change: 1 addition & 0 deletions proto/poktroll/service/relay_mining_difficulty.proto
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "gogoproto/gogo.proto";

// RelayMiningDifficulty is a message used to store the on-chain Relay Mining
// difficulty associated with a specific service ID.
// TODO_TECHDEBT: Embed this message in the Service message.
message RelayMiningDifficulty {
// The service ID the relay mining difficulty is associated with.
string service_id = 1;
Expand Down
2 changes: 1 addition & 1 deletion proto/poktroll/shared/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ message MsgUpdateParam {
string name = 2;
oneof as_type {
string as_string = 3 [(gogoproto.jsontag) = "as_string"];
int64 as_int64 = 6 [(gogoproto.jsontag) = "as_int64"];
uint64 as_uint64 = 6 [(gogoproto.jsontag) = "as_uint64"];
bytes as_bytes = 7 [(gogoproto.jsontag) = "as_bytes"];
}
}
Expand Down
5 changes: 5 additions & 0 deletions proto/poktroll/supplier/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ 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.
message Params {
option (amino.name) = "poktroll/x/supplier/Params";
option (gogoproto.equal) = true;

// min_stake is the minimum amount of uPOKT that a supplier must stake to be
// included in network sessions and remain staked.
cosmos.base.v1beta1.Coin min_stake = 1 [(gogoproto.jsontag) = "min_stake", (gogoproto.moretags) = "yaml:\"min_stake\""];
}
43 changes: 27 additions & 16 deletions proto/poktroll/supplier/tx.proto
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
syntax = "proto3";

package poktroll.supplier;

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

import "poktroll/supplier/params.proto";
import "poktroll/shared/service.proto";


// Msg defines the Msg service.
service Msg {
option (cosmos.msg.v1.service) = true;
Expand All @@ -23,19 +22,16 @@ service Msg {
rpc UpdateParams (MsgUpdateParams ) returns (MsgUpdateParamsResponse );
rpc StakeSupplier (MsgStakeSupplier ) returns (MsgStakeSupplierResponse );
rpc UnstakeSupplier (MsgUnstakeSupplier) returns (MsgUnstakeSupplierResponse);
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/supplier/MsgUpdateParams";
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "poktroll/x/supplier/MsgUpdateParams";

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

// TODO_IMPROVE(#322): The requirement to provide all params is adopted from the
// latest Cosmos SDK version. We should look into either improving this ourselves
// or seeing if it is on their roadmap.

// params defines the x/supplier parameters to update.
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true];
Expand All @@ -47,22 +43,37 @@ message MsgUpdateParamsResponse {}

message MsgStakeSupplier {
option (cosmos.msg.v1.signer) = "signer"; // https://docs.cosmos.network/main/build/building-modules/messages-and-queries

string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message signer (i.e. owner or operator)
string owner_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the owner (i.e. custodial, staker)
string operator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial)
cosmos.base.v1beta1.Coin stake = 4; // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any)
repeated poktroll.shared.SupplierServiceConfig services = 5; // The list of services this supplier is staked to provide service for
string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message signer (i.e. owner or operator)
string owner_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the owner (i.e. custodial, staker)
string operator_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial)
cosmos.base.v1beta1.Coin stake = 4; // The total amount of uPOKT the supplier has staked. Must be ≥ to the current amount that the supplier has staked (if any)
repeated poktroll.shared.SupplierServiceConfig services = 5; // The list of services this supplier is staked to provide service for
}

message MsgStakeSupplierResponse {}

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

string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message signer (i.e. owner or operator)
string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the message signer (i.e. owner or operator)
string operator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; // The Bech32 address of the operator (i.e. provider, non-custodial)
}

message MsgUnstakeSupplierResponse {}

// 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 asType {
cosmos.base.v1beta1.Coin as_coin = 3;
}
}

message MsgUpdateParamResponse {
Params params = 1;
}

8 changes: 4 additions & 4 deletions proto/poktroll/tokenomics/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ message EventClaimExpired {
// Number of estimated compute units claimed as a function of the number of claimed
// compute units and the relay difficulty multiplier for the particular service.
uint64 num_estimated_compute_units = 5 [(gogoproto.jsontag) = "num_estimated_compute_units"];
// The amount of uPOKT claimed to be rewarded for the work done as a function of
// The uPOKT coin claimed to be rewarded for the work done as a function of
// the number of estimated compute units and the compute uints to token multiplier.
cosmos.base.v1beta1.Coin claimed_amount_upokt = 6 [(gogoproto.jsontag) = "claimed_amount_upokt"];
cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
}

// EventClaimSettled is an event emitted whenever a claim is settled.
Expand All @@ -48,9 +48,9 @@ message EventClaimSettled {
// Number of estimated compute units claimed as a function of the number of claimed
// compute units and the relay difficulty multiplier for the particular service.
uint64 num_estimated_compute_units = 5 [(gogoproto.jsontag) = "num_estimated_compute_units"];
// The amount of uPOKT claimed to be rewarded for the work done as a function of
// The uPOKT coin claimed to be rewarded for the work done as a function of
// the number of estimated compute units and the compute uints to token multiplier.
cosmos.base.v1beta1.Coin claimed_amount_upokt = 6 [(gogoproto.jsontag) = "claimed_amount_upokt"];
cosmos.base.v1beta1.Coin claimed_upokt = 6 [(gogoproto.jsontag) = "claimed_upokt"];
}

// EventApplicationOverserviced is emitted when an application has less stake than
Expand Down
54 changes: 54 additions & 0 deletions scripts/copy-poktroll-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/sh

set -e

DIR="$(dirname "$0")"
if [ ! -d "$DIR" ]; then
DIR="$PWD"
fi

. ${DIR}/shared.sh

if ! command -v ignite >/dev/null 2>&1; then
error_log "Ignite is not installed. Please install it at: https://docs.ignite.com/welcome/install."
exit 1
fi

default_branch="main"
branch=${1:-$default_branch}

rm -rf poktroll
info_log "Poktroll github repository is going to be clone..."
git clone https://github.com/pokt-network/poktroll.git
{
info_log "Poktroll github repository is cloned..."
cd poktroll

if [ "$branch" != "$default_branch" ]; then
info_log "Poktroll github repository is going to be checkout to $branch branch..."
git checkout $branch
fi

info_log "TypeScript client files will be generated..."
echo "Y" | ignite generate ts-client --yes --use-cache

info_log "TypeScript client files were generated. Now copying them to the project..."
cd ..
rm -rf ${DIR}/../src/client
mkdir -p ${DIR}/../src/client

# Here we are copying the files from poktroll.application because every directory copied has the types directory with the same files inside.
cp -TR poktroll/ts-client/poktroll.application/types ${DIR}/../src/client
rm -f ${DIR}/../src/client/route-name.eta

info_log "TypeScript client files were copied. Now copying proto files..."

rm -rf ${DIR}/../proto/poktroll
mkdir -p ${DIR}/../proto/poktroll
cp -TR poktroll/proto/poktroll/ ${DIR}/../proto/poktroll
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#PUC

git add ${DIR}/../proto/poktroll

info_log "Proto files were copied."
rm -rf poktroll
info_log "Poktroll folder cloned from github was deleted."
} || rm -rf poktroll
9 changes: 9 additions & 0 deletions src/client/amino/amino.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading