validation

package
v0.32.11-verification-... Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: AGPL-3.0 Imports: 24 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

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(ctx irrecoverable.SignalerContext,
	logger zerolog.Logger,
	sporkID flow.Identifier,
	config *p2pconf.GossipSubRPCValidationInspectorConfigs,
	distributor p2p.GossipSubInspectorNotifDistributor,
	inspectMsgQueueCacheCollector module.HeroCacheMetrics,
	clusterPrefixedCacheCollector module.HeroCacheMetrics,
	idProvider module.IdentityProvider,
	inspectorMetrics module.GossipSubRpcValidationInspectorMetrics,
	rpcTracker p2p.RpcControlTracking) (*ControlMsgValidationInspector, error)

NewControlMsgValidationInspector returns new ControlMsgValidationInspector Args:

  • logger: the logger used by the inspector.
  • sporkID: the current spork ID.
  • config: inspector configuration.
  • distributor: gossipsub inspector notification distributor.
  • clusterPrefixedCacheCollector: metrics collector for the underlying cluster prefix received tracker cache.
  • idProvider: identity provider is used to get the flow identifier for a peer.

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.

func (*ControlMsgValidationInspector) Name

Name returns the name of the rpc inspector.

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, msgType p2pmsg.ControlMessageType) DuplicateMessageIDErr

NewDuplicateMessageIDErr returns a new DuplicateMessageIDErr.

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, msgType p2pmsg.ControlMessageType) DuplicateTopicErr

NewDuplicateTopicErr 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 float64) 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 float64) 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.

Jump to

Keyboard shortcuts

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