Skip to content

Commit

Permalink
Merge remote-tracking branch 'pokt/main' into issues/799/e2e/param-he…
Browse files Browse the repository at this point in the history
…lpers

* pokt/main:
  [Code Health] refactor: rename `ApplicationTransfer` msgs (#788)
  [Docs] Add operations documentation about proof submission fee (#806)
  • Loading branch information
bryanchriswhite committed Sep 23, 2024
2 parents 4808996 + 1cf73ca commit 730d19f
Show file tree
Hide file tree
Showing 15 changed files with 502 additions and 424 deletions.
493 changes: 246 additions & 247 deletions api/poktroll/application/tx.pulsar.go

Large diffs are not rendered by default.

40 changes: 20 additions & 20 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.

:::
2 changes: 1 addition & 1 deletion e2e/tests/stake_app_transfer.feature
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Feature: App Stake Transfer Namespace
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 "TransferApplicationStake" message to be submitted
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
Expand Down
6 changes: 3 additions & 3 deletions proto/poktroll/application/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ service Msg {
rpc UnstakeApplication (MsgUnstakeApplication) returns (MsgUnstakeApplicationResponse);
rpc DelegateToGateway (MsgDelegateToGateway) returns (MsgDelegateToGatewayResponse);
rpc UndelegateFromGateway (MsgUndelegateFromGateway) returns (MsgUndelegateFromGatewayResponse);
rpc TransferApplicationStake (MsgTransferApplicationStake) returns (MsgTransferApplicationStakeResponse);
rpc TransferApplication (MsgTransferApplication) returns (MsgTransferApplicationResponse);
}
// MsgUpdateParams is the Msg/UpdateParams request type.
message MsgUpdateParams {
Expand Down Expand Up @@ -83,13 +83,13 @@ message MsgUndelegateFromGateway {

message MsgUndelegateFromGatewayResponse {}

message MsgTransferApplicationStake {
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 MsgTransferApplicationStakeResponse {
message MsgTransferApplicationResponse {
poktroll.application.Application application = 1;
}

10 changes: 5 additions & 5 deletions x/application/keeper/msg_server_transfer_application_stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import (
"github.com/pokt-network/poktroll/x/application/types"
)

// TransferApplicationStake transfers the stake (held in escrow in the application
// TransferApplication transfers the stake (held in escrow in the application
// module account) from a source to a (new) destination application account .
func (k msgServer) TransferApplicationStake(ctx context.Context, msg *types.MsgTransferApplicationStake) (*types.MsgTransferApplicationStakeResponse, error) {
func (k msgServer) TransferApplication(ctx context.Context, msg *types.MsgTransferApplication) (*types.MsgTransferApplicationResponse, error) {
isSuccessful := false
defer telemetry.EventSuccessCounter(
"transfer_application_stake",
telemetry.DefaultCounterFn,
func() bool { return isSuccessful },
)

logger := k.Logger().With("method", "TransferApplicationStake")
logger := k.Logger().With("method", "TransferApplication")

if err := msg.ValidateBasic(); err != nil {
return nil, err
Expand Down Expand Up @@ -62,7 +62,7 @@ func (k msgServer) TransferApplicationStake(ctx context.Context, msg *types.MsgT

isSuccessful = true

return &types.MsgTransferApplicationStakeResponse{
Application: &dstApp,
return &types.MsgTransferApplicationResponse{
Application: &srcApp,
}, nil
}
20 changes: 10 additions & 10 deletions x/application/keeper/msg_server_transfer_application_stake_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
)

func TestMsgServer_TransferApplicationStake_Success(t *testing.T) {
func TestMsgServer_TransferApplication_Success(t *testing.T) {
k, ctx := keepertest.ApplicationKeeper(t)
srv := appkeeper.NewMsgServerImpl(k)

Expand Down Expand Up @@ -52,29 +52,29 @@ func TestMsgServer_TransferApplicationStake_Success(t *testing.T) {
require.Equal(t, "svc1", srcApp.ServiceConfigs[0].ServiceId)

// Transfer the application stake from the source to the destination application address.
transferStakeMsg := apptypes.NewMsgTransferApplicationStake(srcAddr, dstAddr)
transferStakeMsg := apptypes.NewMsgTransferApplication(srcAddr, dstAddr)

transferAppStakeRes, stakeTransferErr := srv.TransferApplicationStake(ctx, transferStakeMsg)
transferAppStakeRes, stakeTransferErr := srv.TransferApplication(ctx, transferStakeMsg)
require.NoError(t, stakeTransferErr)

// Verify that the destination app was created with the correct state.
srcApp, isSrcFound = k.GetApplication(ctx, dstAddr)
require.True(t, isSrcFound)

dstApp, isDstFound := k.GetApplication(ctx, dstAddr)
require.True(t, isDstFound)
require.Equal(t, dstAddr, dstApp.Address)
require.Equal(t, expectedAppStake, dstApp.Stake)
require.Len(t, dstApp.ServiceConfigs, 1)
require.EqualValues(t, &srcApp, transferAppStakeRes.Application)

srcApp.Address = ""
dstApp.Address = ""
require.EqualValues(t, srcApp, dstApp)
require.EqualValues(t, &dstApp, transferAppStakeRes.Application)

// Verify that the source app was unstaked.
srcApp, isSrcFound = k.GetApplication(ctx, srcAddr)
require.False(t, isSrcFound)
}

func TestMsgServer_TransferApplicationStake_Error_DestinationExists(t *testing.T) {
func TestMsgServer_TransferApplication_Error_DestinationExists(t *testing.T) {
k, ctx := keepertest.ApplicationKeeper(t)
srv := appkeeper.NewMsgServerImpl(k)

Expand Down Expand Up @@ -120,9 +120,9 @@ func TestMsgServer_TransferApplicationStake_Error_DestinationExists(t *testing.T
require.NoError(t, err)

// Attempt to transfer the source application stake to the destination.
transferStakeMsg := apptypes.NewMsgTransferApplicationStake(srcAddr, dstAddr)
transferStakeMsg := apptypes.NewMsgTransferApplication(srcAddr, dstAddr)

_, err = srv.TransferApplicationStake(ctx, transferStakeMsg)
_, err = srv.TransferApplication(ctx, transferStakeMsg)
require.ErrorContains(t, err, apptypes.ErrAppDuplicateAddress.Wrapf("destination application (%q) exists", dstAddr).Error())

// Verify that the original application still exists.
Expand Down
4 changes: 2 additions & 2 deletions x/application/module/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
// PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "gateway_address"}},
// },
{
RpcMethod: "TransferApplicationStake",
RpcMethod: "TransferApplication",
Use: "transfer [source app address] [destination app address]",
Short: "Transfer the application stake from [source app address] to [destination app address] and unstake the source application",
Short: "Transfer the application from [source app address] to [destination app address] and remove the source application",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "source_address"}, {ProtoField: "destination_address"}},
},
// this line is used by ignite scaffolding # autocli/tx
Expand Down
20 changes: 10 additions & 10 deletions x/application/module/simulation.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ const (
// TODO: Determine the simulation weight value
defaultWeightMsgUndelegateFromGateway int = 100

opWeightMsgTransferApplicationStake = "op_weight_msg_transfer_application_stake"
opWeightMsgTransferApplication = "op_weight_msg_transfer_application"
// TODO: Determine the simulation weight value
defaultWeightMsgTransferApplicationStake int = 100
defaultWeightMsgTransferApplication int = 100

// this line is used by starport scaffolding # simapp/module/const
)
Expand Down Expand Up @@ -115,15 +115,15 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
applicationsimulation.SimulateMsgUndelegateFromGateway(am.accountKeeper, am.bankKeeper, am.applicationKeeper),
))

var weightMsgTransferApplicationStake int
simState.AppParams.GetOrGenerate(opWeightMsgTransferApplicationStake, &weightMsgTransferApplicationStake, nil,
var weightMsgTransferApplication int
simState.AppParams.GetOrGenerate(opWeightMsgTransferApplication, &weightMsgTransferApplication, nil,
func(_ *rand.Rand) {
weightMsgTransferApplicationStake = defaultWeightMsgTransferApplicationStake
weightMsgTransferApplication = defaultWeightMsgTransferApplication
},
)
operations = append(operations, simulation.NewWeightedOperation(
weightMsgTransferApplicationStake,
applicationsimulation.SimulateMsgTransferApplicationStake(am.accountKeeper, am.bankKeeper, am.applicationKeeper),
weightMsgTransferApplication,
applicationsimulation.SimulateMsgTransferApplication(am.accountKeeper, am.bankKeeper, am.applicationKeeper),
))

// this line is used by starport scaffolding # simapp/module/operation
Expand Down Expand Up @@ -167,10 +167,10 @@ func (am AppModule) ProposalMsgs(simState module.SimulationState) []simtypes.Wei
},
),
simulation.NewWeightedProposalMsg(
opWeightMsgTransferApplicationStake,
defaultWeightMsgTransferApplicationStake,
opWeightMsgTransferApplication,
defaultWeightMsgTransferApplication,
func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) sdk.Msg {
applicationsimulation.SimulateMsgTransferApplicationStake(am.accountKeeper, am.bankKeeper, am.applicationKeeper)
applicationsimulation.SimulateMsgTransferApplication(am.accountKeeper, am.bankKeeper, am.applicationKeeper)
return nil
},
),
Expand Down
Loading

0 comments on commit 730d19f

Please sign in to comment.