Skip to content

Enforce proper check of ParentAgregatedSeal during preprepare phase (1.5.x release) #1830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

hbandura
Copy link
Contributor

@hbandura hbandura commented Feb 2, 2022

Problem

During consensus, when a validator has to verify that a proposed block is valid, the validators are not checking the ParentAggregatedSeal. Thus, they can potentially accept an invalid block as valid.

Full Nodes during regular block syncing don't have the same problem, and thus reject the block. In a scenario with validators depending on proxies (full nodes) this also implies that after such a block, network connections between validators and proxies will break, thus the network will stall.

How?

To verify a block, validators have to check the header, but ignore the AggreatedSeal since this field is the result of consensus and will only be added as the final step of it.

To achieve this, backend.VerifyProposal() calls engine.VerifyHeader and it will mark the block as invalid if this call fails, unless the error is related to the AggregatedSeal. This is incorrect, since if engine.VerifyHeader() fails due to the missing AggregatedSeal it does not imply that the rest of the header is valid, just that the first error on it found is that.

In particular, engine.VerifyHeader() will not verify the ParentAggregatedSeal if AggreatedSeal is missing.

Fix

In this PR, instead of calling VerifyHeader we call a new function verifyHeaderFromProposal that checks that the AggregatedSeal's signature is empty, and checks all others fields. As expected from a consensus proposal.

This PR is applied on top of the 1.5.x version branch

@hbandura hbandura requested a review from a team as a code owner February 2, 2022 18:07
@hbandura hbandura requested review from mcortesi and 37ng and removed request for a team February 2, 2022 18:07
@piersy
Copy link
Contributor

piersy commented Feb 2, 2022

Coverage from tests in ./e2e_test/... for ./consensus/istanbul/... at commit 1bd6b18

coverage: 44.7% of statements across all listed packages
coverage:  54.1% of statements in consensus/istanbul
coverage:  45.0% of statements in consensus/istanbul/backend
coverage:   0.0% of statements in consensus/istanbul/backend/backendtest
coverage:  43.3% of statements in consensus/istanbul/backend/internal/db
coverage:  24.1% of statements in consensus/istanbul/backend/internal/enodes
coverage:  22.4% of statements in consensus/istanbul/backend/internal/replica
coverage:  63.9% of statements in consensus/istanbul/core
coverage:   0.0% of statements in consensus/istanbul/proxy
coverage:  75.3% of statements in consensus/istanbul/uptime
coverage: 100.0% of statements in consensus/istanbul/uptime/store
coverage:  51.8% of statements in consensus/istanbul/validator
coverage:  79.2% of statements in consensus/istanbul/validator/random
CommentID: 076f09b18d

@mcortesi
Copy link
Contributor

mcortesi commented Feb 2, 2022

This PR has been merged manually (git rebase on v1.5.x) to mantain the commit SHA that were already using during the emergency patch generation

@mcortesi mcortesi closed this Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants