Documentation ¶
Index ¶
Constants ¶
const ( // StaleMessage is a misbehavior that is reported when an engine receives a message that is deemed stale based on the // local view of the engine. The decision to consider a message stale is up to the engine. StaleMessage network.Misbehavior = "misbehavior-stale-message" // ResourceIntensiveRequest is a misbehavior that is reported when an engine receives a request that takes an unreasonable amount // of resources by the engine to process, e.g., a request for a large number of blocks. The decision to consider a // request heavy is up to the engine. ResourceIntensiveRequest network.Misbehavior = "misbehavior-resource-intensive-request" // RedundantMessage is a misbehavior that is reported when an engine receives a message that is redundant, i.e., the // message is already known to the engine. The decision to consider a message redundant is up to the engine. RedundantMessage network.Misbehavior = "misbehavior-redundant-message" // UnsolicitedMessage is a misbehavior that is reported when an engine receives a message that is not solicited by the // engine. The decision to consider a message unsolicited is up to the engine. UnsolicitedMessage network.Misbehavior = "misbehavior-unsolicited-message" // InvalidMessage is a misbehavior that is reported when an engine receives a message that is invalid, i.e., // the message is not valid according to the engine's validation logic. The decision to consider a message invalid // is up to the engine. InvalidMessage network.Misbehavior = "misbehavior-invalid-message" // UnExpectedValidationError is a misbehavior that is reported when a validation error is encountered during message validation before the message // is processed by an engine. UnExpectedValidationError network.Misbehavior = "unexpected-validation-error" // UnknownMsgType is a misbehavior that is reported when a message of unknown type is received from a peer. UnknownMsgType network.Misbehavior = "unknown-message-type" // SenderEjected is a misbehavior that is reported when a message is received from an ejected peer. SenderEjected network.Misbehavior = "sender-ejected" UnauthorizedUnicastOnChannel network.Misbehavior = "unauthorized-unicast-on-channel" // UnAuthorizedSender is a misbehavior that is reported when a message is sent by an unauthorized role. UnAuthorizedSender network.Misbehavior = "unauthorized-sender" UnauthorizedPublishOnChannel network.Misbehavior = "unauthorized-pubsub-on-channel" )
Variables ¶
This section is empty.
Functions ¶
func AllMisbehaviorTypes ¶
func AllMisbehaviorTypes() []network.Misbehavior
Types ¶
type MisbehaviorReport ¶
type MisbehaviorReport struct {
// contains filtered or unexported fields
}
MisbehaviorReport is a report that is sent to the networking layer to penalize the misbehaving node. A MisbehaviorReport reports the misbehavior of a node on sending a message to the current node that appears valid based on the networking layer but is considered invalid by the current node based on the Flow protocol.
A MisbehaviorReport consists of a reason and a penalty. The reason is a string that describes the misbehavior. The penalty is a value that is deducted from the overall score of the misbehaving node. The score is decayed at each decay interval. If the overall penalty of the misbehaving node drops below the disallow-listing threshold, the node is reported to be disallow-listed by the networking layer, i.e., existing connections to the node are closed and the node is no longer allowed to connect till its penalty is decayed back to zero.
func NewMisbehaviorReport ¶
func NewMisbehaviorReport(misbehavingId flow.Identifier, reason network.Misbehavior, opts ...MisbehaviorReportOpt) (*MisbehaviorReport, error)
NewMisbehaviorReport creates a new misbehavior report with the given reason and options. If no options are provided, the default penalty value is used. The returned error by this function indicates that the report is not created. In BFT setup, the returned error should be treated as a fatal error. The default penalty value is 0.01 * misbehaviorDisallowListingThreshold = -86.4
func (MisbehaviorReport) OriginId ¶
func (r MisbehaviorReport) OriginId() flow.Identifier
OriginId returns the ID of the misbehaving node.
func (MisbehaviorReport) Penalty ¶
func (r MisbehaviorReport) Penalty() float64
Penalty returns the penalty value of the misbehavior.
func (MisbehaviorReport) Reason ¶
func (r MisbehaviorReport) Reason() network.Misbehavior
Reason returns the reason of the misbehavior.
type MisbehaviorReportOpt ¶
type MisbehaviorReportOpt func(r *MisbehaviorReport) error
MisbehaviorReportOpt is an option that can be used to configure a misbehavior report.
func WithPenaltyAmplification ¶
func WithPenaltyAmplification(v float64) MisbehaviorReportOpt
WithPenaltyAmplification returns an option that can be used to amplify the penalty value. The penalty value is multiplied by the given value. The value should be between 1-100. If the value is not in the range, an error is returned. The returned error by this option indicates that the option is not applied. In BFT setup, the returned error should be treated as a fatal error.
type SpamRecordCache ¶
type SpamRecordCache interface { // Adjust applies the given adjust function to the spam record of the given origin id. // Returns the Penalty value of the record after the adjustment. // It returns an error if the adjustFunc returns an error or if the record does not exist. // Assuming that adjust is always called when the record exists, the error is irrecoverable and indicates a bug. Adjust(originId flow.Identifier, adjustFunc model.RecordAdjustFunc) (float64, error) // Identities returns the list of identities of the nodes that have a spam record in the cache. Identities() []flow.Identifier // Remove removes the spam record of the given origin id from the cache. // Returns true if the record is removed, false otherwise (i.e., the record does not exist). Remove(originId flow.Identifier) bool // Get returns the spam record of the given origin id. // Returns the record and true if the record exists, nil and false otherwise. // Args: // - originId: the origin id of the spam record. // Returns: // - the record and true if the record exists, nil and false otherwise. // Note that the returned record is a copy of the record in the cache (we do not want the caller to modify the record). Get(originId flow.Identifier) (*model.ProtocolSpamRecord, bool) // Size returns the number of records in the cache. Size() uint }
SpamRecordCache is a cache of spam records for the ALSP module. It is used to keep track of the spam records of the nodes that have been reported for spamming.