validation

package
v0.33.35-find-trie-roo... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2024 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultNumberOfWorkers default number of workers for the inspector component.
	DefaultNumberOfWorkers = 5
	// DefaultControlMsgValidationInspectorQueueCacheSize is the default size of the inspect message queue.
	DefaultControlMsgValidationInspectorQueueCacheSize = 100
	// DefaultClusterPrefixedControlMsgsReceivedCacheSize is the default size of the cluster prefixed topics received record cache.
	DefaultClusterPrefixedControlMsgsReceivedCacheSize = 150
	// DefaultClusterPrefixedControlMsgsReceivedCacheDecay the default cache decay value for cluster prefixed topics received cached counters.
	DefaultClusterPrefixedControlMsgsReceivedCacheDecay = 0.99
)

Variables

This section is empty.

Functions

func IsDuplicateMessageIDErr added in v0.32.0

func IsDuplicateMessageIDErr(err error) bool

IsDuplicateMessageIDErr returns true if an error is DuplicateMessageIDErr.

func IsDuplicateTopicErr added in v0.32.0

func IsDuplicateTopicErr(err error) bool

IsDuplicateTopicErr returns true if an error is DuplicateTopicErr.

func IsErrActiveClusterIDsNotSet added in v0.31.0

func IsErrActiveClusterIDsNotSet(err error) bool

IsErrActiveClusterIDsNotSet returns true if an error is ErrActiveClusterIdsNotSet.

func IsErrUnstakedPeer added in v0.31.0

func IsErrUnstakedPeer(err error) bool

IsErrUnstakedPeer returns true if an error is ErrUnstakedPeer.

func IsIWantCacheMissThresholdErr added in v0.32.0

func IsIWantCacheMissThresholdErr(err error) bool

IsIWantCacheMissThresholdErr returns true if an error is IWantCacheMissThresholdErr

func IsIWantDuplicateMsgIDThresholdErr added in v0.32.0

func IsIWantDuplicateMsgIDThresholdErr(err error) bool

IsIWantDuplicateMsgIDThresholdErr returns true if an error is IWantDuplicateMsgIDThresholdErr

func IsInvalidRpcPublishMessagesErr added in v0.33.1

func IsInvalidRpcPublishMessagesErr(err error) bool

IsInvalidRpcPublishMessagesErr returns true if an error is InvalidRpcPublishMessagesErr.

Types

type ControlMsgValidationInspector

type ControlMsgValidationInspector struct {
	component.Component
	events.Noop
	// contains filtered or unexported fields
}

ControlMsgValidationInspector RPC message inspector that inspects control messages and performs some validation on them, when some validation rule is broken feedback is given via the Peer scoring notifier.

func NewControlMsgValidationInspector

func NewControlMsgValidationInspector(params *InspectorParams) (*ControlMsgValidationInspector, error)

NewControlMsgValidationInspector returns new ControlMsgValidationInspector Args:

  • *InspectorParams: params used to create the inspector.

Returns:

  • *ControlMsgValidationInspector: a new control message validation inspector.
  • error: an error if there is any error while creating the inspector. All errors are irrecoverable and unexpected.

func (*ControlMsgValidationInspector) ActiveClustersChanged added in v0.31.0

func (c *ControlMsgValidationInspector) ActiveClustersChanged(clusterIDList flow.ChainIDList)

ActiveClustersChanged consumes cluster ID update protocol events.

func (*ControlMsgValidationInspector) Inspect

func (c *ControlMsgValidationInspector) Inspect(from peer.ID, rpc *pubsub.RPC) error

Inspect is called by gossipsub upon reception of a rpc from a remote node. It creates a new InspectRPCRequest for the RPC to be inspected async by the worker pool. Args:

  • from: the sender.
  • rpc: the control message RPC.

Returns:

  • error: if a new inspect rpc request cannot be created, all errors returned are considered irrecoverable.

func (*ControlMsgValidationInspector) Name

Name returns the name of the rpc inspector.

func (*ControlMsgValidationInspector) Start added in v0.33.1

type DuplicateMessageIDErr added in v0.32.0

type DuplicateMessageIDErr struct {
	// contains filtered or unexported fields
}

DuplicateMessageIDErr error that indicates a duplicate message ID has been detected in a IHAVE or IWANT control message.

func NewDuplicateMessageIDErr added in v0.32.0

func NewDuplicateMessageIDErr(id string, count int, msgType p2pmsg.ControlMessageType) DuplicateMessageIDErr

NewDuplicateMessageIDErr returns a new DuplicateMessageIDErr. Args:

id: id of the message that is duplicated
count: the number of times the message ID has been duplicated
msgType: the control message type that the message ID was found in.

func (DuplicateMessageIDErr) Error added in v0.32.0

func (e DuplicateMessageIDErr) Error() string

type DuplicateTopicErr added in v0.32.0

type DuplicateTopicErr struct {
	// contains filtered or unexported fields
}

DuplicateTopicErr error that indicates a duplicate has been detected. This can be duplicate topic or message ID tracking.

func NewDuplicateTopicErr added in v0.31.0

func NewDuplicateTopicErr(topic string, count int, msgType p2pmsg.ControlMessageType) DuplicateTopicErr

NewDuplicateTopicErr returns a new DuplicateTopicErr. Args:

topic: the topic that is duplicated
count: the number of times the topic has been duplicated
msgType: the control message type that the topic was found in

