Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
14 changes: 12 additions & 2 deletions cmd/shannon.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@ import (
func getShannonFullNode(logger polylog.Logger, config *shannonconfig.ShannonGatewayConfig) (shannon.FullNode, error) {
fullNodeConfig := config.FullNodeConfig

// TODO_TECHDEBT(@adshmh): Refactor to find a better fit for load testing config handling.
//
// Load Testing against a RelayMiner:
// Restrict the allowed supplier
var allowedSupplierAddr string
if config.GatewayConfig.LoadTestingConfig != nil {
allowedSupplierAddr = config.GatewayConfig.LoadTestingConfig.GetAllowedSupplierAddr()
}

// TODO_MVP(@adshmh): rename the variables here once a more accurate name is selected for `LazyFullNode`
// LazyFullNode skips all caching and queries the onchain data for serving each relay request.
lazyFullNode, err := shannon.NewLazyFullNode(logger, fullNodeConfig)
lazyFullNode, err := shannon.NewLazyFullNode(logger, fullNodeConfig, allowedSupplierAddr)
if err != nil {
return nil, fmt.Errorf("failed to create Shannon lazy full node: %w", err)
}
Expand All @@ -27,7 +36,8 @@ func getShannonFullNode(logger polylog.Logger, config *shannonconfig.ShannonGate
return lazyFullNode, nil
}

fullNode, err := shannon.NewCachingFullNode(logger, lazyFullNode, fullNodeConfig.CacheConfig)
// TODO_TECHDEBT(@adshmh): Refactor to clarify the fullnode's config requirements (including owned apps).
fullNode, err := shannon.NewCachingFullNode(logger, lazyFullNode, fullNodeConfig.CacheConfig, config.GatewayConfig)
if err != nil {
return nil, fmt.Errorf("failed to create a Shannon caching full node instance: %w", err)
}
Expand Down
12 changes: 12 additions & 0 deletions protocol/shannon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,18 @@ func (fnc *FullNodeConfig) HydrateDefaults() {
}
}

func (ltc *LoadTestingConfig) GetAllowedSupplierAddr() string {
relayMinerConfig := ltc.RelayMinerConfig

// RelayMiner config not specified:
// No restrictions on supplier address.
if relayMinerConfig == nil {
return ""
}

return relayMinerConfig.SupplierAddr
}

func (ltc *LoadTestingConfig) Validate() error {
// Error: neither backend server nor RelayMiner config are specified.
if ltc.BackendServiceURL == nil && ltc.RelayMinerConfig == nil {
Expand Down
8 changes: 4 additions & 4 deletions protocol/shannon/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ type protocolEndpoint struct {
// the first app will be chosen. A randomization among the apps in this (unlikely) scenario
// may be needed.
// session is the active session corresponding to the app, of which the endpoint is a member.
session sessiontypes.Session
session *sessiontypes.Session
}

// IsFallback returns false for protocol endpoints.
Expand Down Expand Up @@ -165,7 +165,7 @@ func (e protocolEndpoint) WebsocketURL() (string, error) {

// Session returns a pointer to the session associated with the endpoint.
func (e protocolEndpoint) Session() *sessiontypes.Session {
return &e.session
return e.session
}

// Supplier returns the supplier address of the endpoint.
Expand All @@ -177,15 +177,15 @@ func (e protocolEndpoint) Supplier() string {
// It returns a map for efficient lookup, as the main/only consumer of this function uses
// the return value for selecting an endpoint for sending a relay.
func endpointsFromSession(
session sessiontypes.Session,
session *sessiontypes.Session,
// TODO_TECHDEBT(@adshmh): Refactor load testing logic to make it more visible.
//
// The only supplier allowed from the session.
// Used in Load Testing against a single RelayMiner.
allowedSupplierAddr string,
) (map[protocol.EndpointAddr]endpoint, error) {
sf := sdk.SessionFilter{
Session: &session,
Session: session,
}

// AllEndpoints will return a map of supplier address to a list of supplier endpoints.
Expand Down
5 changes: 2 additions & 3 deletions protocol/shannon/full_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

apptypes "github.com/pokt-network/poktroll/x/application/types"
servicetypes "github.com/pokt-network/poktroll/x/service/types"
sessiontypes "github.com/pokt-network/poktroll/x/session/types"
sharedtypes "github.com/pokt-network/poktroll/x/shared/types"
sdk "github.com/pokt-network/shannon-sdk"

Expand All @@ -27,7 +26,7 @@ type FullNode interface {
// GetSession returns the latest session matching the supplied service+app combination.
// Sessions are solely used for sending relays, and therefore only the latest session for any service+app combination is needed.
// Note: Shannon returns the latest session for a service+app combination if no blockHeight is provided.
GetSession(ctx context.Context, serviceID protocol.ServiceID, appAddr string) (sessiontypes.Session, error)
GetSession(ctx context.Context, serviceID protocol.ServiceID, appAddr string) (hydratedSession, error)

// GetSessionWithExtendedValidity implements session retrieval with support for
// Pocket Network's native "session grace period" business logic.
Expand All @@ -52,7 +51,7 @@ type FullNode interface {
// - https://dev.poktroll.com/protocol/governance/gov_params
// - https://dev.poktroll.com/protocol/primitives/claim_and_proof_lifecycle
// If within grace period of a session rollover, it may return the previous session.
GetSessionWithExtendedValidity(ctx context.Context, serviceID protocol.ServiceID, appAddr string) (sessiontypes.Session, error)
GetSessionWithExtendedValidity(ctx context.Context, serviceID protocol.ServiceID, appAddr string) (hydratedSession, error)

// GetSharedParams returns the shared module parameters from the blockchain.
GetSharedParams(ctx context.Context) (*sharedtypes.Params, error)
Expand Down
Loading