Skip to content

Commit

Permalink
Merge branch 'issues/799/merge/integration-app_x_sup-stake-evts' into…
Browse files Browse the repository at this point in the history
… issues/799/tests/params

* issues/799/merge/integration-app_x_sup-stake-evts:
  fix: add missing steps and update module name for moved param
  [Code Health] refactor: rename `ApplicationTransfer` msgs (#788)
  [Docs] Add operations documentation about proof submission fee (#806)
  [Testing] Fix non-idempotency in (and speed up) supplier staking tests (#815)
  [Application] feat: app stake transfer (#743)
  Empty commit
  chore: review feedback improvements
  • Loading branch information
bryanchriswhite committed Sep 23, 2024
2 parents 9ced306 + d4d0014 commit 43e5737
Show file tree
Hide file tree
Showing 22 changed files with 2,254 additions and 185 deletions.
1,298 changes: 1,177 additions & 121 deletions api/poktroll/application/tx.pulsar.go

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions api/poktroll/application/tx_grpc.pb.go

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

82 changes: 80 additions & 2 deletions docusaurus/docs/operate/configs/relayminer_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ You can find a fully featured example configuration at [relayminer_config_full_e
- [Configuring Signing Keys](#configuring-signing-keys)
- [Example Configuration](#example-configuration)
- [Supported server types](#supported-server-types)
- [Payable Proof Submissions](#payable-proof-submissions)
- [Overview](#overview)
- [Key Requirements for Operators](#key-requirements-for-operators)
- [Recommendations for Supplier Operators](#recommendations-for-supplier-operators)

## Introduction

Expand Down Expand Up @@ -115,8 +119,9 @@ smt_store_path: <string>
_`Required`_ if `suppliers.*.signing_key_names` is not specified.

This configuration option specifies a list of key names from the keyring that the
`RelayMiner` will use to sign transactions. These key names are used to derive the public
key and the corresponding address, which are essential for interacting with POKT.
`RelayMiner` will use to sign transactions (i.e. `SupplierOperator`).
These key names are used to derive the public key and the corresponding address,
which are essential for interacting with POKT.
Each key name listed here must be present in the keyring used to start the
`RelayMiner` instance.

Expand Down Expand Up @@ -451,3 +456,76 @@ flowchart
## Supported server types

The list of supported server types can be found at [pkg/relayer/config/types.go](https://github.com/pokt-network/poktroll/tree/main/pkg/relayer/config/types.go#L8)

## Payable Proof Submissions

### Overview

Submitting `Proofs` requires the payment of a fee, which is defined by the
`proof_submission_fee` governance parameter.

This fee mechanism is designed to prevent spam attacks (e.g., Sybil bloat attacks)
by discouraging invalid or unnecessary `Proofs`.

Since `Proofs` are the most block space-consuming primitive in the Pocket Network,
this fee plays a crucial role in maintaining the integrity of the network.

<!-- TODO_MAINNET(@red-0ne): Add a link to a block in our explorer showcasing this. -->

### Key Requirements for Operators

Due to the probabilistic nature of the `Proof` requirement, `Supplier` operators must
ensure that they maintain sufficient funds to cover the submission fees for all
`Proof`s associated with the `Claim`s they plan to submit.

Failure to maintain adequate funds can result in missed submissions, which can
result in `Supplier` slashing if the `Proof` is required.

### Recommendations for Supplier Operators

- **Sufficient Balance**: Operators should regularly check their account balance
and ensure they have enough funds to cover the submission fees for `Proofs`.

The following command can be used to check the balance of a `Supplier` operator:
```bash
poktrolld query bank balance <supplier_operator_address> upokt --node https://shannon-testnet-grove-seed-rpc.poktroll.com
```
Which output would look like:
```yaml
balance:
amount: "109999000"
denom: upokt
```
- **Automated Monitoring**: It is highly recommended to implement balance monitoring
or alert systems to avoid running out of funds during critical periods.
<!-- TODO_POST_MAINNET(@okdas): Link to example alerts & infrastructure others can use. -->
- **Cost Awareness**: Operators should familiarize themselves with the current
`proof_submission_fee` and plan their funding accordingly, especially if they
anticipate submitting a higher volume of `Proofs`.

The following command can be used to check the current `proof_submission_fee`:
```bash
poktrolld query proof params --node https://shannon-testnet-grove-seed-rpc.poktroll.com
```
Which output would look like:
```yaml
proof_submission_fee:
amount: "1000000"
denom: upokt
```

The list of `Proof` governance parameters can be found at [proto/proof/params.proto](https://github.com/pokt-network/poktroll/blob/main/proto/poktroll/proof/params.proto)

:::warning

If you submit a claim but do not submit its corresponding proof, this could result in SLASHING!

Having insufficient funds could lead to rejected `Proof` submissions . This
can disrupt the operator’s participation in the Pocket Network. To maintain a
smooth operation, avoid being slashed, and earn your rewards, operators must plan
and manage their account balance as part of their operational procedures.

:::
5 changes: 2 additions & 3 deletions e2e/tests/0_settlement.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ Feature: Tokenomics Namespace
| proof_missing_penalty | 320 | coin |
| proof_submission_fee | 1000000 | coin |
And all "proof" module params should be updated
# TODO_IN_THIS_COMMIT: param moved to shared module?
And the "tokenomics" module parameters are set as follows
And the "shared" module parameters are set as follows
| compute_units_to_tokens_multiplier | 42 | int64 |
# TODO_IN_THIS_COMMIT: all module params should be updated
And all "shared" module params should be updated
When the supplier "supplier1" has serviced a session with "20" relays for service "anvil" for application "app1"
# Wait for the Claim & Proof lifecycle
And the user should wait for the "proof" module "CreateClaim" Message to be submitted
Expand Down
5 changes: 2 additions & 3 deletions e2e/tests/session.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ Feature: Session Namespace
| proof_missing_penalty | 320 | coin |
| proof_submission_fee | 1000000 | coin |
And all "proof" module params should be updated
# TODO_IN_THIS_COMMIT: param moved to shared module?
And the "tokenomics" module parameters are set as follows
And the "shared" module parameters are set as follows
| compute_units_to_tokens_multiplier | 42 | int64 |
# TODO_IN_THIS_COMMIT: all module params should be updated
And all "shared" module params should be updated
When the supplier "supplier1" has serviced a session with "5" relays for service "anvil" for application "app1"
And the user should wait for the "proof" module "CreateClaim" Message to be submitted
And the user should wait for the "proof" module "ClaimCreated" tx event to be broadcast
Expand Down
21 changes: 21 additions & 0 deletions e2e/tests/stake_app_transfer.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Feature: App Stake Transfer Namespace

Scenario: User can transfer Application stake to non-existing application address
Given the user has the pocketd binary installed
# Unstake the applications in case they're already staked.
And this test ensures the "application" for account "app2" is not staked
And this test ensures the "application" for account "app3" is not staked
# Stake with 1 uPOKT more than the current stake used in genesis to make
# the transaction succeed.
And the account "app2" has a balance greater than "1000070" uPOKT
And an account exists for "app3"
And the user successfully stakes a "application" with "1000070" uPOKT for "anvil" service from the account "app2"
When the user transfers the "application" stake from account "app2" to account "app3"
Then the user should be able to see standard output containing "txhash:"
And the user should be able to see standard output containing "code: 0"
And the pocketd binary should exit without error
And the user should wait for the "application" module "TransferApplication" message to be submitted
And the "application" for account "app3" is staked with "1000070" uPOKT
And the account balance of "app3" should be "0" uPOKT "less" than before
And the user verifies the "application" for account "app2" is not staked
And the account balance of "app2" should be "0" uPOKT "more" than before
51 changes: 51 additions & 0 deletions e2e/tests/stake_app_transfer_steps_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//go:build e2e

package e2e

import (
"github.com/stretchr/testify/require"
)

func (s *suite) TheUserSuccessfullyStakesAWithUpoktForServiceFromTheAccount(actorType string, amount int64, serviceId, accName string) {
s.TheUserStakesAWithUpoktForServiceFromTheAccount(actorType, amount, serviceId, accName)
s.TheUserShouldBeAbleToSeeStandardOutputContaining("txhash:")
s.TheUserShouldBeAbleToSeeStandardOutputContaining("code: 0")
s.ThePocketdBinaryShouldExitWithoutError()
s.TheUserShouldWaitForTheModuleMessageToBeSubmitted("application", "StakeApplication")
s.TheForAccountIsStakedWithUpokt(actorType, accName, amount)
s.TheAccountBalanceOfShouldBeUpoktThanBefore(accName, amount, "less")
}

func (s *suite) TheUserTransfersTheStakeFromAccountToAccount(actorType, fromAccName, toAccName string) {
fromAddr, fromAddrIsFound := accNameToAddrMap[fromAccName]
require.Truef(s, fromAddrIsFound, "account name %s not found in accNameToAddrMap", fromAccName)

toAddr, toAddrIsFound := accNameToAddrMap[toAccName]
require.Truef(s, toAddrIsFound, "account name %s not found in accNameToAddrMap", toAccName)

args := []string{
"tx",
actorType,
"transfer",
fromAddr,
toAddr,
"--from",
fromAccName,
keyRingFlag,
chainIdFlag,
"-y",
}
res, err := s.pocketd.RunCommandOnHost("", args...)
require.NoError(s, err)

s.pocketd.result = res
}

// This helper ensures that the actor is unstaked if it was staked when this step ran.
func (s *suite) ThisTestEnsuresTheForAccountIsNotStaked(actorType, accName string) {
if _, ok := s.getStakedAmount(actorType, accName); ok {
s.TheUserUnstakesAFromTheAccount(actorType, accName)
s.TheUserShouldBeAbleToSeeStandardOutputContaining("txhash:")
s.TheUserShouldBeAbleToSeeStandardOutputContaining("code: 0")
}
}
36 changes: 24 additions & 12 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,10 +50,12 @@ 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 {}
Expand All @@ -68,7 +71,6 @@ 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 {}
Expand All @@ -81,3 +83,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;
}

Loading

0 comments on commit 43e5737

Please sign in to comment.