ssvlabs / ssv-spec

GNU General Public License v3.0
25 stars 22 forks source link

Message Validation #491

Open MatheusFranco99 opened 3 weeks ago

MatheusFranco99 commented 3 weeks ago

Overview

This PR updates the message validation module.

It adds a MessageValidator structure that implements the ValidatorForTopic function, as defined by the libp2p framework.

Its main validation function starts a chain of validation checks for the pub-sub, syntax, semantics, QBFT and duty logic rules.

Documentation and message rate estimation

The PR also updates the message validation and scoring documentation in p2p/SPEC.md and p2p/SCORING.md. The go code for the message rate estimation is added (along with tests) since this estimation is referenced by the scoring documentation.

Tests

This PR also adds tests for each implemented rule, as can be seen in the following list.

PubSub

Syntax validation

General semantics validation

Consensus semantics validation

Consensus QBFT logic validation

Consensus duty logic validation

Partial signature semantics validation

Partial signature duty logic validation

General duty logic validation

Wrong signature

Valid

alan-ssvlabs commented 1 week ago

Maybe p2p/SPEC.md needs some update at line 268-283 about Basic Validation

MatheusFranco99 commented 1 week ago

@alan-ssvlabs Indeed. Thanks!

MatheusFranco99 commented 1 week ago

@GalRogozinski @alan-ssvlabs

In the p2p/SCORING.md file I have a code snippet for the message rate estimation. What do you guys think of creating a file with this code? The fact that p2p scoring needs it may be enough reason to add it. Also, the SSV repo uses exactly this function.

MatheusFranco99 commented 1 week ago

@GalRogozinski @alan-ssvlabs Moved the msg estimation code to a go file and added some tests.