Returns:

A new DuplicateTopicErr.

func (DuplicateTopicErr) Error added in v0.32.0

func (e DuplicateTopicErr) Error() string

type ErrActiveClusterIdsNotSet added in v0.31.0

type ErrActiveClusterIdsNotSet struct {
	// contains filtered or unexported fields
}

ErrActiveClusterIdsNotSet error that indicates a cluster prefixed control message has been received but the cluster IDs have not been set yet.

func NewActiveClusterIdsNotSetErr added in v0.31.0

func NewActiveClusterIdsNotSetErr(topic channels.Topic) ErrActiveClusterIdsNotSet

NewActiveClusterIdsNotSetErr returns a new ErrActiveClusterIdsNotSet.

func (ErrActiveClusterIdsNotSet) Error added in v0.31.0

type ErrUnstakedPeer added in v0.31.0

type ErrUnstakedPeer struct {
	// contains filtered or unexported fields
}

ErrUnstakedPeer error that indicates a cluster prefixed control message has been from an unstaked peer.

func NewUnstakedPeerErr added in v0.31.0

func NewUnstakedPeerErr(err error) ErrUnstakedPeer

NewUnstakedPeerErr returns a new ErrUnstakedPeer.

func (ErrUnstakedPeer) Error added in v0.31.0

func (e ErrUnstakedPeer) Error() string

type IWantCacheMissThresholdErr added in v0.32.0

type IWantCacheMissThresholdErr struct {
	// contains filtered or unexported fields
}

IWantCacheMissThresholdErr indicates that the amount of cache misses exceeds the allowed threshold.

func NewIWantCacheMissThresholdErr added in v0.32.0

func NewIWantCacheMissThresholdErr(cacheMissCount int, sampleSize uint, threshold int) IWantCacheMissThresholdErr

NewIWantCacheMissThresholdErr returns a new IWantCacheMissThresholdErr.

func (IWantCacheMissThresholdErr) Error added in v0.32.0

type IWantDuplicateMsgIDThresholdErr added in v0.32.0

type IWantDuplicateMsgIDThresholdErr struct {
	// contains filtered or unexported fields
}

IWantDuplicateMsgIDThresholdErr indicates that the amount of duplicate message ids exceeds the allowed threshold.

func NewIWantDuplicateMsgIDThresholdErr added in v0.32.0

func NewIWantDuplicateMsgIDThresholdErr(duplicates int, sampleSize uint, threshold int) IWantDuplicateMsgIDThresholdErr

NewIWantDuplicateMsgIDThresholdErr returns a new IWantDuplicateMsgIDThresholdErr.

func (IWantDuplicateMsgIDThresholdErr) Error added in v0.32.0

type InspectRPCRequest added in v0.32.0

type InspectRPCRequest struct {
	// Nonce adds random value so that when msg req is stored on hero store a unique ID can be created from the struct fields.
	Nonce []byte
	// Peer sender of the message.
	Peer peer.ID
	// contains filtered or unexported fields
}

InspectRPCRequest represents a short digest of an RPC control message. It is used for further message inspection by component workers.

func NewInspectRPCRequest added in v0.32.0

func NewInspectRPCRequest(from peer.ID, rpc *pubsub.RPC) (*InspectRPCRequest, error)

NewInspectRPCRequest returns a new *InspectRPCRequest.

type InspectorParams added in v0.33.1

type InspectorParams struct {
	// Logger the logger used by the inspector.
	Logger zerolog.Logger `validate:"required"`
	// SporkID the current spork ID.
	SporkID flow.Identifier `validate:"required"`
	// Config inspector configuration.
	Config *p2pconfig.RpcValidationInspector `validate:"required"`
	// Distributor gossipsub inspector notification distributor.
	Distributor p2p.GossipSubInspectorNotifDistributor `validate:"required"`
	// HeroCacheMetricsFactory the metrics factory.
	HeroCacheMetricsFactory metrics.HeroCacheMetricsFactory `validate:"required"`
	// IdProvider identity provider is used to get the flow identifier for a peer.
	IdProvider module.IdentityProvider `validate:"required"`
	// InspectorMetrics metrics for the validation inspector.
	InspectorMetrics module.GossipSubRpcValidationInspectorMetrics `validate:"required"`
	// RpcTracker tracker used to track iHave RPC's sent and last size.
	RpcTracker p2p.RpcControlTracking `validate:"required"`
	// NetworkingType the networking type of the node.
	NetworkingType network.NetworkingType `validate:"required"`
	// TopicOracle callback used to retrieve the current subscribed topics of the libp2p node.
	// It is set as a callback to avoid circular dependencies between the topic oracle and the inspector.
	TopicOracle func() p2p.TopicProvider `validate:"required"`
}

type InvalidRpcPublishMessagesErr added in v0.33.1

type InvalidRpcPublishMessagesErr struct {
	// contains filtered or unexported fields
}

InvalidRpcPublishMessagesErr error indicates that rpc publish message validation failed.

func NewInvalidRpcPublishMessagesErr added in v0.33.1

func NewInvalidRpcPublishMessagesErr(err error, count int) InvalidRpcPublishMessagesErr

NewInvalidRpcPublishMessagesErr returns a new InvalidRpcPublishMessagesErr.

func (InvalidRpcPublishMessagesErr) Error added in v0.33.1

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL