validation

package
v0.35.0-crescendo-prev... Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	RPCInspectionDisabledWarning     = "rpc inspection disabled for all control message types, skipping inspection"
	GraftInspectionDisabledWarning   = "rpc graft inspection disabled skipping"
	PruneInspectionDisabledWarning   = "rpc prune inspection disabled skipping"
	IWantInspectionDisabledWarning   = "rpc iwant inspection disabled skipping"
	IHaveInspectionDisabledWarning   = "rpc ihave inspection disabled skipping"
	PublishInspectionDisabledWarning = "rpc publish message inspection disabled skipping"

	RPCTruncationDisabledWarning            = "rpc truncation disabled for all control message types, skipping truncation"
	GraftTruncationDisabledWarning          = "rpc graft truncation disabled skipping"
	PruneTruncationDisabledWarning          = "rpc prune truncation disabled skipping"
	IHaveTruncationDisabledWarning          = "rpc ihave truncation disabled skipping"
	IHaveMessageIDTruncationDisabledWarning = "ihave message ids truncation disabled skipping"
	IWantTruncationDisabledWarning          = "rpc iwant truncation disabled skipping"
	IWantMessageIDTruncationDisabledWarning = "iwant message ids truncation disabled skipping"
)

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 IsDuplicateTopicIDThresholdExceeded added in v0.33.30

func IsDuplicateTopicIDThresholdExceeded(err error) bool

IsDuplicateTopicIDThresholdExceeded returns true if an error is DuplicateTopicIDThresholdExceeded

func IsErrActiveClusterIDsNotSet added in v0.31.0

func IsErrActiveClusterIDsNotSet(err error) bool

IsErrActiveClusterIDsNotSet returns true if an error is ErrActiveClusterIdsNotSet.

func IsErrEjectedPeer added in v0.33.30

func IsErrEjectedPeer(err error) bool

IsErrEjectedPeer returns true if an error is ErrEjectedPeer.

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.

func IsInvalidTopicIDThresholdExceeded added in v0.33.30

func IsInvalidTopicIDThresholdExceeded(err error) bool

IsInvalidTopicIDThresholdExceeded returns true if an error is InvalidTopicIDThresholdExceeded.

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 DuplicateTopicIDThresholdExceeded added in v0.33.30

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

DuplicateTopicIDThresholdExceeded indicates that the number of duplicate topic IDs exceeds the allowed threshold.

func NewDuplicateTopicIDThresholdExceeded added in v0.33.30

func NewDuplicateTopicIDThresholdExceeded(duplicates int, sampleSize int, threshold int) DuplicateTopicIDThresholdExceeded

NewDuplicateTopicIDThresholdExceeded returns a new DuplicateTopicIDThresholdExceeded error.

func (DuplicateTopicIDThresholdExceeded) Error added in v0.33.30

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 ErrEjectedPeer added in v0.33.30

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

ErrEjectedPeer error that indicates a cluster prefixed control message has been received from an ejected peer.

func NewEjectedPeerErr added in v0.33.30

func NewEjectedPeerErr(pid peer.ID) ErrEjectedPeer

NewEjectedPeerErr returns a new ErrEjectedPeer.

func (ErrEjectedPeer) Error added in v0.33.30

func (e ErrEjectedPeer) Error() string

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(pid peer.ID) 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"`
	// 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"`

	// InvalidControlMessageNotificationConsumer the consumer that will be notified when a misbehavior is detected upon inspection of an RPC.
	// For each RPC, at most one notification is sent to the consumer.
	// Each notification acts as a penalty to the peer's score.
	InvalidControlMessageNotificationConsumer p2p.GossipSubInvCtrlMsgNotifConsumer `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

type InvalidTopicIDThresholdExceeded added in v0.33.30

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

InvalidTopicIDThresholdExceeded indicates that the number of invalid topic IDs exceeds the allowed threshold.

func NewInvalidTopicIDThresholdExceeded added in v0.33.30

func NewInvalidTopicIDThresholdExceeded(invalidCount, threshold int) InvalidTopicIDThresholdExceeded

NewInvalidTopicIDThresholdExceeded returns a new InvalidTopicIDThresholdExceeded error.

func (InvalidTopicIDThresholdExceeded) Error added in v0.33.30

Jump to

Keyboard shortcuts

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