Skip to content

Commit

Permalink
[Load Testing] fix: relay stress test duration calculation (#651)
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite authored Jul 3, 2024
1 parent 1bb1b85 commit 29c97d6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
17 changes: 9 additions & 8 deletions load-testing/tests/relays_stress_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ 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 @@ -212,7 +213,7 @@ func (s *relaysSuite) mapSessionInfoForLoadTestDurationFn(
// If the test duration is reached, stop sending requests
sendRelaysEndHeight := s.testStartHeight + s.relayLoadDurationBlocks
if blockHeight >= sendRelaysEndHeight {
testEndHeight := s.testStartHeight + s.testDurationBlocks
testEndHeight := s.testStartHeight + s.plans.totalDurationBlocks(s.sharedParams, blockHeight)

remainingRelayLoadBlocks := blockHeight - sendRelaysEndHeight
waitForSettlementBlocks := testEndHeight - sendRelaysEndHeight
Expand Down Expand Up @@ -371,16 +372,16 @@ func (plans *actorLoadTestIncrementPlans) validateMaxAmounts(t gocuke.TestingT)
// totalDurationBlocks returns the number of blocks which will have elapsed when the
// proof corresponding to the session in which the maxActorCount for the given actor
// has been committed.
func (plans *actorLoadTestIncrementPlans) totalDurationBlocks(sharedParams *sharedtypes.Params) int64 {
func (plans *actorLoadTestIncrementPlans) totalDurationBlocks(
sharedParams *sharedtypes.Params,
currentHeight int64,
) int64 {
// 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).
blocksToLastSessionEnd := plans.maxActorBlocksToFinalIncrementEnd()

blocksToLastProofWindowEnd := blocksToLastSessionEnd + int64(sharedParams.GetGracePeriodEndOffsetBlocks())
blocksToFinalSessionEnd := plans.maxActorBlocksToFinalIncrementEnd()
finalSessionEndHeight := shared.GetSessionEndHeight(sharedParams, currentHeight+blocksToFinalSessionEnd)

// Add one session length so that the duration is inclusive of the block which
// commits the last session's proof.
return blocksToLastProofWindowEnd + int64(sharedParams.GetNumBlocksPerSession())
return shared.GetProofWindowCloseHeight(sharedParams, finalSessionEndHeight) - currentHeight
}

// blocksToFinalIncrementStart returns the number of blocks that will have
Expand Down
23 changes: 8 additions & 15 deletions load-testing/tests/relays_stress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,9 @@ type relaysSuite struct {
// It is calculated as the longest duration of the three actor increments.
relayLoadDurationBlocks int64

// testDurationBlocks is the duration of the test in blocks and is used to determine
// when the test is done.
// It is calculated as the time it takes to send all relay requests plus the time
// it takes so submit all claims and proofs.
testDurationBlocks int64
// plans is the actor load test increment plans used to increment the actors during the test
// and calculate the test duration.
plans *actorLoadTestIncrementPlans

// gatewayUrls is a map of gatewayAddress->URL representing the provisioned gateways.
// These gateways are not staked yet but have their off-chain instance running
Expand Down Expand Up @@ -390,27 +388,22 @@ func (s *relaysSuite) TheFollowingInitialActorsAreStaked(table gocuke.DataTable)

func (s *relaysSuite) MoreActorsAreStakedAsFollows(table gocuke.DataTable) {
// Parse and validate the actor increment plans from the given step table.
plans := s.parseActorLoadTestIncrementPlans(table)
s.validateActorLoadTestIncrementPlans(plans)
s.plans = s.parseActorLoadTestIncrementPlans(table)
s.validateActorLoadTestIncrementPlans(s.plans)

// The relay load duration is the longest duration of the three actor increments.
// The duration of each actor is calculated as how many blocks it takes to
// increment the actor count to the maximum.
s.relayLoadDurationBlocks = plans.maxActorBlocksToFinalIncrementEnd()

// The test duration indicates when the test is complete.
// It is calculated as the relay load duration plus the time it takes to
// submit all claims and proofs.
s.testDurationBlocks = plans.totalDurationBlocks(s.sharedParams)
s.relayLoadDurationBlocks = s.plans.maxActorBlocksToFinalIncrementEnd()

if s.isEphemeralChain {
// Adjust the max delegations parameter to the max gateways to permit all
// applications to delegate to all gateways.
// This is to ensure that requests are distributed evenly across all gateways
// at any given time.
s.sendAdjustMaxDelegationsParamTx(plans.gateways.maxActorCount)
s.sendAdjustMaxDelegationsParamTx(s.plans.gateways.maxActorCount)
s.waitForTxsToBeCommitted()
s.ensureUpdatedMaxDelegations(plans.gateways.maxActorCount)
s.ensureUpdatedMaxDelegations(s.plans.gateways.maxActorCount)
}

// Fund all the provisioned suppliers and gateways since their addresses are
Expand Down

0 comments on commit 29c97d6

Please sign in to comment.