distinguish local message validation failures from remote
This commit is contained in:
parent
5aa90b0478
commit
094baf8aa9
@ -546,7 +546,8 @@ func (mv *MessageValidator) Validate(ctx context.Context, pid peer.ID, msg *pubs
|
|||||||
log.Debugf("failed to add message from network to message pool (From: %s, To: %s, Nonce: %d, Value: %s): %s", m.Message.From, m.Message.To, m.Message.Nonce, types.FIL(m.Message.Value), err)
|
log.Debugf("failed to add message from network to message pool (From: %s, To: %s, Nonce: %d, Value: %s): %s", m.Message.From, m.Message.To, m.Message.Nonce, types.FIL(m.Message.Value), err)
|
||||||
ctx, _ = tag.New(
|
ctx, _ = tag.New(
|
||||||
ctx,
|
ctx,
|
||||||
tag.Insert(metrics.FailureType, "add"),
|
tag.Upsert(metrics.FailureType, "add"),
|
||||||
|
tag.Upsert(metrics.Local, "false"),
|
||||||
)
|
)
|
||||||
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
||||||
switch {
|
switch {
|
||||||
@ -565,36 +566,60 @@ func (mv *MessageValidator) Validate(ctx context.Context, pid peer.ID, msg *pubs
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (mv *MessageValidator) validateLocalMessage(ctx context.Context, msg *pubsub.Message) pubsub.ValidationResult {
|
func (mv *MessageValidator) validateLocalMessage(ctx context.Context, msg *pubsub.Message) pubsub.ValidationResult {
|
||||||
|
ctx, _ = tag.New(
|
||||||
|
ctx,
|
||||||
|
tag.Upsert(metrics.Local, "true"),
|
||||||
|
)
|
||||||
// do some lightweight validation
|
// do some lightweight validation
|
||||||
stats.Record(ctx, metrics.MessagePublished.M(1))
|
stats.Record(ctx, metrics.MessagePublished.M(1))
|
||||||
|
|
||||||
m, err := types.DecodeSignedMessage(msg.Message.GetData())
|
m, err := types.DecodeSignedMessage(msg.Message.GetData())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("failed to decode local message: %s", err)
|
log.Warnf("failed to decode local message: %s", err)
|
||||||
|
ctx, _ = tag.New(
|
||||||
|
ctx,
|
||||||
|
tag.Upsert(metrics.FailureType, "decode"),
|
||||||
|
)
|
||||||
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
||||||
return pubsub.ValidationIgnore
|
return pubsub.ValidationIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Size() > 32*1024 {
|
if m.Size() > 32*1024 {
|
||||||
log.Warnf("local message is too large! (%dB)", m.Size())
|
log.Warnf("local message is too large! (%dB)", m.Size())
|
||||||
|
ctx, _ = tag.New(
|
||||||
|
ctx,
|
||||||
|
tag.Upsert(metrics.FailureType, "oversize"),
|
||||||
|
)
|
||||||
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
||||||
return pubsub.ValidationIgnore
|
return pubsub.ValidationIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
if m.Message.To == address.Undef {
|
if m.Message.To == address.Undef {
|
||||||
log.Warn("local message has invalid destination address")
|
log.Warn("local message has invalid destination address")
|
||||||
|
ctx, _ = tag.New(
|
||||||
|
ctx,
|
||||||
|
tag.Upsert(metrics.FailureType, "undef-addr"),
|
||||||
|
)
|
||||||
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
||||||
return pubsub.ValidationIgnore
|
return pubsub.ValidationIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
if !m.Message.Value.LessThan(types.TotalFilecoinInt) {
|
if !m.Message.Value.LessThan(types.TotalFilecoinInt) {
|
||||||
log.Warnf("local messages has too high value: %s", m.Message.Value)
|
log.Warnf("local messages has too high value: %s", m.Message.Value)
|
||||||
|
ctx, _ = tag.New(
|
||||||
|
ctx,
|
||||||
|
tag.Upsert(metrics.FailureType, "value-too-high"),
|
||||||
|
)
|
||||||
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
||||||
return pubsub.ValidationIgnore
|
return pubsub.ValidationIgnore
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mv.mpool.VerifyMsgSig(m); err != nil {
|
if err := mv.mpool.VerifyMsgSig(m); err != nil {
|
||||||
log.Warnf("signature verification failed for local message: %s", err)
|
log.Warnf("signature verification failed for local message: %s", err)
|
||||||
|
ctx, _ = tag.New(
|
||||||
|
ctx,
|
||||||
|
tag.Upsert(metrics.FailureType, "verify-sig"),
|
||||||
|
)
|
||||||
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
stats.Record(ctx, metrics.MessageValidationFailure.M(1))
|
||||||
return pubsub.ValidationIgnore
|
return pubsub.ValidationIgnore
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ var (
|
|||||||
Commit, _ = tag.NewKey("commit")
|
Commit, _ = tag.NewKey("commit")
|
||||||
PeerID, _ = tag.NewKey("peer_id")
|
PeerID, _ = tag.NewKey("peer_id")
|
||||||
FailureType, _ = tag.NewKey("failure_type")
|
FailureType, _ = tag.NewKey("failure_type")
|
||||||
|
Local, _ = tag.NewKey("local")
|
||||||
MessageFrom, _ = tag.NewKey("message_from")
|
MessageFrom, _ = tag.NewKey("message_from")
|
||||||
MessageTo, _ = tag.NewKey("message_to")
|
MessageTo, _ = tag.NewKey("message_to")
|
||||||
MessageNonce, _ = tag.NewKey("message_nonce")
|
MessageNonce, _ = tag.NewKey("message_nonce")
|
||||||
@ -30,7 +31,7 @@ var (
|
|||||||
LotusInfo = stats.Int64("info", "Arbitrary counter to tag lotus info to", stats.UnitDimensionless)
|
LotusInfo = stats.Int64("info", "Arbitrary counter to tag lotus info to", stats.UnitDimensionless)
|
||||||
ChainNodeHeight = stats.Int64("chain/node_height", "Current Height of the node", stats.UnitDimensionless)
|
ChainNodeHeight = stats.Int64("chain/node_height", "Current Height of the node", stats.UnitDimensionless)
|
||||||
ChainNodeWorkerHeight = stats.Int64("chain/node_worker_height", "Current Height of workers on the node", stats.UnitDimensionless)
|
ChainNodeWorkerHeight = stats.Int64("chain/node_worker_height", "Current Height of workers on the node", stats.UnitDimensionless)
|
||||||
MessagePublished = stats.Int64("message/pubished", "Counter for total locally published messages", stats.UnitDimensionless)
|
MessagePublished = stats.Int64("message/published", "Counter for total locally published messages", stats.UnitDimensionless)
|
||||||
MessageReceived = stats.Int64("message/received", "Counter for total received messages", stats.UnitDimensionless)
|
MessageReceived = stats.Int64("message/received", "Counter for total received messages", stats.UnitDimensionless)
|
||||||
MessageValidationFailure = stats.Int64("message/failure", "Counter for message validation failures", stats.UnitDimensionless)
|
MessageValidationFailure = stats.Int64("message/failure", "Counter for message validation failures", stats.UnitDimensionless)
|
||||||
MessageValidationSuccess = stats.Int64("message/success", "Counter for message validation successes", stats.UnitDimensionless)
|
MessageValidationSuccess = stats.Int64("message/success", "Counter for message validation successes", stats.UnitDimensionless)
|
||||||
@ -89,7 +90,7 @@ var (
|
|||||||
MessageValidationFailureView = &view.View{
|
MessageValidationFailureView = &view.View{
|
||||||
Measure: MessageValidationFailure,
|
Measure: MessageValidationFailure,
|
||||||
Aggregation: view.Count(),
|
Aggregation: view.Count(),
|
||||||
TagKeys: []tag.Key{FailureType},
|
TagKeys: []tag.Key{FailureType, Local},
|
||||||
}
|
}
|
||||||
MessageValidationSuccessView = &view.View{
|
MessageValidationSuccessView = &view.View{
|
||||||
Measure: MessageValidationSuccess,
|
Measure: MessageValidationSuccess,
|
||||||
|
Loading…
Reference in New Issue
Block a user