Skip to content

Commit

Permalink
Merge branch 'refactor/testutil/filter-events' into issues/858/events…
Browse files Browse the repository at this point in the history
…/application

* refactor/testutil/filter-events:
  chore: rename testevents import
  refactor: simplify testevents.FilterEvents()
  [Code Health] refactor: share helpers to consolidate avoid dependency cycles (#855)
  [Tooling, Docs] Refactor params docs generation command & update params docs (#864)
  [On-Chain] Refactor `uint64` type individual param update logic (#863)
  [Service] Refresh service module params logic (#861)
  [Proof] Refresh proof module params logic (#851)
  [Shared] Refresh shared module params logic (#852)
  • Loading branch information
bryanchriswhite committed Oct 15, 2024
2 parents f5ba559 + e8d0bd3 commit 0925d58
Show file tree
Hide file tree
Showing 90 changed files with 1,410 additions and 1,517 deletions.
224 changes: 113 additions & 111 deletions api/poktroll/application/tx.pulsar.go

Large diffs are not rendered by default.

350 changes: 86 additions & 264 deletions api/poktroll/proof/tx.pulsar.go

Large diffs are not rendered by default.

152 changes: 76 additions & 76 deletions api/poktroll/shared/tx.pulsar.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api/poktroll/supplier/tx.pulsar.go

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

29 changes: 18 additions & 11 deletions docusaurus/docs/protocol/governance/params.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,21 @@ Please follow the instructions in [this guide](../../develop/developer_guide/add

|Module | Field Type | Field Name |Comment |
|-------|------------|------------|--------|
| `application` | `uint64 ` | `max_delegated_gateways` | max_delegated_gateways defines the maximum number of gateways that a single application can delegate to. This is used to prevent performance issues in case the relay ring signature becomes too large. |
| `proof ` | `float ` | `proof_request_probability` | proof_request_probability is the probability of a session requiring a proof if it's cost (i.e. compute unit consumption) is below the ProofRequirementThreshold. |
| `shared ` | `uint64 ` | `num_blocks_per_session` | num_blocks_per_session is the number of blocks between the session start & end heights. |
| `shared ` | `uint64 ` | `grace_period_end_offset_blocks` | grace_period_end_offset_blocks is the number of blocks, after the session end height, during which the supplier can still service payable relays. Suppliers will need to recreate a claim for the previous session (if already created) to get paid for the additional relays. |
| `shared ` | `uint64 ` | `claim_window_open_offset_blocks` | claim_window_open_offset_blocks is the number of blocks after the session grace period height, at which the claim window opens. |
| `shared ` | `uint64 ` | `claim_window_close_offset_blocks` | claim_window_close_offset_blocks is the number of blocks after the claim window open height, at which the claim window closes. |
| `shared ` | `uint64 ` | `proof_window_open_offset_blocks` | proof_window_open_offset_blocks is the number of blocks after the claim window close height, at which the proof window opens. |
| `shared ` | `uint64 ` | `proof_window_close_offset_blocks` | proof_window_close_offset_blocks is the number of blocks after the proof window open height, at which the proof window closes. |
| `shared ` | `uint64 ` | `supplier_unbonding_period_sessions` | supplier_unbonding_period_sessions is the number of sessions that a supplier must wait after unstaking before their staked assets are moved to their account balance. On-chain business logic requires, and ensures, that the corresponding block count of the unbonding period will exceed the end of any active claim & proof lifecycles. |
| `shared ` | `uint64 ` | `application_unbonding_period_sessions` | application_unbonding_period_sessions is the number of sessions that an application must wait after unstaking before their staked assets are moved to their account balance. 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. |
| `shared ` | `uint64 ` | `compute_units_to_tokens_multiplier` | 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. |
| `application` | `uint64` | `max_delegated_gateways` | max_delegated_gateways defines the maximum number of gateways that a single application can delegate to. This is used to prevent performance issues in case the relay ring signature becomes too large. |
| `application` | `cosmos.base.v1beta1.Coin` | `min_stake` | min_stake is the minimum stake in upokt that an application must have to remain staked. |
| `gateway` | `cosmos.base.v1beta1.Coin` | `min_stake` | min_stake is the minimum amount of uPOKT that a gateway must stake. |
| `proof` | `cosmos.base.v1beta1.Coin` | `proof_missing_penalty` | 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`. |
| `proof` | `float` | `proof_request_probability` | proof_request_probability is the probability of a session requiring a proof if it's cost (i.e. compute unit consumption) is below the ProofRequirementThreshold. |
| `proof` | `cosmos.base.v1beta1.Coin` | `proof_requirement_threshold` | proof_requirement_threshold is the session cost (i.e. compute unit consumption) threshold which asserts that a session MUST have a corresponding proof when its cost 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_upokt`. |
| `proof` | `cosmos.base.v1beta1.Coin` | `proof_submission_fee` | 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`. |
| `service` | `cosmos.base.v1beta1.Coin` | `add_service_fee` | 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. |
| `shared` | `uint64` | `application_unbonding_period_sessions` | application_unbonding_period_sessions is the number of sessions that an application must wait after unstaking before their staked assets are moved to their account balance. 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. |
| `shared` | `uint64` | `claim_window_close_offset_blocks` | claim_window_close_offset_blocks is the number of blocks after the claim window open height, at which the claim window closes. |
| `shared` | `uint64` | `claim_window_open_offset_blocks` | claim_window_open_offset_blocks is the number of blocks after the session grace period height, at which the claim window opens. |
| `shared` | `uint64` | `compute_units_to_tokens_multiplier` | 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. |
| `shared` | `uint64` | `grace_period_end_offset_blocks` | grace_period_end_offset_blocks is the number of blocks, after the session end height, during which the supplier can still service payable relays. Suppliers will need to recreate a claim for the previous session (if already created) to get paid for the additional relays. |
| `shared` | `uint64` | `num_blocks_per_session` | num_blocks_per_session is the number of blocks between the session start & end heights. |
| `shared` | `uint64` | `proof_window_close_offset_blocks` | proof_window_close_offset_blocks is the number of blocks after the proof window open height, at which the proof window closes. |
| `shared` | `uint64` | `proof_window_open_offset_blocks` | proof_window_open_offset_blocks is the number of blocks after the claim window close height, at which the proof window opens. |
| `shared` | `uint64` | `supplier_unbonding_period_sessions` | supplier_unbonding_period_sessions is the number of sessions that a supplier must wait after unstaking before their staked assets are moved to their account balance. On-chain business logic requires, and ensures, that the corresponding block count of the unbonding period will exceed the end of any active claim & proof lifecycles. |
| `supplier` | `cosmos.base.v1beta1.Coin` | `min_stake` | min_stake is the minimum amount of uPOKT that a supplier must stake to be included in network sessions and remain staked. |
3 changes: 1 addition & 2 deletions e2e/tests/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
prooftypes "github.com/pokt-network/poktroll/x/proof/types"
servicetypes "github.com/pokt-network/poktroll/x/service/types"
sessiontypes "github.com/pokt-network/poktroll/x/session/types"
"github.com/pokt-network/poktroll/x/shared"
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
suppliertypes "github.com/pokt-network/poktroll/x/supplier/types"
)
Expand Down Expand Up @@ -781,7 +780,7 @@ func (s *suite) getSupplierUnbondingHeight(accName string) int64 {
responseBz := []byte(strings.TrimSpace(res.Stdout))
s.cdc.MustUnmarshalJSON(responseBz, &resp)

return shared.GetSupplierUnbondingHeight(&resp.Params, supplier)
return sharedtypes.GetSupplierUnbondingHeight(&resp.Params, supplier)
}

// getApplicationInfo returns the application information for a given application address.
Expand Down
22 changes: 3 additions & 19 deletions e2e/tests/parse_params_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,6 @@ func (s *suite) newTokenomicsMsgUpdateParam(authority string, param paramAny) (m

func (s *suite) newProofMsgUpdateParam(authority string, param paramAny) (msg proto.Message) {
switch param.typeStr {
case "string":
msg = proto.Message(&prooftypes.MsgUpdateParam{
Authority: authority,
Name: param.name,
AsType: &prooftypes.MsgUpdateParam_AsString{
AsString: param.value.(string),
},
})
case "int64":
msg = proto.Message(&prooftypes.MsgUpdateParam{
Authority: authority,
Name: param.name,
AsType: &prooftypes.MsgUpdateParam_AsInt64{
AsInt64: param.value.(int64),
},
})
case "bytes":
msg = proto.Message(&prooftypes.MsgUpdateParam{
Authority: authority,
Expand Down Expand Up @@ -347,12 +331,12 @@ func (s *suite) newSharedMsgUpdateParam(authority string, param paramAny) (msg p
AsString: param.value.(string),
},
})
case "int64":
case "uint64":
msg = proto.Message(&sharedtypes.MsgUpdateParam{
Authority: authority,
Name: param.name,
AsType: &sharedtypes.MsgUpdateParam_AsInt64{
AsInt64: param.value.(int64),
AsType: &sharedtypes.MsgUpdateParam_AsUint64{
AsUint64: param.value.(uint64),
},
})
case "bytes":
Expand Down
5 changes: 2 additions & 3 deletions load-testing/tests/relays_stress_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import (
"github.com/pokt-network/poktroll/testutil/testclient/testeventsquery"
apptypes "github.com/pokt-network/poktroll/x/application/types"
gatewaytypes "github.com/pokt-network/poktroll/x/gateway/types"
"github.com/pokt-network/poktroll/x/shared"
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
suppliertypes "github.com/pokt-network/poktroll/x/supplier/types"
)
Expand Down Expand Up @@ -379,9 +378,9 @@ func (plans *actorLoadTestIncrementPlans) totalDurationBlocks(
// The last block of the last session SHOULD align with the last block of the
// last increment duration (i.e. **after** maxActorCount actors are activated).
blocksToFinalSessionEnd := plans.maxActorBlocksToFinalIncrementEnd()
finalSessionEndHeight := shared.GetSessionEndHeight(sharedParams, currentHeight+blocksToFinalSessionEnd)
finalSessionEndHeight := sharedtypes.GetSessionEndHeight(sharedParams, currentHeight+blocksToFinalSessionEnd)

return shared.GetProofWindowCloseHeight(sharedParams, finalSessionEndHeight) - currentHeight
return sharedtypes.GetProofWindowCloseHeight(sharedParams, finalSessionEndHeight) - currentHeight
}

// blocksToFinalIncrementStart returns the number of blocks that will have
Expand Down
15 changes: 7 additions & 8 deletions pkg/client/query/sharedquerier.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/cosmos/gogoproto/grpc"

"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/x/shared"
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
)

Expand Down Expand Up @@ -71,7 +70,7 @@ func (sq *sharedQuerier) GetClaimWindowOpenHeight(ctx context.Context, queryHeig
if err != nil {
return 0, err
}
return shared.GetClaimWindowOpenHeight(sharedParams, queryHeight), nil
return sharedtypes.GetClaimWindowOpenHeight(sharedParams, queryHeight), nil
}

// GetProofWindowOpenHeight returns the block height at which the proof window of
Expand All @@ -87,7 +86,7 @@ func (sq *sharedQuerier) GetProofWindowOpenHeight(ctx context.Context, queryHeig
if err != nil {
return 0, err
}
return shared.GetProofWindowOpenHeight(sharedParams, queryHeight), nil
return sharedtypes.GetProofWindowOpenHeight(sharedParams, queryHeight), nil
}

// GetSessionGracePeriodEndHeight returns the block height at which the grace period
Expand All @@ -108,7 +107,7 @@ func (sq *sharedQuerier) GetSessionGracePeriodEndHeight(
if err != nil {
return 0, err
}
return shared.GetSessionGracePeriodEndHeight(sharedParams, queryHeight), nil
return sharedtypes.GetSessionGracePeriodEndHeight(sharedParams, queryHeight), nil
}

// GetEarliestSupplierClaimCommitHeight returns the earliest block height at which a claim
Expand All @@ -127,7 +126,7 @@ func (sq *sharedQuerier) GetEarliestSupplierClaimCommitHeight(ctx context.Contex

// Fetch the block at the proof window open height. Its hash is used as part
// of the seed to the pseudo-random number generator.
claimWindowOpenHeight := shared.GetClaimWindowOpenHeight(sharedParams, queryHeight)
claimWindowOpenHeight := sharedtypes.GetClaimWindowOpenHeight(sharedParams, queryHeight)
claimWindowOpenBlock, err := sq.blockQuerier.Block(ctx, &claimWindowOpenHeight)
if err != nil {
return 0, err
Expand All @@ -136,7 +135,7 @@ func (sq *sharedQuerier) GetEarliestSupplierClaimCommitHeight(ctx context.Contex
// NB: Byte slice representation of block hashes don't need to be normalized.
claimWindowOpenBlockHash := claimWindowOpenBlock.BlockID.Hash.Bytes()

return shared.GetEarliestSupplierClaimCommitHeight(
return sharedtypes.GetEarliestSupplierClaimCommitHeight(
sharedParams,
queryHeight,
claimWindowOpenBlockHash,
Expand All @@ -160,13 +159,13 @@ func (sq *sharedQuerier) GetEarliestSupplierProofCommitHeight(ctx context.Contex

// Fetch the block at the proof window open height. Its hash is used as part
// of the seed to the pseudo-random number generator.
proofWindowOpenHeight := shared.GetProofWindowOpenHeight(sharedParams, queryHeight)
proofWindowOpenHeight := sharedtypes.GetProofWindowOpenHeight(sharedParams, queryHeight)
proofWindowOpenBlock, err := sq.blockQuerier.Block(ctx, &proofWindowOpenHeight)
if err != nil {
return 0, err
}

return shared.GetEarliestSupplierProofCommitHeight(
return sharedtypes.GetEarliestSupplierProofCommitHeight(
sharedParams,
queryHeight,
proofWindowOpenBlock.BlockID.Hash,
Expand Down
3 changes: 1 addition & 2 deletions pkg/crypto/rings/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/pokt-network/poktroll/pkg/polylog"
apptypes "github.com/pokt-network/poktroll/x/application/types"
"github.com/pokt-network/poktroll/x/service/types"
"github.com/pokt-network/poktroll/x/shared"
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
)

Expand Down Expand Up @@ -294,7 +293,7 @@ func GetRingAddressesAtBlock(
blockHeight int64,
) []string {
// Get the target session end height at which we want to get the active delegations.
targetSessionEndHeight := uint64(shared.GetSessionEndHeight(sharedParams, blockHeight))
targetSessionEndHeight := uint64(sharedtypes.GetSessionEndHeight(sharedParams, blockHeight))

return GetRingAddressesAtSessionEndHeight(app, targetSessionEndHeight)
}
Expand Down
7 changes: 3 additions & 4 deletions pkg/relayer/proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/pokt-network/poktroll/pkg/relayer/config"
"github.com/pokt-network/poktroll/pkg/relayer/proxy"
"github.com/pokt-network/poktroll/testutil/testproxy"
"github.com/pokt-network/poktroll/x/shared"
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
)

Expand Down Expand Up @@ -356,17 +355,17 @@ func TestRelayerProxy_Relays(t *testing.T) {

sharedParams := sharedtypes.DefaultParams()

sessionTwoStartHeight := shared.GetSessionEndHeight(&sharedParams, blockHeight) + 1
sessionTwoStartHeight := sharedtypes.GetSessionEndHeight(&sharedParams, blockHeight) + 1

// blockOutsideSessionGracePeriod is the block height that is after the first
// session's grace period and within the second session's grace period,
// meaning a relay should be handled as part of the session two AND NOT session one.
blockOutsideSessionGracePeriod := shared.GetSessionGracePeriodEndHeight(&sharedParams, sessionTwoStartHeight)
blockOutsideSessionGracePeriod := sharedtypes.GetSessionGracePeriodEndHeight(&sharedParams, sessionTwoStartHeight)

// blockWithinSessionGracePeriod is the block height that is after the first
// session but within its session's grace period, meaning a relay should be
// handled at this block height.
blockWithinSessionGracePeriod := shared.GetSessionGracePeriodEndHeight(&sharedParams, blockHeight) - 1
blockWithinSessionGracePeriod := sharedtypes.GetSessionGracePeriodEndHeight(&sharedParams, blockHeight) - 1

tests := []struct {
desc string
Expand Down
10 changes: 5 additions & 5 deletions pkg/relayer/proxy/relay_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package proxy
import (
"context"

"github.com/pokt-network/poktroll/x/service/types"
"github.com/pokt-network/poktroll/x/shared"
servicetypes "github.com/pokt-network/poktroll/x/service/types"
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
)

// VerifyRelayRequest is a shared method used by RelayServers to check the relay
// request signature and session validity.
func (rp *relayerProxy) VerifyRelayRequest(
ctx context.Context,
relayRequest *types.RelayRequest,
relayRequest *servicetypes.RelayRequest,
supplierServiceId string,
) error {
// Get the block height at which the relayRequest should be processed.
Expand Down Expand Up @@ -97,7 +97,7 @@ func (rp *relayerProxy) VerifyRelayRequest(
// If the session has expired, then return an error.
func (rp *relayerProxy) getTargetSessionBlockHeight(
ctx context.Context,
relayRequest *types.RelayRequest,
relayRequest *servicetypes.RelayRequest,
) (sessionHeight int64, err error) {
currentHeight := rp.blockClient.LastBlock(ctx).Height()
sessionEndHeight := relayRequest.Meta.SessionHeader.GetSessionEndBlockHeight()
Expand All @@ -116,7 +116,7 @@ func (rp *relayerProxy) getTargetSessionBlockHeight(
if sessionEndHeight < currentHeight {
// Do not process the `RelayRequest` if the session has expired and the current
// block height is outside the session's grace period.
if !shared.IsGracePeriodElapsed(sharedParams, sessionEndHeight, currentHeight) {
if !sharedtypes.IsGracePeriodElapsed(sharedParams, sessionEndHeight, currentHeight) {
// The RelayRequest's session has expired but is still within the
// grace period so process it as if the session is still active.
return sessionEndHeight, nil
Expand Down
Loading

0 comments on commit 0925d58

Please sign in to comment.