ssvlabs / ssv-spec

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

Audit Suggestion 5: Unnecessary checks increase complexity #355

Open MatheusFranco99 opened 7 months ago

MatheusFranco99 commented 7 months ago

Overview

We changed the isProposalJustification function according to the QBFT formal specification (Audit suggestion 5).

To compare the changes, follow up the QBFT formal spec isProposalJustification and validRoundChange functions.

Basically, we used to:

Now, we:

Dependency

This PR is built upon the Fix - Misaligned terms PR's branch.

Discussion topics

Performance implications

All times are in milliseconds.

Max processing time for the Proposal message

Round 1 Round 2 Round 3
Old 1.5 18 18
New 1.5 8 8

Max processing time for a consensus round

1st round 2nd round 3rd round
Old 13 64 64
New 13 44 44

The difference is 20ms (not 10ms as one could expect) because, once a quorum of Round-Change messages is received, the isReceivedProposalJustification function is called.

Namely, look at the break-down times of each phase for round 2:

Round-Changes Proposal Prepares Commits
Old 4, 9, 21 18 1, 1, 1, 1 1, 1, 1, 1
New 4, 9, 11 8 1, 1, 1, 1 1, 1, 1, 1

Tests

In the following, we list existing and added tests for the proposal phase.

The existing tests are listed for one to check the test coverage.

Valid

Existing:

Proposal fields

Message{
        MsgType(ProposalMsgType),
        Height,
        Round,
        Identifier,
        Root,
        RoundChangeJustification,
        ProposalJustification,
    }
SignedMessage{
        Signature,
        Signers([]types.OperatorID{state.Share.OperatorID}),
        Message,
        FullData,
    }

Existing:

Added:

Message time or multiplicity

Existing:

Justification - Quorum checks

Existing:

Justification - Logic

Existing:

Added: